dsh-thoughtdag 0.5.9 → 0.5.10
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-app/assets/{canonical-BuO7_FJb.js → canonical-wWV9jbzN.js} +2 -2
- package/dist-app/assets/{canvas-record-D3HdLWps.js → canvas-record-BHE3oU8V.js} +1 -1
- package/dist-app/assets/{claude-code-session-DA4UoHlf.js → claude-code-session-DNu1noFg.js} +1 -1
- package/dist-app/assets/{codex-session-CTdwdWhJ.js → codex-session-tfRW8ANZ.js} +1 -1
- package/dist-app/assets/{dsh-session-4Ul6Mxx8.js → dsh-session-B5EgVXLB.js} +1 -1
- package/dist-app/assets/{experiment-loop-t0sYsW2J.js → experiment-loop-Dv6KJPhf.js} +1 -1
- package/dist-app/assets/{http-bridge-DOGmFOH2.js → http-bridge-DOG0Sv0E.js} +1 -1
- package/dist-app/assets/{index-BbbLhjvs.js → index-BRdlgS3c.js} +3 -3
- package/dist-app/assets/{index-DYL_9PJ-.js → index-BrpB22PP.js} +1 -1
- package/dist-app/assets/{index-DpEbRp_J.js → index-CSvW8Pqz.js} +1 -1
- package/dist-app/assets/{index-CGGP8_QX.js → index-Du6_AuUF.js} +16 -16
- package/dist-app/assets/{pi-session-CYGbudh0.js → pi-session-BxEhSP49.js} +1 -1
- package/dist-app/assets/{sensitive-scan-C8VYATus.js → sensitive-scan-CUWgeb_A.js} +1 -1
- package/dist-app/assets/{session-handoff-AggmklDT.js → session-handoff-BPugrCrq.js} +2 -2
- package/dist-app/assets/{shared-DSCz0Bq4.js → shared-BHozYtdN.js} +1 -1
- package/dist-app/assets/{turndown-plugin-gfm.cjs-DwpDMrH3.js → turndown-plugin-gfm.cjs-B39qaw5-.js} +1 -1
- package/dist-app/assets/{update-check-KJ2ZKsng.js → update-check-CLgVgdNf.js} +1 -1
- package/dist-app/index.html +1 -1
- package/lib/why.mjs +5 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/claude-code-session-DNu1noFg.js","assets/shared-BHozYtdN.js","assets/codex-session-tfRW8ANZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function a(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();const GO="modulepreload",YO=function(e){return"/thoughtdag/"+e},N5={},ft=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),u=o?.nonce||o?.getAttribute("nonce");r=d(n.map(h=>{if(h=YO(h),h in N5)return;N5[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const x=document.createElement("link");if(x.rel=m?"stylesheet":GO,m||(x.as="script"),x.crossOrigin="",x.href=h,u&&x.setAttribute("nonce",u),document.head.appendChild(x),m)return new Promise((b,y)=>{x.addEventListener("load",b),x.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(o){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=o,window.dispatchEvent(u),!u.defaultPrevented)throw o}return r.then(o=>{for(const u of o||[])u.status==="rejected"&&s(u.reason);return t().catch(s)})};var Oue=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function D0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Due(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var G1={exports:{}},bd={};var A5;function KO(){if(A5)return bd;A5=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:o,ref:r!==void 0?r:null,props:s}}return bd.Fragment=t,bd.jsx=n,bd.jsxs=n,bd}var C5;function XO(){return C5||(C5=1,G1.exports=KO()),G1.exports}var l=XO(),Y1={exports:{}},an={};var _5;function QO(){if(_5)return an;_5=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(G){return G===null||typeof G!="object"?null:(G=x&&G[x]||G["@@iterator"],typeof G=="function"?G:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,E={};function v(G,J,K){this.props=G,this.context=J,this.refs=E,this.updater=K||y}v.prototype.isReactComponent={},v.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},v.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function A(){}A.prototype=v.prototype;function T(G,J,K){this.props=G,this.context=J,this.refs=E,this.updater=K||y}var C=T.prototype=new A;C.constructor=T,w(C,v.prototype),C.isPureReactComponent=!0;var I=Array.isArray;function O(){}var _={H:null,A:null,T:null,S:null},S=Object.prototype.hasOwnProperty;function z(G,J,K){var ee=K.ref;return{$$typeof:e,type:G,key:J,ref:ee!==void 0?ee:null,props:K}}function V(G,J){return z(G.type,J,G.props)}function P(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function L(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(K){return J[K]})}var Y=/\/+/g;function q(G,J){return typeof G=="object"&&G!==null&&G.key!=null?L(""+G.key):J.toString(36)}function B(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(O,O):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function j(G,J,K,ee,ue){var pe=typeof G;(pe==="undefined"||pe==="boolean")&&(G=null);var be=!1;if(G===null)be=!0;else switch(pe){case"bigint":case"string":case"number":be=!0;break;case"object":switch(G.$$typeof){case e:case t:be=!0;break;case m:return be=G._init,j(be(G._payload),J,K,ee,ue)}}if(be)return ue=ue(G),be=ee===""?"."+q(G,0):ee,I(ue)?(K="",be!=null&&(K=be.replace(Y,"$&/")+"/"),j(ue,J,K,"",function(Ce){return Ce})):ue!=null&&(P(ue)&&(ue=V(ue,K+(ue.key==null||G&&G.key===ue.key?"":(""+ue.key).replace(Y,"$&/")+"/")+be)),J.push(ue)),1;be=0;var ae=ee===""?".":ee+":";if(I(G))for(var xe=0;xe<G.length;xe++)ee=G[xe],pe=ae+q(ee,xe),be+=j(ee,J,K,pe,ue);else if(xe=b(G),typeof xe=="function")for(G=xe.call(G),xe=0;!(ee=G.next()).done;)ee=ee.value,pe=ae+q(ee,xe++),be+=j(ee,J,K,pe,ue);else if(pe==="object"){if(typeof G.then=="function")return j(B(G),J,K,ee,ue);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return be}function $(G,J,K){if(G==null)return G;var ee=[],ue=0;return j(G,ee,"","",function(pe){return J.call(K,pe,ue++)}),ee}function X(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(K){(G._status===0||G._status===-1)&&(G._status=1,G._result=K)},function(K){(G._status===0||G._status===-1)&&(G._status=2,G._result=K)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._result.default;throw G._result}var Q=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var J=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(J))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},F={map:$,forEach:function(G,J,K){$(G,function(){J.apply(this,arguments)},K)},count:function(G){var J=0;return $(G,function(){J++}),J},toArray:function(G){return $(G,function(J){return J})||[]},only:function(G){if(!P(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return an.Activity=p,an.Children=F,an.Component=v,an.Fragment=n,an.Profiler=r,an.PureComponent=T,an.StrictMode=a,an.Suspense=d,an.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,an.__COMPILER_RUNTIME={__proto__:null,c:function(G){return _.H.useMemoCache(G)}},an.cache=function(G){return function(){return G.apply(null,arguments)}},an.cacheSignal=function(){return null},an.cloneElement=function(G,J,K){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var ee=w({},G.props),ue=G.key;if(J!=null)for(pe in J.key!==void 0&&(ue=""+J.key),J)!S.call(J,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&J.ref===void 0||(ee[pe]=J[pe]);var pe=arguments.length-2;if(pe===1)ee.children=K;else if(1<pe){for(var be=Array(pe),ae=0;ae<pe;ae++)be[ae]=arguments[ae+2];ee.children=be}return z(G.type,ue,ee)},an.createContext=function(G){return G={$$typeof:o,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:s,_context:G},G},an.createElement=function(G,J,K){var ee,ue={},pe=null;if(J!=null)for(ee in J.key!==void 0&&(pe=""+J.key),J)S.call(J,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(ue[ee]=J[ee]);var be=arguments.length-2;if(be===1)ue.children=K;else if(1<be){for(var ae=Array(be),xe=0;xe<be;xe++)ae[xe]=arguments[xe+2];ue.children=ae}if(G&&G.defaultProps)for(ee in be=G.defaultProps,be)ue[ee]===void 0&&(ue[ee]=be[ee]);return z(G,pe,ue)},an.createRef=function(){return{current:null}},an.forwardRef=function(G){return{$$typeof:u,render:G}},an.isValidElement=P,an.lazy=function(G){return{$$typeof:m,_payload:{_status:-1,_result:G},_init:X}},an.memo=function(G,J){return{$$typeof:h,type:G,compare:J===void 0?null:J}},an.startTransition=function(G){var J=_.T,K={};_.T=K;try{var ee=G(),ue=_.S;ue!==null&&ue(K,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(O,Q)}catch(pe){Q(pe)}finally{J!==null&&K.types!==null&&(J.types=K.types),_.T=J}},an.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},an.use=function(G){return _.H.use(G)},an.useActionState=function(G,J,K){return _.H.useActionState(G,J,K)},an.useCallback=function(G,J){return _.H.useCallback(G,J)},an.useContext=function(G){return _.H.useContext(G)},an.useDebugValue=function(){},an.useDeferredValue=function(G,J){return _.H.useDeferredValue(G,J)},an.useEffect=function(G,J){return _.H.useEffect(G,J)},an.useEffectEvent=function(G){return _.H.useEffectEvent(G)},an.useId=function(){return _.H.useId()},an.useImperativeHandle=function(G,J,K){return _.H.useImperativeHandle(G,J,K)},an.useInsertionEffect=function(G,J){return _.H.useInsertionEffect(G,J)},an.useLayoutEffect=function(G,J){return _.H.useLayoutEffect(G,J)},an.useMemo=function(G,J){return _.H.useMemo(G,J)},an.useOptimistic=function(G,J){return _.H.useOptimistic(G,J)},an.useReducer=function(G,J,K){return _.H.useReducer(G,J,K)},an.useRef=function(G){return _.H.useRef(G)},an.useState=function(G){return _.H.useState(G)},an.useSyncExternalStore=function(G,J,K){return _.H.useSyncExternalStore(G,J,K)},an.useTransition=function(){return _.H.useTransition()},an.version="19.2.4",an}var M5;function R0(){return M5||(M5=1,Y1.exports=QO()),Y1.exports}var D=R0();const Rd=D0(D);var K1={exports:{}},yd={},X1={exports:{}},Q1={};var I5;function ZO(){return I5||(I5=1,(function(e){function t(j,$){var X=j.length;j.push($);e:for(;0<X;){var Q=X-1>>>1,F=j[Q];if(0<r(F,$))j[Q]=$,j[X]=F,X=Q;else break e}}function n(j){return j.length===0?null:j[0]}function a(j){if(j.length===0)return null;var $=j[0],X=j.pop();if(X!==$){j[0]=X;e:for(var Q=0,F=j.length,G=F>>>1;Q<G;){var J=2*(Q+1)-1,K=j[J],ee=J+1,ue=j[ee];if(0>r(K,X))ee<F&&0>r(ue,K)?(j[Q]=ue,j[ee]=X,Q=ee):(j[Q]=K,j[J]=X,Q=J);else if(ee<F&&0>r(ue,X))j[Q]=ue,j[ee]=X,Q=ee;else break e}}return $}function r(j,$){var X=j.sortIndex-$.sortIndex;return X!==0?X:j.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,u=o.now();e.unstable_now=function(){return o.now()-u}}var d=[],h=[],m=1,p=null,x=3,b=!1,y=!1,w=!1,E=!1,v=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function C(j){for(var $=n(h);$!==null;){if($.callback===null)a(h);else if($.startTime<=j)a(h),$.sortIndex=$.expirationTime,t(d,$);else break;$=n(h)}}function I(j){if(w=!1,C(j),!y)if(n(d)!==null)y=!0,O||(O=!0,L());else{var $=n(h);$!==null&&B(I,$.startTime-j)}}var O=!1,_=-1,S=5,z=-1;function V(){return E?!0:!(e.unstable_now()-z<S)}function P(){if(E=!1,O){var j=e.unstable_now();z=j;var $=!0;try{e:{y=!1,w&&(w=!1,A(_),_=-1),b=!0;var X=x;try{t:{for(C(j),p=n(d);p!==null&&!(p.expirationTime>j&&V());){var Q=p.callback;if(typeof Q=="function"){p.callback=null,x=p.priorityLevel;var F=Q(p.expirationTime<=j);if(j=e.unstable_now(),typeof F=="function"){p.callback=F,C(j),$=!0;break t}p===n(d)&&a(d),C(j)}else a(d);p=n(d)}if(p!==null)$=!0;else{var G=n(h);G!==null&&B(I,G.startTime-j),$=!1}}break e}finally{p=null,x=X,b=!1}$=void 0}}finally{$?L():O=!1}}}var L;if(typeof T=="function")L=function(){T(P)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,q=Y.port2;Y.port1.onmessage=P,L=function(){q.postMessage(null)}}else L=function(){v(P,0)};function B(j,$){_=v(function(){j(e.unstable_now())},$)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):S=0<j?Math.floor(1e3/j):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(j){switch(x){case 1:case 2:case 3:var $=3;break;default:$=x}var X=x;x=$;try{return j()}finally{x=X}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(j,$){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var X=x;x=j;try{return $()}finally{x=X}},e.unstable_scheduleCallback=function(j,$,X){var Q=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Q+X:Q):X=Q,j){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=X+F,j={id:m++,callback:$,priorityLevel:j,startTime:X,expirationTime:F,sortIndex:-1},X>Q?(j.sortIndex=X,t(h,j),n(d)===null&&j===n(h)&&(w?(A(_),_=-1):w=!0,B(I,X-Q))):(j.sortIndex=F,t(d,j),y||b||(y=!0,O||(O=!0,L()))),j},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(j){var $=x;return function(){var X=x;x=$;try{return j.apply(this,arguments)}finally{x=X}}}})(Q1)),Q1}var O5;function JO(){return O5||(O5=1,X1.exports=ZO()),X1.exports}var Z1={exports:{}},rr={};var D5;function eD(){if(D5)return rr;D5=1;var e=R0();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function s(d,h,m){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:p==null?null:""+p,children:d,containerInfo:h,implementation:m}}var o=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return rr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,rr.createPortal=function(d,h){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return s(d,h,null,m)},rr.flushSync=function(d){var h=o.T,m=a.p;try{if(o.T=null,a.p=2,d)return d()}finally{o.T=h,a.p=m,a.d.f()}},rr.preconnect=function(d,h){typeof d=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(d,h))},rr.prefetchDNS=function(d){typeof d=="string"&&a.d.D(d)},rr.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var m=h.as,p=u(m,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,b=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?a.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:p,integrity:x,fetchPriority:b}):m==="script"&&a.d.X(d,{crossOrigin:p,integrity:x,fetchPriority:b,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},rr.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=u(h.as,h.crossOrigin);a.d.M(d,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(d)},rr.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,p=u(m,h.crossOrigin);a.d.L(d,m,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},rr.preloadModule=function(d,h){if(typeof d=="string")if(h){var m=u(h.as,h.crossOrigin);a.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(d)},rr.requestFormReset=function(d){a.d.r(d)},rr.unstable_batchedUpdates=function(d,h){return d(h)},rr.useFormState=function(d,h,m){return o.H.useFormState(d,h,m)},rr.useFormStatus=function(){return o.H.useHostTransitionStatus()},rr.version="19.2.4",rr}var R5;function VT(){if(R5)return Z1.exports;R5=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Z1.exports=eD(),Z1.exports}var j5;function tD(){if(j5)return yd;j5=1;var e=JO(),t=R0(),n=VT();function a(i){var c="https://react.dev/errors/"+i;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+i+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function s(i){var c=i,f=i;if(i.alternate)for(;c.return;)c=c.return;else{i=c;do c=i,(c.flags&4098)!==0&&(f=c.return),i=c.return;while(i)}return c.tag===3?f:null}function o(i){if(i.tag===13){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function u(i){if(i.tag===31){var c=i.memoizedState;if(c===null&&(i=i.alternate,i!==null&&(c=i.memoizedState)),c!==null)return c.dehydrated}return null}function d(i){if(s(i)!==i)throw Error(a(188))}function h(i){var c=i.alternate;if(!c){if(c=s(i),c===null)throw Error(a(188));return c!==i?null:i}for(var f=i,g=c;;){var k=f.return;if(k===null)break;var N=k.alternate;if(N===null){if(g=k.return,g!==null){f=g;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===f)return d(k),i;if(N===g)return d(k),c;N=N.sibling}throw Error(a(188))}if(f.return!==g.return)f=k,g=N;else{for(var W=!1,te=k.child;te;){if(te===f){W=!0,f=k,g=N;break}if(te===g){W=!0,g=k,f=N;break}te=te.sibling}if(!W){for(te=N.child;te;){if(te===f){W=!0,f=N,g=k;break}if(te===g){W=!0,g=N,f=k;break}te=te.sibling}if(!W)throw Error(a(189))}}if(f.alternate!==g)throw Error(a(190))}if(f.tag!==3)throw Error(a(188));return f.stateNode.current===f?i:c}function m(i){var c=i.tag;if(c===5||c===26||c===27||c===6)return i;for(i=i.child;i!==null;){if(c=m(i),c!==null)return c;i=i.sibling}return null}var p=Object.assign,x=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),T=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function L(i){return i===null||typeof i!="object"?null:(i=P&&i[P]||i["@@iterator"],typeof i=="function"?i:null)}var Y=Symbol.for("react.client.reference");function q(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Y?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case w:return"Fragment";case v:return"Profiler";case E:return"StrictMode";case I:return"Suspense";case O:return"SuspenseList";case z:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case y:return"Portal";case T:return i.displayName||"Context";case A:return(i._context.displayName||"Context")+".Consumer";case C:var c=i.render;return i=i.displayName,i||(i=c.displayName||c.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case _:return c=i.displayName||null,c!==null?c:q(i.type)||"Memo";case S:c=i._payload,i=i._init;try{return q(i(c))}catch{}}return null}var B=Array.isArray,j=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Q=[],F=-1;function G(i){return{current:i}}function J(i){0>F||(i.current=Q[F],Q[F]=null,F--)}function K(i,c){F++,Q[F]=i.current,i.current=c}var ee=G(null),ue=G(null),pe=G(null),be=G(null);function ae(i,c){switch(K(pe,c),K(ue,i),K(ee,null),c.nodeType){case 9:case 11:i=(i=c.documentElement)&&(i=i.namespaceURI)?K3(i):0;break;default:if(i=c.tagName,c=c.namespaceURI)c=K3(c),i=X3(c,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}J(ee),K(ee,i)}function xe(){J(ee),J(ue),J(pe)}function Ce(i){i.memoizedState!==null&&K(be,i);var c=ee.current,f=X3(c,i.type);c!==f&&(K(ue,i),K(ee,f))}function ze(i){ue.current===i&&(J(ee),J(ue)),be.current===i&&(J(be),md._currentValue=X)}var Ie,Fe;function Ee(i){if(Ie===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);Ie=c&&c[1]||"",Fe=-1<f.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Ie+i+Fe}var Me=!1;function De(i,c){if(!i||Me)return"";Me=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(c){var Ke=function(){throw Error()};if(Object.defineProperty(Ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ke,[])}catch(qe){var He=qe}Reflect.construct(i,[],Ke)}else{try{Ke.call()}catch(qe){He=qe}i.call(Ke.prototype)}}else{try{throw Error()}catch(qe){He=qe}(Ke=i())&&typeof Ke.catch=="function"&&Ke.catch(function(){})}}catch(qe){if(qe&&He&&typeof qe.stack=="string")return[qe.stack,He.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var N=g.DetermineComponentFrameRoot(),W=N[0],te=N[1];if(W&&te){var ge=W.split(`
|
|
@@ -31,7 +31,7 @@ Output the content only, no preamble.`,"panel.close":"Close panel","role.label":
|
|
|
31
31
|
• Fewer interruptions: “upstream changed” lights only when the change bears on the answer
|
|
32
32
|
• Cleaner memory: only what is worth keeping reaches your profile and dossiers
|
|
33
33
|
• Forgiving search: a mistyped term is corrected to one you actually used
|
|
34
|
-
About half a second per decision. Off, every decision falls back to a rule; nothing stops working.`,"judge.rowTitle":"Decision model · fast thinking","judge.stateOn":"available · {j}","judge.stateNoApi":"no interface available; rules apply","judge.stateOff":"off; rules apply","judge.stateTripped":"not answering; rules for now","judge.goConfigure":"Configure…","model.answerGroup":"Answering model · slow thinking","model.interfaces":"Interfaces","judge.title":"Decision model · System One","judge.providerLabel":"Provider","judge.provider.none":"No decision model (rank by matched terms and recency)","judge.provider.openrouter":"Jev on OpenRouter (typesafe/jev-latest)","judge.provider.typesafe":"TypeSafe directly (api.typesafe.ai)","judge.provider.cloudflare":"Jev on Cloudflare Workers AI","judge.provider.custom":"A System One endpoint of your own (Kev, Laya, Von…)","judge.provider.llm":"The current chat model stands in (uncalibrated)","judge.provider.off":"Off, rules decide","judge.key":"API key","judge.keyOptional":"API key (optional)","judge.account":"Account ID","judge.token":"API token","judge.url":"Endpoint","judge.urlHint":"Anything that serves POST /v1/systemone, this machine included.","judge.openrouterStored":"The OpenRouter key saved with your model providers is filled in; a change here affects the decision model only.","judge.openrouterHint":"Leave empty to use the OpenRouter key saved under model access. Billed per input token; output is free.","judge.typesafeHint":"Your TypeSafe key. Requests go through the local proxy.","judge.cloudflareHint":"Account ID and a token with Workers AI access. Requests go through the local proxy.","judge.llmHint":"The chat model you have selected answers the same questions as JSON. It works, but is slower, costs output tokens, and its numbers are its opinion, not calibrated probabilities.","judge.test":"Test","judge.testOk":"{ms} ms · {model} · urgent {p} · department {c}","judge.calibrated":"calibrated","judge.uncalibrated":"uncalibrated","panel.recallRelevance":"relevance {p}","panel.recallCorrected":"{a} corrected to {b}","panel.recallJudge":"decision model: {j}","panel.recallPool":"{n} candidates read, {m} hits in the index","panel.recallJudgeFailed":"the decision model did not answer, ranked by rules: {e}","panel.recallDropped":"{n} held irrelevant by the decision model","panel.recallMore":"Bring a few more","recall.scaleLean":"lean","recall.scaleStandard":"standard","recall.scaleGenerous":"generous","recall.scaleHint":"A ceiling on the input tokens brought into the ask. Lean 4k: a dossier and five to eight excerpts; standard 12k: two dossiers and some twenty; generous 40k: everything the decision model finds relevant. A small window caps at two fifths of itself. With a decision model relevance fills it; without, the ranking does.","recall.chip":"Recall","recall.chipOn":"Recall · {r}","recall.reachFullShort":"full","recall.menuOn":"Recall on","recall.menuReach":"Search reach","recall.menuScale":"Context brought in","recall.menuOnce":"For this ask only","recall.menuDefault":"Set as default","recall.menuDefaultDone":"Set as the default","recall.menuNeedsJudge":"Connect the decision model to choose this","recall.reachLight":"light","recall.reachDeep":"deep","recall.reachFull":"full (costly)","recall.reachHint":"How many candidates the decision model sees per recall. Light: the 40 best keyword hits, each read in full before judging. Deep: 2,000 hits, judged by their opening lines, the ones that pass read in full; ten-odd seconds and a few cents a question. Full: every turn in the index, keywords or not, timed and priced by the size of the index. Without a decision model only light runs.","recall.reachFullTitle":"Switch to full recall","recall.reachFullMsg":"Full hands every one of the {n} turns in the index to the decision model: about {s} seconds and ${c} per question, more as the index grows. In testing, deep answered as many questions as full. Switch to full?","recall.reachFullOk":"Switch to full","panel.recallReach":"search reach: {r}","panel.recallJudging":"The decision model is reading candidates: {done}/{total}","panel.recallOffHint":"Recall is off. This node keeps {n} recalled items; with recall on they ride along on the next ask.","plugin.updateHintDesktop":"On the Harness's Plugins page, add {pkg} again, then restart the Harness","plugin.updateCopiedDesktop":"Package name copied. Add it on the Harness's Plugins page, then restart","panel.recallNoMore":"Nothing more","takeaway.conclusive":"settledness: {l}","takeaway.level0":"speculative","takeaway.level1":"leaning","takeaway.level2":"definite","takeaway.level3":"verified","takeaway.judged":"judged · confidence {p}","toolbar.recall":"Recall: on send, the question's words are looked up in this machine's conversations and memories and the exact excerpts join the context","toolbar.recallOff":"Recall is off. On, each send looks up past conversations and memories","panel.recall":"Recall","panel.recallCount":"{n}/{m} items","panel.recallEmpty":"Recall is on. On send, the question's words are looked up in past conversations and memories; the hits are listed here and can be removed one by one.","panel.recallNone":"Nothing in those exact words this time.","panel.recallMatched":"matched: {w}","panel.recallExclude":"Leave out of the context","panel.recallInclude":"Bring back into the context","atlas.tabSessions":"Conversations","atlas.tabMemory":"Memory","atlas.searchPlaceholder":"Find the exact words in conversations and memories…","recall.turns":"Conversations","recall.memories":"Memories","recall.open":"Open","recall.cite":"Cite","recall.import":"Import","recall.searching":"Searching…","recall.none":"Nothing in those exact words. Matching is exact; try another wording.","recall.summary":"{n} hits · {m} sources","recall.more":"Showing the first {n}; narrow the words to see more.","recall.cited":"Cited as material into the current node.","recall.citedLoose":"Placed on the canvas. Wire it into a node for it to enter that context.","recall.unavailable":"No local index in this build; the exact words cannot be searched.","recall.entry":"entry {n}","recall.turn":"turn {n}","memory.mine":"ThoughtDAG memory","memory.agentFiles":"Other agents' memories","memory.agentFilesHint":"Read-only, from the claude-code and codex memory files on this machine. Import copies one entry into the library above; Cite places it on the canvas.","memory.agentFilesNone":"No other agent's memory files found on this machine.","memory.entriesN":"{n} entries","memory.importedOne":"Added to the library.","node.recallSource":"From {s}","atlas.title":"Session Atlas","atlas.subtitle":"Your local agent conversations, grouped by project folder — click one to import it as a canvas. Read-only: nothing you do on the canvas ever writes back to a conversation file.","atlas.refresh":"Refresh","atlas.scanning":"Scanning…","atlas.folders":"Project folders","atlas.myCanvases":"My canvases","atlas.unfiled":"Unfiled","atlas.sessions":"{n} sessions","atlas.empty":"No agent conversations found. Conversations from command-line agents on this machine will appear here.","atlas.import":"Import as canvas","atlas.openCli":"Open in CLI","atlas.cmdCopied":"Resume command copied — paste it into a terminal to re-enter the session","atlas.parseFailed":"Could not parse this session file: {msg}","atlas.opened":"Session opened in your terminal","atlas.sources":"Sources","atlas.sourcesTitle":"Session sources","atlas.sourcesHint":"Built-in sources probe their standard paths. Custom directories join through the system picker — always read-only.","atlas.autoDetect":"Re-detect","atlas.addDir":"Add directory…","atlas.parserSoon":"parser in progress","atlas.rootMissing":"not found","atlas.filterTitle":"Filter titles…","atlas.filteredOut":"No sessions match the current filters — adjust them above to bring the list back.","atlas.changesSummary":"Since your last look: {n} new · {m} updated","atlas.markAllSeen":"Mark all seen","atlas.onlyChanged":"Changed only","atlas.showSub":"Subthreads","atlas.badgeNew":"NEW","atlas.appended":"+{n} turns appended to this session’s canvas","atlas.upToDate":"The canvas already mirrors this session in full","atlas.liveAppended":"Session grew: +{n} turns synced automatically","atlas.mountedBranch":"Experiment mounted back at its departure node ({n} turns)","atlas.mountedChapter":"New chapter continues the main line ({n} turns)","atlas.mountPending":"A new session belongs to another canvas — open it (or click its card) to mount","atlas.onCanvas":"has a canvas","atlas.currentOpen":"open now","atlas.mountTo":"Mount onto a canvas…","atlas.mountHint":"The session attaches at the chosen canvas’s main-line tail; the canvas then listens for its updates.","atlas.turnsN":"{n} turns","atlas.terminalChoice":'Terminal used by "open in terminal"',"atlas.otherTerminal":"Other app…","atlas.recent":"Recent work","atlas.webNoScan":"Scanning external sessions needs the desktop app; manage your canvases here.","atlas.recast":"Re-mirror (discard canvas edits)","atlas.recastDone":"Mirror rebuilt from the source session","confirm.recastTitle":"Re-mirror","confirm.recast":"This deletes the canvas “{name}” — including all your edits and hand-made nodes — and rebuilds the full mirror from the source session. The source file is untouched.","switcher.allCanvases":"All canvases & sessions…","switcher.archive":"Archive (hide from lists, keep data)","atlas.archivedGroup":"Archived ({n})","atlas.restoreOpen":"Restore & open","confirm.deletePristine":"“{name}” is an unmodified mirror of its session — deleting loses nothing; rebuild it from the map any time.","confirm.deleteDiverged":"“{name}” holds your edits or hand-made content — deleting loses them. The source session is untouched, but only the original mirror can be rebuilt.","confirm.deleteNative":"“{name}” is the only copy — deletion cannot be undone.","switcher.mirrorBadge":"This canvas subscribes to a {runner} session — click to see it on the map","switcher.mirrorBadgeGone":"Source session not found on this machine — the mirror runs as an archive; listening resumes when the source appears","toast.importAlreadySubscribed":"Session already has canvas “{name}” — opened it for you (one session, one canvas)","toast.unsubscribed":"Stopped listening to {n} conversation(s): no mirror nodes left on this canvas. Reopen it from Session Atlas to resubscribe.","toast.unsubscribedNative":"Stopped listening to {n} conversation(s): all mirror nodes were deleted. No listening sessions remain — this canvas is native again.","sensitive.title":"Possibly sensitive content found","sensitive.body":"This canvas holds {n} likely keys or credentials (often from agent-session tool output):","sensitive.more":"…and {n} more","sensitive.hint":"Continuing lets this content leave your machine. Consider deleting or editing those nodes first.","sensitive.proceed":"Proceed anyway","handoff.deeplinkMiss":"Could not find this session in the connected folders. Check the folder list under the map's connect button.","atlas.mergedName":"Collection · {title} +{n}","atlas.handoffTitle":"One-command handoff","atlas.handoffOn":"Enabled","atlas.handoffOff":"Not enabled","atlas.handoffOutdated":"Update available (or the local file was edited)","atlas.handoffEnable":"Enable","atlas.handoffUpdate":"Update","atlas.handoffRemove":"Remove","atlas.handoffEnableTitle":"Enable one-command handoff","atlas.handoffInstalled":"Enabled. Type {cmd} inside the agent to bring the current session into ThoughtDAG.","confirm.installCommand":`Installs a local command file:
|
|
34
|
+
About half a second per decision. Off, every decision falls back to a rule; nothing stops working.`,"judge.rowTitle":"Decision model · fast thinking","judge.stateOn":"available · {j}","judge.stateNoApi":"no interface available; rules apply","judge.stateOff":"off; rules apply","judge.stateTripped":"not answering; rules for now","judge.goConfigure":"Configure…","model.answerGroup":"Answering model · slow thinking","model.interfaces":"Interfaces","judge.title":"Decision model · System One","judge.providerLabel":"Provider","judge.provider.none":"No decision model (rank by matched terms and recency)","judge.provider.openrouter":"Jev on OpenRouter (typesafe/jev-latest)","judge.provider.typesafe":"TypeSafe directly (api.typesafe.ai)","judge.provider.cloudflare":"Jev on Cloudflare Workers AI","judge.provider.custom":"A System One endpoint of your own (Kev, Laya, Von…)","judge.provider.llm":"The current chat model stands in (uncalibrated)","judge.provider.off":"Off, rules decide","judge.key":"API key","judge.keyOptional":"API key (optional)","judge.account":"Account ID","judge.token":"API token","judge.url":"Endpoint","judge.urlHint":"Anything that serves POST /v1/systemone, this machine included.","judge.openrouterStored":"The OpenRouter key saved with your model providers is filled in; a change here affects the decision model only.","judge.openrouterHint":"Leave empty to use the OpenRouter key saved under model access. Billed per input token; output is free.","judge.typesafeHint":"Your TypeSafe key. Requests go through the local proxy.","judge.cloudflareHint":"Account ID and a token with Workers AI access. Requests go through the local proxy.","judge.llmHint":"The chat model you have selected answers the same questions as JSON. It works, but is slower, costs output tokens, and its numbers are its opinion, not calibrated probabilities.","judge.test":"Test","judge.testOk":"{ms} ms · {model} · urgent {p} · department {c}","judge.calibrated":"calibrated","judge.uncalibrated":"uncalibrated","panel.recallRelevance":"relevance {p}","panel.recallCorrected":"{a} corrected to {b}","panel.recallJudge":"decision model: {j}","panel.recallPool":"{n} candidates read, {m} hits in the index","panel.recallJudgeFailed":"the decision model did not answer, ranked by rules: {e}","panel.recallDropped":"{n} held irrelevant by the decision model","panel.recallMore":"Bring a few more","recall.scaleLean":"lean","recall.scaleStandard":"standard","recall.scaleGenerous":"generous","recall.scaleHint":"A ceiling on the input tokens brought into the ask. Lean 4k: a dossier and five to eight excerpts; standard 12k: two dossiers and some twenty; generous 40k: everything the decision model finds relevant. A small window caps at two fifths of itself. With a decision model relevance fills it; without, the ranking does.","recall.chip":"Recall","recall.chipOn":"Recall · {r}","recall.reachFullShort":"full","recall.menuOn":"Recall on","recall.menuReach":"Search reach","recall.menuScale":"Context brought in","recall.menuOnce":"For this ask only","recall.menuDefault":"Set as default","recall.menuDefaultDone":"Set as the default","recall.menuNeedsJudge":"Connect the decision model to choose this","recall.reachLight":"light","recall.reachDeep":"deep","recall.reachFull":"full (costly)","recall.reachHint":"How many candidates the decision model sees per recall. Light: the 40 best keyword hits, each read in full before judging. Deep: 2,000 hits, judged by their opening lines, the ones that pass read in full; ten-odd seconds and a few cents a question. Full: every turn in the index, keywords or not, timed and priced by the size of the index. Without a decision model only light runs.","recall.reachFullTitle":"Switch to full recall","recall.reachFullMsg":"Full hands every one of the {n} turns in the index to the decision model: about {s} seconds and ${c} per question, more as the index grows. In testing, deep answered as many questions as full. Switch to full?","recall.reachFullOk":"Switch to full","recall.reachFullEmpty":"The index has no conversations to hand to the decision model yet, or it is being rebuilt. Ask once on light or deep; choose full once the index is built.","panel.recallReach":"search reach: {r}","panel.recallJudging":"The decision model is reading candidates: {done}/{total}","panel.recallOffHint":"Recall is off. This node keeps {n} recalled items; with recall on they ride along on the next ask.","plugin.updateHintDesktop":"On the Harness's Plugins page, add {pkg} again, then restart the Harness","plugin.updateCopiedDesktop":"Package name copied. Add it on the Harness's Plugins page, then restart","panel.recallNoMore":"Nothing more","takeaway.conclusive":"settledness: {l}","takeaway.level0":"speculative","takeaway.level1":"leaning","takeaway.level2":"definite","takeaway.level3":"verified","takeaway.judged":"judged · confidence {p}","toolbar.recall":"Recall: on send, the question's words are looked up in this machine's conversations and memories and the exact excerpts join the context","toolbar.recallOff":"Recall is off. On, each send looks up past conversations and memories","panel.recall":"Recall","panel.recallCount":"{n}/{m} items","panel.recallEmpty":"Recall is on. On send, the question's words are looked up in past conversations and memories; the hits are listed here and can be removed one by one.","panel.recallNone":"Nothing in those exact words this time.","panel.recallMatched":"matched: {w}","panel.recallExclude":"Leave out of the context","panel.recallInclude":"Bring back into the context","atlas.tabSessions":"Conversations","atlas.tabMemory":"Memory","atlas.searchPlaceholder":"Find the exact words in conversations and memories…","recall.turns":"Conversations","recall.memories":"Memories","recall.open":"Open","recall.cite":"Cite","recall.import":"Import","recall.searching":"Searching…","recall.none":"Nothing in those exact words. Matching is exact; try another wording.","recall.summary":"{n} hits · {m} sources","recall.more":"Showing the first {n}; narrow the words to see more.","recall.cited":"Cited as material into the current node.","recall.citedLoose":"Placed on the canvas. Wire it into a node for it to enter that context.","recall.unavailable":"No local index in this build; the exact words cannot be searched.","recall.entry":"entry {n}","recall.turn":"turn {n}","memory.mine":"ThoughtDAG memory","memory.agentFiles":"Other agents' memories","memory.agentFilesHint":"Read-only, from the claude-code and codex memory files on this machine. Import copies one entry into the library above; Cite places it on the canvas.","memory.agentFilesNone":"No other agent's memory files found on this machine.","memory.entriesN":"{n} entries","memory.importedOne":"Added to the library.","node.recallSource":"From {s}","atlas.title":"Session Atlas","atlas.subtitle":"Your local agent conversations, grouped by project folder — click one to import it as a canvas. Read-only: nothing you do on the canvas ever writes back to a conversation file.","atlas.refresh":"Refresh","atlas.scanning":"Scanning…","atlas.folders":"Project folders","atlas.myCanvases":"My canvases","atlas.unfiled":"Unfiled","atlas.sessions":"{n} sessions","atlas.empty":"No agent conversations found. Conversations from command-line agents on this machine will appear here.","atlas.import":"Import as canvas","atlas.openCli":"Open in CLI","atlas.cmdCopied":"Resume command copied — paste it into a terminal to re-enter the session","atlas.parseFailed":"Could not parse this session file: {msg}","atlas.opened":"Session opened in your terminal","atlas.sources":"Sources","atlas.sourcesTitle":"Session sources","atlas.sourcesHint":"Built-in sources probe their standard paths. Custom directories join through the system picker — always read-only.","atlas.autoDetect":"Re-detect","atlas.addDir":"Add directory…","atlas.parserSoon":"parser in progress","atlas.rootMissing":"not found","atlas.filterTitle":"Filter titles…","atlas.filteredOut":"No sessions match the current filters — adjust them above to bring the list back.","atlas.changesSummary":"Since your last look: {n} new · {m} updated","atlas.markAllSeen":"Mark all seen","atlas.onlyChanged":"Changed only","atlas.showSub":"Subthreads","atlas.badgeNew":"NEW","atlas.appended":"+{n} turns appended to this session’s canvas","atlas.upToDate":"The canvas already mirrors this session in full","atlas.liveAppended":"Session grew: +{n} turns synced automatically","atlas.mountedBranch":"Experiment mounted back at its departure node ({n} turns)","atlas.mountedChapter":"New chapter continues the main line ({n} turns)","atlas.mountPending":"A new session belongs to another canvas — open it (or click its card) to mount","atlas.onCanvas":"has a canvas","atlas.currentOpen":"open now","atlas.mountTo":"Mount onto a canvas…","atlas.mountHint":"The session attaches at the chosen canvas’s main-line tail; the canvas then listens for its updates.","atlas.turnsN":"{n} turns","atlas.terminalChoice":'Terminal used by "open in terminal"',"atlas.otherTerminal":"Other app…","atlas.recent":"Recent work","atlas.webNoScan":"Scanning external sessions needs the desktop app; manage your canvases here.","atlas.recast":"Re-mirror (discard canvas edits)","atlas.recastDone":"Mirror rebuilt from the source session","confirm.recastTitle":"Re-mirror","confirm.recast":"This deletes the canvas “{name}” — including all your edits and hand-made nodes — and rebuilds the full mirror from the source session. The source file is untouched.","switcher.allCanvases":"All canvases & sessions…","switcher.archive":"Archive (hide from lists, keep data)","atlas.archivedGroup":"Archived ({n})","atlas.restoreOpen":"Restore & open","confirm.deletePristine":"“{name}” is an unmodified mirror of its session — deleting loses nothing; rebuild it from the map any time.","confirm.deleteDiverged":"“{name}” holds your edits or hand-made content — deleting loses them. The source session is untouched, but only the original mirror can be rebuilt.","confirm.deleteNative":"“{name}” is the only copy — deletion cannot be undone.","switcher.mirrorBadge":"This canvas subscribes to a {runner} session — click to see it on the map","switcher.mirrorBadgeGone":"Source session not found on this machine — the mirror runs as an archive; listening resumes when the source appears","toast.importAlreadySubscribed":"Session already has canvas “{name}” — opened it for you (one session, one canvas)","toast.unsubscribed":"Stopped listening to {n} conversation(s): no mirror nodes left on this canvas. Reopen it from Session Atlas to resubscribe.","toast.unsubscribedNative":"Stopped listening to {n} conversation(s): all mirror nodes were deleted. No listening sessions remain — this canvas is native again.","sensitive.title":"Possibly sensitive content found","sensitive.body":"This canvas holds {n} likely keys or credentials (often from agent-session tool output):","sensitive.more":"…and {n} more","sensitive.hint":"Continuing lets this content leave your machine. Consider deleting or editing those nodes first.","sensitive.proceed":"Proceed anyway","handoff.deeplinkMiss":"Could not find this session in the connected folders. Check the folder list under the map's connect button.","atlas.mergedName":"Collection · {title} +{n}","atlas.handoffTitle":"One-command handoff","atlas.handoffOn":"Enabled","atlas.handoffOff":"Not enabled","atlas.handoffOutdated":"Update available (or the local file was edited)","atlas.handoffEnable":"Enable","atlas.handoffUpdate":"Update","atlas.handoffRemove":"Remove","atlas.handoffEnableTitle":"Enable one-command handoff","atlas.handoffInstalled":"Enabled. Type {cmd} inside the agent to bring the current session into ThoughtDAG.","confirm.installCommand":`Installs a local command file:
|
|
35
35
|
{path}
|
|
36
36
|
|
|
37
37
|
The command reads local sessions and opens them in ThoughtDAG. Removable here.`,"atlas.mergeSelected":"{n} conversations picked","atlas.mergeNew":"Merge into a new canvas","atlas.mergeInto":"Merge into a canvas…","atlas.pickForMerge":"Pick for merging","atlas.merged":"Placed {n} conversations side by side, each listening independently. No wires between the chains — the context relations are yours to draw.","atlas.mergeSkippedInfo":"{n} conversation(s) already live on a canvas and were skipped (one session, one canvas).","panel.revertToSource":"Revert to source text","panel.ctxOrder":"Merge order (first → last)","panel.ctxOrderUp":"Move block earlier","panel.ctxOrderDown":"Move block later","panel.reverted":"Reverted to the text imported from the source","atlas.openApp":"Open in app ({name})","atlas.openTerminal":"Open in terminal","atlas.appOpened":"App activated — session id copied; search for it inside the app","atlas.sortTime":"Time","atlas.sortName":"Name","atlas.sortSize":"Size","atlas.sortRunner":"CLI","confirm.deleteNodesTitle":"Delete nodes","confirm.deleteNodes":"Delete {n} selected nodes?","confirm.deleteCanvasTitle":"Delete canvas","confirm.deleteCanvas":'Delete "{name}" and all its nodes? This cannot be undone.',"toast.pasteFileHint":"Files copied in the file manager cannot be read by the browser. Drag the file onto the canvas instead.","toast.copied":"Copied to clipboard","toast.exported":'Exported "{name}"',"toast.imported":'Imported "{name}" ({n} nodes)',"toast.importFailedJson":"Import failed: not valid JSON","toast.importManifest":"This file is a run manifest: the audit trail of a canvas. It records provenance, not full content, so it cannot be imported. Export the .thoughtdag.json backup from the project menu instead.","toast.importFailedShape":"Import failed: the nodes in this file are not canvas nodes (position/data missing). Import a .thoughtdag.json backup exported from the project menu.","toast.importFailedGeneric":"Import failed: {msg}","toast.importFailedMissing":"Import failed: missing nodes/edges arrays","toast.generationFailed":"Generation failed: {message}","toast.editMakesStale":"Question edited: {n} downstream answers were written against the old content (re-run manually)","timeline.label":"Timeline: jump to a node by when it was created","timeline.created":"Created","timeline.modified":"Last edited","timeline.openOverview":"Open the full timeline","tlov.title":"Timeline","tlov.count":"{n} steps","tlov.empty":"Nothing on the timeline yet.","tlov.undated":"Undated","tlov.detail":"Detail","tlov.detailTitle":"How much of each step to show: topic, takeaway, brief, abstract. Texts are shown whole, never clipped.","ladder.level0":"topic","ladder.level1":"takeaway","ladder.level2":"brief","ladder.level3":"abstract","tlov.locate":"Locate","tlov.gedankenGenerate":"Write the journey","tlov.gedankenLoading":"Reading the map…","tlov.gedankenStale":"Out of date","tlov.gedankenRedo":"Regenerate","tlov.gedankenFailed":"Could not write the journey. Try again.","timeline.clickHint":"Click to locate · double-click to open","tlov.exportPoster":"Poster","tlov.exportingPoster":"Drawing…","tlov.exportPosterTitle":"Export this journey as a manuscript-chronicle poster (PNG)","share.directLane":"Read-only link","share.linkTooLong":"This canvas is large: chat apps may truncate the link and break it. The full canvas file below travels safely.","share.fullFile":"Export full canvas (.json)","share.readonlyMark":"Mark as read-only","import.readonlyTitle":"A canvas shared read-only","import.readonlyConfirm":"This canvas was shared as read-only. Importing creates an editable copy on your side. Continue?","share.directNote":"The link carries a read-only copy of the whole canvas. It opens for anyone, no account, wherever it was minted. Best for chat, mail, docs.","question.lockedWhileGenerating":"The answer is still generating — stop it first to edit the question.","question.editCancel":"Cancel","question.editSubmit":"Submit & generate","toast.noModelYet":"No model connected yet. Pick a provider and paste a key, then hit Retry on the node.","toast.rateLimited":"The model rate-limited this request (free tiers meter requests per minute). Wait half a minute and hit Retry.","toast.contextOverWindow":"Context is ~{est} tokens, over the {limit}-token window of {model}. Pick a larger-window model, or prune wires and attachments.","toast.visionRerouted":'"{from}" cannot see images — "{to}" is answering this one.',"toast.visionLearnedTrue":"Verified: {m} understands images — the 📷 mark is now on.","toast.visionLearnedFalse":"{m} could not read the images: retried as text (succeeded) and switched its vision mark off (adjustable in Model interfaces).","toast.imagesAsText":`The vision stand-in could not take this context (its window is usually far smaller); "{model}" is answering from the images' companion text instead.`,"takeaway.insight":"Insight","takeaway.ruleout":"Ruled out","takeaway.decision":"Decision","takeaway.pivot":"Pivot","takeaway.open":"Open question","node.generatedByTitle":"The model that generated this version. Recorded at generation time, so changing the global model never obscures where an answer came from.","node.pinnedModel":"Pinned model: {m} (used for the next generation)","node.gatewaySearching":"Searching the web…","node.gatewaySearched":"Web-searched","node.gatewaySearchedTitle":"This version was answered with the model gateway's built-in web search.","node.exploredHere":"A branch explores this passage. Click to jump to it","condense.editLocked":"Condensing in progress: the canvas is read-only for a moment (viewing is fine); editing resumes when the copy is ready.","condense.entryBuilding":"Condensing (run {i}/{n}), click to view","condense.runningBg":"Condensing in the background: closing this window does not interrupt; the toolbar icon shows progress.","condense.copyIntroShort":"Check the runs to collapse; the original tree stays untouched.","condense.copyIntroFull":"Builds a condensed copy beside the original: checked runs collapse into distill nodes (decisions and conclusions, highlights verbatim), everything else is copied with wires rebuilt. Decision/pivot turns never collapse.","condense.scanLine":"Scanned {turns} turns, {n} candidate runs; the last 3 steps are the working frontier and stay out.","condense.rescan":"Rescan","condense.rescanTitle":"Re-detect candidate runs across the map (local, no model call)","condense.copyFootnote":"Original untouched. One undo removes the copy","condense.buildCopy":"Build condensed copy ({n} runs collapse, {tok} tok saved)","condense.buildingRun":"Distilling run {i}/{n} (with a rolling brief, one small call each)…","condense.copyDone":"Condensed copy ready: {runs} runs collapsed, {n} nodes, right beside the original.","condense.copyReady":"The condensed copy is ready, beside the original","condense.copyCompareHint":"Wire the same question to each tree to compare; the chip on a distill node jumps back to its source.","condense.viewCopy":"View the copy","condense.archiveOriginal":"Archive the original tree","condense.originalArchived":"Original archived: dimmed, out of context, restorable from the node menu anytime.","node.condensedFrom":"condensed from {n} turns","node.condensedFromTitle":"This node was distilled from a run in the original tree. Click to highlight and travel to it.","condense.segIntro":"Candidate runs found locally (consecutive unbranched Q/A). Hover a row and its segment lights up on the canvas. Each segment is its own decision: preview a distilled note first, or lower directly. Lowered nodes fold into plaques on the canvas — what you see is what the model gets.","condense.segNothing":"No unbranched runs of 3+ turns. This map is tight.","condense.segMeta":"{n} turns, saves {tok} tok","condense.segKeyMoves":"{n} decision/pivot","condense.segDistill":"Distill preview (one small call)","condense.segDistilling":"Distilling, a few seconds…","condense.segApplyPlain":"Lower directly","condense.segApplyPlainTitle":"No distilled note; each turn enters as its takeaway line","condense.segKeepNote":"Also keep the distilled note","condense.segApply":"Apply ({n} turns, {tok} tok saved)","condense.segApplied":"Condensed {n} turns: plaques on the canvas, takeaways downstream. One undo restores.","condense.segDone":"condensed","condense.modelLabel":"Audit model","condense.modelGlobal":"Follow global ({model})","condense.auditingHint":"Large maps or reasoning models can take a minute or two; a faster model shortens the wait.","condense.entryTitle":"Condense: let a model audit the map and suggest turns whose granularity can drop","condense.title":"Condense","condense.intro":"A model reads the whole map STRUCTURE and takeaways (never the full prose, an order of magnitude cheaper) and finds turns that can enter downstream context as their takeaway line: repeated refinements on one topic, intermediate drafts superseded later. It can only propose the two moves you already know: lowering the context form, optionally plus a distilled note of still-valid decisions.","condense.introTrust":"Nothing is pre-checked; every row carries its reason and saving; rows touching decision/pivot badges are flagged; applying is one undo step; every lowered node wears a badge that restores full form in one click.","condense.run":"Run the audit ({n} turns, one model call)","condense.tooSmall":"Too few turns yet to be worth condensing.","condense.auditing":"The auditor is reading the takeaways…","condense.planHead":"Audited {audited} turns, {n} suggestions, ~{tok} tok saved if all applied","condense.nothing":"The auditor found no turns worth lowering. This map is tight.","condense.typeLower":"Lower context form","condense.typeMerge":"Lower + distilled note","condense.itemMeta":"{n} nodes, saves {tok} tok","condense.keyMoves":"touches decision/pivot","condense.previewDistilled":"Preview the distilled note","condense.reversible":"One undo restores everything","condense.apply":"Apply selected ({n} items, {tok} tok saved)","condense.applied":"Condensed {n} turns, wrote {notes} distilled note(s). Node badges restore full form anytime.","node.condensedForm":"enters as takeaway","node.condensedFormTitle":"This node enters downstream context as its takeaway line (the full text stays on the card). Click to restore full form.","ctx.formSummary":"Enter context as takeaway (downstream gets one line)","ctx.formFull":"Restore full context form","node.summaryLabel":"Summary","node.summaryTitle":"An automatic summary of this answer, for the map only. It never enters context. Double-click the card to read the full answer in the panel.","node.staleBadge":"Upstream changed","node.staleJudged":"An upstream change bears on this answer (decision model {p}). Click to replay; the new version can be compared","node.staleTitle":"This answer predates changes in its upstream. Click to re-run (appends a new version for comparison)","replay.chip":"Replay stale ({n})","replay.chipTitle":"Re-run every stale node in dependency order (confirms first; each appends a new version)","replay.confirmTitle":"Replay stale nodes","replay.confirmMsg":"This will replay {n} nodes in dependency order (each appends a new version, nothing is overwritten), sending an estimated {tok} tokens. You can stop at any time.","replay.confirmBtn":"Start replay","replay.progress":"Replaying {done}/{total}…","replay.stop":"Stop","replay.stopped":"Replay stopped ({done}/{total} finished); remaining nodes keep their stale badges","replay.done":"Replay finished: {done} nodes updated","toolbar.diagnose":"Diagnose graph topology: residual edges / shadow references / blind-pool breaches / long chains…","diag.title":"Diagnostic report","diag.summary":"{a} definite · {b} observations","diag.clean":"The graph is clean. Nothing found.","diag.tier1":"Definite problems (one-click fix)","diag.tier2":"Observations (for judgment)","diag.locate":"Locate","diag.fix":"Delete this edge","diag.residual":"Residual solid edge: “{a}” → “{b}” duplicates a longer chain","diag.shadow":"Shadow reference: “{a}” already flows in full into “{b}” along solid edges; this reference doubles the content","diag.breach":"Blind-pool breach: candidate “{a}” can read candidate “{b}”","diag.asym":"Pool asymmetry: “{a}” has {n} private inputs its sibling candidates lack","diag.longChain":"Long chain: “{a}” is {d} deep, ~{tok} tok. Consider merge-summarize + archive upstream","diag.openBranches":"{n} open branches: unconverged, unarchived leaves piling up","diag.collider":"Attribution collapse: “{a}” ({n}-way fan-in with further descendants; downstream conclusions can no longer be attributed to a source branch)","diag.orphans":"{n} unwired materials feeding no context","diag.loadBearing":"Load-bearing node: “{a}” supports {n} downstream nodes; editing it stales a wide area","toast.unknownError":"Unknown error","toast.projectsLoadFailed":"Failed to load projects. Starting with an empty canvas","toast.unsupportedFile":"Unsupported format: {name}. For legacy .doc files, save as .docx or PDF first.","export.contextChain":"Context chain","export.selectedNodes":"Selected nodes","export.attachmentsLabel":"Attachments:","evaluator.badge":"Evaluator","toolbar.relayout":"Tidy layout","toolbar.align":"Align","toolbar.duplicate":"Duplicate","toolbar.duplicateTitle":"Copy the selection as a whole (inner links kept, links crossing the selection are not carried over)","confirm.relayoutTitle":"Tidy layout","confirm.relayoutMsg":"Rearrange all nodes by their arrow order? Your manual positions will be replaced (Cmd+Z to undo).","confirm.alignTitle":"Align selection","confirm.alignMsg":"Stack the {n} selected nodes into one column, in conversation order? (Cmd+Z to undo)","common.confirmAlign":"Align","refs.title":"References","caps.title":"Capabilities","caps.webSearch":"Web search","caps.engineServer":"Server default ({engine})","caps.engineStd":"search_std · standard, ~¥0.01/query","caps.enginePro":"search_pro · better sources, ~¥0.03/query","caps.engineAnysearch":"AnySearch · aggregator","caps.anysearchKeyPlaceholder":"AnySearch key…","caps.anysearchHintQuota":"Daily quota per key or per IP (keyless on local runs); a free signup lifts it:","caps.anysearchHintEnable":"The current interfaces provide no search channel. Add an AnySearch key (free signup) to enable web search:","caps.anysearchSaved":"Search key saved.","caps.anysearchCleared":"Search key removed.","caps.enginePickTitle":"Which server-side search engine handles web searches. The model still decides when to search; this decides how well.","caps.webSearchOff":"The current interfaces carry no search channel of their own.","caps.scholar":"Scholarly search","caps.scholarDesc":"arXiv + Semantic Scholar · free public APIs, always available","caps.memory":"Memory","caps.memoryTitle":"Ambient long-term memory: the model quietly remembers durable facts about you and uses them when relevant. Writes announce themselves; manage everything in one place.","caps.on":"On","caps.off":"Off","memory.entryTitle":"Memory: what the model remembers about you, across all canvases. View, edit, import, export.","memory.manage":"Manage","memory.managerTitle":"Memory","memory.hint":"{n} entries · used across all canvases when relevant","memory.empty":"Nothing remembered yet. The model saves durable facts as you work (each save shows a toast), or add and import entries here.","memory.add":"Add memory","memory.import":"Import (paste)","memory.importPlaceholder":"Paste one memory per line. A memory list copied from another assistant's settings works as-is.","memory.importConfirm":"Import","memory.export":"Export JSON","memory.exportTitle":"Your memories are yours: one file, easy out.","memory.kindAuto":"auto","memory.catPreference":"preference","memory.catIdentity":"identity","memory.catProject":"project","memory.kindManual":"manual","memory.kindImported":"imported","mp.subtitle":"Your profile, one dossier per project, and their sources. The search above covers all of it.","mp.settings":"Settings","mp.recallOn":"Recall past conversations when asking","mp.recallOnHint":"Before sending, find the dossiers and conversations that bear on the question and bring them into the context. Can be turned off per node.","mp.memoryOn":"Update memory from conversations","mp.memoryOnHint":"After an answer, decide whether something durable was said and write it into “you” or the project dossier. Every write leaves a changelog line.","mp.judgeRow":"Decision model and budget","mp.judgeRowHint":"Set under Model APIs; not repeated here.","mp.open":"Open…","mp.you":"You","mp.preferences":"Preferences","mp.identity":"Identity","mp.docEmpty":"Nothing yet. The model writes here as you work; you can write by hand too.","mp.updatedAt":"updated {d}","mp.docHint":"One fact per line. Model updates rewrite the line they touch, never append; each line keeps which canvas it came from, when, and whether you said it or it was inferred.","mp.changelog":"Changes","mp.evidenceStated":"you said it","mp.evidenceInferred":"inferred","mp.evidenceManual":"edited by hand","mp.evidenceFolded":"earlier entry","mp.lineWas":"rewritten from: {t}","mp.save":"Save","mp.edit":"Edit","mp.export":"Export","mp.editedNote":"edited by hand","mp.projects":"Projects","mp.editTopics":"Edit topics…","mp.noTopics":"No topics yet. Write a few under “Edit topics” or let the model propose some; after labelling, a dossier can be built.","mp.notBuilt":"not built yet","mp.labeledTurns":"{n} turns labelled","mp.newTurns":"{n} new turns","mp.pending":"{n} to merge","mp.fromTurns":"from {n} turns","mp.build":"Build dossier","mp.update":"Update dossier","mp.updateN":"Update dossier ({n} new turns)","mp.rebuild":"Rebuild from conversations","mp.building":"Reading conversations, writing…","mp.pendingList":"To merge","mp.sourceOpen":"open this turn","mp.filedTag":"memory","mp.buildHint":"{n} turns carry this topic; “Build dossier” has the model read the newest batch and write it.","mp.needIndex":"This build has no local index, so no project dossiers.","mp.inbox":"Inbox · {n} facts no project claimed","mp.fileTo":"File to…","mp.discard":"Discard","mp.filed":"Filed to the “{name}” dossier, to be merged.","mp.sources":"Sources","mp.sourcesN":"{n} sources, read-only","mp.index":"Local conversation index","mp.indexLine":"{n} turns","mp.labelState":"{n} of {m} turns labelled","panel.recallLead":"Brought in {what}.","panel.recallLeadDossier":"the {name} dossier","panel.recallLeadTurns":"{n} conversations","panel.recallLeadJoin":" and ","panel.recallAllOff":"All removed; nothing rides this time.","panel.recallHow":"how it was chosen","panel.recallDetailYes":"the decision model read the question as asking for a detail ({p}), so excerpts came too","panel.recallDetailNo":"the decision model read the question as asking for an overview ({p}), so only the dossier came","panel.recallKept":"{n} candidates, {k} brought in","panel.recallUsed":"ceiling {b} tok (input tokens brought into the ask), used {u}","panel.relatedAddChip":"term or topic","panel.relatedExpandBtn":"Let the model expand","panel.relatedMore":"{n} more","panel.relatedAll":"all","panel.relatedFewer":"fewer","panel.relatedTermPlaceholder":"term…","panel.relatedPickTopic":"Pick a topic:","recall.groupSummary":"{s} conversations · {n} mentions","recall.groupedHint":"grouped by conversation, newest first","recall.moreIn":"{n} more mentions not listed; narrow the phrase to see them.","recall.dossierOpen":"Open","recall.openSession":"Open","memory.filedToDossier":"Filed to the “{name}” dossier, to be merged: {t}","memory.filedToInbox":"Put in the inbox: {t}","memory.mergedPreferences":"Preferences updated: {t}","memory.mergedIdentity":"Identity updated: {t}","dossier.title":"{name} dossier","dossier.updated":"updated","dossier.secWhat":"What it is","dossier.secDecisions":"Decisions taken","dossier.secNow":"Where it stands","dossier.secOpen":"Still open","dossier.badOutput":"The model did not write the dossier in the expected shape; try again.","dossier.noTopic":"That topic no longer exists.","dossier.nothingToRead":"No labelled conversations for this topic yet; label first.","dossier.logBuilt":"built from {n} turns","dossier.logUpdated":"merged {n} new turns and {m} filed facts","dossier.logEdited":"hand-edited “{s}”","memory.saved":"Remembered: {t}","memory.updated":"Memory updated: {t}","memory.undo":"Undo","memory.rowLabel":"Memory (ambient layer)","memory.rowTitle":"These entries ride the system layer of every ordinary generation while memory is on. Click to manage.","caps.vision":"Image reading & Recognize","caps.visionAuto":"Auto (strongest model first)","caps.visionPickTitle":"Which model reads pasted images and recognizes scanned pages. Auto prefers the strongest, which may be the most expensive.","caps.visionOff":"Needs at least one vision model for image auto-reading and Recognize. Connect one via provider setup (GLM-4V Flash has a free tier).","toolbar.webSearch":"Web search: the model decides when to search","toolbar.webSearchOff":"Web search off","toolbar.model":"Model: applies to new generations","model.vision":"vision","model.inherit":"Model: global default","search.placeholder":"Search nodes… (↑↓ navigate, Enter to jump)","search.count":"{n} found","search.entryTitle":"Search this canvas (⌘F): questions, answers, notes, highlights, material names","search.more":"{n} more results; keep typing to narrow down","toast.importNoConversations":"No conversations with messages found in this file","toast.importedChats":"Imported {n} conversation(s), {m} nodes total","import.title":"Import conversations","import.subtitle":"Each selected conversation becomes its own canvas. ChatGPT edit/regenerate branches are preserved as graph forks.","import.selectAll":"Select all","import.messages":"{n} messages","import.confirm":"Import {n} selected","evaluator.rerun":"Re-critique now","paradigm.emptyTitle":"Design a paradigm","paradigm.emptyHint":"A paradigm has just two node kinds: dialogue nodes mark where the human asks; prompt nodes process upstream information with a fixed prompt. No LLM runs here — when the score is ready, instantiate it as a chat canvas and perform it live.","paradigm.instantiate":"Instantiate as canvas","paradigm.instantiateTitle":"Turn this paradigm into a runnable chat canvas (nothing generates until you act)","paradigm.kind.human":"Dialogue (human)","paradigm.kind.prompt":"Prompt (machine)","paradigm.addHuman":"Dialogue node","paradigm.addPrompt":"Prompt node","paradigm.titlePlaceholder":"Step title…","paradigm.humanHintPlaceholder":"Guidance for the operator (optional) — the human types here and the run pauses for them…","paradigm.promptPlaceholder":"Prompt — processes what flows in from upstream nodes; persona goes in the opening lines; runs automatically once upstream is ready…","paradigm.insertPersona":"Insert this persona at the top of the prompt","paradigm.yourTurn":"Your turn","paradigm.start":"Start","paradigm.waitingUpstream":"Waiting for upstream","paradigm.exportParadigm":"Export paradigm (.json)","paradigm.newParadigm":"New paradigm","paradigm.exampleRuleOut":"Example: Rule-out / Rule-in","landing.paradigmTitle":"Start from a paradigm","landing.paradigmDesc":"Design the human–AI division of labor once, then run it as a canvas","paradigm.badge":"Paradigm","paradigm.expand":"Expand {n} perspectives","paradigm.expandTitle":"Fan out this step into its configured role branches — you choose when","fanout.entry":"Add perspectives","fanout.entryTitle":"N role perspectives: answer once in parallel (blind), or keep reviewing as the thread grows","fanout.title":"Add perspectives","fanout.subtitle":"N roles, one mechanism, two run policies: answer once in parallel (candidate pool), or stay attached and keep reviewing.","fanout.modeOnce":"Answer once","fanout.modeFollow":"Keep reviewing","fanout.modeOnceHint":"Each perspective answers once, blind to its siblings — the rule-in / rule-out candidate pool.","fanout.modeFollowHint":"Each perspective becomes a reviewer: a red edge slides with the thread tip and re-critiques whenever upstream grows.","fanout.rounds":"Auto-review rounds","fanout.roundsHint":"max auto re-critiques per manual action (a bounded, file-declared loop)","fanout.question":"Shared question","fanout.instruction":"Standing instruction (runs on every re-review)","fanout.critiqueInstruction":"Critique the discussion above: identify overclaims, missing evidence, and unstated assumptions. Note what improved since the previous version if any. Be concise and specific. Respond in the language of the discussion.","fanout.templates":"Role templates","fanout.custom":"Custom roles (one per line: Name: prompt)","fanout.customPlaceholder":`Bayesian: You reason strictly in terms of priors and evidence...
|
|
@@ -53,7 +53,7 @@ Economist: You analyze through incentives and trade-offs...`,"fanout.confirm":"F
|
|
|
53
53
|
• 少打扰:「上游已变」只在改动真影响回答时亮
|
|
54
54
|
• 记忆更干净:值得记的才写进画像和档案
|
|
55
55
|
• 搜索更宽容:打错的词纠正到你说过的词
|
|
56
|
-
每次判断约半秒。关掉后全部退回规则,功能不变。`,"judge.rowTitle":"判断模型 · 快思考","judge.stateOn":"可用 · {j}","judge.stateNoApi":"没有可用接口,按规则","judge.stateOff":"已关,按规则","judge.stateTripped":"没有回应,暂时按规则","judge.goConfigure":"去配置…","model.answerGroup":"回答模型 · 慢思考","model.interfaces":"接口","judge.providerLabel":"供应商","judge.provider.none":"沿用已保存的接入(有 OpenRouter 的 key 就直接用)","judge.provider.openrouter":"OpenRouter 上的 Jev(typesafe/jev-latest)","judge.provider.typesafe":"TypeSafe 直连(api.typesafe.ai)","judge.provider.cloudflare":"Cloudflare Workers AI 上的 Jev","judge.provider.custom":"自定义 System One 地址(Kev、Laya、Von…)","judge.provider.llm":"当前对话模型代答(无校准)","judge.provider.off":"关闭,按规则","judge.key":"API key","judge.keyOptional":"API key(可选)","judge.account":"Account ID","judge.token":"API token","judge.url":"地址","judge.urlHint":"任何实现 POST /v1/systemone 的服务,本机的也行。","judge.openrouterStored":"已带入模型接入里保存的 OpenRouter key,在这里改动只影响判断模型。","judge.openrouterHint":"留空则沿用模型接入里保存的 OpenRouter key。按输入 token 计费,输出免费。","judge.typesafeHint":"TypeSafe 的 key。请求经本机代理转发。","judge.cloudflareHint":"账户 ID 与有 Workers AI 权限的 token。请求经本机代理转发。","judge.llmHint":"用你当前选的对话模型按 JSON 回答同样的问题。能用,但慢、花输出 token,概率只是它的意见,不是校准过的。","judge.test":"测试","judge.testOk":"{ms} ms · {model} · 紧急 {p} · 部门 {c}","judge.calibrated":"已校准","judge.uncalibrated":"未校准","panel.recallRelevance":"相关 {p}","panel.recallCorrected":"已把 {a} 纠正为 {b}","panel.recallJudge":"判断模型:{j}","panel.recallPool":"看了 {n} 条候选,索引共 {m} 处命中","panel.recallJudgeFailed":"判断模型没有回应,按规则排序:{e}","panel.recallDropped":"{n} 条被判断模型判为无关","panel.recallMore":"再带几条","recall.scaleLean":"省","recall.scaleStandard":"标准","recall.scaleGenerous":"多带","recall.scaleHint":"带进提问的输入 token 上限。省 4k:一份档案加五到八条对话;标准 12k:两份档案加二十来条;多带 40k:判断模型认为相关的全部带上。窗口小的模型另按窗口的四成封顶。有判断模型按相关度填,没有按排序填。","recall.chip":"回忆","recall.chipOn":"回忆 · {r}","recall.reachFullShort":"全量","recall.menuOn":"开启回忆","recall.menuReach":"搜索范围","recall.menuScale":"带入上下文","recall.menuOnce":"只对这一次提问生效","recall.menuDefault":"设为默认","recall.menuDefaultDone":"已设为默认","recall.menuNeedsJudge":"接入判断模型后可选","recall.reachLight":"轻量","recall.reachDeep":"深挖","recall.reachFull":"全量(慎重)","recall.reachHint":"回忆时给判断模型看多少条候选。轻量:关键词命中里最好的 40 条,逐条读全文再判。深挖:命中里的 2,000 条,先判开头,过关的再读全文,每问约十几秒、几美分。全量:索引里的每一条对话都判,不看关键词,按索引大小计时计价。没有判断模型时只有轻量。","recall.reachFullTitle":"改成全量回忆","recall.reachFullMsg":"全量会把索引里全部 {n} 条对话都交给判断模型:每次提问约 {s} 秒、约 {c} 美元,索引越大越慢越贵。测试里深挖答对的题数和全量一样。确定改成全量?","recall.reachFullOk":"改成全量","panel.recallReach":"搜索范围:{r}","panel.recallJudging":"判断模型正在看候选:{done}/{total}","panel.recallOffHint":"回忆已关。这个节点留着 {n} 条回忆,打开回忆后下次提问会带上。","plugin.updateHintDesktop":"在 Harness 的「插件」页重新添加 {pkg},然后重启 Harness","plugin.updateCopiedDesktop":"包名已复制。去 Harness 的插件页添加,然后重启","panel.recallNoMore":"没有更多了","takeaway.judged":"由判断模型判定 · 置信 {p}","takeaway.conclusive":"定论度:{l}","takeaway.level0":"猜测","takeaway.level1":"倾向","takeaway.level2":"明确","takeaway.level3":"已验证","toolbar.recall":"回忆:发送时用问题里的词,去本机的对话与记忆里查原话带进上下文","toolbar.recallOff":"回忆已关。开了以后,发送时会查过去的对话与记忆","panel.recall":"回忆","panel.recallCount":"{n}/{m} 条","panel.recallEmpty":"回忆开着。发送时会用问题里的词去查过去的对话与记忆,命中列在这里,可逐条去掉。","panel.recallNone":"这次没有查到原话一致的内容。","panel.recallMatched":"命中词:{w}","panel.recallExclude":"不带进上下文","panel.recallInclude":"重新带进上下文","atlas.tabSessions":"对话","atlas.tabMemory":"记忆","atlas.searchPlaceholder":"查对话与记忆里的原话…","recall.turns":"对话","recall.memories":"记忆","recall.open":"看","recall.cite":"引用","recall.import":"导入","recall.searching":"在查…","recall.none":"没有这几个字的原话。匹配是精确的,换个说法试试。","recall.summary":"{n} 处命中 · {m} 个来源","recall.more":"只显示前 {n} 条,缩小范围看更多。","recall.cited":"已作为引用材料连进当前节点。","recall.citedLoose":"已放到画布上。连线到要用它的节点,它才进上下文。","recall.unavailable":"这个版本没有本机索引,查不了原话。","recall.entry":"第 {n} 条","recall.turn":"第 {n} 轮","memory.mine":"ThoughtDAG 的记忆","memory.agentFiles":"其他 Agent 的记忆","memory.agentFilesHint":"只读,来自本机 claude-code 与 codex 的记忆文件。「导入」把一条收进上面的记忆库;「引用」把它放到画布上。","memory.agentFilesNone":"本机没有找到其他 Agent 的记忆文件。","memory.entriesN":"{n} 条","memory.importedOne":"已收进记忆库。","node.recallSource":"引自 {s}","atlas.title":"Agent 对话地图","atlas.subtitle":"按项目文件夹聚合本机的 Agent 对话,点击导入为画布。只读:画布上的任何修改都不会写回对话文件。","atlas.refresh":"刷新","atlas.scanning":"扫描中…","atlas.folders":"项目文件夹","atlas.myCanvases":"我的画布","atlas.unfiled":"未分类","atlas.sessions":"{n} 个会话","atlas.empty":"未发现 Agent 对话。本机命令行 Agent 的对话记录会出现在这里。","atlas.import":"导入为画布","atlas.openCli":"在 CLI 中打开","atlas.cmdCopied":"恢复命令已复制,粘贴到终端即可回到该会话","atlas.parseFailed":"无法解析该会话文件:{msg}","atlas.opened":"已在终端打开该会话","atlas.sources":"接入","atlas.sourcesTitle":"会话来源","atlas.sourcesHint":"内置来源自动探测标准路径。自定义目录经系统选择器授权后加入,一律只读。","atlas.autoDetect":"重新探测","atlas.addDir":"添加目录…","atlas.parserSoon":"解析器开发中","atlas.rootMissing":"未找到","atlas.filterTitle":"过滤标题…","atlas.filteredOut":"当前筛选没有匹配的会话,调整上方筛选条件即可恢复。","atlas.changesSummary":"相比上次查看:{n} 个新会话 · {m} 个有更新","atlas.markAllSeen":"全部标读","atlas.onlyChanged":"仅看变化","atlas.showSub":"子线程","atlas.badgeNew":"新","atlas.appended":"+{n} 轮已追加到该会话的画布尾部","atlas.upToDate":"画布已是该会话的最新镜像","atlas.liveAppended":"会话有新内容:+{n} 轮已自动同步","atlas.mountedBranch":"实验已自动挂回出发节点({n} 轮)","atlas.mountedChapter":"新章已续接主线({n} 轮)","atlas.mountPending":"检测到与其他画布相关的新会话,打开该画布或点击其会话卡即可挂载","atlas.onCanvas":"已有画布","atlas.currentOpen":"当前打开","atlas.mountTo":"挂载到画布…","atlas.mountHint":"该会话将接在所选画布主线的尾部,此后该画布开始监听它的更新。","atlas.turnsN":"{n} 轮","atlas.terminalChoice":"在终端打开时使用的终端","atlas.otherTerminal":"其他 App…","atlas.recent":"最近工作","atlas.webNoScan":"外部会话扫描仅桌面版可用;这里管理你的画布。","atlas.recast":"重新镜像(丢弃画布修改)","atlas.recastDone":"已从源会话重建镜像","confirm.recastTitle":"重新镜像","confirm.recast":"将删除画布「{name}」——包括你的全部修改与自建节点——并从源会话重建完整镜像。源文件不受影响。","switcher.allCanvases":"全部画布与会话…","switcher.archive":"归档(从列表隐藏,数据保留)","atlas.archivedGroup":"已归档 ({n})","atlas.restoreOpen":"还原并打开","confirm.deletePristine":"「{name}」是会话的未修改镜像,删除后可随时从地图重建,不会丢失任何内容。","confirm.deleteDiverged":"「{name}」包含你的修改或自建内容,删除后这些将丢失。源会话不受影响,但可重建的只是原始镜像。","confirm.deleteNative":"「{name}」是唯一副本,删除后不可恢复。","switcher.mirrorBadge":"此画布订阅 {runner} 会话的更新,点击在地图中查看","switcher.mirrorBadgeGone":"源会话未在本机发现——镜像以档案模式运行,源出现后自动恢复监听","toast.importAlreadySubscribed":"该会话已有画布「{name}」,已为你打开(一个会话一张画布)","toast.unsubscribed":"已停止监听 {n} 个对话:它在画布上的镜像已全部删除。要重新连接,在 Agent 对话地图里再次打开即可。","toast.unsubscribedNative":"已停止监听 {n} 个对话:镜像已全部删除。此画布已无监听会话,回归原生画布。","sensitive.title":"发现疑似敏感内容","sensitive.body":"这张画布里有 {n} 处疑似密钥或凭证(多来自 Agent 对话的工具输出):","sensitive.more":"…及另外 {n} 处","sensitive.hint":"继续操作会让这些内容离开本机。建议先删除或编辑相关节点。","sensitive.proceed":"仍要继续","handoff.deeplinkMiss":"没有在已接入的目录里找到这个会话。检查会话地图右上角「接入」的目录列表。","atlas.mergedName":"合集 · {title} 等 {n} 个对话","atlas.handoffTitle":"一键接入","atlas.handoffOn":"已启用","atlas.handoffOff":"未启用","atlas.handoffOutdated":"有更新(或本地文件被改动过)","atlas.handoffEnable":"启用","atlas.handoffUpdate":"更新","atlas.handoffRemove":"移除","atlas.handoffEnableTitle":"启用一键接入","atlas.handoffInstalled":"已启用。在 Agent 里输入 {cmd} 即可把当前会话带进 ThoughtDAG。","confirm.installCommand":`安装本地命令文件:
|
|
56
|
+
每次判断约半秒。关掉后全部退回规则,功能不变。`,"judge.rowTitle":"判断模型 · 快思考","judge.stateOn":"可用 · {j}","judge.stateNoApi":"没有可用接口,按规则","judge.stateOff":"已关,按规则","judge.stateTripped":"没有回应,暂时按规则","judge.goConfigure":"去配置…","model.answerGroup":"回答模型 · 慢思考","model.interfaces":"接口","judge.providerLabel":"供应商","judge.provider.none":"沿用已保存的接入(有 OpenRouter 的 key 就直接用)","judge.provider.openrouter":"OpenRouter 上的 Jev(typesafe/jev-latest)","judge.provider.typesafe":"TypeSafe 直连(api.typesafe.ai)","judge.provider.cloudflare":"Cloudflare Workers AI 上的 Jev","judge.provider.custom":"自定义 System One 地址(Kev、Laya、Von…)","judge.provider.llm":"当前对话模型代答(无校准)","judge.provider.off":"关闭,按规则","judge.key":"API key","judge.keyOptional":"API key(可选)","judge.account":"Account ID","judge.token":"API token","judge.url":"地址","judge.urlHint":"任何实现 POST /v1/systemone 的服务,本机的也行。","judge.openrouterStored":"已带入模型接入里保存的 OpenRouter key,在这里改动只影响判断模型。","judge.openrouterHint":"留空则沿用模型接入里保存的 OpenRouter key。按输入 token 计费,输出免费。","judge.typesafeHint":"TypeSafe 的 key。请求经本机代理转发。","judge.cloudflareHint":"账户 ID 与有 Workers AI 权限的 token。请求经本机代理转发。","judge.llmHint":"用你当前选的对话模型按 JSON 回答同样的问题。能用,但慢、花输出 token,概率只是它的意见,不是校准过的。","judge.test":"测试","judge.testOk":"{ms} ms · {model} · 紧急 {p} · 部门 {c}","judge.calibrated":"已校准","judge.uncalibrated":"未校准","panel.recallRelevance":"相关 {p}","panel.recallCorrected":"已把 {a} 纠正为 {b}","panel.recallJudge":"判断模型:{j}","panel.recallPool":"看了 {n} 条候选,索引共 {m} 处命中","panel.recallJudgeFailed":"判断模型没有回应,按规则排序:{e}","panel.recallDropped":"{n} 条被判断模型判为无关","panel.recallMore":"再带几条","recall.scaleLean":"省","recall.scaleStandard":"标准","recall.scaleGenerous":"多带","recall.scaleHint":"带进提问的输入 token 上限。省 4k:一份档案加五到八条对话;标准 12k:两份档案加二十来条;多带 40k:判断模型认为相关的全部带上。窗口小的模型另按窗口的四成封顶。有判断模型按相关度填,没有按排序填。","recall.chip":"回忆","recall.chipOn":"回忆 · {r}","recall.reachFullShort":"全量","recall.menuOn":"开启回忆","recall.menuReach":"搜索范围","recall.menuScale":"带入上下文","recall.menuOnce":"只对这一次提问生效","recall.menuDefault":"设为默认","recall.menuDefaultDone":"已设为默认","recall.menuNeedsJudge":"接入判断模型后可选","recall.reachLight":"轻量","recall.reachDeep":"深挖","recall.reachFull":"全量(慎重)","recall.reachHint":"回忆时给判断模型看多少条候选。轻量:关键词命中里最好的 40 条,逐条读全文再判。深挖:命中里的 2,000 条,先判开头,过关的再读全文,每问约十几秒、几美分。全量:索引里的每一条对话都判,不看关键词,按索引大小计时计价。没有判断模型时只有轻量。","recall.reachFullTitle":"改成全量回忆","recall.reachFullMsg":"全量会把索引里全部 {n} 条对话都交给判断模型:每次提问约 {s} 秒、约 {c} 美元,索引越大越慢越贵。测试里深挖答对的题数和全量一样。确定改成全量?","recall.reachFullOk":"改成全量","recall.reachFullEmpty":"索引里还没有可以交给判断模型的对话,或者索引正在重建。先用轻量或深挖问一次,索引建好后再选全量。","panel.recallReach":"搜索范围:{r}","panel.recallJudging":"判断模型正在看候选:{done}/{total}","panel.recallOffHint":"回忆已关。这个节点留着 {n} 条回忆,打开回忆后下次提问会带上。","plugin.updateHintDesktop":"在 Harness 的「插件」页重新添加 {pkg},然后重启 Harness","plugin.updateCopiedDesktop":"包名已复制。去 Harness 的插件页添加,然后重启","panel.recallNoMore":"没有更多了","takeaway.judged":"由判断模型判定 · 置信 {p}","takeaway.conclusive":"定论度:{l}","takeaway.level0":"猜测","takeaway.level1":"倾向","takeaway.level2":"明确","takeaway.level3":"已验证","toolbar.recall":"回忆:发送时用问题里的词,去本机的对话与记忆里查原话带进上下文","toolbar.recallOff":"回忆已关。开了以后,发送时会查过去的对话与记忆","panel.recall":"回忆","panel.recallCount":"{n}/{m} 条","panel.recallEmpty":"回忆开着。发送时会用问题里的词去查过去的对话与记忆,命中列在这里,可逐条去掉。","panel.recallNone":"这次没有查到原话一致的内容。","panel.recallMatched":"命中词:{w}","panel.recallExclude":"不带进上下文","panel.recallInclude":"重新带进上下文","atlas.tabSessions":"对话","atlas.tabMemory":"记忆","atlas.searchPlaceholder":"查对话与记忆里的原话…","recall.turns":"对话","recall.memories":"记忆","recall.open":"看","recall.cite":"引用","recall.import":"导入","recall.searching":"在查…","recall.none":"没有这几个字的原话。匹配是精确的,换个说法试试。","recall.summary":"{n} 处命中 · {m} 个来源","recall.more":"只显示前 {n} 条,缩小范围看更多。","recall.cited":"已作为引用材料连进当前节点。","recall.citedLoose":"已放到画布上。连线到要用它的节点,它才进上下文。","recall.unavailable":"这个版本没有本机索引,查不了原话。","recall.entry":"第 {n} 条","recall.turn":"第 {n} 轮","memory.mine":"ThoughtDAG 的记忆","memory.agentFiles":"其他 Agent 的记忆","memory.agentFilesHint":"只读,来自本机 claude-code 与 codex 的记忆文件。「导入」把一条收进上面的记忆库;「引用」把它放到画布上。","memory.agentFilesNone":"本机没有找到其他 Agent 的记忆文件。","memory.entriesN":"{n} 条","memory.importedOne":"已收进记忆库。","node.recallSource":"引自 {s}","atlas.title":"Agent 对话地图","atlas.subtitle":"按项目文件夹聚合本机的 Agent 对话,点击导入为画布。只读:画布上的任何修改都不会写回对话文件。","atlas.refresh":"刷新","atlas.scanning":"扫描中…","atlas.folders":"项目文件夹","atlas.myCanvases":"我的画布","atlas.unfiled":"未分类","atlas.sessions":"{n} 个会话","atlas.empty":"未发现 Agent 对话。本机命令行 Agent 的对话记录会出现在这里。","atlas.import":"导入为画布","atlas.openCli":"在 CLI 中打开","atlas.cmdCopied":"恢复命令已复制,粘贴到终端即可回到该会话","atlas.parseFailed":"无法解析该会话文件:{msg}","atlas.opened":"已在终端打开该会话","atlas.sources":"接入","atlas.sourcesTitle":"会话来源","atlas.sourcesHint":"内置来源自动探测标准路径。自定义目录经系统选择器授权后加入,一律只读。","atlas.autoDetect":"重新探测","atlas.addDir":"添加目录…","atlas.parserSoon":"解析器开发中","atlas.rootMissing":"未找到","atlas.filterTitle":"过滤标题…","atlas.filteredOut":"当前筛选没有匹配的会话,调整上方筛选条件即可恢复。","atlas.changesSummary":"相比上次查看:{n} 个新会话 · {m} 个有更新","atlas.markAllSeen":"全部标读","atlas.onlyChanged":"仅看变化","atlas.showSub":"子线程","atlas.badgeNew":"新","atlas.appended":"+{n} 轮已追加到该会话的画布尾部","atlas.upToDate":"画布已是该会话的最新镜像","atlas.liveAppended":"会话有新内容:+{n} 轮已自动同步","atlas.mountedBranch":"实验已自动挂回出发节点({n} 轮)","atlas.mountedChapter":"新章已续接主线({n} 轮)","atlas.mountPending":"检测到与其他画布相关的新会话,打开该画布或点击其会话卡即可挂载","atlas.onCanvas":"已有画布","atlas.currentOpen":"当前打开","atlas.mountTo":"挂载到画布…","atlas.mountHint":"该会话将接在所选画布主线的尾部,此后该画布开始监听它的更新。","atlas.turnsN":"{n} 轮","atlas.terminalChoice":"在终端打开时使用的终端","atlas.otherTerminal":"其他 App…","atlas.recent":"最近工作","atlas.webNoScan":"外部会话扫描仅桌面版可用;这里管理你的画布。","atlas.recast":"重新镜像(丢弃画布修改)","atlas.recastDone":"已从源会话重建镜像","confirm.recastTitle":"重新镜像","confirm.recast":"将删除画布「{name}」——包括你的全部修改与自建节点——并从源会话重建完整镜像。源文件不受影响。","switcher.allCanvases":"全部画布与会话…","switcher.archive":"归档(从列表隐藏,数据保留)","atlas.archivedGroup":"已归档 ({n})","atlas.restoreOpen":"还原并打开","confirm.deletePristine":"「{name}」是会话的未修改镜像,删除后可随时从地图重建,不会丢失任何内容。","confirm.deleteDiverged":"「{name}」包含你的修改或自建内容,删除后这些将丢失。源会话不受影响,但可重建的只是原始镜像。","confirm.deleteNative":"「{name}」是唯一副本,删除后不可恢复。","switcher.mirrorBadge":"此画布订阅 {runner} 会话的更新,点击在地图中查看","switcher.mirrorBadgeGone":"源会话未在本机发现——镜像以档案模式运行,源出现后自动恢复监听","toast.importAlreadySubscribed":"该会话已有画布「{name}」,已为你打开(一个会话一张画布)","toast.unsubscribed":"已停止监听 {n} 个对话:它在画布上的镜像已全部删除。要重新连接,在 Agent 对话地图里再次打开即可。","toast.unsubscribedNative":"已停止监听 {n} 个对话:镜像已全部删除。此画布已无监听会话,回归原生画布。","sensitive.title":"发现疑似敏感内容","sensitive.body":"这张画布里有 {n} 处疑似密钥或凭证(多来自 Agent 对话的工具输出):","sensitive.more":"…及另外 {n} 处","sensitive.hint":"继续操作会让这些内容离开本机。建议先删除或编辑相关节点。","sensitive.proceed":"仍要继续","handoff.deeplinkMiss":"没有在已接入的目录里找到这个会话。检查会话地图右上角「接入」的目录列表。","atlas.mergedName":"合集 · {title} 等 {n} 个对话","atlas.handoffTitle":"一键接入","atlas.handoffOn":"已启用","atlas.handoffOff":"未启用","atlas.handoffOutdated":"有更新(或本地文件被改动过)","atlas.handoffEnable":"启用","atlas.handoffUpdate":"更新","atlas.handoffRemove":"移除","atlas.handoffEnableTitle":"启用一键接入","atlas.handoffInstalled":"已启用。在 Agent 里输入 {cmd} 即可把当前会话带进 ThoughtDAG。","confirm.installCommand":`安装本地命令文件:
|
|
57
57
|
{path}
|
|
58
58
|
|
|
59
59
|
该命令读取本机会话并在 ThoughtDAG 中打开,可在此移除。`,"atlas.mergeSelected":"已选 {n} 个对话","atlas.mergeNew":"合并为新画布","atlas.mergeInto":"合并入画布…","atlas.pickForMerge":"选入合并","atlas.merged":"已把 {n} 个对话并排放入画布,各自独立监听。链之间没有连线——上下文关系由你来画。","atlas.mergeSkippedInfo":"{n} 个对话已有画布,跳过(一个会话只有一张画布)。","panel.revertToSource":"还原为源文本","panel.ctxOrder":"汇入顺序(先 → 后)","panel.ctxOrderUp":"整块提前","panel.ctxOrderDown":"整块置后","panel.reverted":"已还原为导入时的源文本","atlas.openApp":"在 App 中打开({name})","atlas.openTerminal":"在终端打开","atlas.appOpened":"已唤起 App,会话 id 已复制,可在 App 内搜索定位","atlas.sortTime":"时间","atlas.sortName":"名称","atlas.sortSize":"大小","atlas.sortRunner":"CLI","confirm.deleteNodesTitle":"删除节点","confirm.deleteNodes":"删除选中的 {n} 个节点?","confirm.deleteCanvasTitle":"删除画布","confirm.deleteCanvas":"删除「{name}」及其全部节点?此操作无法撤销。","toast.pasteFileHint":"从文件管理器复制的文件,浏览器读不到内容。把文件直接拖进画布即可。","toast.copied":"已复制到剪贴板","toast.exported":"已导出「{name}」","toast.imported":"已导入「{name}」({n} 个节点)","toast.importFailedJson":"导入失败:不是有效的 JSON","toast.importManifest":"这是运行 manifest,即画布的审计记录。它只记录出处,不含完整内容,无法导入。请从画布菜单导出 .thoughtdag.json 备份再导入。","toast.importFailedShape":"导入失败:文件里的 nodes 不是画布节点(缺 position/data)。请导入从画布菜单导出的 .thoughtdag.json 备份。","toast.importFailedGeneric":"导入失败:{msg}","toast.importFailedMissing":"导入失败:缺少 nodes/edges 数组","toast.generationFailed":"生成失败:{message}","toast.editMakesStale":"问题已修改:下游 {n} 个节点的回答基于旧内容(可手动重跑)","timeline.label":"时间轴:按创建时间跳转到节点","timeline.created":"创建于","timeline.modified":"最后修改","timeline.openOverview":"打开完整时间线","tlov.title":"时间线","tlov.count":"{n} 步","tlov.empty":"时间线上还没有内容。","tlov.undated":"无时间","tlov.detail":"详略","tlov.detailTitle":"每一步显示多少:主题、结论、短述、摘要。文字完整显示,不截断。","ladder.level0":"主题","ladder.level1":"结论","ladder.level2":"短述","ladder.level3":"摘要","tlov.locate":"定位","tlov.gedankenGenerate":"生成思路导语","tlov.gedankenLoading":"正在梳理…","tlov.gedankenStale":"导语已过期","tlov.gedankenRedo":"重新生成","tlov.gedankenFailed":"导语生成失败,请重试。","timeline.clickHint":"单击定位 · 双击打开","tlov.exportPoster":"导出海报","tlov.exportingPoster":"绘制中…","tlov.exportPosterTitle":"把这段思路导出为手稿编年史海报(PNG)","share.directLane":"只读链接","share.linkTooLong":"画布较大:链接可能被部分聊天工具截断而打不开。发送下面的完整画布文件更稳妥。","share.fullFile":"导出完整画布 (.json)","share.readonlyMark":"附只读标记","import.readonlyTitle":"只读分享的画布","import.readonlyConfirm":"对方以只读方式分享了这份画布。导入会在你这里创建一份可编辑副本,继续吗?","share.directNote":"链接携带整张画布的只读副本,打开即看、无需账号,在任何设备生成都可访问。适合聊天、邮件、文档。","question.lockedWhileGenerating":"回答生成中,先停止再编辑问题。","question.editCancel":"取消","question.editSubmit":"提交并生成","toast.noModelYet":"还没有连接模型。选一家服务商填 key,然后回到节点点重试。","toast.rateLimited":"模型限流了这次请求(免费档按分钟限速)。等半分钟,回到节点点重试。","toast.contextOverWindow":"上下文约 {est} tokens,超出 {model} 的窗口({limit})。换个窗口更大的模型,或修剪连线和附件。","toast.visionRerouted":"「{from}」不能看图,这次由「{to}」代答。","toast.visionLearnedTrue":"已验证 {m} 支持图片理解,📷 标记已自动点亮。","toast.visionLearnedFalse":"{m} 读不了图片:已按纯文本重试成功,并为它关闭视觉标记(可在模型接口改回)。","toast.imagesAsText":"视觉模型没接住这条上下文(通常是它的窗口小得多),已回到「{model}」,用图片的伴随文本重答。","takeaway.insight":"洞见","takeaway.ruleout":"排除","takeaway.decision":"决策","takeaway.pivot":"转向","takeaway.open":"待解","node.generatedByTitle":"生成这个版本的模型。生成时记录,之后切换全局模型也不会混淆答案的出处。","node.pinnedModel":"已固定模型:{m}(下次生成使用)","node.gatewaySearching":"联网搜索中…","node.gatewaySearched":"已联网搜索","node.gatewaySearchedTitle":"这个版本的回答由模型网关联网搜索后生成。","node.exploredHere":"有分支从这段文字出发探索。点击跳转到该分支","condense.editLocked":"凝练进行中:画布暂时只读(可以查看),编辑等副本生成后继续。","condense.entryBuilding":"凝练进行中(第 {i}/{n} 段)· 点击查看","condense.runningBg":"正在后台凝练:关闭此窗口不会中断,工具栏图标显示进度。","condense.copyIntroShort":"勾选要坍缩的段,生成凝练副本;原树不动。","condense.copyIntroFull":"生成一棵凝练副本放在原树右侧:勾选的连续段坍缩成蒸馏节点(决策与结论清单,高光原文保真),其余节点原样复制、连线照接。原树一个字都不动;决策/转向徽章的节点永不坍缩。","condense.scanLine":"已检查 {turns} 个轮次,{n} 段候选;最近 3 步是工作前沿,不参与凝练。","condense.rescan":"重新扫描","condense.rescanTitle":"重新检测全图的候选段(本地计算,不调用模型)","condense.copyFootnote":"原树不动 · 一步撤销移除副本","condense.buildCopy":"生成凝练副本({n} 段坍缩 · 省 {tok} tok)","condense.buildingRun":"正在蒸馏第 {i}/{n} 段(带前情提要,逐段小调用)…","condense.copyDone":"凝练副本已生成:{runs} 段坍缩,副本共 {n} 个节点,就在原树右侧。","condense.copyReady":"凝练副本已生成,就在原树右侧","condense.copyCompareHint":"同一个问题连到两边各问一次即可对比;蒸馏节点的芯片跳回原段。","condense.viewCopy":"查看副本","condense.archiveOriginal":"归档原树","condense.originalArchived":"原树已归档:淡化显示、不进上下文,节点右键可随时恢复。","node.condensedFrom":"凝练自 {n} 步","node.condensedFromTitle":"这个节点由原树的一段轮次蒸馏而来。点击高亮并跳到原段。","condense.segIntro":"下面是本地找出的候选链段(连续无分叉的问答段)。悬停一条,画布上对应的段会亮起。每段独立决定:先蒸馏预览,或直接降低出场形态。降低后的节点在画布上收成门牌,所见即所喂。","condense.segNothing":"没有 3 步以上的连续直链段。这张图很紧凑。","condense.segMeta":"{n} 步 · 省 {tok} tok","condense.segKeyMoves":"{n} 个决策/转向","condense.segDistill":"蒸馏预览(一次小调用)","condense.segDistilling":"蒸馏中,几秒…","condense.segApplyPlain":"直接降低","condense.segApplyPlainTitle":"不生成蒸馏便签,这段每一步以收获句出场","condense.segKeepNote":"同时生成蒸馏便签","condense.segApply":"应用({n} 步 · 省 {tok} tok)","condense.segApplied":"已凝练 {n} 步:画布上收成门牌,下游上下文改收收获句。一步撤销可恢复。","condense.segDone":"已凝练","condense.modelLabel":"审查用模型","condense.modelGlobal":"跟随全局({model})","condense.auditingHint":"大图或思考型模型可能要一两分钟;换更快的模型可以缩短等待。","condense.entryTitle":"凝练:让模型检查全图,建议哪些轮次可以降低颗粒度","condense.title":"凝练","condense.intro":"让模型通读全图的结构与收获句(不读全文,便宜一个量级),找出可以以收获句形式进入下游上下文的轮次:同一话题的反复雕琢、被后续版本覆盖的中间稿。它只能建议两种你已经了解的动作:降低出场形态,或再附一份「仍然有效的决策」蒸馏便签。","condense.introTrust":"所有建议默认不勾选;每条带理由与节省额度;涉及决策/转向徽章的会标警示;应用是一步撤销;被降低的节点戴角标,点一下即恢复全文。","condense.run":"开始检查({n} 个轮次 · 一次模型调用)","condense.tooSmall":"画布轮次还少,暂时不需要凝练。","condense.auditing":"审查员正在通读收获句…","condense.planHead":"检查了 {audited} 个轮次,{n} 条建议,全部应用约省 {tok} tok","condense.nothing":"审查员没有找到值得降低颗粒度的轮次。这张图很紧凑。","condense.typeLower":"降低出场形态","condense.typeMerge":"降低 + 蒸馏便签","condense.itemMeta":"{n} 个节点 · 省 {tok} tok","condense.keyMoves":"含决策/转向","condense.previewDistilled":"预览蒸馏稿","condense.reversible":"应用后一步撤销可全部恢复","condense.apply":"应用所选({n} 条 · 省 {tok} tok)","condense.applied":"已凝练 {n} 个轮次,生成 {notes} 份蒸馏便签。节点角标可随时恢复全文。","node.condensedForm":"收获句出场","node.condensedFormTitle":"这个节点以收获句进入下游上下文(全文仍在卡片里)。点击恢复全文出场。","ctx.formSummary":"以收获句出场(下游上下文只收这一句)","ctx.formFull":"恢复全文出场","node.summaryLabel":"摘要","node.summaryTitle":"这是自动摘要,只给人看,不进上下文。双击卡片在面板中读全文。","node.staleBadge":"上游已变","node.staleTitle":"此回答基于旧的上游内容。点击重放(追加新版本,可对比)","node.staleJudged":"上游改动影响此回答(判断模型 {p})。点击重放,追加新版本可对比","replay.chip":"重放陈旧 ({n})","replay.chipTitle":"按依赖顺序重跑所有陈旧节点(先确认,逐个追加新版本)","replay.confirmTitle":"批量重放陈旧节点","replay.confirmMsg":"将按依赖顺序重放 {n} 个节点(各自追加新版本,不覆盖旧回答),预计发送约 {tok} token。重放过程中随时可以停止。","replay.confirmBtn":"开始重放","replay.progress":"重放中 {done}/{total}…","replay.stop":"停止","replay.stopped":"重放已停止(完成 {done}/{total}),其余节点保留陈旧标记","replay.done":"重放完成:{done} 个节点已更新","toolbar.diagnose":"诊断图结构:残差边 / 影子引用 / 盲评破盲 / 巨链等","diag.title":"诊断报告","diag.summary":"{a} 处确定问题 · {b} 项观察","diag.clean":"图很干净,没有发现问题。","diag.tier1":"确定问题(可一键处理)","diag.tier2":"观察(供判断)","diag.locate":"定位","diag.fix":"删除该边","diag.residual":"残差实线:「{a}」到「{b}」与更长的链重复,属于冗余边","diag.shadow":"影子引用:「{a}」已沿实线全文流入「{b}」,这条引用使内容进入两次","diag.breach":"盲评破盲:候选「{a}」能读到候选「{b}」的内容","diag.asym":"候选不对称:「{a}」有 {n} 个池外私有输入,与兄弟候选待遇不同","diag.longChain":"巨链:「{a}」深 {d} 层、约 {tok} tok。考虑合并摘要后归档上游","diag.openBranches":"开放支线 {n} 条:未收敛也未归档的叶子在堆积","diag.collider":"归因坍缩点:「{a}」({n} 路扇入后继续延伸,下游结论难以归属到源支)","diag.orphans":"未连线材料 {n} 个,不进入任何上下文","diag.loadBearing":"承重节点:「{a}」支撑下游 {n} 个节点,编辑它会大面积陈旧","toast.unknownError":"未知错误","toast.projectsLoadFailed":"加载画布失败,将以空画布启动","toast.unsupportedFile":"暂不支持 {name} 的格式。旧版 .doc 请另存为 .docx 或 PDF 后再拖入。","export.contextChain":"上下文链","export.selectedNodes":"选中节点","export.attachmentsLabel":"附件:","evaluator.badge":"评审者","toolbar.relayout":"一键排版","toolbar.align":"对齐","toolbar.duplicate":"复制","toolbar.duplicateTitle":"把选中节点整体复制一份(内部连线保留,跨出选区的连线不带走)","confirm.relayoutTitle":"一键排版","confirm.relayoutMsg":"按箭头顺序重新排列全部节点?手动摆放的位置将被替换(可 Cmd+Z 撤销)。","confirm.alignTitle":"对齐所选节点","confirm.alignMsg":"将选中的 {n} 个节点按对话顺序竖向排成一列?(可 Cmd+Z 撤销)","common.confirmAlign":"对齐","refs.title":"参考来源","caps.title":"能力","caps.webSearch":"联网搜索","caps.engineServer":"服务端默认({engine})","caps.engineStd":"search_std · 标准,约 ¥0.01/次","caps.enginePro":"search_pro · 来源更好,约 ¥0.03/次","caps.engineAnysearch":"AnySearch · 聚合引擎","caps.anysearchKeyPlaceholder":"AnySearch key…","caps.anysearchHintQuota":"每日额度按 key 或 IP(本地免 key)计;免费注册可提升:","caps.anysearchHintEnable":"当前接口没有搜索通道。填入 AnySearch key(免费注册)即可开启网页搜索:","caps.anysearchSaved":"搜索 key 已保存。","caps.anysearchCleared":"搜索 key 已移除。","caps.enginePickTitle":"联网搜索用哪个服务端引擎。何时搜索仍由模型判断,这里决定搜得多好。","caps.webSearchOff":"当前接口没有自带搜索通道。","caps.scholar":"学术检索","caps.scholarDesc":"arXiv + Semantic Scholar · 免费公开 API,始终可用","caps.memory":"记忆","caps.memoryTitle":"常驻长期记忆:模型安静地记住关于你的持久事实,并在相关时使用。每次写入都会自我宣告;所有条目在管理器中统一维护。","caps.on":"开","caps.off":"关","memory.entryTitle":"记忆:模型跨画布记住的关于你的事。查看、编辑、导入、导出。","memory.manage":"管理","memory.managerTitle":"记忆","memory.hint":"{n} 条 · 相关时用于所有画布","memory.empty":"还没有记忆。工作中模型会自动保存持久事实(每次保存都有提示),也可以在这里手动添加或导入。","memory.add":"添加记忆","memory.import":"导入(粘贴)","memory.importPlaceholder":"每行一条。从其他助手设置页复制的记忆列表可以直接粘贴。","memory.importConfirm":"导入","memory.export":"导出 JSON","memory.exportTitle":"记忆是你的:一个文件,随时带走。","memory.kindAuto":"自动","memory.catPreference":"偏好","memory.catIdentity":"身份","memory.catProject":"项目","memory.kindManual":"手动","memory.kindImported":"导入","mp.subtitle":"你的画像、每个项目的档案,和它们的来源。上面的搜索覆盖全部。","mp.settings":"设置","mp.recallOn":"提问时回忆过去的对话","mp.recallOnHint":"发送前按问题找相关档案与对话,带进上下文。节点上可逐次关。","mp.memoryOn":"从对话里更新记忆","mp.memoryOnHint":"回答后判断有没有值得记的,写进「你」或对应项目档案。每次留一行变更记录。","mp.judgeRow":"判断模型与预算","mp.judgeRowHint":"在「配置模型 API」里设置,这里不重复。","mp.open":"打开…","mp.you":"你","mp.preferences":"偏好","mp.identity":"身份","mp.docEmpty":"还没有内容。工作中模型会写,也可以手动写。","mp.updatedAt":"更新于 {d}","mp.docHint":"一行一条。模型更新时会改写相关的行,不追加;每行记着来自哪个画布、哪天、是本人说的还是推断的。","mp.changelog":"变更记录","mp.evidenceStated":"本人说的","mp.evidenceInferred":"推断的","mp.evidenceManual":"手改","mp.evidenceFolded":"早期条目","mp.lineWas":"改写自:{t}","mp.save":"保存","mp.edit":"编辑","mp.export":"导出","mp.editedNote":"手动编辑","mp.projects":"项目","mp.editTopics":"编辑主题…","mp.noTopics":"还没有主题。在「编辑主题」里写几个或让模型提议,打标之后就能生成档案。","mp.notBuilt":"还没生成","mp.labeledTurns":"{n} 轮已标","mp.newTurns":"{n} 轮新内容","mp.pending":"{n} 条待并入","mp.fromTurns":"来自 {n} 轮","mp.build":"生成档案","mp.update":"更新档案","mp.updateN":"更新档案({n} 轮新内容)","mp.rebuild":"从对话重建","mp.building":"在读对话写档案…","mp.pendingList":"待并入","mp.sourceOpen":"看这一轮","mp.filedTag":"记忆","mp.buildHint":"这个主题已标了 {n} 轮对话,点「生成档案」让模型读最新的一批写出来。","mp.needIndex":"这个版本没有本机索引,没有项目档案。","mp.inbox":"待归档 · {n} 条判不出项目的记忆","mp.fileTo":"归到…","mp.discard":"丢弃","mp.filed":"已归到「{name}」档案,待并入。","mp.sources":"来源","mp.sourcesN":"{n} 个来源,只读","mp.index":"本机对话索引","mp.indexLine":"{n} 轮","mp.labelState":"已标 {n} / {m} 轮","panel.recallLead":"带进了 {what}。","panel.recallLeadDossier":"{name} 档案","panel.recallLeadTurns":"{n} 条对话","panel.recallLeadJoin":" 和 ","panel.recallAllOff":"都去掉了,这次不带。","panel.recallHow":"怎么选的","panel.recallDetailYes":"判断模型认为在查具体细节({p}),所以带了对话片段","panel.recallDetailNo":"判断模型认为问的是全貌({p}),只带档案","panel.recallKept":"候选 {n} 条,带入 {k}","panel.recallUsed":"上限 {b} tok(带进提问的输入 token),用了 {u}","panel.relatedAddChip":"词或主题","panel.relatedExpandBtn":"让模型扩展","panel.relatedMore":"还有 {n} 条","panel.relatedAll":"全部","panel.relatedFewer":"收起","panel.relatedTermPlaceholder":"词…","panel.relatedPickTopic":"选主题:","recall.groupSummary":"{s} 个会话 · {n} 处提到","recall.groupedHint":"按会话归组,新的在前","recall.moreIn":"还有 {n} 处没列出,缩小范围看更多。","recall.dossierOpen":"打开","recall.openSession":"看","memory.saved":"已记住:{t}","memory.filedToDossier":"已记到「{name}」档案,待并入:{t}","memory.filedToInbox":"已放到待归档:{t}","memory.mergedPreferences":"偏好已更新:{t}","memory.mergedIdentity":"身份已更新:{t}","dossier.title":"{name} 档案","dossier.updated":"更新于","dossier.secWhat":"是什么","dossier.secDecisions":"定过的决定","dossier.secNow":"现在到哪一步","dossier.secOpen":"还没解决","dossier.badOutput":"模型没有按格式写出档案,再试一次。","dossier.noTopic":"这个主题不存在了。","dossier.nothingToRead":"这个主题还没有标上的对话,先打标。","dossier.logBuilt":"档案生成,来自 {n} 轮","dossier.logUpdated":"并入 {n} 轮新对话、{m} 条记忆","dossier.logEdited":"手动编辑「{s}」","memory.updated":"记忆已更新:{t}","memory.undo":"撤销","memory.rowLabel":"记忆(常驻层)","memory.rowTitle":"记忆开启时,这些条目随每次普通生成进入系统层。点击管理。","caps.vision":"图像识读与识别","caps.visionAuto":"自动(最强模型优先)","caps.visionPickTitle":"由哪个模型识读粘贴的图片、识别扫描页。自动模式优先最强,可能也最贵。","caps.visionOff":"需要至少一个视觉模型,图像识读与「识别」按钮才可用。连接入口:配置模型 API(GLM-4V Flash 有免费档)。","toolbar.webSearch":"联网搜索:模型自行判断何时搜索","toolbar.webSearchOff":"联网搜索已关闭","toolbar.model":"模型:对新的生成生效","model.vision":"视觉","model.inherit":"模型:跟随全局","search.placeholder":"搜索节点…(↑↓ 选择,Enter 定位)","search.count":"找到 {n} 个","search.entryTitle":"画布内搜索(⌘F):搜问题、回答、便签、高光、材料名","search.more":"还有 {n} 个结果,继续输入以缩小范围","toast.importNoConversations":"这个文件里没有找到含消息的对话","toast.importedChats":"已导入 {n} 个对话,共 {m} 个节点","import.title":"导入对话","import.subtitle":"每个选中的对话会成为一张独立画布。ChatGPT 的编辑/重新生成分支会保留为图的分叉。","import.selectAll":"全选","import.messages":"{n} 条消息","import.confirm":"导入选中的 {n} 个","evaluator.rerun":"立即重新评审","paradigm.emptyTitle":"设计一个范式","paradigm.emptyHint":"范式只有两种节点:对话节点是人提问的位置,Prompt 节点用固定提示词处理上游信息。这里不运行 LLM。乐谱写好后,实例化为对话画布去现场演奏。","paradigm.instantiate":"实例化为画布","paradigm.instantiateTitle":"把这个范式变成可运行的对话画布(在你动手之前不会有任何生成)","paradigm.kind.human":"对话(人)","paradigm.kind.prompt":"Prompt(机器)","paradigm.addHuman":"对话节点","paradigm.addPrompt":"Prompt 节点","paradigm.titlePlaceholder":"步骤名……","paradigm.humanHintPlaceholder":"给操作者的引导(可选)。实例化后这里由人输入,运行会在此暂停等待……","paradigm.promptPlaceholder":"Prompt:处理上游节点流入的信息,人设写在开头即可。上游就绪后自动运行……","paradigm.insertPersona":"把这个人设插入 Prompt 开头","paradigm.yourTurn":"轮到你","paradigm.start":"开始","paradigm.waitingUpstream":"等待上游","paradigm.exportParadigm":"导出范式 (.json)","paradigm.newParadigm":"新建范式","landing.paradigmTitle":"从一个范式开始","landing.paradigmDesc":"范式是可复用的协作结构:先编排人与 AI 的分工,再实例化为画布运行","paradigm.exampleRuleOut":"示例:排除 / 确认","paradigm.badge":"范式","paradigm.expand":"展开 {n} 个视角","paradigm.expandTitle":"把这一步扇出为预配的角色分支,何时展开由你决定","fanout.entry":"添加视角","fanout.entryTitle":"N 个角色视角:并行盲答一次,或作为评审者持续跟随","fanout.title":"添加视角","fanout.subtitle":"N 个角色、一套机制、两种运行方式:并行盲答一次(候选池),或挂在思路旁持续评审。","fanout.modeOnce":"回答一次","fanout.modeFollow":"持续评审","fanout.modeOnceHint":"每个视角独立回答一次、彼此不可见,正是 rule-in / rule-out 的盲评候选池。","fanout.modeFollowHint":"每个视角成为评审者:红色跟随边滑向思路最新末端,上游每次更新自动重评。","fanout.rounds":"自动重评轮数","fanout.roundsHint":"每次人工动作后最多自动评审几轮(有界循环,写进范式文件)","fanout.question":"共同问题","fanout.instruction":"常驻指令(每次重评执行)","fanout.critiqueInstruction":"批评上面的讨论:指出夸大之处、缺失的证据和未言明的假设。如有前一版,说明哪些点已改进。保持简洁、具体。","fanout.templates":"角色模板","fanout.custom":"自定义角色(每行一个:名称: 提示词)","fanout.customPlaceholder":`贝叶斯主义者: 你严格用先验与证据推理……
|
|
@@ -63,7 +63,7 @@ Economist: You analyze through incentives and trade-offs...`,"fanout.confirm":"F
|
|
|
63
63
|
`);m=w.pop()||"";for(const E of w){const v=E.trim();if(!v.startsWith("data: "))continue;const A=v.slice(6);if(A==="[DONE]")continue;let T;try{T=JSON.parse(A)}catch{continue}if(T.error){const _=typeof T.error=="string"?T.error:T.error.message;throw new Error(_||"Upstream stream error")}const C=T.choices?.[0];if(!C)continue;const I=C.delta;I?.content&&(p+=I.content,a(I.content));const O=I?.reasoning??I?.reasoning_content;O&&r(O);for(const _ of I?.annotations??[]){const S=_.url_citation;S?.url&&!s.has(S.url)&&s.set(S.url,{title:S.title||S.url,url:S.url,media:"Web"})}C.finish_reason&&(x=C.finish_reason)}}return{text:p,finishReason:x}}async function qq(e,t,n,a,r,s,o,u){const d=d8(n,s),h=x2(e.baseURL)&&u!==!1,m=new Map;let p="",x="";const b=w=>{p+=w,a(w,p)},y=w=>{x+=w,o?.onReasoning?.(w,x)};try{let w=await mE(e,h?`${t}:online`:t,d,b,y,m,r);if(h&&p.length===0&&(w=await mE(e,t,d,b,y,m,r)),p.length===0)throw new Error(`Model produced no text (finish: ${w.finishReason}, model: ${t}${h?" via :online":""})`);return m.size>0&&o?.onSources?.([...m.values()]),p}catch(w){throw h8(w)}}async function $q(e,t,n,a){try{const r=await fetch(`${e.baseURL.replace(/\/$/,"")}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json","X-Title":"ThoughtDAG"},body:JSON.stringify({model:t,messages:d8(n,a)})});if(!r.ok){const o=await r.json().catch(()=>null);throw new Error(o?.error?.message||`HTTP ${r.status}`)}return(await r.json()).choices?.[0]?.message?.content??""}catch(r){throw h8(r)}}const Wq=`${ci}/api/claude`,f8=()=>{const e=as();return e.length>0?e:void 0},Vq=`${ci}/api/stream`,Gq=`${ci}/api/pdf-extract`,Yq=`${ci}/api/approvals`;async function Kq(e,t){const n=e.id,a=typeof t=="string"?{confirmed:t!=="rejected",...t==="allowed-session"?{scope:"session"}:{}}:t;if(e.channel?.runId&&window.desktopAgents)try{return await window.desktopAgents.answer(e.channel.runId,n,a)}catch{return!1}const r="confirmed"in a&&a.confirmed?"allowed-once":"rejected";try{return(await fetch(`${Yq}/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({outcome:r})})).ok}catch{return!1}}async function Xq(e){const t=await fetch(Gq,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({base64:e})});if(!t.ok){const n=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw new Error(Fl(n,`HTTP ${t.status}`))}return t.json()}async function Qq(e){try{const t=await fetch(`${ci}/api/fetch-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})});if(!t.ok){const n=await t.json().catch(()=>({error:t.status===404?"Proxy has no /api/fetch-url — restart it (npm run server)":`HTTP ${t.status}`}));throw new Error(Fl(n,`HTTP ${t.status}`))}return t.json()}catch(t){throw y2(t)}}function y2(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e instanceof Error?e.message:"Unknown error";return new Error(/fetch|network|Failed to fetch/i.test(t)?`${t} — is the proxy running? (npm run server)`:t)}async function m8(e,t){if(!t?.length)return t;const n=await dr(),a=e??n?.default??void 0,r=a?n?.models.find(s=>s.id===a):void 0;if(!(r&&r.vision===!1&&t.every(s=>s.hasCompanion)))return t}async function p8(e,t){if(!t?.length)return;const n=await dr(),a=e??n?.default??void 0,r=a?n?.models.find(s=>s.id===a):void 0;if(r&&r.vision===!1)throw new Error(Te("error.textOnlyModelImages"))}async function er(e,t,n,a){const r=n||oe.getState().selectedModel||void 0;t=await m8(r,t);const s=b2();if(s&&r)return await p8(r,t),$q(s,r,e,t);try{const o=await fetch(Wq,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e,images:t?.length?t:void 0,model:n||oe.getState().selectedModel||void 0,...a?.fast?{fast:!0}:{},providers:f8()})});if(!o.ok){const d=await o.json().catch(()=>({error:"Unknown error"}));throw new Error(Fl(d,`HTTP ${o.status}`))}return(await o.json()).text}catch(o){throw y2(o)}}async function g8(e,t,n,a,r,s,o,u){const d=o||oe.getState().selectedModel||void 0;if(d&&si(d)&&window.desktopAgents)return r?.onDispatch?.({messages:e,images:a??[],model:d,toolPrefs:s??{},lane:"proxy"}),HV(e,t,n,a,r,d,u?.cwd?{cwd:u.cwd,sessionPath:u.sessionPath,forkEntryId:u.forkEntryId,continue:u.continue}:void 0,u?.nodeId);a=await m8(d,a);let h=!1;const m={...r,onRerouted:(w,E)=>{h=!0,r?.onRerouted?.(w,E)}},p=async(w,E)=>{const v=b2();return v&&d?(await p8(d,w),r?.onDispatch?.({messages:e,images:w??[],model:d,toolPrefs:s??{},lane:"direct"}),qq(v,d,e,E,n,w,m,s?.web)):(r?.onDispatch?.({messages:e,images:w??[],model:d??"",toolPrefs:s??{},lane:"proxy"}),y(w,E))},x=d?xq(d):void 0,b=!!d&&as().some(w=>w.models.some(E=>E.id===d));if(a?.length&&d&&b&&x!==!1){const w=d.split("/").pop()??d,E=(A,T)=>{bq(d,A)&&(W0(as()).then(ql).catch(()=>{}),We("info",ye(Te(T),{m:w})))};let v=!1;try{const A=await p(a,(T,C)=>{v=!0,t(T,C)});return x===void 0&&!h&&A.trim()&&E(!0,"toast.visionLearnedTrue"),A}catch(A){if(A instanceof DOMException&&A.name==="AbortError"||v||h)throw A;if(x===!0){const C=A instanceof Error?A.message:String(A);throw new Error(`${C} ${Te("error.visionDeclaredHint")}`)}const T=await p(void 0,t);return T.trim()&&E(!1,"toast.visionLearnedFalse"),T}}return p(a,t);async function y(w,E){try{const v=await fetch(Vq,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e,images:w?.length?w:void 0,webSearch:s?.web,scholarSearch:s?.scholar,mcpTools:s?.mcp,...oe.getState().searchEnginePref!=="server"?{searchEngine:oe.getState().searchEnginePref}:{},...oe.getState().anysearchKey?{anysearchKey:oe.getState().anysearchKey}:{},model:o||oe.getState().selectedModel||void 0,providers:f8(),...u?{harness:u}:{}}),signal:n});if(!v.ok){const _=await v.json().catch(()=>({error:"Unknown error"}));throw new Error(Fl(_,`HTTP ${v.status}`))}const A=v.body.getReader(),T=new TextDecoder;let C="",I="",O="";for(;;){const{done:_,value:S}=await A.read();if(_)break;C+=T.decode(S,{stream:!0});const z=C.split(`
|
|
64
64
|
`);C=z.pop()||"";for(const V of z){const P=V.trim();if(!P||!P.startsWith("data: "))continue;const L=P.slice(6);if(L!=="[DONE]")try{const Y=JSON.parse(L);if(Y.error)throw new Error(Fl(Y.error,"Upstream stream error"));Y.text&&(I+=Y.text,E(Y.text,I)),Y.reasoning&&(O+=Y.reasoning,m.onReasoning?.(Y.reasoning,O)),Y.tool?.query&&m.onToolCall?.(Y.tool.name,Y.tool.query),Y.gatewaySearch&&m.onGatewaySearch?.(),typeof Y.harnessSession=="string"&&m.onHarnessSession?.(Y.harnessSession,!!Y.continued),Y.harnessTurn?.session&&m.onHarnessTurn?.(Y.harnessTurn),Y.approval?.id&&m.onApproval?.(Y.approval),Y.approvalDecided?.id&&m.onApprovalDecided?.(Y.approvalDecided),Array.isArray(Y.sources)&&m.onSources?.(Y.sources),Y.rerouted?.to&&(We("info",ye(Te("toast.visionRerouted"),{from:Y.rerouted.from,to:Y.rerouted.to}),7e3),m.onRerouted?.(Y.rerouted.from,Y.rerouted.to)),Y.imageFallback?.model&&(We("info",ye(Te("toast.imagesAsText"),{model:Y.imageFallback.model}),9e3),m.onImageFallback?.(Y.imageFallback.model))}catch(Y){if(Y instanceof Error&&Y.message!==L)throw Y}}}return I}catch(v){throw y2(v)}}}const Yb="att-content:",x8=e=>`${Yb}${e}`,b8=e=>e.type==="application/pdf"&&!!e.content&&!e.contentInVault;async function v2(e){return b8(e)?(await jr(x8(e.id),e.content),{...e,content:"",contentInVault:!0}):e}async function w2(e){return e.contentInVault?await Yo(x8(e.id))??"":e.content}async function k2(e){const t=[];for(const n of e){const a=n.data.attachments;if(!a?.some(s=>s.contentInVault)){t.push(n);continue}const r=[];for(const s of a){if(!s.contentInVault){r.push(s);continue}const o=await w2(s),u={...s,content:o};delete u.contentInVault,r.push(u)}t.push({...n,data:{...n.data,attachments:r}})}return t}async function wp(e){const t=[];for(const n of e){const a=n.data.attachments;if(!a?.some(b8)){t.push(n);continue}const r=[];for(const s of a)r.push(await v2(s));t.push({...n,data:{...n.data,attachments:r}})}return t}async function y8(e){const t=await i8();let n=0;for(const a of t)typeof a!="string"||!a.startsWith(Yb)||e.has(a.slice(Yb.length))||(await bu(a),n++);return n}const Zq=Object.freeze(Object.defineProperty({__proto__:null,gcVault:y8,inlineVaultedContent:k2,internAttachment:v2,internNodes:wp,loadAttachmentContent:w2},Symbol.toStringTag,{value:"Module"}));function Jq(e){return e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/[ \t]+/g," ").replace(/\s*\n\s*(\s*\n\s*)+/g,`
|
|
65
65
|
|
|
66
|
-
`).trim()}const e$=/\.(md|txt|js|ts|tsx|jsx|py|json|csv|yaml|yml|toml|sh|bash|zsh|c|cpp|h|hpp|java|rs|go|rb|swift|kt|css|xml|sql|r|m|lua)$/i,t$=/\.x?html?$/i,n$=/\.(pptx?|key|odp|doc|rtf|odt|xlsx?|numbers|ods)$/i,b0="image/*,.pdf,.txt,.md,.js,.ts,.tsx,.jsx,.py,.json,.csv,.yaml,.yml,.toml,.sh,.c,.cpp,.h,.java,.rs,.go,.rb,.swift,.css,.html,.htm,.xml,.sql";function Kc(e){return`${e.name}|${e.size}|${e.content?.substring(0,100)}`}function a$(e){return new Promise(t=>{const n=Tn(),a=new Date().toISOString(),r=e.type.startsWith("image/"),s=e.type==="application/pdf"||e.name.endsWith(".pdf"),o=e.type==="text/html"||t$.test(e.name),u=e.type.startsWith("text/")||e$.test(e.name),d=e.name.toLowerCase().endsWith(".docx");if(r){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:e.type,size:e.size,addedAt:a,content:m,thumbnailUrl:h.result})},h.readAsDataURL(e)}else if(s){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:"application/pdf",size:e.size,addedAt:a,content:m})},h.readAsDataURL(e)}else d?e.arrayBuffer().then(async h=>{try{const p=await(await ft(()=>import("./index-
|
|
66
|
+
`).trim()}const e$=/\.(md|txt|js|ts|tsx|jsx|py|json|csv|yaml|yml|toml|sh|bash|zsh|c|cpp|h|hpp|java|rs|go|rb|swift|kt|css|xml|sql|r|m|lua)$/i,t$=/\.x?html?$/i,n$=/\.(pptx?|key|odp|doc|rtf|odt|xlsx?|numbers|ods)$/i,b0="image/*,.pdf,.txt,.md,.js,.ts,.tsx,.jsx,.py,.json,.csv,.yaml,.yml,.toml,.sh,.c,.cpp,.h,.java,.rs,.go,.rb,.swift,.css,.html,.htm,.xml,.sql";function Kc(e){return`${e.name}|${e.size}|${e.content?.substring(0,100)}`}function a$(e){return new Promise(t=>{const n=Tn(),a=new Date().toISOString(),r=e.type.startsWith("image/"),s=e.type==="application/pdf"||e.name.endsWith(".pdf"),o=e.type==="text/html"||t$.test(e.name),u=e.type.startsWith("text/")||e$.test(e.name),d=e.name.toLowerCase().endsWith(".docx");if(r){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:e.type,size:e.size,addedAt:a,content:m,thumbnailUrl:h.result})},h.readAsDataURL(e)}else if(s){const h=new FileReader;h.onload=()=>{const m=h.result.split(",")[1];t({id:n,name:e.name,type:"application/pdf",size:e.size,addedAt:a,content:m})},h.readAsDataURL(e)}else d?e.arrayBuffer().then(async h=>{try{const p=await(await ft(()=>import("./index-CSvW8Pqz.js").then(x=>x.i),[])).extractRawText({arrayBuffer:h});t({id:n,name:e.name,type:"text/plain",size:e.size,addedAt:a,content:p.value.trim()})}catch{t(null)}}):o?e.text().then(h=>{t({id:n,name:e.name,type:"text/html",size:e.size,addedAt:a,content:h})}):u?e.text().then(h=>{t({id:n,name:e.name,type:e.type||"text/plain",size:e.size,addedAt:a,content:h})}):t(null)})}async function pE(e){const[t,n]=await Promise.all([ft(()=>import("./pdf-gh-BrLFn.js"),[]),ft(()=>import("./pdf.worker.min-C_APr3k7.js"),[])]);t.GlobalWorkerOptions.workerSrc=n.default;const a=Uint8Array.from(atob(e),r=>r.charCodeAt(0));return t.getDocument({data:a,verbosity:0}).promise}const r$=150;async function gE(e){const t=r$/72,n=[];for(let a=1;a<=e.numPages;a++){const r=document.createElement("canvas");try{const s=await e.getPage(a),o=s.getViewport({scale:t});r.width=Math.ceil(o.width),r.height=Math.ceil(o.height);const u=r.getContext("2d");if(!u)throw new Error("no 2d context");await s.render({canvasContext:u,viewport:o}).promise}catch{r.width=8,r.height=8}n.push(r.toDataURL("image/png").split(",")[1])}return n}async function V0(e,t){if(n$.test(e.name)){We("info",`${e.name}: ${Te("content.officeExportHint")}`);return}const n=await a$(e);if(!n)return;if(n.type==="text/html"){t.add({...n,isExtracting:!0});try{const{extractHtmlMaterial:r}=await ft(async()=>{const{extractHtmlMaterial:o}=await Promise.resolve().then(()=>IM);return{extractHtmlMaterial:o}},void 0),s=await r(n.content);t.update(n.id,{extractedText:s.markdown,numPages:s.numPages,isExtracting:!1})}catch{t.update(n.id,{extractedText:Jq(n.content),isExtracting:!1})}return}if(n.type!=="application/pdf"){t.add(n);return}const a=await v2(n);t.add({...a,isExtracting:!0});try{const r=await Xq(n.content);if(!r.numPages&&!r.text?.trim())throw new Error("empty extraction result");const s=r.numPages||0;let o=r.images;if(!o?.length)try{const u=await pE(n.content);o=await gE(u),u.destroy()}catch{o=void 0}t.update(n.id,{extractedText:r.text,pageImages:o?.length?o:void 0,numPages:s,renderMode:s>Zk?"text-only":"full",isExtracting:!1})}catch{try{const r=await pE(n.content),s=[];for(let u=1;u<=r.numPages;u++)try{const h=await(await r.getPage(u)).getTextContent();s.push(h.items.map(m=>"str"in m?m.str:"").join(" "))}catch{s.push("")}let o;try{o=await gE(r)}catch{o=void 0}r.destroy(),t.update(n.id,{extractedText:s.join(`
|
|
67
67
|
|
|
68
68
|
`).trim(),pageImages:o?.length?o:void 0,numPages:r.numPages,renderMode:r.numPages>Zk?"text-only":"full",isExtracting:!1})}catch{t.update(n.id,{isExtracting:!1})}}}const kd="[*_`~()#>\\[\\]|-]*",s$="\\s+(?:(?:\\d{1,3}[.)]|[-*+>|]|#{1,6}|[-:|]{3,})\\s+)*";function E2(e){const t=[...e.trim()];if(t.length===0)return null;const n=[];let a=!1;for(const r of t){if(/\s/.test(r)){a=!0;continue}const s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n.length===0?n.push(s):a?n.push(`${kd}${s$}${kd}${s}`):n.push(`${kd}${s}`),a=!1}try{return new RegExp(kd+n.join("")+kd,"g")}catch{return null}}function i$(e,t){const n=E2(t);return n?n.test(e):!1}function om(e,t){const n=e??[],a=n.filter(r=>i$(t,r.text));return a.length===n.length?n:a}function xE(e){const t=e.data.question.replace(/\s+/g," ").trim();return t.length>60?`${t.slice(0,60)}…`:t}function v8(e){const t=e.data.highlightMode||"off",n=e.data.highlights||[];if(t==="filter"&&n.length>0)return n.map(a=>a.text).join(`
|
|
69
69
|
|
|
@@ -153,7 +153,7 @@ ${y??`*${ye(Te("reader.pageFail"),{n:p+1})}*`}`),n(p+1,d.length)}if(!a()){if(!m)
|
|
|
153
153
|
`)[0].slice(0,80)}catch{}return null}function wW(e){for(const t of e){if(t.type!=="user/message")continue;const n=t.data;if(!n||n.source?.kind&&n.source.kind!=="user")continue;const a=(n.content??[]).filter(r=>r.type==="text"&&r.text).map(r=>r.text).join(`
|
|
154
154
|
`).trim();if(a&&!a.startsWith("<"))return a.split(`
|
|
155
155
|
`)[0].slice(0,80)}return null}const V8="thoughtdag.atlas.disabledRoots",O2=()=>{try{return new Set(JSON.parse(localStorage.getItem(V8)??"[]"))}catch{return new Set}};function kW(e,t){const n=O2();t?n.add(e):n.delete(e),localStorage.setItem(V8,JSON.stringify([...n]))}const jm=new Set;async function EW(){const e=window.desktopSessions;if(!e)return[];const t=O2(),n=(await e.roots().catch(()=>[])).filter(r=>r.exists&&!t.has(r.key)).map(r=>r.key),a=[];for(const r of n){const o=[...await e.list(r).catch(()=>[])].sort((d,h)=>h.mtime-d.mtime),u=12;for(let d=0;d<o.length;d+=u){const h=await Promise.all(o.slice(d,d+u).map(async m=>{const p=m.rel.endsWith(".zstd")?NE:vW,x=await e.head(r,m.rel,p).catch(()=>"");if(!x)return null;const b=AE(r,m.rel,x,m.mtime,m.size);if(b)return b;const y=await e.head(r,m.rel,NE).catch(()=>"");return y.length>x.length?AE(r,m.rel,y,m.mtime,m.size):null}));for(const m of h)m&&a.push(m)}}jm.clear();for(const r of a)jm.add(r.sessionId);return a.sort((r,s)=>s.mtime-r.mtime)}function SW(e){const t=new Map;for(const n of e){const a=n.cwd??"";let r=t.get(a);r||(r={cwd:n.cwd,name:n.cwd?n.cwd.split("/").filter(Boolean).pop()??n.cwd:"",cards:[]},t.set(a,r)),r.cards.push(n)}return[...t.values()].sort((n,a)=>!n.cwd!=!a.cwd?n.cwd?-1:1:a.cards[0].mtime-n.cards[0].mtime)}async function CE(e,t){let n="";for(;;){const a=await t();if(a===null)break;const r=(n+a).split(`
|
|
156
|
-
`);n=r.pop()??"";for(const s of r)e.feedLine(s)}return n&&e.feedLine(n),e.toSubagentSession()}async function Uc(e,t,n,a){if(!e?.adopt||!e.sessionId||!window.desktopSessions)return e;const r=[];try{const{shellSessionReader:s}=await ft(async()=>{const{shellSessionReader:o}=await import("./canonical-
|
|
156
|
+
`);n=r.pop()??"";for(const s of r)e.feedLine(s)}return n&&e.feedLine(n),e.toSubagentSession()}async function Uc(e,t,n,a){if(!e?.adopt||!e.sessionId||!window.desktopSessions)return e;const r=[];try{const{shellSessionReader:s}=await ft(async()=>{const{shellSessionReader:o}=await import("./canonical-wWV9jbzN.js");return{shellSessionReader:o}},[]);if(e.source==="claude-code"){const o=`${n.replace(/\.jsonl$/,"")}/subagents/`,u=(await window.desktopSessions.list(t)).map(d=>d.rel).filter(d=>d.startsWith(o)&&d.endsWith(".jsonl"));if(u.length){const{ClaudeSessionCollector:d}=await ft(async()=>{const{ClaudeSessionCollector:h}=await import("./claude-code-session-DNu1noFg.js");return{ClaudeSessionCollector:h}},__vite__mapDeps([0,1]));for(const h of u){const m=await CE(new d,s(t,h)).catch(()=>null);m&&r.push(m)}}}else if(e.source==="codex"&&a){const o=a.filter(u=>u.runner==="codex"&&u.subagent&&u.parentSessionId===e.sessionId);if(o.length){const{CodexSessionCollector:u}=await ft(async()=>{const{CodexSessionCollector:d}=await import("./codex-session-tfRW8ANZ.js");return{CodexSessionCollector:d}},__vite__mapDeps([2,1]));for(const d of o){const h=await CE(new u,s(d.rootKey,d.rel)).catch(()=>null);h&&r.push(h)}}}}catch{}return r.length&&e.adopt(r),e}function G8(e,t){return e.find(n=>(n.rel.split("/").pop()??n.rel).includes(t))}let _E=!1,Jb=null;function TW(){Jb?.()}let ey=null;async function D2(e){return ey?(await ey(e),!0):!1}function NW(){const e=window.desktopSessions;if(!e||_E)return;_E=!0,e.watchStart();let t=!1,n=null;const a=async d=>{if(t){n=d;return}t=!0;try{window.dispatchEvent(new CustomEvent("td:sessions-changed"));const{useProjects:h,subscribedSessionIds:m}=await ft(async()=>{const{useProjects:_,subscribedSessionIds:S}=await Promise.resolve().then(()=>Sa);return{useProjects:_,subscribedSessionIds:S}},void 0),{activeId:p,projects:x}=h.getState(),b=x.find(_=>_.id===p),y=await e.head(d.rootKey,d.rel,262144).catch(()=>"");if(!y)return;const w=TE(y);if(!w)return;const E=!!b&&m(b).includes(w);let v=null;if(!E){if(x.some(V=>m(V).includes(w)))return;const{useStore:S}=await ft(async()=>{const{useStore:V}=await Promise.resolve().then(()=>vs);return{useStore:V}},void 0);if(!S.getState().nodes.some(V=>V.data.importSource?.sessionId===w)){const{parseAnchor:V}=await ft(async()=>{const{parseAnchor:L}=await import("./experiment-loop-Dv6KJPhf.js");return{parseAnchor:L}},[]),P=V(y);if(!P||!x.some(L=>L.id===P.project))return;if(v=P.project,v!==p){We("info",Te("atlas.mountPending"),9e3);return}}}const{streamRunnerConversation:A}=await ft(async()=>{const{streamRunnerConversation:_}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:_}},[]),{importOrAppendConversation:T,shellSessionReader:C}=await ft(async()=>{const{importOrAppendConversation:_,shellSessionReader:S}=await import("./canonical-wWV9jbzN.js");return{importOrAppendConversation:_,shellSessionReader:S}},[]),I=await Uc(await A(C(d.rootKey,d.rel)).catch(()=>null),d.rootKey,d.rel),O=await T(I,{focusOnRefresh:!1});O?.kind==="appended"?We("success",ye(Te("atlas.liveAppended"),{n:O.turns}),8e3):O?.kind==="mounted"&&We("success",ye(Te(O.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:O.turns}),9e3)}finally{if(t=!1,n){const h=n;n=null,a(h)}}};e.onSessionsChanged(d=>{a(d)});const r=async d=>{if(!d)return;const{useStore:h}=await ft(async()=>{const{useStore:x}=await Promise.resolve().then(()=>vs);return{useStore:x}},void 0),{useUiStore:m}=await ft(async()=>{const{useUiStore:x}=await Promise.resolve().then(()=>cu);return{useUiStore:x}},void 0),p=h.getState().nodes.find(x=>x.data.importSource?.itemIds?.includes(d));p&&m.getState().setArrivalFocusNodeId(p.id)},s=async(d,h)=>{const{useProjects:m,switchProject:p}=await ft(async()=>{const{useProjects:w,switchProject:E}=await Promise.resolve().then(()=>Sa);return{useProjects:w,switchProject:E}},void 0),x=m.getState().projects,b=x.filter(w=>w.name===d),y=x.find(w=>w.id===d)??(b.length===1?b[0]:void 0);if(!y){We("error",Te("handoff.deeplinkMiss"));return}if(await p(y.id),h){const{useStore:w}=await ft(async()=>{const{useStore:v}=await Promise.resolve().then(()=>vs);return{useStore:v}},void 0),{useUiStore:E}=await ft(async()=>{const{useUiStore:v}=await Promise.resolve().then(()=>cu);return{useUiStore:v}},void 0);w.getState().nodes.some(v=>v.id===h)&&E.getState().setArrivalFocusNodeId(h)}},o=async d=>{let h="",m="";try{const A=new URL(d),T=A.searchParams.get("canvas");if(T){await s(T,A.searchParams.get("node")??"");return}h=A.searchParams.get("session")??"",m=A.searchParams.get("turn")??""}catch{return}if(!/^[A-Za-z0-9_-]{8,}$/.test(h))return;/^[A-Za-z0-9_-]*$/.test(m)||(m="");const p=await e.roots().catch(()=>[]);let x=null;for(const A of p){const T=await e.list(A.key).catch(()=>[]),C=G8(T,h);if(C){x={rootKey:A.key,rel:C.rel};break}}if(!x){const A=[];for(const T of p)for(const C of await e.list(T.key).catch(()=>[]))A.push({rootKey:T.key,rel:C.rel,mtime:C.mtime});A.sort((T,C)=>C.mtime-T.mtime);for(const T of A.slice(0,40)){const C=await e.head(T.rootKey,T.rel,262144).catch(()=>"");if(C&&TE(C)===h){x=T;break}}}if(!x){We("error",Te("handoff.deeplinkMiss"));return}const{streamRunnerConversation:b}=await ft(async()=>{const{streamRunnerConversation:A}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:A}},[]),{importOrAppendConversation:y,shellSessionReader:w}=await ft(async()=>{const{importOrAppendConversation:A,shellSessionReader:T}=await import("./canonical-wWV9jbzN.js");return{importOrAppendConversation:A,shellSessionReader:T}},[]),E=await Uc(await b(w(x.rootKey,x.rel)).catch(()=>null),x.rootKey,x.rel),v=await y(E);v?v.kind==="appended"?We("success",ye(Te("atlas.liveAppended"),{n:v.turns}),8e3):v.kind==="mounted"?We("success",ye(Te(v.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:v.turns}),9e3):v.kind==="imported"&&We("success",ye(Te("toast.importedChats"),{n:1,m:v.nodeCount}),8e3):We("error",Te("handoff.notASession")),v&&m&&await r(m)};ey=o,e.onDeepLink?.(d=>{o(d)}),(async()=>{const{bootProjects:d}=await ft(async()=>{const{bootProjects:m}=await Promise.resolve().then(()=>Sa);return{bootProjects:m}},void 0);await d();const h=await e.pendingDeepLink?.().catch(()=>null);h&&o(h)})();const u="thoughtdag.atlas.sweepmark";Jb=async()=>{const{bootProjects:d}=await ft(async()=>{const{bootProjects:y}=await Promise.resolve().then(()=>Sa);return{bootProjects:y}},void 0);await d();const h=await e.roots().catch(()=>[]),m=[];for(const y of h){const w=await e.list(y.key).catch(()=>[]);for(const E of w)m.push({rootKey:y.key,rel:E.rel,mtime:E.mtime,size:E.size})}let p={};try{p=JSON.parse(localStorage.getItem(u)??"{}")}catch{}const x=Object.keys(p).length===0;m.sort((y,w)=>w.mtime-y.mtime);const b=m.filter((y,w)=>{const E=`${y.mtime}|${y.size}`;return p[`${y.rootKey}|${y.rel}`]===E?!1:x?w<30:!0});for(const y of b)await a({rootKey:y.rootKey,rel:y.rel});for(const y of m)p[`${y.rootKey}|${y.rel}`]=`${y.mtime}|${y.size}`;localStorage.setItem(u,JSON.stringify(p))},Jb()}const Y8=Object.freeze(Object.defineProperty({__proto__:null,openWhyLink:D2,pickSessionFile:G8,startLiveMirror:NW,sweepRecentSessions:TW},Symbol.toStringTag,{value:"Module"})),K8=(e,t)=>`td:card:${e}#${t}`,AW=420;let Ex=0;const CW=4;async function X8(e,t){try{const n=await Yo(K8(e,t));return typeof n=="string"&&n?n:void 0}catch{return}}async function Q8(e,t,n){const a=(await dr())?.default??void 0,r=`Condense the past exchange below into a card of at most 60 words (or 120 Chinese characters), in the exchange's own language: what was asked, what was concluded or decided, the names, numbers and file names that matter. No preamble, no markdown. Output only the card.
|
|
157
157
|
|
|
158
158
|
${n.slice(0,6e3)}`,o=(await er([{role:"user",content:r}],void 0,a)).trim().replace(/^["“「]|["”」]$/g,"").slice(0,AW);if(!(o.length<20)){try{await jr(K8(e,t),o)}catch{}return o}}function R2(e,t){const n=t.filter(a=>!a.card);n.length&&(async()=>{for(const a of n){for(;Ex>=CW;)await new Promise(r=>setTimeout(r,200));Ex++,Q8(a.session,a.turn,a.text).then(r=>{r&&se.setState(s=>({nodes:s.nodes.map(o=>o.id===e&&o.data.recallItems?.some(u=>u.id===a.id)?{...o,data:{...o.data,recallItems:o.data.recallItems.map(u=>u.id===a.id?{...u,card:r,cardTokens:Nn(r)}:u)}}:o)}))}).catch(()=>{}).finally(()=>{Ex--})}})()}const v0=["what","decisions","now","open"],Lm={what:"dossier.secWhat",decisions:"dossier.secDecisions",now:"dossier.secNow",open:"dossier.secOpen"},_W=100,MW=60,IW=6,OW=3200,DW=e=>e?e.slice(5,10).replace("-","-"):"",RW=(e,t)=>{const n=e.sources[t];return n?`${n.runner} ${DW(n.at)}`:""};function jW(e,t,n={}){const a=n.cap??OW,r=n.sources??!0,s=[`## ${ye(Te("dossier.title"),{name:t})}${e.updatedAt?` (${Te("dossier.updated")} ${e.updatedAt.slice(0,10)})`:""}`];for(const u of v0){const d=e.sections[u];if(d.length){s.push(`### ${Te(Lm[u])}`);for(const h of d){const m=r?h.src.map(p=>RW(e,p)).filter(Boolean).slice(0,2):[];s.push(`- ${h.text}${m.length?` (${m.join("; ")})`:""}`)}}}const o=s.join(`
|
|
159
159
|
`);return o.length>a?o.slice(0,a).trimEnd()+`
|
|
@@ -229,7 +229,7 @@ takeaway: the conclusion, stated first and plainly, as one clause. Hard limit: 1
|
|
|
229
229
|
|
|
230
230
|
Both in the same language as the question. Never use dash characters (—, –, -) inside topic or takeaway; use commas or colons instead. Output only that one line.`}],void 0,p,{fast:!0}).then(x=>{const b=x.trim().split(`
|
|
231
231
|
`)[0].trim(),y=b.match(/^(INSIGHT|RULEOUT|DECISION|PIVOT|OPEN)\s*[||::]\s*([^||]+?)\s*[||]\s*(.+)$/is),w=y?null:b.match(/^(INSIGHT|RULEOUT|DECISION|PIVOT|OPEN)[::||]\s*(.+)$/is),E=(y?.[1]??w?.[1])?.toLowerCase()??"insight",v=y?y[2].trim():void 0,A=y?y[3].trim():w?w[2].trim():b;return d(A,v,E)});if(!s){o.then(m).catch(()=>{});return}zm.add(e),o.then(async p=>{if(!p)return;const x=await v7(t,n,p,{context:s.context,thread:s.thread,parentAnswer:s.parentAnswer}).catch(()=>null);s.set(e,n,x),x?await d(hu(x,1),hu(x,0),x.move??"insight"):await m(p)}).catch(()=>{}).finally(()=>zm.delete(e))}function wV(e,t,n){const{ordered:a}=Lr(e,t,n),r={ruleout:"RULEOUT",decision:"DECISION",pivot:"PIVOT",open:"OPEN"},s=a.filter(u=>u.id!==e).map(u=>{const d=Ko(u.data);if(!d)return null;const h=u.data.summaryTypes?.[u.data.responseIndex];return`- ${h&&r[h]?`${r[h]}: `:""}${d}`}).filter(u=>!!u).slice(-8),o=a.find(u=>u.data.isRoot&&u.id!==e);return o?.data.question&&s.unshift(`Opening question of the map: ${o.data.question.slice(0,200)}`),s}const Ds=new Map,Nx=new Map,E0=new Map;async function Li(e,t,n,a){if(Et)return;const{question:r,images:s,onSuccess:o,versionMode:u="replace"}=a;let{messages:d}=a;a.autoChain||E0.clear(),Ds.get(n)?.abort();const h=(Nx.get(n)??0)+1;Nx.set(n,h);const m=()=>Nx.get(n)===h,p=new AbortController;Ds.set(n,p),e(Y=>({nodes:Y.nodes.map(q=>q.id===n?{...q,data:{...q.data,generationFailed:void 0,reasoning:void 0,restreaming:q.data.response?!0:void 0}}:q)}));let x;const b=t().nodes.find(Y=>Y.id===n)?.data.model;let y=b;const w=await dr(),E=w?.default??null;if(b&&w&&w.models.length>0){const Y=I7(b,w.models);Y!==b&&(y=Y??void 0,We("info",ye(Te(Y?"node.pinnedModelRemapped":"node.pinnedModelUnavailable"),Y?{m:b,r:Y}:{m:b}),7e3))}let v,A=!1;const T=y??oe.getState().selectedModel??E??void 0,C=await C8(n,T),I=C?void 0:await _7(T,n);let O,_=null,S=null;const z=(Y,q=!1)=>{if(!m())return;const B=Nn(r+Y),j=v??T;t().logEvent("generate",n,{chars:Y.length,...j?{model:j}:{},...q?{failed:!0}:{}});const $=w8(n,t().nodes,t().edges),X=c$(k8(n,t().nodes,t().edges));e(Q=>({nodes:Q.nodes.map(F=>{if(F.id!==n)return F;const G=new Set([Te("node.failedPlaceholder"),Te("node.emptyResponse")]),J=u==="append"||q?F.data.responses.map((Ie,Fe)=>({r:Ie,q:F.data.questions?.[Fe],by:F.data.generatedBy?.[Fe],rs:F.data.reasonings?.[Fe],at:F.data.generatedAts?.[Fe],ed:F.data.editedAts?.[Fe],gw:F.data.gatewaySearches?.[Fe],ef:F.data.generatedEfforts?.[Fe]})).filter(({r:Ie})=>Ie&&!(q&&G.has(Ie))):[],K=new Date().toISOString(),ee=[...J.map(({r:Ie})=>Ie),Y],ue=[...J.map(({q:Ie})=>Ie??F.data.question),F.data.question],pe=[...J.map(({by:Ie})=>Ie),j],be=[...J.map(({gw:Ie})=>Ie),A||void 0],ae=[...J.map(({ef:Ie})=>Ie),si(j)&&F.data.agentSession?.effort||void 0],xe=[...J.map(({rs:Ie})=>Ie),F.data.reasoning||void 0],Ce=[...J.map(({at:Ie})=>Ie),K],ze=[...J.map(({ed:Ie})=>Ie),void 0];return{...F,data:{...F.data,response:Y,responses:ee,questions:ue,generatedBy:pe,gatewaySearches:be,generatedEfforts:ae,reasonings:xe,generatedAts:Ce,editedAts:ze,reasoning:void 0,restreaming:void 0,pendingApprovals:void 0,agentTrace:void 0,responseIndex:ee.length-1,isLoading:!1,tokenCount:B,generationFailed:q||void 0,references:x,highlights:om(F.data.highlights,Y),lastContextHash:$,lastContextParts:X,lastGeneratedAt:K}}})}))},V=t().nodes.find(Y=>Y.id===n)?.data,P=!V?.stepKind&&!V?.digestOf?cW():null;if(P){let Y=d.length-1;for(let q=d.length-1;q>=0;q--)if(d[q].role==="assistant"){Y=q+1;break}d=[...d.slice(0,Y),P,...d.slice(Y)]}if(!V?.stepKind&&!V?.digestOf&&(V?.recall??oe.getState().recallEnabled)&&m()){let Y=V?.recallItems;if(!Y){const{useProjects:B}=await ft(async()=>{const{useProjects:X}=await Promise.resolve().then(()=>Sa);return{useProjects:X}},void 0),j=(X,Q)=>{m()&&e(F=>({nodes:F.nodes.map(G=>G.id===n?{...G,data:{...G.data,recallProgress:{done:X,total:Q}}}:G)}))},$=await m7(r,{excludeSession:B.getState().activeId,model:T,onProgress:j,reach:V?.recallReach,scale:V?.recallScale});if(Y=$.items,!m())return;e(X=>({nodes:X.nodes.map(Q=>Q.id===n?{...Q,data:{...Q.data,recallItems:$.items,recallMeta:$.meta,recallProgress:null}}:Q)})),R2(n,$.items)}const q=eV(Y);if(q){let B=d.length-1;for(let j=d.length-1;j>=0;j--)if(d[j].role==="assistant"){B=j+1;break}d=[...d.slice(0,B),q,...d.slice(B)]}}try{const Y=T,q=Y?a8(Y):void 0;if(q){const ee=Nn(d.map(ue=>ue.content).join(`
|
|
232
|
-
`));if(ee>=q)throw new Error(ye(Te("toast.contextOverWindow"),{est:ee.toLocaleString(),model:Y,limit:q.toLocaleString()}))}let B=null,j=null;const $=()=>{if(!B||!m()){B=null;return}const ee=B;B=null,e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n?{...pe,data:{...pe.data,...ee.response!==void 0?{response:ee.response,restreaming:void 0}:{},...ee.reasoning!==void 0?{reasoning:ee.reasoning}:{}}}:pe)}))},X=ee=>{B={...B??{},...ee},j==null&&($(),j=window.setTimeout(()=>{j=null,$()},100))},Q=()=>{j!=null&&(clearTimeout(j),j=null),$()},F=[...new Set((a.sources??[]).map(ee=>ee.nodeId).filter(ee=>!!ee))],G=async ee=>{const ue=await Promise.all(ee.images.map(async ae=>({type:ae.mimeType,sha:await Mm(ae.data)}))),pe=await Mm(T2({messages:ee.messages,images:ue,model:ee.model,tools:{web:!!ee.toolPrefs.web,scholar:!!ee.toolPrefs.scholar,mcp:!!ee.toolPrefs.mcp}})),be=F.slice(0,200);t().logEvent("commit",n,{kind:"request",sha:`sha256:${pe}`,n:ee.messages.length,images:ee.images.length,lane:ee.lane,...ee.model?{model:ee.model}:{},...be.length?{m:be.join(",")}:{},...F.length>be.length?{more:!0}:{}})};let J=!1;const K=await g8(d,(ee,ue)=>{if(X({response:ue}),C&&!J){J=!0;const pe=new Date().toISOString();e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&ae.data.agentTrace?.some(xe=>xe.status==="running")?{...ae,data:{...ae.data,agentTrace:ae.data.agentTrace.map(xe=>xe.status==="running"?{...xe,status:"ok",endedAt:pe}:xe)}}:ae)}))}},p.signal,s,{onDispatch:ee=>{G(ee).catch(()=>{})},onToolCall:(ee,ue)=>{if(!m())return;if(C){const be=new Date().toISOString();e(ae=>({nodes:ae.nodes.map(xe=>{if(xe.id!==n)return xe;const Ce=(xe.data.agentTrace??[]).map(ze=>ze.status==="running"?{...ze,status:"ok",endedAt:be}:ze);return Ce.push({id:`${be}-${Ce.length}`,name:ee,query:ue,status:"running",startedAt:be}),{...xe,data:{...xe.data,agentTrace:Ce}}})}));return}const pe=ee==="arxiv_search"?"📚":ee==="semantic_scholar"?"🎓":ee.startsWith("mcp:")?"🔧":"🔍";e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&!ae.data.response?{...ae,data:{...ae.data,response:`${pe} ${ue}…`}}:ae)}))},onGatewaySearch:()=>{m()&&(A=!0,e(ee=>({nodes:ee.nodes.map(ue=>ue.id===n&&!ue.data.response?{...ue,data:{...ue.data,response:`🌐 ${Te("node.gatewaySearching")}`}}:ue)})))},onSources:ee=>{x=ee},onHarnessSession:ee=>{O=ee},onAgentTool:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=[...be.data.agentTrace??[]];if(ee.phase==="start")ae.push({id:ee.id||`${ae.length}`,name:ee.name,query:ee.query,status:"running",startedAt:ue});else{const xe=ae.findIndex(Ce=>Ce.id===ee.id&&Ce.status==="running");xe>=0&&(ae[xe]={...ae[xe],status:ee.isError?"error":"ok",endedAt:ue})}return{...be,data:{...be.data,agentTrace:ae}}})}))},onAgentSession:ee=>{if(!m())return;const ue=!!I?.continue;e(pe=>({nodes:pe.nodes.map(be=>be.id===n?{...be,data:{...be.data,agentSession:{...be.data.agentSession,...ee,continued:ue}}}:be)})),ue&&ee.sessionId&&jV(ee.runtime,n,ee.sessionId,ee.cwd)},onAgentChanges:ee=>{m()&&e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n&&pe.data.agentSession?{...pe,data:{...pe.data,agentSession:{...pe.data.agentSession,changes:ee}}}:pe)}))},onHarnessTurn:ee=>{_=ee,C&&!S&&(S=I8(e,n,C,ee).catch(()=>!1))},onApproval:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=be.data.pendingApprovals??[];return ae.some(xe=>xe.id===ee.id)?be:{...be,data:{...be.data,pendingApprovals:[...ae,{...ee,askedAt:ue}]}}})})),We("info",Te("approval.toast"),8e3)},onApprovalDecided:({id:ee,outcome:ue,value:pe,auto:be,name:ae,query:xe,rule:Ce})=>{if(!m())return;const ze=new Date().toISOString();e(Ie=>({nodes:Ie.nodes.map(Fe=>{if(Fe.id!==n)return Fe;const Ee=Fe.data.pendingApprovals??[],Me=Ee.find(Ye=>Ye.id===ee),De=Ee.filter(Ye=>Ye.id!==ee),bt=De.length?De:void 0;if(!Me&&be)return{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{id:ee,kind:"confirm",toolName:Fe.data.agentSession?.runtime??"agent",callId:null,reason:null,name:ae??"",query:xe??"",arguments:null,askedAt:ze,decidedAt:ze,outcome:ue,auto:!0,...Ce?{rule:Ce}:{}}]}};if(!Me)return{...Fe,data:{...Fe.data,pendingApprovals:bt}};const mt={...Me};return delete mt.answered,{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{...mt,outcome:ue,decidedAt:ze,...pe?{value:pe}:{}}]}}})}))},onRerouted:(ee,ue)=>{v=ue},onImageFallback:ee=>{v=ee},onReasoning:(ee,ue)=>{X({reasoning:ue})}},(()=>{const ee=t().nodes.find(ue=>ue.id===n)?.data;return{web:ee?.webSearch??oe.getState().webSearchEnabled,scholar:ee?.scholarSearch??oe.getState().scholarSearchEnabled,mcp:oe.getState().mcpEnabled}})(),y,C??(I?{...I,nodeId:n}:void 0));if(Q(),!m())return;if(Ds.delete(n),!K.trim()){z(Te("node.emptyResponse"),!0);return}if(I){const ee=t().nodes.find(ue=>ue.id===n)?.data.agentSession;ee&&await FV(n,ee,r).catch(()=>!1)}if(z(K),C){const ee=S?await S:!1;await O8(e,t,n,{question:r,response:K},C,O,_,ee)}o?.(K),t().pushHistory(),vV(n,r,K,t().setSummary,wV(n,t().nodes,t().edges),{model:C||I?void 0:T,set:t().setLadder,...S7(n,t().nodes,t().edges)}),!V?.stepKind&&!V?.digestOf&&ft(async()=>{const{useProjects:ee}=await Promise.resolve().then(()=>Sa);return{useProjects:ee}},void 0).then(({useProjects:ee})=>{const{projects:ue,activeId:pe}=ee.getState(),be=ue.find(ae=>ae.id===pe);pW(r,K,be?{id:be.id,name:be.name}:void 0)}),kV(e,t,n),Ul(t,n)}catch(Y){if(!m())return;Ds.delete(n);const q=t().nodes.find(j=>j.id===n)?.data.response||"";if(Y instanceof DOMException&&Y.name==="AbortError")z(q||Te("node.stoppedPlaceholder"));else{const j=Y instanceof Error?Y.message:Te("toast.unknownError");/no model configured/i.test(j)?(We("info",Te("toast.noModelYet")),oe.getState().setApiKeyModalOpen(!0)):/429|too many requests|rate.?limit|quota/i.test(j)?We("info",Te("toast.rateLimited")):We("error",ye(Te("toast.generationFailed"),{message:j})),z(q||Te("node.failedPlaceholder"),!0)}t().pushHistory()}}function Ul(e,t){if(oe.getState().autoRefreshPaused)return;const{nodes:n,edges:a}=e(),r=new Map(n.map(o=>[o.id,o])),s=o=>{const u=r.get(o);return!u||u.data.isLoading?!1:u.data.stepKind==="human"||u.data.stepKind==="note"||u.data.stepKind==="link"?!!u.data.question.trim():u.data.stepKind==="file"?(u.data.attachments?.length??0)>0:!!u.data.response&&!u.data.generationFailed};for(const o of a){if(o.source!==t||o.data?.isCrossLink)continue;const u=r.get(o.target);!u||u.data.stepKind!=="prompt"||u.data.response||u.data.isLoading||u.data.generationFailed||!a.filter(h=>h.target===u.id&&!h.data?.isCrossLink).map(h=>h.source).every(s)||e().rerunNode(u.id,{auto:!0})}}function kV(e,t,n){if(oe.getState().autoRefreshPaused)return;const a=new Set([n]),r=[n];for(;r.length>0;){const d=r.shift();for(const h of t().edges)h.target===d&&!h.data?.isCrossLink&&!a.has(h.source)&&(a.add(h.source),r.push(h.source))}t().edges.some(d=>d.data?.followsTip&&d.source!==n&&a.has(d.source))&&e(d=>({edges:d.edges.map(h=>h.data?.followsTip&&h.source!==n&&a.has(h.source)?{...h,id:`watch-${n}-${h.target}`,source:n}:h)}));const{nodes:o,edges:u}=t();for(const d of o){if(!(d.data.autoRerun??d.data.evaluatorTrigger==="auto")||d.id===n||d.data.isLoading||Ds.has(d.id))continue;const m=E0.get(d.id)??0;if(m>=(d.data.autoRerunRounds??1))continue;const{ordered:p}=Lr(d.id,o,u);p.some(x=>x.id===n)&&(E0.set(d.id,m+1),t().rerunNode(d.id,{auto:!0}))}}const BE=e=>{for(const t of e){const n=Ds.get(t);n&&(n.abort(),Ds.delete(t))}},EV=(e,t)=>({nodes:[],edges:[],selectedNodeId:null,selectedNodeIds:[],setNodes:n=>e({nodes:n}),setEdges:n=>e({edges:n}),setSelectedNodeId:n=>e({selectedNodeId:n,selectedNodeIds:n?[n]:[]}),setSelectedNodeIds:n=>e({selectedNodeIds:n,selectedNodeId:n.length===1?n[0]:null}),deleteNode:n=>{if(Kr())return;t().logEvent("delete",n,{n:1}),t().pushHistory();const{edges:a}=t(),r=Vo(n,a),s=new Set([n,...r]);BE(s),e(o=>({nodes:o.nodes.filter(u=>!s.has(u.id)),edges:o.edges.filter(u=>!s.has(u.source)&&!s.has(u.target))})),t().pushHistory(),ft(()=>import("./canonical-BuO7_FJb.js"),[]).then(o=>o.unsubscribeOrphanedSessions())},deleteEdges:n=>{if(Kr())return;t().logEvent("disconnect",n[0],{n:n.length});const a=new Set(n);t().edges.some(r=>a.has(r.id))&&(t().pushHistory(),e(r=>({edges:r.edges.filter(s=>!a.has(s.id))})),t().pushHistory())},editResponse:(n,a)=>{if(Kr())return;t().logEvent("edit-response",n,{chars:a.length}),t().pushHistory();const r=Nn(t().nodes.find(s=>s.id===n)?.data.question+a||a);e(s=>({nodes:s.nodes.map(o=>o.id===n?{...o,data:{...o.data,response:a,responses:o.data.responses.map((u,d)=>d===o.data.responseIndex?a:u),summaries:o.data.summaries?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTypes:o.data.summaryTypes?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTopics:o.data.summaryTopics?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryLadders:o.data.summaryLadders?.map((u,d)=>d===o.data.responseIndex?void 0:u),editedAts:o.data.responses.map((u,d)=>d===o.data.responseIndex?new Date().toISOString():o.data.editedAts?.[d]),highlights:om(o.data.highlights,a),isEditingResponse:!1,tokenCount:r}}:o)})),t().pushHistory()},toggleCollapse:n=>{const a=t().nodes.find(h=>h.id===n);if(!a)return;const r=zi(a),o=S2({...a,data:{...a.data,isCollapsed:!a.data.isCollapsed}})-r,u=Vo(n,t().edges),d=new Set(u);e(h=>({nodes:h.nodes.map(m=>m.id===n?{...m,data:{...m.data,isCollapsed:!m.data.isCollapsed}}:d.has(m.id)?{...m,position:{...m.position,y:m.position.y+o}}:m)}))},setEditing:(n,a)=>{a&&Kr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditing:a}}:s)}))},setEditingResponse:(n,a)=>{a&&Kr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditingResponse:a}}:s)}))},duplicateNode:n=>{const a=t().nodes.find(m=>m.id===n);if(!a)return;t().pushHistory();const r=Tn(),s={id:r,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{...a.data,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,highlights:a.data.highlights.map(m=>({...m,id:Tn()}))}},o=t().edges.find(m=>m.target===n),u=o?{...o,id:`edge-${o.source}-${r}`,target:r}:null,d=u?[...t().edges,u]:t().edges,h=xr([...t().nodes,s],d);e({nodes:h,edges:d,selectedNodeId:r}),t().pushHistory()},addCrossLink:(n,a)=>{const{edges:r,nodes:s}=t();if(r.some(x=>x.source===n&&x.target===a))return;const u=s.find(x=>x.id===n);if(u&&["note","file","link"].includes(u.data.stepKind??"")){t().pushHistory();const x={id:`edge-${n}-${a}`,source:n,sourceHandle:"continue",target:a,targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};e(y=>({edges:[...y.edges,x]})),t().logEvent("connect",x.id),t().setEdgeStructural(x.id,!0);const b=t().edges.find(y=>y.id===x.id);if(b&&!b.data?.isCrossLink){const w=br(n,t().nodes,t().edges).messages.reduce((E,v)=>E+Nn(v.content),0);We("success",ye(Te("edge.materialWiredFull"),{n:w.toLocaleString()}),8e3,{label:Te("edge.materialMakeQuote"),run:()=>t().setEdgeStructural(x.id,!1)})}return}t().pushHistory();const d=s.find(x=>x.id===n),h=s.find(x=>x.id===a),m=!!d&&!!h&&h.position.y>d.position.y+60&&Math.abs(h.position.x-d.position.x)<320,p={id:`crosslink-${n}-${a}`,source:n,sourceHandle:m?"continue":"branch",target:a,targetHandle:m?"top":"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};if(e(x=>({edges:[...x.edges,p]})),t().logEvent("connect",p.id),t().pushHistory(),d&&!["note","file","link"].includes(d.data.stepKind??"")){const{ordered:x}=Lr(n,s,r.filter(y=>!y.data?.isCrossLink)),b=x.filter(y=>y.id!==n&&!["note","file","link"].includes(y.data.stepKind??""));if(b.length>0){const y=Nn(y0({source:d,depth:"quote",chain:b})),E=br(n,s,r).messages.reduce((v,A)=>v+Nn(A.content),0)+Nn(d.data.question+d.data.response);We("info",ye(Te("edge.linkedQuote"),{n:y}),8e3,{label:ye(Te("edge.makeFull"),{m:E}),run:()=>t().setEdgeStructural(p.id,!0)})}}},staleIds:[],staleFps:{},staleVerdicts:{},setStaleVerdicts:n=>e(a=>({staleVerdicts:{...a.staleVerdicts,...n}})),recomputeStaleness:()=>{const{nodes:n,edges:a}=t(),r=[],s={};for(const d of n){if(!d.data.lastContextHash||!d.data.response||["note","file","link","frame"].includes(d.data.stepKind??""))continue;const h=w8(d.id,n,a);h!==d.data.lastContextHash&&(r.push(d.id),s[d.id]=h)}const o=t().staleFps,u=t().staleIds;u.length===r.length&&u.every((d,h)=>d===r[h]&&o[d]===s[d])||(e({staleIds:r,staleFps:s}),r.length&&ft(()=>Promise.resolve().then(()=>TV),void 0).then(d=>d.judgeStaleness()).catch(()=>{}))},setEdgeStructural:(n,a)=>{const{nodes:r,edges:s}=t(),o=s.find(u=>u.id===n);if(o){if(a){const u=s.filter(h=>!h.data?.isCrossLink),{ordered:d}=Lr(o.source,r,u);if(d.some(h=>h.id===o.target)){We("error",Te("edge.cycleBlocked"));return}}t().pushHistory(),t().logEvent(a?"connect":"disconnect",n,{convert:!0}),e(u=>({edges:u.edges.map(d=>{if(d.id!==n)return d;if(a){const h={...d.data??{}};return delete h.isCrossLink,delete h.contextDepth,delete h.isWatch,{...d,sourceHandle:"continue",targetHandle:"top",animated:!1,style:{stroke:it.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:h}}return{...d,animated:!0,style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{...d.data??{},isCrossLink:!0,contextDepth:void 0}}})})),e(u=>({nodes:xr(u.nodes,u.edges)})),t().pushHistory()}},setCrossLinkDepth:(n,a)=>{t().pushHistory(),e(r=>({edges:r.edges.map(s=>s.id!==n||!s.data?.isCrossLink?s:{...s,style:{...s.style,strokeDasharray:a==="full"?"12 3":"8 4",strokeWidth:a==="full"?3:2},data:{...s.data,contextDepth:a==="full"?"full":void 0}})})),t().pushHistory()},navigateVersion:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const{responses:o,responseIndex:u}=s.data;let d=a==="prev"?u-1:u+1;return d<0&&(d=o.length-1),d>=o.length&&(d=0),{...s,data:{...s.data,responseIndex:d,response:o[d],question:s.data.questions?.[d]??s.data.question,generationFailed:void 0,highlights:om(s.data.highlights,o[d])}}})}))},deleteVersion:(n,a)=>{t().pushHistory(),e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const o=s.data.responses.filter((d,h)=>h!==a);if(o.length===0)return s;const u=Math.min(s.data.responseIndex,o.length-1);return{...s,data:{...s.data,responses:o,responseIndex:u,response:o[u],questions:s.data.questions?.filter((d,h)=>h!==a),question:s.data.questions?.filter((d,h)=>h!==a)[u]??s.data.question,summaries:s.data.summaries?.filter((d,h)=>h!==a),generatedBy:s.data.generatedBy?.filter((d,h)=>h!==a),summaryTypes:s.data.summaryTypes?.filter((d,h)=>h!==a),reasonings:s.data.reasonings?.filter((d,h)=>h!==a),generatedAts:s.data.generatedAts?.filter((d,h)=>h!==a),editedAts:s.data.editedAts?.filter((d,h)=>h!==a),highlights:om(s.data.highlights,o[u])}}})})),t().pushHistory()},relayout:()=>{Kr()||(t().pushHistory(),e(n=>{const a=m$(n.nodes,n.edges);return{nodes:xr(n.nodes,a),edges:a}}),t().pushHistory())},setArchived:(n,a)=>{const r=new Set(n);t().pushHistory(),t().logEvent(a?"archive":"unarchive",n[0],{n:n.length}),e(s=>({nodes:s.nodes.map(o=>r.has(o.id)?{...o,data:{...o.data,archived:a||void 0,archivedAt:a?new Date().toISOString():void 0}}:o)})),t().pushHistory()},setNodeModel:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,model:a}}:s)}))},alignSelection:n=>{if(n.length<2)return;const a=new Set(n),{nodes:r,edges:s}=t(),o=new Map,u=s.filter(b=>!b.data?.isWatch),d=(b,y)=>{if(o.has(b))return o.get(b);if(y.has(b))return 0;y.add(b);const w=u.filter(v=>v.target===b&&a.has(v.source)),E=w.length===0?0:1+Math.max(...w.map(v=>d(v.source,y)));return o.set(b,E),E},h=n.map(b=>r.find(y=>y.id===b)).filter(b=>!!b).sort((b,y)=>d(b.id,new Set)-d(y.id,new Set)||b.position.y-y.position.y);t().pushHistory();const m=h[0].position;let p=m.y;const x=new Map;for(const b of h)x.set(b.id,{x:m.x,y:p}),p+=zi(b)+40;e(b=>({nodes:b.nodes.map(y=>{const w=x.get(y.id);return w?{...y,position:w}:y})})),t().pushHistory()},batchDelete:n=>{if(Kr())return;t().logEvent("delete",n[0],{n:n.length}),t().pushHistory();const a=new Set(n);BE(a),e(r=>({nodes:r.nodes.filter(s=>!a.has(s.id)),edges:r.edges.filter(s=>!a.has(s.source)&&!a.has(s.target)),selectedNodeId:null,selectedNodeIds:[]})),t().pushHistory(),ft(()=>import("./canonical-BuO7_FJb.js"),[]).then(r=>r.unsubscribeOrphanedSessions())},duplicateSelection:n=>{const{nodes:a,edges:r}=t(),s=new Set(n),o=a.filter(_=>s.has(_.id));if(o.length===0)return;t().pushHistory();const u=_=>({x:_.position.x,y:_.position.y,w:_.measured?.width??_.width??520,h:_.measured?.height??_.height??zi(_)}),d=o.map(u),h={x:Math.min(...d.map(_=>_.x)),y:Math.min(...d.map(_=>_.y)),right:Math.max(...d.map(_=>_.x+_.w)),bottom:Math.max(...d.map(_=>_.y+_.h))},m=80,p=h.right-h.x+m,x=h.bottom-h.y+m,b=[];for(let _=1;_<=6;_++)b.push({dx:_*p,dy:0},{dx:0,dy:_*x},{dx:_*p,dy:_*x});const y=a.filter(_=>_.data.stepKind!=="frame").map(u),w=(_,S)=>_.x<S.x+S.w&&_.x+_.w>S.x&&_.y<S.y+S.h&&_.y+_.h>S.y,E=b.find(_=>!d.some(S=>y.some(z=>w({...S,x:S.x+_.dx,y:S.y+_.dy},z))))??{dx:p,dy:x},v=new Map,A=new Map;for(const _ of o){v.set(_.id,Tn());for(const S of _.data.attachments??[])A.set(S.id,Tn())}const T=_=>(_??[]).map(S=>A.get(S)??S),C=o.map(_=>({..._,id:v.get(_.id),position:{x:_.position.x+E.dx,y:_.position.y+E.dy},selected:!0,data:{..._.data,attachments:(_.data.attachments??[]).map(S=>({...S,id:A.get(S.id)})),excludedAttachmentIds:T(_.data.excludedAttachmentIds),includedAttachmentIds:T(_.data.includedAttachmentIds),digestOf:_.data.digestOf?A.get(_.data.digestOf)??_.data.digestOf:void 0,highlights:(_.data.highlights??[]).map(S=>({...S,id:Tn()})),isEditing:!1,isEditingResponse:!1,isLoading:!1}})),I=r.filter(_=>s.has(_.source)&&s.has(_.target)).map(_=>({..._,id:`edge-${v.get(_.source)}-${v.get(_.target)}`,source:v.get(_.source),target:v.get(_.target),data:_.data?{..._.data}:_.data})),O=C.map(_=>_.id);e(_=>({nodes:[..._.nodes.map(S=>S.selected?{...S,selected:!1}:S),...C],edges:[..._.edges,...I],selectedNodeId:O.length===1?O[0]:null,selectedNodeIds:O})),t().pushHistory()}}),H2=(e,t)=>{const n=e.staleVerdicts[t];return!!n&&n.fp===e.staleFps[t]&&n.p<q$},Xr=e=>e.staleIds.filter(t=>!H2(e,t)),N7=(e,t)=>{const n=e.staleVerdicts[t];return n&&n.fp===e.staleFps[t]?n:void 0},SV=8;let Ax=!1;const Cx=new Set;async function A7(){if(Ax||!Dr())return;const e=se.getState(),t=e.staleIds.filter(a=>e.staleVerdicts[a]?.fp!==e.staleFps[a]&&!Cx.has(`${a}:${e.staleFps[a]}`));if(!t.length)return;Ax=!0;try{const{nodes:a,edges:r}=e,s=[];for(const o of t.slice(0,SV)){Cx.add(`${o}:${e.staleFps[o]}`);const u=a.find(p=>p.id===o),d=u?.data.lastContextParts;if(!u||!d)continue;const h=k8(o,a,r),m=[];for(const[p,x]of Object.entries(h)){const b=d[p];(!b||b.h!==x.h)&&m.push({node:p,before:b?.head??"",after:x.text})}for(const p of Object.keys(d))h[p]||m.push({node:p,before:d[p].head,after:""});m.length&&s.push({id:o,question:u.data.question,answer:u.data.response,changes:m})}if(s.length){const o=await $$(s),u={};for(const d of s)u[d.id]={fp:e.staleFps[d.id],p:o[d.id],changed:d.changes.map(h=>h.node)};se.getState().setStaleVerdicts(u)}}catch{}finally{Ax=!1}const n=se.getState();n.staleIds.some(a=>n.staleVerdicts[a]?.fp!==n.staleFps[a]&&!Cx.has(`${a}:${n.staleFps[a]}`))&&A7()}const TV=Object.freeze(Object.defineProperty({__proto__:null,currentStaleVerdict:N7,judgeStaleness:A7,shownStaleIds:Xr,staleHiddenByJudge:H2},Symbol.toStringTag,{value:"Module"})),NV=(e,t)=>({addQuestion:async(n,a={})=>{if(Kr())return;const{parentId:r,branchContext:s,branchYRatio:o,inheritRole:u,rolePrompt:d,initialAttachments:h,excludeAllInheritedAttachments:m,mentions:p}=a,x=Tn();t().logEvent("ask",x,{chars:n.length,...r?{}:{root:!0},...s?{branch:!0}:{}});const b=!r,y=r?t().nodes.find(Y=>Y.id===r)?.data.model:void 0,w={id:x,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:n,createdAt:new Date().toISOString(),askedAt:new Date().toISOString(),model:y,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!0,tokenCount:0,branchContext:s,highlights:[],highlightMode:"tag",attachments:h||[],excludedAttachmentIds:m&&r?t().getInheritedAttachments(r).map(({attachment:Y})=>Y.id).concat((t().nodes.find(Y=>Y.id===r)?.data.attachments||[]).map(Y=>Y.id)):[],includedAttachmentIds:[],roleMode:u===!1?"reset":"inherit",rolePrompt:d||void 0,isRoot:b,isBranch:!!s,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled,...zd()}},E=!!s,v=r?{id:`edge-${r}-${x}`,source:r,target:x,sourceHandle:E?"branch":"continue",targetHandle:E?"left":"top",type:"smoothstep",...E?{style:{stroke:it.warm,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.warm,width:18,height:18},data:{isBranchFromSelection:!0,branchYRatio:o??.5}}:{style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}:null;let A=v?[...t().edges,v]:t().edges;const T=(p??[]).filter(Y=>Y!==x&&Y!==r&&t().nodes.some(q=>q.id===Y));if(T.length>0){const Y=A.filter($=>!$.data?.isCrossLink),q=r?new Set(Lr(r,t().nodes,Y).ordered.map($=>$.id)):new Set,B=new Set(A.filter($=>$.data?.isCrossLink&&$.target===x).map($=>$.source));let j=0;for(const $ of T)q.has($)||B.has($)||(A=[...A,{id:`crosslink-${$}-${x}`,source:$,target:x,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}}],j++);j>0&&We("info",ye(Te("mention.wired"),{n:j}),6e3)}const C=r?t().nodes.map(Y=>Y.id===r?{...Y,data:{...Y.data,isCollapsed:!0}}:Y):t().nodes,I=xr([...C,w],A);e({nodes:I,edges:A,selectedNodeId:x});const O=t().nodes.find(Y=>Y.id===x),_=r?br(r,t().nodes,t().edges,s,O?.data.excludedAttachmentIds,O?.data.includedAttachmentIds,Xr(t())):{messages:[],images:[],sources:[]},S=_.messages,z=_.images,V=r?t().nodes.find(Y=>Y.id===r):null;vE(S,yE(O?.data,V?.data,!!r));const P=O?.data.attachments||[];for(const Y of P)S.some(B=>B.content.includes(`[PDF: ${Y.name}]`)||B.content.includes(`[File: ${Y.name}]`))||(Y.type.startsWith("image/")?z.push({data:Y.content,mimeType:Y.type}):Y.type==="application/pdf"?Y.extractedText&&S.push({role:"user",content:`[PDF: ${Y.name}]
|
|
232
|
+
`));if(ee>=q)throw new Error(ye(Te("toast.contextOverWindow"),{est:ee.toLocaleString(),model:Y,limit:q.toLocaleString()}))}let B=null,j=null;const $=()=>{if(!B||!m()){B=null;return}const ee=B;B=null,e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n?{...pe,data:{...pe.data,...ee.response!==void 0?{response:ee.response,restreaming:void 0}:{},...ee.reasoning!==void 0?{reasoning:ee.reasoning}:{}}}:pe)}))},X=ee=>{B={...B??{},...ee},j==null&&($(),j=window.setTimeout(()=>{j=null,$()},100))},Q=()=>{j!=null&&(clearTimeout(j),j=null),$()},F=[...new Set((a.sources??[]).map(ee=>ee.nodeId).filter(ee=>!!ee))],G=async ee=>{const ue=await Promise.all(ee.images.map(async ae=>({type:ae.mimeType,sha:await Mm(ae.data)}))),pe=await Mm(T2({messages:ee.messages,images:ue,model:ee.model,tools:{web:!!ee.toolPrefs.web,scholar:!!ee.toolPrefs.scholar,mcp:!!ee.toolPrefs.mcp}})),be=F.slice(0,200);t().logEvent("commit",n,{kind:"request",sha:`sha256:${pe}`,n:ee.messages.length,images:ee.images.length,lane:ee.lane,...ee.model?{model:ee.model}:{},...be.length?{m:be.join(",")}:{},...F.length>be.length?{more:!0}:{}})};let J=!1;const K=await g8(d,(ee,ue)=>{if(X({response:ue}),C&&!J){J=!0;const pe=new Date().toISOString();e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&ae.data.agentTrace?.some(xe=>xe.status==="running")?{...ae,data:{...ae.data,agentTrace:ae.data.agentTrace.map(xe=>xe.status==="running"?{...xe,status:"ok",endedAt:pe}:xe)}}:ae)}))}},p.signal,s,{onDispatch:ee=>{G(ee).catch(()=>{})},onToolCall:(ee,ue)=>{if(!m())return;if(C){const be=new Date().toISOString();e(ae=>({nodes:ae.nodes.map(xe=>{if(xe.id!==n)return xe;const Ce=(xe.data.agentTrace??[]).map(ze=>ze.status==="running"?{...ze,status:"ok",endedAt:be}:ze);return Ce.push({id:`${be}-${Ce.length}`,name:ee,query:ue,status:"running",startedAt:be}),{...xe,data:{...xe.data,agentTrace:Ce}}})}));return}const pe=ee==="arxiv_search"?"📚":ee==="semantic_scholar"?"🎓":ee.startsWith("mcp:")?"🔧":"🔍";e(be=>({nodes:be.nodes.map(ae=>ae.id===n&&!ae.data.response?{...ae,data:{...ae.data,response:`${pe} ${ue}…`}}:ae)}))},onGatewaySearch:()=>{m()&&(A=!0,e(ee=>({nodes:ee.nodes.map(ue=>ue.id===n&&!ue.data.response?{...ue,data:{...ue.data,response:`🌐 ${Te("node.gatewaySearching")}`}}:ue)})))},onSources:ee=>{x=ee},onHarnessSession:ee=>{O=ee},onAgentTool:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=[...be.data.agentTrace??[]];if(ee.phase==="start")ae.push({id:ee.id||`${ae.length}`,name:ee.name,query:ee.query,status:"running",startedAt:ue});else{const xe=ae.findIndex(Ce=>Ce.id===ee.id&&Ce.status==="running");xe>=0&&(ae[xe]={...ae[xe],status:ee.isError?"error":"ok",endedAt:ue})}return{...be,data:{...be.data,agentTrace:ae}}})}))},onAgentSession:ee=>{if(!m())return;const ue=!!I?.continue;e(pe=>({nodes:pe.nodes.map(be=>be.id===n?{...be,data:{...be.data,agentSession:{...be.data.agentSession,...ee,continued:ue}}}:be)})),ue&&ee.sessionId&&jV(ee.runtime,n,ee.sessionId,ee.cwd)},onAgentChanges:ee=>{m()&&e(ue=>({nodes:ue.nodes.map(pe=>pe.id===n&&pe.data.agentSession?{...pe,data:{...pe.data,agentSession:{...pe.data.agentSession,changes:ee}}}:pe)}))},onHarnessTurn:ee=>{_=ee,C&&!S&&(S=I8(e,n,C,ee).catch(()=>!1))},onApproval:ee=>{if(!m())return;const ue=new Date().toISOString();e(pe=>({nodes:pe.nodes.map(be=>{if(be.id!==n)return be;const ae=be.data.pendingApprovals??[];return ae.some(xe=>xe.id===ee.id)?be:{...be,data:{...be.data,pendingApprovals:[...ae,{...ee,askedAt:ue}]}}})})),We("info",Te("approval.toast"),8e3)},onApprovalDecided:({id:ee,outcome:ue,value:pe,auto:be,name:ae,query:xe,rule:Ce})=>{if(!m())return;const ze=new Date().toISOString();e(Ie=>({nodes:Ie.nodes.map(Fe=>{if(Fe.id!==n)return Fe;const Ee=Fe.data.pendingApprovals??[],Me=Ee.find(Ye=>Ye.id===ee),De=Ee.filter(Ye=>Ye.id!==ee),bt=De.length?De:void 0;if(!Me&&be)return{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{id:ee,kind:"confirm",toolName:Fe.data.agentSession?.runtime??"agent",callId:null,reason:null,name:ae??"",query:xe??"",arguments:null,askedAt:ze,decidedAt:ze,outcome:ue,auto:!0,...Ce?{rule:Ce}:{}}]}};if(!Me)return{...Fe,data:{...Fe.data,pendingApprovals:bt}};const mt={...Me};return delete mt.answered,{...Fe,data:{...Fe.data,pendingApprovals:bt,approvals:[...Fe.data.approvals??[],{...mt,outcome:ue,decidedAt:ze,...pe?{value:pe}:{}}]}}})}))},onRerouted:(ee,ue)=>{v=ue},onImageFallback:ee=>{v=ee},onReasoning:(ee,ue)=>{X({reasoning:ue})}},(()=>{const ee=t().nodes.find(ue=>ue.id===n)?.data;return{web:ee?.webSearch??oe.getState().webSearchEnabled,scholar:ee?.scholarSearch??oe.getState().scholarSearchEnabled,mcp:oe.getState().mcpEnabled}})(),y,C??(I?{...I,nodeId:n}:void 0));if(Q(),!m())return;if(Ds.delete(n),!K.trim()){z(Te("node.emptyResponse"),!0);return}if(I){const ee=t().nodes.find(ue=>ue.id===n)?.data.agentSession;ee&&await FV(n,ee,r).catch(()=>!1)}if(z(K),C){const ee=S?await S:!1;await O8(e,t,n,{question:r,response:K},C,O,_,ee)}o?.(K),t().pushHistory(),vV(n,r,K,t().setSummary,wV(n,t().nodes,t().edges),{model:C||I?void 0:T,set:t().setLadder,...S7(n,t().nodes,t().edges)}),!V?.stepKind&&!V?.digestOf&&ft(async()=>{const{useProjects:ee}=await Promise.resolve().then(()=>Sa);return{useProjects:ee}},void 0).then(({useProjects:ee})=>{const{projects:ue,activeId:pe}=ee.getState(),be=ue.find(ae=>ae.id===pe);pW(r,K,be?{id:be.id,name:be.name}:void 0)}),kV(e,t,n),Ul(t,n)}catch(Y){if(!m())return;Ds.delete(n);const q=t().nodes.find(j=>j.id===n)?.data.response||"";if(Y instanceof DOMException&&Y.name==="AbortError")z(q||Te("node.stoppedPlaceholder"));else{const j=Y instanceof Error?Y.message:Te("toast.unknownError");/no model configured/i.test(j)?(We("info",Te("toast.noModelYet")),oe.getState().setApiKeyModalOpen(!0)):/429|too many requests|rate.?limit|quota/i.test(j)?We("info",Te("toast.rateLimited")):We("error",ye(Te("toast.generationFailed"),{message:j})),z(q||Te("node.failedPlaceholder"),!0)}t().pushHistory()}}function Ul(e,t){if(oe.getState().autoRefreshPaused)return;const{nodes:n,edges:a}=e(),r=new Map(n.map(o=>[o.id,o])),s=o=>{const u=r.get(o);return!u||u.data.isLoading?!1:u.data.stepKind==="human"||u.data.stepKind==="note"||u.data.stepKind==="link"?!!u.data.question.trim():u.data.stepKind==="file"?(u.data.attachments?.length??0)>0:!!u.data.response&&!u.data.generationFailed};for(const o of a){if(o.source!==t||o.data?.isCrossLink)continue;const u=r.get(o.target);!u||u.data.stepKind!=="prompt"||u.data.response||u.data.isLoading||u.data.generationFailed||!a.filter(h=>h.target===u.id&&!h.data?.isCrossLink).map(h=>h.source).every(s)||e().rerunNode(u.id,{auto:!0})}}function kV(e,t,n){if(oe.getState().autoRefreshPaused)return;const a=new Set([n]),r=[n];for(;r.length>0;){const d=r.shift();for(const h of t().edges)h.target===d&&!h.data?.isCrossLink&&!a.has(h.source)&&(a.add(h.source),r.push(h.source))}t().edges.some(d=>d.data?.followsTip&&d.source!==n&&a.has(d.source))&&e(d=>({edges:d.edges.map(h=>h.data?.followsTip&&h.source!==n&&a.has(h.source)?{...h,id:`watch-${n}-${h.target}`,source:n}:h)}));const{nodes:o,edges:u}=t();for(const d of o){if(!(d.data.autoRerun??d.data.evaluatorTrigger==="auto")||d.id===n||d.data.isLoading||Ds.has(d.id))continue;const m=E0.get(d.id)??0;if(m>=(d.data.autoRerunRounds??1))continue;const{ordered:p}=Lr(d.id,o,u);p.some(x=>x.id===n)&&(E0.set(d.id,m+1),t().rerunNode(d.id,{auto:!0}))}}const BE=e=>{for(const t of e){const n=Ds.get(t);n&&(n.abort(),Ds.delete(t))}},EV=(e,t)=>({nodes:[],edges:[],selectedNodeId:null,selectedNodeIds:[],setNodes:n=>e({nodes:n}),setEdges:n=>e({edges:n}),setSelectedNodeId:n=>e({selectedNodeId:n,selectedNodeIds:n?[n]:[]}),setSelectedNodeIds:n=>e({selectedNodeIds:n,selectedNodeId:n.length===1?n[0]:null}),deleteNode:n=>{if(Kr())return;t().logEvent("delete",n,{n:1}),t().pushHistory();const{edges:a}=t(),r=Vo(n,a),s=new Set([n,...r]);BE(s),e(o=>({nodes:o.nodes.filter(u=>!s.has(u.id)),edges:o.edges.filter(u=>!s.has(u.source)&&!s.has(u.target))})),t().pushHistory(),ft(()=>import("./canonical-wWV9jbzN.js"),[]).then(o=>o.unsubscribeOrphanedSessions())},deleteEdges:n=>{if(Kr())return;t().logEvent("disconnect",n[0],{n:n.length});const a=new Set(n);t().edges.some(r=>a.has(r.id))&&(t().pushHistory(),e(r=>({edges:r.edges.filter(s=>!a.has(s.id))})),t().pushHistory())},editResponse:(n,a)=>{if(Kr())return;t().logEvent("edit-response",n,{chars:a.length}),t().pushHistory();const r=Nn(t().nodes.find(s=>s.id===n)?.data.question+a||a);e(s=>({nodes:s.nodes.map(o=>o.id===n?{...o,data:{...o.data,response:a,responses:o.data.responses.map((u,d)=>d===o.data.responseIndex?a:u),summaries:o.data.summaries?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTypes:o.data.summaryTypes?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryTopics:o.data.summaryTopics?.map((u,d)=>d===o.data.responseIndex?void 0:u),summaryLadders:o.data.summaryLadders?.map((u,d)=>d===o.data.responseIndex?void 0:u),editedAts:o.data.responses.map((u,d)=>d===o.data.responseIndex?new Date().toISOString():o.data.editedAts?.[d]),highlights:om(o.data.highlights,a),isEditingResponse:!1,tokenCount:r}}:o)})),t().pushHistory()},toggleCollapse:n=>{const a=t().nodes.find(h=>h.id===n);if(!a)return;const r=zi(a),o=S2({...a,data:{...a.data,isCollapsed:!a.data.isCollapsed}})-r,u=Vo(n,t().edges),d=new Set(u);e(h=>({nodes:h.nodes.map(m=>m.id===n?{...m,data:{...m.data,isCollapsed:!m.data.isCollapsed}}:d.has(m.id)?{...m,position:{...m.position,y:m.position.y+o}}:m)}))},setEditing:(n,a)=>{a&&Kr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditing:a}}:s)}))},setEditingResponse:(n,a)=>{a&&Kr()||e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,isEditingResponse:a}}:s)}))},duplicateNode:n=>{const a=t().nodes.find(m=>m.id===n);if(!a)return;t().pushHistory();const r=Tn(),s={id:r,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{...a.data,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,highlights:a.data.highlights.map(m=>({...m,id:Tn()}))}},o=t().edges.find(m=>m.target===n),u=o?{...o,id:`edge-${o.source}-${r}`,target:r}:null,d=u?[...t().edges,u]:t().edges,h=xr([...t().nodes,s],d);e({nodes:h,edges:d,selectedNodeId:r}),t().pushHistory()},addCrossLink:(n,a)=>{const{edges:r,nodes:s}=t();if(r.some(x=>x.source===n&&x.target===a))return;const u=s.find(x=>x.id===n);if(u&&["note","file","link"].includes(u.data.stepKind??"")){t().pushHistory();const x={id:`edge-${n}-${a}`,source:n,sourceHandle:"continue",target:a,targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};e(y=>({edges:[...y.edges,x]})),t().logEvent("connect",x.id),t().setEdgeStructural(x.id,!0);const b=t().edges.find(y=>y.id===x.id);if(b&&!b.data?.isCrossLink){const w=br(n,t().nodes,t().edges).messages.reduce((E,v)=>E+Nn(v.content),0);We("success",ye(Te("edge.materialWiredFull"),{n:w.toLocaleString()}),8e3,{label:Te("edge.materialMakeQuote"),run:()=>t().setEdgeStructural(x.id,!1)})}return}t().pushHistory();const d=s.find(x=>x.id===n),h=s.find(x=>x.id===a),m=!!d&&!!h&&h.position.y>d.position.y+60&&Math.abs(h.position.x-d.position.x)<320,p={id:`crosslink-${n}-${a}`,source:n,sourceHandle:m?"continue":"branch",target:a,targetHandle:m?"top":"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}};if(e(x=>({edges:[...x.edges,p]})),t().logEvent("connect",p.id),t().pushHistory(),d&&!["note","file","link"].includes(d.data.stepKind??"")){const{ordered:x}=Lr(n,s,r.filter(y=>!y.data?.isCrossLink)),b=x.filter(y=>y.id!==n&&!["note","file","link"].includes(y.data.stepKind??""));if(b.length>0){const y=Nn(y0({source:d,depth:"quote",chain:b})),E=br(n,s,r).messages.reduce((v,A)=>v+Nn(A.content),0)+Nn(d.data.question+d.data.response);We("info",ye(Te("edge.linkedQuote"),{n:y}),8e3,{label:ye(Te("edge.makeFull"),{m:E}),run:()=>t().setEdgeStructural(p.id,!0)})}}},staleIds:[],staleFps:{},staleVerdicts:{},setStaleVerdicts:n=>e(a=>({staleVerdicts:{...a.staleVerdicts,...n}})),recomputeStaleness:()=>{const{nodes:n,edges:a}=t(),r=[],s={};for(const d of n){if(!d.data.lastContextHash||!d.data.response||["note","file","link","frame"].includes(d.data.stepKind??""))continue;const h=w8(d.id,n,a);h!==d.data.lastContextHash&&(r.push(d.id),s[d.id]=h)}const o=t().staleFps,u=t().staleIds;u.length===r.length&&u.every((d,h)=>d===r[h]&&o[d]===s[d])||(e({staleIds:r,staleFps:s}),r.length&&ft(()=>Promise.resolve().then(()=>TV),void 0).then(d=>d.judgeStaleness()).catch(()=>{}))},setEdgeStructural:(n,a)=>{const{nodes:r,edges:s}=t(),o=s.find(u=>u.id===n);if(o){if(a){const u=s.filter(h=>!h.data?.isCrossLink),{ordered:d}=Lr(o.source,r,u);if(d.some(h=>h.id===o.target)){We("error",Te("edge.cycleBlocked"));return}}t().pushHistory(),t().logEvent(a?"connect":"disconnect",n,{convert:!0}),e(u=>({edges:u.edges.map(d=>{if(d.id!==n)return d;if(a){const h={...d.data??{}};return delete h.isCrossLink,delete h.contextDepth,delete h.isWatch,{...d,sourceHandle:"continue",targetHandle:"top",animated:!1,style:{stroke:it.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:h}}return{...d,animated:!0,style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{...d.data??{},isCrossLink:!0,contextDepth:void 0}}})})),e(u=>({nodes:xr(u.nodes,u.edges)})),t().pushHistory()}},setCrossLinkDepth:(n,a)=>{t().pushHistory(),e(r=>({edges:r.edges.map(s=>s.id!==n||!s.data?.isCrossLink?s:{...s,style:{...s.style,strokeDasharray:a==="full"?"12 3":"8 4",strokeWidth:a==="full"?3:2},data:{...s.data,contextDepth:a==="full"?"full":void 0}})})),t().pushHistory()},navigateVersion:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const{responses:o,responseIndex:u}=s.data;let d=a==="prev"?u-1:u+1;return d<0&&(d=o.length-1),d>=o.length&&(d=0),{...s,data:{...s.data,responseIndex:d,response:o[d],question:s.data.questions?.[d]??s.data.question,generationFailed:void 0,highlights:om(s.data.highlights,o[d])}}})}))},deleteVersion:(n,a)=>{t().pushHistory(),e(r=>({nodes:r.nodes.map(s=>{if(s.id!==n)return s;const o=s.data.responses.filter((d,h)=>h!==a);if(o.length===0)return s;const u=Math.min(s.data.responseIndex,o.length-1);return{...s,data:{...s.data,responses:o,responseIndex:u,response:o[u],questions:s.data.questions?.filter((d,h)=>h!==a),question:s.data.questions?.filter((d,h)=>h!==a)[u]??s.data.question,summaries:s.data.summaries?.filter((d,h)=>h!==a),generatedBy:s.data.generatedBy?.filter((d,h)=>h!==a),summaryTypes:s.data.summaryTypes?.filter((d,h)=>h!==a),reasonings:s.data.reasonings?.filter((d,h)=>h!==a),generatedAts:s.data.generatedAts?.filter((d,h)=>h!==a),editedAts:s.data.editedAts?.filter((d,h)=>h!==a),highlights:om(s.data.highlights,o[u])}}})})),t().pushHistory()},relayout:()=>{Kr()||(t().pushHistory(),e(n=>{const a=m$(n.nodes,n.edges);return{nodes:xr(n.nodes,a),edges:a}}),t().pushHistory())},setArchived:(n,a)=>{const r=new Set(n);t().pushHistory(),t().logEvent(a?"archive":"unarchive",n[0],{n:n.length}),e(s=>({nodes:s.nodes.map(o=>r.has(o.id)?{...o,data:{...o.data,archived:a||void 0,archivedAt:a?new Date().toISOString():void 0}}:o)})),t().pushHistory()},setNodeModel:(n,a)=>{e(r=>({nodes:r.nodes.map(s=>s.id===n?{...s,data:{...s.data,model:a}}:s)}))},alignSelection:n=>{if(n.length<2)return;const a=new Set(n),{nodes:r,edges:s}=t(),o=new Map,u=s.filter(b=>!b.data?.isWatch),d=(b,y)=>{if(o.has(b))return o.get(b);if(y.has(b))return 0;y.add(b);const w=u.filter(v=>v.target===b&&a.has(v.source)),E=w.length===0?0:1+Math.max(...w.map(v=>d(v.source,y)));return o.set(b,E),E},h=n.map(b=>r.find(y=>y.id===b)).filter(b=>!!b).sort((b,y)=>d(b.id,new Set)-d(y.id,new Set)||b.position.y-y.position.y);t().pushHistory();const m=h[0].position;let p=m.y;const x=new Map;for(const b of h)x.set(b.id,{x:m.x,y:p}),p+=zi(b)+40;e(b=>({nodes:b.nodes.map(y=>{const w=x.get(y.id);return w?{...y,position:w}:y})})),t().pushHistory()},batchDelete:n=>{if(Kr())return;t().logEvent("delete",n[0],{n:n.length}),t().pushHistory();const a=new Set(n);BE(a),e(r=>({nodes:r.nodes.filter(s=>!a.has(s.id)),edges:r.edges.filter(s=>!a.has(s.source)&&!a.has(s.target)),selectedNodeId:null,selectedNodeIds:[]})),t().pushHistory(),ft(()=>import("./canonical-wWV9jbzN.js"),[]).then(r=>r.unsubscribeOrphanedSessions())},duplicateSelection:n=>{const{nodes:a,edges:r}=t(),s=new Set(n),o=a.filter(_=>s.has(_.id));if(o.length===0)return;t().pushHistory();const u=_=>({x:_.position.x,y:_.position.y,w:_.measured?.width??_.width??520,h:_.measured?.height??_.height??zi(_)}),d=o.map(u),h={x:Math.min(...d.map(_=>_.x)),y:Math.min(...d.map(_=>_.y)),right:Math.max(...d.map(_=>_.x+_.w)),bottom:Math.max(...d.map(_=>_.y+_.h))},m=80,p=h.right-h.x+m,x=h.bottom-h.y+m,b=[];for(let _=1;_<=6;_++)b.push({dx:_*p,dy:0},{dx:0,dy:_*x},{dx:_*p,dy:_*x});const y=a.filter(_=>_.data.stepKind!=="frame").map(u),w=(_,S)=>_.x<S.x+S.w&&_.x+_.w>S.x&&_.y<S.y+S.h&&_.y+_.h>S.y,E=b.find(_=>!d.some(S=>y.some(z=>w({...S,x:S.x+_.dx,y:S.y+_.dy},z))))??{dx:p,dy:x},v=new Map,A=new Map;for(const _ of o){v.set(_.id,Tn());for(const S of _.data.attachments??[])A.set(S.id,Tn())}const T=_=>(_??[]).map(S=>A.get(S)??S),C=o.map(_=>({..._,id:v.get(_.id),position:{x:_.position.x+E.dx,y:_.position.y+E.dy},selected:!0,data:{..._.data,attachments:(_.data.attachments??[]).map(S=>({...S,id:A.get(S.id)})),excludedAttachmentIds:T(_.data.excludedAttachmentIds),includedAttachmentIds:T(_.data.includedAttachmentIds),digestOf:_.data.digestOf?A.get(_.data.digestOf)??_.data.digestOf:void 0,highlights:(_.data.highlights??[]).map(S=>({...S,id:Tn()})),isEditing:!1,isEditingResponse:!1,isLoading:!1}})),I=r.filter(_=>s.has(_.source)&&s.has(_.target)).map(_=>({..._,id:`edge-${v.get(_.source)}-${v.get(_.target)}`,source:v.get(_.source),target:v.get(_.target),data:_.data?{..._.data}:_.data})),O=C.map(_=>_.id);e(_=>({nodes:[..._.nodes.map(S=>S.selected?{...S,selected:!1}:S),...C],edges:[..._.edges,...I],selectedNodeId:O.length===1?O[0]:null,selectedNodeIds:O})),t().pushHistory()}}),H2=(e,t)=>{const n=e.staleVerdicts[t];return!!n&&n.fp===e.staleFps[t]&&n.p<q$},Xr=e=>e.staleIds.filter(t=>!H2(e,t)),N7=(e,t)=>{const n=e.staleVerdicts[t];return n&&n.fp===e.staleFps[t]?n:void 0},SV=8;let Ax=!1;const Cx=new Set;async function A7(){if(Ax||!Dr())return;const e=se.getState(),t=e.staleIds.filter(a=>e.staleVerdicts[a]?.fp!==e.staleFps[a]&&!Cx.has(`${a}:${e.staleFps[a]}`));if(!t.length)return;Ax=!0;try{const{nodes:a,edges:r}=e,s=[];for(const o of t.slice(0,SV)){Cx.add(`${o}:${e.staleFps[o]}`);const u=a.find(p=>p.id===o),d=u?.data.lastContextParts;if(!u||!d)continue;const h=k8(o,a,r),m=[];for(const[p,x]of Object.entries(h)){const b=d[p];(!b||b.h!==x.h)&&m.push({node:p,before:b?.head??"",after:x.text})}for(const p of Object.keys(d))h[p]||m.push({node:p,before:d[p].head,after:""});m.length&&s.push({id:o,question:u.data.question,answer:u.data.response,changes:m})}if(s.length){const o=await $$(s),u={};for(const d of s)u[d.id]={fp:e.staleFps[d.id],p:o[d.id],changed:d.changes.map(h=>h.node)};se.getState().setStaleVerdicts(u)}}catch{}finally{Ax=!1}const n=se.getState();n.staleIds.some(a=>n.staleVerdicts[a]?.fp!==n.staleFps[a]&&!Cx.has(`${a}:${n.staleFps[a]}`))&&A7()}const TV=Object.freeze(Object.defineProperty({__proto__:null,currentStaleVerdict:N7,judgeStaleness:A7,shownStaleIds:Xr,staleHiddenByJudge:H2},Symbol.toStringTag,{value:"Module"})),NV=(e,t)=>({addQuestion:async(n,a={})=>{if(Kr())return;const{parentId:r,branchContext:s,branchYRatio:o,inheritRole:u,rolePrompt:d,initialAttachments:h,excludeAllInheritedAttachments:m,mentions:p}=a,x=Tn();t().logEvent("ask",x,{chars:n.length,...r?{}:{root:!0},...s?{branch:!0}:{}});const b=!r,y=r?t().nodes.find(Y=>Y.id===r)?.data.model:void 0,w={id:x,type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:n,createdAt:new Date().toISOString(),askedAt:new Date().toISOString(),model:y,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!0,tokenCount:0,branchContext:s,highlights:[],highlightMode:"tag",attachments:h||[],excludedAttachmentIds:m&&r?t().getInheritedAttachments(r).map(({attachment:Y})=>Y.id).concat((t().nodes.find(Y=>Y.id===r)?.data.attachments||[]).map(Y=>Y.id)):[],includedAttachmentIds:[],roleMode:u===!1?"reset":"inherit",rolePrompt:d||void 0,isRoot:b,isBranch:!!s,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled,...zd()}},E=!!s,v=r?{id:`edge-${r}-${x}`,source:r,target:x,sourceHandle:E?"branch":"continue",targetHandle:E?"left":"top",type:"smoothstep",...E?{style:{stroke:it.warm,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.warm,width:18,height:18},data:{isBranchFromSelection:!0,branchYRatio:o??.5}}:{style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}:null;let A=v?[...t().edges,v]:t().edges;const T=(p??[]).filter(Y=>Y!==x&&Y!==r&&t().nodes.some(q=>q.id===Y));if(T.length>0){const Y=A.filter($=>!$.data?.isCrossLink),q=r?new Set(Lr(r,t().nodes,Y).ordered.map($=>$.id)):new Set,B=new Set(A.filter($=>$.data?.isCrossLink&&$.target===x).map($=>$.source));let j=0;for(const $ of T)q.has($)||B.has($)||(A=[...A,{id:`crosslink-${$}-${x}`,source:$,target:x,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.accent,strokeDasharray:"8 4",strokeWidth:2},animated:!0,data:{isCrossLink:!0,createdAt:new Date().toISOString()}}],j++);j>0&&We("info",ye(Te("mention.wired"),{n:j}),6e3)}const C=r?t().nodes.map(Y=>Y.id===r?{...Y,data:{...Y.data,isCollapsed:!0}}:Y):t().nodes,I=xr([...C,w],A);e({nodes:I,edges:A,selectedNodeId:x});const O=t().nodes.find(Y=>Y.id===x),_=r?br(r,t().nodes,t().edges,s,O?.data.excludedAttachmentIds,O?.data.includedAttachmentIds,Xr(t())):{messages:[],images:[],sources:[]},S=_.messages,z=_.images,V=r?t().nodes.find(Y=>Y.id===r):null;vE(S,yE(O?.data,V?.data,!!r));const P=O?.data.attachments||[];for(const Y of P)S.some(B=>B.content.includes(`[PDF: ${Y.name}]`)||B.content.includes(`[File: ${Y.name}]`))||(Y.type.startsWith("image/")?z.push({data:Y.content,mimeType:Y.type}):Y.type==="application/pdf"?Y.extractedText&&S.push({role:"user",content:`[PDF: ${Y.name}]
|
|
233
233
|
${Y.extractedText}`}):Y.type==="text/html"?Y.extractedText?.trim()&&S.push({role:"user",content:`[File: ${Y.name}]
|
|
234
234
|
${Y.extractedText}`}):Y.content&&S.push({role:"user",content:`[File: ${Y.name}]
|
|
235
235
|
${Y.content}`}));const L=S.find(Y=>Y.role==="system")?.content||void 0;S.push({role:"user",content:n}),e(Y=>({nodes:Y.nodes.map(q=>q.id===x?{...q,data:{...q.data,appliedRole:L}}:q)})),await Li(e,t,x,{question:n,messages:S,images:z,sources:_.sources})},fanOut:async(n,a,r,s={})=>{t().logEvent("fanout",n,{roles:r.length,chars:a.length});const o=t().nodes.find(T=>T.id===n);if(!o||r.length===0)return;const u=!!s.follow,d=u&&s.rounds&&s.rounds>1?Math.min(s.rounds,5):void 0;t().pushHistory();const h=[],m=[],p=[];r.forEach((T,C)=>{const I=Tn(),O=`${T.prompt}
|
|
@@ -287,7 +287,7 @@ ${u.content.trim()}`).join(`
|
|
|
287
287
|
|
|
288
288
|
---
|
|
289
289
|
|
|
290
|
-
${p}`:p,v=oe.getState().agentEffort||void 0,A=[...new Set(se.getState().nodes.flatMap(S=>(S.data.approvals??[]).filter(z=>z.outcome==="allowed-session"&&typeof z.rule=="string"&&z.rule.startsWith(h.runtime==="claude-code"?"claude:":h.runtime+":")).map(z=>z.rule)))];zV();let T="",C="",I="";const _=await new Promise(S=>{d.run({runtime:h.runtime,cwd:m,prompt:E,...o?.sessionPath?{sessionPath:o.sessionPath}:{},...o?.forkEntryId?{forkEntryId:o.forkEntryId}:{},images:(a??[]).map(z=>({type:"image",data:z.data,mimeType:z.mimeType})),model:{provider:h.provider,id:h.id},...v?{effort:v}:{},...A.length?{allowRules:A}:{}}).then(z=>{const V=()=>{d.abort(z)};n?.aborted&&V(),n?.addEventListener("abort",V,{once:!0}),lm.set(z,P=>{switch(P.type){case"session":{const L=P.model?.resolved;L&&window.dispatchEvent(new CustomEvent("td:agent-model-resolved",{detail:{id:s,resolved:L}})),r?.onAgentSession?.({runtime:h.runtime,sessionId:P.sessionId??null,sessionFile:P.sessionFile??null,cwd:P.cwd??m,...typeof P.effort=="string"&&P.effort?{effort:P.effort}:{}});break}case"message_update":{const L=P.assistantMessageEvent;L?.type==="text_delta"&&L.delta?(T+=L.delta,t(L.delta,T)):L?.type==="thinking_delta"&&L.delta&&(C+=L.delta,r?.onReasoning?.(L.delta,C));break}case"tool_execution_start":{const L=String(P.toolName??"tool"),Y=BV(L,P.args);r?.onAgentTool?.({id:String(P.toolCallId??""),name:L,query:Y,phase:"start"});break}case"tool_execution_end":r?.onAgentTool?.({id:String(P.toolCallId??""),name:String(P.toolName??"tool"),query:"",phase:"end",isError:!!P.isError});break;case"extension_ui_cancelled":{const L=`dialog-${Date.now()}`,Y=String(P.title??P.method??"dialog");r?.onAgentTool?.({id:L,name:"dialog",query:Y,phase:"start"}),r?.onAgentTool?.({id:L,name:"dialog",query:"",phase:"end",isError:!0});break}case"question_answered":r?.onApprovalDecided?.({...P.auto?{auto:!0,name:String(P.title??""),query:String(P.message??""),rule:typeof P.rule=="string"?P.rule:null}:{},id:String(P.id),outcome:P.outcome??"cancelled",value:typeof P.value=="string"?P.value:null});break;case"question":r?.onApproval?.({id:String(P.id),kind:P.kind??"confirm",toolName:h.runtime,callId:null,reason:null,name:String(P.title??""),query:String(P.message??""),arguments:null,options:Array.isArray(P.options)?P.options:[],placeholder:typeof P.placeholder=="string"?P.placeholder:null,prefill:typeof P.prefill=="string"?P.prefill:null,channel:{runId:z},paths:Array.isArray(P.paths)?P.paths:[],suggest:typeof P.suggest=="string"?P.suggest:null,rule:typeof P.rule=="string"?P.rule:null});break;case"fs_changes":r?.onAgentChanges?.({changed:P.changed??[],added:P.added??[],removed:P.removed??[],truncated:!!P.truncated});break;case"run_end":I=typeof P.text=="string"&&P.text?P.text:T,lm.delete(z),n?.removeEventListener("abort",V),S({how:String(P.how??"end")});break;case"run_error":lm.delete(z),n?.removeEventListener("abort",V),S({how:"error",error:String(P.message??"agent run failed")});break}})}).catch(z=>S({how:"error",error:z instanceof Error?z.message:String(z)}))});if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(_.how==="error")throw new Error(_.error??"agent run failed");return I||T}async function FV(e,t,n){const a=o=>(console.warn("[agent] turn not adopted:",o,t.runtime,t.sessionFile),!1),r=window.desktopSessions;if(!r||!t.sessionFile)return a(r?"no session file":"no sessions bridge");const s=Ki[t.runtime].rootKey;try{const u=(await r.roots()).find(q=>q.key===s);if(!u)return a("no root "+s);const d=u.path.replace(/\/$/,"")+"/";if(!t.sessionFile.startsWith(d))return a("file outside root "+d);const h=t.sessionFile.slice(d.length),{anyRunnerSessionConversation:m}=await ft(async()=>{const{anyRunnerSessionConversation:q}=await import("./index-
|
|
290
|
+
${p}`:p,v=oe.getState().agentEffort||void 0,A=[...new Set(se.getState().nodes.flatMap(S=>(S.data.approvals??[]).filter(z=>z.outcome==="allowed-session"&&typeof z.rule=="string"&&z.rule.startsWith(h.runtime==="claude-code"?"claude:":h.runtime+":")).map(z=>z.rule)))];zV();let T="",C="",I="";const _=await new Promise(S=>{d.run({runtime:h.runtime,cwd:m,prompt:E,...o?.sessionPath?{sessionPath:o.sessionPath}:{},...o?.forkEntryId?{forkEntryId:o.forkEntryId}:{},images:(a??[]).map(z=>({type:"image",data:z.data,mimeType:z.mimeType})),model:{provider:h.provider,id:h.id},...v?{effort:v}:{},...A.length?{allowRules:A}:{}}).then(z=>{const V=()=>{d.abort(z)};n?.aborted&&V(),n?.addEventListener("abort",V,{once:!0}),lm.set(z,P=>{switch(P.type){case"session":{const L=P.model?.resolved;L&&window.dispatchEvent(new CustomEvent("td:agent-model-resolved",{detail:{id:s,resolved:L}})),r?.onAgentSession?.({runtime:h.runtime,sessionId:P.sessionId??null,sessionFile:P.sessionFile??null,cwd:P.cwd??m,...typeof P.effort=="string"&&P.effort?{effort:P.effort}:{}});break}case"message_update":{const L=P.assistantMessageEvent;L?.type==="text_delta"&&L.delta?(T+=L.delta,t(L.delta,T)):L?.type==="thinking_delta"&&L.delta&&(C+=L.delta,r?.onReasoning?.(L.delta,C));break}case"tool_execution_start":{const L=String(P.toolName??"tool"),Y=BV(L,P.args);r?.onAgentTool?.({id:String(P.toolCallId??""),name:L,query:Y,phase:"start"});break}case"tool_execution_end":r?.onAgentTool?.({id:String(P.toolCallId??""),name:String(P.toolName??"tool"),query:"",phase:"end",isError:!!P.isError});break;case"extension_ui_cancelled":{const L=`dialog-${Date.now()}`,Y=String(P.title??P.method??"dialog");r?.onAgentTool?.({id:L,name:"dialog",query:Y,phase:"start"}),r?.onAgentTool?.({id:L,name:"dialog",query:"",phase:"end",isError:!0});break}case"question_answered":r?.onApprovalDecided?.({...P.auto?{auto:!0,name:String(P.title??""),query:String(P.message??""),rule:typeof P.rule=="string"?P.rule:null}:{},id:String(P.id),outcome:P.outcome??"cancelled",value:typeof P.value=="string"?P.value:null});break;case"question":r?.onApproval?.({id:String(P.id),kind:P.kind??"confirm",toolName:h.runtime,callId:null,reason:null,name:String(P.title??""),query:String(P.message??""),arguments:null,options:Array.isArray(P.options)?P.options:[],placeholder:typeof P.placeholder=="string"?P.placeholder:null,prefill:typeof P.prefill=="string"?P.prefill:null,channel:{runId:z},paths:Array.isArray(P.paths)?P.paths:[],suggest:typeof P.suggest=="string"?P.suggest:null,rule:typeof P.rule=="string"?P.rule:null});break;case"fs_changes":r?.onAgentChanges?.({changed:P.changed??[],added:P.added??[],removed:P.removed??[],truncated:!!P.truncated});break;case"run_end":I=typeof P.text=="string"&&P.text?P.text:T,lm.delete(z),n?.removeEventListener("abort",V),S({how:String(P.how??"end")});break;case"run_error":lm.delete(z),n?.removeEventListener("abort",V),S({how:"error",error:String(P.message??"agent run failed")});break}})}).catch(z=>S({how:"error",error:z instanceof Error?z.message:String(z)}))});if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(_.how==="error")throw new Error(_.error??"agent run failed");return I||T}async function FV(e,t,n){const a=o=>(console.warn("[agent] turn not adopted:",o,t.runtime,t.sessionFile),!1),r=window.desktopSessions;if(!r||!t.sessionFile)return a(r?"no session file":"no sessions bridge");const s=Ki[t.runtime].rootKey;try{const u=(await r.roots()).find(q=>q.key===s);if(!u)return a("no root "+s);const d=u.path.replace(/\/$/,"")+"/";if(!t.sessionFile.startsWith(d))return a("file outside root "+d);const h=t.sessionFile.slice(d.length),{anyRunnerSessionConversation:m}=await ft(async()=>{const{anyRunnerSessionConversation:q}=await import("./index-BRdlgS3c.js");return{anyRunnerSessionConversation:q}},[]),{useStore:p}=await ft(async()=>{const{useStore:q}=await Promise.resolve().then(()=>vs);return{useStore:q}},void 0),{useProjects:x,registerLedgerEntry:b,updateSourceSession:y,subscribedSessionIds:w}=await ft(async()=>{const{useProjects:q,registerLedgerEntry:B,updateSourceSession:j,subscribedSessionIds:$}=await Promise.resolve().then(()=>Sa);return{useProjects:q,registerLedgerEntry:B,updateSourceSession:j,subscribedSessionIds:$}},void 0),E=await r.read(s,h);if(!E)return a("empty file");const v=await m(E);if(!v?.sessionId)return a("no conversation recognized");const T=v.build().nodes.filter(q=>q.data.importSource),C=n.trim();let I=-1;for(let q=T.length-1;q>=0;q--){const B=T[q].data.question.trim();if(B===C||B.endsWith(C)||C.endsWith(B)){I=q;break}}if(I<0&&(I=T.length-1),I<0)return a("no turn in file yet");const O=T[I],_=O.data.attachments??[],S=qV(t,_),z=S?[..._,S]:_;p.setState(q=>({nodes:q.nodes.map(B=>B.id===e?{...B,data:{...B.data,attachments:[...(B.data.attachments??[]).filter(j=>!j.op),...z],excludedAttachmentIds:[...new Set([...B.data.excludedAttachmentIds??[],...z.map(j=>j.id)])],importSource:O.data.importSource,source:O.data.source??{question:O.data.question,response:O.data.response},agentTrace:void 0}}:B)}));const{projects:V,activeId:P}=x.getState(),L=P?V.find(q=>q.id===P):void 0;if(!L)return!0;const Y={sessionId:v.sessionId,runner:t.runtime,importedCount:I+1,tailNodeId:e};if(w(L).includes(v.sessionId)){const{patchLedgerEntry:q}=await ft(async()=>{const{patchLedgerEntry:B}=await Promise.resolve().then(()=>Sa);return{patchLedgerEntry:B}},void 0);await q(P,v.sessionId,{importedCount:I+1,tailNodeId:e})}else L.sourceSession?await b(P,"chapter",Y):(await y(P,Y),x.getState().projects.find(q=>q.id===P)?.sourceSession||(x.setState(q=>({projects:q.projects.map(B=>B.id===P?{...B,sourceSession:Y}:B)})),await b(P,"chapter",Y).catch(()=>{}),x.setState(q=>({projects:q.projects.map(B=>B.id===P&&B.sourceSession?{...B,sourceSession:{...B.sourceSession,chapters:(B.sourceSession.chapters??[]).filter(j=>j.sessionId!==Y.sessionId)}}:B)}))));return!0}catch(o){return a("threw: "+(o instanceof Error?o.message:String(o)))}}async function UV(){try{const{useProjects:e}=await ft(async()=>{const{useProjects:r}=await Promise.resolve().then(()=>Sa);return{useProjects:r}},void 0),{projects:t,activeId:n}=e.getState(),a=t.find(r=>r.id===n)?.agentGuard;return{mode:a?.mode==="allow"?"allow":"ask",allow:a?.allow??[]}}catch{return{mode:"ask",allow:[]}}}async function U2(e){if(!window.desktopAgents)return;const t=e??(await F2())?.cwd;if(t)try{await window.desktopAgents.guardWrite(t,await UV())}catch{}}async function qE(e){const{useProjects:t,setProjectAgentGuard:n}=await ft(async()=>{const{useProjects:o,setProjectAgentGuard:u}=await Promise.resolve().then(()=>Sa);return{useProjects:o,setProjectAgentGuard:u}},void 0),{projects:a,activeId:r}=t.getState();if(!r)return;const s=a.find(o=>o.id===r)?.agentGuard;await n(r,{mode:e,allow:s?.allow??[]}),await U2()}async function M7(e,t=!1){const{useProjects:n,setProjectAgentGuard:a}=await ft(async()=>{const{useProjects:d,setProjectAgentGuard:h}=await Promise.resolve().then(()=>Sa);return{useProjects:d,setProjectAgentGuard:h}},void 0),{projects:r,activeId:s}=n.getState();if(!s)return;const o=r.find(d=>d.id===s)?.agentGuard,u=t?(o?.allow??[]).filter(d=>d!==e):[...new Set([...o?.allow??[],e])];await a(s,{mode:o?.mode??"ask",allow:u}),await U2()}function qV(e,t){const n=e.changes;if(!n)return null;const a=new Set;for(const d of t)for(const h of d.paths??[])a.add(h.startsWith("/")?h:`${e.cwd.replace(/\/$/,"")}/${h}`);const r=[...n.changed,...n.added].filter(d=>!a.has(d)),s=n.removed.filter(d=>!a.has(d));if(r.length===0&&s.length===0&&!n.truncated)return null;const o=d=>d.startsWith(e.cwd)?d.slice(e.cwd.length).replace(/^\//,""):d,u=[];return r.length&&u.push("Changed on disk during this turn (seen by the file system, not declared by a tool):",...r.map(d=>"- "+o(d))),s.length&&u.push("Removed:",...s.map(d=>"- "+o(d))),n.truncated&&u.push("(the directory was too large to scan completely)"),{id:`fs-${Date.now().toString(36)}`,name:"tool: fs-changes",type:"text/plain",size:0,content:u.join(`
|
|
291
291
|
`),op:"write",paths:[...r,...s]}}let Za=null,ly=null;const Yd=new Set;function dr(){return Za?Promise.resolve(Za):(ly??=(async()=>{const e=as();let t=null;if(e.length>0)try{t=await W0(e)}catch{}return t||(t=await fetch(`${ci}/api/models`).then(n=>n.json()).then(n=>({models:n.models??[],default:n.default??null,capabilities:n.capabilities})).catch(()=>null)),t?(Za=D7(t),Za):null})(),ly)}function $E(e){return(e.split("/").pop()??e).toLowerCase()}function I7(e,t){if(t.some(r=>r.id===e))return e;const n=$E(e),a=t.find(r=>$E(r.id)===n);return a?a.id:null}const q2="thoughtdag.agentModels",O7="thoughtdag.agentModelNames",Tp=()=>typeof window<"u"&&!!window.desktopAgents,mu=e=>e.provider===sr&&si(e.id);function $2(){try{const e=JSON.parse(localStorage.getItem(O7)??"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function W2(e){const t=$2();return e.map(n=>{const a=n.provider===sr?t[n.id]:void 0;return!a||n.id.endsWith("/"+a)||n.name.includes(a)?n:{...n,name:`${n.name} · ${a}`}})}function S0(e,t,n){if(!e)return"";const a=C7(e);if(!a)return e.split("/").pop()??e;let r=[];try{r=JSON.parse(localStorage.getItem(q2)??"[]")}catch{r=[]}const o=r.find(h=>h&&h.id===e)?.name??`${Ki[a.runtime].label} · ${a.id}`,u=n?.compact?void 0:$2()[e],d=u&&!o.includes(u)?`${o} · ${u}`:o;return t?`${d} · ${t}`:d}function D7(e){if(!Tp())return e;let t=[];try{t=JSON.parse(localStorage.getItem(q2)??"[]")}catch{t=[]}const n=e.models.filter(a=>!mu(a));return{...e,models:[...n,...W2(t.filter(a=>a&&mu(a)))],agentsPending:!1}}let Bm=!1,Sd=null;async function V2(){if(!(!Tp()||!Za))return Sd||(Sd=(async()=>{const e=Za;ql({...e,agentsPending:!0});const t=await OV().catch(()=>({models:[],runtimes:{}})),n=t.models;try{localStorage.setItem(q2,JSON.stringify(n))}catch{}const a=(Za??e).models.filter(r=>!mu(r));ql({...Za??e,models:[...a,...W2(n)],agentsPending:!1,runtimes:t.runtimes})})().finally(()=>{Sd=null}),Sd)}function $V(){return Bm=!0,dr().then(()=>V2())}function WE(){Bm||!Tp()||(Bm=!0,dr().then(()=>V2()))}function WV(e,t){if(!e||!t)return;const n=$2();if(n[e]===t)return;n[e]=t;try{localStorage.setItem(O7,JSON.stringify(n))}catch{}if(!Za)return;const a=Za.models.filter(s=>!mu(s)),r=Za.models.filter(mu).map(s=>({...s,name:s.name.split(" · ").slice(0,2).join(" · ")}));ql({...Za,models:[...a,...W2(r)]})}typeof window<"u"&&window.addEventListener("td:agent-model-resolved",e=>{const t=e.detail;t?.id&&t?.resolved&&WV(t.id,t.resolved)});function ql(e){Za=e,ly=Promise.resolve(e);for(const t of Yd)t(e);if(e.agentsPending===void 0&&Tp()&&!e.models.some(mu)){Za=D7(e);for(const t of Yd)t(Za);Bm&&V2()}}function Yl(){const[e,t]=D.useState(Za);return D.useEffect(()=>{const n=a=>t(a);return Yd.add(n),Za||dr().then(a=>{Yd.has(n)&&a&&t(a)}),()=>{Yd.delete(n)}},[]),e}const VV=[[/^(Read|NotebookRead)$/i,"📖"],[/^(Edit|Write|MultiEdit|NotebookEdit)$/i,"✏️"],[/^(Bash|BashOutput|Shell)$/i,"⌨️"],[/^(Grep|Glob|LS|Search|WebSearch)$/i,"🔍"],[/^(WebFetch|Fetch)$/i,"🌐"],[/^(Task|Agent)$/i,"🤖"]],R7=/^tool: (\S+?)( \(truncated\))?$/;function GV(e){const t=new Map;for(const n of e.attachments??[]){const a=n.name.match(R7);if(!a)continue;const r=a[1],s=VV.find(([u])=>u.test(r))?.[1]??"🔧",o=t.get(r);o?o.count+=1:t.set(r,{glyph:s,name:r,count:1})}return[...t.values()]}function YV(e){let t=0;for(const s of e.attachments??[])R7.test(s.name)&&(t+=Nn(s.content));if(t===0)return null;const n=Nn(e.question),a=Nn(e.response),r=n+a+t;return{q:n,a,tool:t,total:r,toolShare:r>0?t/r:0}}function KV(e){const t=new Map;for(const n of e.attachments??[])if(!(!n.paths?.length||n.op!=="read"&&n.op!=="write"&&n.op!=="edit"))for(const a of n.paths){const r=t.get(a);r?r.op==="read"&&n.op!=="read"&&(r.op=n.op):t.set(a,{path:a,name:a.split("/").filter(Boolean).pop()??a,op:n.op})}return[...t.values()].sort((n,a)=>(n.op==="read"?1:0)-(a.op==="read"?1:0))}function XV(e,t=140){const n=e.replace(/```[\s\S]*?```/g,"").split(/\n\s*\n/).map(s=>s.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[#*`>|_~]/g,"").replace(/^\s*[-•\d.)]+\s*/gm,"").replace(/\s+/g," ").trim()).filter(s=>s.length>12&&!/[::]$/.test(s)&&!/^(sources?|references?|来源|参考)\b/i.test(s)),a=n.filter(s=>s.length>=30),r=a[a.length-1]??n[n.length-1]??e.replace(/[#*`>-]/g,"").replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t)}…`:r}function Y0(){const e=D.useRef("work");return ln(t=>{const n=t.transform[2],a=e.current;return a==="work"?n<=.8&&(e.current=n<=.32?"glyph":"map"):a==="map"?n>=.9?e.current="work":n<=.32&&(e.current="glyph"):n>=.9?e.current="work":n>=.4&&(e.current="map"),e.current})}const VE={en:{name:"Rule-out / Rule-in",steps:[{id:"q",kind:"human",x:560,y:40,title:"Research question",instruction:"Type the question to differentiate: what phenomenon needs explaining?"},{id:"mechA",kind:"prompt",x:20,y:440,title:"Candidate: Mechanism A",instruction:`You advocate a low-level mechanistic account of the phenomenon. Be concrete and falsifiable.
|
|
292
292
|
From this lens, give the single best candidate explanation for the question above: name the mechanism, its testable predictions, and what evidence would rule it in or out.`},{id:"mechB",kind:"prompt",x:500,y:440,title:"Candidate: Mechanism B",instruction:`You advocate a higher-level / systems account. Name the mechanism and its boundary conditions.
|
|
293
293
|
From this lens, give the single best candidate explanation for the question above: name the mechanism, its testable predictions, and what evidence would rule it in or out.`},{id:"conf",kind:"prompt",x:980,y:440,title:"Candidate: Confound",instruction:`You argue the effect is an artifact or confound, not the phenomenon of interest.
|
|
@@ -298,19 +298,19 @@ For each candidate above, judge what evidence would rule it OUT and what would r
|
|
|
298
298
|
严格从这个视角,为上面的问题给出唯一最佳的候选解释:说清机制、可检验的预测,以及什么证据能确认或排除它。`},{id:"conf",kind:"prompt",x:980,y:440,title:"候选:混杂",instruction:`你主张这个效应是假象或混杂因素,而非目标现象。
|
|
299
299
|
严格从这个视角,为上面的问题给出唯一最佳的候选解释:说清疑似的混杂来源、可检验的预测,以及什么证据能确认或排除它。`},{id:"null",kind:"prompt",x:1460,y:440,title:"候选:零假设",instruction:`你主张这个效应可能不真实或被夸大,给出最强的收缩性论证。
|
|
300
300
|
严格从这个视角回答上面的问题:什么会让效应消失,以及什么证据能确认或排除这一解释。`},{id:"rev",kind:"prompt",x:560,y:920,title:"鉴别评审",instruction:`你是一位严谨的方法学家,正在对相互竞争的解释做鉴别诊断。
|
|
301
|
-
对上面每个候选,判断什么证据能将它排除(rule out)、什么能将它确认(rule in)。按可区分度排序:哪个检验最能把它们分开?`},{id:"syn",kind:"prompt",x:560,y:1360,title:"收敛",instruction:"综合上面的候选与区分性检验:先确认哪个解释、排除哪个,以及信息量最大的下一个实验是什么。"}],edges:[["q","mechA"],["q","mechB"],["q","conf"],["q","null"],["mechA","rev"],["mechB","rev"],["conf","rev"],["null","rev"],["rev","syn"]]}};function QV(e){const{name:t,steps:n,edges:a}=VE[e]??VE.en,r=n.map(o=>({id:`p-${o.id}`,type:"thought",position:{x:o.x,y:o.y},dragHandle:".drag-handle",data:{question:o.title,instruction:o.instruction,stepKind:o.kind,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:o.id==="q",isBranch:!1}})),s=a.map(([o,u])=>({id:`p-e-${o}-${u}`,source:`p-${o}`,target:`p-${u}`,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}));return{name:t,nodes:r,edges:s}}const cy="thoughtdag:projects",GE="thoughtdag",ws=e=>`thoughtdag:project:${e}`;async function Hm(e,t){const{projects:n,activeId:a}=sn.getState();if(t&&e===a){const r=n.filter(s=>s.id!==e&&!s.archived).sort((s,o)=>o.updatedAt-s.updatedAt);r.length>0?await Ui(r[0].id):await Np("My Canvas")}sn.setState(r=>({projects:r.projects.map(s=>s.id===e?{...s,archived:t}:s)})),await Pr()}async function ZV(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e&&a.sourceSession?{...a,sourceSession:{...a.sourceSession,...t}}:a)})),await Pr()}async function JV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e||!r.sourceSession)return r;const s=r.sourceSession;return s.sessionId===t?{...r,sourceSession:{...s,...n}}:{...r,sourceSession:{...s,chapters:s.chapters?.map(o=>o.sessionId===t?{...o,...n}:o),branches:s.branches?.map(o=>o.sessionId===t?{...o,...n}:o)}}})})),await Pr()}async function eG(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e)return r;const s=r.sourceSession??{sessionId:"",runner:"",importedCount:0,tailNodeId:""};return t==="chapter"?{...r,sourceSession:{...s,chapters:[...s.chapters??[],{sessionId:n.sessionId,runner:n.runner,importedCount:n.importedCount,tailNodeId:n.tailNodeId}]}}:{...r,sourceSession:{...s,branches:[...s.branches??[],{...n,anchorNodeId:n.anchorNodeId??""}]}}})})),await Pr()}async function tG(e,t){sn.setState(n=>({projects:n.projects.map(a=>{if(a.id!==e||!a.sourceSession)return a;const r=a.sourceSession,s=(r.chapters??[]).filter(d=>d.sessionId!==t),o=(r.branches??[]).filter(d=>d.sessionId!==t),u={...r,chapters:s.length?s:void 0,branches:o.length?o:void 0};return u.sessionId===t&&(u.sessionId="",u.runner="",u.importedCount=0,u.tailNodeId=""),!u.sessionId&&s.length===0&&o.length===0?{...a,sourceSession:void 0}:{...a,sourceSession:u}})})),await Pr()}function uy(e){const t=e.sourceSession;return t?[t.sessionId,...(t.chapters??[]).map(n=>n.sessionId),...(t.branches??[]).map(n=>n.sessionId)].filter(Boolean):[]}async function j7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,instantiatedFrom:{name:t,at:new Date().toISOString()}}:a)})),await Pr()}const sn=$0(()=>({projects:[],activeId:null,switching:!1}));async function Pr(){const{projects:e,activeId:t}=sn.getState();await jr(cy,{projects:e,activeId:t})}let YE=null;function L7(){return YE??=(async()=>{let e=await Yo(cy);if(!e||e.projects.length===0){const t=await Yo(GE),n=crypto.randomUUID(),a=Date.now();t&&await jr(ws(n),t),e={projects:[{id:n,name:"My Canvas",createdAt:a,updatedAt:a}],activeId:n},await jr(cy,e),t&&await bu(GE)}e.projects.some(t=>t.id===e.activeId)||(e.activeId=e.projects[0].id),sn.setState({projects:e.projects,activeId:e.activeId}),se.persist.setOptions({name:ws(e.activeId)}),await se.persist.rehydrate()})().catch(async e=>{console.error("[thoughtdag] project boot failed:",e),We("error",Te("toast.projectsLoadFailed")),se.persist.setOptions({name:ws("recovery")}),await se.persist.rehydrate()}),YE}let dy=!1;async function nG(){for(const t of Ds.values())t.abort();const e=Date.now()+1e3;for(;Ds.size>0&&Date.now()<e;)await new Promise(t=>setTimeout(t,30));await new Promise(t=>setTimeout(t,0))}const P7=[];async function Ui(e){for(const r of P7)await r().catch(()=>{});const{activeId:t,switching:n,projects:a}=sn.getState();if(!(n||e===t||!a.some(r=>r.id===e))){sn.setState({switching:!0});try{await nG(),await Rq(),lW(),dy=!0,se.persist.setOptions({name:ws(e)}),await se.persist.rehydrate(),se.setState({selectedNodeId:null,selectedNodeIds:[]}),sn.setState(r=>({activeId:e,projects:r.projects.map(s=>s.id===e&&s.archived?{...s,archived:!1}:s)})),await Pr()}finally{dy=!1,sn.setState({switching:!1})}}}async function Np(e="Untitled",t="chat"){const n=crypto.randomUUID(),a=Date.now();return sn.setState(r=>({projects:[...r.projects,{id:n,name:e,createdAt:a,updatedAt:a,kind:t}]})),await Pr(),await Ui(n),n}async function G2(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentCwd:t}:a)})),await Pr()}async function aG(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentGuard:t}:a)})),await Pr()}async function z7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,name:t}:a)})),await Pr()}async function B7(e){const{projects:t,activeId:n}=sn.getState();if(e===n){const a=t.filter(r=>r.id!==e);a.length>0?await Ui(a[0].id):await Np("My Canvas")}await bu(ws(e)),sn.setState(a=>({projects:a.projects.filter(r=>r.id!==e)})),await Pr(),ft(()=>import("./canvas-record-
|
|
301
|
+
对上面每个候选,判断什么证据能将它排除(rule out)、什么能将它确认(rule in)。按可区分度排序:哪个检验最能把它们分开?`},{id:"syn",kind:"prompt",x:560,y:1360,title:"收敛",instruction:"综合上面的候选与区分性检验:先确认哪个解释、排除哪个,以及信息量最大的下一个实验是什么。"}],edges:[["q","mechA"],["q","mechB"],["q","conf"],["q","null"],["mechA","rev"],["mechB","rev"],["conf","rev"],["null","rev"],["rev","syn"]]}};function QV(e){const{name:t,steps:n,edges:a}=VE[e]??VE.en,r=n.map(o=>({id:`p-${o.id}`,type:"thought",position:{x:o.x,y:o.y},dragHandle:".drag-handle",data:{question:o.title,instruction:o.instruction,stepKind:o.kind,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:o.id==="q",isBranch:!1}})),s=a.map(([o,u])=>({id:`p-e-${o}-${u}`,source:`p-${o}`,target:`p-${u}`,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}));return{name:t,nodes:r,edges:s}}const cy="thoughtdag:projects",GE="thoughtdag",ws=e=>`thoughtdag:project:${e}`;async function Hm(e,t){const{projects:n,activeId:a}=sn.getState();if(t&&e===a){const r=n.filter(s=>s.id!==e&&!s.archived).sort((s,o)=>o.updatedAt-s.updatedAt);r.length>0?await Ui(r[0].id):await Np("My Canvas")}sn.setState(r=>({projects:r.projects.map(s=>s.id===e?{...s,archived:t}:s)})),await Pr()}async function ZV(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e&&a.sourceSession?{...a,sourceSession:{...a.sourceSession,...t}}:a)})),await Pr()}async function JV(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e||!r.sourceSession)return r;const s=r.sourceSession;return s.sessionId===t?{...r,sourceSession:{...s,...n}}:{...r,sourceSession:{...s,chapters:s.chapters?.map(o=>o.sessionId===t?{...o,...n}:o),branches:s.branches?.map(o=>o.sessionId===t?{...o,...n}:o)}}})})),await Pr()}async function eG(e,t,n){sn.setState(a=>({projects:a.projects.map(r=>{if(r.id!==e)return r;const s=r.sourceSession??{sessionId:"",runner:"",importedCount:0,tailNodeId:""};return t==="chapter"?{...r,sourceSession:{...s,chapters:[...s.chapters??[],{sessionId:n.sessionId,runner:n.runner,importedCount:n.importedCount,tailNodeId:n.tailNodeId}]}}:{...r,sourceSession:{...s,branches:[...s.branches??[],{...n,anchorNodeId:n.anchorNodeId??""}]}}})})),await Pr()}async function tG(e,t){sn.setState(n=>({projects:n.projects.map(a=>{if(a.id!==e||!a.sourceSession)return a;const r=a.sourceSession,s=(r.chapters??[]).filter(d=>d.sessionId!==t),o=(r.branches??[]).filter(d=>d.sessionId!==t),u={...r,chapters:s.length?s:void 0,branches:o.length?o:void 0};return u.sessionId===t&&(u.sessionId="",u.runner="",u.importedCount=0,u.tailNodeId=""),!u.sessionId&&s.length===0&&o.length===0?{...a,sourceSession:void 0}:{...a,sourceSession:u}})})),await Pr()}function uy(e){const t=e.sourceSession;return t?[t.sessionId,...(t.chapters??[]).map(n=>n.sessionId),...(t.branches??[]).map(n=>n.sessionId)].filter(Boolean):[]}async function j7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,instantiatedFrom:{name:t,at:new Date().toISOString()}}:a)})),await Pr()}const sn=$0(()=>({projects:[],activeId:null,switching:!1}));async function Pr(){const{projects:e,activeId:t}=sn.getState();await jr(cy,{projects:e,activeId:t})}let YE=null;function L7(){return YE??=(async()=>{let e=await Yo(cy);if(!e||e.projects.length===0){const t=await Yo(GE),n=crypto.randomUUID(),a=Date.now();t&&await jr(ws(n),t),e={projects:[{id:n,name:"My Canvas",createdAt:a,updatedAt:a}],activeId:n},await jr(cy,e),t&&await bu(GE)}e.projects.some(t=>t.id===e.activeId)||(e.activeId=e.projects[0].id),sn.setState({projects:e.projects,activeId:e.activeId}),se.persist.setOptions({name:ws(e.activeId)}),await se.persist.rehydrate()})().catch(async e=>{console.error("[thoughtdag] project boot failed:",e),We("error",Te("toast.projectsLoadFailed")),se.persist.setOptions({name:ws("recovery")}),await se.persist.rehydrate()}),YE}let dy=!1;async function nG(){for(const t of Ds.values())t.abort();const e=Date.now()+1e3;for(;Ds.size>0&&Date.now()<e;)await new Promise(t=>setTimeout(t,30));await new Promise(t=>setTimeout(t,0))}const P7=[];async function Ui(e){for(const r of P7)await r().catch(()=>{});const{activeId:t,switching:n,projects:a}=sn.getState();if(!(n||e===t||!a.some(r=>r.id===e))){sn.setState({switching:!0});try{await nG(),await Rq(),lW(),dy=!0,se.persist.setOptions({name:ws(e)}),await se.persist.rehydrate(),se.setState({selectedNodeId:null,selectedNodeIds:[]}),sn.setState(r=>({activeId:e,projects:r.projects.map(s=>s.id===e&&s.archived?{...s,archived:!1}:s)})),await Pr()}finally{dy=!1,sn.setState({switching:!1})}}}async function Np(e="Untitled",t="chat"){const n=crypto.randomUUID(),a=Date.now();return sn.setState(r=>({projects:[...r.projects,{id:n,name:e,createdAt:a,updatedAt:a,kind:t}]})),await Pr(),await Ui(n),n}async function G2(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentCwd:t}:a)})),await Pr()}async function aG(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,agentGuard:t}:a)})),await Pr()}async function z7(e,t){sn.setState(n=>({projects:n.projects.map(a=>a.id===e?{...a,name:t}:a)})),await Pr()}async function B7(e){const{projects:t,activeId:n}=sn.getState();if(e===n){const a=t.filter(r=>r.id!==e);a.length>0?await Ui(a[0].id):await Np("My Canvas")}await bu(ws(e)),sn.setState(a=>({projects:a.projects.filter(r=>r.id!==e)})),await Pr(),ft(()=>import("./canvas-record-BHE3oU8V.js"),[]).then(a=>a.removeCanvasRecord(e)).catch(()=>{})}async function vu(e,t,n="chat",a){const r=Date.now();sn.setState(s=>({projects:[...s.projects,{id:e,name:t,createdAt:r,updatedAt:r,kind:n,...a}]})),await Pr(),await Ui(e)}async function rG(e){const{name:t,nodes:n,edges:a}=QV(e),r=crypto.randomUUID();await jr(ws(r),JSON.stringify({state:{nodes:n,edges:a},version:1})),await vu(r,t,"paradigm")}let _x=null;se.subscribe((e,t)=>{dy||e.nodes===t.nodes&&e.edges===t.edges||(_x&&clearTimeout(_x),_x=setTimeout(()=>{const{activeId:n}=sn.getState();if(!n)return;const a=[...new Set(se.getState().nodes.map(r=>r.data.importSource?.sessionId).filter(r=>!!r))];sn.setState(r=>({projects:r.projects.map(s=>s.id===n?{...s,updatedAt:Date.now(),provenanceSessions:a}:s)})),Pr()},1e3))});const Sa=Object.freeze(Object.defineProperty({__proto__:null,adoptImportedProject:vu,beforeSwitchHooks:P7,bootProjects:L7,createBuiltinParadigm:rG,createProject:Np,deleteProject:B7,markInstantiatedFrom:j7,patchLedgerEntry:JV,projectStorageKey:ws,registerLedgerEntry:eG,removeLedgerEntry:tG,renameProject:z7,setProjectAgentCwd:G2,setProjectAgentGuard:aG,setProjectArchived:Hm,subscribedSessionIds:uy,switchProject:Ui,updateSourceSession:ZV,useProjects:sn},Symbol.toStringTag,{value:"Module"}));function H7(e){if(Array.isArray(e)&&e.length>0){const n=e[0];if(n&&typeof n=="object"&&"mapping"in n)return"chatgpt";if(n&&typeof n=="object"&&"chat_messages"in n)return"claude"}const t=e;return t&&typeof t=="object"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)?"thoughtdag":"unknown"}function F7(e,t,n){return{id:Tn(),type:"thought",position:{x:0,y:0},dragHandle:".drag-handle",data:{question:e,response:t,responses:[t],responseIndex:0,isCollapsed:!0,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:Math.ceil((e+t).length/4),highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:n,isBranch:!1}}}function U7(e,t){return{id:`edge-${e}-${t}`,source:e,target:t,type:"smoothstep",sourceHandle:"continue",targetHandle:"top",style:{stroke:"#6B5CE7",strokeWidth:2},markerEnd:{type:"arrowclosed",color:"#6B5CE7",width:18,height:18},data:{}}}function q7(e){const t=e.message?.content?.parts;return Array.isArray(t)?t.filter(n=>typeof n=="string").join(`
|
|
302
302
|
`).trim():""}function sG(e){const t=[],n=[],a=Object.values(e).filter(s=>!s.parent||!e[s.parent]),r=(s,o,u)=>{const d=e[s];if(!d)return;const h=d.message?.author?.role,m=q7(d);let p=o,x=u;if(h==="user"&&m)p=m;else if(h==="assistant"&&m){if(p!==null){const b=F7(p,m,u===null);t.push(b),u&&n.push(U7(u,b.id)),x=b.id,p=null}else if(x){const b=t.find(y=>y.id===x);b&&(b.data.response+=`
|
|
303
303
|
|
|
304
304
|
`+m,b.data.responses=[b.data.response])}}for(const b of d.children??[])r(b,p,x)};for(const s of a)r(s.id,null,null);return{nodes:xr(t,n),edges:n}}function $7(e){return typeof e.text=="string"&&e.text.trim()?e.text.trim():Array.isArray(e.content)?e.content.filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
305
305
|
`).trim():""}function iG(e){const t=[],n=[];let a=null,r=null;for(const s of e){const o=$7(s);if(o){if(s.sender==="human")a=o;else if(s.sender==="assistant"){if(a!==null){const u=F7(a,o,r===null);t.push(u),r&&n.push(U7(r,u.id)),r=u.id,a=null}else if(r){const u=t.find(d=>d.id===r);u&&(u.data.response+=`
|
|
306
306
|
|
|
307
|
-
`+o,u.data.responses=[u.data.response])}}}}return{nodes:xr(t,n),edges:n}}function oG(e){const t=H7(e),n=[];if(t==="chatgpt")for(const a of e){const r=a.mapping??{},s=Object.values(r).filter(o=>["user","assistant"].includes(o.message?.author?.role??"")&&q7(o)).length;s!==0&&n.push({title:a.title||"Untitled",messageCount:s,source:"chatgpt",build:()=>sG(r)})}else if(t==="claude")for(const a of e){const r=a.chat_messages??[],s=r.filter(o=>$7(o)).length;s!==0&&n.push({title:a.name||"Untitled",messageCount:s,source:"claude",build:()=>iG(r)})}return n}function lG(e){return e.some(t=>t.data.stepKind==="human"&&!t.data.question||t.data.stepKind==="prompt"&&(t.data.isLoading||!t.data.response&&!t.data.generationFailed))}function cG(e){const t=e;return!!t&&typeof t=="object"&&t.kind==="thoughtdag-paradigm"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}const uG=()=>({question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1});function dG(e,t){const n=new Map,a=e.map(u=>{const d=Tn();n.set(u.id,d);const h=u.data.stepKind??"prompt",m=(u.data.instruction?.trim()||u.data.question||"").trim(),p={...uG(),question:m,rolePrompt:u.data.rolePrompt||void 0,roleMode:u.data.rolePrompt?"reset":"inherit"};return h==="human"&&(p.stepKind="human",p.question="",p.instruction=u.data.instruction?.trim()||void 0,p.rolePrompt=void 0,p.roleMode="inherit"),h==="prompt"&&(p.stepKind="prompt",p.webSearch=u.data.webSearch,p.scholarSearch=u.data.scholarSearch,p.autoRerun=u.data.autoRerun,p.autoRerunRounds=u.data.autoRerunRounds),(h==="note"||h==="file"||h==="link"||h==="frame")&&(p.stepKind=h,p.question=u.data.question||"",p.attachments=u.data.attachments??[],p.tokenCount=u.data.tokenCount??0,p.linkUrl=u.data.linkUrl,p.linkTitle=u.data.linkTitle,p.linkFetchedAt=u.data.linkFetchedAt,p.frameColor=u.data.frameColor),h==="review"&&(p.isEvaluator=!0,p.autoRerun=!0,p.autoRerunRounds=u.data.autoRerunRounds,p.rolePrompt||(p.roleMode="inherit")),h==="fanout"&&(p.stepKind="fanout",p.fanoutRoles=u.data.fanoutRoles),{id:d,type:"thought",position:{...u.position},width:u.width,height:u.height,zIndex:u.zIndex,dragHandle:".drag-handle",data:p}}),r=new Set(e.filter(u=>(u.data.stepKind??"step")==="review").map(u=>n.get(u.id))),s=t.filter(u=>n.has(u.source)&&n.has(u.target)).map(u=>{const d=n.get(u.source),h=n.get(u.target);return r.has(h)?{id:`watch-${d}-${h}`,source:d,target:h,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.watch,strokeWidth:2,strokeDasharray:"4 4"},animated:!0,markerEnd:{type:"arrowclosed",color:it.watch,width:18,height:18},data:{isCrossLink:!0,isWatch:!0,followsTip:!0}}:{id:`edge-${d}-${h}`,source:d,target:h,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}),o=new Set(s.map(u=>u.target));for(const u of a)o.has(u.id)||(u.data.isRoot=!0);return{nodes:xr(a,s),edges:s}}const W7=1,Y2=1;function Ap(e){return e.replace(/[\\/:*?"<>|]/g,"_").trim()||"canvas"}function K0(e,t,n){const a=URL.createObjectURL(new Blob([t],{type:n}));Object.assign(document.createElement("a"),{href:a,download:e}).click(),URL.revokeObjectURL(a)}async function K2(e){await navigator.clipboard.writeText(e),We("success",Te("toast.copied"))}function qi(){const{projects:e,activeId:t}=sn.getState();return e.find(n=>n.id===t)?.name??"canvas"}async function hy(e){const{nodes:t}=se.getState(),{confirmIfSensitive:n}=await ft(async()=>{const{confirmIfSensitive:p}=await import("./sensitive-scan-
|
|
307
|
+
`+o,u.data.responses=[u.data.response])}}}}return{nodes:xr(t,n),edges:n}}function oG(e){const t=H7(e),n=[];if(t==="chatgpt")for(const a of e){const r=a.mapping??{},s=Object.values(r).filter(o=>["user","assistant"].includes(o.message?.author?.role??"")&&q7(o)).length;s!==0&&n.push({title:a.title||"Untitled",messageCount:s,source:"chatgpt",build:()=>sG(r)})}else if(t==="claude")for(const a of e){const r=a.chat_messages??[],s=r.filter(o=>$7(o)).length;s!==0&&n.push({title:a.name||"Untitled",messageCount:s,source:"claude",build:()=>iG(r)})}return n}function lG(e){return e.some(t=>t.data.stepKind==="human"&&!t.data.question||t.data.stepKind==="prompt"&&(t.data.isLoading||!t.data.response&&!t.data.generationFailed))}function cG(e){const t=e;return!!t&&typeof t=="object"&&t.kind==="thoughtdag-paradigm"&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}const uG=()=>({question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1});function dG(e,t){const n=new Map,a=e.map(u=>{const d=Tn();n.set(u.id,d);const h=u.data.stepKind??"prompt",m=(u.data.instruction?.trim()||u.data.question||"").trim(),p={...uG(),question:m,rolePrompt:u.data.rolePrompt||void 0,roleMode:u.data.rolePrompt?"reset":"inherit"};return h==="human"&&(p.stepKind="human",p.question="",p.instruction=u.data.instruction?.trim()||void 0,p.rolePrompt=void 0,p.roleMode="inherit"),h==="prompt"&&(p.stepKind="prompt",p.webSearch=u.data.webSearch,p.scholarSearch=u.data.scholarSearch,p.autoRerun=u.data.autoRerun,p.autoRerunRounds=u.data.autoRerunRounds),(h==="note"||h==="file"||h==="link"||h==="frame")&&(p.stepKind=h,p.question=u.data.question||"",p.attachments=u.data.attachments??[],p.tokenCount=u.data.tokenCount??0,p.linkUrl=u.data.linkUrl,p.linkTitle=u.data.linkTitle,p.linkFetchedAt=u.data.linkFetchedAt,p.frameColor=u.data.frameColor),h==="review"&&(p.isEvaluator=!0,p.autoRerun=!0,p.autoRerunRounds=u.data.autoRerunRounds,p.rolePrompt||(p.roleMode="inherit")),h==="fanout"&&(p.stepKind="fanout",p.fanoutRoles=u.data.fanoutRoles),{id:d,type:"thought",position:{...u.position},width:u.width,height:u.height,zIndex:u.zIndex,dragHandle:".drag-handle",data:p}}),r=new Set(e.filter(u=>(u.data.stepKind??"step")==="review").map(u=>n.get(u.id))),s=t.filter(u=>n.has(u.source)&&n.has(u.target)).map(u=>{const d=n.get(u.source),h=n.get(u.target);return r.has(h)?{id:`watch-${d}-${h}`,source:d,target:h,sourceHandle:"branch",targetHandle:"left",type:"smoothstep",style:{stroke:it.watch,strokeWidth:2,strokeDasharray:"4 4"},animated:!0,markerEnd:{type:"arrowclosed",color:it.watch,width:18,height:18},data:{isCrossLink:!0,isWatch:!0,followsTip:!0}}:{id:`edge-${d}-${h}`,source:d,target:h,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}}),o=new Set(s.map(u=>u.target));for(const u of a)o.has(u.id)||(u.data.isRoot=!0);return{nodes:xr(a,s),edges:s}}const W7=1,Y2=1;function Ap(e){return e.replace(/[\\/:*?"<>|]/g,"_").trim()||"canvas"}function K0(e,t,n){const a=URL.createObjectURL(new Blob([t],{type:n}));Object.assign(document.createElement("a"),{href:a,download:e}).click(),URL.revokeObjectURL(a)}async function K2(e){await navigator.clipboard.writeText(e),We("success",Te("toast.copied"))}function qi(){const{projects:e,activeId:t}=sn.getState();return e.find(n=>n.id===t)?.name??"canvas"}async function hy(e){const{nodes:t}=se.getState(),{confirmIfSensitive:n}=await ft(async()=>{const{confirmIfSensitive:p}=await import("./sensitive-scan-CUWgeb_A.js");return{confirmIfSensitive:p}},[]);if(!await n(t))return;localStorage.setItem("thoughtdag.lastBackupAt",String(Date.now()));const{nodes:a,edges:r,events:s}=se.getState(),o=await k2(a),{projects:u,activeId:d}=sn.getState(),h=qi(),m=JSON.stringify({version:W7,name:h,projectId:d,exportedAt:new Date().toISOString(),instantiatedFrom:u.find(p=>p.id===d)?.instantiatedFrom,...e?.sharedReadonly?{sharedReadonly:!0}:{},nodes:Xo(o),edges:r,events:s});K0(`${Ap(h)}.thoughtdag.json`,m,"application/json"),We("success",ye(Te("toast.exported"),{name:h}))}function hG(){const{nodes:e,edges:t}=se.getState(),n=qi(),a=JSON.stringify({kind:"thoughtdag-paradigm",version:1,name:n,nodes:Xo(e),edges:t});K0(`${Ap(n)}.paradigm.json`,a,"application/json"),We("success",ye(Te("toast.exported"),{name:n}))}async function fG(e){const t=await e.text();let n;try{n=JSON.parse(t)}catch{const{anyRunnerSessionConversation:r}=await ft(async()=>{const{anyRunnerSessionConversation:o}=await import("./index-BRdlgS3c.js");return{anyRunnerSessionConversation:o}},[]),s=await r(t);return s?{kind:"chat",conversations:[s]}:(We("error",Te("toast.importFailedJson")),{kind:"error"})}if(cG(n)){const r=crypto.randomUUID(),s=await wp(await V7(n.nodes));return await jr(ws(r),JSON.stringify({state:{nodes:s,edges:n.edges},version:Y2})),await vu(r,n.name||"Paradigm","paradigm"),We("success",ye(Te("toast.imported"),{name:n.name,n:n.nodes.length})),{kind:"own",ok:!0}}if(n?.format==="thoughtdag-manifest")return We("error",Te("toast.importManifest"),9e3),{kind:"error"};const a=H7(n);if(a==="chatgpt"||a==="claude"){const r=oG(n);return r.length===0?(We("error",Te("toast.importNoConversations")),{kind:"error"}):{kind:"chat",conversations:r}}return{kind:"own",ok:await gG(e,n)}}function mG(e){return e.every(t=>{const n=t;return!!n&&typeof n.id=="string"&&!!n.position&&typeof n.position.x=="number"&&typeof n.position.y=="number"&&!!n.data&&typeof n.data=="object"})}async function pG(e){let t=null,n=0;for(const a of e){const{nodes:r,edges:s}=a.build();if(r.length===0)continue;if(t===null){const{useUiStore:u}=await ft(async()=>{const{useUiStore:d}=await Promise.resolve().then(()=>cu);return{useUiStore:d}},void 0);u.getState().setArrivalFocusNodeId(r[r.length-1].id)}const o=crypto.randomUUID();await jr(ws(o),JSON.stringify({state:{nodes:Xo(r),edges:s},version:Y2})),await vu(o,a.title.slice(0,60)),t??=o,n+=r.length}t&&We("success",ye(Te("toast.importedChats"),{n:e.length,m:n}))}async function V7(e){const t=await dr();if(!t||t.models.length===0)return e;const n=new Set,a=new Set,r=e.map(s=>{const o=s.data?.model;if(!o)return s;const u=I7(o,t.models);return u===o?s:u?(n.add(`${o} → ${u}`),{...s,data:{...s.data,model:u}}):(a.add(o),s)});return n.size&&We("info",ye(Te("import.modelsRemapped"),{list:[...n].join(",")}),9e3),a.size&&We("info",ye(Te("import.modelsMissing"),{list:[...a].join(",")}),1e4),r}async function gG(e,t){let n;try{n=t??JSON.parse(await e.text())}catch{return We("error",Te("toast.importFailedJson")),!1}if(!Array.isArray(n.nodes)||!Array.isArray(n.edges))return We("error",Te("toast.importFailedMissing")),!1;if(n.nodes.length>0&&!mG(n.nodes))return We("error",Te("toast.importFailedShape"),9e3),!1;if(n.sharedReadonly&&!await ri({title:Te("import.readonlyTitle"),message:Te("import.readonlyConfirm"),confirmLabel:Te("common.confirm")}))return!1;if(n.sourceSession?.sessionId){const{useProjects:o,switchProject:u}=await ft(async()=>{const{useProjects:h,switchProject:m}=await Promise.resolve().then(()=>Sa);return{useProjects:h,switchProject:m}},void 0),d=o.getState().projects.find(h=>h.sourceSession?.sessionId===n.sourceSession.sessionId);if(d)return await u(d.id),We("info",ye(Te("toast.importAlreadySubscribed"),{name:d.name}),9e3),!0}const a=crypto.randomUUID(),r=await wp(await V7(n.nodes));await jr(ws(a),JSON.stringify({state:{nodes:Xo(r),edges:n.edges,...Array.isArray(n.events)?{events:n.events}:{}},version:Y2}));const s=n.name?.trim()||e.name.replace(/\.thoughtdag\.json$|\.json$/i,"")||"Imported canvas";return await vu(a,s,"chat",{instantiatedFrom:n.instantiatedFrom,sourceSession:n.sourceSession}),We("success",ye(Te("toast.imported"),{name:s,n:n.nodes.length})),!0}function xG(){const{events:e}=se.getState();if(e.length===0)return;const t=r=>`"${r.replace(/"/g,'""')}"`,a=["t,op,id,detail",...e.map(r=>[r.t,r.op,r.id??"",r.d?t(JSON.stringify(r.d)):""].join(","))].join(`
|
|
308
308
|
`);K0(`${Ap(qi())}.events.csv`,a,"text/csv"),We("success",ye(Te("toast.exported"),{name:qi()}))}function bG(e){const t=[`## Q: ${e.data.question}`,""],n=e.data.attachments||[];return n.length>0&&t.push(`> ${Te("export.attachmentsLabel")} ${n.map(a=>a.name).join(", ")}`,""),e.data.branchContext&&t.push(`> Exploring from: "${e.data.branchContext.slice(0,120)}"`,""),t.push(e.data.response||"_(no response)_",""),t.join(`
|
|
309
309
|
`)}function G7(e,t){const n=e.reduce((a,r)=>a+Nn(r.data.question+r.data.response),0);return[`# ${qi()}`,"",`> ${t} · exported ${new Date().toISOString().slice(0,10)} · ${e.length} nodes · ~${n} tok`,"",e.map(bG).join(`
|
|
310
310
|
---
|
|
311
311
|
|
|
312
312
|
`)].join(`
|
|
313
|
-
`)}function KE(e){const{nodes:t,edges:n}=se.getState(),a=Bq(e,t,n);return G7(a,Te("export.contextChain"))}function yG(e){const{nodes:t}=se.getState(),n=e.map(a=>t.find(r=>r.id===a)).filter(a=>!!a).sort((a,r)=>a.position.y-r.position.y||a.position.x-r.position.x);return G7(n,Te("export.selectedNodes"))}function X2(e){K0(`${Ap(qi())}.md`,e,"text/markdown")}let XE=null,QE=null,ZE=new Map;const vG="[]";function Y7(e,t,n){if(XE!==t||QE!==n){const a=new Map(t.map(s=>[s.id,s])),r=new Map;for(const s of n){const o=a.get(s.target);if(!o?.data.branchContext||o.data.anchor)continue;const u=r.get(s.source)??[];u.push({text:o.data.branchContext.replace(/^\(p\.\s?\d+\)\s*/,""),nodeId:o.id,question:o.data.question}),r.set(s.source,u)}ZE=new Map([...r].map(([s,o])=>[s,JSON.stringify(o)])),XE=t,QE=n}return ZE.get(e)??vG}function wG(){const e=St(),t=oe(S=>S.recallEnabled),n=oe(S=>S.recallReach),a=oe(S=>S.recallScale),r=oe(S=>S.recallOverride),s=oe(S=>S.setRecallOverride),o=oe(S=>S.setRecallEnabled),u=oe(S=>S.setRecallReach),d=oe(S=>S.setRecallScale),h=oe(S=>S.judge),m=yu(h),p=r?.enabled??t,x=r?.reach??n,b=r?.scale??a,[y,w]=D.useState(null),E=D.useRef(null),v=D.useRef(null);D.useEffect(()=>{if(!y)return;const S=V=>{const P=V.target;!E.current?.contains(P)&&!v.current?.contains(P)&&w(null)},z=V=>{V.key==="Escape"&&w(null)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",z)}},[y]);const A=S=>e(S==="light"?"recall.reachLight":S==="deep"?"recall.reachDeep":"recall.reachFullShort"),T=S=>e(S==="lean"?"recall.scaleLean":S==="standard"?"recall.scaleStandard":"recall.scaleGenerous"),C=async S=>{if(S==="full"){const z=await Promise.resolve().then(()=>In()?.turns({limit:0})).then(L=>L?.total??0).catch(()=>0),V=KW(z);if(!await ri({title:e("recall.reachFullTitle"),message:ye(e("recall.reachFullMsg"),{n:z.toLocaleString(),s:String(Math.round(V.seconds)),c:V.dollars.toFixed(2)}),confirmLabel:e("recall.reachFullOk")}))return}s({reach:S})},I=!!r&&(r.enabled!==void 0&&r.enabled!==t||r.reach!==void 0&&r.reach!==n||r.scale!==void 0&&r.scale!==a),O=()=>{o(p),u(x),d(b),s(null),We("success",e("recall.menuDefaultDone"),3e3),w(null)},_=(S,z,V,P,L,Y)=>l.jsx("button",{type:"button","aria-disabled":V||void 0,onClick:V?void 0:L,title:Y,className:`px-2 py-0.5 rounded-md text-2xs whitespace-nowrap transition-colors ${z?"bg-accent text-white":V?"text-ink-faint opacity-50 cursor-default":"text-ink-muted hover:bg-wash"}`,"data-recall-menu-option":S,children:P},S);return l.jsxs("div",{ref:E,className:"relative shrink-0",children:[l.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation();const z=S.currentTarget.getBoundingClientRect();w(V=>V?null:{left:Math.max(8,Math.min(z.right-296,window.innerWidth-304)),bottom:window.innerHeight-z.top+8})},"aria-expanded":!!y,title:e(p?"toolbar.recall":"toolbar.recallOff"),className:`h-8 px-2.5 rounded-full flex items-center gap-1.5 text-2xs font-medium transition-colors ${p?"text-accent bg-accent/15 ring-1 ring-accent/40 hover:bg-accent/25":"text-ink-muted opacity-60 hover:opacity-100 hover:bg-line"}`,"data-recall-toggle":!0,"data-recall-on":p?"on":"off","data-recall-reach":p?x:void 0,children:[p&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent","aria-hidden":!0}),l.jsx("span",{children:p?ye(e("recall.chipOn"),{r:A(x)}):e("recall.chip")})]}),y&&ur.createPortal(l.jsxs("div",{ref:v,style:{position:"fixed",left:y.left,bottom:y.bottom},className:"w-[296px] rounded-xl border border-line bg-card shadow-lg p-3 z-[90] text-xs space-y-2.5","data-recall-menu":!0,onClick:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:e("recall.menuOn")}),l.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>s({enabled:!p}),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${p?"bg-accent":"bg-line-strong"}`,"data-recall-menu-switch":!0,children:l.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${p?"translate-x-4":""}`})})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-ink-faint whitespace-nowrap",title:e("recall.reachHint"),children:e("recall.menuReach")}),l.jsx("div",{className:"flex gap-0.5","data-recall-menu-reach":!0,children:["light","deep","full"].map(S=>_(S,x===S,!p||!m&&S!=="light",A(S),()=>{C(S)},p&&!m&&S!=="light"?e("recall.menuNeedsJudge"):void 0))})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-ink-faint whitespace-nowrap",title:e("recall.scaleHint"),children:e("recall.menuScale")}),l.jsx("div",{className:"flex gap-0.5","data-recall-menu-scale":!0,children:["lean","standard","generous"].map(S=>_(S,b===S,!p,`${T(S)} ${i7[S].budget/1e3}k`,()=>s({scale:S})))})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-line/70",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:e("recall.menuOnce")}),l.jsx("button",{type:"button",onClick:O,disabled:!I,className:"text-2xs text-accent hover:underline disabled:opacity-40 disabled:no-underline","data-recall-menu-default":!0,children:e("recall.menuDefault")})]})]}),document.body)]})}function T0({size:e=16}){const t=oe(m=>m.webSearchEnabled),n=oe(m=>m.setWebSearchEnabled),a=oe(m=>m.scholarSearchEnabled),r=oe(m=>m.setScholarSearchEnabled),s=kp(),o=St(),u=Yl()?.capabilities?.webSearch??!0;oe(m=>m.selectedModel);const d=Fq(),h=m=>d?"transition-colors shrink-0 rounded-full w-8 h-8 flex items-center justify-center text-ink-faint opacity-30 cursor-not-allowed":`transition-colors shrink-0 rounded-full w-8 h-8 flex items-center justify-center ${m?"text-accent bg-accent/15 ring-1 ring-accent/40 hover:bg-accent/25":"text-ink-muted opacity-50 hover:opacity-90 hover:bg-line"}`;return l.jsxs(l.Fragment,{children:[u&&l.jsx("button",{type:"button",onClick:()=>{d||n(!t)},disabled:d,title:o(d?"toolbar.searchUnavailableLane":t?"toolbar.webSearch":"toolbar.webSearchOff"),className:h(t),"data-web-toggle":!0,children:l.jsx(Am,{size:e,strokeWidth:1.75})}),l.jsx("button",{type:"button",onClick:()=>{d||r(!a)},disabled:d,title:o(d?"toolbar.searchUnavailableLane":a?"toolbar.scholarSearch":"toolbar.scholarSearchOff"),className:h(a),"data-scholar-toggle":!0,children:l.jsx(HA,{size:e,strokeWidth:1.75})}),s&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-4 bg-line mx-0.5 shrink-0","aria-hidden":!0}),l.jsx(wG,{})]})]})}function JE(e){const t=[],n=String(e||"");let a=n.indexOf(","),r=0,s=!1;for(;!s;){a===-1&&(a=n.length,s=!0);const o=n.slice(r,a).trim();(o||!s)&&t.push(o),r=a+1,a=n.indexOf(",",r)}return t}function K7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const kG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,SG={};function e6(e,t){return(SG.jsx?EG:kG).test(e)}const TG=/[ \t\n\f\r]/g;function NG(e){return typeof e=="object"?e.type==="text"?t6(e.value):!1:t6(e)}function t6(e){return e.replace(TG,"")===""}class X0{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}X0.prototype.normal={};X0.prototype.property={};X0.prototype.space=void 0;function X7(e,t){const n={},a={};for(const r of e)Object.assign(n,r.property),Object.assign(a,r.normal);return new X0(n,a,t)}function N0(e){return e.toLowerCase()}class zr{constructor(t,n){this.attribute=n,this.property=t}}zr.prototype.attribute="";zr.prototype.booleanish=!1;zr.prototype.boolean=!1;zr.prototype.commaOrSpaceSeparated=!1;zr.prototype.commaSeparated=!1;zr.prototype.defined=!1;zr.prototype.mustUseProperty=!1;zr.prototype.number=!1;zr.prototype.overloadedBoolean=!1;zr.prototype.property="";zr.prototype.spaceSeparated=!1;zr.prototype.space=void 0;let AG=0;const dn=Kl(),Oa=Kl(),fy=Kl(),ht=Kl(),ea=Kl(),Zc=Kl(),Yr=Kl();function Kl(){return 2**++AG}const my=Object.freeze(Object.defineProperty({__proto__:null,boolean:dn,booleanish:Oa,commaOrSpaceSeparated:Yr,commaSeparated:Zc,number:ht,overloadedBoolean:fy,spaceSeparated:ea},Symbol.toStringTag,{value:"Module"})),Mx=Object.keys(my);class Q2 extends zr{constructor(t,n,a,r){let s=-1;if(super(t,n),n6(this,"space",r),typeof a=="number")for(;++s<Mx.length;){const o=Mx[s];n6(this,Mx[s],(a&my[o])===my[o])}}}Q2.prototype.defined=!0;function n6(e,t,n){n&&(e[t]=n)}function wu(e){const t={},n={};for(const[a,r]of Object.entries(e.properties)){const s=new Q2(a,e.transform(e.attributes||{},a),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(s.mustUseProperty=!0),t[a]=s,n[N0(a)]=a,n[N0(s.attribute)]=a}return new X0(t,n,e.space)}const Q7=wu({properties:{ariaActiveDescendant:null,ariaAtomic:Oa,ariaAutoComplete:null,ariaBusy:Oa,ariaChecked:Oa,ariaColCount:ht,ariaColIndex:ht,ariaColSpan:ht,ariaControls:ea,ariaCurrent:null,ariaDescribedBy:ea,ariaDetails:null,ariaDisabled:Oa,ariaDropEffect:ea,ariaErrorMessage:null,ariaExpanded:Oa,ariaFlowTo:ea,ariaGrabbed:Oa,ariaHasPopup:null,ariaHidden:Oa,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ea,ariaLevel:ht,ariaLive:null,ariaModal:Oa,ariaMultiLine:Oa,ariaMultiSelectable:Oa,ariaOrientation:null,ariaOwns:ea,ariaPlaceholder:null,ariaPosInSet:ht,ariaPressed:Oa,ariaReadOnly:Oa,ariaRelevant:null,ariaRequired:Oa,ariaRoleDescription:ea,ariaRowCount:ht,ariaRowIndex:ht,ariaRowSpan:ht,ariaSelected:Oa,ariaSetSize:ht,ariaSort:null,ariaValueMax:ht,ariaValueMin:ht,ariaValueNow:ht,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Z7(e,t){return t in e?e[t]:t}function J7(e,t){return Z7(e,t.toLowerCase())}const CG=wu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Zc,acceptCharset:ea,accessKey:ea,action:null,allow:null,allowFullScreen:dn,allowPaymentRequest:dn,allowUserMedia:dn,alt:null,as:null,async:dn,autoCapitalize:null,autoComplete:ea,autoFocus:dn,autoPlay:dn,blocking:ea,capture:null,charSet:null,checked:dn,cite:null,className:ea,cols:ht,colSpan:null,content:null,contentEditable:Oa,controls:dn,controlsList:ea,coords:ht|Zc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dn,defer:dn,dir:null,dirName:null,disabled:dn,download:fy,draggable:Oa,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dn,formTarget:null,headers:ea,height:ht,hidden:fy,high:ht,href:null,hrefLang:null,htmlFor:ea,httpEquiv:ea,id:null,imageSizes:null,imageSrcSet:null,inert:dn,inputMode:null,integrity:null,is:null,isMap:dn,itemId:null,itemProp:ea,itemRef:ea,itemScope:dn,itemType:ea,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dn,low:ht,manifest:null,max:null,maxLength:ht,media:null,method:null,min:null,minLength:ht,multiple:dn,muted:dn,name:null,nonce:null,noModule:dn,noValidate:dn,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:dn,optimum:ht,pattern:null,ping:ea,placeholder:null,playsInline:dn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dn,referrerPolicy:null,rel:ea,required:dn,reversed:dn,rows:ht,rowSpan:ht,sandbox:ea,scope:null,scoped:dn,seamless:dn,selected:dn,shadowRootClonable:dn,shadowRootDelegatesFocus:dn,shadowRootMode:null,shape:null,size:ht,sizes:null,slot:null,span:ht,spellCheck:Oa,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ht,step:null,style:null,tabIndex:ht,target:null,title:null,translate:null,type:null,typeMustMatch:dn,useMap:null,value:Oa,width:ht,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ea,axis:null,background:null,bgColor:null,border:ht,borderColor:null,bottomMargin:ht,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dn,declare:dn,event:null,face:null,frame:null,frameBorder:null,hSpace:ht,leftMargin:ht,link:null,longDesc:null,lowSrc:null,marginHeight:ht,marginWidth:ht,noResize:dn,noHref:dn,noShade:dn,noWrap:dn,object:null,profile:null,prompt:null,rev:null,rightMargin:ht,rules:null,scheme:null,scrolling:Oa,standby:null,summary:null,text:null,topMargin:ht,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ht,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dn,disableRemotePlayback:dn,prefix:null,property:null,results:ht,security:null,unselectable:null},space:"html",transform:J7}),_G=wu({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:Yr,accentHeight:ht,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ht,amplitude:ht,arabicForm:null,ascent:ht,attributeName:null,attributeType:null,azimuth:ht,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ht,by:null,calcMode:null,capHeight:ht,className:ea,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:ht,diffuseConstant:ht,direction:null,display:null,dur:null,divisor:ht,dominantBaseline:null,download:dn,dx:null,dy:null,edgeMode:null,editable:null,elevation:ht,enableBackground:null,end:null,event:null,exponent:ht,externalResourcesRequired:null,fill:null,fillOpacity:ht,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:Zc,g2:Zc,glyphName:Zc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ht,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ht,horizOriginX:ht,horizOriginY:ht,id:null,ideographic:ht,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ht,k:ht,k1:ht,k2:ht,k3:ht,k4:ht,kernelMatrix:Yr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ht,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:ht,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:ht,overlineThickness:ht,paintOrder:null,panose1:null,path:null,pathLength:ht,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ea,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ht,pointsAtY:ht,pointsAtZ:ht,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yr,rev:Yr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yr,requiredFeatures:Yr,requiredFonts:Yr,requiredFormats:Yr,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:ht,specularExponent:ht,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ht,strikethroughThickness:ht,string:null,stroke:null,strokeDashArray:Yr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ht,strokeOpacity:ht,strokeWidth:null,style:null,surfaceScale:ht,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yr,tabIndex:ht,tableValues:null,target:null,targetX:ht,targetY:ht,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ht,underlineThickness:ht,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ht,values:null,vAlphabetic:ht,vMathematical:ht,vectorEffect:null,vHanging:ht,vIdeographic:ht,version:null,vertAdvY:ht,vertOriginX:ht,vertOriginY:ht,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ht,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Z7}),e9=wu({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()}}),t9=wu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:J7}),n9=wu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),MG={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"},IG=/[A-Z]/g,a6=/-[a-z]/g,OG=/^data[-\w.:]+$/i;function Cp(e,t){const n=N0(t);let a=t,r=zr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OG.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(a6,RG);a="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!a6.test(s)){let o=s.replace(IG,DG);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}r=Q2}return new r(a,t)}function DG(e){return"-"+e.toLowerCase()}function RG(e){return e.charAt(1).toUpperCase()}const Q0=X7([Q7,CG,e9,t9,n9],"html"),tl=X7([Q7,_G,e9,t9,n9],"svg");function r6(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function a9(e){return e.join(" ").trim()}var Ic={},Ix,s6;function jG(){if(s6)return Ix;s6=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,r=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
313
|
+
`)}function KE(e){const{nodes:t,edges:n}=se.getState(),a=Bq(e,t,n);return G7(a,Te("export.contextChain"))}function yG(e){const{nodes:t}=se.getState(),n=e.map(a=>t.find(r=>r.id===a)).filter(a=>!!a).sort((a,r)=>a.position.y-r.position.y||a.position.x-r.position.x);return G7(n,Te("export.selectedNodes"))}function X2(e){K0(`${Ap(qi())}.md`,e,"text/markdown")}let XE=null,QE=null,ZE=new Map;const vG="[]";function Y7(e,t,n){if(XE!==t||QE!==n){const a=new Map(t.map(s=>[s.id,s])),r=new Map;for(const s of n){const o=a.get(s.target);if(!o?.data.branchContext||o.data.anchor)continue;const u=r.get(s.source)??[];u.push({text:o.data.branchContext.replace(/^\(p\.\s?\d+\)\s*/,""),nodeId:o.id,question:o.data.question}),r.set(s.source,u)}ZE=new Map([...r].map(([s,o])=>[s,JSON.stringify(o)])),XE=t,QE=n}return ZE.get(e)??vG}function wG(){const e=St(),t=oe(S=>S.recallEnabled),n=oe(S=>S.recallReach),a=oe(S=>S.recallScale),r=oe(S=>S.recallOverride),s=oe(S=>S.setRecallOverride),o=oe(S=>S.setRecallEnabled),u=oe(S=>S.setRecallReach),d=oe(S=>S.setRecallScale),h=oe(S=>S.judge),m=yu(h),p=r?.enabled??t,x=r?.reach??n,b=r?.scale??a,[y,w]=D.useState(null),E=D.useRef(null),v=D.useRef(null);D.useEffect(()=>{if(!y)return;const S=V=>{const P=V.target;!E.current?.contains(P)&&!v.current?.contains(P)&&w(null)},z=V=>{V.key==="Escape"&&w(null)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",z)}},[y]);const A=S=>e(S==="light"?"recall.reachLight":S==="deep"?"recall.reachDeep":"recall.reachFullShort"),T=S=>e(S==="lean"?"recall.scaleLean":S==="standard"?"recall.scaleStandard":"recall.scaleGenerous"),C=async S=>{if(S==="full"){const z=await Promise.resolve().then(()=>In()?.turns({limit:0})).then(L=>L?.total??0).catch(()=>0);if(!z){We("info",e("recall.reachFullEmpty"),6e3);return}const V=KW(z);if(!await ri({title:e("recall.reachFullTitle"),message:ye(e("recall.reachFullMsg"),{n:z.toLocaleString(),s:String(Math.round(V.seconds)),c:V.dollars.toFixed(2)}),confirmLabel:e("recall.reachFullOk")}))return}s({reach:S})},I=!!r&&(r.enabled!==void 0&&r.enabled!==t||r.reach!==void 0&&r.reach!==n||r.scale!==void 0&&r.scale!==a),O=()=>{o(p),u(x),d(b),s(null),We("success",e("recall.menuDefaultDone"),3e3),w(null)},_=(S,z,V,P,L,Y)=>l.jsx("button",{type:"button","aria-disabled":V||void 0,onClick:V?void 0:L,title:Y,className:`px-2 py-0.5 rounded-md text-2xs whitespace-nowrap transition-colors ${z?"bg-accent text-white":V?"text-ink-faint opacity-50 cursor-default":"text-ink-muted hover:bg-wash"}`,"data-recall-menu-option":S,children:P},S);return l.jsxs("div",{ref:E,className:"relative shrink-0",children:[l.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation();const z=S.currentTarget.getBoundingClientRect();w(V=>V?null:{left:Math.max(8,Math.min(z.right-296,window.innerWidth-304)),bottom:window.innerHeight-z.top+8})},"aria-expanded":!!y,title:e(p?"toolbar.recall":"toolbar.recallOff"),className:`h-8 px-2.5 rounded-full flex items-center gap-1.5 text-2xs font-medium transition-colors ${p?"text-accent bg-accent/15 ring-1 ring-accent/40 hover:bg-accent/25":"text-ink-muted opacity-60 hover:opacity-100 hover:bg-line"}`,"data-recall-toggle":!0,"data-recall-on":p?"on":"off","data-recall-reach":p?x:void 0,children:[p&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent","aria-hidden":!0}),l.jsx("span",{children:p?ye(e("recall.chipOn"),{r:A(x)}):e("recall.chip")})]}),y&&ur.createPortal(l.jsxs("div",{ref:v,style:{position:"fixed",left:y.left,bottom:y.bottom},className:"w-[296px] rounded-xl border border-line bg-card shadow-lg p-3 z-[90] text-xs space-y-2.5","data-recall-menu":!0,onClick:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:e("recall.menuOn")}),l.jsx("button",{type:"button",role:"switch","aria-checked":p,onClick:()=>s({enabled:!p}),className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${p?"bg-accent":"bg-line-strong"}`,"data-recall-menu-switch":!0,children:l.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${p?"translate-x-4":""}`})})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-ink-faint whitespace-nowrap",title:e("recall.reachHint"),children:e("recall.menuReach")}),l.jsx("div",{className:"flex gap-0.5","data-recall-menu-reach":!0,children:["light","deep","full"].map(S=>_(S,x===S,!p||!m&&S!=="light",A(S),()=>{C(S)},p&&!m&&S!=="light"?e("recall.menuNeedsJudge"):void 0))})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("span",{className:"text-ink-faint whitespace-nowrap",title:e("recall.scaleHint"),children:e("recall.menuScale")}),l.jsx("div",{className:"flex gap-0.5","data-recall-menu-scale":!0,children:["lean","standard","generous"].map(S=>_(S,b===S,!p,`${T(S)} ${i7[S].budget/1e3}k`,()=>s({scale:S})))})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-line/70",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:e("recall.menuOnce")}),l.jsx("button",{type:"button",onClick:O,disabled:!I,className:"text-2xs text-accent hover:underline disabled:opacity-40 disabled:no-underline","data-recall-menu-default":!0,children:e("recall.menuDefault")})]})]}),document.body)]})}function T0({size:e=16}){const t=oe(m=>m.webSearchEnabled),n=oe(m=>m.setWebSearchEnabled),a=oe(m=>m.scholarSearchEnabled),r=oe(m=>m.setScholarSearchEnabled),s=kp(),o=St(),u=Yl()?.capabilities?.webSearch??!0;oe(m=>m.selectedModel);const d=Fq(),h=m=>d?"transition-colors shrink-0 rounded-full w-8 h-8 flex items-center justify-center text-ink-faint opacity-30 cursor-not-allowed":`transition-colors shrink-0 rounded-full w-8 h-8 flex items-center justify-center ${m?"text-accent bg-accent/15 ring-1 ring-accent/40 hover:bg-accent/25":"text-ink-muted opacity-50 hover:opacity-90 hover:bg-line"}`;return l.jsxs(l.Fragment,{children:[u&&l.jsx("button",{type:"button",onClick:()=>{d||n(!t)},disabled:d,title:o(d?"toolbar.searchUnavailableLane":t?"toolbar.webSearch":"toolbar.webSearchOff"),className:h(t),"data-web-toggle":!0,children:l.jsx(Am,{size:e,strokeWidth:1.75})}),l.jsx("button",{type:"button",onClick:()=>{d||r(!a)},disabled:d,title:o(d?"toolbar.searchUnavailableLane":a?"toolbar.scholarSearch":"toolbar.scholarSearchOff"),className:h(a),"data-scholar-toggle":!0,children:l.jsx(HA,{size:e,strokeWidth:1.75})}),s&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-4 bg-line mx-0.5 shrink-0","aria-hidden":!0}),l.jsx(wG,{})]})]})}function JE(e){const t=[],n=String(e||"");let a=n.indexOf(","),r=0,s=!1;for(;!s;){a===-1&&(a=n.length,s=!0);const o=n.slice(r,a).trim();(o||!s)&&t.push(o),r=a+1,a=n.indexOf(",",r)}return t}function K7(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const kG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,SG={};function e6(e,t){return(SG.jsx?EG:kG).test(e)}const TG=/[ \t\n\f\r]/g;function NG(e){return typeof e=="object"?e.type==="text"?t6(e.value):!1:t6(e)}function t6(e){return e.replace(TG,"")===""}class X0{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}X0.prototype.normal={};X0.prototype.property={};X0.prototype.space=void 0;function X7(e,t){const n={},a={};for(const r of e)Object.assign(n,r.property),Object.assign(a,r.normal);return new X0(n,a,t)}function N0(e){return e.toLowerCase()}class zr{constructor(t,n){this.attribute=n,this.property=t}}zr.prototype.attribute="";zr.prototype.booleanish=!1;zr.prototype.boolean=!1;zr.prototype.commaOrSpaceSeparated=!1;zr.prototype.commaSeparated=!1;zr.prototype.defined=!1;zr.prototype.mustUseProperty=!1;zr.prototype.number=!1;zr.prototype.overloadedBoolean=!1;zr.prototype.property="";zr.prototype.spaceSeparated=!1;zr.prototype.space=void 0;let AG=0;const dn=Kl(),Oa=Kl(),fy=Kl(),ht=Kl(),ea=Kl(),Zc=Kl(),Yr=Kl();function Kl(){return 2**++AG}const my=Object.freeze(Object.defineProperty({__proto__:null,boolean:dn,booleanish:Oa,commaOrSpaceSeparated:Yr,commaSeparated:Zc,number:ht,overloadedBoolean:fy,spaceSeparated:ea},Symbol.toStringTag,{value:"Module"})),Mx=Object.keys(my);class Q2 extends zr{constructor(t,n,a,r){let s=-1;if(super(t,n),n6(this,"space",r),typeof a=="number")for(;++s<Mx.length;){const o=Mx[s];n6(this,Mx[s],(a&my[o])===my[o])}}}Q2.prototype.defined=!0;function n6(e,t,n){n&&(e[t]=n)}function wu(e){const t={},n={};for(const[a,r]of Object.entries(e.properties)){const s=new Q2(a,e.transform(e.attributes||{},a),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(s.mustUseProperty=!0),t[a]=s,n[N0(a)]=a,n[N0(s.attribute)]=a}return new X0(t,n,e.space)}const Q7=wu({properties:{ariaActiveDescendant:null,ariaAtomic:Oa,ariaAutoComplete:null,ariaBusy:Oa,ariaChecked:Oa,ariaColCount:ht,ariaColIndex:ht,ariaColSpan:ht,ariaControls:ea,ariaCurrent:null,ariaDescribedBy:ea,ariaDetails:null,ariaDisabled:Oa,ariaDropEffect:ea,ariaErrorMessage:null,ariaExpanded:Oa,ariaFlowTo:ea,ariaGrabbed:Oa,ariaHasPopup:null,ariaHidden:Oa,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ea,ariaLevel:ht,ariaLive:null,ariaModal:Oa,ariaMultiLine:Oa,ariaMultiSelectable:Oa,ariaOrientation:null,ariaOwns:ea,ariaPlaceholder:null,ariaPosInSet:ht,ariaPressed:Oa,ariaReadOnly:Oa,ariaRelevant:null,ariaRequired:Oa,ariaRoleDescription:ea,ariaRowCount:ht,ariaRowIndex:ht,ariaRowSpan:ht,ariaSelected:Oa,ariaSetSize:ht,ariaSort:null,ariaValueMax:ht,ariaValueMin:ht,ariaValueNow:ht,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Z7(e,t){return t in e?e[t]:t}function J7(e,t){return Z7(e,t.toLowerCase())}const CG=wu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Zc,acceptCharset:ea,accessKey:ea,action:null,allow:null,allowFullScreen:dn,allowPaymentRequest:dn,allowUserMedia:dn,alt:null,as:null,async:dn,autoCapitalize:null,autoComplete:ea,autoFocus:dn,autoPlay:dn,blocking:ea,capture:null,charSet:null,checked:dn,cite:null,className:ea,cols:ht,colSpan:null,content:null,contentEditable:Oa,controls:dn,controlsList:ea,coords:ht|Zc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dn,defer:dn,dir:null,dirName:null,disabled:dn,download:fy,draggable:Oa,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dn,formTarget:null,headers:ea,height:ht,hidden:fy,high:ht,href:null,hrefLang:null,htmlFor:ea,httpEquiv:ea,id:null,imageSizes:null,imageSrcSet:null,inert:dn,inputMode:null,integrity:null,is:null,isMap:dn,itemId:null,itemProp:ea,itemRef:ea,itemScope:dn,itemType:ea,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dn,low:ht,manifest:null,max:null,maxLength:ht,media:null,method:null,min:null,minLength:ht,multiple:dn,muted:dn,name:null,nonce:null,noModule:dn,noValidate:dn,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:dn,optimum:ht,pattern:null,ping:ea,placeholder:null,playsInline:dn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dn,referrerPolicy:null,rel:ea,required:dn,reversed:dn,rows:ht,rowSpan:ht,sandbox:ea,scope:null,scoped:dn,seamless:dn,selected:dn,shadowRootClonable:dn,shadowRootDelegatesFocus:dn,shadowRootMode:null,shape:null,size:ht,sizes:null,slot:null,span:ht,spellCheck:Oa,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ht,step:null,style:null,tabIndex:ht,target:null,title:null,translate:null,type:null,typeMustMatch:dn,useMap:null,value:Oa,width:ht,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ea,axis:null,background:null,bgColor:null,border:ht,borderColor:null,bottomMargin:ht,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dn,declare:dn,event:null,face:null,frame:null,frameBorder:null,hSpace:ht,leftMargin:ht,link:null,longDesc:null,lowSrc:null,marginHeight:ht,marginWidth:ht,noResize:dn,noHref:dn,noShade:dn,noWrap:dn,object:null,profile:null,prompt:null,rev:null,rightMargin:ht,rules:null,scheme:null,scrolling:Oa,standby:null,summary:null,text:null,topMargin:ht,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ht,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dn,disableRemotePlayback:dn,prefix:null,property:null,results:ht,security:null,unselectable:null},space:"html",transform:J7}),_G=wu({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:Yr,accentHeight:ht,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ht,amplitude:ht,arabicForm:null,ascent:ht,attributeName:null,attributeType:null,azimuth:ht,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ht,by:null,calcMode:null,capHeight:ht,className:ea,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:ht,diffuseConstant:ht,direction:null,display:null,dur:null,divisor:ht,dominantBaseline:null,download:dn,dx:null,dy:null,edgeMode:null,editable:null,elevation:ht,enableBackground:null,end:null,event:null,exponent:ht,externalResourcesRequired:null,fill:null,fillOpacity:ht,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:Zc,g2:Zc,glyphName:Zc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ht,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ht,horizOriginX:ht,horizOriginY:ht,id:null,ideographic:ht,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ht,k:ht,k1:ht,k2:ht,k3:ht,k4:ht,kernelMatrix:Yr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ht,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:ht,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:ht,overlineThickness:ht,paintOrder:null,panose1:null,path:null,pathLength:ht,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ea,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ht,pointsAtY:ht,pointsAtZ:ht,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Yr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Yr,rev:Yr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Yr,requiredFeatures:Yr,requiredFonts:Yr,requiredFormats:Yr,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:ht,specularExponent:ht,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ht,strikethroughThickness:ht,string:null,stroke:null,strokeDashArray:Yr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ht,strokeOpacity:ht,strokeWidth:null,style:null,surfaceScale:ht,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Yr,tabIndex:ht,tableValues:null,target:null,targetX:ht,targetY:ht,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Yr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ht,underlineThickness:ht,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ht,values:null,vAlphabetic:ht,vMathematical:ht,vectorEffect:null,vHanging:ht,vIdeographic:ht,version:null,vertAdvY:ht,vertOriginX:ht,vertOriginY:ht,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ht,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Z7}),e9=wu({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()}}),t9=wu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:J7}),n9=wu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),MG={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"},IG=/[A-Z]/g,a6=/-[a-z]/g,OG=/^data[-\w.:]+$/i;function Cp(e,t){const n=N0(t);let a=t,r=zr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OG.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(a6,RG);a="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!a6.test(s)){let o=s.replace(IG,DG);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}r=Q2}return new r(a,t)}function DG(e){return"-"+e.toLowerCase()}function RG(e){return e.charAt(1).toUpperCase()}const Q0=X7([Q7,CG,e9,t9,n9],"html"),tl=X7([Q7,_G,e9,t9,n9],"svg");function r6(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function a9(e){return e.join(" ").trim()}var Ic={},Ix,s6;function jG(){if(s6)return Ix;s6=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,r=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
314
314
|
`,h="/",m="*",p="",x="comment",b="declaration";function y(E,v){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];v=v||{};var A=1,T=1;function C(q){var B=q.match(t);B&&(A+=B.length);var j=q.lastIndexOf(d);T=~j?q.length-j:T+q.length}function I(){var q={line:A,column:T};return function(B){return B.position=new O(q),z(),B}}function O(q){this.start=q,this.end={line:A,column:T},this.source=v.source}O.prototype.content=E;function _(q){var B=new Error(v.source+":"+A+":"+T+": "+q);if(B.reason=q,B.filename=v.source,B.line=A,B.column=T,B.source=E,!v.silent)throw B}function S(q){var B=q.exec(E);if(B){var j=B[0];return C(j),E=E.slice(j.length),B}}function z(){S(n)}function V(q){var B;for(q=q||[];B=P();)B!==!1&&q.push(B);return q}function P(){var q=I();if(!(h!=E.charAt(0)||m!=E.charAt(1))){for(var B=2;p!=E.charAt(B)&&(m!=E.charAt(B)||h!=E.charAt(B+1));)++B;if(B+=2,p===E.charAt(B-1))return _("End of comment missing");var j=E.slice(2,B-2);return T+=2,C(j),E=E.slice(B),T+=2,q({type:x,comment:j})}}function L(){var q=I(),B=S(a);if(B){if(P(),!S(r))return _("property missing ':'");var j=S(s),$=q({type:b,property:w(B[0].replace(e,p)),value:j?w(j[0].replace(e,p)):p});return S(o),$}}function Y(){var q=[];V(q);for(var B;B=L();)B!==!1&&(q.push(B),V(q));return q}return z(),Y()}function w(E){return E?E.replace(u,p):p}return Ix=y,Ix}var i6;function LG(){if(i6)return Ic;i6=1;var e=Ic&&Ic.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Ic,"__esModule",{value:!0}),Ic.default=n;const t=e(jG());function n(a,r){let s=null;if(!a||typeof a!="string")return s;const o=(0,t.default)(a),u=typeof r=="function";return o.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;u?r(h,m,d):m&&(s=s||{},s[h]=m)}),s}return Ic}var Td={},o6;function PG(){if(o6)return Td;o6=1,Object.defineProperty(Td,"__esModule",{value:!0}),Td.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,s=function(h){return!h||n.test(h)||e.test(h)},o=function(h,m){return m.toUpperCase()},u=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),s(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(r,u):h=h.replace(a,u),h.replace(t,o))};return Td.camelCase=d,Td}var Nd,l6;function zG(){if(l6)return Nd;l6=1;var e=Nd&&Nd.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},t=e(LG()),n=PG();function a(r,s){var o={};return!r||typeof r!="string"||(0,t.default)(r,function(u,d){u&&d&&(o[(0,n.camelCase)(u,s)]=d)}),o}return a.default=a,Nd=a,Nd}var BG=zG();const HG=D0(BG),_p=r9("end"),ui=r9("start");function r9(e){return t;function t(n){const a=n&&n.position&&n.position[e]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function s9(e){const t=ui(e),n=_p(e);if(t&&n)return{start:t,end:n}}function Kd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?c6(e.position):"start"in e||"end"in e?c6(e):"line"in e||"column"in e?py(e):""}function py(e){return u6(e&&e.line)+":"+u6(e&&e.column)}function c6(e){return py(e&&e.start)+"-"+py(e&&e.end)}function u6(e){return e&&typeof e=="number"?e:1}class hr extends Error{constructor(t,n,a){super(),typeof n=="string"&&(a=n,n=void 0);let r="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?r=t:!s.cause&&t&&(o=!0,r=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof a=="string"){const d=a.indexOf(":");d===-1?s.ruleId=a:(s.source=a.slice(0,d),s.ruleId=a.slice(d+1))}if(!s.place&&s.ancestors&&s.ancestors){const d=s.ancestors[s.ancestors.length-1];d&&(s.place=d.position)}const u=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=u?u.line:void 0,this.name=Kd(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}hr.prototype.file="";hr.prototype.name="";hr.prototype.reason="";hr.prototype.message="";hr.prototype.stack="";hr.prototype.column=void 0;hr.prototype.line=void 0;hr.prototype.ancestors=void 0;hr.prototype.cause=void 0;hr.prototype.fatal=void 0;hr.prototype.place=void 0;hr.prototype.ruleId=void 0;hr.prototype.source=void 0;const Z2={}.hasOwnProperty,FG=new Map,UG=/[A-Z]/g,qG=new Set(["table","tbody","thead","tfoot","tr"]),$G=new Set(["td","th"]),i9="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function WG(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=JG(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=ZG(n,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,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"?tl:Q0,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=o9(r,e,void 0);return s&&typeof s!="string"?s:r.create(e,r.Fragment,{children:s||void 0},void 0)}function o9(e,t,n){if(t.type==="element")return VG(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return GG(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return KG(e,t,n);if(t.type==="mdxjsEsm")return YG(e,t);if(t.type==="root")return XG(e,t,n);if(t.type==="text")return QG(e,t)}function VG(e,t,n){const a=e.schema;let r=a;t.tagName.toLowerCase()==="svg"&&a.space==="html"&&(r=tl,e.schema=r),e.ancestors.push(t);const s=c9(e,t.tagName,!1),o=eY(e,t);let u=ev(e,t);return qG.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!NG(d):!0})),l9(e,o,s,t),J2(o,u),e.ancestors.pop(),e.schema=a,e.create(t,s,o,n)}function GG(e,t){if(t.data&&t.data.estree&&e.evaluater){const a=t.data.estree.body[0];return a.type,e.evaluater.evaluateExpression(a.expression)}A0(e,t.position)}function YG(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);A0(e,t.position)}function KG(e,t,n){const a=e.schema;let r=a;t.name==="svg"&&a.space==="html"&&(r=tl,e.schema=r),e.ancestors.push(t);const s=t.name===null?e.Fragment:c9(e,t.name,!0),o=tY(e,t),u=ev(e,t);return l9(e,o,s,t),J2(o,u),e.ancestors.pop(),e.schema=a,e.create(t,s,o,n)}function XG(e,t,n){const a={};return J2(a,ev(e,t)),e.create(t,e.Fragment,a,n)}function QG(e,t){return t.value}function l9(e,t,n,a){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=a)}function J2(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ZG(e,t,n){return a;function a(r,s,o,u){const h=Array.isArray(o.children)?n:t;return u?h(s,o,u):h(s,o)}}function JG(e,t){return n;function n(a,r,s,o){const u=Array.isArray(s.children),d=ui(a);return t(r,s,o,u,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function eY(e,t){const n={};let a,r;for(r in t.properties)if(r!=="children"&&Z2.call(t.properties,r)){const s=nY(e,r,t.properties[r]);if(s){const[o,u]=s;e.tableCellAlignToStyle&&o==="align"&&typeof u=="string"&&$G.has(t.tagName)?a=u:n[o]=u}}if(a){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return n}function tY(e,t){const n={};for(const a of t.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&e.evaluater){const s=a.data.estree.body[0];s.type;const o=s.expression;o.type;const u=o.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else A0(e,t.position);else{const r=a.name;let s;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&e.evaluater){const u=a.value.data.estree.body[0];u.type,s=e.evaluater.evaluateExpression(u.expression)}else A0(e,t.position);else s=a.value===null?!0:a.value;n[r]=s}return n}function ev(e,t){const n=[];let a=-1;const r=e.passKeys?new Map:FG;for(;++a<t.children.length;){const s=t.children[a];let o;if(e.passKeys){const d=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(d){const h=r.get(d)||0;o=d+"-"+h,r.set(d,h+1)}}const u=o9(e,s,o);u!==void 0&&n.push(u)}return n}function nY(e,t,n){const a=Cp(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?K7(n):a9(n)),a.property==="style"){let r=typeof n=="object"?n:aY(e,String(n));return e.stylePropertyNameCase==="css"&&(r=rY(r)),["style",r]}return[e.elementAttributeNameCase==="react"&&a.space?MG[a.property]||a.property:a.attribute,n]}}function aY(e,t){try{return HG(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const a=n,r=new hr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=i9+"#cannot-parse-style-attribute",r}}function c9(e,t,n){let a;if(!n)a={type:"Literal",value:t};else if(t.includes(".")){const r=t.split(".");let s=-1,o;for(;++s<r.length;){const u=e6(r[s])?{type:"Identifier",name:r[s]}:{type:"Literal",value:r[s]};o=o?{type:"MemberExpression",object:o,property:u,computed:!!(s&&u.type==="Literal"),optional:!1}:u}a=o}else a=e6(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(a.type==="Literal"){const r=a.value;return Z2.call(e.components,r)?e.components[r]:r}if(e.evaluater)return e.evaluater.evaluateExpression(a);A0(e)}function A0(e,t){const n=new hr("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=i9+"#cannot-handle-mdx-estrees-without-createevaluater",n}function rY(e){const t={};let n;for(n in e)Z2.call(e,n)&&(t[sY(n)]=e[n]);return t}function sY(e){let t=e.replace(UG,iY);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function iY(e){return"-"+e.toLowerCase()}const Ox={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"]},oY={};function tv(e,t){const n=oY,a=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,r=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return u9(e,a,r)}function u9(e,t,n){if(lY(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 d6(e.children,t,n)}return Array.isArray(e)?d6(e,t,n):""}function d6(e,t,n){const a=[];let r=-1;for(;++r<e.length;)a[r]=u9(e[r],t,n);return a.join("")}function lY(e){return!!(e&&typeof e=="object")}const h6=document.createElement("i");function nv(e){const t="&"+e+";";h6.innerHTML=t;const n=h6.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function es(e,t,n,a){const r=e.length;let s=0,o;if(t<0?t=-t>r?0:r+t:t=t>r?r:t,n=n>0?n:0,a.length<1e4)o=Array.from(a),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<a.length;)o=a.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function xs(e,t){return e.length>0?(es(e,e.length,0,t),e):t}const f6={}.hasOwnProperty;function d9(e){const t={};let n=-1;for(;++n<e.length;)cY(t,e[n]);return t}function cY(e,t){let n;for(n in t){const r=(f6.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){f6.call(r,o)||(r[o]=[]);const u=s[o];uY(r[o],Array.isArray(u)?u:u?[u]:[])}}}function uY(e,t){let n=-1;const a=[];for(;++n<t.length;)(t[n].add==="after"?e:a).push(t[n]);es(e,0,0,a)}function h9(e,t){const 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 Ps(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yr=nl(/[A-Za-z]/),ir=nl(/[\dA-Za-z]/),dY=nl(/[#-'*+\--9=?A-Z^-~]/);function Fm(e){return e!==null&&(e<32||e===127)}const gy=nl(/\d/),hY=nl(/[\dA-Fa-f]/),fY=nl(/[!-/:-@[-`{-~]/);function Bt(e){return e!==null&&e<-2}function Qn(e){return e!==null&&(e<0||e===32)}function vn(e){return e===-2||e===-1||e===32}const Mp=nl(new RegExp("\\p{P}|\\p{S}","u")),$l=nl(/\s/);function nl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ku(e){const t=[];let n=-1,a=0,r=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&ir(e.charCodeAt(n+1))&&ir(e.charCodeAt(n+2)))r=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const u=e.charCodeAt(n+1);s<56320&&u>56319&&u<57344?(o=String.fromCharCode(s,u),r=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(a,n),encodeURIComponent(o)),a=n+r+1,o=""),r&&(n+=r,r=0)}return t.join("")+e.slice(a)}function xn(e,t,n,a){const r=a?a-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(d){return vn(d)?(e.enter(n),u(d)):t(d)}function u(d){return vn(d)&&s++<r?(e.consume(d),u):(e.exit(n),t(d))}}const mY={tokenize:pY};function pY(e){const t=e.attempt(this.parser.constructs.contentInitial,a,r);let n;return t;function a(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),xn(e,t,"linePrefix")}function r(u){return e.enter("paragraph"),s(u)}function s(u){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,o(u)}function o(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return Bt(u)?(e.consume(u),e.exit("chunkText"),s):(e.consume(u),o)}}const gY={tokenize:xY},m6={tokenize:bY};function xY(e){const t=this,n=[];let a=0,r,s,o;return u;function u(T){if(a<n.length){const C=n[a];return t.containerState=C[1],e.attempt(C[0].continuation,d,h)(T)}return h(T)}function d(T){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&A();const C=t.events.length;let I=C,O;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){O=t.events[I][1].end;break}v(a);let _=C;for(;_<t.events.length;)t.events[_][1].end={...O},_++;return es(t.events,I+1,0,t.events.slice(C)),t.events.length=_,h(T)}return u(T)}function h(T){if(a===n.length){if(!r)return x(T);if(r.currentConstruct&&r.currentConstruct.concrete)return y(T);t.interrupt=!!(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(m6,m,p)(T)}function m(T){return r&&A(),v(a),x(T)}function p(T){return t.parser.lazy[t.now().line]=a!==n.length,o=t.now().offset,y(T)}function x(T){return t.containerState={},e.attempt(m6,b,y)(T)}function b(T){return a++,n.push([t.currentConstruct,t.containerState]),x(T)}function y(T){if(T===null){r&&A(),v(0),e.consume(T);return}return r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:s}),w(T)}function w(T){if(T===null){E(e.exit("chunkFlow"),!0),v(0),e.consume(T);return}return Bt(T)?(e.consume(T),E(e.exit("chunkFlow")),a=0,t.interrupt=void 0,u):(e.consume(T),w)}function E(T,C){const I=t.sliceStream(T);if(C&&I.push(null),T.previous=s,s&&(s.next=T),s=T,r.defineSkip(T.start),r.write(I),t.parser.lazy[T.start.line]){let O=r.events.length;for(;O--;)if(r.events[O][1].start.offset<o&&(!r.events[O][1].end||r.events[O][1].end.offset>o))return;const _=t.events.length;let S=_,z,V;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){if(z){V=t.events[S][1].end;break}z=!0}for(v(a),O=_;O<t.events.length;)t.events[O][1].end={...V},O++;es(t.events,S+1,0,t.events.slice(_)),t.events.length=O}}function v(T){let C=n.length;for(;C-- >T;){const I=n[C];t.containerState=I[1],I[0].exit.call(t,e)}n.length=T}function A(){r.write([null]),s=void 0,r=void 0,t.containerState._closeFlow=void 0}}function bY(e,t,n){return xn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pu(e){if(e===null||Qn(e)||$l(e))return 1;if(Mp(e))return 2}function Ip(e,t,n){const a=[];let r=-1;for(;++r<e.length;){const s=e[r].resolveAll;s&&!a.includes(s)&&(t=s(t,n),a.push(s))}return t}const xy={name:"attention",resolveAll:yY,tokenize:vY};function yY(e,t){let n=-1,a,r,s,o,u,d,h,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(a=n;a--;)if(e[a][0]==="exit"&&e[a][1].type==="attentionSequence"&&e[a][1]._open&&t.sliceSerialize(e[a][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[a][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[a][1].end.offset-e[a][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[a][1].end.offset-e[a][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[a][1].end},x={...e[n][1].start};p6(p,-d),p6(x,d),o={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[a][1].end}},u={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},s={type:d>1?"strongText":"emphasisText",start:{...e[a][1].end},end:{...e[n][1].start}},r={type:d>1?"strong":"emphasis",start:{...o.start},end:{...u.end}},e[a][1].end={...o.start},e[n][1].start={...u.end},h=[],e[a][1].end.offset-e[a][1].start.offset&&(h=xs(h,[["enter",e[a][1],t],["exit",e[a][1],t]])),h=xs(h,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",s,t]]),h=xs(h,Ip(t.parser.constructs.insideSpan.null,e.slice(a+1,n),t)),h=xs(h,[["exit",s,t],["enter",u,t],["exit",u,t],["exit",r,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,h=xs(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,es(e,a-1,n-a+3,h),n=a+h.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function vY(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,r=pu(a);let s;return o;function o(d){return s=d,e.enter("attentionSequence"),u(d)}function u(d){if(d===s)return e.consume(d),u;const h=e.exit("attentionSequence"),m=pu(d),p=!m||m===2&&r||n.includes(d),x=!r||r===2&&m||n.includes(a);return h._open=!!(s===42?p:p&&(r||!x)),h._close=!!(s===42?x:x&&(m||!p)),t(d)}}function p6(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const wY={name:"autolink",tokenize:kY};function kY(e,t,n){let a=0;return r;function r(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(b){return yr(b)?(e.consume(b),o):b===64?n(b):h(b)}function o(b){return b===43||b===45||b===46||ir(b)?(a=1,u(b)):h(b)}function u(b){return b===58?(e.consume(b),a=0,d):(b===43||b===45||b===46||ir(b))&&a++<32?(e.consume(b),u):(a=0,h(b))}function d(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||Fm(b)?n(b):(e.consume(b),d)}function h(b){return b===64?(e.consume(b),m):dY(b)?(e.consume(b),h):n(b)}function m(b){return ir(b)?p(b):n(b)}function p(b){return b===46?(e.consume(b),a=0,m):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):x(b)}function x(b){if((b===45||ir(b))&&a++<63){const y=b===45?x:p;return e.consume(b),y}return n(b)}}const Z0={partial:!0,tokenize:EY};function EY(e,t,n){return a;function a(s){return vn(s)?xn(e,r,"linePrefix")(s):r(s)}function r(s){return s===null||Bt(s)?t(s):n(s)}}const f9={continuation:{tokenize:TY},exit:NY,name:"blockQuote",tokenize:SY};function SY(e,t,n){const a=this;return r;function r(o){if(o===62){const u=a.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return vn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function TY(e,t,n){const a=this;return r;function r(o){return vn(o)?xn(e,s,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(f9,t,n)(o)}}function NY(e){e.exit("blockQuote")}const m9={name:"characterEscape",tokenize:AY};function AY(e,t,n){return a;function a(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),r}function r(s){return fY(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const p9={name:"characterReference",tokenize:CY};function CY(e,t,n){const a=this;let r=0,s,o;return u;function u(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),d}function d(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),s=31,o=ir,m(p))}function h(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=hY,m):(e.enter("characterReferenceValue"),s=7,o=gy,m(p))}function m(p){if(p===59&&r){const x=e.exit("characterReferenceValue");return o===ir&&!nv(a.sliceSerialize(x))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&r++<s?(e.consume(p),m):n(p)}}const g6={partial:!0,tokenize:MY},x6={concrete:!0,name:"codeFenced",tokenize:_Y};function _Y(e,t,n){const a=this,r={partial:!0,tokenize:I};let s=0,o=0,u;return d;function d(O){return h(O)}function h(O){const _=a.events[a.events.length-1];return s=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,u=O,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(O)}function m(O){return O===u?(o++,e.consume(O),m):o<3?n(O):(e.exit("codeFencedFenceSequence"),vn(O)?xn(e,p,"whitespace")(O):p(O))}function p(O){return O===null||Bt(O)?(e.exit("codeFencedFence"),a.interrupt?t(O):e.check(g6,w,C)(O)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(O))}function x(O){return O===null||Bt(O)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(O)):vn(O)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),xn(e,b,"whitespace")(O)):O===96&&O===u?n(O):(e.consume(O),x)}function b(O){return O===null||Bt(O)?p(O):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(O))}function y(O){return O===null||Bt(O)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(O)):O===96&&O===u?n(O):(e.consume(O),y)}function w(O){return e.attempt(r,C,E)(O)}function E(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),v}function v(O){return s>0&&vn(O)?xn(e,A,"linePrefix",s+1)(O):A(O)}function A(O){return O===null||Bt(O)?e.check(g6,w,C)(O):(e.enter("codeFlowValue"),T(O))}function T(O){return O===null||Bt(O)?(e.exit("codeFlowValue"),A(O)):(e.consume(O),T)}function C(O){return e.exit("codeFenced"),t(O)}function I(O,_,S){let z=0;return V;function V(B){return O.enter("lineEnding"),O.consume(B),O.exit("lineEnding"),P}function P(B){return O.enter("codeFencedFence"),vn(B)?xn(O,L,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):L(B)}function L(B){return B===u?(O.enter("codeFencedFenceSequence"),Y(B)):S(B)}function Y(B){return B===u?(z++,O.consume(B),Y):z>=o?(O.exit("codeFencedFenceSequence"),vn(B)?xn(O,q,"whitespace")(B):q(B)):S(B)}function q(B){return B===null||Bt(B)?(O.exit("codeFencedFence"),_(B)):S(B)}}}function MY(e,t,n){const a=this;return r;function r(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return a.parser.lazy[a.now().line]?n(o):t(o)}}const Dx={name:"codeIndented",tokenize:OY},IY={partial:!0,tokenize:DY};function OY(e,t,n){const a=this;return r;function r(h){return e.enter("codeIndented"),xn(e,s,"linePrefix",5)(h)}function s(h){const m=a.events[a.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?o(h):n(h)}function o(h){return h===null?d(h):Bt(h)?e.attempt(IY,o,d)(h):(e.enter("codeFlowValue"),u(h))}function u(h){return h===null||Bt(h)?(e.exit("codeFlowValue"),o(h)):(e.consume(h),u)}function d(h){return e.exit("codeIndented"),t(h)}}function DY(e,t,n){const a=this;return r;function r(o){return a.parser.lazy[a.now().line]?n(o):Bt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r):xn(e,s,"linePrefix",5)(o)}function s(o){const u=a.events[a.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(o):Bt(o)?r(o):n(o)}}const RY={name:"codeText",previous:LY,resolve:jY,tokenize:PY};function jY(e){let t=e.length-4,n=3,a,r;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(a=n;++a<t;)if(e[a][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(a=n-1,t++;++a<=t;)r===void 0?a!==t&&e[a][1].type!=="lineEnding"&&(r=a):(a===t||e[a][1].type==="lineEnding")&&(e[r][1].type="codeTextData",a!==r+2&&(e[r][1].end=e[a-1][1].end,e.splice(r+2,a-r-2),t-=a-r-2,a=r+2),r=void 0);return e}function LY(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function PY(e,t,n){let a=0,r,s;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),u(p)}function u(p){return p===96?(e.consume(p),a++,u):(e.exit("codeTextSequence"),d(p))}function d(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),d):p===96?(s=e.enter("codeTextSequence"),r=0,m(p)):Bt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(p))}function h(p){return p===null||p===32||p===96||Bt(p)?(e.exit("codeTextData"),d(p)):(e.consume(p),h)}function m(p){return p===96?(e.consume(p),r++,m):r===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(s.type="codeTextData",h(p))}}class zY{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const a=n??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(t,a):t>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(t,n,a){const r=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return a&&Ad(this.left,a),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ad(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ad(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ad(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ad(this.left,n.reverse())}}}function Ad(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 g9(e){const t={};let n=-1,a,r,s,o,u,d,h;const m=new zY(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(a=m.get(n),n&&a[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(d=a[1]._tokenizer.events,s=0,s<d.length&&d[s][1].type==="lineEndingBlank"&&(s+=2),s<d.length&&d[s][1].type==="content"))for(;++s<d.length&&d[s][1].type!=="content";)d[s][1].type==="chunkText"&&(d[s][1]._isInFirstContentOfListItem=!0,s++);if(a[0]==="enter")a[1].contentType&&(Object.assign(t,BY(m,n)),n=t[n],h=!0);else if(a[1]._container){for(s=n,r=void 0;s--;)if(o=m.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(r&&(m.get(r)[1].type="lineEndingBlank"),o[1].type="lineEnding",r=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;r&&(a[1].end={...m.get(r)[1].start},u=m.slice(r,n),u.unshift(a),m.splice(r,n-r+1,u))}}return es(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function BY(e,t){const n=e.get(t)[1],a=e.get(t)[2];let r=t-1;const s=[];let o=n._tokenizer;o||(o=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const u=o.events,d=[],h={};let m,p,x=-1,b=n,y=0,w=0;const E=[w];for(;b;){for(;e.get(++r)[1]!==b;);s.push(r),b._tokenizer||(m=a.sliceStream(b),b.next||m.push(null),p&&o.defineSkip(b.start),b._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(m),b._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=b,b=b.next}for(b=n;++x<u.length;)u[x][0]==="exit"&&u[x-1][0]==="enter"&&u[x][1].type===u[x-1][1].type&&u[x][1].start.line!==u[x][1].end.line&&(w=x+1,E.push(w),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(o.events=[],b?(b._tokenizer=void 0,b.previous=void 0):E.pop(),x=E.length;x--;){const v=u.slice(E[x],E[x+1]),A=s.pop();d.push([A,A+v.length-1]),e.splice(A,2,v)}for(d.reverse(),x=-1;++x<d.length;)h[y+d[x][0]]=y+d[x][1],y+=d[x][1]-d[x][0]-1;return h}const HY={resolve:UY,tokenize:qY},FY={partial:!0,tokenize:$Y};function UY(e){return g9(e),e}function qY(e,t){let n;return a;function a(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(u)}function r(u){return u===null?s(u):Bt(u)?e.check(FY,o,s)(u):(e.consume(u),r)}function s(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function o(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}function $Y(e,t,n){const a=this;return r;function r(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),xn(e,s,"linePrefix")}function s(o){if(o===null||Bt(o))return n(o);const u=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(o):e.interrupt(a.parser.constructs.flow,n,t)(o)}}function x9(e,t,n,a,r,s,o,u,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(v){return v===60?(e.enter(a),e.enter(r),e.enter(s),e.consume(v),e.exit(s),x):v===null||v===32||v===41||Fm(v)?n(v):(e.enter(a),e.enter(o),e.enter(u),e.enter("chunkString",{contentType:"string"}),w(v))}function x(v){return v===62?(e.enter(s),e.consume(v),e.exit(s),e.exit(r),e.exit(a),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),b(v))}function b(v){return v===62?(e.exit("chunkString"),e.exit(u),x(v)):v===null||v===60||Bt(v)?n(v):(e.consume(v),v===92?y:b)}function y(v){return v===60||v===62||v===92?(e.consume(v),b):b(v)}function w(v){return!m&&(v===null||v===41||Qn(v))?(e.exit("chunkString"),e.exit(u),e.exit(o),e.exit(a),t(v)):m<h&&v===40?(e.consume(v),m++,w):v===41?(e.consume(v),m--,w):v===null||v===32||v===40||Fm(v)?n(v):(e.consume(v),v===92?E:w)}function E(v){return v===40||v===41||v===92?(e.consume(v),w):w(v)}}function b9(e,t,n,a,r,s){const o=this;let u=0,d;return h;function h(b){return e.enter(a),e.enter(r),e.consume(b),e.exit(r),e.enter(s),m}function m(b){return u>999||b===null||b===91||b===93&&!d||b===94&&!u&&"_hiddenFootnoteSupport"in o.parser.constructs?n(b):b===93?(e.exit(s),e.enter(r),e.consume(b),e.exit(r),e.exit(a),t):Bt(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Bt(b)||u++>999?(e.exit("chunkString"),m(b)):(e.consume(b),d||(d=!vn(b)),b===92?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),u++,p):p(b)}}function y9(e,t,n,a,r,s){let o;return u;function u(x){return x===34||x===39||x===40?(e.enter(a),e.enter(r),e.consume(x),e.exit(r),o=x===40?41:x,d):n(x)}function d(x){return x===o?(e.enter(r),e.consume(x),e.exit(r),e.exit(a),t):(e.enter(s),h(x))}function h(x){return x===o?(e.exit(s),d(o)):x===null?n(x):Bt(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),xn(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===o||x===null||Bt(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?p:m)}function p(x){return x===o||x===92?(e.consume(x),m):m(x)}}function Xd(e,t){let n;return a;function a(r){return Bt(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,a):vn(r)?xn(e,a,n?"linePrefix":"lineSuffix")(r):t(r)}}const WY={name:"definition",tokenize:GY},VY={partial:!0,tokenize:YY};function GY(e,t,n){const a=this;let r;return s;function s(b){return e.enter("definition"),o(b)}function o(b){return b9.call(a,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return r=Ps(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):n(b)}function d(b){return Qn(b)?Xd(e,h)(b):h(b)}function h(b){return x9(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(VY,p,p)(b)}function p(b){return vn(b)?xn(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Bt(b)?(e.exit("definition"),a.parser.defined.push(r),t(b)):n(b)}}function YY(e,t,n){return a;function a(u){return Qn(u)?Xd(e,r)(u):n(u)}function r(u){return y9(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function s(u){return vn(u)?xn(e,o,"whitespace")(u):o(u)}function o(u){return u===null||Bt(u)?t(u):n(u)}}const KY={name:"hardBreakEscape",tokenize:XY};function XY(e,t,n){return a;function a(s){return e.enter("hardBreakEscape"),e.consume(s),r}function r(s){return Bt(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const QY={name:"headingAtx",resolve:ZY,tokenize:JY};function ZY(e,t){let n=e.length-2,a=3,r,s;return e[a][1].type==="whitespace"&&(a+=2),n-2>a&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(a===n-1||n-4>a&&e[n-2][1].type==="whitespace")&&(n-=a+1===n?2:4),n>a&&(r={type:"atxHeadingText",start:e[a][1].start,end:e[n][1].end},s={type:"chunkText",start:e[a][1].start,end:e[n][1].end,contentType:"text"},es(e,a,n-a+1,[["enter",r,t],["enter",s,t],["exit",s,t],["exit",r,t]])),e}function JY(e,t,n){let a=0;return r;function r(m){return e.enter("atxHeading"),s(m)}function s(m){return e.enter("atxHeadingSequence"),o(m)}function o(m){return m===35&&a++<6?(e.consume(m),o):m===null||Qn(m)?(e.exit("atxHeadingSequence"),u(m)):n(m)}function u(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||Bt(m)?(e.exit("atxHeading"),t(m)):vn(m)?xn(e,u,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),u(m))}function h(m){return m===null||m===35||Qn(m)?(e.exit("atxHeadingText"),u(m)):(e.consume(m),h)}}const eK=["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"],b6=["pre","script","style","textarea"],tK={concrete:!0,name:"htmlFlow",resolveTo:rK,tokenize:sK},nK={partial:!0,tokenize:oK},aK={partial:!0,tokenize:iK};function rK(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 sK(e,t,n){const a=this;let r,s,o,u,d;return h;function h(K){return m(K)}function m(K){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(K),p}function p(K){return K===33?(e.consume(K),x):K===47?(e.consume(K),s=!0,w):K===63?(e.consume(K),r=3,a.interrupt?t:F):yr(K)?(e.consume(K),o=String.fromCharCode(K),E):n(K)}function x(K){return K===45?(e.consume(K),r=2,b):K===91?(e.consume(K),r=5,u=0,y):yr(K)?(e.consume(K),r=4,a.interrupt?t:F):n(K)}function b(K){return K===45?(e.consume(K),a.interrupt?t:F):n(K)}function y(K){const ee="CDATA[";return K===ee.charCodeAt(u++)?(e.consume(K),u===ee.length?a.interrupt?t:L:y):n(K)}function w(K){return yr(K)?(e.consume(K),o=String.fromCharCode(K),E):n(K)}function E(K){if(K===null||K===47||K===62||Qn(K)){const ee=K===47,ue=o.toLowerCase();return!ee&&!s&&b6.includes(ue)?(r=1,a.interrupt?t(K):L(K)):eK.includes(o.toLowerCase())?(r=6,ee?(e.consume(K),v):a.interrupt?t(K):L(K)):(r=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(K):s?A(K):T(K))}return K===45||ir(K)?(e.consume(K),o+=String.fromCharCode(K),E):n(K)}function v(K){return K===62?(e.consume(K),a.interrupt?t:L):n(K)}function A(K){return vn(K)?(e.consume(K),A):V(K)}function T(K){return K===47?(e.consume(K),V):K===58||K===95||yr(K)?(e.consume(K),C):vn(K)?(e.consume(K),T):V(K)}function C(K){return K===45||K===46||K===58||K===95||ir(K)?(e.consume(K),C):I(K)}function I(K){return K===61?(e.consume(K),O):vn(K)?(e.consume(K),I):T(K)}function O(K){return K===null||K===60||K===61||K===62||K===96?n(K):K===34||K===39?(e.consume(K),d=K,_):vn(K)?(e.consume(K),O):S(K)}function _(K){return K===d?(e.consume(K),d=null,z):K===null||Bt(K)?n(K):(e.consume(K),_)}function S(K){return K===null||K===34||K===39||K===47||K===60||K===61||K===62||K===96||Qn(K)?I(K):(e.consume(K),S)}function z(K){return K===47||K===62||vn(K)?T(K):n(K)}function V(K){return K===62?(e.consume(K),P):n(K)}function P(K){return K===null||Bt(K)?L(K):vn(K)?(e.consume(K),P):n(K)}function L(K){return K===45&&r===2?(e.consume(K),j):K===60&&r===1?(e.consume(K),$):K===62&&r===4?(e.consume(K),G):K===63&&r===3?(e.consume(K),F):K===93&&r===5?(e.consume(K),Q):Bt(K)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(nK,J,Y)(K)):K===null||Bt(K)?(e.exit("htmlFlowData"),Y(K)):(e.consume(K),L)}function Y(K){return e.check(aK,q,J)(K)}function q(K){return e.enter("lineEnding"),e.consume(K),e.exit("lineEnding"),B}function B(K){return K===null||Bt(K)?Y(K):(e.enter("htmlFlowData"),L(K))}function j(K){return K===45?(e.consume(K),F):L(K)}function $(K){return K===47?(e.consume(K),o="",X):L(K)}function X(K){if(K===62){const ee=o.toLowerCase();return b6.includes(ee)?(e.consume(K),G):L(K)}return yr(K)&&o.length<8?(e.consume(K),o+=String.fromCharCode(K),X):L(K)}function Q(K){return K===93?(e.consume(K),F):L(K)}function F(K){return K===62?(e.consume(K),G):K===45&&r===2?(e.consume(K),F):L(K)}function G(K){return K===null||Bt(K)?(e.exit("htmlFlowData"),J(K)):(e.consume(K),G)}function J(K){return e.exit("htmlFlow"),t(K)}}function iK(e,t,n){const a=this;return r;function r(o){return Bt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return a.parser.lazy[a.now().line]?n(o):t(o)}}function oK(e,t,n){return a;function a(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Z0,t,n)}}const lK={name:"htmlText",tokenize:cK};function cK(e,t,n){const a=this;let r,s,o;return u;function u(F){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(F),d}function d(F){return F===33?(e.consume(F),h):F===47?(e.consume(F),I):F===63?(e.consume(F),T):yr(F)?(e.consume(F),S):n(F)}function h(F){return F===45?(e.consume(F),m):F===91?(e.consume(F),s=0,y):yr(F)?(e.consume(F),A):n(F)}function m(F){return F===45?(e.consume(F),b):n(F)}function p(F){return F===null?n(F):F===45?(e.consume(F),x):Bt(F)?(o=p,$(F)):(e.consume(F),p)}function x(F){return F===45?(e.consume(F),b):p(F)}function b(F){return F===62?j(F):F===45?x(F):p(F)}function y(F){const G="CDATA[";return F===G.charCodeAt(s++)?(e.consume(F),s===G.length?w:y):n(F)}function w(F){return F===null?n(F):F===93?(e.consume(F),E):Bt(F)?(o=w,$(F)):(e.consume(F),w)}function E(F){return F===93?(e.consume(F),v):w(F)}function v(F){return F===62?j(F):F===93?(e.consume(F),v):w(F)}function A(F){return F===null||F===62?j(F):Bt(F)?(o=A,$(F)):(e.consume(F),A)}function T(F){return F===null?n(F):F===63?(e.consume(F),C):Bt(F)?(o=T,$(F)):(e.consume(F),T)}function C(F){return F===62?j(F):T(F)}function I(F){return yr(F)?(e.consume(F),O):n(F)}function O(F){return F===45||ir(F)?(e.consume(F),O):_(F)}function _(F){return Bt(F)?(o=_,$(F)):vn(F)?(e.consume(F),_):j(F)}function S(F){return F===45||ir(F)?(e.consume(F),S):F===47||F===62||Qn(F)?z(F):n(F)}function z(F){return F===47?(e.consume(F),j):F===58||F===95||yr(F)?(e.consume(F),V):Bt(F)?(o=z,$(F)):vn(F)?(e.consume(F),z):j(F)}function V(F){return F===45||F===46||F===58||F===95||ir(F)?(e.consume(F),V):P(F)}function P(F){return F===61?(e.consume(F),L):Bt(F)?(o=P,$(F)):vn(F)?(e.consume(F),P):z(F)}function L(F){return F===null||F===60||F===61||F===62||F===96?n(F):F===34||F===39?(e.consume(F),r=F,Y):Bt(F)?(o=L,$(F)):vn(F)?(e.consume(F),L):(e.consume(F),q)}function Y(F){return F===r?(e.consume(F),r=void 0,B):F===null?n(F):Bt(F)?(o=Y,$(F)):(e.consume(F),Y)}function q(F){return F===null||F===34||F===39||F===60||F===61||F===96?n(F):F===47||F===62||Qn(F)?z(F):(e.consume(F),q)}function B(F){return F===47||F===62||Qn(F)?z(F):n(F)}function j(F){return F===62?(e.consume(F),e.exit("htmlTextData"),e.exit("htmlText"),t):n(F)}function $(F){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),X}function X(F){return vn(F)?xn(e,Q,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):Q(F)}function Q(F){return e.enter("htmlTextData"),o(F)}}const av={name:"labelEnd",resolveAll:fK,resolveTo:mK,tokenize:pK},uK={tokenize:gK},dK={tokenize:xK},hK={tokenize:bK};function fK(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const r=a.type==="labelImage"?4:2;a.type="data",t+=r}}return e.length!==n.length&&es(e,0,e.length,n),e}function mK(e,t){let n=e.length,a=0,r,s,o,u;for(;n--;)if(r=e[n][1],s){if(r.type==="link"||r.type==="labelLink"&&r._inactive)break;e[n][0]==="enter"&&r.type==="labelLink"&&(r._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(r.type==="labelImage"||r.type==="labelLink")&&!r._balanced&&(s=n,r.type!=="labelLink")){a=2;break}}else r.type==="labelEnd"&&(o=n);const d={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},m={type:"labelText",start:{...e[s+a+2][1].end},end:{...e[o-2][1].start}};return u=[["enter",d,t],["enter",h,t]],u=xs(u,e.slice(s+1,s+a+3)),u=xs(u,[["enter",m,t]]),u=xs(u,Ip(t.parser.constructs.insideSpan.null,e.slice(s+a+4,o-3),t)),u=xs(u,[["exit",m,t],e[o-2],e[o-1],["exit",h,t]]),u=xs(u,e.slice(o+1)),u=xs(u,[["exit",d,t]]),es(e,s,e.length,u),e}function pK(e,t,n){const a=this;let r=a.events.length,s,o;for(;r--;)if((a.events[r][1].type==="labelImage"||a.events[r][1].type==="labelLink")&&!a.events[r][1]._balanced){s=a.events[r][1];break}return u;function u(x){return s?s._inactive?p(x):(o=a.parser.defined.includes(Ps(a.sliceSerialize({start:s.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(uK,m,o?m:p)(x):x===91?e.attempt(dK,m,o?h:p)(x):o?m(x):p(x)}function h(x){return e.attempt(hK,m,p)(x)}function m(x){return t(x)}function p(x){return s._balanced=!0,n(x)}}function gK(e,t,n){return a;function a(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),r}function r(p){return Qn(p)?Xd(e,s)(p):s(p)}function s(p){return p===41?m(p):x9(e,o,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Qn(p)?Xd(e,d)(p):m(p)}function u(p){return n(p)}function d(p){return p===34||p===39||p===40?y9(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):m(p)}function h(p){return Qn(p)?Xd(e,m)(p):m(p)}function m(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function xK(e,t,n){const a=this;return r;function r(u){return b9.call(a,e,s,o,"reference","referenceMarker","referenceString")(u)}function s(u){return a.parser.defined.includes(Ps(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function o(u){return n(u)}}function bK(e,t,n){return a;function a(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),r}function r(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const yK={name:"labelStartImage",resolveAll:av.resolveAll,tokenize:vK};function vK(e,t,n){const a=this;return r;function r(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),s}function s(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),o):n(u)}function o(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):t(u)}}const wK={name:"labelStartLink",resolveAll:av.resolveAll,tokenize:kK};function kK(e,t,n){const a=this;return r;function r(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(o):t(o)}}const Rx={name:"lineEnding",tokenize:EK};function EK(e,t){return n;function n(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),xn(e,t,"linePrefix")}}const cm={name:"thematicBreak",tokenize:SK};function SK(e,t,n){let a=0,r;return s;function s(h){return e.enter("thematicBreak"),o(h)}function o(h){return r=h,u(h)}function u(h){return h===r?(e.enter("thematicBreakSequence"),d(h)):a>=3&&(h===null||Bt(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===r?(e.consume(h),a++,d):(e.exit("thematicBreakSequence"),vn(h)?xn(e,u,"whitespace")(h):u(h))}}const Mr={continuation:{tokenize:CK},exit:MK,name:"list",tokenize:AK},TK={partial:!0,tokenize:IK},NK={partial:!0,tokenize:_K};function AK(e,t,n){const a=this,r=a.events[a.events.length-1];let s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,o=0;return u;function u(b){const y=a.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!a.containerState.marker||b===a.containerState.marker:gy(b)){if(a.containerState.type||(a.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(cm,n,h)(b):h(b);if(!a.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return n(b)}function d(b){return gy(b)&&++o<10?(e.consume(b),d):(!a.interrupt||o<2)&&(a.containerState.marker?b===a.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):n(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||b,e.check(Z0,a.interrupt?n:m,e.attempt(TK,x,p))}function m(b){return a.containerState.initialBlankLine=!0,s++,x(b)}function p(b){return vn(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):n(b)}function x(b){return a.containerState.size=s+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function CK(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check(Z0,r,s);function r(u){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,xn(e,t,"listItemIndent",a.containerState.size+1)(u)}function s(u){return a.containerState.furtherBlankLines||!vn(u)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,o(u)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(NK,t,o)(u))}function o(u){return a.containerState._closeFlow=!0,a.interrupt=void 0,xn(e,e.attempt(Mr,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function _K(e,t,n){const a=this;return xn(e,r,"listItemIndent",a.containerState.size+1);function r(s){const o=a.events[a.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===a.containerState.size?t(s):n(s)}}function MK(e){e.exit(this.containerState.type)}function IK(e,t,n){const a=this;return xn(e,r,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(s){const o=a.events[a.events.length-1];return!vn(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const y6={name:"setextUnderline",resolveTo:OK,tokenize:DK};function OK(e,t){let n=e.length,a,r,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){a=n;break}e[n][1].type==="paragraph"&&(r=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[a][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",s?(e.splice(r,0,["enter",o,t]),e.splice(s+1,0,["exit",e[a][1],t]),e[a][1].end={...e[s][1].end}):e[a][1]=o,e.push(["exit",o,t]),e}function DK(e,t,n){const a=this;let r;return s;function s(h){let m=a.events.length,p;for(;m--;)if(a.events[m][1].type!=="lineEnding"&&a.events[m][1].type!=="linePrefix"&&a.events[m][1].type!=="content"){p=a.events[m][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||p)?(e.enter("setextHeadingLine"),r=h,o(h)):n(h)}function o(h){return e.enter("setextHeadingLineSequence"),u(h)}function u(h){return h===r?(e.consume(h),u):(e.exit("setextHeadingLineSequence"),vn(h)?xn(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||Bt(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const RK={tokenize:jK};function jK(e){const t=this,n=e.attempt(Z0,a,e.attempt(this.parser.constructs.flowInitial,r,xn(e,e.attempt(this.parser.constructs.flow,r,e.attempt(HY,r)),"linePrefix")));return n;function a(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const LK={resolveAll:w9()},PK=v9("string"),zK=v9("text");function v9(e){return{resolveAll:w9(e==="text"?BK:void 0),tokenize:t};function t(n){const a=this,r=this.parser.constructs[e],s=n.attempt(r,o,u);return o;function o(m){return h(m)?s(m):u(m)}function u(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),d}function d(m){return h(m)?(n.exit("data"),s(m)):(n.consume(m),d)}function h(m){if(m===null)return!0;const p=r[m];let x=-1;if(p)for(;++x<p.length;){const b=p[x];if(!b.previous||b.previous.call(a,a.previous))return!0}return!1}}}function w9(e){return t;function t(n,a){let r=-1,s;for(;++r<=n.length;)s===void 0?n[r]&&n[r][1].type==="data"&&(s=r,r++):(!n[r]||n[r][1].type!=="data")&&(r!==s+2&&(n[s][1].end=n[r-1][1].end,n.splice(s+2,r-s-2),r=s+2),s=void 0);return e?e(n,a):n}}function BK(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const a=e[n-1][1],r=t.sliceStream(a);let s=r.length,o=-1,u=0,d;for(;s--;){const h=r[s];if(typeof h=="string"){for(o=h.length;h.charCodeAt(o-1)===32;)u++,o--;if(o)break;o=-1}else if(h===-2)d=!0,u++;else if(h!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const h={type:n===e.length||d||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:a.start._bufferIndex+o,_index:a.start._index+s,line:a.end.line,column:a.end.column-u,offset:a.end.offset-u},end:{...a.end}};a.end={...h.start},a.start.offset===a.end.offset?Object.assign(a,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const HK={42:Mr,43:Mr,45:Mr,48:Mr,49:Mr,50:Mr,51:Mr,52:Mr,53:Mr,54:Mr,55:Mr,56:Mr,57:Mr,62:f9},FK={91:WY},UK={[-2]:Dx,[-1]:Dx,32:Dx},qK={35:QY,42:cm,45:[y6,cm],60:tK,61:y6,95:cm,96:x6,126:x6},$K={38:p9,92:m9},WK={[-5]:Rx,[-4]:Rx,[-3]:Rx,33:yK,38:p9,42:xy,60:[wY,lK],91:wK,92:[KY,m9],93:av,95:xy,96:RY},VK={null:[xy,LK]},GK={null:[42,95]},YK={null:[]},KK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:GK,contentInitial:FK,disable:YK,document:HK,flow:qK,flowInitial:UK,insideSpan:VK,string:$K,text:WK},Symbol.toStringTag,{value:"Module"}));function XK(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},s=[];let o=[],u=[];const d={attempt:_(I),check:_(O),consume:A,enter:T,exit:C,interrupt:_(O,{interrupt:!0})},h={code:null,containerState:{},defineSkip:w,events:[],now:y,parser:e,previous:null,sliceSerialize:x,sliceStream:b,write:p};let m=t.tokenize.call(h,d);return t.resolveAll&&s.push(t),h;function p(P){return o=xs(o,P),E(),o[o.length-1]!==null?[]:(S(t,0),h.events=Ip(s,h.events,h),h.events)}function x(P,L){return ZK(b(P),L)}function b(P){return QK(o,P)}function y(){const{_bufferIndex:P,_index:L,line:Y,column:q,offset:B}=a;return{_bufferIndex:P,_index:L,line:Y,column:q,offset:B}}function w(P){r[P.line]=P.column,V()}function E(){let P;for(;a._index<o.length;){const L=o[a._index];if(typeof L=="string")for(P=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===P&&a._bufferIndex<L.length;)v(L.charCodeAt(a._bufferIndex));else v(L)}}function v(P){m=m(P)}function A(P){Bt(P)?(a.line++,a.column=1,a.offset+=P===-3?2:1,V()):P!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===o[a._index].length&&(a._bufferIndex=-1,a._index++)),h.previous=P}function T(P,L){const Y=L||{};return Y.type=P,Y.start=y(),h.events.push(["enter",Y,h]),u.push(Y),Y}function C(P){const L=u.pop();return L.end=y(),h.events.push(["exit",L,h]),L}function I(P,L){S(P,L.from)}function O(P,L){L.restore()}function _(P,L){return Y;function Y(q,B,j){let $,X,Q,F;return Array.isArray(q)?J(q):"tokenize"in q?J([q]):G(q);function G(pe){return be;function be(ae){const xe=ae!==null&&pe[ae],Ce=ae!==null&&pe.null,ze=[...Array.isArray(xe)?xe:xe?[xe]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return J(ze)(ae)}}function J(pe){return $=pe,X=0,pe.length===0?j:K(pe[X])}function K(pe){return be;function be(ae){return F=z(),Q=pe,pe.partial||(h.currentConstruct=pe),pe.name&&h.parser.constructs.disable.null.includes(pe.name)?ue():pe.tokenize.call(L?Object.assign(Object.create(h),L):h,d,ee,ue)(ae)}}function ee(pe){return P(Q,F),B}function ue(pe){return F.restore(),++X<$.length?K($[X]):j}}}function S(P,L){P.resolveAll&&!s.includes(P)&&s.push(P),P.resolve&&es(h.events,L,h.events.length-L,P.resolve(h.events.slice(L),h)),P.resolveTo&&(h.events=P.resolveTo(h.events,h))}function z(){const P=y(),L=h.previous,Y=h.currentConstruct,q=h.events.length,B=Array.from(u);return{from:q,restore:j};function j(){a=P,h.previous=L,h.currentConstruct=Y,h.events.length=q,u=B,V()}}function V(){a.line in r&&a.column<2&&(a.column=r[a.line],a.offset+=r[a.line]-1)}}function QK(e,t){const n=t.start._index,a=t.start._bufferIndex,r=t.end._index,s=t.end._bufferIndex;let o;if(n===r)o=[e[n].slice(a,s)];else{if(o=e.slice(n,r),a>-1){const u=o[0];typeof u=="string"?o[0]=u.slice(a):o.shift()}s>0&&o.push(e[r].slice(0,s))}return o}function ZK(e,t){let n=-1;const a=[];let r;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
315
315
|
`;break}case-3:{o=`\r
|
|
316
316
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&r)continue;o=" ";break}default:o=String.fromCharCode(s)}r=s===-2,a.push(o)}return a.join("")}function JK(e){const a={constructs:d9([KK,...(e||{}).extensions||[]]),content:r(mY),defined:[],document:r(gY),flow:r(RK),lazy:{},string:r(PK),text:r(zK)};return a;function r(s){return o;function o(u){return XK(a,s,u)}}}function eX(e){for(;!g9(e););return e}const v6=/[\0\t\n\r]/g;function tX(){let e=1,t="",n=!0,a;return r;function r(s,o,u){const d=[];let h,m,p,x,b;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),p=0,t="",n&&(s.charCodeAt(0)===65279&&p++,n=void 0);p<s.length;){if(v6.lastIndex=p,h=v6.exec(s),x=h&&h.index!==void 0?h.index:s.length,b=s.charCodeAt(x),!h){t=s.slice(p);break}if(b===10&&p===x&&a)d.push(-3),a=void 0;else switch(a&&(d.push(-5),a=void 0),p<x&&(d.push(s.slice(p,x)),e+=x-p),b){case 0:{d.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,d.push(-2);e++<m;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:a=!0,e=1}p=x+1}return u&&(a&&d.push(-5),t&&d.push(t),d.push(null)),d}}const nX=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function aX(e){return e.replace(nX,rX)}function rX(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const r=n.charCodeAt(1),s=r===120||r===88;return h9(n.slice(s?2:1),s?16:10)}return nv(n)||e}const k9={}.hasOwnProperty;function sX(e,t,n){return typeof t!="string"&&(n=t,t=void 0),iX(n)(eX(JK(n).document().write(tX()(e,t,!0))))}function iX(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Ye),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(Me),blockQuote:s(Ce),characterEscape:z,characterReference:z,codeFenced:s(ze),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(ze,o),codeText:s(Ie,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(Fe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Ee),hardBreakEscape:s(De),hardBreakTrailing:s(De),htmlFlow:s(bt,o),htmlFlowData:z,htmlText:s(bt,o),htmlTextData:z,image:s(mt),label:o,link:s(Ye),listItem:s(rt),listItemValue:x,listOrdered:s(at,p),listUnordered:s(at),paragraph:s(Ue),reference:K,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Me),strong:s(Ct),thematicBreak:s(It)},exit:{atxHeading:d(),atxHeadingSequence:I,autolink:d(),autolinkEmail:xe,autolinkProtocol:ae,blockQuote:d(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:pe,characterReference:be,codeFenced:d(E),codeFencedFence:w,codeFencedFenceInfo:b,codeFencedFenceMeta:y,codeFlowValue:V,codeIndented:d(v),codeText:d(B),codeTextData:V,data:V,definition:d(),definitionDestinationString:C,definitionLabelString:A,definitionTitleString:T,emphasis:d(),hardBreakEscape:d(L),hardBreakTrailing:d(L),htmlFlow:d(Y),htmlFlowData:V,htmlText:d(q),htmlTextData:V,image:d($),label:Q,labelText:X,lineEnding:P,link:d(j),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ee,resourceDestinationString:F,resourceTitleString:G,resource:J,setextHeading:d(S),setextHeadingLineSequence:_,setextHeadingText:O,strong:d(),thematicBreak:d()}};E9(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(_e){let Ze={type:"root",children:[]};const ie={stack:[Ze],tokenStack:[],config:t,enter:u,exit:h,buffer:o,resume:m,data:n},Be=[];let Je=-1;for(;++Je<_e.length;)if(_e[Je][1].type==="listOrdered"||_e[Je][1].type==="listUnordered")if(_e[Je][0]==="enter")Be.push(Je);else{const Ht=Be.pop();Je=r(_e,Ht,Je)}for(Je=-1;++Je<_e.length;){const Ht=t[_e[Je][0]];k9.call(Ht,_e[Je][1].type)&&Ht[_e[Je][1].type].call(Object.assign({sliceSerialize:_e[Je][2].sliceSerialize},ie),_e[Je][1])}if(ie.tokenStack.length>0){const Ht=ie.tokenStack[ie.tokenStack.length-1];(Ht[1]||w6).call(ie,void 0,Ht[0])}for(Ze.position={start:jo(_e.length>0?_e[0][1].start:{line:1,column:1,offset:0}),end:jo(_e.length>0?_e[_e.length-2][1].end:{line:1,column:1,offset:0})},Je=-1;++Je<t.transforms.length;)Ze=t.transforms[Je](Ze)||Ze;return Ze}function r(_e,Ze,ie){let Be=Ze-1,Je=-1,Ht=!1,Kt,qt,Rt,en;for(;++Be<=ie;){const Gt=_e[Be];switch(Gt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Gt[0]==="enter"?Je++:Je--,en=void 0;break}case"lineEndingBlank":{Gt[0]==="enter"&&(Kt&&!en&&!Je&&!Rt&&(Rt=Be),en=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:en=void 0}if(!Je&&Gt[0]==="enter"&&Gt[1].type==="listItemPrefix"||Je===-1&&Gt[0]==="exit"&&(Gt[1].type==="listUnordered"||Gt[1].type==="listOrdered")){if(Kt){let ha=Be;for(qt=void 0;ha--;){const zn=_e[ha];if(zn[1].type==="lineEnding"||zn[1].type==="lineEndingBlank"){if(zn[0]==="exit")continue;qt&&(_e[qt][1].type="lineEndingBlank",Ht=!0),zn[1].type="lineEnding",qt=ha}else if(!(zn[1].type==="linePrefix"||zn[1].type==="blockQuotePrefix"||zn[1].type==="blockQuotePrefixWhitespace"||zn[1].type==="blockQuoteMarker"||zn[1].type==="listItemIndent"))break}Rt&&(!qt||Rt<qt)&&(Kt._spread=!0),Kt.end=Object.assign({},qt?_e[qt][1].start:Gt[1].end),_e.splice(qt||Be,0,["exit",Kt,Gt[2]]),Be++,ie++}if(Gt[1].type==="listItemPrefix"){const ha={type:"listItem",_spread:!1,start:Object.assign({},Gt[1].start),end:void 0};Kt=ha,_e.splice(Be,0,["enter",ha,Gt[2]]),Be++,ie++,Rt=void 0,en=!0}}}return _e[Ze][1]._spread=Ht,ie}function s(_e,Ze){return ie;function ie(Be){u.call(this,_e(Be),Be),Ze&&Ze.call(this,Be)}}function o(){this.stack.push({type:"fragment",children:[]})}function u(_e,Ze,ie){this.stack[this.stack.length-1].children.push(_e),this.stack.push(_e),this.tokenStack.push([Ze,ie||void 0]),_e.position={start:jo(Ze.start),end:void 0}}function d(_e){return Ze;function Ze(ie){_e&&_e.call(this,ie),h.call(this,ie)}}function h(_e,Ze){const ie=this.stack.pop(),Be=this.tokenStack.pop();if(Be)Be[0].type!==_e.type&&(Ze?Ze.call(this,_e,Be[0]):(Be[1]||w6).call(this,_e,Be[0]));else throw new Error("Cannot close `"+_e.type+"` ("+Kd({start:_e.start,end:_e.end})+"): it’s not open");ie.position.end=jo(_e.end)}function m(){return tv(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function x(_e){if(this.data.expectingFirstListItemValue){const Ze=this.stack[this.stack.length-2];Ze.start=Number.parseInt(this.sliceSerialize(_e),10),this.data.expectingFirstListItemValue=void 0}}function b(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.lang=_e}function y(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.meta=_e}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function E(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.value=_e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.value=_e.replace(/(\r?\n|\r)$/g,"")}function A(_e){const Ze=this.resume(),ie=this.stack[this.stack.length-1];ie.label=Ze,ie.identifier=Ps(this.sliceSerialize(_e)).toLowerCase()}function T(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.title=_e}function C(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.url=_e}function I(_e){const Ze=this.stack[this.stack.length-1];if(!Ze.depth){const ie=this.sliceSerialize(_e).length;Ze.depth=ie}}function O(){this.data.setextHeadingSlurpLineEnding=!0}function _(_e){const Ze=this.stack[this.stack.length-1];Ze.depth=this.sliceSerialize(_e).codePointAt(0)===61?1:2}function S(){this.data.setextHeadingSlurpLineEnding=void 0}function z(_e){const ie=this.stack[this.stack.length-1].children;let Be=ie[ie.length-1];(!Be||Be.type!=="text")&&(Be=ot(),Be.position={start:jo(_e.start),end:void 0},ie.push(Be)),this.stack.push(Be)}function V(_e){const Ze=this.stack.pop();Ze.value+=this.sliceSerialize(_e),Ze.position.end=jo(_e.end)}function P(_e){const Ze=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ie=Ze.children[Ze.children.length-1];ie.position.end=jo(_e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ze.type)&&(z.call(this,_e),V.call(this,_e))}function L(){this.data.atHardBreak=!0}function Y(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.value=_e}function q(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.value=_e}function B(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.value=_e}function j(){const _e=this.stack[this.stack.length-1];if(this.data.inReference){const Ze=this.data.referenceType||"shortcut";_e.type+="Reference",_e.referenceType=Ze,delete _e.url,delete _e.title}else delete _e.identifier,delete _e.label;this.data.referenceType=void 0}function $(){const _e=this.stack[this.stack.length-1];if(this.data.inReference){const Ze=this.data.referenceType||"shortcut";_e.type+="Reference",_e.referenceType=Ze,delete _e.url,delete _e.title}else delete _e.identifier,delete _e.label;this.data.referenceType=void 0}function X(_e){const Ze=this.sliceSerialize(_e),ie=this.stack[this.stack.length-2];ie.label=aX(Ze),ie.identifier=Ps(Ze).toLowerCase()}function Q(){const _e=this.stack[this.stack.length-1],Ze=this.resume(),ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,ie.type==="link"){const Be=_e.children;ie.children=Be}else ie.alt=Ze}function F(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.url=_e}function G(){const _e=this.resume(),Ze=this.stack[this.stack.length-1];Ze.title=_e}function J(){this.data.inReference=void 0}function K(){this.data.referenceType="collapsed"}function ee(_e){const Ze=this.resume(),ie=this.stack[this.stack.length-1];ie.label=Ze,ie.identifier=Ps(this.sliceSerialize(_e)).toLowerCase(),this.data.referenceType="full"}function ue(_e){this.data.characterReferenceType=_e.type}function pe(_e){const Ze=this.sliceSerialize(_e),ie=this.data.characterReferenceType;let Be;ie?(Be=h9(Ze,ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Be=nv(Ze);const Je=this.stack[this.stack.length-1];Je.value+=Be}function be(_e){const Ze=this.stack.pop();Ze.position.end=jo(_e.end)}function ae(_e){V.call(this,_e);const Ze=this.stack[this.stack.length-1];Ze.url=this.sliceSerialize(_e)}function xe(_e){V.call(this,_e);const Ze=this.stack[this.stack.length-1];Ze.url="mailto:"+this.sliceSerialize(_e)}function Ce(){return{type:"blockquote",children:[]}}function ze(){return{type:"code",lang:null,meta:null,value:""}}function Ie(){return{type:"inlineCode",value:""}}function Fe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ee(){return{type:"emphasis",children:[]}}function Me(){return{type:"heading",depth:0,children:[]}}function De(){return{type:"break"}}function bt(){return{type:"html",value:""}}function mt(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function at(_e){return{type:"list",ordered:_e.type==="listOrdered",start:null,spread:_e._spread,children:[]}}function rt(_e){return{type:"listItem",spread:_e._spread,checked:null,children:[]}}function Ue(){return{type:"paragraph",children:[]}}function Ct(){return{type:"strong",children:[]}}function ot(){return{type:"text",value:""}}function It(){return{type:"thematicBreak"}}}function jo(e){return{line:e.line,column:e.column,offset:e.offset}}function E9(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?E9(e,a):oX(e,a)}}function oX(e,t){let n;for(n in t)if(k9.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function w6(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Kd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Kd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Kd({start:t.start,end:t.end})+") is still open")}function lX(e){const t=this;t.parser=n;function n(a){return sX(a,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function cX(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function uX(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -645,17 +645,17 @@ ${Te("continue.genOpen")}
|
|
|
645
645
|
${u.join(`
|
|
646
646
|
`)||"-"}`}]),h=u8(new Date().toISOString()).slice(0,10),m=Sle(n.position);ps("note",m,{question:`**📌 ${h} · ${Te("continue.recapTag")}**
|
|
647
647
|
|
|
648
|
-
${d.trim()}`}),AM.current?.setCenter((n.position.x+m.x)/2+260,(n.position.y+m.y)/2+140,{zoom:.75,duration:600}),We("success",Te("continue.noteDropped"))}catch(a){We("error",a instanceof Error?a.message:String(a))}}}function Tle({x:e,y:t,nodeId:n,onClose:a}){const r=St(),s=D.useRef(null),o=se(A=>A.nodes.find(T=>T.id===n));if(D.useEffect(()=>{const A=C=>{s.current?.contains(C.target)||a()},T=C=>{C.key==="Escape"&&a()};return window.addEventListener("mousedown",A),window.addEventListener("keydown",T),()=>{window.removeEventListener("mousedown",A),window.removeEventListener("keydown",T)}},[a]),!o)return null;const u=o.data.stepKind,d=!!u,h=!d&&!!o.data.response&&!o.data.isLoading,m=d?u==="note"||u==="link"?o.data.question:"":o.data.response,p="w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",x="text-ink-faint shrink-0",b=200,y=380,w=Math.min(e,window.innerWidth-b-8),E=Math.min(t,window.innerHeight-y-8),v=A=>()=>{a(),A()};return ur.createPortal(l.jsxs("div",{ref:s,className:"fixed z-[70] bg-card border border-line rounded-xl shadow-lg py-1 w-[200px] animate-fade-in",style:{left:w,top:E},children:[!d&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().setSelectedNodeId(n),oe.getState().setPanelOpen(!0)}),children:[l.jsx(Bl,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.openPanel")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>oe.getState().setResponseViewerNodeId(n)),children:[l.jsx(UA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.readingView")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().rerunNode(n)}),children:[l.jsx(or,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.rerun")]}),h&&l.jsxs("button",{className:p,title:Te("actions.regenBranchTitle"),onClick:v(()=>{se.getState().regenerate(n)}),children:[l.jsx(BA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.regenBranch")]}),h&&(o.data.response?.length??0)>=400&&l.jsxs("button",{className:p,onClick:v(()=>{NM([n])}),"data-reselect-ladder":!0,children:[l.jsx(h2,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.reselectLadder")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{CM(n)}),children:[l.jsx(oi,{size:14,strokeWidth:1.75,className:x})," ",r("continue.summarize")]}),m&&l.jsxs("button",{className:p,onClick:v(()=>{navigator.clipboard.writeText(m).then(()=>We("success",Te("ctx.copied")))}),children:[l.jsx(to,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.copyContent")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().duplicateNode(n)),children:[l.jsx(wF,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.duplicate")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().setArchived([n],!o.data.archived)),children:[o.data.archived?l.jsx(jA,{size:14,strokeWidth:1.75,className:x}):l.jsx(el,{size:14,strokeWidth:1.75,className:x}),o.data.archived?r("ctx.unarchive"):r("archive.label")]}),!d&&l.jsxs("button",{className:p,title:Te("exp.copyForCliTitle"),onClick:v(()=>{ft(()=>import("./experiment-loop-
|
|
648
|
+
${d.trim()}`}),AM.current?.setCenter((n.position.x+m.x)/2+260,(n.position.y+m.y)/2+140,{zoom:.75,duration:600}),We("success",Te("continue.noteDropped"))}catch(a){We("error",a instanceof Error?a.message:String(a))}}}function Tle({x:e,y:t,nodeId:n,onClose:a}){const r=St(),s=D.useRef(null),o=se(A=>A.nodes.find(T=>T.id===n));if(D.useEffect(()=>{const A=C=>{s.current?.contains(C.target)||a()},T=C=>{C.key==="Escape"&&a()};return window.addEventListener("mousedown",A),window.addEventListener("keydown",T),()=>{window.removeEventListener("mousedown",A),window.removeEventListener("keydown",T)}},[a]),!o)return null;const u=o.data.stepKind,d=!!u,h=!d&&!!o.data.response&&!o.data.isLoading,m=d?u==="note"||u==="link"?o.data.question:"":o.data.response,p="w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",x="text-ink-faint shrink-0",b=200,y=380,w=Math.min(e,window.innerWidth-b-8),E=Math.min(t,window.innerHeight-y-8),v=A=>()=>{a(),A()};return ur.createPortal(l.jsxs("div",{ref:s,className:"fixed z-[70] bg-card border border-line rounded-xl shadow-lg py-1 w-[200px] animate-fade-in",style:{left:w,top:E},children:[!d&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().setSelectedNodeId(n),oe.getState().setPanelOpen(!0)}),children:[l.jsx(Bl,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.openPanel")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>oe.getState().setResponseViewerNodeId(n)),children:[l.jsx(UA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.readingView")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{se.getState().rerunNode(n)}),children:[l.jsx(or,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.rerun")]}),h&&l.jsxs("button",{className:p,title:Te("actions.regenBranchTitle"),onClick:v(()=>{se.getState().regenerate(n)}),children:[l.jsx(BA,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.regenBranch")]}),h&&(o.data.response?.length??0)>=400&&l.jsxs("button",{className:p,onClick:v(()=>{NM([n])}),"data-reselect-ladder":!0,children:[l.jsx(h2,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.reselectLadder")]}),h&&l.jsxs("button",{className:p,onClick:v(()=>{CM(n)}),children:[l.jsx(oi,{size:14,strokeWidth:1.75,className:x})," ",r("continue.summarize")]}),m&&l.jsxs("button",{className:p,onClick:v(()=>{navigator.clipboard.writeText(m).then(()=>We("success",Te("ctx.copied")))}),children:[l.jsx(to,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.copyContent")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().duplicateNode(n)),children:[l.jsx(wF,{size:14,strokeWidth:1.75,className:x})," ",r("ctx.duplicate")]}),l.jsxs("button",{className:p,onClick:v(()=>se.getState().setArchived([n],!o.data.archived)),children:[o.data.archived?l.jsx(jA,{size:14,strokeWidth:1.75,className:x}):l.jsx(el,{size:14,strokeWidth:1.75,className:x}),o.data.archived?r("ctx.unarchive"):r("archive.label")]}),!d&&l.jsxs("button",{className:p,title:Te("exp.copyForCliTitle"),onClick:v(()=>{ft(()=>import("./experiment-loop-Dv6KJPhf.js"),[]).then(A=>A.takeToExperiment(n,"branch"))}),"data-take-to-experiment":!0,children:[l.jsx(EF,{size:14,strokeWidth:1.75,className:x})," ",r("exp.copyForCli")]}),l.jsx("div",{className:"h-px bg-line my-1"}),l.jsxs("button",{className:"w-full text-left px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors flex items-center gap-2.5",onClick:v(()=>{ri({title:Te("confirm.deleteNodesTitle"),message:ye(Te("confirm.deleteNodes"),{n:1}),confirmLabel:Te("common.delete"),danger:!0}).then(A=>{A&&se.getState().deleteNode(n)})}),children:[l.jsx(Ja,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",r("common.delete")]})]}),document.body)}function Nle({onLocate:e}){const t=oe(C=>C.highlightsOverviewOpen),n=oe(C=>C.setHighlightsOverviewOpen),a=se(C=>C.nodes),r=se(C=>C.removeHighlight),s=se(C=>C.weaveHighlights),o=St(),[u,d]=D.useState("time"),[h,m]=D.useState(new Set),[p,x]=D.useState(""),b=D.useMemo(()=>{const C=[];for(const O of a){const _=O.data.question.replace(/\s+/g," ").trim().slice(0,60)||"—";for(const S of O.data.highlights||[])C.push({hlId:S.id,text:S.text,at:S.at,nodeId:O.id,nodeTitle:_})}const I=u==="time"?[...C].sort((O,_)=>(_.at??"").localeCompare(O.at??"")):C;return I.map((O,_)=>({...O,showGroup:u==="node"&&(_===0||I[_-1].nodeTitle!==O.nodeTitle)}))},[a,u]);if(!t)return null;const y=C=>{const I=new Set(h);I.has(C)?I.delete(C):I.add(C),m(I)},w=()=>{n(!1),m(new Set),x("")},E=()=>{const C=[...h].filter(O=>b.some(_=>_.hlId===O));if(C.length===0)return;const I=[...new Set(b.filter(O=>C.includes(O.hlId)).map(O=>O.nodeId))];w(),s(I,p.trim()||void 0,C)},v=()=>{const C=b.map(I=>`- ${I.text}
|
|
649
649
|
— ${I.nodeTitle}${I.at?` · ${I.at.slice(0,10)}`:""}`);X2(`# ${o("hlov.title")}
|
|
650
650
|
|
|
651
651
|
${C.join(`
|
|
652
652
|
`)}
|
|
653
653
|
`)},A="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",T=(C,I)=>l.jsx("button",{onClick:()=>d(C),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${u===C?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:I});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:w,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:C=>C.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(m0,{size:15,strokeWidth:1.75,className:"text-amber-500"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:o("hlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ye(o("hlov.count"),{n:b.length})}),l.jsx("div",{className:"flex-1"}),T("time",o("hlov.byTime")),T("node",o("hlov.byNode")),l.jsx("button",{onClick:w,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[b.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:o("hlov.empty")}),b.map(C=>l.jsxs("div",{children:[C.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:C.nodeTitle}),l.jsxs("div",{className:"group flex items-start gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("input",{type:"checkbox",checked:h.has(C.hlId),onChange:()=>y(C.hlId),className:"mt-1 accent-amber-500 shrink-0"}),l.jsx("span",{className:"flex-1 text-sm text-ink leading-relaxed min-w-0",children:l.jsx("mark",{className:"bg-amber-100 text-amber-800 px-0.5 rounded",children:C.text})}),u==="time"&&l.jsxs("button",{className:A,onClick:()=>{w(),e(C.nodeId)},title:o("hlov.locateTitle"),children:[C.nodeTitle.slice(0,14),C.nodeTitle.length>14?"…":""]}),u==="node"&&l.jsx("button",{className:A,onClick:()=>{w(),e(C.nodeId)},title:o("hlov.locateTitle"),children:"↦"}),C.at&&l.jsx("span",{className:"shrink-0 text-2xs text-ink-faint font-mono mt-0.5",children:C.at.slice(5,10)}),l.jsx("button",{onClick:()=>r(C.nodeId,C.hlId),title:o("common.delete"),className:"text-ink-faint hover:text-red-500 w-5 h-5 rounded-full flex items-center justify-center transition-colors shrink-0 opacity-0 group-hover:opacity-100",children:l.jsx(Ja,{size:12,strokeWidth:1.75})})]})]},C.hlId))]}),l.jsxs("div",{className:"px-5 py-3 border-t border-line shrink-0 space-y-2",children:[h.size>0&&l.jsxs("div",{className:"flex gap-1.5",children:[l.jsx("input",{type:"text",value:p,onChange:C=>x(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!lr(C)&&E()},placeholder:o("toolbar.intentPlaceholder"),className:"flex-1 text-xs border border-amber-500/30 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-amber-500 bg-amber-500/5"}),l.jsx("button",{onClick:E,className:"text-xs bg-amber-500 hover:bg-amber-400 text-white px-3 py-2 rounded-lg transition-colors shrink-0",children:ye(o("hlov.weavePicked"),{n:h.size})})]}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:h.size>0?ye(o("hlov.picked"),{n:h.size}):o("hlov.pickHint")}),l.jsx("div",{className:"flex-1"}),b.length>0&&l.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 text-2xs text-ink-faint hover:text-ink-muted transition-colors",title:o("hlov.exportTitle"),children:[l.jsx(Ml,{size:12,strokeWidth:1.75})," ",o("hlov.export")]})]})]})]})}),document.body)}const Ale={pdf:js,img:HF,txt:js,note:oi,link:Gi};function Cle({onLocate:e}){const t=oe(x=>x.materialsOverviewOpen),n=oe(x=>x.setMaterialsOverviewOpen),a=se(x=>x.nodes),r=St(),[s,o]=D.useState("time"),u=D.useMemo(()=>{const x=[];for(const y of a){const w=y.data.stepKind;if(w==="note"||w==="link"){const v=w==="link"?y.data.linkTitle||y.data.linkUrl||"—":y.data.question.split(`
|
|
654
|
-
`)[0].replace(/^#+\s*/,"").slice(0,60)||"—";x.push({key:y.id,name:v,icon:w,at:y.data.createdAt,nodeId:y.id,nodeTitle:v,canOpen:!0});continue}const E=y.data.question.replace(/\s+/g," ").trim().slice(0,60)||(w==="file"?r("glyph.file"):"—");for(const v of y.data.attachments||[]){const A=v.type==="application/pdf"?"pdf":v.type.startsWith("image/")?"img":"txt";x.push({key:v.id,name:v.name,icon:A,sizeKB:v.size/1024,at:v.addedAt,nodeId:y.id,nodeTitle:E,canOpen:A==="pdf"})}}const b=s==="time"?[...x].sort((y,w)=>(w.at??"").localeCompare(y.at??"")):x;return b.map((y,w)=>({...y,showGroup:s==="node"&&(w===0||b[w-1].nodeTitle!==y.nodeTitle)}))},[a,s,r]);if(!t)return null;const d=()=>n(!1),h=x=>{d(),oe.getState().setReaderNodeId(x)},m="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",p=(x,b)=>l.jsx("button",{onClick:()=>o(x),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${s===x?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:b});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:d,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:x=>x.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(Ls,{size:15,strokeWidth:1.75,className:"text-warm"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("matov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ye(r("matov.count"),{n:u.length})}),l.jsx("div",{className:"flex-1"}),p("time",r("hlov.byTime")),p("node",r("hlov.byNode")),l.jsx("button",{onClick:d,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[u.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("matov.empty")}),u.map(x=>{const b=Ale[x.icon];return l.jsxs("div",{children:[x.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:x.nodeTitle}),l.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${x.icon==="note"?"bg-amber-100 text-amber-600":x.icon==="link"?"bg-cyan-100 text-cyan-700":"bg-wash text-ink-muted"}`,children:l.jsx(b,{size:14,strokeWidth:1.75})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-ink truncate",children:x.name}),l.jsxs("p",{className:"text-2xs text-ink-faint",children:[x.sizeKB!=null?`${x.sizeKB.toFixed(1)} KB`:r(`matov.kind.${x.icon}`),x.at?` · ${x.at.slice(0,10)}`:""]})]}),s==="time"&&l.jsxs("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:[x.nodeTitle.slice(0,14),x.nodeTitle.length>14?"…":""]}),s==="node"&&l.jsx("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:"↦"}),x.canOpen&&l.jsx("button",{onClick:()=>h(x.nodeId),title:r("attach.openReader"),className:"w-7 h-7 rounded-lg text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors shrink-0",children:l.jsx(Bl,{size:14,strokeWidth:1.75})})]})]},x.key)})]})]})}),document.body)}function _le(e){const t=e.data.stepKind;return t==="note"||t==="file"||t==="link"||t==="frame"?t:e.data.condensedFrom?.length?"distill":"qa"}function Mle(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n+=1,a=e.indexOf(t,a+t.length);return n}function Ile(e,t,n){const r=Math.max(0,t-40),s=Math.min(e.length,t+n+60),o=r>0?"…":"",u=s<e.length?"…":"";return{snippet:o+e.slice(r,s)+u,matchStart:o.length+(t-r)}}function Ole(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=[];for(const r of e){const s=r.data;if(s.stepKind==="fanout")continue;const o=[s.question??"",s.response??"",...(s.highlights??[]).map(p=>p.text),s.linkTitle??"",...(s.attachments??[]).map(p=>p.name),s.summaries?.[s.responseIndex]??s.summary??""];let u=0,d=null;for(const p of o){if(!p)continue;const x=p.toLowerCase(),b=x.indexOf(n);b!==-1&&(u+=Mle(x,n),d||(d={text:p,at:b}))}if(!d)continue;const{snippet:h,matchStart:m}=Ile(d.text,d.at,n.length);a.push({nodeId:r.id,kind:_le(r),archived:!!s.archived,count:u,snippet:h,matchStart:m,matchLen:n.length})}return a.sort((r,s)=>Number(r.archived)-Number(s.archived)||s.count-r.count),a}const Dle={qa:qA,note:oi,file:js,link:Gi,frame:Ub,distill:bp},pb=50;function Rle({open:e,onClose:t,onLocate:n}){const a=St(),r=se(v=>v.nodes),s=oe(v=>v.setSearchHitIds),[o,u]=D.useState(""),[d,h]=D.useState(0),m=D.useRef(null),[p,x]=D.useState(e);p!==e&&(x(e),e&&(u(""),h(0))),D.useEffect(()=>{e&&setTimeout(()=>m.current?.focus(),50)},[e]);const[b,y]=D.useState("");D.useEffect(()=>{const v=setTimeout(()=>y(o),120);return()=>clearTimeout(v)},[o]);const w=D.useMemo(()=>e?Ole(r,b):[],[e,r,b]);if(D.useEffect(()=>{if(!e||!b.trim()){s(null);return}s(new Set(w.map(v=>v.nodeId)))},[e,b,w,s]),D.useEffect(()=>()=>s(null),[s]),!e)return null;const E=v=>{n(v.nodeId);const A=b.trim().toLowerCase();setTimeout(()=>{const T=document.querySelector("[data-focus-panel]");if(!T||!A)return;const C=document.createTreeWalker(T,NodeFilter.SHOW_TEXT);let I;for(;I=C.nextNode();)if(I.textContent?.toLowerCase().includes(A)){const O=I.parentElement;O?.scrollIntoView({block:"center",behavior:"smooth"}),O?.animate([{backgroundColor:"rgba(107, 92, 231, 0.22)"},{backgroundColor:"transparent"}],{duration:1800,easing:"ease-out"});break}},500)};return l.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20 w-[460px]","data-canvas-search":!0,children:l.jsxs("div",{className:"bg-card border border-line rounded-xl shadow-xl overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 transition-shadow focus-within:ring-1 focus-within:ring-accent/40",children:[l.jsx(g0,{size:15,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{ref:m,type:"text",value:o,onChange:v=>{u(v.target.value),h(0)},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t()),v.key==="ArrowDown"&&(v.preventDefault(),h(A=>Math.min(A+1,w.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),h(A=>Math.max(A-1,0))),v.key==="Enter"&&!lr(v)&&w[d]&&(v.preventDefault(),E(w[d]))},placeholder:a("search.placeholder"),className:"flex-1 bg-transparent text-sm text-ink placeholder-ink-faint focus:outline-none","data-search-input":!0}),o&&l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ye(a("search.count"),{n:w.length})}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),w.length>0&&l.jsxs("ul",{className:"border-t border-line/60 max-h-72 overflow-y-auto py-1",children:[w.slice(0,pb).map((v,A)=>{const T=Dle[v.kind],I=r.find(O=>O.id===v.nodeId)?.data.question||"—";return l.jsx("li",{children:l.jsxs("button",{onClick:()=>E(v),onMouseEnter:()=>h(A),className:`w-full text-left px-4 py-2 transition-colors ${A===d?"bg-accent/8":""} ${v.archived?"opacity-55":""}`,"data-search-hit-row":!0,children:[l.jsxs("p",{className:`text-xs font-medium truncate flex items-center gap-1.5 ${A===d?"text-accent":"text-ink"}`,children:[l.jsx(T,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate flex-1 min-w-0",children:I}),v.archived&&l.jsx(el,{size:11,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),v.count>1&&l.jsxs("span",{className:"text-2xs text-ink-faint font-normal shrink-0",children:["×",v.count]})]}),l.jsxs("p",{className:"text-2xs text-ink-faint mt-0.5 break-all leading-relaxed",children:[v.snippet.slice(0,v.matchStart),l.jsx("mark",{className:"bg-accent/20 text-accent rounded-sm px-px",children:v.snippet.slice(v.matchStart,v.matchStart+v.matchLen)}),v.snippet.slice(v.matchStart+v.matchLen)]})]})},v.nodeId)}),w.length>pb&&l.jsx("li",{className:"px-4 py-2 text-2xs text-ink-faint",children:ye(a("search.more"),{n:w.length-pb})})]})]})})}const bT=new Set(["note","file","link"]),Ws=e=>{const t=(e?.data.question??"").replace(/\s+/g," ").trim();return t.length>24?`${t.slice(0,24)}…`:t||"(空)"};function gb(e,t,n){const a=new Set([e]),r=[e];for(;r.length;){const s=r.shift();for(const o of n.get(s)??[]){if(o===t)return!0;a.has(o)||(a.add(o),r.push(o))}}return!1}function xb(e){const t=new Map;for(const n of e)t.has(n.source)||t.set(n.source,[]),t.get(n.source).push(n.target);return t}function yT(e,t){const n=[],a=new Map(e.map(S=>[S.id,S])),r=t.filter(S=>!S.data?.isCrossLink),s=t.filter(S=>S.data?.isCrossLink),o=xb(r),u=xb(t);for(const S of r){const z=xb(r.filter(V=>V.id!==S.id));gb(S.source,S.target,z)&&n.push({tier:1,kind:"residual-edge",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]})}for(const S of s)gb(S.source,S.target,o)&&n.push({tier:1,kind:"shadow-reference",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]});const d=new Map;for(const S of r)d.has(S.source)||d.set(S.source,[]),d.get(S.source).push(S.target);const h=[];for(const S of d.values()){const z=S.filter(P=>a.get(P)?.data.stepKind==="prompt"),V=S.filter(P=>a.get(P)?.data.isBranch);z.length>=2&&h.push(z),V.length>=2&&h.push(V)}for(const S of h)for(const z of S)for(const V of S)if(z!==V&&gb(z,V,u)){const P=t.find(L=>L.source===z&&L.target===V);n.push({tier:1,kind:"blind-pool-breach",fixable:!!P,params:{a:Ws(a.get(V)),b:Ws(a.get(z))},nodeIds:[V,z],edgeIds:P?[P.id]:[]})}for(const S of h){const z=S.map(P=>new Set(t.filter(L=>L.target===P).map(L=>L.source))),V=new Set([...z[0]].filter(P=>z.every(L=>L.has(P))));S.forEach((P,L)=>{const Y=[...z[L]].filter(q=>!V.has(q)&&!S.includes(q));Y.length>0&&n.push({tier:1,kind:"pool-asymmetry",fixable:!1,params:{a:Ws(a.get(P)),n:Y.length},nodeIds:[P,...Y],edgeIds:[]})})}const m=e.filter(S=>!bT.has(S.data.stepKind??"")&&S.data.stepKind!=="frame"),p=new Map,x=new Map,b=S=>Nn(S.data.question+S.data.response),y=new Map;for(const S of m)y.set(S.id,0);for(const S of r)y.has(S.target)&&y.has(S.source)&&y.set(S.target,(y.get(S.target)??0)+1);const w=m.filter(S=>(y.get(S.id)??0)===0).map(S=>S.id),E=[],v=new Map(y);for(;w.length;){const S=w.shift();E.push(S);for(const z of o.get(S)??[])v.has(z)&&(v.set(z,v.get(z)-1),v.get(z)===0&&w.push(z))}for(const S of E){const z=a.get(S),V=r.filter(Y=>Y.target===S&&p.has(Y.source)),P=V.length?Math.max(...V.map(Y=>p.get(Y.source)))+1:1,L=V.length?Math.max(...V.map(Y=>x.get(Y.source)))+b(z):b(z);p.set(S,P),x.set(S,L)}const A=m.filter(S=>!(o.get(S.id)??[]).length&&!S.data.archived),T=A.filter(S=>(p.get(S.id)??0)>=8||(x.get(S.id)??0)>=15e3).sort((S,z)=>(p.get(z.id)??0)-(p.get(S.id)??0)).slice(0,3);for(const S of T)n.push({tier:2,kind:"long-chain",fixable:!1,params:{a:Ws(S),d:p.get(S.id)??0,tok:x.get(S.id)??0},nodeIds:[S.id],edgeIds:[]});const C=A.filter(S=>S.data.response);C.length>=4&&n.push({tier:2,kind:"open-branches",fixable:!1,params:{n:C.length},nodeIds:C.map(S=>S.id),edgeIds:[]});for(const S of m){const z=r.filter(P=>P.target===S.id).length,V=(o.get(S.id)??[]).length;z>=2&&V>=1&&n.push({tier:2,kind:"collider-continuation",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]})}const I=e.filter(S=>bT.has(S.data.stepKind??"")&&!t.some(z=>z.source===S.id));I.length>0&&n.push({tier:2,kind:"orphan-materials",fixable:!1,params:{n:I.length},nodeIds:I.map(S=>S.id),edgeIds:[]});const O=S=>{const z=new Set,V=[S];for(;V.length;)for(const P of o.get(V.shift())??[])z.has(P)||(z.add(P),V.push(P));return z.size},_=m.map(S=>({n:S,c:O(S.id)})).filter(({c:S})=>S>=5).sort((S,z)=>z.c-S.c).slice(0,3);for(const{n:S,c:z}of _)n.push({tier:2,kind:"load-bearing",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]});return n.sort((S,z)=>S.tier-z.tier)}const jle={"residual-edge":"diag.residual","shadow-reference":"diag.shadow","blind-pool-breach":"diag.breach","pool-asymmetry":"diag.asym","long-chain":"diag.longChain","open-branches":"diag.openBranches","collider-continuation":"diag.collider","orphan-materials":"diag.orphans","load-bearing":"diag.loadBearing"};function Lle({onLocate:e,openPing:t=0,showTrigger:n=!0}){const a=se(v=>v.deleteEdges),r=St(),[s,o]=D.useState(!1),[u,d]=D.useState([]),h=D.useRef(null),[m,p]=D.useState(t);D.useEffect(()=>{if(!s)return;const v=A=>{h.current?.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[s]);const x=()=>{const{nodes:v,edges:A}=se.getState();d(yT(v,A)),o(!0)};t!==m&&(p(t),x());const b=v=>{a(v.edgeIds);const{nodes:A,edges:T}=se.getState();d(yT(A,T))},y=u.filter(v=>v.tier===1),w=u.filter(v=>v.tier===2),E=(v,A)=>l.jsxs("div",{className:"px-3 py-2 border-b border-line/50 last:border-0 flex items-start gap-2",children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${v.tier===1?"bg-red-400":"bg-amber-400"}`}),l.jsx("span",{className:"text-xs text-ink-muted leading-relaxed flex-1 min-w-0",children:ye(r(jle[v.kind]),v.params)}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v.nodeIds.length>0&&l.jsx("button",{onClick:()=>e(v.nodeIds[0]),title:r("diag.locate"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(Pd,{size:13,strokeWidth:1.75})}),v.fixable&&l.jsx("button",{onClick:()=>b(v),title:r("diag.fix"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-red-500 hover:bg-red-50 flex items-center justify-center transition-colors",children:l.jsx(Ja,{size:13,strokeWidth:1.75})})]})]},`${v.kind}-${A}`);return l.jsxs("div",{ref:h,className:"relative",children:[n&&l.jsx("button",{onClick:()=>s?o(!1):x(),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${s?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:r("toolbar.diagnose"),children:l.jsx(GA,{size:15,strokeWidth:1.75})}),s&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[340px] max-h-[420px] overflow-y-auto z-30 animate-fade-in",children:[l.jsxs("div",{className:"px-3 py-1.5 text-2xs font-semibold text-ink-muted border-b border-line",children:[r("diag.title"),l.jsx("span",{className:"text-ink-faint font-normal ml-2",children:u.length===0?"":ye(r("diag.summary"),{a:y.length,b:w.length})})]}),u.length===0&&l.jsx("p",{className:"px-3 py-3 text-xs text-ink-faint italic",children:r("diag.clean")}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-red-500",children:r("diag.tier1")}),y.map(E)]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-amber-600",children:r("diag.tier2")}),w.map(E)]})]})]})}async function _M(e,t){const{default:n}=await ft(async()=>{const{default:s}=await import("./purify.es-Cz4mVeUR.js");return{default:s}},[]),a=n.sanitize(e,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style"],FORBID_TAGS:["script","iframe","object","embed","form","base","meta",...t?.baseUrl?[]:["link"]]}),r=new DOMParser().parseFromString(a,"text/html");return t?.baseUrl&&Ple(r,t.baseUrl),r}function Ple(e,t){const n=a=>{try{const r=new URL(a,t);return/^https?:$/.test(r.protocol)?r.href:null}catch{return null}};e.querySelectorAll("link").forEach(a=>{const r=a.getAttribute("href"),s=r?n(r):null;(a.getAttribute("rel")??"").toLowerCase()!=="stylesheet"||!s?a.remove():a.setAttribute("href",s)});for(const[a,r]of[["img","src"],["source","src"],["video","poster"],["a","href"]])e.querySelectorAll(`${a}[${r}]`).forEach(s=>{const o=s.getAttribute(r),u=o?n(o):null;u?s.setAttribute(r,u):s.removeAttribute(r)});e.querySelectorAll("img[srcset], source[srcset]").forEach(a=>a.removeAttribute("srcset"))}async function zle(){const[{default:e},t]=await Promise.all([ft(()=>import("./turndown.browser.es-kLzRgxYD.js"),[]),ft(()=>import("./turndown-plugin-gfm.cjs-DwpDMrH3.js").then(a=>a.t),[])]),n=new e({headingStyle:"atx",codeBlockStyle:"fenced",hr:"---"});return n.use(t.gfm),n.remove(["style","script","noscript","title"]),n}function vT(e){return(e.textContent??"").trim().length>0||!!e.querySelector("img,svg,canvas,video")}function $v(e){const t=Array.from(e.querySelectorAll(".reveal .slides > section"));if(t.length>=2){const s=[];for(const o of t){const u=Array.from(o.children).filter(d=>d.tagName==="SECTION");u.length>0?s.push(...u):s.push(o)}return s}const n=new Map;for(const s of Array.from(e.body?.querySelectorAll("[class]")??[])){const o=s.getAttribute("class")??"";if(!/(?:^|[\s_-])(?:slide|page)(?:[\s_-]|$)/i.test(o)||!vT(s))continue;const u=s.parentElement;if(!u)continue;const d=n.get(u)??[];d.push(s),n.set(u,d)}let a=null;for(const s of n.values())s.length>=2&&(!a||s.length>a.length)&&(a=s);if(a)return a;const r=Array.from(e.querySelectorAll("body > section")).filter(vT);return r.length>=3?r:null}async function Ble(e,t){const n=await _M(e,t),a=await zle(),r=$v(n);if(r)return{markdown:r.map((d,h)=>`<!-- tdag-page:${h+1} -->
|
|
654
|
+
`)[0].replace(/^#+\s*/,"").slice(0,60)||"—";x.push({key:y.id,name:v,icon:w,at:y.data.createdAt,nodeId:y.id,nodeTitle:v,canOpen:!0});continue}const E=y.data.question.replace(/\s+/g," ").trim().slice(0,60)||(w==="file"?r("glyph.file"):"—");for(const v of y.data.attachments||[]){const A=v.type==="application/pdf"?"pdf":v.type.startsWith("image/")?"img":"txt";x.push({key:v.id,name:v.name,icon:A,sizeKB:v.size/1024,at:v.addedAt,nodeId:y.id,nodeTitle:E,canOpen:A==="pdf"})}}const b=s==="time"?[...x].sort((y,w)=>(w.at??"").localeCompare(y.at??"")):x;return b.map((y,w)=>({...y,showGroup:s==="node"&&(w===0||b[w-1].nodeTitle!==y.nodeTitle)}))},[a,s,r]);if(!t)return null;const d=()=>n(!1),h=x=>{d(),oe.getState().setReaderNodeId(x)},m="shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors",p=(x,b)=>l.jsx("button",{onClick:()=>o(x),className:`text-2xs px-2.5 py-1 rounded-full transition-colors ${s===x?"bg-accent/10 text-accent":"text-ink-faint hover:bg-wash"}`,children:b});return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:d,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] max-h-[80vh] flex flex-col",onClick:x=>x.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(Ls,{size:15,strokeWidth:1.75,className:"text-warm"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("matov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ye(r("matov.count"),{n:u.length})}),l.jsx("div",{className:"flex-1"}),p("time",r("hlov.byTime")),p("node",r("hlov.byNode")),l.jsx("button",{onClick:d,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors ml-1",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-3",children:[u.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("matov.empty")}),u.map(x=>{const b=Ale[x.icon];return l.jsxs("div",{children:[x.showGroup&&l.jsx("div",{className:"text-2xs text-ink-faint font-medium mt-3 mb-1 first:mt-0 truncate",children:x.nodeTitle}),l.jsxs("div",{className:"group flex items-center gap-2.5 py-1.5 border-b border-line/50 last:border-0",children:[l.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${x.icon==="note"?"bg-amber-100 text-amber-600":x.icon==="link"?"bg-cyan-100 text-cyan-700":"bg-wash text-ink-muted"}`,children:l.jsx(b,{size:14,strokeWidth:1.75})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-ink truncate",children:x.name}),l.jsxs("p",{className:"text-2xs text-ink-faint",children:[x.sizeKB!=null?`${x.sizeKB.toFixed(1)} KB`:r(`matov.kind.${x.icon}`),x.at?` · ${x.at.slice(0,10)}`:""]})]}),s==="time"&&l.jsxs("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:[x.nodeTitle.slice(0,14),x.nodeTitle.length>14?"…":""]}),s==="node"&&l.jsx("button",{className:m,onClick:()=>{d(),e(x.nodeId)},title:r("hlov.locateTitle"),children:"↦"}),x.canOpen&&l.jsx("button",{onClick:()=>h(x.nodeId),title:r("attach.openReader"),className:"w-7 h-7 rounded-lg text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors shrink-0",children:l.jsx(Bl,{size:14,strokeWidth:1.75})})]})]},x.key)})]})]})}),document.body)}function _le(e){const t=e.data.stepKind;return t==="note"||t==="file"||t==="link"||t==="frame"?t:e.data.condensedFrom?.length?"distill":"qa"}function Mle(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n+=1,a=e.indexOf(t,a+t.length);return n}function Ile(e,t,n){const r=Math.max(0,t-40),s=Math.min(e.length,t+n+60),o=r>0?"…":"",u=s<e.length?"…":"";return{snippet:o+e.slice(r,s)+u,matchStart:o.length+(t-r)}}function Ole(e,t){const n=t.trim().toLowerCase();if(!n)return[];const a=[];for(const r of e){const s=r.data;if(s.stepKind==="fanout")continue;const o=[s.question??"",s.response??"",...(s.highlights??[]).map(p=>p.text),s.linkTitle??"",...(s.attachments??[]).map(p=>p.name),s.summaries?.[s.responseIndex]??s.summary??""];let u=0,d=null;for(const p of o){if(!p)continue;const x=p.toLowerCase(),b=x.indexOf(n);b!==-1&&(u+=Mle(x,n),d||(d={text:p,at:b}))}if(!d)continue;const{snippet:h,matchStart:m}=Ile(d.text,d.at,n.length);a.push({nodeId:r.id,kind:_le(r),archived:!!s.archived,count:u,snippet:h,matchStart:m,matchLen:n.length})}return a.sort((r,s)=>Number(r.archived)-Number(s.archived)||s.count-r.count),a}const Dle={qa:qA,note:oi,file:js,link:Gi,frame:Ub,distill:bp},pb=50;function Rle({open:e,onClose:t,onLocate:n}){const a=St(),r=se(v=>v.nodes),s=oe(v=>v.setSearchHitIds),[o,u]=D.useState(""),[d,h]=D.useState(0),m=D.useRef(null),[p,x]=D.useState(e);p!==e&&(x(e),e&&(u(""),h(0))),D.useEffect(()=>{e&&setTimeout(()=>m.current?.focus(),50)},[e]);const[b,y]=D.useState("");D.useEffect(()=>{const v=setTimeout(()=>y(o),120);return()=>clearTimeout(v)},[o]);const w=D.useMemo(()=>e?Ole(r,b):[],[e,r,b]);if(D.useEffect(()=>{if(!e||!b.trim()){s(null);return}s(new Set(w.map(v=>v.nodeId)))},[e,b,w,s]),D.useEffect(()=>()=>s(null),[s]),!e)return null;const E=v=>{n(v.nodeId);const A=b.trim().toLowerCase();setTimeout(()=>{const T=document.querySelector("[data-focus-panel]");if(!T||!A)return;const C=document.createTreeWalker(T,NodeFilter.SHOW_TEXT);let I;for(;I=C.nextNode();)if(I.textContent?.toLowerCase().includes(A)){const O=I.parentElement;O?.scrollIntoView({block:"center",behavior:"smooth"}),O?.animate([{backgroundColor:"rgba(107, 92, 231, 0.22)"},{backgroundColor:"transparent"}],{duration:1800,easing:"ease-out"});break}},500)};return l.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20 w-[460px]","data-canvas-search":!0,children:l.jsxs("div",{className:"bg-card border border-line rounded-xl shadow-xl overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 transition-shadow focus-within:ring-1 focus-within:ring-accent/40",children:[l.jsx(g0,{size:15,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{ref:m,type:"text",value:o,onChange:v=>{u(v.target.value),h(0)},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),t()),v.key==="ArrowDown"&&(v.preventDefault(),h(A=>Math.min(A+1,w.length-1))),v.key==="ArrowUp"&&(v.preventDefault(),h(A=>Math.max(A-1,0))),v.key==="Enter"&&!lr(v)&&w[d]&&(v.preventDefault(),E(w[d]))},placeholder:a("search.placeholder"),className:"flex-1 bg-transparent text-sm text-ink placeholder-ink-faint focus:outline-none","data-search-input":!0}),o&&l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ye(a("search.count"),{n:w.length})}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),w.length>0&&l.jsxs("ul",{className:"border-t border-line/60 max-h-72 overflow-y-auto py-1",children:[w.slice(0,pb).map((v,A)=>{const T=Dle[v.kind],I=r.find(O=>O.id===v.nodeId)?.data.question||"—";return l.jsx("li",{children:l.jsxs("button",{onClick:()=>E(v),onMouseEnter:()=>h(A),className:`w-full text-left px-4 py-2 transition-colors ${A===d?"bg-accent/8":""} ${v.archived?"opacity-55":""}`,"data-search-hit-row":!0,children:[l.jsxs("p",{className:`text-xs font-medium truncate flex items-center gap-1.5 ${A===d?"text-accent":"text-ink"}`,children:[l.jsx(T,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate flex-1 min-w-0",children:I}),v.archived&&l.jsx(el,{size:11,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),v.count>1&&l.jsxs("span",{className:"text-2xs text-ink-faint font-normal shrink-0",children:["×",v.count]})]}),l.jsxs("p",{className:"text-2xs text-ink-faint mt-0.5 break-all leading-relaxed",children:[v.snippet.slice(0,v.matchStart),l.jsx("mark",{className:"bg-accent/20 text-accent rounded-sm px-px",children:v.snippet.slice(v.matchStart,v.matchStart+v.matchLen)}),v.snippet.slice(v.matchStart+v.matchLen)]})]})},v.nodeId)}),w.length>pb&&l.jsx("li",{className:"px-4 py-2 text-2xs text-ink-faint",children:ye(a("search.more"),{n:w.length-pb})})]})]})})}const bT=new Set(["note","file","link"]),Ws=e=>{const t=(e?.data.question??"").replace(/\s+/g," ").trim();return t.length>24?`${t.slice(0,24)}…`:t||"(空)"};function gb(e,t,n){const a=new Set([e]),r=[e];for(;r.length;){const s=r.shift();for(const o of n.get(s)??[]){if(o===t)return!0;a.has(o)||(a.add(o),r.push(o))}}return!1}function xb(e){const t=new Map;for(const n of e)t.has(n.source)||t.set(n.source,[]),t.get(n.source).push(n.target);return t}function yT(e,t){const n=[],a=new Map(e.map(S=>[S.id,S])),r=t.filter(S=>!S.data?.isCrossLink),s=t.filter(S=>S.data?.isCrossLink),o=xb(r),u=xb(t);for(const S of r){const z=xb(r.filter(V=>V.id!==S.id));gb(S.source,S.target,z)&&n.push({tier:1,kind:"residual-edge",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]})}for(const S of s)gb(S.source,S.target,o)&&n.push({tier:1,kind:"shadow-reference",fixable:!0,params:{a:Ws(a.get(S.source)),b:Ws(a.get(S.target))},nodeIds:[S.target,S.source],edgeIds:[S.id]});const d=new Map;for(const S of r)d.has(S.source)||d.set(S.source,[]),d.get(S.source).push(S.target);const h=[];for(const S of d.values()){const z=S.filter(P=>a.get(P)?.data.stepKind==="prompt"),V=S.filter(P=>a.get(P)?.data.isBranch);z.length>=2&&h.push(z),V.length>=2&&h.push(V)}for(const S of h)for(const z of S)for(const V of S)if(z!==V&&gb(z,V,u)){const P=t.find(L=>L.source===z&&L.target===V);n.push({tier:1,kind:"blind-pool-breach",fixable:!!P,params:{a:Ws(a.get(V)),b:Ws(a.get(z))},nodeIds:[V,z],edgeIds:P?[P.id]:[]})}for(const S of h){const z=S.map(P=>new Set(t.filter(L=>L.target===P).map(L=>L.source))),V=new Set([...z[0]].filter(P=>z.every(L=>L.has(P))));S.forEach((P,L)=>{const Y=[...z[L]].filter(q=>!V.has(q)&&!S.includes(q));Y.length>0&&n.push({tier:1,kind:"pool-asymmetry",fixable:!1,params:{a:Ws(a.get(P)),n:Y.length},nodeIds:[P,...Y],edgeIds:[]})})}const m=e.filter(S=>!bT.has(S.data.stepKind??"")&&S.data.stepKind!=="frame"),p=new Map,x=new Map,b=S=>Nn(S.data.question+S.data.response),y=new Map;for(const S of m)y.set(S.id,0);for(const S of r)y.has(S.target)&&y.has(S.source)&&y.set(S.target,(y.get(S.target)??0)+1);const w=m.filter(S=>(y.get(S.id)??0)===0).map(S=>S.id),E=[],v=new Map(y);for(;w.length;){const S=w.shift();E.push(S);for(const z of o.get(S)??[])v.has(z)&&(v.set(z,v.get(z)-1),v.get(z)===0&&w.push(z))}for(const S of E){const z=a.get(S),V=r.filter(Y=>Y.target===S&&p.has(Y.source)),P=V.length?Math.max(...V.map(Y=>p.get(Y.source)))+1:1,L=V.length?Math.max(...V.map(Y=>x.get(Y.source)))+b(z):b(z);p.set(S,P),x.set(S,L)}const A=m.filter(S=>!(o.get(S.id)??[]).length&&!S.data.archived),T=A.filter(S=>(p.get(S.id)??0)>=8||(x.get(S.id)??0)>=15e3).sort((S,z)=>(p.get(z.id)??0)-(p.get(S.id)??0)).slice(0,3);for(const S of T)n.push({tier:2,kind:"long-chain",fixable:!1,params:{a:Ws(S),d:p.get(S.id)??0,tok:x.get(S.id)??0},nodeIds:[S.id],edgeIds:[]});const C=A.filter(S=>S.data.response);C.length>=4&&n.push({tier:2,kind:"open-branches",fixable:!1,params:{n:C.length},nodeIds:C.map(S=>S.id),edgeIds:[]});for(const S of m){const z=r.filter(P=>P.target===S.id).length,V=(o.get(S.id)??[]).length;z>=2&&V>=1&&n.push({tier:2,kind:"collider-continuation",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]})}const I=e.filter(S=>bT.has(S.data.stepKind??"")&&!t.some(z=>z.source===S.id));I.length>0&&n.push({tier:2,kind:"orphan-materials",fixable:!1,params:{n:I.length},nodeIds:I.map(S=>S.id),edgeIds:[]});const O=S=>{const z=new Set,V=[S];for(;V.length;)for(const P of o.get(V.shift())??[])z.has(P)||(z.add(P),V.push(P));return z.size},_=m.map(S=>({n:S,c:O(S.id)})).filter(({c:S})=>S>=5).sort((S,z)=>z.c-S.c).slice(0,3);for(const{n:S,c:z}of _)n.push({tier:2,kind:"load-bearing",fixable:!1,params:{a:Ws(S),n:z},nodeIds:[S.id],edgeIds:[]});return n.sort((S,z)=>S.tier-z.tier)}const jle={"residual-edge":"diag.residual","shadow-reference":"diag.shadow","blind-pool-breach":"diag.breach","pool-asymmetry":"diag.asym","long-chain":"diag.longChain","open-branches":"diag.openBranches","collider-continuation":"diag.collider","orphan-materials":"diag.orphans","load-bearing":"diag.loadBearing"};function Lle({onLocate:e,openPing:t=0,showTrigger:n=!0}){const a=se(v=>v.deleteEdges),r=St(),[s,o]=D.useState(!1),[u,d]=D.useState([]),h=D.useRef(null),[m,p]=D.useState(t);D.useEffect(()=>{if(!s)return;const v=A=>{h.current?.contains(A.target)||o(!1)};return window.addEventListener("mousedown",v),()=>window.removeEventListener("mousedown",v)},[s]);const x=()=>{const{nodes:v,edges:A}=se.getState();d(yT(v,A)),o(!0)};t!==m&&(p(t),x());const b=v=>{a(v.edgeIds);const{nodes:A,edges:T}=se.getState();d(yT(A,T))},y=u.filter(v=>v.tier===1),w=u.filter(v=>v.tier===2),E=(v,A)=>l.jsxs("div",{className:"px-3 py-2 border-b border-line/50 last:border-0 flex items-start gap-2",children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 ${v.tier===1?"bg-red-400":"bg-amber-400"}`}),l.jsx("span",{className:"text-xs text-ink-muted leading-relaxed flex-1 min-w-0",children:ye(r(jle[v.kind]),v.params)}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[v.nodeIds.length>0&&l.jsx("button",{onClick:()=>e(v.nodeIds[0]),title:r("diag.locate"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-accent hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(Pd,{size:13,strokeWidth:1.75})}),v.fixable&&l.jsx("button",{onClick:()=>b(v),title:r("diag.fix"),className:"w-6 h-6 rounded-md text-ink-faint hover:text-red-500 hover:bg-red-50 flex items-center justify-center transition-colors",children:l.jsx(Ja,{size:13,strokeWidth:1.75})})]})]},`${v.kind}-${A}`);return l.jsxs("div",{ref:h,className:"relative",children:[n&&l.jsx("button",{onClick:()=>s?o(!1):x(),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${s?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:r("toolbar.diagnose"),children:l.jsx(GA,{size:15,strokeWidth:1.75})}),s&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[340px] max-h-[420px] overflow-y-auto z-30 animate-fade-in",children:[l.jsxs("div",{className:"px-3 py-1.5 text-2xs font-semibold text-ink-muted border-b border-line",children:[r("diag.title"),l.jsx("span",{className:"text-ink-faint font-normal ml-2",children:u.length===0?"":ye(r("diag.summary"),{a:y.length,b:w.length})})]}),u.length===0&&l.jsx("p",{className:"px-3 py-3 text-xs text-ink-faint italic",children:r("diag.clean")}),y.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-red-500",children:r("diag.tier1")}),y.map(E)]}),w.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"px-3 pt-2 pb-1 text-2xs font-semibold text-amber-600",children:r("diag.tier2")}),w.map(E)]})]})]})}async function _M(e,t){const{default:n}=await ft(async()=>{const{default:s}=await import("./purify.es-Cz4mVeUR.js");return{default:s}},[]),a=n.sanitize(e,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style"],FORBID_TAGS:["script","iframe","object","embed","form","base","meta",...t?.baseUrl?[]:["link"]]}),r=new DOMParser().parseFromString(a,"text/html");return t?.baseUrl&&Ple(r,t.baseUrl),r}function Ple(e,t){const n=a=>{try{const r=new URL(a,t);return/^https?:$/.test(r.protocol)?r.href:null}catch{return null}};e.querySelectorAll("link").forEach(a=>{const r=a.getAttribute("href"),s=r?n(r):null;(a.getAttribute("rel")??"").toLowerCase()!=="stylesheet"||!s?a.remove():a.setAttribute("href",s)});for(const[a,r]of[["img","src"],["source","src"],["video","poster"],["a","href"]])e.querySelectorAll(`${a}[${r}]`).forEach(s=>{const o=s.getAttribute(r),u=o?n(o):null;u?s.setAttribute(r,u):s.removeAttribute(r)});e.querySelectorAll("img[srcset], source[srcset]").forEach(a=>a.removeAttribute("srcset"))}async function zle(){const[{default:e},t]=await Promise.all([ft(()=>import("./turndown.browser.es-kLzRgxYD.js"),[]),ft(()=>import("./turndown-plugin-gfm.cjs-B39qaw5-.js").then(a=>a.t),[])]),n=new e({headingStyle:"atx",codeBlockStyle:"fenced",hr:"---"});return n.use(t.gfm),n.remove(["style","script","noscript","title"]),n}function vT(e){return(e.textContent??"").trim().length>0||!!e.querySelector("img,svg,canvas,video")}function $v(e){const t=Array.from(e.querySelectorAll(".reveal .slides > section"));if(t.length>=2){const s=[];for(const o of t){const u=Array.from(o.children).filter(d=>d.tagName==="SECTION");u.length>0?s.push(...u):s.push(o)}return s}const n=new Map;for(const s of Array.from(e.body?.querySelectorAll("[class]")??[])){const o=s.getAttribute("class")??"";if(!/(?:^|[\s_-])(?:slide|page)(?:[\s_-]|$)/i.test(o)||!vT(s))continue;const u=s.parentElement;if(!u)continue;const d=n.get(u)??[];d.push(s),n.set(u,d)}let a=null;for(const s of n.values())s.length>=2&&(!a||s.length>a.length)&&(a=s);if(a)return a;const r=Array.from(e.querySelectorAll("body > section")).filter(vT);return r.length>=3?r:null}async function Ble(e,t){const n=await _M(e,t),a=await zle(),r=$v(n);if(r)return{markdown:r.map((d,h)=>`<!-- tdag-page:${h+1} -->
|
|
655
655
|
|
|
656
656
|
${a.turndown(d.cloneNode(!0).outerHTML).trim()}`).join(`
|
|
657
657
|
|
|
658
|
-
`).trim(),numPages:r.length,title:n.title||void 0};let s=n.title||void 0,o=null;try{const{default:u}=await ft(async()=>{const{default:h}=await import("./index-
|
|
658
|
+
`).trim(),numPages:r.length,title:n.title||void 0};let s=n.title||void 0,o=null;try{const{default:u}=await ft(async()=>{const{default:h}=await import("./index-BrpB22PP.js").then(m=>m.i);return{default:h}},[]),d=new u(n.cloneNode(!0)).parse();d?.content&&d.content.replace(/<[^>]+>/g," ").trim().length>40&&(o=d.content,d.title&&(s=d.title))}catch{}if(o==null&&n.body){const u=n.body.cloneNode(!0);u.querySelectorAll("script,style,noscript,nav,header,footer,aside").forEach(d=>d.remove()),o=u.innerHTML}return{markdown:o?a.turndown(o).trim():"",title:s}}const Hle=[":root{color-scheme:light}","html,body{margin:0;padding:0;overflow-x:hidden}","[data-tdag-shell]{position:static !important;transform:none !important;width:auto !important;height:auto !important;min-height:0 !important;max-height:none !important;overflow:visible !important;display:block !important;margin:0 !important;padding:0 !important}","[data-tdag-slide]{display:block !important;visibility:visible !important;opacity:1 !important;position:relative !important;inset:auto !important;transform:none !important;margin:0 auto !important}"].join(`
|
|
659
659
|
`);function Hy(e){return e.replace(/&/g,"&").replace(/"/g,""")}function Fle(e,t){const n=e.tagName.toLowerCase(),a=["class","id","style"].map(r=>{const s=e.getAttribute(r);return s?` ${r}="${Hy(s)}"`:""}).join("");return`<${n}${a} data-tdag-shell>${t}</${n}>`}function wT(e,t,n,a){const r=n?` class="${Hy(n)}"`:"",s=a?` style="${Hy(a)}"`:"";return`<!doctype html><html><head><meta charset="utf-8">${e}<style>${Hle}</style></head><body${r}${s}>${t}</body></html>`}async function MM(e,t){const n=await _M(e,t),a=Array.from(n.querySelectorAll('style, link[rel="stylesheet" i]')).map(u=>u.outerHTML).join(`
|
|
660
660
|
`),r=n.body?.getAttribute("class"),s=n.body?.getAttribute("style"),o=$v(n);return o?o.map((u,d)=>{const h=u.cloneNode(!0);h.setAttribute("data-tdag-slide","");let m=h.outerHTML;for(let p=u.parentElement;p&&p!==n.body&&p.tagName!=="HTML";p=p.parentElement)m=Fle(p,m);return{page:d+1,srcdoc:wT(a,m,r,s)}}):[{page:null,srcdoc:wT(a,n.body?.innerHTML??"",r,s)}]}const IM=Object.freeze(Object.defineProperty({__proto__:null,buildReaderPages:MM,detectSlides:$v,extractHtmlMaterial:Ble},Symbol.toStringTag,{value:"Module"}));function kT({att:e,onSelect:t,clipMode:n,onClipped:a,baseUrl:r}){const s=St(),[o,u]=D.useState(null),[d,h]=D.useState(!1);return D.useEffect(()=>{let m=!1;return MM(e.content,r?{baseUrl:r}:void 0).then(p=>{m||u(p)}).catch(()=>{m||h(!0)}),()=>{m=!0}},[]),d?l.jsx("p",{className:"text-sm text-ink-faint italic py-10 text-center",children:s("reader.htmlNoText")}):o?l.jsx("div",{className:"flex flex-col items-center py-6 px-4",children:o.map(m=>l.jsxs("div",{"data-page":m.page??void 0,className:"w-full max-w-[860px]",children:[m.page!=null&&l.jsxs("div",{className:"text-2xs text-ink-faint font-mono text-center select-none pt-4 pb-2",children:["— p.",m.page," —"]}),l.jsx(Ule,{srcdoc:m.srcdoc,page:m.page,onSelect:t,clipMode:n,onClipped:a,clipFailedText:s("reader.clipFailed")})]},m.page??0))}):l.jsxs("div",{className:"flex items-center justify-center gap-2 h-full min-h-[200px] text-sm text-ink-muted",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",s("reader.loading")]})}function Ule({srcdoc:e,page:t,onSelect:n,clipMode:a,onClipped:r,clipFailedText:s}){const o=D.useRef(null),u=D.useRef(null),[d,h]=D.useState(120),[m,p]=D.useState(null),[x,b]=D.useState(!1),y=()=>{const v=u.current,A=v?.contentDocument;if(!v||!A?.body)return;const T=A.body.scrollWidth||A.documentElement.scrollWidth,C=v.clientWidth;T>C+2&&(A.body.style.zoom=String(C/T)),h(Math.max(40,A.documentElement.scrollHeight+2)),A.addEventListener("mouseup",()=>{const I=v.contentWindow?.getSelection();if(!I||I.isCollapsed){n(null);return}const O=I.toString().replace(/\s+/g," ").trim();if(O.length<2)return;const _=I.getRangeAt(0).getBoundingClientRect(),S=v.getBoundingClientRect();n({text:O,page:t,x:S.left+_.left+_.width/2,y:S.top+_.bottom})})},w=v=>{const A=o.current.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(v.clientX-A.left)/A.width)),y:Math.min(1,Math.max(0,(v.clientY-A.top)/A.height))}},E=()=>{if(!m||x){p(null);return}const v=Math.min(m.x0,m.x1),A=Math.min(m.y0,m.y1),T=Math.abs(m.x1-m.x0),C=Math.abs(m.y1-m.y0);if(p(null),T<.02||C<.01)return;const I=u.current?.contentDocument;!I?.documentElement||!r||(b(!0),(async()=>{const{toCanvas:O}=await ft(async()=>{const{toCanvas:B}=await import("./index-BeoRn2gJ.js");return{toCanvas:B}},[]),_=await O(I.documentElement,{pixelRatio:2}),S=Math.floor(v*_.width),z=Math.floor(A*_.height),V=Math.max(1,Math.floor(T*_.width)),P=Math.max(1,Math.floor(C*_.height)),L=document.createElement("canvas");L.width=V,L.height=P,L.getContext("2d").drawImage(_,S,z,V,P,0,0,V,P);const Y=o.current.getBoundingClientRect(),q={left:Y.left+v*Y.width,top:Y.top+A*Y.height,width:T*Y.width,height:C*Y.height};r(t??1,[v,A,T,C],L.toDataURL("image/png"),q)})().catch(()=>We("error",s)).finally(()=>b(!1)))};return l.jsxs("div",{ref:o,className:"relative",children:[l.jsx("iframe",{ref:u,sandbox:"allow-same-origin",srcDoc:e,onLoad:y,style:{height:d},className:"w-full border-0 bg-white shadow-md rounded-sm","aria-label":t!=null?`p.${t}`:"document"}),a&&l.jsxs("div",{className:"absolute inset-0 cursor-crosshair",style:{zIndex:6},"data-clip-overlay":t??1,onMouseDown:v=>{v.preventDefault();const A=w(v);p({x0:A.x,y0:A.y,x1:A.x,y1:A.y})},onMouseMove:v=>{if(m){const A=w(v);p({...m,x1:A.x,y1:A.y})}},onMouseUp:E,onMouseLeave:()=>{m&&E()},children:[x&&l.jsx("div",{className:"absolute top-2 right-2 flex items-center gap-1.5 text-2xs text-warm bg-card/95 border border-line rounded-lg px-2 py-1 shadow-sm",children:l.jsx(nn,{size:11,strokeWidth:1.75,className:"animate-spin"})}),m&&l.jsx("div",{className:"absolute border-2 border-warm bg-warm/10 rounded-sm pointer-events-none",style:{left:`${Math.min(m.x0,m.x1)*100}%`,top:`${Math.min(m.y0,m.y1)*100}%`,width:`${Math.abs(m.x1-m.x0)*100}%`,height:`${Math.abs(m.y1-m.y0)*100}%`}})]})]})}let bb=null;function qle(){return bb||(bb=Promise.all([ft(()=>import("./pdf-gh-BrLFn.js"),[]),ft(()=>import("./pdf.worker.min-C_APr3k7.js"),[])]).then(([e,t])=>(e.GlobalWorkerOptions.workerSrc=t.default,e))),bb}function $le(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}const Wle=/<!--\s*tdag-page:(\d+)\s*-->/;function Vle(e){const t=e.split(Wle),n=[];t[0].trim()&&n.push({page:null,md:t[0]});for(let a=1;a<t.length;a+=2)n.push({page:Number(t[a]),md:t[a+1]??""});return n.length>0?n:[{page:null,md:e}]}const yb=60,ET=new Map;function Gle({onLocate:e}){const t=oe(a=>a.readerNodeId),n=se(a=>t?a.nodes.find(r=>r.id===t):void 0);return D.useEffect(()=>{t&&!n&&oe.getState().setReaderNodeId(null)},[t,n]),n?l.jsx(Yle,{node:n,onLocate:e},n.id):null}function Yle({node:e,onLocate:t}){const n=St(),a=e.data,r=a.stepKind==="file"||!a.stepKind&&(a.attachments??[]).some(ve=>ve.type==="application/pdf")?"file":a.stepKind==="link"?"link":"note",s=D.useMemo(()=>a.attachments??[],[a.attachments]),o=s.find(ve=>ve.type==="application/pdf"),u=s.find(ve=>ve.type==="text/html"),d=r==="link"?a.linkSnapshotHtml:void 0,h=D.useMemo(()=>d?{id:`link-snapshot-${e.id}`,name:a.linkTitle||a.linkUrl||"snapshot",type:"text/html",size:d.length,content:d}:null,[d,e.id,a.linkTitle,a.linkUrl]),m=D.useMemo(()=>s.filter(ve=>ve.type.startsWith("image/")),[s]),p=()=>oe.getState().setReaderNodeId(null),x=D.useMemo(()=>{if(o)return o.extractedText??"";if(r==="file"){const ve=s.filter(kt=>!kt.type.startsWith("image/")&&kt.type!=="application/pdf"),tt=ve.map(kt=>{const jt=kt.type==="text/html"?kt.extractedText??"":kt.content;return ve.length>1?`### ${kt.name}
|
|
661
661
|
|
|
@@ -671,7 +671,7 @@ ${_}`:O.question.trim();a([...n,{id:Tn(),text:S,at:new Date().toISOString(),from
|
|
|
671
671
|
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-3 text-sm text-ink resize-y focus:outline-none","data-mp-profile-text":!0}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1",children:n("mp.docHint")}),l.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[l.jsx("button",{onClick:()=>u(!1),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:n("common.cancel")}),l.jsx("button",{onClick:()=>{rW(e,r,n("mp.editedNote")),u(!1)},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white","data-mp-profile-save":!0,children:n("mp.save")})]})]}):d.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic",children:n("mp.docEmpty")}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed list-disc pl-5 max-w-[68ch]","data-mp-profile-lines":!0,children:d.map((h,m)=>{const p=H8(a,h);return l.jsxs("li",{children:[l.jsx("span",{children:h}),p&&l.jsx("span",{className:"ml-1.5 align-baseline inline-flex font-mono text-2xs text-ink-faint border border-line rounded px-1 whitespace-nowrap",title:p.was?ye(n("mp.lineWas"),{t:p.was}):void 0,"data-mp-line-note":p.evidence,children:[p.from,ti(p.at),n(ece[p.evidence])].filter(Boolean).join(" · ")})]},m)})}),a.changelog.length>0&&l.jsxs("div",{className:"mt-3 pt-2 border-t border-dashed border-line-strong text-2xs text-ink-muted space-y-0.5",children:[l.jsx("div",{className:"text-ink-faint",children:n("mp.changelog")}),a.changelog.slice(-6).reverse().map((h,m)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:ti(h.at)}),h.note]},m))]})]})}function CT({topicId:e,name:t,onClose:n,onChanged:a,onOpened:r}){const s=St(),[o,u]=D.useState(void 0),[d,h]=D.useState(null),[m,p]=D.useState(null),[x,b]=D.useState(null),[y,w]=D.useState(""),[E,v]=D.useState(null),A=D.useCallback(async()=>{const _=In();if(_)try{const[S,z]=await Promise.all([_.dossier(e),_.dossiers()]);u(S),v(z.find(V=>V.topicId===e)??null)}catch(S){p(mm(S))}},[e]);D.useEffect(()=>{A()},[A]);const T=async _=>{h(_),p(null);try{const S=_==="build"?await L2(e):_==="update"?await n7(e):await LW(e);u(S),await A(),a()}catch(S){p(mm(S))}finally{h(null)}},C=async()=>{if(x)try{const _=await PW(e,x,y.split(`
|
|
672
672
|
`));u(_),b(null),a()}catch(_){p(mm(_))}},I=async _=>{const S=o?.sources[_];!S||S.kind!=="turn"||await D2(S.open)&&r?.()},O=!!o?.builtAt&&!j2(o);return l.jsxs("div",{className:"border border-line rounded-xl bg-surface px-4 py-3 mt-3","data-mp-dossier":e,children:[l.jsxs("div",{className:"flex items-baseline gap-3 flex-wrap mb-2",children:[l.jsx("span",{className:"text-sm font-semibold text-ink",children:t}),l.jsx("span",{className:"text-2xs text-ink-faint",children:O?`${ye(s("mp.fromTurns"),{n:o.covered.length})} · ${ye(s("mp.updatedAt"),{d:ti(o.updatedAt)})}`:s("mp.notBuilt")}),l.jsx("span",{className:"flex-1"}),d?l.jsxs("span",{className:"text-xs text-accent flex items-center gap-1",children:[l.jsx(nn,{size:12,className:"animate-spin"})," ",s("mp.building")]}):l.jsxs(l.Fragment,{children:[O?l.jsxs("button",{onClick:()=>{T("update")},disabled:!E||E.newTurns===0&&E.pending===0,className:"text-xs px-2.5 py-1 rounded-lg bg-accent text-white disabled:opacity-40 flex items-center gap-1","data-mp-dossier-update":!0,children:[l.jsx(or,{size:12,strokeWidth:1.75})," ",E?.newTurns?ye(s("mp.updateN"),{n:E.newTurns}):s("mp.update")]}):l.jsxs("button",{onClick:()=>{T("build")},className:"text-xs px-2.5 py-1 rounded-lg bg-accent text-white flex items-center gap-1","data-mp-dossier-build":!0,children:[l.jsx(Hl,{size:12,strokeWidth:1.75})," ",s("mp.build")]}),O&&l.jsx("button",{onClick:()=>{T("rebuild")},className:"text-xs px-2.5 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("mp.rebuild")})]}),l.jsx("button",{onClick:n,className:"text-xs px-2 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.close")})]}),m&&l.jsx("p",{className:"text-2xs text-red-500 mb-2","data-mp-dossier-error":!0,children:m}),o===void 0?l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"}):l.jsxs("div",{className:"grid gap-3 max-w-[72ch]",children:[v0.map(_=>{const S=o?.sections[_]??[];return!S.length&&O&&x!==_?l.jsxs("div",{className:"group",children:[l.jsxs("div",{className:"text-2xs font-semibold text-ink-faint tracking-wide flex items-center gap-2",children:[s(Lm[_]),l.jsx("button",{onClick:()=>{b(_),w("")},className:"opacity-0 group-hover:opacity-100 text-accent font-normal",children:s("mp.edit")})]}),l.jsx("p",{className:"text-xs text-ink-faint italic",children:"—"})]},_):!S.length&&!O?null:l.jsxs("div",{className:"group","data-mp-dossier-section":_,children:[l.jsxs("div",{className:"text-2xs font-semibold text-ink-faint tracking-wide flex items-center gap-2",children:[s(Lm[_]),x!==_&&l.jsx("button",{onClick:()=>{b(_),w(S.map(z=>z.text).join(`
|
|
673
673
|
`))},className:"opacity-0 group-hover:opacity-100 text-accent font-normal",children:s("mp.edit")})]}),x===_?l.jsxs("div",{children:[l.jsx("textarea",{value:y,onChange:z=>w(z.target.value),rows:Math.max(3,y.split(`
|
|
674
|
-
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-2 text-sm text-ink resize-y focus:outline-none"}),l.jsxs("div",{className:"flex justify-end gap-2 mt-1",children:[l.jsx("button",{onClick:()=>b(null),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.cancel")}),l.jsx("button",{onClick:()=>{C()},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white",children:s("mp.save")})]})]}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed space-y-0.5",children:S.map((z,V)=>l.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-1.5",children:[l.jsx("span",{children:z.text}),z.src.map(P=>{const L=o.sources[P];return L?l.jsxs("button",{onClick:()=>{I(P)},title:`${L.title} · ${s("mp.sourceOpen")}`,className:"inline-flex items-center gap-0.5 font-mono text-2xs text-ink-faint border border-line rounded px-1 hover:text-accent hover:border-accent/40","data-mp-source":!0,children:[L.runner," · ",ti(L.at),L.kind==="turn"&&l.jsx(gp,{size:9})]},P):P.startsWith("filed:")?l.jsx("span",{className:"font-mono text-2xs text-ink-faint border border-line rounded px-1",children:s("mp.filedTag")},P):null})]},V))})]},_)}),!O&&!d&&l.jsx("p",{className:"text-xs text-ink-faint italic",children:E?.labeled?ye(s("mp.buildHint"),{n:E.labeled}):s("dossier.nothingToRead")}),!!o?.pending.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2","data-mp-dossier-pending":!0,children:[l.jsxs("div",{className:"text-ink-faint mb-0.5",children:[s("mp.pendingList")," · ",o.pending.length]}),o.pending.map(_=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:ti(_.at)}),_.text]},_.id))]}),!!o?.changelog.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2",children:[l.jsx("div",{className:"text-ink-faint mb-0.5",children:s("mp.changelog")}),o.changelog.slice(-6).reverse().map((_,S)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:ti(_.at)}),_.note]},S))]})]})]})}function nce({query:e,onOpened:t}){const n=St(),a=oe(j=>j.recallEnabled),r=oe(j=>j.setRecallEnabled),s=oe(j=>j.memoryEnabled),o=oe(j=>j.setMemoryEnabled),u=oe(j=>j.profile),d=oe(j=>j.memoryInbox),[h,m]=D.useState(null),[p,x]=D.useState(null),[b,y]=D.useState(null),[w,E]=D.useState(null),[v,A]=D.useState(!1),[T,C]=D.useState(!1),[I,O]=D.useState(!1),[_,S]=D.useState(null),z=kp();D.useEffect(()=>{M2()},[]);const[V,P]=D.useState(0),L=D.useCallback(()=>P(j=>j+1),[]);D.useEffect(()=>{const j=In();if(!j)return;let $=!0;return(async()=>{try{const[X,Q]=await Promise.all([j.dossiers(),j.topics()]);if(!$)return;x(X),y(Q);for(const F of X)F.built&&F.pending>=IW&&!TT.has(F.topicId)&&(TT.add(F.topicId),n7(F.topicId).then(()=>P(G=>G+1)).catch(()=>{}))}catch{$&&x([])}})(),()=>{$=!1}},[V]),D.useEffect(()=>{!I||_!==null||In()?.memories().then(j=>S(j.length)).catch(()=>S(0))},[I,_]);const Y=D.useMemo(()=>({preferences:rs(u.preferences),identity:rs(u.identity)}),[u]),q=async(j,$)=>{const X=In(),Q=d.find(F=>F.id===j);if(!(!X||!Q))try{await X.dossierPending($,{text:Q.text,...Q.from?{from:Q.from}:{}}),EE(j),We("success",ye(n("mp.filed"),{name:b?.topics.find(F=>F.id===$)?.name??""})),L()}catch(F){We("error",mm(F))}},B=e.trim().length>=2;return l.jsxs("div",{"data-memory-page":!0,children:[B&&l.jsx(kM,{phrase:e,onOpened:t,dossiers:p??[],onOpenDossier:j=>E(j)}),B&&w&&l.jsx(CT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t}),!B&&l.jsxs("div",{className:"max-w-[860px]",children:[l.jsxs("section",{className:"mb-6","data-mp-section":"settings",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.settings")}),l.jsxs("div",{className:"border-t border-line",children:[l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.recallOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.recallOnHint")})]}),l.jsx(NT,{on:a,onChange:r,testId:"recall"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.memoryOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.memoryOnHint")})]}),l.jsx(NT,{on:s,onChange:o,testId:"memory"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.judgeRow")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.judgeRowHint")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0,"judge"),className:"text-xs text-accent hover:underline","data-judge-configure":!0,children:n("mp.open")})]})]})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"you",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.you")}),l.jsx("div",{className:"border-t border-line",children:["preferences","identity"].map(j=>l.jsxs("button",{onClick:()=>m(h===j?null:j),className:`w-full grid grid-cols-[110px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${h===j?"bg-wash":""}`,"data-mp-doc":j,children:[l.jsx("span",{className:"text-sm text-ink font-medium",children:n(j==="preferences"?"mp.preferences":"mp.identity")}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:Y[j].length?Y[j].join(" · "):n("mp.docEmpty")}),l.jsx("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:u[j].updatedAt?ye(n("mp.updatedAt"),{d:ti(u[j].updatedAt)}):""})]},j))}),h&&l.jsx(tce,{kind:h,onClose:()=>m(null)})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"projects",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint",children:n("mp.projects")}),l.jsx("span",{className:"flex-1"}),z&&b&&b.topics.length>0&&l.jsxs("span",{className:"text-2xs text-ink-faint","data-mp-label-state":!0,children:[ye(n("mp.labelState"),{n:b.labeled,m:b.turns}),b.status.running?` · ${ye(n("topics.running"),{a:b.status.done,b:b.status.total})}`:""]}),z&&l.jsxs("button",{onClick:()=>A(j=>!j),className:"text-xs text-ink-muted hover:text-ink flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-wash","data-mp-edit-topics":!0,children:[l.jsx(YA,{size:12,strokeWidth:1.75})," ",n("mp.editTopics")]})]}),z?l.jsxs(l.Fragment,{children:[v&&l.jsx("div",{className:"border border-line rounded-xl px-4 pb-3 mb-3 bg-surface",children:l.jsx(Jle,{onOpened:t,onChanged:L})}),l.jsx("div",{className:"border-t border-line",children:p===null?l.jsx("div",{className:"py-3",children:l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"})}):p.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic py-2","data-mp-no-topics":!0,children:n("mp.noTopics")}):p.map(j=>l.jsxs("button",{onClick:()=>E(w===j.topicId?null:j.topicId),className:`w-full grid grid-cols-[150px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${w===j.topicId?"bg-wash":""}`,"data-mp-project":j.topicId,children:[l.jsx("span",{className:"text-sm text-ink font-medium truncate",children:j.name}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:j.built?j.lead:l.jsxs("span",{className:"text-ink-faint italic",children:[n("mp.notBuilt"),j.labeled?` · ${ye(n("mp.labeledTurns"),{n:j.labeled})}`:""]})}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap flex items-center gap-1.5",children:[j.built&&j.newTurns>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-warm/60 text-warm bg-warm/10",children:ye(n("mp.newTurns"),{n:j.newTurns})}),j.pending>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-accent/40 text-accent bg-accent/10",children:ye(n("mp.pending"),{n:j.pending})}),j.built&&ye(n("mp.updatedAt"),{d:ti(j.updatedAt)})]})]},j.topicId))}),w&&!B&&l.jsx(CT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t})]}):l.jsx("p",{className:"text-xs text-ink-faint italic border-t border-line pt-2",children:n("mp.needIndex")}),d.length>0&&l.jsx(AT,{label:ye(n("mp.inbox"),{n:d.length}),open:T,onToggle:()=>C(j=>!j),testId:"inbox",children:l.jsx("div",{className:"space-y-1.5",children:d.map(j=>l.jsxs("div",{className:"flex items-center gap-2 text-xs","data-mp-inbox-item":!0,children:[l.jsx("span",{className:"flex-1 min-w-0 text-ink truncate",children:j.text}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:[j.from?`${j.from} · `:"",ti(j.at)]}),z&&!!b?.topics.length&&l.jsxs("select",{defaultValue:"",onChange:$=>{$.target.value&&q(j.id,$.target.value)},className:"text-2xs bg-wash border border-line rounded-md px-1.5 py-0.5","data-mp-inbox-file":!0,children:[l.jsx("option",{value:"",children:n("mp.fileTo")}),b.topics.map($=>l.jsx("option",{value:$.id,children:$.name},$.id))]}),l.jsx("button",{onClick:()=>EE(j.id),className:"text-2xs text-ink-faint hover:text-red-500 px-1.5 py-0.5 rounded",children:n("mp.discard")})]},j.id))})})]}),z&&l.jsxs("section",{className:"mb-4","data-mp-section":"sources",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.sources")}),l.jsxs(AT,{label:ye(n("mp.sourcesN"),{n:1+(_??0)}),open:I,onToggle:()=>O(j=>!j),testId:"sources",children:[l.jsxs("div",{className:"text-xs text-ink-muted mb-3 flex items-center gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:n("mp.index")}),l.jsx("span",{children:b?ye(n("mp.indexLine"),{n:b.turns}):"…"})]}),l.jsx(Zle,{})]})]})]})]})}const OM="thoughtdag.atlas.watermark",Uo=e=>`${e.rootKey}:${e.rel}`;function Wv(){try{return JSON.parse(localStorage.getItem(OM)??"{}")}catch{return{}}}function np(e){localStorage.setItem(OM,JSON.stringify(e))}function ace(e){const t=Wv(),n=new Map;if(Object.keys(t).length===0)return np(Object.fromEntries(e.map(s=>[Uo(s),{mtime:s.mtime,size:s.size}]))),n;const a=new Set(e.map(Uo));let r=!1;for(const s of Object.keys(t))a.has(s)||(delete t[s],r=!0);for(const s of e){const o=t[Uo(s)];o?(s.size>o.size||s.mtime>o.mtime+1e3)&&n.set(Uo(s),{kind:"updated",deltaSize:Math.max(0,s.size-o.size)}):n.set(Uo(s),{kind:"new",deltaSize:s.size})}return r&&np(t),n}function rce(e){const t=Wv();t[Uo(e)]={mtime:e.mtime,size:e.size},np(t)}function sce(e){const t=Wv();for(const n of e)t[Uo(n)]={mtime:n.mtime,size:n.size};np(t)}const jc=Uo,vb=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),_T=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`,ice={time:(e,t)=>t.mtime-e.mtime,name:(e,t)=>e.title.localeCompare(t.title),size:(e,t)=>t.size-e.size,runner:(e,t)=>e.runner.localeCompare(t.runner)||t.mtime-e.mtime};function oce({roots:e,counts:t,onChanged:n,onClose:a}){const r=St(),s=O2(),o={"claude-projects":"Claude Code","codex-sessions":"Codex","dsh-sessions":"DeepSeek Harness","pi-sessions":"Pi"},[u,d]=D.useState(null),h=()=>{window.desktopSessions?.commandsStatus?.().then(d).catch(()=>{})};D.useEffect(h,[]);const m={"claude-code":"Claude Code",codex:"Codex",dsh:"DeepSeek Harness",pi:"Pi"},p=x=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line last:border-b-0","data-atlas-source":x.key,children:[l.jsx("input",{type:"checkbox",checked:!s.has(x.key),disabled:!x.exists,onChange:b=>{kW(x.key,!b.target.checked),n()},className:"shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink",children:o[x.key]??x.path.split("/").filter(Boolean).pop()}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:x.path})]}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:x.exists?t.get(x.key)??0:r("atlas.rootMissing")}),!x.builtin&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",onClick:()=>{window.desktopSessions.removeRoot(x.key).then(n)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x.key);return l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:a,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[440px] max-h-[80%] overflow-y-auto",onClick:x=>x.stopPropagation(),"data-atlas-sources-dialog":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r("atlas.sourcesTitle")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r("atlas.sourcesHint")})]}),e.filter(x=>x.builtin).map(p),u&&Object.values(u).some(x=>x.state!=="unavailable")&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-4 pt-3 pb-1.5 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.handoffTitle")}),Object.entries(u).filter(([,x])=>x.state!=="unavailable").map(([x,b])=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line","data-atlas-handoff":x,"data-handoff-state":b.state,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink flex items-center gap-2",children:[m[x]??x,l.jsx("code",{className:"text-2xs bg-wash border border-line rounded px-1.5 py-px font-mono",children:b.invoke})]}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:r(b.state==="installed"?"atlas.handoffOn":b.state==="outdated"?"atlas.handoffOutdated":"atlas.handoffOff")})]}),b.state!=="installed"&&l.jsx("button",{className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-2.5 py-1 rounded-lg transition-colors shrink-0","data-handoff-install":!0,onClick:()=>{(async()=>{const{confirmDialog:y}=await ft(async()=>{const{confirmDialog:v}=await Promise.resolve().then(()=>cu);return{confirmDialog:v}},void 0);if(!await y({title:Te("atlas.handoffEnableTitle"),message:ye(Te("confirm.installCommand"),{path:b.dest}),confirmLabel:Te(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}))return;const E=await window.desktopSessions.commandsInstall(x);E.ok?We("success",ye(Te("atlas.handoffInstalled"),{cmd:b.invoke}),8e3):We("error",E.error??"install failed"),h()})()},children:r(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}),(b.state==="installed"||b.state==="outdated")&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",title:r("atlas.handoffRemove"),"data-handoff-remove":!0,onClick:()=>{window.desktopSessions.commandsRemove(x).then(h)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x))]}),e.filter(x=>!x.builtin).map(p),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[l.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors",children:[l.jsx(or,{size:13,strokeWidth:1.75})," ",r("atlas.autoDetect")]}),l.jsxs("button",{onClick:()=>{window.desktopSessions.addRoot().then(x=>{x&&n()})},className:"flex items-center gap-1.5 text-sm text-accent border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-add-dir":!0,children:[l.jsx($A,{size:13,strokeWidth:1.75})," ",r("atlas.addDir")]})]})]})})}function Vv({onClose:e,onSwitched:t,focusSessionId:n,initialTab:a}){const r=St(),[s,o]=D.useState(a??"sessions"),u=!!In(),d=sn(ie=>ie.projects),h=sn(ie=>ie.projects.find(Be=>Be.id===ie.activeId)?.sourceSession?.sessionId),m=!!window.desktopSessions,[p,x]=D.useState(null),[b,y]=D.useState([]),[w,E]=D.useState(!1),[v,A]=D.useState(window.desktopSessions?null:"canvases"),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(null),[z,V]=D.useState(new Map),[P,L]=D.useState(new Map),[Y,q]=D.useState(new Map),[B,j]=D.useState(!1),$=ie=>`${ie.rootKey}|${ie.rel}`,X=ie=>q(Be=>{const Je=new Map(Be),Ht=$(ie);return Je.has(Ht)?Je.delete(Ht):Je.set(Ht,ie),Je}),Q=ie=>d.find(Be=>uy(Be).includes(ie)),[F,G]=D.useState(""),[J,K]=D.useState(new Set),[ee,ue]=D.useState("time"),[pe,be]=D.useState(!1),[ae,xe]=D.useState(!1),[Ce,ze]=D.useState(new Map),[Ie,Fe]=D.useState(null);D.useEffect(()=>{window.desktopSessions?.openTargets().then(Fe).catch(()=>{})},[]);const Ee=D.useMemo(()=>new Map((Ie?.apps??[]).map(ie=>[ie.runner,ie.name])),[Ie]),Me=async()=>{E(!0);try{y(await window.desktopSessions?.roots().catch(()=>[])??[]);const ie=await EW();if(x(ie),ze(ace(ie)),window.desktopSessions?.codexThreads?.().then(Be=>{Be&&(V(new Map(Be.filter(Je=>Je.name&&Je.sessionId).map(Je=>[Je.sessionId,Je.name]))),L(new Map(Be.filter(Je=>Je.forkedFromId&&Je.sessionId).map(Je=>[Je.sessionId,Je.forkedFromId]))))}).catch(()=>{}),n){const Be=ie.find(Je=>Je.sessionId===n);Be&&A(Be.cwd??"")}}finally{E(!1)}};D.useEffect(()=>{Me()},[]),D.useEffect(()=>{let ie=!1;const Be=()=>{ie||w||(ie=!0,setTimeout(()=>{ie=!1,Me()},2e3))};return window.addEventListener("td:sessions-changed",Be),()=>window.removeEventListener("td:sessions-changed",Be)},[w]);const De=D.useCallback(ie=>z.get(ie.sessionId)??ie.title,[z]),bt=D.useMemo(()=>(p??[]).filter(ie=>!J.has(ie.runner)&&(ae||!ie.subagent)&&(!pe||Ce.has(jc(ie)))&&(!F.trim()||De(ie).toLowerCase().includes(F.trim().toLowerCase()))),[p,J,F,pe,Ce,ae,De]),mt=D.useMemo(()=>SW(bt),[bt]),Ye=D.useMemo(()=>[...new Set((p??[]).map(ie=>ie.runner))].sort(),[p]),at=D.useMemo(()=>{const ie=new Map;for(const Be of p??[])ie.set(Be.rootKey,(ie.get(Be.rootKey)??0)+1);return ie},[p]),rt=v==="canvases"?null:mt.find(ie=>(ie.cwd??"")===(v??mt[0]?.cwd??""))??mt[0]??null,Ue=D.useMemo(()=>{if(!rt)return[];const ie=ee==="name"?(Be,Je)=>De(Be).localeCompare(De(Je)):ice[ee];return[...rt.cards].sort(ie)},[rt,ee,De]),Ct=ie=>{rce(ie),ze(Be=>{const Je=new Map(Be);return Je.delete(jc(ie)),Je})},ot=async ie=>{if(!T){C(ie.rel),Ct(ie);try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-BbbLhjvs.js");return{streamRunnerConversation:Rt}},[]),{importOrAppendConversation:Je,shellSessionReader:Ht}=await ft(async()=>{const{importOrAppendConversation:Rt,shellSessionReader:en}=await import("./canonical-BuO7_FJb.js");return{importOrAppendConversation:Rt,shellSessionReader:en}},[]),Kt=await Uc(await Be(Ht(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p),qt=await Je(Kt);if(!qt)throw new Error(Te("handoff.notASession"));qt.kind==="appended"?We("success",ye(Te("atlas.appended"),{n:qt.turns}),9e3):qt.kind==="mounted"?We("success",ye(Te(qt.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:qt.turns}),9e3):qt.kind==="opened"?We("info",Te("atlas.upToDate"),6e3):We("success",ye(Te("toast.importedChats"),{n:1,m:qt.nodeCount}),9e3),e(),t()}catch(Be){We("error",ye(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},It=async ie=>{if(!(T||Y.size<2)){C("__merge__");try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-BbbLhjvs.js");return{streamRunnerConversation:Rt}},[]),{mergeSessionsIntoProject:Je,shellSessionReader:Ht}=await ft(async()=>{const{mergeSessionsIntoProject:Rt,shellSessionReader:en}=await import("./canonical-BuO7_FJb.js");return{mergeSessionsIntoProject:Rt,shellSessionReader:en}},[]),Kt=[];for(const Rt of Y.values())Kt.push(await Uc(await Be(Ht(Rt.rootKey,Rt.rel)),Rt.rootKey,Rt.rel,p)),Ct(Rt);const qt=await Je(Kt,ie);if(!qt)throw new Error(Te("handoff.notASession"));We("success",ye(Te("atlas.merged"),{n:qt.mounted}),1e4),qt.skipped>0&&We("info",ye(Te("atlas.mergeSkippedInfo"),{n:qt.skipped}),8e3),q(new Map),e(),t()}catch(Be){We("error",ye(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},_e=async ie=>{const Be=sn.getState().projects.find(Kt=>Kt.sourceSession?.sessionId===ie.sessionId);if(!Be||T)return;const{confirmDialog:Je}=await ft(async()=>{const{confirmDialog:Kt}=await Promise.resolve().then(()=>cu);return{confirmDialog:Kt}},void 0);if(await Je({title:Te("confirm.recastTitle"),message:ye(Te("confirm.recast"),{name:Be.name}),confirmLabel:Te("confirm.recastTitle"),danger:!0})){C(ie.rel);try{const{streamRunnerConversation:Kt}=await ft(async()=>{const{streamRunnerConversation:zn}=await import("./index-BbbLhjvs.js");return{streamRunnerConversation:zn}},[]),{importOrAppendConversation:qt,shellSessionReader:Rt}=await ft(async()=>{const{importOrAppendConversation:zn,shellSessionReader:tr}=await import("./canonical-BuO7_FJb.js");return{importOrAppendConversation:zn,shellSessionReader:tr}},[]),en=await Uc(await Kt(Rt(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p);if(!en)throw new Error(Te("handoff.notASession"));const{deleteProject:Gt}=await ft(async()=>{const{deleteProject:zn}=await Promise.resolve().then(()=>Sa);return{deleteProject:zn}},void 0);if(await Gt(Be.id),!await qt(en))throw new Error(Te("handoff.notASession"));We("success",Te("atlas.recastDone"),8e3),e(),t()}catch(Kt){We("error",ye(Te("atlas.parseFailed"),{msg:Kt instanceof Error?Kt.message:String(Kt)}))}finally{C(null)}}},Ze=async(ie,Be)=>{const Je=await window.desktopSessions.openInCli(ie.runner,ie.cwd,ie.sessionId,Be).catch(()=>({opened:!1,via:"",command:""}));Je.opened&&Je.via==="app"?(await navigator.clipboard.writeText(ie.sessionId).catch(()=>{}),We("success",Te("atlas.appOpened"),9e3)):Je.opened?We("success",Te("atlas.opened")):Je.command&&(await navigator.clipboard.writeText(Je.command).catch(()=>{}),We("info",Te("atlas.cmdCopied"),9e3))};return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6","data-session-atlas":!0,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-2xl w-full max-w-[980px] h-[min(680px,90vh)] flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-base font-semibold text-ink",children:r(s==="memory"?"memory.managerTitle":"atlas.title")}),l.jsx("div",{className:"text-xs text-ink-muted mt-0.5",children:r(s==="memory"?"mp.subtitle":"atlas.subtitle")}),Ce.size>0&&l.jsxs("div",{className:"text-xs mt-1 flex items-center gap-2","data-atlas-changes":!0,children:[l.jsx("span",{className:"text-accent",children:ye(r("atlas.changesSummary"),{n:[...Ce.values()].filter(ie=>ie.kind==="new").length,m:[...Ce.values()].filter(ie=>ie.kind==="updated").length})}),l.jsx("button",{className:"text-ink-faint hover:text-ink underline decoration-dotted transition-colors",onClick:()=>{sce(p??[]),ze(new Map)},"data-atlas-mark-all":!0,children:r("atlas.markAllSeen")})]})]}),m&&Ie&&Ie.terminals.length>0&&l.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-ink-muted border border-line rounded-lg px-2.5 py-1.5 cursor-pointer",title:r("atlas.terminalChoice"),children:[l.jsx(Go,{size:14,strokeWidth:1.75}),l.jsxs("select",{value:Ie.prefs.terminal,onChange:ie=>{const Be=ie.target.value;if(Be==="__add__"){window.desktopSessions?.addTerminal().then(()=>window.desktopSessions?.openTargets().then(Fe));return}window.desktopSessions?.setOpenPrefs({terminal:Be}).then(Je=>Fe(Ht=>Ht&&{...Ht,prefs:Je}))},className:"bg-transparent focus:outline-none text-sm text-ink cursor-pointer","data-atlas-terminal-select":!0,children:[Ie.terminals.map(ie=>l.jsx("option",{value:ie.id,children:ie.name},ie.id)),Ie.canAddCustom&&l.jsx("option",{value:"__add__",children:r("atlas.otherTerminal")})]})]}),m&&l.jsxs("button",{onClick:()=>O(!0),hidden:s==="memory",className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-sources":!0,children:[l.jsx($A,{size:14,strokeWidth:1.75})," ",r("atlas.sources")]}),m&&s!=="memory"&&l.jsxs("button",{onClick:()=>{Me()},disabled:w,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors disabled:opacity-60","data-atlas-refresh":!0,children:[w?l.jsx(nn,{size:14,className:"animate-spin"}):l.jsx(or,{size:14,strokeWidth:1.75}),r(w?"atlas.scanning":"atlas.refresh")]}),l.jsx("button",{onClick:e,className:"text-ink-faint hover:text-ink p-1.5 rounded-lg hover:bg-wash transition-colors","data-atlas-close":!0,children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 border-b border-line shrink-0","data-atlas-tabs":!0,children:[l.jsx("div",{className:"flex items-center bg-wash rounded-lg p-0.5 shrink-0",children:["sessions","memory"].map(ie=>l.jsx("button",{onClick:()=>o(ie),className:`text-xs px-3 py-1 rounded-md transition-colors ${s===ie?"bg-card text-ink shadow-sm font-medium":"text-ink-muted hover:text-ink"}`,"data-atlas-tab":ie,"aria-pressed":s===ie,children:r(ie==="sessions"?"atlas.tabSessions":"atlas.tabMemory")},ie))}),u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2.5 py-1 bg-card flex-1 max-w-[520px]",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.searchPlaceholder"),className:"text-sm bg-transparent focus:outline-none w-full text-ink placeholder:text-ink-faint","data-atlas-search":!0})]})]}),s==="memory"?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4","data-atlas-memory":!0,children:l.jsx(nce,{query:u?F:"",onOpened:()=>{e(),t()}})}):l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"w-[260px] border-r border-line overflow-y-auto py-2 shrink-0",children:[l.jsx("div",{className:"px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.recent")}),d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).slice(0,6).map(ie=>l.jsxs("button",{onClick:()=>{e(),Ui(ie.id).then(t)},className:"w-full text-left px-4 py-1.5 flex items-center gap-2 text-ink hover:bg-wash transition-colors","data-atlas-recent":ie.id,children:[ie.sourceSession?.sessionId?l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner}):l.jsx(Kk,{size:13,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name})]},ie.id)),l.jsx("div",{className:"border-t border-line mt-2 pt-2 px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.folders")}),!m&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.webNoScan")}),m&&p===null&&l.jsxs("div",{className:"px-4 py-2 text-sm text-ink-faint flex items-center gap-2",children:[l.jsx(nn,{size:14,className:"animate-spin"})," ",r("atlas.scanning")]}),m&&p!==null&&mt.length===0&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.empty")}),mt.map(ie=>{const Be=ie.cwd??"",Je=v!=="canvases"&&rt===ie;return l.jsxs("button",{onClick:()=>A(Be),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${Je?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-folder":ie.name||"unfiled",children:[Je?l.jsx(lu,{size:15,strokeWidth:1.75,className:"shrink-0"}):l.jsx(AF,{size:15,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name||r("atlas.unfiled")}),(()=>{const Ht=ie.cards.filter(Kt=>Ce.has(jc(Kt))).length;return Ht>0?l.jsxs("span",{className:"text-2xs text-accent shrink-0","data-atlas-folder-changes":!0,children:["+",Ht]}):null})(),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ie.cards.length})]},Be)}),l.jsx("div",{className:"border-t border-line mt-2 pt-2",children:l.jsxs("button",{onClick:()=>A("canvases"),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${v==="canvases"?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-canvases":!0,children:[l.jsx(Kk,{size:15,strokeWidth:1.75,className:"shrink-0"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:r("atlas.myCanvases")}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:d.length})]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&F.trim().length>=2&&l.jsx(kM,{phrase:F,onOpened:()=>{e(),t()}}),v==="canvases"?l.jsxs("div",{className:"space-y-1.5",children:[d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("div",{className:"group flex items-center flex-wrap gap-2 border border-line rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer",onClick:()=>{e(),Ui(ie.id).then(t)},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium truncate",children:ie.name}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-1.5",children:[l.jsx("span",{children:vb(ie.updatedAt)}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px",children:ie.sourceSession.runner})]})]}),l.jsx("button",{title:r("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1.5 rounded transition-all shrink-0",onClick:Be=>{Be.stopPropagation(),Hm(ie.id,!0)},"data-atlas-archive":!0,children:l.jsx(el,{size:15,strokeWidth:1.75})}),!!ie.sourceSession&&uy(ie).length>0&&l.jsxs("div",{className:"w-full basis-full text-2xs text-ink-faint font-mono flex flex-wrap gap-x-3 gap-y-0.5 pt-1","data-atlas-cluster":!0,children:[ie.sourceSession.sessionId&&l.jsxs("span",{children:["◉ ",ie.sourceSession.runner," ",ie.sourceSession.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:ie.sourceSession.importedCount})]}),(ie.sourceSession.chapters??[]).map(Be=>l.jsxs("span",{children:["↳ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId)),(ie.sourceSession.branches??[]).map(Be=>l.jsxs("span",{children:["⑂ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId))]})]},ie.id)),d.some(ie=>ie.archived)&&l.jsxs("details",{className:"pt-2","data-atlas-archived-group":!0,children:[l.jsx("summary",{className:"text-2xs uppercase tracking-wide text-ink-faint cursor-pointer px-1 py-1",children:ye(r("atlas.archivedGroup"),{n:d.filter(ie=>ie.archived).length})}),l.jsx("div",{className:"space-y-1.5 mt-1.5",children:d.filter(ie=>ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("button",{title:r("atlas.restoreOpen"),onClick:()=>{Hm(ie.id,!1).then(()=>{e(),Ui(ie.id).then(t)})},className:"w-full text-left border border-dashed border-line rounded-xl px-4 py-2.5 hover:bg-wash transition-colors opacity-70 hover:opacity-100","data-atlas-archived-item":!0,children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:ie.name}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner})]}),l.jsx("div",{className:"text-2xs text-ink-faint mt-0.5",children:vb(ie.updatedAt)})]},ie.id))})]})]}):l.jsxs(l.Fragment,{children:[(p?.length??0)>0&&l.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[!u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2 py-1 bg-card",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.filterTitle"),className:"text-sm bg-transparent focus:outline-none w-[150px] text-ink placeholder:text-ink-faint","data-atlas-filter":!0})]}),Ye.map(ie=>l.jsx("button",{onClick:()=>K(Be=>{const Je=new Set(Be);return Je.has(ie)?Je.delete(ie):Je.add(ie),Je}),className:`text-2xs font-mono border rounded-lg px-2 py-1 transition-colors ${J.has(ie)?"border-line text-ink-faint line-through":"border-accent/40 text-accent bg-accent/5"}`,"data-atlas-runner-toggle":ie,children:ie},ie)),Ce.size>0&&l.jsx("button",{onClick:()=>be(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${pe?"border-accent text-white bg-accent":"border-line text-ink-muted hover:text-ink"}`,"data-atlas-only-changed":!0,children:r("atlas.onlyChanged")}),(p??[]).some(ie=>ie.subagent)&&l.jsx("button",{onClick:()=>xe(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${ae?"border-accent text-accent bg-accent/5":"border-line text-ink-faint hover:text-ink"}`,"data-atlas-show-sub":!0,children:r("atlas.showSub")}),l.jsxs("button",{onClick:()=>ue(ie=>({time:"name",name:"size",size:"runner",runner:"time"})[ie]),className:"ml-auto flex items-center gap-1.5 text-2xs text-ink-muted hover:text-ink border border-line rounded-lg px-2 py-1 hover:bg-wash transition-colors","data-atlas-sort":!0,children:[l.jsx(TH,{size:12,strokeWidth:1.75}),r(`atlas.sort${ee[0].toUpperCase()}${ee.slice(1)}`)]})]}),rt?l.jsxs(l.Fragment,{children:[rt.cwd&&l.jsxs("div",{className:"text-2xs text-ink-faint mb-3 truncate",children:[rt.cwd," · ",ye(r("atlas.sessions"),{n:rt.cards.length})]}),l.jsx("div",{className:"space-y-1.5",children:Ue.map(ie=>l.jsxs("div",{className:`group border rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer flex items-center gap-3 ${Y.has($(ie))?"border-accent/60 bg-accent/5":"border-line"}`,onClick:()=>{ot(ie)},"data-atlas-session":ie.sessionId,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:De(ie)}),P.has(ie.sessionId)&&l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0 font-mono",title:`⑂ ${P.get(ie.sessionId)}`,"data-atlas-fork":!0,children:"⑂"}),Ce.get(jc(ie))?.kind==="new"&&l.jsx("span",{className:"text-2xs text-white bg-accent rounded px-1 py-px shrink-0","data-atlas-badge":"new",children:r("atlas.badgeNew")}),Ce.get(jc(ie))?.kind==="updated"&&l.jsxs("span",{className:"text-2xs text-accent border border-accent/40 rounded px-1 py-px shrink-0","data-atlas-badge":"updated",children:["+",_T(Ce.get(jc(ie)).deltaSize)]}),ie.sessionId===h?l.jsx("span",{className:"text-2xs text-white bg-ink rounded px-1 py-px shrink-0","data-atlas-badge":"current",children:r("atlas.currentOpen")}):(()=>{const Be=Q(ie.sessionId);return Be?l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0",title:Be.name,"data-atlas-badge":"canvas",children:r("atlas.onCanvas")}):null})()]}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-2",children:[l.jsx("span",{className:"border border-line rounded px-1 py-px font-mono",children:ie.runner}),l.jsx("span",{children:vb(ie.mtime)}),l.jsx("span",{children:_T(ie.size)})]})]}),T===ie.rel?l.jsx(nn,{size:16,className:"animate-spin text-accent shrink-0"}):l.jsxs("div",{className:`${Y.has($(ie))?"":"opacity-0 group-hover:opacity-100"} transition-opacity flex items-center gap-1 shrink-0`,children:[!Q(ie.sessionId)&&!!ie.sessionId&&l.jsx("button",{title:r("atlas.pickForMerge"),className:`p-1.5 rounded transition-colors ${Y.has($(ie))?"text-accent":"text-ink-faint hover:text-accent"}`,onClick:Be=>{Be.stopPropagation(),X(ie)},"data-atlas-pick":Y.has($(ie))?"on":"off",children:Y.has($(ie))?l.jsx(BU,{size:16,strokeWidth:1.75}):l.jsx(q0,{size:16,strokeWidth:1.75})}),l.jsx("span",{title:r("atlas.import"),className:"text-ink-faint hover:text-accent p-1.5",children:l.jsx(UF,{size:16,strokeWidth:1.75})}),d.some(Be=>Be.sourceSession?.sessionId===ie.sessionId)&&l.jsx("button",{title:r("atlas.recast"),className:"text-ink-faint hover:text-red-500 p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),_e(ie)},"data-atlas-recast":!0,children:l.jsx(WA,{size:16,strokeWidth:1.75})}),!Q(ie.sessionId)&&l.jsx("button",{title:r("atlas.mountTo"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),S(ie)},"data-atlas-mount":!0,children:l.jsx(Gi,{size:16,strokeWidth:1.75})}),Ee.has(ie.runner)&&l.jsx("button",{title:ye(r("atlas.openApp"),{name:Ee.get(ie.runner)}),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"app")},"data-atlas-open-app":!0,children:l.jsx(wH,{size:16,strokeWidth:1.75})}),l.jsx("button",{title:r("atlas.openTerminal"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"terminal")},"data-atlas-open-cli":!0,children:l.jsx(Go,{size:16,strokeWidth:1.75})})]})]},ie.rel))})]}):l.jsx("div",{className:"py-16 text-center text-sm text-ink-faint",children:p===null?r("atlas.scanning"):p.length>0?r("atlas.filteredOut"):r("atlas.empty")})]})]})]}),Y.size>=2&&!B&&l.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-10 bg-surface border border-line rounded-xl shadow-lg px-4 py-2.5 flex items-center gap-3","data-atlas-merge-bar":!0,children:[l.jsx("span",{className:"text-xs text-ink-muted whitespace-nowrap",children:ye(r("atlas.mergeSelected"),{n:Y.size})}),T==="__merge__"?l.jsx(nn,{size:15,className:"animate-spin text-accent"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"text-xs bg-accent hover:bg-accent-strong text-white font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>{It()},"data-atlas-merge-new":!0,children:r("atlas.mergeNew")}),l.jsx("button",{className:"text-xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>j(!0),"data-atlas-merge-into":!0,children:r("atlas.mergeInto")})]}),l.jsx("button",{className:"text-ink-faint hover:text-ink p-1",onClick:()=>q(new Map),title:r("common.cancel"),children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),(_||B)&&l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:()=>{S(null),j(!1)},children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[400px] max-h-[70%] overflow-y-auto",onClick:ie=>ie.stopPropagation(),"data-atlas-mount-picker":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r(B?"atlas.mergeInto":"atlas.mountTo")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r(B?"atlas.mergeSelected":"atlas.mountHint").replace("{n}",String(Y.size))})]}),d.filter(ie=>!ie.archived&&ie.kind!=="paradigm").sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsx("button",{className:"w-full text-left px-4 py-2.5 text-sm text-ink hover:bg-wash transition-colors border-b border-line last:border-b-0",onClick:()=>{if(B){j(!1),It(ie.id);return}const Be=_;S(null),(async()=>{C(Be.rel);try{const{streamRunnerConversation:Je}=await ft(async()=>{const{streamRunnerConversation:en}=await import("./index-BbbLhjvs.js");return{streamRunnerConversation:en}},[]),{mountConversationToProject:Ht,shellSessionReader:Kt}=await ft(async()=>{const{mountConversationToProject:en,shellSessionReader:Gt}=await import("./canonical-BuO7_FJb.js");return{mountConversationToProject:en,shellSessionReader:Gt}},[]),qt=await Uc(await Je(Kt(Be.rootKey,Be.rel)),Be.rootKey,Be.rel,p),Rt=await Ht(qt,ie.id);if(!Rt)throw new Error(Te("handoff.notASession"));We("success",ye(Te("atlas.mountedChapter"),{n:Rt.kind==="mounted"||Rt.kind==="appended"?Rt.turns:0}),9e3),e(),t()}catch(Je){We("error",ye(Te("atlas.parseFailed"),{msg:Je instanceof Error?Je.message:String(Je)}))}finally{C(null)}})()},children:ie.name},ie.id))]})}),I&&l.jsx(oce,{roots:b,counts:at,onChanged:()=>{Me()},onClose:()=>O(!1)})]})}),document.body)}function lce(){const e=St(),t=oe(a=>!!a.harnessHost?.bar);if(!R$||t)return null;const n=()=>window.parent.postMessage({source:"dsh-thoughtdag",type:"td:close"},window.location.origin);return l.jsxs("div",{className:"bg-card/90 backdrop-blur border border-line rounded-xl p-0.5 shadow-sm flex items-center",role:"group","aria-label":"view switch","data-harness-view-switch":!0,children:[l.jsx("button",{type:"button",onClick:n,className:"h-8 px-3 rounded-[10px] text-xs font-semibold text-ink-muted hover:bg-wash hover:text-ink transition-colors whitespace-nowrap","data-view":"dialog","aria-pressed":!1,children:e("harness.viewChat")}),l.jsx("button",{type:"button",className:"h-8 px-3 rounded-[10px] text-xs font-semibold bg-ink text-card whitespace-nowrap cursor-default","data-view":"map","aria-pressed":!0,children:e("harness.viewMap")})]})}function cce({conversations:e,onClose:t,onDone:n}){const a=St(),[r,s]=D.useState(new Set),[o,u]=D.useState(!1),d=p=>{s(x=>{const b=new Set(x);return b.has(p)?b.delete(p):b.add(p),b})},h=r.size===e.length,m=async()=>{r.size===0||o||(u(!0),await pG([...r].sort((p,x)=>p-x).map(p=>e[p])),u(!1),n())};return l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:t,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-full max-w-lg max-h-[80vh] flex flex-col",onClick:p=>p.stopPropagation(),children:[l.jsxs("div",{className:"px-6 py-4 border-b border-line flex items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-base font-semibold text-ink",children:a("import.title")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1 leading-relaxed",children:a("import.subtitle")})]}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0 mt-0.5",children:l.jsx(cn,{size:16,strokeWidth:1.75})})]}),l.jsx("div",{className:"px-6 py-2 border-b border-line/60",children:l.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-muted cursor-pointer select-none py-1",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:()=>s(h?new Set:new Set(e.map((p,x)=>x))),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5"}),a("import.selectAll"),l.jsx("span",{className:"ml-auto text-2xs text-ink-faint uppercase tracking-wider",children:e[0]?.source})]})}),l.jsx("ul",{className:"flex-1 overflow-y-auto py-1",children:e.map((p,x)=>l.jsx("li",{children:l.jsxs("label",{className:"flex items-center gap-3 px-6 py-2 hover:bg-wash transition-colors cursor-pointer select-none",children:[l.jsx("input",{type:"checkbox",checked:r.has(x),onChange:()=>d(x),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5 shrink-0"}),l.jsx(qA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"text-sm text-ink truncate flex-1",children:p.title}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ye(a("import.messages"),{n:p.messageCount})})]})},x))}),l.jsxs("div",{className:"px-6 py-4 border-t border-line flex justify-end gap-2",children:[l.jsx("button",{onClick:t,className:"text-xs text-ink-muted hover:text-ink px-4 py-2 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")}),l.jsx("button",{onClick:()=>{m()},disabled:r.size===0||o,className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors disabled:opacity-30",children:o?"…":ye(a("import.confirm"),{n:r.size})})]})]})})}function uce(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return Te("switcher.justNow");if(n<60)return ye(Te("switcher.minAgo"),{n});const a=Math.floor(n/60);if(a<24)return ye(Te("switcher.hourAgo"),{n:a});const r=Math.floor(a/24);return r<30?ye(Te("switcher.dayAgo"),{n:r}):new Date(e).toLocaleDateString(Da.getState().lang==="zh"?"zh-CN":"en-US")}function dce({onSwitched:e}){const t=St(),n=sn(S=>S.projects),a=sn(S=>S.activeId),r=sn(S=>S.switching),s=n.find(S=>S.id===a)?.kind==="paradigm",[o,u]=D.useState(!1),[d,h]=D.useState(null),[m,p]=D.useState(!1),[x,b]=D.useState(void 0),[y,w]=D.useState(null),[E,v]=D.useState(""),A=D.useRef(null),T=D.useRef(null),C=n.find(S=>S.id===a),I=n.filter(S=>!S.archived).sort((S,z)=>z.updatedAt-S.updatedAt).slice(0,7),O=async S=>{const{canvasUniqueness:z}=await ft(async()=>{const{canvasUniqueness:Y}=await import("./canonical-BuO7_FJb.js");return{canvasUniqueness:Y}},[]),V=await z(S.id),P=V==="native"?"confirm.deleteNative":V==="diverged-mirror"?"confirm.deleteDiverged":"confirm.deletePristine";await ri({title:Te("confirm.deleteCanvasTitle"),message:ye(Te(P),{name:S.name}),confirmLabel:Te("common.delete"),danger:V!=="pristine-mirror"})&&B7(S.id).then(e)};D.useEffect(()=>{if(!o)return;const S=z=>{T.current?.contains(z.target)||u(!1)};return window.addEventListener("mousedown",S),()=>window.removeEventListener("mousedown",S)},[o]);const _=async S=>{u(!1),await Ui(S),e(),ft(()=>import("./canonical-BuO7_FJb.js"),[]).then(z=>z.unsubscribeOrphanedSessions()),ft(()=>Promise.resolve().then(()=>Y8),void 0).then(z=>z.sweepRecentSessions())};return l.jsxs("div",{ref:T,className:"absolute top-4 left-4 z-20",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{onClick:()=>u(!o),disabled:r,className:"bg-card/90 backdrop-blur border border-line rounded-xl px-3.5 py-2 shadow-sm hover:bg-wash transition-colors flex items-center gap-2 text-sm text-ink max-w-[240px] disabled:opacity-60",children:[r?l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin shrink-0 text-accent"}):s?l.jsx(cF,{size:16,strokeWidth:1.75,className:"shrink-0 text-accent"}):l.jsx(lu,{size:16,strokeWidth:1.75,className:"shrink-0 text-ink-muted"}),l.jsx("span",{className:"truncate font-medium",children:C?.name??"…"}),l.jsx(cr,{size:14,strokeWidth:1.75,className:"shrink-0 text-ink-faint"})]}),l.jsx(lce,{}),!!C?.sourceSession?.sessionId&&(()=>{const S=jm.size>0&&!jm.has(C.sourceSession.sessionId);return l.jsxs("button",{title:S?Te("switcher.mirrorBadgeGone"):ye(Te("switcher.mirrorBadge"),{runner:C.sourceSession.runner}),onClick:()=>{b(C.sourceSession.sessionId),p(!0)},className:`bg-card/90 backdrop-blur border border-line rounded-xl px-2 py-2 shadow-sm hover:bg-wash transition-colors text-2xs font-mono flex items-center gap-1 ${S?"text-ink-faint/50 line-through decoration-1":"text-ink-faint hover:text-accent"}`,"data-twin-badge":S?"unreachable":"live",children:["⇄ ",C.sourceSession.runner]})})()]}),o&&l.jsxs("div",{className:"mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1.5 w-[320px] animate-fade-in",children:[l.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:I.map(S=>l.jsx("div",{className:`group flex items-center gap-1 px-3 py-2 hover:bg-wash cursor-pointer transition-colors ${S.id===a?"bg-accent/5":""}`,onClick:()=>{y!==S.id&&S.id!==a&&_(S.id)},children:y===S.id?l.jsx("input",{autoFocus:!0,value:E,onChange:z=>v(z.target.value),onClick:z=>z.stopPropagation(),onKeyDown:z=>{z.key==="Enter"&&!lr(z)&&E.trim()&&(z7(S.id,E.trim()),w(null)),z.key==="Escape"&&w(null)},onBlur:()=>w(null),className:"flex-1 text-sm text-ink border border-accent/40 rounded-lg px-2 py-1 bg-surface focus:outline-none"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:`text-sm truncate ${S.id===a?"text-accent font-medium":"text-ink"}`,children:S.name}),l.jsxs("div",{className:"text-2xs text-ink-faint flex items-center gap-1.5",children:[l.jsx("span",{children:uce(S.updatedAt)}),!!S.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px","data-mirror-mark":!0,children:S.sourceSession.runner})]})]}),l.jsx("button",{title:t("switcher.rename"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-ink p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),w(S.id),v(S.name)},children:l.jsx(Gl,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("common.delete"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-red-500 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),O(S)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),Hm(S.id,!0).then(e)},"data-archive-canvas":!0,children:l.jsx(el,{size:14,strokeWidth:1.75})})]})},S.id))}),l.jsxs("div",{className:"border-t border-line mt-1 pt-1",children:[l.jsxs("button",{onClick:()=>{u(!1),Np().then(e)},className:"w-full text-left px-3 py-2 text-sm text-accent hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(U0,{size:15,strokeWidth:1.75})," ",t("switcher.newCanvas")]}),l.jsxs("button",{onClick:()=>A.current?.click(),className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(ZU,{size:15,strokeWidth:1.75})," ",t("switcher.importBackup")]}),l.jsxs("button",{onClick:()=>{u(!1),p(!0)},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-open-atlas":!0,children:[l.jsx(tU,{size:15,strokeWidth:1.75})," ",t("switcher.allCanvases")]}),window.desktop&&l.jsxs("button",{onClick:()=>{u(!1),window.desktop.checkForUpdates()},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-check-updates":!0,children:[l.jsx(or,{size:15,strokeWidth:1.75})," ",t("update.checkMenu"),l.jsxs("span",{className:"ml-auto text-2xs text-ink-faint",children:["v",new URLSearchParams(window.location.search).get("dv")]})]}),l.jsx("input",{ref:A,type:"file",accept:".json,.jsonl,application/json",className:"hidden",onChange:S=>{const z=S.target.files?.[0];z&&fG(z).then(V=>{V.kind==="own"&&V.ok?(u(!1),e()):V.kind==="chat"&&(u(!1),h(V.conversations))}).catch(V=>{We("error",ye(Te("toast.importFailedGeneric"),{msg:V instanceof Error?V.message:String(V)}))}),S.target.value=""}})]})]}),d&&l.jsx(cce,{conversations:d,onClose:()=>h(null),onDone:()=>{h(null),e()}}),m&&l.jsx(Vv,{onClose:()=>{p(!1),b(void 0)},onSwitched:e,focusSessionId:x})]})}const hce="JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUiA0IDAgUl0gL0NvdW50IDIgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvQ29udGVudHMgNSAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNyAwIFIgL0YyIDggMCBSID4+ID4+ID4+CmVuZG9iago0IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTk1IDg0Ml0gL0NvbnRlbnRzIDYgMCBSIC9SZXNvdXJjZXMgPDwgL0ZvbnQgPDwgL0YxIDcgMCBSIC9GMiA4IDAgUiA+PiA+PiA+PgplbmRvYmoKNSAwIG9iago8PCAvTGVuZ3RoIDExMTIgPj4Kc3RyZWFtCkJUCi9GMiAxOSBUZiAxIDAgMCAxIDY0IDcyNS4wIFRtIChXaHkgU2F2ZWQgQXJ0aWNsZXMgU3RheSBVbnJlYWQpIFRqCi9GMSAxMSBUZiAxIDAgMCAxIDY0IDcwOC4wIFRtIChBIHNob3J0IGJyaWVmIG9uIGRpZ2l0YWwgaG9hcmRpbmcgYW5kIHRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjIgMTMgVGYgMSAwIDAgMSA2NCA2NjkuMCBUbSAoMS4gVGhlIHBoZW5vbWVub24pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjUxLjUgVG0gKFJlYWQtaXQtbGF0ZXIgc2VydmljZXMgcmVwb3J0IHRoYXQgbW9zdCBzYXZlZCBpdGVtcyBhcmUgbmV2ZXIpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjM0LjAgVG0gKHJlb3BlbmVkLiBBY3Jvc3MgcHVibGlzaGVkIHVzYWdlIHN0dWRpZXMsIHRoZSBzaGFyZSBvZiBzYXZlZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA2MTYuNSBUbSAoYXJ0aWNsZXMgdGhhdCBnZXQgYSBzZWNvbmQgdmlzaXQgaXMgc21hbGwsIGFuZCBjb21wbGV0aW9uIHJhdGVzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU5OS4wIFRtIChhcmUgc21hbGxlciBzdGlsbC4gVGhlIGFyY2hpdmUgZ3Jvd3M7IHRoZSByZWFkaW5nIGRvZXMgbm90LikgVGoKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNTYwLjAgVG0gKDIuIFRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU0Mi41IFRtIChDb2xsZWN0aW5nIHByb2R1Y2VzIGFuIGltbWVkaWF0ZSBzZW5zZSBvZiBwcm9ncmVzcyB3aGlsZSB0aGUpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTI1LjAgVG0gKHVuZGVyc3RhbmRpbmcgaXQgcHJvbWlzZXMgaXMgZGVmZXJyZWQuIFNhdmluZyBhIHRleHQgZmVlbHMgbGlrZSkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1MDcuNSBUbSAoYSBmaXJzdCBzdGVwIG9mIHJlYWRpbmcgaXQsIGJ1dCBubyBwYXJ0IG9mIHRoZSByZWFkaW5nIGhhcykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA0OTAuMCBUbSAoaGFwcGVuZWQuKSBUagovRjIgMTEuNSBUZiAxIDAgMCAxIDY0IDQ3Mi41IFRtIChUaGUgYWN0IG9mIHNhdmluZyBpcyBtaXN0YWtlbiBmb3IgdGhlIGFjdCBvZiBsZWFybmluZy4pIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNiAwIG9iago8PCAvTGVuZ3RoIDkwOCA+PgpzdHJlYW0KQlQKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNzI1LjAgVG0gKDMuIFdoeSBpdCBwZXJzaXN0cykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA3MDcuNSBUbSAoVGhlIGNvc3RzIGFyZSBhc3ltbWV0cmljOiBzYXZpbmcgdGFrZXMgb25lIHNlY29uZCBhbmQgcGF5cyBvdXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjkwLjAgVG0gKGEgc21hbGwgcmV3YXJkIG5vdzsgcmVhZGluZyB0YWtlcyBhbiBob3VyIGFuZCBwYXlzIG91dCBsYXRlci4pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjcyLjUgVG0gKEhhYml0cyBmb2xsb3cgdGhlIGNoZWFwZXIgbG9vcCwgc28gbGlicmFyaWVzIGluZmxhdGUgYnkgZGVmYXVsdC4pIFRqCi9GMiAxMyBUZiAxIDAgMCAxIDY0IDYzMy41IFRtICg0LiBXaGF0IGhlbHBzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDYxNi4wIFRtIChJbnRlcnZlbnRpb25zIHRoYXQgd29yayBtb3ZlIHByb2Nlc3NpbmcgdG8gdGhlIG1vbWVudCBvZiBjYXB0dXJlOikgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1OTguNSBUbSAod3JpdGUgb25lIGxpbmUgaW4geW91ciBvd24gd29yZHMgYWJvdXQgd2h5IHRoZSBpdGVtIG1hdHRlcnMsIGFuZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1ODEuMCBUbSAoc2NoZWR1bGUgYSByZXZpZXcgcGFzcyBpbnN0ZWFkIG9mIHRydXN0aW5nIHRoZSBhcmNoaXZlIHRvKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU2My41IFRtIChyZXN1cmZhY2UgaXQuKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDUzMi4wIFRtIChBIHNtYWxsZXIgbGlicmFyeSB0aGF0IGdldHMgcHJvY2Vzc2VkIGJlYXRzIGEgY29tcGxldGUgb25lIHRoYXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTE0LjUgVG0gKGRvZXMgbm90LikgVGoKRVQKZW5kc3RyZWFtCmVuZG9iago3IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKOCAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EtQm9sZCA+PgplbmRvYmoKeHJlZgowIDkKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDEyMSAwMDAwMCBuIAowMDAwMDAwMjU3IDAwMDAwIG4gCjAwMDAwMDAzOTMgMDAwMDAgbiAKMDAwMDAwMTU1NyAwMDAwMCBuIAowMDAwMDAyNTE2IDAwMDAwIG4gCjAwMDAwMDI1ODYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA5IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoyNjYxCiUlRU9G",fce=`<!-- tdag-page:1 -->
|
|
674
|
+
`).length+1),className:"w-full bg-wash border border-accent rounded-lg p-2 text-sm text-ink resize-y focus:outline-none"}),l.jsxs("div",{className:"flex justify-end gap-2 mt-1",children:[l.jsx("button",{onClick:()=>b(null),className:"text-xs px-3 py-1 rounded-lg text-ink-muted hover:bg-wash",children:s("common.cancel")}),l.jsx("button",{onClick:()=>{C()},className:"text-xs px-3 py-1 rounded-lg bg-accent text-white",children:s("mp.save")})]})]}):l.jsx("ul",{className:"text-sm text-ink leading-relaxed space-y-0.5",children:S.map((z,V)=>l.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-1.5",children:[l.jsx("span",{children:z.text}),z.src.map(P=>{const L=o.sources[P];return L?l.jsxs("button",{onClick:()=>{I(P)},title:`${L.title} · ${s("mp.sourceOpen")}`,className:"inline-flex items-center gap-0.5 font-mono text-2xs text-ink-faint border border-line rounded px-1 hover:text-accent hover:border-accent/40","data-mp-source":!0,children:[L.runner," · ",ti(L.at),L.kind==="turn"&&l.jsx(gp,{size:9})]},P):P.startsWith("filed:")?l.jsx("span",{className:"font-mono text-2xs text-ink-faint border border-line rounded px-1",children:s("mp.filedTag")},P):null})]},V))})]},_)}),!O&&!d&&l.jsx("p",{className:"text-xs text-ink-faint italic",children:E?.labeled?ye(s("mp.buildHint"),{n:E.labeled}):s("dossier.nothingToRead")}),!!o?.pending.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2","data-mp-dossier-pending":!0,children:[l.jsxs("div",{className:"text-ink-faint mb-0.5",children:[s("mp.pendingList")," · ",o.pending.length]}),o.pending.map(_=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:ti(_.at)}),_.text]},_.id))]}),!!o?.changelog.length&&l.jsxs("div",{className:"text-2xs text-ink-muted border-t border-dashed border-line-strong pt-2",children:[l.jsx("div",{className:"text-ink-faint mb-0.5",children:s("mp.changelog")}),o.changelog.slice(-6).reverse().map((_,S)=>l.jsxs("div",{children:[l.jsx("span",{className:"font-mono text-ink mr-2",children:ti(_.at)}),_.note]},S))]})]})]})}function nce({query:e,onOpened:t}){const n=St(),a=oe(j=>j.recallEnabled),r=oe(j=>j.setRecallEnabled),s=oe(j=>j.memoryEnabled),o=oe(j=>j.setMemoryEnabled),u=oe(j=>j.profile),d=oe(j=>j.memoryInbox),[h,m]=D.useState(null),[p,x]=D.useState(null),[b,y]=D.useState(null),[w,E]=D.useState(null),[v,A]=D.useState(!1),[T,C]=D.useState(!1),[I,O]=D.useState(!1),[_,S]=D.useState(null),z=kp();D.useEffect(()=>{M2()},[]);const[V,P]=D.useState(0),L=D.useCallback(()=>P(j=>j+1),[]);D.useEffect(()=>{const j=In();if(!j)return;let $=!0;return(async()=>{try{const[X,Q]=await Promise.all([j.dossiers(),j.topics()]);if(!$)return;x(X),y(Q);for(const F of X)F.built&&F.pending>=IW&&!TT.has(F.topicId)&&(TT.add(F.topicId),n7(F.topicId).then(()=>P(G=>G+1)).catch(()=>{}))}catch{$&&x([])}})(),()=>{$=!1}},[V]),D.useEffect(()=>{!I||_!==null||In()?.memories().then(j=>S(j.length)).catch(()=>S(0))},[I,_]);const Y=D.useMemo(()=>({preferences:rs(u.preferences),identity:rs(u.identity)}),[u]),q=async(j,$)=>{const X=In(),Q=d.find(F=>F.id===j);if(!(!X||!Q))try{await X.dossierPending($,{text:Q.text,...Q.from?{from:Q.from}:{}}),EE(j),We("success",ye(n("mp.filed"),{name:b?.topics.find(F=>F.id===$)?.name??""})),L()}catch(F){We("error",mm(F))}},B=e.trim().length>=2;return l.jsxs("div",{"data-memory-page":!0,children:[B&&l.jsx(kM,{phrase:e,onOpened:t,dossiers:p??[],onOpenDossier:j=>E(j)}),B&&w&&l.jsx(CT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t}),!B&&l.jsxs("div",{className:"max-w-[860px]",children:[l.jsxs("section",{className:"mb-6","data-mp-section":"settings",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.settings")}),l.jsxs("div",{className:"border-t border-line",children:[l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.recallOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.recallOnHint")})]}),l.jsx(NT,{on:a,onChange:r,testId:"recall"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.memoryOn")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.memoryOnHint")})]}),l.jsx(NT,{on:s,onChange:o,testId:"memory"})]}),l.jsxs("div",{className:"flex items-center gap-4 py-2.5 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium",children:n("mp.judgeRow")}),l.jsx("div",{className:"text-2xs text-ink-faint",children:n("mp.judgeRowHint")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0,"judge"),className:"text-xs text-accent hover:underline","data-judge-configure":!0,children:n("mp.open")})]})]})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"you",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.you")}),l.jsx("div",{className:"border-t border-line",children:["preferences","identity"].map(j=>l.jsxs("button",{onClick:()=>m(h===j?null:j),className:`w-full grid grid-cols-[110px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${h===j?"bg-wash":""}`,"data-mp-doc":j,children:[l.jsx("span",{className:"text-sm text-ink font-medium",children:n(j==="preferences"?"mp.preferences":"mp.identity")}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:Y[j].length?Y[j].join(" · "):n("mp.docEmpty")}),l.jsx("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:u[j].updatedAt?ye(n("mp.updatedAt"),{d:ti(u[j].updatedAt)}):""})]},j))}),h&&l.jsx(tce,{kind:h,onClose:()=>m(null)})]}),l.jsxs("section",{className:"mb-6","data-mp-section":"projects",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint",children:n("mp.projects")}),l.jsx("span",{className:"flex-1"}),z&&b&&b.topics.length>0&&l.jsxs("span",{className:"text-2xs text-ink-faint","data-mp-label-state":!0,children:[ye(n("mp.labelState"),{n:b.labeled,m:b.turns}),b.status.running?` · ${ye(n("topics.running"),{a:b.status.done,b:b.status.total})}`:""]}),z&&l.jsxs("button",{onClick:()=>A(j=>!j),className:"text-xs text-ink-muted hover:text-ink flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-wash","data-mp-edit-topics":!0,children:[l.jsx(YA,{size:12,strokeWidth:1.75})," ",n("mp.editTopics")]})]}),z?l.jsxs(l.Fragment,{children:[v&&l.jsx("div",{className:"border border-line rounded-xl px-4 pb-3 mb-3 bg-surface",children:l.jsx(Jle,{onOpened:t,onChanged:L})}),l.jsx("div",{className:"border-t border-line",children:p===null?l.jsx("div",{className:"py-3",children:l.jsx(nn,{size:14,className:"animate-spin text-ink-faint"})}):p.length===0?l.jsx("p",{className:"text-xs text-ink-faint italic py-2","data-mp-no-topics":!0,children:n("mp.noTopics")}):p.map(j=>l.jsxs("button",{onClick:()=>E(w===j.topicId?null:j.topicId),className:`w-full grid grid-cols-[150px_minmax(0,1fr)_auto] gap-3 items-center py-2.5 border-b border-line text-left hover:bg-wash -mx-2 px-2 ${w===j.topicId?"bg-wash":""}`,"data-mp-project":j.topicId,children:[l.jsx("span",{className:"text-sm text-ink font-medium truncate",children:j.name}),l.jsx("span",{className:"text-xs text-ink-muted truncate",children:j.built?j.lead:l.jsxs("span",{className:"text-ink-faint italic",children:[n("mp.notBuilt"),j.labeled?` · ${ye(n("mp.labeledTurns"),{n:j.labeled})}`:""]})}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap flex items-center gap-1.5",children:[j.built&&j.newTurns>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-warm/60 text-warm bg-warm/10",children:ye(n("mp.newTurns"),{n:j.newTurns})}),j.pending>0&&l.jsx("span",{className:"px-1.5 py-px rounded-full border border-accent/40 text-accent bg-accent/10",children:ye(n("mp.pending"),{n:j.pending})}),j.built&&ye(n("mp.updatedAt"),{d:ti(j.updatedAt)})]})]},j.topicId))}),w&&!B&&l.jsx(CT,{topicId:w,name:p?.find(j=>j.topicId===w)?.name??"",onClose:()=>E(null),onChanged:L,onOpened:t})]}):l.jsx("p",{className:"text-xs text-ink-faint italic border-t border-line pt-2",children:n("mp.needIndex")}),d.length>0&&l.jsx(AT,{label:ye(n("mp.inbox"),{n:d.length}),open:T,onToggle:()=>C(j=>!j),testId:"inbox",children:l.jsx("div",{className:"space-y-1.5",children:d.map(j=>l.jsxs("div",{className:"flex items-center gap-2 text-xs","data-mp-inbox-item":!0,children:[l.jsx("span",{className:"flex-1 min-w-0 text-ink truncate",children:j.text}),l.jsxs("span",{className:"text-2xs text-ink-faint whitespace-nowrap",children:[j.from?`${j.from} · `:"",ti(j.at)]}),z&&!!b?.topics.length&&l.jsxs("select",{defaultValue:"",onChange:$=>{$.target.value&&q(j.id,$.target.value)},className:"text-2xs bg-wash border border-line rounded-md px-1.5 py-0.5","data-mp-inbox-file":!0,children:[l.jsx("option",{value:"",children:n("mp.fileTo")}),b.topics.map($=>l.jsx("option",{value:$.id,children:$.name},$.id))]}),l.jsx("button",{onClick:()=>EE(j.id),className:"text-2xs text-ink-faint hover:text-red-500 px-1.5 py-0.5 rounded",children:n("mp.discard")})]},j.id))})})]}),z&&l.jsxs("section",{className:"mb-4","data-mp-section":"sources",children:[l.jsx("h4",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:n("mp.sources")}),l.jsxs(AT,{label:ye(n("mp.sourcesN"),{n:1+(_??0)}),open:I,onToggle:()=>O(j=>!j),testId:"sources",children:[l.jsxs("div",{className:"text-xs text-ink-muted mb-3 flex items-center gap-3",children:[l.jsx("span",{className:"text-ink font-medium",children:n("mp.index")}),l.jsx("span",{children:b?ye(n("mp.indexLine"),{n:b.turns}):"…"})]}),l.jsx(Zle,{})]})]})]})]})}const OM="thoughtdag.atlas.watermark",Uo=e=>`${e.rootKey}:${e.rel}`;function Wv(){try{return JSON.parse(localStorage.getItem(OM)??"{}")}catch{return{}}}function np(e){localStorage.setItem(OM,JSON.stringify(e))}function ace(e){const t=Wv(),n=new Map;if(Object.keys(t).length===0)return np(Object.fromEntries(e.map(s=>[Uo(s),{mtime:s.mtime,size:s.size}]))),n;const a=new Set(e.map(Uo));let r=!1;for(const s of Object.keys(t))a.has(s)||(delete t[s],r=!0);for(const s of e){const o=t[Uo(s)];o?(s.size>o.size||s.mtime>o.mtime+1e3)&&n.set(Uo(s),{kind:"updated",deltaSize:Math.max(0,s.size-o.size)}):n.set(Uo(s),{kind:"new",deltaSize:s.size})}return r&&np(t),n}function rce(e){const t=Wv();t[Uo(e)]={mtime:e.mtime,size:e.size},np(t)}function sce(e){const t=Wv();for(const n of e)t[Uo(n)]={mtime:n.mtime,size:n.size};np(t)}const jc=Uo,vb=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),_T=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`,ice={time:(e,t)=>t.mtime-e.mtime,name:(e,t)=>e.title.localeCompare(t.title),size:(e,t)=>t.size-e.size,runner:(e,t)=>e.runner.localeCompare(t.runner)||t.mtime-e.mtime};function oce({roots:e,counts:t,onChanged:n,onClose:a}){const r=St(),s=O2(),o={"claude-projects":"Claude Code","codex-sessions":"Codex","dsh-sessions":"DeepSeek Harness","pi-sessions":"Pi"},[u,d]=D.useState(null),h=()=>{window.desktopSessions?.commandsStatus?.().then(d).catch(()=>{})};D.useEffect(h,[]);const m={"claude-code":"Claude Code",codex:"Codex",dsh:"DeepSeek Harness",pi:"Pi"},p=x=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line last:border-b-0","data-atlas-source":x.key,children:[l.jsx("input",{type:"checkbox",checked:!s.has(x.key),disabled:!x.exists,onChange:b=>{kW(x.key,!b.target.checked),n()},className:"shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink",children:o[x.key]??x.path.split("/").filter(Boolean).pop()}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:x.path})]}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:x.exists?t.get(x.key)??0:r("atlas.rootMissing")}),!x.builtin&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",onClick:()=>{window.desktopSessions.removeRoot(x.key).then(n)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x.key);return l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:a,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[440px] max-h-[80%] overflow-y-auto",onClick:x=>x.stopPropagation(),"data-atlas-sources-dialog":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r("atlas.sourcesTitle")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r("atlas.sourcesHint")})]}),e.filter(x=>x.builtin).map(p),u&&Object.values(u).some(x=>x.state!=="unavailable")&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"px-4 pt-3 pb-1.5 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.handoffTitle")}),Object.entries(u).filter(([,x])=>x.state!=="unavailable").map(([x,b])=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-line","data-atlas-handoff":x,"data-handoff-state":b.state,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink flex items-center gap-2",children:[m[x]??x,l.jsx("code",{className:"text-2xs bg-wash border border-line rounded px-1.5 py-px font-mono",children:b.invoke})]}),l.jsx("div",{className:"text-2xs text-ink-faint truncate",children:r(b.state==="installed"?"atlas.handoffOn":b.state==="outdated"?"atlas.handoffOutdated":"atlas.handoffOff")})]}),b.state!=="installed"&&l.jsx("button",{className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-2.5 py-1 rounded-lg transition-colors shrink-0","data-handoff-install":!0,onClick:()=>{(async()=>{const{confirmDialog:y}=await ft(async()=>{const{confirmDialog:v}=await Promise.resolve().then(()=>cu);return{confirmDialog:v}},void 0);if(!await y({title:Te("atlas.handoffEnableTitle"),message:ye(Te("confirm.installCommand"),{path:b.dest}),confirmLabel:Te(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}))return;const E=await window.desktopSessions.commandsInstall(x);E.ok?We("success",ye(Te("atlas.handoffInstalled"),{cmd:b.invoke}),8e3):We("error",E.error??"install failed"),h()})()},children:r(b.state==="outdated"?"atlas.handoffUpdate":"atlas.handoffEnable")}),(b.state==="installed"||b.state==="outdated")&&l.jsx("button",{className:"text-ink-faint hover:text-red-500 p-1 rounded transition-colors shrink-0",title:r("atlas.handoffRemove"),"data-handoff-remove":!0,onClick:()=>{window.desktopSessions.commandsRemove(x).then(h)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})})]},x))]}),e.filter(x=>!x.builtin).map(p),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",children:[l.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors",children:[l.jsx(or,{size:13,strokeWidth:1.75})," ",r("atlas.autoDetect")]}),l.jsxs("button",{onClick:()=>{window.desktopSessions.addRoot().then(x=>{x&&n()})},className:"flex items-center gap-1.5 text-sm text-accent border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-add-dir":!0,children:[l.jsx($A,{size:13,strokeWidth:1.75})," ",r("atlas.addDir")]})]})]})})}function Vv({onClose:e,onSwitched:t,focusSessionId:n,initialTab:a}){const r=St(),[s,o]=D.useState(a??"sessions"),u=!!In(),d=sn(ie=>ie.projects),h=sn(ie=>ie.projects.find(Be=>Be.id===ie.activeId)?.sourceSession?.sessionId),m=!!window.desktopSessions,[p,x]=D.useState(null),[b,y]=D.useState([]),[w,E]=D.useState(!1),[v,A]=D.useState(window.desktopSessions?null:"canvases"),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(null),[z,V]=D.useState(new Map),[P,L]=D.useState(new Map),[Y,q]=D.useState(new Map),[B,j]=D.useState(!1),$=ie=>`${ie.rootKey}|${ie.rel}`,X=ie=>q(Be=>{const Je=new Map(Be),Ht=$(ie);return Je.has(Ht)?Je.delete(Ht):Je.set(Ht,ie),Je}),Q=ie=>d.find(Be=>uy(Be).includes(ie)),[F,G]=D.useState(""),[J,K]=D.useState(new Set),[ee,ue]=D.useState("time"),[pe,be]=D.useState(!1),[ae,xe]=D.useState(!1),[Ce,ze]=D.useState(new Map),[Ie,Fe]=D.useState(null);D.useEffect(()=>{window.desktopSessions?.openTargets().then(Fe).catch(()=>{})},[]);const Ee=D.useMemo(()=>new Map((Ie?.apps??[]).map(ie=>[ie.runner,ie.name])),[Ie]),Me=async()=>{E(!0);try{y(await window.desktopSessions?.roots().catch(()=>[])??[]);const ie=await EW();if(x(ie),ze(ace(ie)),window.desktopSessions?.codexThreads?.().then(Be=>{Be&&(V(new Map(Be.filter(Je=>Je.name&&Je.sessionId).map(Je=>[Je.sessionId,Je.name]))),L(new Map(Be.filter(Je=>Je.forkedFromId&&Je.sessionId).map(Je=>[Je.sessionId,Je.forkedFromId]))))}).catch(()=>{}),n){const Be=ie.find(Je=>Je.sessionId===n);Be&&A(Be.cwd??"")}}finally{E(!1)}};D.useEffect(()=>{Me()},[]),D.useEffect(()=>{let ie=!1;const Be=()=>{ie||w||(ie=!0,setTimeout(()=>{ie=!1,Me()},2e3))};return window.addEventListener("td:sessions-changed",Be),()=>window.removeEventListener("td:sessions-changed",Be)},[w]);const De=D.useCallback(ie=>z.get(ie.sessionId)??ie.title,[z]),bt=D.useMemo(()=>(p??[]).filter(ie=>!J.has(ie.runner)&&(ae||!ie.subagent)&&(!pe||Ce.has(jc(ie)))&&(!F.trim()||De(ie).toLowerCase().includes(F.trim().toLowerCase()))),[p,J,F,pe,Ce,ae,De]),mt=D.useMemo(()=>SW(bt),[bt]),Ye=D.useMemo(()=>[...new Set((p??[]).map(ie=>ie.runner))].sort(),[p]),at=D.useMemo(()=>{const ie=new Map;for(const Be of p??[])ie.set(Be.rootKey,(ie.get(Be.rootKey)??0)+1);return ie},[p]),rt=v==="canvases"?null:mt.find(ie=>(ie.cwd??"")===(v??mt[0]?.cwd??""))??mt[0]??null,Ue=D.useMemo(()=>{if(!rt)return[];const ie=ee==="name"?(Be,Je)=>De(Be).localeCompare(De(Je)):ice[ee];return[...rt.cards].sort(ie)},[rt,ee,De]),Ct=ie=>{rce(ie),ze(Be=>{const Je=new Map(Be);return Je.delete(jc(ie)),Je})},ot=async ie=>{if(!T){C(ie.rel),Ct(ie);try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:Rt}},[]),{importOrAppendConversation:Je,shellSessionReader:Ht}=await ft(async()=>{const{importOrAppendConversation:Rt,shellSessionReader:en}=await import("./canonical-wWV9jbzN.js");return{importOrAppendConversation:Rt,shellSessionReader:en}},[]),Kt=await Uc(await Be(Ht(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p),qt=await Je(Kt);if(!qt)throw new Error(Te("handoff.notASession"));qt.kind==="appended"?We("success",ye(Te("atlas.appended"),{n:qt.turns}),9e3):qt.kind==="mounted"?We("success",ye(Te(qt.mode==="continue"?"atlas.mountedChapter":"atlas.mountedBranch"),{n:qt.turns}),9e3):qt.kind==="opened"?We("info",Te("atlas.upToDate"),6e3):We("success",ye(Te("toast.importedChats"),{n:1,m:qt.nodeCount}),9e3),e(),t()}catch(Be){We("error",ye(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},It=async ie=>{if(!(T||Y.size<2)){C("__merge__");try{const{streamRunnerConversation:Be}=await ft(async()=>{const{streamRunnerConversation:Rt}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:Rt}},[]),{mergeSessionsIntoProject:Je,shellSessionReader:Ht}=await ft(async()=>{const{mergeSessionsIntoProject:Rt,shellSessionReader:en}=await import("./canonical-wWV9jbzN.js");return{mergeSessionsIntoProject:Rt,shellSessionReader:en}},[]),Kt=[];for(const Rt of Y.values())Kt.push(await Uc(await Be(Ht(Rt.rootKey,Rt.rel)),Rt.rootKey,Rt.rel,p)),Ct(Rt);const qt=await Je(Kt,ie);if(!qt)throw new Error(Te("handoff.notASession"));We("success",ye(Te("atlas.merged"),{n:qt.mounted}),1e4),qt.skipped>0&&We("info",ye(Te("atlas.mergeSkippedInfo"),{n:qt.skipped}),8e3),q(new Map),e(),t()}catch(Be){We("error",ye(Te("atlas.parseFailed"),{msg:Be instanceof Error?Be.message:String(Be)}))}finally{C(null)}}},_e=async ie=>{const Be=sn.getState().projects.find(Kt=>Kt.sourceSession?.sessionId===ie.sessionId);if(!Be||T)return;const{confirmDialog:Je}=await ft(async()=>{const{confirmDialog:Kt}=await Promise.resolve().then(()=>cu);return{confirmDialog:Kt}},void 0);if(await Je({title:Te("confirm.recastTitle"),message:ye(Te("confirm.recast"),{name:Be.name}),confirmLabel:Te("confirm.recastTitle"),danger:!0})){C(ie.rel);try{const{streamRunnerConversation:Kt}=await ft(async()=>{const{streamRunnerConversation:zn}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:zn}},[]),{importOrAppendConversation:qt,shellSessionReader:Rt}=await ft(async()=>{const{importOrAppendConversation:zn,shellSessionReader:tr}=await import("./canonical-wWV9jbzN.js");return{importOrAppendConversation:zn,shellSessionReader:tr}},[]),en=await Uc(await Kt(Rt(ie.rootKey,ie.rel)),ie.rootKey,ie.rel,p);if(!en)throw new Error(Te("handoff.notASession"));const{deleteProject:Gt}=await ft(async()=>{const{deleteProject:zn}=await Promise.resolve().then(()=>Sa);return{deleteProject:zn}},void 0);if(await Gt(Be.id),!await qt(en))throw new Error(Te("handoff.notASession"));We("success",Te("atlas.recastDone"),8e3),e(),t()}catch(Kt){We("error",ye(Te("atlas.parseFailed"),{msg:Kt instanceof Error?Kt.message:String(Kt)}))}finally{C(null)}}},Ze=async(ie,Be)=>{const Je=await window.desktopSessions.openInCli(ie.runner,ie.cwd,ie.sessionId,Be).catch(()=>({opened:!1,via:"",command:""}));Je.opened&&Je.via==="app"?(await navigator.clipboard.writeText(ie.sessionId).catch(()=>{}),We("success",Te("atlas.appOpened"),9e3)):Je.opened?We("success",Te("atlas.opened")):Je.command&&(await navigator.clipboard.writeText(Je.command).catch(()=>{}),We("info",Te("atlas.cmdCopied"),9e3))};return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6","data-session-atlas":!0,children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-2xl w-full max-w-[980px] h-[min(680px,90vh)] flex flex-col overflow-hidden",children:[l.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-line",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-base font-semibold text-ink",children:r(s==="memory"?"memory.managerTitle":"atlas.title")}),l.jsx("div",{className:"text-xs text-ink-muted mt-0.5",children:r(s==="memory"?"mp.subtitle":"atlas.subtitle")}),Ce.size>0&&l.jsxs("div",{className:"text-xs mt-1 flex items-center gap-2","data-atlas-changes":!0,children:[l.jsx("span",{className:"text-accent",children:ye(r("atlas.changesSummary"),{n:[...Ce.values()].filter(ie=>ie.kind==="new").length,m:[...Ce.values()].filter(ie=>ie.kind==="updated").length})}),l.jsx("button",{className:"text-ink-faint hover:text-ink underline decoration-dotted transition-colors",onClick:()=>{sce(p??[]),ze(new Map)},"data-atlas-mark-all":!0,children:r("atlas.markAllSeen")})]})]}),m&&Ie&&Ie.terminals.length>0&&l.jsxs("label",{className:"flex items-center gap-1.5 text-sm text-ink-muted border border-line rounded-lg px-2.5 py-1.5 cursor-pointer",title:r("atlas.terminalChoice"),children:[l.jsx(Go,{size:14,strokeWidth:1.75}),l.jsxs("select",{value:Ie.prefs.terminal,onChange:ie=>{const Be=ie.target.value;if(Be==="__add__"){window.desktopSessions?.addTerminal().then(()=>window.desktopSessions?.openTargets().then(Fe));return}window.desktopSessions?.setOpenPrefs({terminal:Be}).then(Je=>Fe(Ht=>Ht&&{...Ht,prefs:Je}))},className:"bg-transparent focus:outline-none text-sm text-ink cursor-pointer","data-atlas-terminal-select":!0,children:[Ie.terminals.map(ie=>l.jsx("option",{value:ie.id,children:ie.name},ie.id)),Ie.canAddCustom&&l.jsx("option",{value:"__add__",children:r("atlas.otherTerminal")})]})]}),m&&l.jsxs("button",{onClick:()=>O(!0),hidden:s==="memory",className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors","data-atlas-sources":!0,children:[l.jsx($A,{size:14,strokeWidth:1.75})," ",r("atlas.sources")]}),m&&s!=="memory"&&l.jsxs("button",{onClick:()=>{Me()},disabled:w,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink border border-line rounded-lg px-2.5 py-1.5 hover:bg-wash transition-colors disabled:opacity-60","data-atlas-refresh":!0,children:[w?l.jsx(nn,{size:14,className:"animate-spin"}):l.jsx(or,{size:14,strokeWidth:1.75}),r(w?"atlas.scanning":"atlas.refresh")]}),l.jsx("button",{onClick:e,className:"text-ink-faint hover:text-ink p-1.5 rounded-lg hover:bg-wash transition-colors","data-atlas-close":!0,children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 border-b border-line shrink-0","data-atlas-tabs":!0,children:[l.jsx("div",{className:"flex items-center bg-wash rounded-lg p-0.5 shrink-0",children:["sessions","memory"].map(ie=>l.jsx("button",{onClick:()=>o(ie),className:`text-xs px-3 py-1 rounded-md transition-colors ${s===ie?"bg-card text-ink shadow-sm font-medium":"text-ink-muted hover:text-ink"}`,"data-atlas-tab":ie,"aria-pressed":s===ie,children:r(ie==="sessions"?"atlas.tabSessions":"atlas.tabMemory")},ie))}),u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2.5 py-1 bg-card flex-1 max-w-[520px]",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.searchPlaceholder"),className:"text-sm bg-transparent focus:outline-none w-full text-ink placeholder:text-ink-faint","data-atlas-search":!0})]})]}),s==="memory"?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-4","data-atlas-memory":!0,children:l.jsx(nce,{query:u?F:"",onOpened:()=>{e(),t()}})}):l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsxs("div",{className:"w-[260px] border-r border-line overflow-y-auto py-2 shrink-0",children:[l.jsx("div",{className:"px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.recent")}),d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).slice(0,6).map(ie=>l.jsxs("button",{onClick:()=>{e(),Ui(ie.id).then(t)},className:"w-full text-left px-4 py-1.5 flex items-center gap-2 text-ink hover:bg-wash transition-colors","data-atlas-recent":ie.id,children:[ie.sourceSession?.sessionId?l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner}):l.jsx(Kk,{size:13,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name})]},ie.id)),l.jsx("div",{className:"border-t border-line mt-2 pt-2 px-4 py-1 text-2xs uppercase tracking-wide text-ink-faint",children:r("atlas.folders")}),!m&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.webNoScan")}),m&&p===null&&l.jsxs("div",{className:"px-4 py-2 text-sm text-ink-faint flex items-center gap-2",children:[l.jsx(nn,{size:14,className:"animate-spin"})," ",r("atlas.scanning")]}),m&&p!==null&&mt.length===0&&l.jsx("div",{className:"px-4 py-2 text-xs text-ink-faint",children:r("atlas.empty")}),mt.map(ie=>{const Be=ie.cwd??"",Je=v!=="canvases"&&rt===ie;return l.jsxs("button",{onClick:()=>A(Be),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${Je?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-folder":ie.name||"unfiled",children:[Je?l.jsx(lu,{size:15,strokeWidth:1.75,className:"shrink-0"}):l.jsx(AF,{size:15,strokeWidth:1.75,className:"shrink-0 text-ink-faint"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:ie.name||r("atlas.unfiled")}),(()=>{const Ht=ie.cards.filter(Kt=>Ce.has(jc(Kt))).length;return Ht>0?l.jsxs("span",{className:"text-2xs text-accent shrink-0","data-atlas-folder-changes":!0,children:["+",Ht]}):null})(),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ie.cards.length})]},Be)}),l.jsx("div",{className:"border-t border-line mt-2 pt-2",children:l.jsxs("button",{onClick:()=>A("canvases"),className:`w-full text-left px-4 py-2 flex items-center gap-2 transition-colors ${v==="canvases"?"bg-accent/5 text-accent":"text-ink hover:bg-wash"}`,"data-atlas-canvases":!0,children:[l.jsx(Kk,{size:15,strokeWidth:1.75,className:"shrink-0"}),l.jsx("span",{className:"flex-1 truncate text-sm",children:r("atlas.myCanvases")}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:d.length})]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[u&&F.trim().length>=2&&l.jsx(kM,{phrase:F,onOpened:()=>{e(),t()}}),v==="canvases"?l.jsxs("div",{className:"space-y-1.5",children:[d.filter(ie=>!ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("div",{className:"group flex items-center flex-wrap gap-2 border border-line rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer",onClick:()=>{e(),Ui(ie.id).then(t)},children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm text-ink font-medium truncate",children:ie.name}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-1.5",children:[l.jsx("span",{children:vb(ie.updatedAt)}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px",children:ie.sourceSession.runner})]})]}),l.jsx("button",{title:r("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1.5 rounded transition-all shrink-0",onClick:Be=>{Be.stopPropagation(),Hm(ie.id,!0)},"data-atlas-archive":!0,children:l.jsx(el,{size:15,strokeWidth:1.75})}),!!ie.sourceSession&&uy(ie).length>0&&l.jsxs("div",{className:"w-full basis-full text-2xs text-ink-faint font-mono flex flex-wrap gap-x-3 gap-y-0.5 pt-1","data-atlas-cluster":!0,children:[ie.sourceSession.sessionId&&l.jsxs("span",{children:["◉ ",ie.sourceSession.runner," ",ie.sourceSession.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:ie.sourceSession.importedCount})]}),(ie.sourceSession.chapters??[]).map(Be=>l.jsxs("span",{children:["↳ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId)),(ie.sourceSession.branches??[]).map(Be=>l.jsxs("span",{children:["⑂ ",Be.runner," ",Be.sessionId.slice(0,8)," · ",ye(r("atlas.turnsN"),{n:Be.importedCount})]},Be.sessionId))]})]},ie.id)),d.some(ie=>ie.archived)&&l.jsxs("details",{className:"pt-2","data-atlas-archived-group":!0,children:[l.jsx("summary",{className:"text-2xs uppercase tracking-wide text-ink-faint cursor-pointer px-1 py-1",children:ye(r("atlas.archivedGroup"),{n:d.filter(ie=>ie.archived).length})}),l.jsx("div",{className:"space-y-1.5 mt-1.5",children:d.filter(ie=>ie.archived).sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsxs("button",{title:r("atlas.restoreOpen"),onClick:()=>{Hm(ie.id,!1).then(()=>{e(),Ui(ie.id).then(t)})},className:"w-full text-left border border-dashed border-line rounded-xl px-4 py-2.5 hover:bg-wash transition-colors opacity-70 hover:opacity-100","data-atlas-archived-item":!0,children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:ie.name}),!!ie.sourceSession?.sessionId&&l.jsx("span",{className:"text-2xs font-mono border border-line rounded px-1 py-px shrink-0 text-ink-faint",children:ie.sourceSession.runner})]}),l.jsx("div",{className:"text-2xs text-ink-faint mt-0.5",children:vb(ie.updatedAt)})]},ie.id))})]})]}):l.jsxs(l.Fragment,{children:[(p?.length??0)>0&&l.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[!u&&l.jsxs("div",{className:"flex items-center gap-1.5 border border-line rounded-lg px-2 py-1 bg-card",children:[l.jsx(g0,{size:13,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("input",{value:F,onChange:ie=>G(ie.target.value),placeholder:r("atlas.filterTitle"),className:"text-sm bg-transparent focus:outline-none w-[150px] text-ink placeholder:text-ink-faint","data-atlas-filter":!0})]}),Ye.map(ie=>l.jsx("button",{onClick:()=>K(Be=>{const Je=new Set(Be);return Je.has(ie)?Je.delete(ie):Je.add(ie),Je}),className:`text-2xs font-mono border rounded-lg px-2 py-1 transition-colors ${J.has(ie)?"border-line text-ink-faint line-through":"border-accent/40 text-accent bg-accent/5"}`,"data-atlas-runner-toggle":ie,children:ie},ie)),Ce.size>0&&l.jsx("button",{onClick:()=>be(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${pe?"border-accent text-white bg-accent":"border-line text-ink-muted hover:text-ink"}`,"data-atlas-only-changed":!0,children:r("atlas.onlyChanged")}),(p??[]).some(ie=>ie.subagent)&&l.jsx("button",{onClick:()=>xe(ie=>!ie),className:`text-2xs border rounded-lg px-2 py-1 transition-colors ${ae?"border-accent text-accent bg-accent/5":"border-line text-ink-faint hover:text-ink"}`,"data-atlas-show-sub":!0,children:r("atlas.showSub")}),l.jsxs("button",{onClick:()=>ue(ie=>({time:"name",name:"size",size:"runner",runner:"time"})[ie]),className:"ml-auto flex items-center gap-1.5 text-2xs text-ink-muted hover:text-ink border border-line rounded-lg px-2 py-1 hover:bg-wash transition-colors","data-atlas-sort":!0,children:[l.jsx(TH,{size:12,strokeWidth:1.75}),r(`atlas.sort${ee[0].toUpperCase()}${ee.slice(1)}`)]})]}),rt?l.jsxs(l.Fragment,{children:[rt.cwd&&l.jsxs("div",{className:"text-2xs text-ink-faint mb-3 truncate",children:[rt.cwd," · ",ye(r("atlas.sessions"),{n:rt.cards.length})]}),l.jsx("div",{className:"space-y-1.5",children:Ue.map(ie=>l.jsxs("div",{className:`group border rounded-xl px-4 py-3 hover:bg-wash transition-colors cursor-pointer flex items-center gap-3 ${Y.has($(ie))?"border-accent/60 bg-accent/5":"border-line"}`,onClick:()=>{ot(ie)},"data-atlas-session":ie.sessionId,children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"text-sm text-ink truncate flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate",children:De(ie)}),P.has(ie.sessionId)&&l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0 font-mono",title:`⑂ ${P.get(ie.sessionId)}`,"data-atlas-fork":!0,children:"⑂"}),Ce.get(jc(ie))?.kind==="new"&&l.jsx("span",{className:"text-2xs text-white bg-accent rounded px-1 py-px shrink-0","data-atlas-badge":"new",children:r("atlas.badgeNew")}),Ce.get(jc(ie))?.kind==="updated"&&l.jsxs("span",{className:"text-2xs text-accent border border-accent/40 rounded px-1 py-px shrink-0","data-atlas-badge":"updated",children:["+",_T(Ce.get(jc(ie)).deltaSize)]}),ie.sessionId===h?l.jsx("span",{className:"text-2xs text-white bg-ink rounded px-1 py-px shrink-0","data-atlas-badge":"current",children:r("atlas.currentOpen")}):(()=>{const Be=Q(ie.sessionId);return Be?l.jsx("span",{className:"text-2xs text-ink-faint border border-line rounded px-1 py-px shrink-0",title:Be.name,"data-atlas-badge":"canvas",children:r("atlas.onCanvas")}):null})()]}),l.jsxs("div",{className:"text-2xs text-ink-faint mt-0.5 flex items-center gap-2",children:[l.jsx("span",{className:"border border-line rounded px-1 py-px font-mono",children:ie.runner}),l.jsx("span",{children:vb(ie.mtime)}),l.jsx("span",{children:_T(ie.size)})]})]}),T===ie.rel?l.jsx(nn,{size:16,className:"animate-spin text-accent shrink-0"}):l.jsxs("div",{className:`${Y.has($(ie))?"":"opacity-0 group-hover:opacity-100"} transition-opacity flex items-center gap-1 shrink-0`,children:[!Q(ie.sessionId)&&!!ie.sessionId&&l.jsx("button",{title:r("atlas.pickForMerge"),className:`p-1.5 rounded transition-colors ${Y.has($(ie))?"text-accent":"text-ink-faint hover:text-accent"}`,onClick:Be=>{Be.stopPropagation(),X(ie)},"data-atlas-pick":Y.has($(ie))?"on":"off",children:Y.has($(ie))?l.jsx(BU,{size:16,strokeWidth:1.75}):l.jsx(q0,{size:16,strokeWidth:1.75})}),l.jsx("span",{title:r("atlas.import"),className:"text-ink-faint hover:text-accent p-1.5",children:l.jsx(UF,{size:16,strokeWidth:1.75})}),d.some(Be=>Be.sourceSession?.sessionId===ie.sessionId)&&l.jsx("button",{title:r("atlas.recast"),className:"text-ink-faint hover:text-red-500 p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),_e(ie)},"data-atlas-recast":!0,children:l.jsx(WA,{size:16,strokeWidth:1.75})}),!Q(ie.sessionId)&&l.jsx("button",{title:r("atlas.mountTo"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),S(ie)},"data-atlas-mount":!0,children:l.jsx(Gi,{size:16,strokeWidth:1.75})}),Ee.has(ie.runner)&&l.jsx("button",{title:ye(r("atlas.openApp"),{name:Ee.get(ie.runner)}),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"app")},"data-atlas-open-app":!0,children:l.jsx(wH,{size:16,strokeWidth:1.75})}),l.jsx("button",{title:r("atlas.openTerminal"),className:"text-ink-faint hover:text-accent p-1.5 rounded transition-colors",onClick:Be=>{Be.stopPropagation(),Ze(ie,"terminal")},"data-atlas-open-cli":!0,children:l.jsx(Go,{size:16,strokeWidth:1.75})})]})]},ie.rel))})]}):l.jsx("div",{className:"py-16 text-center text-sm text-ink-faint",children:p===null?r("atlas.scanning"):p.length>0?r("atlas.filteredOut"):r("atlas.empty")})]})]})]}),Y.size>=2&&!B&&l.jsxs("div",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-10 bg-surface border border-line rounded-xl shadow-lg px-4 py-2.5 flex items-center gap-3","data-atlas-merge-bar":!0,children:[l.jsx("span",{className:"text-xs text-ink-muted whitespace-nowrap",children:ye(r("atlas.mergeSelected"),{n:Y.size})}),T==="__merge__"?l.jsx(nn,{size:15,className:"animate-spin text-accent"}):l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"text-xs bg-accent hover:bg-accent-strong text-white font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>{It()},"data-atlas-merge-new":!0,children:r("atlas.mergeNew")}),l.jsx("button",{className:"text-xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors whitespace-nowrap",onClick:()=>j(!0),"data-atlas-merge-into":!0,children:r("atlas.mergeInto")})]}),l.jsx("button",{className:"text-ink-faint hover:text-ink p-1",onClick:()=>q(new Map),title:r("common.cancel"),children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),(_||B)&&l.jsx("div",{className:"absolute inset-0 z-10 bg-ink/20 flex items-center justify-center",onClick:()=>{S(null),j(!1)},children:l.jsxs("div",{className:"bg-surface border border-line rounded-2xl shadow-xl w-[400px] max-h-[70%] overflow-y-auto",onClick:ie=>ie.stopPropagation(),"data-atlas-mount-picker":!0,children:[l.jsxs("div",{className:"px-4 pt-3.5 pb-2.5 border-b border-line",children:[l.jsx("div",{className:"text-sm font-semibold text-ink",children:r(B?"atlas.mergeInto":"atlas.mountTo")}),l.jsx("div",{className:"text-2xs text-ink-muted mt-0.5",children:r(B?"atlas.mergeSelected":"atlas.mountHint").replace("{n}",String(Y.size))})]}),d.filter(ie=>!ie.archived&&ie.kind!=="paradigm").sort((ie,Be)=>Be.updatedAt-ie.updatedAt).map(ie=>l.jsx("button",{className:"w-full text-left px-4 py-2.5 text-sm text-ink hover:bg-wash transition-colors border-b border-line last:border-b-0",onClick:()=>{if(B){j(!1),It(ie.id);return}const Be=_;S(null),(async()=>{C(Be.rel);try{const{streamRunnerConversation:Je}=await ft(async()=>{const{streamRunnerConversation:en}=await import("./index-BRdlgS3c.js");return{streamRunnerConversation:en}},[]),{mountConversationToProject:Ht,shellSessionReader:Kt}=await ft(async()=>{const{mountConversationToProject:en,shellSessionReader:Gt}=await import("./canonical-wWV9jbzN.js");return{mountConversationToProject:en,shellSessionReader:Gt}},[]),qt=await Uc(await Je(Kt(Be.rootKey,Be.rel)),Be.rootKey,Be.rel,p),Rt=await Ht(qt,ie.id);if(!Rt)throw new Error(Te("handoff.notASession"));We("success",ye(Te("atlas.mountedChapter"),{n:Rt.kind==="mounted"||Rt.kind==="appended"?Rt.turns:0}),9e3),e(),t()}catch(Je){We("error",ye(Te("atlas.parseFailed"),{msg:Je instanceof Error?Je.message:String(Je)}))}finally{C(null)}})()},children:ie.name},ie.id))]})}),I&&l.jsx(oce,{roots:b,counts:at,onChanged:()=>{Me()},onClose:()=>O(!1)})]})}),document.body)}function lce(){const e=St(),t=oe(a=>!!a.harnessHost?.bar);if(!R$||t)return null;const n=()=>window.parent.postMessage({source:"dsh-thoughtdag",type:"td:close"},window.location.origin);return l.jsxs("div",{className:"bg-card/90 backdrop-blur border border-line rounded-xl p-0.5 shadow-sm flex items-center",role:"group","aria-label":"view switch","data-harness-view-switch":!0,children:[l.jsx("button",{type:"button",onClick:n,className:"h-8 px-3 rounded-[10px] text-xs font-semibold text-ink-muted hover:bg-wash hover:text-ink transition-colors whitespace-nowrap","data-view":"dialog","aria-pressed":!1,children:e("harness.viewChat")}),l.jsx("button",{type:"button",className:"h-8 px-3 rounded-[10px] text-xs font-semibold bg-ink text-card whitespace-nowrap cursor-default","data-view":"map","aria-pressed":!0,children:e("harness.viewMap")})]})}function cce({conversations:e,onClose:t,onDone:n}){const a=St(),[r,s]=D.useState(new Set),[o,u]=D.useState(!1),d=p=>{s(x=>{const b=new Set(x);return b.has(p)?b.delete(p):b.add(p),b})},h=r.size===e.length,m=async()=>{r.size===0||o||(u(!0),await pG([...r].sort((p,x)=>p-x).map(p=>e[p])),u(!1),n())};return l.jsx("div",{className:"fixed inset-0 z-50 bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:t,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-full max-w-lg max-h-[80vh] flex flex-col",onClick:p=>p.stopPropagation(),children:[l.jsxs("div",{className:"px-6 py-4 border-b border-line flex items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-base font-semibold text-ink",children:a("import.title")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1 leading-relaxed",children:a("import.subtitle")})]}),l.jsx("button",{onClick:t,className:"text-ink-faint hover:text-ink transition-colors shrink-0 mt-0.5",children:l.jsx(cn,{size:16,strokeWidth:1.75})})]}),l.jsx("div",{className:"px-6 py-2 border-b border-line/60",children:l.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-muted cursor-pointer select-none py-1",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:()=>s(h?new Set:new Set(e.map((p,x)=>x))),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5"}),a("import.selectAll"),l.jsx("span",{className:"ml-auto text-2xs text-ink-faint uppercase tracking-wider",children:e[0]?.source})]})}),l.jsx("ul",{className:"flex-1 overflow-y-auto py-1",children:e.map((p,x)=>l.jsx("li",{children:l.jsxs("label",{className:"flex items-center gap-3 px-6 py-2 hover:bg-wash transition-colors cursor-pointer select-none",children:[l.jsx("input",{type:"checkbox",checked:r.has(x),onChange:()=>d(x),className:"rounded border-line text-accent focus:ring-accent w-3.5 h-3.5 shrink-0"}),l.jsx(qA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"text-sm text-ink truncate flex-1",children:p.title}),l.jsx("span",{className:"text-2xs text-ink-faint shrink-0",children:ye(a("import.messages"),{n:p.messageCount})})]})},x))}),l.jsxs("div",{className:"px-6 py-4 border-t border-line flex justify-end gap-2",children:[l.jsx("button",{onClick:t,className:"text-xs text-ink-muted hover:text-ink px-4 py-2 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")}),l.jsx("button",{onClick:()=>{m()},disabled:r.size===0||o,className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors disabled:opacity-30",children:o?"…":ye(a("import.confirm"),{n:r.size})})]})]})})}function uce(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return Te("switcher.justNow");if(n<60)return ye(Te("switcher.minAgo"),{n});const a=Math.floor(n/60);if(a<24)return ye(Te("switcher.hourAgo"),{n:a});const r=Math.floor(a/24);return r<30?ye(Te("switcher.dayAgo"),{n:r}):new Date(e).toLocaleDateString(Da.getState().lang==="zh"?"zh-CN":"en-US")}function dce({onSwitched:e}){const t=St(),n=sn(S=>S.projects),a=sn(S=>S.activeId),r=sn(S=>S.switching),s=n.find(S=>S.id===a)?.kind==="paradigm",[o,u]=D.useState(!1),[d,h]=D.useState(null),[m,p]=D.useState(!1),[x,b]=D.useState(void 0),[y,w]=D.useState(null),[E,v]=D.useState(""),A=D.useRef(null),T=D.useRef(null),C=n.find(S=>S.id===a),I=n.filter(S=>!S.archived).sort((S,z)=>z.updatedAt-S.updatedAt).slice(0,7),O=async S=>{const{canvasUniqueness:z}=await ft(async()=>{const{canvasUniqueness:Y}=await import("./canonical-wWV9jbzN.js");return{canvasUniqueness:Y}},[]),V=await z(S.id),P=V==="native"?"confirm.deleteNative":V==="diverged-mirror"?"confirm.deleteDiverged":"confirm.deletePristine";await ri({title:Te("confirm.deleteCanvasTitle"),message:ye(Te(P),{name:S.name}),confirmLabel:Te("common.delete"),danger:V!=="pristine-mirror"})&&B7(S.id).then(e)};D.useEffect(()=>{if(!o)return;const S=z=>{T.current?.contains(z.target)||u(!1)};return window.addEventListener("mousedown",S),()=>window.removeEventListener("mousedown",S)},[o]);const _=async S=>{u(!1),await Ui(S),e(),ft(()=>import("./canonical-wWV9jbzN.js"),[]).then(z=>z.unsubscribeOrphanedSessions()),ft(()=>Promise.resolve().then(()=>Y8),void 0).then(z=>z.sweepRecentSessions())};return l.jsxs("div",{ref:T,className:"absolute top-4 left-4 z-20",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs("button",{onClick:()=>u(!o),disabled:r,className:"bg-card/90 backdrop-blur border border-line rounded-xl px-3.5 py-2 shadow-sm hover:bg-wash transition-colors flex items-center gap-2 text-sm text-ink max-w-[240px] disabled:opacity-60",children:[r?l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin shrink-0 text-accent"}):s?l.jsx(cF,{size:16,strokeWidth:1.75,className:"shrink-0 text-accent"}):l.jsx(lu,{size:16,strokeWidth:1.75,className:"shrink-0 text-ink-muted"}),l.jsx("span",{className:"truncate font-medium",children:C?.name??"…"}),l.jsx(cr,{size:14,strokeWidth:1.75,className:"shrink-0 text-ink-faint"})]}),l.jsx(lce,{}),!!C?.sourceSession?.sessionId&&(()=>{const S=jm.size>0&&!jm.has(C.sourceSession.sessionId);return l.jsxs("button",{title:S?Te("switcher.mirrorBadgeGone"):ye(Te("switcher.mirrorBadge"),{runner:C.sourceSession.runner}),onClick:()=>{b(C.sourceSession.sessionId),p(!0)},className:`bg-card/90 backdrop-blur border border-line rounded-xl px-2 py-2 shadow-sm hover:bg-wash transition-colors text-2xs font-mono flex items-center gap-1 ${S?"text-ink-faint/50 line-through decoration-1":"text-ink-faint hover:text-accent"}`,"data-twin-badge":S?"unreachable":"live",children:["⇄ ",C.sourceSession.runner]})})()]}),o&&l.jsxs("div",{className:"mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1.5 w-[320px] animate-fade-in",children:[l.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:I.map(S=>l.jsx("div",{className:`group flex items-center gap-1 px-3 py-2 hover:bg-wash cursor-pointer transition-colors ${S.id===a?"bg-accent/5":""}`,onClick:()=>{y!==S.id&&S.id!==a&&_(S.id)},children:y===S.id?l.jsx("input",{autoFocus:!0,value:E,onChange:z=>v(z.target.value),onClick:z=>z.stopPropagation(),onKeyDown:z=>{z.key==="Enter"&&!lr(z)&&E.trim()&&(z7(S.id,E.trim()),w(null)),z.key==="Escape"&&w(null)},onBlur:()=>w(null),className:"flex-1 text-sm text-ink border border-accent/40 rounded-lg px-2 py-1 bg-surface focus:outline-none"}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:`text-sm truncate ${S.id===a?"text-accent font-medium":"text-ink"}`,children:S.name}),l.jsxs("div",{className:"text-2xs text-ink-faint flex items-center gap-1.5",children:[l.jsx("span",{children:uce(S.updatedAt)}),!!S.sourceSession?.sessionId&&l.jsx("span",{className:"font-mono border border-line rounded px-1 py-px","data-mirror-mark":!0,children:S.sourceSession.runner})]})]}),l.jsx("button",{title:t("switcher.rename"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-ink p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),w(S.id),v(S.name)},children:l.jsx(Gl,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("common.delete"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-red-500 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),O(S)},children:l.jsx(Ja,{size:14,strokeWidth:1.75})}),l.jsx("button",{title:t("switcher.archive"),className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-amber-600 p-1 rounded transition-all shrink-0",onClick:z=>{z.stopPropagation(),Hm(S.id,!0).then(e)},"data-archive-canvas":!0,children:l.jsx(el,{size:14,strokeWidth:1.75})})]})},S.id))}),l.jsxs("div",{className:"border-t border-line mt-1 pt-1",children:[l.jsxs("button",{onClick:()=>{u(!1),Np().then(e)},className:"w-full text-left px-3 py-2 text-sm text-accent hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(U0,{size:15,strokeWidth:1.75})," ",t("switcher.newCanvas")]}),l.jsxs("button",{onClick:()=>A.current?.click(),className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx(ZU,{size:15,strokeWidth:1.75})," ",t("switcher.importBackup")]}),l.jsxs("button",{onClick:()=>{u(!1),p(!0)},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-open-atlas":!0,children:[l.jsx(tU,{size:15,strokeWidth:1.75})," ",t("switcher.allCanvases")]}),window.desktop&&l.jsxs("button",{onClick:()=>{u(!1),window.desktop.checkForUpdates()},className:"w-full text-left px-3 py-2 text-sm text-ink-muted hover:bg-wash transition-colors flex items-center gap-2","data-check-updates":!0,children:[l.jsx(or,{size:15,strokeWidth:1.75})," ",t("update.checkMenu"),l.jsxs("span",{className:"ml-auto text-2xs text-ink-faint",children:["v",new URLSearchParams(window.location.search).get("dv")]})]}),l.jsx("input",{ref:A,type:"file",accept:".json,.jsonl,application/json",className:"hidden",onChange:S=>{const z=S.target.files?.[0];z&&fG(z).then(V=>{V.kind==="own"&&V.ok?(u(!1),e()):V.kind==="chat"&&(u(!1),h(V.conversations))}).catch(V=>{We("error",ye(Te("toast.importFailedGeneric"),{msg:V instanceof Error?V.message:String(V)}))}),S.target.value=""}})]})]}),d&&l.jsx(cce,{conversations:d,onClose:()=>h(null),onDone:()=>{h(null),e()}}),m&&l.jsx(Vv,{onClose:()=>{p(!1),b(void 0)},onSwitched:e,focusSessionId:x})]})}const hce="JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUiA0IDAgUl0gL0NvdW50IDIgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvQ29udGVudHMgNSAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNyAwIFIgL0YyIDggMCBSID4+ID4+ID4+CmVuZG9iago0IDAgb2JqCjw8IC9UeXBlIC9QYWdlIC9QYXJlbnQgMiAwIFIgL01lZGlhQm94IFswIDAgNTk1IDg0Ml0gL0NvbnRlbnRzIDYgMCBSIC9SZXNvdXJjZXMgPDwgL0ZvbnQgPDwgL0YxIDcgMCBSIC9GMiA4IDAgUiA+PiA+PiA+PgplbmRvYmoKNSAwIG9iago8PCAvTGVuZ3RoIDExMTIgPj4Kc3RyZWFtCkJUCi9GMiAxOSBUZiAxIDAgMCAxIDY0IDcyNS4wIFRtIChXaHkgU2F2ZWQgQXJ0aWNsZXMgU3RheSBVbnJlYWQpIFRqCi9GMSAxMSBUZiAxIDAgMCAxIDY0IDcwOC4wIFRtIChBIHNob3J0IGJyaWVmIG9uIGRpZ2l0YWwgaG9hcmRpbmcgYW5kIHRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjIgMTMgVGYgMSAwIDAgMSA2NCA2NjkuMCBUbSAoMS4gVGhlIHBoZW5vbWVub24pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjUxLjUgVG0gKFJlYWQtaXQtbGF0ZXIgc2VydmljZXMgcmVwb3J0IHRoYXQgbW9zdCBzYXZlZCBpdGVtcyBhcmUgbmV2ZXIpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjM0LjAgVG0gKHJlb3BlbmVkLiBBY3Jvc3MgcHVibGlzaGVkIHVzYWdlIHN0dWRpZXMsIHRoZSBzaGFyZSBvZiBzYXZlZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA2MTYuNSBUbSAoYXJ0aWNsZXMgdGhhdCBnZXQgYSBzZWNvbmQgdmlzaXQgaXMgc21hbGwsIGFuZCBjb21wbGV0aW9uIHJhdGVzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU5OS4wIFRtIChhcmUgc21hbGxlciBzdGlsbC4gVGhlIGFyY2hpdmUgZ3Jvd3M7IHRoZSByZWFkaW5nIGRvZXMgbm90LikgVGoKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNTYwLjAgVG0gKDIuIFRoZSBjb2xsZWN0b3IncyBmYWxsYWN5KSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU0Mi41IFRtIChDb2xsZWN0aW5nIHByb2R1Y2VzIGFuIGltbWVkaWF0ZSBzZW5zZSBvZiBwcm9ncmVzcyB3aGlsZSB0aGUpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTI1LjAgVG0gKHVuZGVyc3RhbmRpbmcgaXQgcHJvbWlzZXMgaXMgZGVmZXJyZWQuIFNhdmluZyBhIHRleHQgZmVlbHMgbGlrZSkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1MDcuNSBUbSAoYSBmaXJzdCBzdGVwIG9mIHJlYWRpbmcgaXQsIGJ1dCBubyBwYXJ0IG9mIHRoZSByZWFkaW5nIGhhcykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA0OTAuMCBUbSAoaGFwcGVuZWQuKSBUagovRjIgMTEuNSBUZiAxIDAgMCAxIDY0IDQ3Mi41IFRtIChUaGUgYWN0IG9mIHNhdmluZyBpcyBtaXN0YWtlbiBmb3IgdGhlIGFjdCBvZiBsZWFybmluZy4pIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNiAwIG9iago8PCAvTGVuZ3RoIDkwOCA+PgpzdHJlYW0KQlQKL0YyIDEzIFRmIDEgMCAwIDEgNjQgNzI1LjAgVG0gKDMuIFdoeSBpdCBwZXJzaXN0cykgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA3MDcuNSBUbSAoVGhlIGNvc3RzIGFyZSBhc3ltbWV0cmljOiBzYXZpbmcgdGFrZXMgb25lIHNlY29uZCBhbmQgcGF5cyBvdXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjkwLjAgVG0gKGEgc21hbGwgcmV3YXJkIG5vdzsgcmVhZGluZyB0YWtlcyBhbiBob3VyIGFuZCBwYXlzIG91dCBsYXRlci4pIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNjcyLjUgVG0gKEhhYml0cyBmb2xsb3cgdGhlIGNoZWFwZXIgbG9vcCwgc28gbGlicmFyaWVzIGluZmxhdGUgYnkgZGVmYXVsdC4pIFRqCi9GMiAxMyBUZiAxIDAgMCAxIDY0IDYzMy41IFRtICg0LiBXaGF0IGhlbHBzKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDYxNi4wIFRtIChJbnRlcnZlbnRpb25zIHRoYXQgd29yayBtb3ZlIHByb2Nlc3NpbmcgdG8gdGhlIG1vbWVudCBvZiBjYXB0dXJlOikgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1OTguNSBUbSAod3JpdGUgb25lIGxpbmUgaW4geW91ciBvd24gd29yZHMgYWJvdXQgd2h5IHRoZSBpdGVtIG1hdHRlcnMsIGFuZCkgVGoKL0YxIDExLjUgVGYgMSAwIDAgMSA2NCA1ODEuMCBUbSAoc2NoZWR1bGUgYSByZXZpZXcgcGFzcyBpbnN0ZWFkIG9mIHRydXN0aW5nIHRoZSBhcmNoaXZlIHRvKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDU2My41IFRtIChyZXN1cmZhY2UgaXQuKSBUagovRjEgMTEuNSBUZiAxIDAgMCAxIDY0IDUzMi4wIFRtIChBIHNtYWxsZXIgbGlicmFyeSB0aGF0IGdldHMgcHJvY2Vzc2VkIGJlYXRzIGEgY29tcGxldGUgb25lIHRoYXQpIFRqCi9GMSAxMS41IFRmIDEgMCAwIDEgNjQgNTE0LjUgVG0gKGRvZXMgbm90LikgVGoKRVQKZW5kc3RyZWFtCmVuZG9iago3IDAgb2JqCjw8IC9UeXBlIC9Gb250IC9TdWJ0eXBlIC9UeXBlMSAvQmFzZUZvbnQgL0hlbHZldGljYSA+PgplbmRvYmoKOCAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EtQm9sZCA+PgplbmRvYmoKeHJlZgowIDkKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDEyMSAwMDAwMCBuIAowMDAwMDAwMjU3IDAwMDAwIG4gCjAwMDAwMDAzOTMgMDAwMDAgbiAKMDAwMDAwMTU1NyAwMDAwMCBuIAowMDAwMDAyNTE2IDAwMDAwIG4gCjAwMDAwMDI1ODYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA5IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoyNjYxCiUlRU9G",fce=`<!-- tdag-page:1 -->
|
|
675
675
|
|
|
676
676
|
# Why Saved Articles Stay Unread
|
|
677
677
|
|
|
@@ -904,11 +904,11 @@ ${n==="zh"?"**高光(原文保真)**":"**Highlights (verbatim)**"}
|
|
|
904
904
|
${T.map(S=>`> ${S.text}`).join(`
|
|
905
905
|
`)}`:"",I=Tn();x.push(I);const O=`${n==="zh"?"凝练":"Condensed"}: ${v.data.question.replace(/\s+/g," ").slice(0,60)} → ${A.data.question.replace(/\s+/g," ").slice(0,60)}`,_=`${t[E]||""}${C}`;p.push({id:I,type:"thought",position:{x:v.position.x+h,y:v.position.y},dragHandle:".drag-handle",data:{question:O,response:_,responses:[_],responseIndex:0,condensedFrom:w.nodeIds,createdAt:new Date().toISOString(),isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:Nn(`${O}
|
|
906
906
|
${_}`),highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}),w.nodeIds.forEach(S=>m.set(S,I))});for(const w of r){if(u.has(w.id))continue;const E=Tn();m.set(w.id,E);const v=w.data;p.push({...w,id:E,position:{x:w.position.x+h,y:w.position.y},selected:!1,data:{...v,isEditing:!1,isEditingResponse:!1,isLoading:!1}})}const b=[],y=new Set;for(const w of s){const E=m.get(w.source),v=m.get(w.target);if(!E||!v||E===v)continue;const A=`${E}→${v}`;y.has(A)||(y.add(A),b.push({...w,id:`e-${Tn()}`,source:E,target:v,selected:!1}))}return a.pushHistory(),se.setState(w=>{const E=[...w.nodes,...p],v=[...w.edges,...b];return{nodes:xr(E,v),edges:v}}),{copiedNodes:p.length,collapsedRuns:e.length,distillIds:x}}let Tl=0;function aue(){Tl++,oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})}async function rue(e,t,n){if(e.length===0)return;const a=++Tl,r=oe.getState(),s=se.getState().nodes.map(o=>o.id);r.setCondenseRun({status:"building",current:0,total:e.length,streaming:"",error:void 0,originalIds:s,distillIds:[]});try{const o=[];let u="";for(let h=0;h<e.length;h++){if(Tl!==a)return;oe.getState().setCondenseRun({current:h+1,streaming:""});const m=await eue(e[h],t,n,p=>{Tl===a&&oe.getState().setCondenseRun({streaming:p})},u||void 0);if(Tl!==a)return;o.push(m),u=`${u}
|
|
907
|
-
${m}`.slice(-1500)}const d=nue(e,o,t);if(Tl!==a)return;oe.getState().setCondenseRun({status:"done",streaming:"",distillIds:d.distillIds}),We("success",Te("condense.copyReady"),8e3,{label:Te("tmap.export"),run:()=>oe.getState().setThoughtMapOpen(!0)})}catch(o){if(Tl!==a)return;oe.getState().setCondenseRun({status:"error",error:o instanceof Error?o.message:String(o)})}}function sue({onFocusSegment:e}){const t=oe(P=>P.condenseDialogOpen),n=oe(P=>P.condenseRun),a=St(),r=Da(P=>P.lang),s=se(P=>P.nodes),o=se(P=>P.edges),[u,d]=D.useState(0),h=D.useMemo(()=>t&&n.status==="idle"?Zce(s,o):[],[t,n.status,s,o,u]),m=oe(P=>P.selectedModel),p=Yl()?.models??[],[x,b]=D.useState(""),[y,w]=D.useState(new Set),[E,v]=D.useState(null),A=D.useRef(null),T=P=>{const L=A.current?.getBoundingClientRect();if(!L)return;const Y=P.clientX-L.left,q=P.clientY-L.top,B=$=>v({x:Math.min(window.innerWidth-120,Math.max(0,$.clientX-Y)),y:Math.min(window.innerHeight-80,Math.max(0,$.clientY-q))}),j=()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",j)},C=P=>P.nodeIds.join(","),I=h.filter(P=>!y.has(C(P))),O=I.reduce((P,L)=>P+L.saving,0),_=()=>{oe.getState().setCondenseDialogOpen(!1),oe.getState().setCondenseHighlightIds([])};if(D.useEffect(()=>{if(!t)return;const P=L=>{L.key==="Escape"&&_()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),!t)return null;const S=()=>{I.length!==0&&rue(I,r,x||m||void 0)},z=()=>{se.getState().setArchived(n.originalIds,!0),We("success",a("condense.originalArchived")),oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:"",originalIds:[],distillIds:[]}),_()},V=()=>{const L=se.getState().nodes.filter(Y=>n.distillIds.includes(Y.id));L.length&&e?.(L.map(Y=>Y.id))};return ur.createPortal(l.jsxs("div",{ref:A,className:"fixed z-[70] bg-surface border border-line rounded-2xl shadow-2xl w-[400px] max-h-[72vh] flex flex-col p-4 animate-fade-in",style:E?{left:E.x,top:E.y}:{left:80,bottom:16},"data-condense-dialog":!0,onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between mb-1 cursor-grab active:cursor-grabbing select-none",onMouseDown:T,children:[l.jsxs("div",{className:"text-sm font-semibold text-ink flex items-center gap-2",children:[l.jsx(bp,{size:15,strokeWidth:1.75,className:"text-accent"})," ",a("condense.title")]}),l.jsx("button",{onClick:_,title:n.status==="building"?a("condense.runningBg"):void 0,className:"text-ink-faint hover:text-ink rounded-lg w-7 h-7 flex items-center justify-center hover:bg-wash transition-colors",children:l.jsx(cn,{size:15})})]}),n.status==="idle"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsx("p",{className:"text-2xs text-ink-faint leading-snug",title:a("condense.copyIntroFull"),children:a("condense.copyIntroShort")}),l.jsxs("button",{onClick:()=>d(P=>P+1),title:a("condense.rescanTitle"),"data-condense-rescan":!0,className:"text-2xs text-ink-muted hover:text-accent px-2 py-1 rounded-lg hover:bg-wash transition-colors shrink-0",children:["⟳ ",a("condense.rescan")]})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2","data-condense-scanline":!0,children:ye(a("condense.scanLine"),{turns:String(s.filter(P=>P.data.response&&!P.data.stepKind).length),n:String(h.length)})}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("label",{className:"text-2xs text-ink-muted shrink-0",children:a("condense.modelLabel")}),l.jsxs("select",{value:x,onChange:P=>b(P.target.value),"data-condense-model":!0,className:"text-xs bg-wash text-ink rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/40 max-w-[220px] truncate",children:[l.jsx("option",{value:"",children:ye(a("condense.modelGlobal"),{model:m||"auto"})}),p.map(P=>l.jsx("option",{value:P.id,children:P.id},P.id))]})]}),h.length===0?l.jsx("p",{className:"text-xs text-ink-muted py-4",children:a("condense.segNothing")}):l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:h.map(P=>{const L=C(P),Y=!y.has(L);return l.jsxs("div",{"data-condense-item":!0,className:`border rounded-xl p-3 transition-colors cursor-pointer ${Y?"border-accent/60 bg-accent/5":"border-line opacity-60"}`,onClick:()=>{oe.getState().setCondenseHighlightIds(P.nodeIds),e?.(P.nodeIds)},children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("input",{type:"checkbox",checked:Y,onClick:q=>q.stopPropagation(),onChange:()=>w(q=>{const B=new Set(q);return B.has(L)?B.delete(L):B.add(L),B}),className:"accent-[var(--color-accent)]","data-condense-check":!0}),l.jsx("span",{className:"text-2xs text-ink-faint font-mono",children:ye(a("condense.segMeta"),{n:String(P.nodeIds.length),tok:String(P.saving)})})]}),l.jsx("p",{className:"text-xs text-ink mt-1 leading-snug line-clamp-2",children:P.headQuestion})]},L)})}),h.length>0&&l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-3 mt-2 border-t border-line",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:a("condense.copyFootnote")}),l.jsxs("button",{onClick:S,disabled:I.length===0,"data-condense-build":!0,className:"text-xs bg-accent text-white px-3.5 py-2 rounded-lg disabled:opacity-40 transition-colors flex items-center gap-1.5 shrink-0",children:[l.jsx(to,{size:13,strokeWidth:1.75}),ye(a("condense.buildCopy"),{n:String(I.length),tok:String(O)})]})]})]}),n.status==="building"&&l.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted mb-1.5",children:[l.jsx(nn,{size:15,className:"animate-spin text-accent"}),ye(a("condense.buildingRun"),{i:String(n.current),n:String(n.total)})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2",children:a("condense.runningBg")}),n.streaming&&l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto text-2xs text-ink-muted bg-wash rounded-lg p-2.5 whitespace-pre-wrap leading-relaxed","data-condense-streaming":!0,children:n.streaming}),l.jsx("button",{onClick:()=>aue(),"data-condense-cancel":!0,className:"self-start mt-3 text-xs text-ink-muted hover:text-red-600 px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="error"&&l.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[l.jsx("p",{className:"text-2xs text-red-600",children:n.error}),l.jsx("button",{onClick:()=>oe.getState().setCondenseRun({status:"idle",error:void 0}),className:"self-start text-xs text-ink-muted hover:text-ink px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="done"&&l.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-700",children:[l.jsx(Jr,{size:16})," ",a("condense.copyReady")]}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:a("condense.copyCompareHint")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:V,className:"text-xs bg-accent/10 text-accent hover:bg-accent/20 px-3 py-2 rounded-lg transition-colors",children:a("condense.viewCopy")}),l.jsxs("button",{onClick:z,"data-condense-archive-original":!0,className:"text-xs border border-line text-ink-muted hover:text-ink hover:bg-wash px-3 py-2 rounded-lg transition-colors flex items-center gap-1.5",children:[l.jsx(el,{size:13,strokeWidth:1.75})," ",a("condense.archiveOriginal")]})]}),l.jsx("button",{onClick:()=>{oe.getState().setCondenseRun({status:"idle"}),_()},className:"self-start text-xs text-ink-faint hover:text-ink transition-colors",children:a("common.close")})]})]}),document.body)}function FT(){const e=Da(n=>n.lang),t=Da(n=>n.setLang);return l.jsx("div",{className:"flex items-center bg-card/90 backdrop-blur border border-line rounded-lg shadow-sm overflow-hidden",children:["en","zh"].map(n=>l.jsx("button",{onClick:()=>t(n),className:`px-2 h-8 text-2xs font-medium transition-colors ${e===n?"bg-accent text-white":"text-ink-muted hover:bg-wash"}`,children:n==="en"?"EN":"中"},n))})}function ma({x:e,y:t,w:n=34,h:a=20,tone:r="plain"}){return l.jsxs("g",{children:[l.jsx("rect",{x:e,y:t,width:n,height:a,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),r!=="plain"&&l.jsx("rect",{x:e,y:t,width:2.5,height:a,rx:1.25,fill:r==="accent"?it.accent:it.warm})]})}const iue={1:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:32,tone:"accent"}),l.jsx("circle",{cx:60,cy:28,r:2.5,fill:it.accent})]}),2:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:12,tone:"accent"}),l.jsx("line",{x1:60,y1:32,x2:60,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 47 L 60 52 L 63 47 Z",fill:it.accent}),l.jsx(ma,{x:43,y:52})]}),3:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:20,y:12,tone:"accent"}),l.jsx("line",{x1:37,y1:32,x2:37,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 34 47 L 37 52 L 40 47 Z",fill:it.accent}),l.jsx(ma,{x:20,y:52}),l.jsx("rect",{x:26,y:58,width:14,height:3,rx:1.5,fill:it.trace,opacity:.6}),l.jsx("path",{d:"M 54 62 C 64 62, 62 40, 72 38",stroke:it.warm,strokeWidth:1.75,fill:"none",strokeDasharray:"4 3"}),l.jsx("path",{d:"M 69 35.5 L 74 38 L 70 41 Z",fill:it.warm}),l.jsx(ma,{x:74,y:28,tone:"warm"})]}),4:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:52,stroke:it.line,strokeWidth:1.75,strokeDasharray:"3 3"}),l.jsx("circle",{cx:60,cy:41,r:7,fill:"white",stroke:"#FCA5A5",strokeWidth:1}),l.jsx("line",{x1:57,y1:38,x2:63,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx("line",{x1:63,y1:38,x2:57,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx(ma,{x:43,y:54})]}),5:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:12,y:14,w:40,h:15}),l.jsx("circle",{cx:14,cy:16,r:4.5,fill:"#D64533"}),l.jsx("text",{x:14,y:18.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"✕"}),l.jsx(ma,{x:12,y:35,w:40,h:15}),l.jsx("circle",{cx:14,cy:37,r:4.5,fill:it.accent}),l.jsx("text",{x:14,y:39.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"⚖"}),l.jsx(ma,{x:12,y:56,w:40,h:15}),l.jsx("circle",{cx:14,cy:58,r:4.5,fill:"#C9A227"}),l.jsx("text",{x:14,y:60.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"?"}),l.jsx("path",{d:"M 62 42 L 74 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 71.5 39.5 L 76 42 L 71.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:86,y:14,width:13,height:13,rx:4.5,fill:"#D64533"}),l.jsx("line",{x1:92.5,y1:27,x2:92.5,y2:35,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:35,width:13,height:13,rx:4.5,fill:it.accent}),l.jsx("line",{x1:92.5,y1:48,x2:92.5,y2:56,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:56,width:13,height:13,rx:4.5,fill:"#C9A227"})]}),7:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:14,y:12,width:30,height:22,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("line",{x1:29,y1:34,x2:29,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 26 47 L 29 52 L 32 47 Z",fill:it.accent}),l.jsx(ma,{x:12,y:52,tone:"accent"}),l.jsx("path",{d:"M 100 22 C 80 22, 70 55, 50 60",stroke:it.accent,strokeWidth:1.75,fill:"none",strokeDasharray:"5 3"}),l.jsx("path",{d:"M 52 57 L 47 61 L 52 64 Z",fill:it.accent}),l.jsx(ma,{x:82,y:12})]}),9:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:48,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 45 L 60 50 L 63 45 Z",fill:it.accent}),l.jsx(ma,{x:43,y:50}),l.jsx("circle",{cx:75,cy:53,r:4,fill:"#F59E0B"}),l.jsx("path",{d:"M 73.5 53 a 1.5 1.5 0 1 1 3 0",stroke:"white",strokeWidth:.9,fill:"none"}),l.jsx("text",{x:60,y:80,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"v2/2 · replay"})]}),6:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:18,width:14,height:48,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:15,cy:27,r:3,fill:it.accent,opacity:.7}),l.jsx("rect",{x:12,y:37,width:6,height:6,rx:1,fill:"#F59E0B",opacity:.8}),l.jsx("rect",{x:12,y:49,width:6,height:6,rx:1,fill:it.inkMuted,opacity:.5}),l.jsx("rect",{x:38,y:14,width:32,height:24,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("rect",{x:80,y:14,width:32,height:24,rx:3,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:88,cy:22,r:3,fill:it.line}),l.jsx("path",{d:"M 82 34 L 92 26 L 100 32 L 108 24",stroke:it.inkMuted,strokeWidth:1.2,fill:"none"}),l.jsx("text",{x:72,y:62,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"⌘V paste anything"})]}),8:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:8,width:70,height:52,rx:3,fill:it.accent,opacity:.06,stroke:it.accent,strokeWidth:.8,strokeDasharray:"3 2"}),l.jsx(ma,{x:14,y:14,w:26,h:16}),l.jsx(ma,{x:46,y:14,w:26,h:16}),l.jsx(ma,{x:30,y:38,w:26,h:16}),l.jsx("path",{d:"M 40 46 C 60 50, 70 50, 84 48",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 59 30 C 70 36, 76 42, 84 46",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 43 22 C 66 24, 76 38, 84 44",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx(ma,{x:84,y:40,w:28,h:18,tone:"accent"})]}),10:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:10,y:18,w:30,h:17,tone:"accent"}),l.jsx("line",{x1:25,y1:35,x2:25,y2:48,stroke:it.accent,strokeWidth:1.5}),l.jsx("path",{d:"M 22.5 45.5 L 25 50 L 27.5 45.5 Z",fill:it.accent}),l.jsx(ma,{x:10,y:50,w:30,h:17}),l.jsx("path",{d:"M 46 42 L 60 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 57.5 39.5 L 62 42 L 57.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:68,y:20,width:44,height:44,rx:5,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx(ma,{x:74,y:30,w:20,h:11,tone:"accent"}),l.jsx(ma,{x:88,y:46,w:20,h:11}),l.jsx("rect",{x:76,y:14,width:28,height:11,rx:5.5,fill:"#2B2A28"}),l.jsx("circle",{cx:84,cy:19.5,r:2.6,fill:"none",stroke:"white",strokeWidth:1}),l.jsx("circle",{cx:84,cy:19.5,r:.9,fill:"white"}),l.jsx("text",{x:90,y:22,fontSize:6,fill:"white",fontFamily:"JetBrains Mono Variable, monospace",children:"view"}),l.jsx("text",{x:60,y:78,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"#view= · read-only"})]})},UT={4:"prune",5:"map",6:"reading",7:"ref"};function oue(){const e=oe(h=>h.tutorialOpen),t=oe(h=>h.setTutorialOpen);D.useEffect(()=>{if(!e)return;const h=m=>{m.key==="Escape"&&t(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t]);const n=St(),a=Da(h=>h.lang),[r,s]=D.useState(0),o=[{label:n("tutorial.pg1"),steps:[1,2,3]},{label:n("tutorial.pg2"),steps:[4,5]},{label:n("tutorial.pg3"),steps:[6,7]},{label:n("tutorial.pg4"),steps:[8,9,10]}],u=r===o.length-1;if(D.useEffect(()=>{if(!e)return;s(0);const h=m=>{m.key==="ArrowRight"&&s(p=>Math.min(p+1,o.length-1)),m.key==="ArrowLeft"&&s(p=>Math.max(p-1,0))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e]),!e)return null;const d=o[r];return l.jsx("div",{className:"fixed inset-0 z-[95] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-[min(980px,94vw)] flex flex-col",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between px-7 pt-5 pb-1 shrink-0",children:[l.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[l.jsx("h2",{className:"text-lg font-semibold text-ink tracking-tight shrink-0",children:n("tutorial.title")}),l.jsx("p",{className:"text-xs text-ink-faint truncate",children:n("tutorial.subtitle")})]}),l.jsx("button",{onClick:()=>t(!1),className:"text-ink-faint hover:text-ink transition-colors mt-1",children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 pt-3 pb-1 min-h-[380px]",children:[l.jsx("p",{className:"text-2xs font-semibold text-accent mb-3 uppercase tracking-wider",children:d.label}),l.jsx("div",{className:`grid gap-4 ${d.steps.length===3?"grid-cols-1 sm:grid-cols-3":"grid-cols-1 sm:grid-cols-2"}`,children:d.steps.map(h=>l.jsxs("div",{className:"bg-surface border border-line/70 rounded-xl p-4 flex flex-col animate-fade-in",children:[l.jsx("div",{className:"w-full aspect-[120/72] bg-card rounded-lg border border-line/60 mb-3 overflow-hidden",children:UT[h]?l.jsx("img",{src:`/thoughtdag/tutorial/${UT[h]}-${a}.gif`,loading:"lazy",alt:"",className:"w-full h-full object-cover"}):iue[h]}),l.jsx("h3",{className:"text-[13px] font-semibold text-ink leading-snug",children:n(`tutorial.step${h}.title`)}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed mt-1.5",children:n(`tutorial.step${h}.desc`)})]},h))})]}),l.jsxs("div",{className:"px-7 py-4 shrink-0 flex items-center justify-between",children:[l.jsx("button",{onClick:()=>s(h=>Math.max(h-1,0)),disabled:r===0,className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center disabled:opacity-25 disabled:cursor-not-allowed",children:l.jsx(Nm,{size:16,strokeWidth:1.75})}),l.jsx("div",{className:"flex items-center gap-2",children:o.map((h,m)=>l.jsx("button",{onClick:()=>s(m),className:`h-2 rounded-full transition-all ${m===r?"w-6 bg-accent":"w-2 bg-line hover:bg-line-strong"}`,"aria-label":`${m+1}/${o.length}`},m))}),u?l.jsx("button",{onClick:()=>t(!1),className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors",children:n("tutorial.close")}):l.jsx("button",{onClick:()=>s(h=>h+1),className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center",children:l.jsx(Ba,{size:16,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 py-2.5 border-t border-line/60 shrink-0 flex flex-wrap gap-x-4 gap-y-1 text-2xs text-ink-faint font-mono",children:[l.jsxs("span",{children:[n("shortcut.panKeys")," ",n("shortcut.pan")]}),l.jsxs("span",{children:[n("shortcut.marqueeKeys")," ",n("shortcut.marquee")]}),l.jsxs("span",{children:["⌘","F ",n("shortcut.search")]}),l.jsxs("span",{children:["Space ",n("shortcut.collapse")]}),l.jsxs("span",{children:["R ",n("shortcut.regenerate")]}),l.jsxs("span",{children:["↑↓←→"," ",n("shortcut.navigate")]}),l.jsxs("span",{children:["⌘","Z/","⇧","⌘","Z ",n("shortcut.undo")]}),l.jsxs("span",{children:["Del ",n("shortcut.delete")]}),l.jsxs("span",{children:["Esc ",n("shortcut.escape")]})]})]})})}const lue=new URLSearchParams(window.location.search),_s=lue.get("dv"),Lc="https://chenxiachan.github.io/thoughtdag/docs",FM=[{version:"0.5.9",date:"2026-10-01",announce:!1,lead:{zh:"回忆与记忆的四处收口,都出自 #51 的复审:归档的节点退出回忆索引(这次启动会把索引重建一遍);画像文档的每一行记着来自哪个画布、哪天、是本人说的还是推断的,模型改写后不再丢;新拉出的空节点和阅读器底栏有了和追问框一样的联网、学术、回忆开关;基准的 repair 用例多了一格带陈旧标记的条件。",en:"Four follow-ups from the #51 review, all on recall and memory: archived nodes leave the recall index (the index rebuilds once on this start); every line of the profile documents keeps which canvas it came from, when, and whether you said it or it was inferred, through the model's rewrites; a fresh node and the reader's footer carry the same web, scholar and recall switches as a follow-up; the benchmark's repair cases gain a condition that carries the stale mark."},items:[]},{version:"0.5.8",date:"2026-09-30",announce:!1,lead:{zh:"修复 0.5.7 的一处遗漏:回答里的消毒把画布自己加的标记也剥掉了,从回答文字跳到分支的入口失效,用户高亮和探索标记都退化成默认黄底。现在两种标记保留各自的类和目标,跳转、点状下划线、高亮填色都回来了。",en:"Fixes an oversight in 0.5.7: the answer sanitizer also stripped the marks the canvas adds itself, so the jump from an answer to the branch it bore stopped working and highlights and explore marks fell back to the browser's plain yellow. Both marks keep their class and target again; the jump, the dotted underline and the highlight fill are back."},items:[]},{version:"0.5.7",date:"2026-09-30",announce:!1,lead:{zh:"安全修补:回答里的原始 HTML 先经过消毒再渲染,折叠块、上下标、键帽、高亮、表格、换行照旧,能执行脚本或嵌入外部页面的标签(iframe、object、script、style、form 等)被去掉;此前分享链接、导入的画布或模型引用的网页都能借 srcdoc 的 iframe 在本页面的源里执行代码。托管代理的模型探测只接受公网 https 地址,两处网页快照抓取共用一套地址检查并逐跳核对重定向。另外两处小修:「重跑上游已变」只跑确认框里数到的那些,牌子摘要不再参考已归档的步骤。",en:"Security: raw HTML in an answer is sanitized before rendering; folds, sub/sup, kbd, highlights, tables and line breaks stay, while tags that run scripts or embed pages (iframe, object, script, style, form and the like) are stripped. Until now a shared link, an imported canvas or a page the model quoted could run code in this origin through a srcdoc iframe. The hosted proxy's model probe takes public https endpoints only, and both page-snapshot fetchers share one address guard and check every redirect hop. Two small fixes: replay reruns exactly the stale nodes the dialog counts, and plaque summaries no longer read archived steps."},items:[]},{version:"0.5.6",date:"2026-09-30",announce:!1,lead:{zh:"回忆改成安静的小标签,默认关:输入框旁一个「回忆」,点开是开关、搜索范围(轻量 40 条 / 深挖 2,000 条 / 全量)和带入上下文,改的只对这一次提问生效,「设为默认」写回全局;深挖和全量由判断模型分批看候选,全量先告诉你条数、秒数和费用。判断模型页的开关并进供应商下拉(最后一项「关闭,按规则」);联网和学术搜索也默认关。每个节点都有可缩放的摘要:一句话的回答、笔记、文件都上梯子。双击卡片上的问题,侧栏编辑框带着原文打开。Harness 插件:思维图顶上是自己的标题带(不再压住红绿灯);自己的模型接口回来了,添加、拉模型列表、调用都走插件;不再提示桌面版新版本,插件更新提示直接说在插件页重新添加哪个包;桌面版 0.2 写的 v4 会话文件进得了对话地图。",en:`Recall is a quiet chip, off by default: a "Recall" beside the composer opens the switch, the search reach (light 40 / deep 2,000 / full) and the context brought in; a change there holds for the next ask only, "set as default" writes it back. Deep and full have the decision model read candidates in batches; full first says how many turns, seconds and dollars. The decision model page folds its switch into the provider dropdown (last entry: off, rules decide); web and scholar search start off too. Every node zooms: one-line answers, notes and files get a ladder. Double-clicking a card's question opens the side panel editor with the text in place. Harness plugin: the map wears its own title band (clear of the traffic lights); its own model interfaces are back, added, listed and called through the plugin; no more desktop-app update nudge, and the plugin's own notice names the package to re-add on the Plugins page; the 0.2 desktop's v4 session files reach the atlas.`},items:[]},{version:"0.5.5",date:"2026-09-29",announce:!1,lead:{zh:"换档不再互相盖住:缩小到地图层时,节点的牌子不会超出布局留给它的位置,写不下的摘要在底部渐隐,再放大一档就能看全;折叠卡显示和牌子同一段摘要,放大缩小之间只是字号在变。节点间距略微拉开,已有画布的位置不动,按「一键排版」才换成新间距。另外:从 Finder 启动时也能找到本机的 Pi、Codex、Claude Code 命令行,找不到会说明查过哪些地方,可重新检测;子 Agent 的运行展开在父画布上,作为那一轮旁边的分支;模型接口分成「慢思考 · 回答模型」和「快思考 · 判断模型」两页,只用 Agent 的人也能单独接判断模型;新装机没有模型时会先问一次本机的 Agent。",en:"Zoom tiers no longer cover each other: at map zoom a node's plaque stays inside the room the layout keeps for it, an abstract that runs past it fades out at the bottom and shows in full one step in; the folded card carries the same abstract as the plaque, so zooming only changes the type size. Node gaps open slightly; existing canvases keep their positions until you choose Tidy layout. Also: the Pi, Codex and Claude Code CLIs are found under a Finder launch, and a missing one says where it looked, with a recheck; a subagent's run unfolds on the parent canvas as a branch beside its turn; the model dialog has two pages, slow thinking for answering models and fast thinking for the decision model, which agent-only users can connect on its own; a fresh install with no model asks the local agents first."},items:[]},{version:"0.5.4",date:"2026-09-29",announce:!1,lead:{zh:"鼠标滚轮恢复缩放画布,和 0.5.2 一样。0.5.3 起滚轮改成了平移,这对触控板顺手,却让鼠标用户没法用滚轮缩放。触控板用户可以在画布 ⋯ 菜单打开「滚轮平移画布」:双指滑动即平移,捏合或按住 ⌘/Ctrl 滚动来缩放。",en:"The mouse wheel zooms the canvas again, as in 0.5.2. Since 0.5.3 it panned, which suits a trackpad but left mouse users without wheel zoom. On a trackpad, turn on ⋯ → Wheel pans the canvas: a two-finger scroll pans, pinch or hold ⌘/Ctrl while scrolling to zoom."},items:[]},{version:"0.5.3",date:"2026-09-27",announce:!1,lead:{zh:"圈选多个节点后,工具栏多了「更新节点摘要」:用当前选中的模型为它们一次更新四层摘要,文件、便签和短回答自动跳过。进度在右下角,随时可停。旧画布想整体升级到新摘要,圈一下就行。右键单个节点也是同一个入口。",en:'With several nodes selected, the toolbar gains "Update node summaries": the picked model updates their four summary levels in one go, files, notes and short answers skipped. Progress shows bottom right and can be stopped any time. An older canvas upgrades to the new summaries with one lasso; the right-click item on a single node is the same door.'},items:[{title:{zh:"🧭 摘要写的是这一步新增了什么",en:"🧭 Summaries say what the step adds"},body:{zh:"结论与短述改为由模型撰写。写之前它先读这条思路里前面各步的牌匾,只写本步新增的结论、决定或转向,不重复前面已经说过的;概要仍是原答里的原文摘句,作为证据。旧节点用「更新节点摘要」换新即可。",en:'The takeaway and brief are now written by the model. It first reads the plaques of the earlier steps in the thread, then writes only what this step adds, a conclusion, a decision or a turn, without repeating what came before; the abstract stays verbatim sentences of the answer, as evidence. Older nodes switch over with "Update node summaries".'}},{title:{zh:"🖐️ 触控板双指滑动即平移",en:"🖐️ Two-finger scroll pans"},body:{zh:"在触控板上双指滑动就能移动画布,不用再按住按键拖。捏合缩放不变。鼠标滚轮现在同样是平移,缩放请按住 ⌘(Windows 上是 Ctrl)再滚。感谢 @Pireirik 的贡献。",en:"On a trackpad, a two-finger scroll moves the canvas; no button to hold. Pinch still zooms. A mouse wheel now pans too; hold ⌘ (Ctrl on Windows) to zoom with it. Contributed by @Pireirik."}}]},{version:"0.5.2",date:"2026-09-27",announce:!0,lead:{zh:"🔍 上下文管理重大更新!现在,无论画布缩放至何种比例,节点内容始终保持极佳的阅读体验。",en:"🔍 A major update to context management! Whatever the zoom, every node on the canvas now stays a pleasure to read."},media:{src:{zh:"whats-new/zoom-ladder-zh.mp4",en:"whats-new/zoom-ladder-en.mp4"},alt:{zh:"缩小画布时,牌匾上的结论逐词长成短述再长成摘要",en:"Zooming out, a plaque's takeaway grows word by word into a brief, then an abstract"},width:960,height:600},items:[{title:{zh:"🪜 智能四层摘要",en:"🪜 Four smart summary levels"},body:{zh:"每个回答自动构建「主题、结论、短述、完整概要」四个递进层级,随缩放比例自动无缝切换。",en:"Every answer builds four progressive levels, topic, takeaway, brief and full abstract, and switches between them seamlessly as you zoom."}},{title:{zh:"✨ 丝滑的视觉过渡",en:"✨ Silky visual transitions"},body:{zh:"缩放时,文字会逐词自然展开或收起。保留的关键词会平滑移动,新文本自然淡入,核心重点始终高亮加深。视线聚焦零中断,数十个节点的全局脉络一眼即达。",en:"As you zoom, text unfolds or folds word by word. The words that stay glide into place, new text fades in, and the key points stay highlighted in full ink. Your focus is never broken, and the shape of dozens of nodes reads at a glance."}},{title:{zh:"🔁 新旧节点全面兼容",en:"🔁 New and old nodes alike"},body:{zh:"新回答自动生效该特性;旧节点会在浏览时实时生成摘要层级,若需更精准的 AI 总结,只需右键一键生成。",en:"New answers get it automatically; older nodes build their levels live as you browse, and for a sharper AI-selected summary, one right-click does it."}},{title:{zh:"🎚️ 时间线详略随手调",en:"🎚️ Timeline detail at your fingertips"},body:{zh:"时间线弹窗新增详略滑块,从主题一路拉到完整概要,字号与行距随手指流动,每一步文字完整呈现,告别省略号。",en:"The timeline overview gains a detail slider: glide from topic to full abstract, type and spacing flowing with your drag, every step shown whole, no ellipsis anywhere."},media:{src:{zh:"whats-new/timeline-detail-zh.mp4",en:"whats-new/timeline-detail-en.mp4"},alt:{zh:"拖动时间线弹窗的详略滑块,每一步的文字逐词展开",en:"Dragging the timeline overview's detail slider, each step's text unfolds word by word"},width:720,height:760}},{title:{zh:"🛡️ 所见即所发",en:"🛡️ What you see is what is sent"},body:{zh:"判断模型认定上游改动与答案无关时,「上游已变」标记现在同时从预览和请求中退场,两者始终一致。感谢 Agent Memory Atlas 的审阅指出这一点。",en:'When the decision model rules an upstream change irrelevant, the "upstream changed" mark now leaves the preview and the request together, always in step. Thanks to the Agent Memory Atlas review for catching it.'}},{title:{zh:"🧹 右键菜单焕新",en:"🧹 A refreshed right-click menu"},body:{zh:"「重新生成」更简洁,CLI 相关操作合并为一项,新增「用模型重选摘要」。手动修改过的回答会自动重做摘要。",en:'"Regenerate" is simpler, the CLI actions merge into one, and "Update node summary" joins the menu. Hand-edited answers get their summaries redone automatically.'}}]},{version:"0.5.1",date:"2026-09-26",announce:!1,lead:{zh:"0.5 之后的一批修正。删除正在生成的节点时,那一轮生成随之中止,不再在后台跑完。记忆的自动写入上限按画布分开计,切换画布后重新计;之前是全局三条写满就静默。档案更新只带走模型读过的那几条待归档事实,更新期间新归档的保留下来;档案文件的写入排队进行,不再互相覆盖。why 层不再把执行失败的文件操作算作改动足迹,更新后索引会重建一次。判断模型直接沿用模型接入里保存的 OpenRouter key,不再显示为空、测试不可点。",en:"A round of fixes after 0.5. Deleting a node that is still generating stops that generation instead of letting it run on in the background. The memory judge's automatic-write cap counts per canvas and starts over on a canvas switch; it used to be one global count of three, after which memory went quiet. A dossier update takes only the filed facts the model read and keeps anything filed while it was writing; dossier writes queue instead of overwriting one another. The why layer no longer counts a file operation the harness answered with an error as a change, and the index rebuilds once. The decision model uses the OpenRouter key saved with your model providers, instead of showing an empty field with a disabled test."},items:[]},{version:"0.5.0",date:"2026-09-26",announce:!0,lead:{zh:"🎉 ThoughtDAG 0.5:记忆上线。你在 Pi、Codex、Claude Code、DeepSeek Harness 里聊过的一切,现在接成一个可以回忆的整体。散在几百个会话里的碎片,按主题整理成档案;提问时相关的档案和对话自动带进上下文,跨 Agent、跨时间。背后是快思考与慢思考的分工:慢思考模型回答,快思考模型判断。所有信息都在你自己的机器上。",en:"🎉 ThoughtDAG 0.5: memory. Everything you discussed in Pi, Codex, Claude Code and DeepSeek Harness now forms one whole you can recall. Fragments scattered across hundreds of sessions are organised into dossiers by topic; when you ask, the relevant dossiers and conversations ride into the context, across agents and across time. Behind it, a division of labour: a slow-thinking model answers, a fast-thinking model decides. Everything stays on your machine."},items:[{title:{zh:"碎片串成一条线",en:"Fragments become a thread"},body:{zh:"昨天在 Codex 里定的阈值,上周在 Claude Code 里排除的方案,今天在画布上问起时都在。每个主题一份档案:是什么、定过什么、到哪一步、还没解决什么,每句都能点回原来的那轮对话。「你」是两份文档:偏好与身份,记到新东西时改写而不是堆砌。原来的记忆条目已并入。",en:"The threshold you settled in Codex yesterday and the approach you ruled out in Claude Code last week are there when you ask on the canvas today. Every topic keeps a dossier: what it is, what was decided, where it stands, what is still open, each line pointing back to its turn. Your profile is two documents, preferences and identity, rewritten rather than piled up. Earlier memory entries were folded in."},link:{label:{zh:"记忆指南",en:"The memory guide"},href:`${Lc}/zh/guides/memory`}},{title:{zh:"提问时自动回忆",en:"Recall as you ask"},media:{src:{zh:"whats-new/jev-recall.mp4",en:"whats-new/jev-recall.mp4"},alt:{zh:"回忆流程里,判断模型半秒内从候选片段中选出相关的几条",en:"In the recall flow the decision model picks the relevant excerpts from the candidates in under a second"},width:1200,height:720},body:{zh:"开着「回忆」提问,先判断问题涉及哪些主题,把档案整份带进去;问的是细节时再补几条原话。带了什么、花了多少,面板上一条一条看得见,不想要的划掉就不带。带入量三档:省、标准、多带。",en:"With recall on, a question is first matched to its topics and their dossiers ride in whole; a question about a detail brings a few verbatim excerpts too. What came in and what it cost is listed item by item; strike one and it stays out. Three amounts: lean, standard, generous."}},{title:{zh:"快思考,慢思考",en:"Fast thinking, slow thinking"},body:{zh:"回答你的是慢思考模型。判断「这条相关吗」「这句是决定吗」「这处改动影响吗」的是快思考模型:半秒一次,返回校准过的概率,让回忆、地图徽章和「上游已变」都有依据。模型选择器里一行开关,默认开;关掉全部退回规则,功能不变。",en:"The slow-thinking model answers you. The fast-thinking model decides — is this relevant, is this line a decision, does this change matter — in half a second, with calibrated probabilities, so recall, map badges and “upstream changed” rest on evidence. One switch in the model picker, on by default; off, every decision falls back to a rule and nothing stops working."}},{title:{zh:"接入一个快思考模型",en:"Connect a fast-thinking model"},body:{zh:"Jev 类判断模型可以经你已保存的聚合商接入直接使用,也支持官方接口和自建服务;没有接入时会提示,一切照常。",en:"A Jev-class decision model runs through the aggregator access you already saved, through the official endpoint, or from a self-hosted server; without one you are told, and everything still works."},link:{label:{zh:"怎么接入",en:"How to connect one"},href:`${Lc}/zh/setup#decision-model`}},{title:{zh:"一切都在本地",en:"All of it stays local"},body:{zh:"索引、主题标签、档案存在本机 .thoughtdag 目录,画像文档存在应用本地。判断时发出去的只有问题和候选片段,发给你自己选的接入。",en:"The index, topic labels and dossiers live in your machine's .thoughtdag folder; your profile lives in the app's own storage. A decision sends only the question and the candidate excerpts, to the access you chose."}}]},{version:"0.4.20",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件一轮实测后的整理。「对话 | 思维图」开关:对话页顶部仍是浮动的,切到思维图后它移到画布顶栏「画布名」右侧,不再压住画布工具栏。工作目录改用 Harness 自己的目录选择器:本机运行时弹的就是系统的文件夹对话框,远程访问时回落为输入路径;0.4.19 里自带的目录浏览器撤掉。Harness Agent 也能选工作目录,新会话按所选目录运行。插件里去掉配置模型 API 的入口。实时镜像刷新会话时不再把镜头拉回节点。节点记录的是发起请求时的模型,执行中切换选择器不再改写徽章。Harness 执行中的每个工具调用都列为一条步骤,思考尾巴显示在下方。备份提醒去掉。",en:"DeepSeek Harness plugin, after a round of hands-on testing. The 对话 | 思维图 switch still floats over the chat; on the canvas it sits in the canvas's own top bar next to the canvas chip, so it never covers the toolbar. The working directory is chosen in the harness's own picker: the system folder dialog when the harness runs on this machine, a typed path when reached remotely; the folder browser 0.4.19 carried is withdrawn. The Harness Agent gets the folder chip too, and a fresh session runs where it says. The API-key door is gone inside the plugin. The live mirror no longer drags the camera back to a node while its session refreshes. A node records the model it was asked with; switching the picker mid-run no longer relabels it. Every tool call of a harness run is listed as a step, the thinking beneath. The backup reminder is removed."},items:[]},{version:"0.4.19",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:Harness Agent 节点的回答不再「闪一下就没了」。新版 Harness(0.1.5-rc.3)不再把逐字流写进会话日志,一步只落一条 assistant/message;画布续读实时日志时按会话列表报的序号少读了一条,恰好是带答案的那条,节点随后被镜像成空回答。现在按实际持有的最后一条事件续读,且镜像永不把已有回答改写为空。思考过程重新同步显示:宿主订阅 Harness 新的流事件(agent/assistant-stream),正文和思考逐字到达节点,没有流的运行时从每步的 reasoning 块补发。「对话 | 思维图」开关回到浮动位置,空态也能切换(0.4.18 的标题栏开关撤回)。Agent 的工作目录改为浏览宿主机的文件夹来选,也仍可直接输入路径。",en:"DeepSeek Harness plugin: a Harness Agent node no longer shows its answer for a moment and then loses it. Newer Harness builds (0.1.5-rc.3) stop writing the token stream into the session log; a step lands as one assistant/message. When the canvas read the live log incrementally it asked from the seq the session list reported and skipped exactly one event, the one carrying the answer, and the node was then mirrored as an empty reply. It now continues from the last event it actually holds, and a mirror never rewrites an existing answer to nothing. Reasoning shows live again: the host subscribes to the Harness's new stream event (agent/assistant-stream), so text and reasoning reach the node as they are produced; a runtime without that stream gets each step's reasoning block instead. The 对话 | 思维图 switch floats again and works on the empty page (the 0.4.18 header switch is withdrawn). An agent's working directory is chosen by browsing the host's folders, with a path field still there for typing."},items:[]},{version:"0.4.18",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:历史会话列表在新版 Harness 上不再为空。dsh 从 0.1.5-rc.2 起把会话格式版本写进日志文件名(session.v3.jsonl.zstd),插件现在按已知文件名探测,新旧两种都认(#44,感谢 @LHN-xiao-hai-tun)。模型选择器加宽,条目悬停显示完整名称,Agent 执行组的长名字改为换行而不是截断,flash 与 flash-vision 一眼可辨(#43)。",en:"DeepSeek Harness plugin: the list of past sessions is no longer empty on newer Harness builds. From 0.1.5-rc.2 dsh writes the session format version into the log file name (session.v3.jsonl.zstd); the plugin now probes the known names and reads both (#44, thanks @LHN-xiao-hai-tun). The model picker is wider, every entry shows its full name on hover, and long names in the agent group wrap instead of being cut, so flash and flash-vision tell apart at a glance (#43)."},items:[]},{version:"0.4.17",date:"2026-09-21",announce:!1,lead:{zh:"DeepSeek Harness 插件:从画布向 Harness 提问时,节点只接自己那一轮。此前如果你同时在聊天框里发消息,画布节点会拿到你那轮的回答、在你那轮结束时提前收尾,并把镜像标记挂到错误的轮次上,产生重复节点;工具审批也可能被画布抢走。现在 Host 用 dsh 记在消息上的请求 id 精确认出自己的那一轮,文本、工具调用、审批、结束全部按这一轮过滤(#42,感谢 @nanami-0713)。桌面版本次只同步版本号。",en:"DeepSeek Harness plugin: a question asked from the canvas now receives only its own turn. Before, if you were also typing in the chat, the canvas node could receive your turn's answer, finish early when your turn ended, and stamp its mirror mark on the wrong turn, leaving duplicate nodes; tool approvals could be captured by the canvas as well. The host now recognises its own turn by the request id dsh records on the message, and filters text, tool calls, approvals and the end of turn to that turn alone (#42, thanks @nanami-0713). The desktop app only moves its version number."},items:[]},{version:"0.4.16",date:"2026-09-17",announce:!1,lead:{zh:"分区框:两个只是部分重叠的框不再互相收编。拖动大框时,重叠的小框和它自己的节点留在原地;拖动和一键排版现在用同一条成员规则,普通节点按中心点归属,框只有完整落在另一个框里才算它的成员(#40,感谢 @nanami-0713)。DeepSeek Harness 插件:「插件有新版本」提示复制的命令带上具体版本号,发版当天也能立刻装到新版。",en:"Frames: two frames that merely overlap no longer own each other. Dragging the larger one leaves the overlapping smaller frame and its own nodes in place; dragging and auto layout now share one membership rule, nodes by centre and a frame only when it lies fully inside another (#40, thanks @nanami-0713). DeepSeek Harness plugin: the update hint now copies a command naming the exact version, so a release installs on its first day too."},items:[]},{version:"0.4.15",date:"2026-09-15",announce:!1,lead:{zh:"分区框三件事:一键排版后,框跟着框内的节点重新包好(#32);拖动外框会带动嵌套在里面的框;重叠时小框叠在大框上面,标题栏不再被盖住。三项均来自 @hexu321。DeepSeek Harness 插件:「对话 | 思维图」切换器移进会话标题栏,不再遮挡标题;返回按钮居中,画布右上的工具栏保持可见;从画布切回会话的跳转修好了(#30,来自 @nanami-0713)。插件重新在 npm 上发布,安装命令恢复为包名。",en:"Frames, three fixes: after auto layout a frame re-wraps the nodes it held (#32); dragging an outer frame carries the frames nested inside it; where frames overlap, the smaller one stacks on top so its title bar stays reachable. All three by @hexu321. DeepSeek Harness plugin: the 对话 | 思维图 switch moves into the session header and no longer covers the title; the back button sits top centre, clear of the canvas toolbar; jumping from the canvas back to a session works again (#30, by @nanami-0713). The plugin is back on npm and the install command is the package name again."},items:[]},{version:"0.4.14",date:"2026-09-11",announce:!1,lead:{zh:"插件的「有新版本」提示现在复制 dsh plugin --profile web add dsh-thoughtdag@latest,这条命令对从 npm 装和从 Release 文件装的用户都有效(update 对文件安装无效)。其余同 0.4.13。",en:"The plugin's update hint now copies dsh plugin --profile web add dsh-thoughtdag@latest, which works for installs from npm and from a release file alike (update does nothing for a file install). Otherwise the same as 0.4.13."},items:[]},{version:"0.4.13",date:"2026-09-11",announce:!1,lead:{zh:"修复:DeepSeek Harness 插件里,模型选择器丢失了「Harness · 模型」这一组 Agent 条目(0.4.11 起,机器上没装 Pi、Codex 等命令行时整组消失)。原因是思维图把 Harness 给的条目当成本机命令行的探测结果替换掉了,现在只替换命令行报来的那几种。插件里「如何使用」的教程动图也能显示了(#35,感谢 @Moya-Doc)。",en:`Fix: inside the DeepSeek Harness plugin, the model picker lost the "Harness · model" agent entries (since 0.4.11; with no Pi or Codex CLI on the machine the whole group vanished). The canvas had been replacing the harness's entries with the local CLI probe; now only the entries the CLIs report get replaced. The tutorial gifs inside the plugin load again (#35, thanks @Moya-Doc).`},items:[]},{version:"0.4.12",date:"2026-09-10",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 子节点现在续接父节点的会话;同一父节点下的第二个分支从父节点那一轮分叉出自己的会话,preset 的会话状态不再在每个子节点重头开始(#28、#29)。插件的构建脚本在 Windows 上也能跑了(#24、#26)。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an agent child node now continues its parent's session, and a second branch off the same parent forks its own session at that parent's turn, so a preset's session state no longer restarts at every child (#28, #29). The plugin's build script runs on Windows too (#24, #26). The desktop app only moves its version number."},items:[]},{version:"0.4.11",date:"2026-09-08",announce:!1,lead:{zh:"性能优化:启动更快,后台更省,多个工具调用并行时更稳;300 节点以上的画布实测流畅。ThoughtDAG 现在可以用 Claude Code、Codex、Pi 作为节点的 Agent 运行时,处于测试阶段。",en:"Performance: faster launch, lighter in the background, steadier when several tool calls run in parallel; canvases past 300 nodes measured smooth. ThoughtDAG can now run a node through Claude Code, Codex or Pi as its agent runtime, in testing."},items:[]},{version:"0.4.10",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览继续:Codex 加入,和 Pi 一样在画布里带工具作答;这条通道现在在桌面版、本地网页版和 DeepSeek Harness 插件里都可用;插件里的 Harness Agent 按模型平铺;插件有新版本时画布会提示。",en:"Agent runs, preview continued: Codex joins Pi, answering with tools right from the canvas; the lane now works in the desktop app, the local web app and the DeepSeek Harness plugin alike; inside the plugin the Harness agent lists one entry per model; the canvas tells you when a newer plugin is out."},items:[]},{version:"0.4.9",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览:桌面版的模型选择器多了「Agent 执行」组,装了 Pi 的话可以直接在画布里让它带工具作答,轨迹、足迹、审批和提问都落在节点上,工作目录在顶栏可见可改。正式版会连同 Claude Code 与 Codex 一起发布。DeepSeek Harness 插件里的审批卡片同步更新。",en:'Agent runs, preview: the desktop picker gains an "Agent runs" group; with Pi installed, a question runs through it with tools right from the canvas, and the trace, footprints, approvals and questions land on the node, with the working directory visible on the toolbar. The full release will arrive together with Claude Code and Codex. The approval card inside the DeepSeek Harness plugin is updated alike.'},items:[]},{version:"0.4.8",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件在 Windows 上能打开了:静态资源和会话目录的路径守卫此前只认正斜杠,Windows 用户看到的是一片 403。感谢 GitHub 上的报告(#23)。桌面版本次只同步版本号。",en:"The DeepSeek Harness plugin now opens on Windows: the path guards for static assets and session directories only accepted forward slashes, so Windows users saw nothing but 403s. Thanks to the report on GitHub (#23). The desktop app only moves its version number this time."},items:[]},{version:"0.4.7",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 需要你批准的操作现在直接出现在节点上:工具、命令、理由,允许一次或拒绝,决定留在节点记录里。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an action the agent needs approved now appears on the node itself: tool, command, reason, allow once or reject, and the decision stays in the node's record. The desktop app only moves its version number this time."},items:[]},{version:"0.4.6",date:"2026-09-06",announce:!0,lead:{zh:"🎉 Pi 的会话进了对话地图,「⋯」菜单里多了更新历史,随时能回看每一版改了什么。",en:"🎉 Pi sessions join the Session Atlas, and the ⋯ menu gains a release history, so what every version changed is one click away."},items:[{title:{zh:"Pi 的会话也在地图上了",en:"Pi sessions are on the map"},body:{zh:"本地 Pi 会话按项目聚在一起,打开就是一张图。Pi 里的每次分叉在图上就是一条支线,不再压成一条直线。命令行 why 和 MCP 也同步认识 Pi 留下的文件足迹。",en:"Local Pi sessions group by project and open as a graph. Every fork you made in Pi shows up as a branch instead of being flattened into one line. The why command and MCP index Pi's file footprints too."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"更新历史,随时补看",en:"Release history, whenever you like"},body:{zh:"右上「⋯」菜单,「如何使用」下面。每个版本改了什么都在这里,从新到旧,当前版本有标记。",en:"In the ⋯ menu, under How it works: what each release changed, newest first, with the version you are running marked."}}]},{version:"0.4.5",date:"2026-09-06",announce:!0,lead:{zh:"🎉 这是 ThoughtDAG 到目前为止最大的一次升级:散在各个 Agent 里的对话接成了一张地图,能从画布里查,还能直接在 DeepSeek Harness 里用。四件新东西,都值得试一试。",en:"🎉 The biggest ThoughtDAG release so far: the conversations scattered across your agents become one map, you can query them, and it all runs inside DeepSeek Harness. Four new things, each worth a try."},items:[{title:{zh:"跨 Agent 的对话地图,终于连成一张",en:"Session Atlas: all your agents, one map"},body:{zh:"Claude Code、Codex 和 DeepSeek Harness 的本地会话按项目文件夹聚在一起,点开就是一张图,随对话实时生长。",en:"Local Claude Code, Codex and DeepSeek Harness sessions, grouped by project; open one as a graph and it follows the conversation live."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"命令行 why:一条命令找回塑造文件的那些对话",en:"thoughtdag why: one command finds the conversations that shaped a file"},body:{zh:"npx thoughtdag why <文件> 列出哪些轮次读过、改过它,当时问了什么、改了什么;find 按原话搜,MCP 让 Agent 自己来查。",en:"npx thoughtdag why <file> lists the turns that read or changed it, what was asked and what changed; find searches verbatim; MCP lets your agent ask."},link:{label:{zh:"命令与 MCP",en:"CLI and MCP"},href:`${Lc}/zh/guides/why-layer`}},{title:{zh:"DeepSeek Harness 插件上线",en:"DeepSeek Harness plugin is live"},body:{zh:'dsh plugin --profile web add dsh-thoughtdag,Harness 的网页里多一个"思维图"视图:在画布上提问、让 Harness 的 Agent 带工具作答,why 也成了它的原生工具。',en:"dsh plugin --profile web add dsh-thoughtdag adds a canvas view to the Harness web UI: ask from the canvas, let its agent answer with tools, and why becomes a native tool there."},link:{label:{zh:"插件说明",en:"Plugin README"},href:"https://github.com/chenxiachan/thoughtdag/tree/main/dsh#readme"}},{title:{zh:"文档站上线",en:"The docs site is live"},body:{zh:"概念、任务指南、命令字典和隐私说明各有一页,中英文对照。感谢一路同行,欢迎来 Discussions 说说你怎么用它。",en:"Concepts, task guides, the command dictionary and the privacy notes, each on its own page, in both languages. Thank you for coming this far with us; tell us how you use it in Discussions."},link:{label:{zh:"打开文档",en:"Open the docs"},href:`${Lc}/zh/`}}]},{version:"0.4.4",date:"2026-09-04",announce:!1,lead:{zh:"DeepSeek Harness 成为对话地图的内置来源:它的 zstd 日志由桌面壳逐帧解码,每条消息一个节点,工具调用与结果配对成附件。",en:"DeepSeek Harness becomes a built-in Atlas source: the shell decodes its zstd logs frame by frame, one node per message, tool calls paired with their results as attachments."},items:[]},{version:"0.4.3",date:"2026-09-03",announce:!1,lead:{zh:"深链接可以直达某一轮,画布可以按稳定 id 打开;子 Agent 的会话文件不再打扰实时监听。",en:"A deep link can land on a turn and a canvas opens by its stable id; subagent session files no longer disturb the live watcher."},items:[]},{version:"0.4.2",date:"2026-09-02",announce:!1,lead:{zh:"镜像节点列出那一轮碰过的文件(✏️ 改过、📖 读过),预览用结论而不是开头;子 Agent 的会话作为子线程识别,报告折回发起它的那一轮。",en:"A mirrored node lists the files its turn touched (✏️ edited, 📖 read) and previews the conclusion rather than the opening line; subagent files are recognized as sub-threads and their reports fold into the launching turn."},items:[]},{version:"0.4.1",date:"2026-09-01",announce:!1,lead:{zh:"Agent 对话地图首发:本地 Claude Code 与 Codex 的会话按项目文件夹聚成一张图,一键接入,随对话实时生长。",en:"Session Atlas debuts: local Claude Code and Codex sessions group by project folder into one map, connect in one click, and grow with the conversation."},items:[]}];function $y(e,t){const n=e.split(".").map(r=>parseInt(r,10)||0),a=t.split(".").map(r=>parseInt(r,10)||0);for(let r=0;r<Math.max(n.length,a.length);r++){const s=(n[r]??0)-(a[r]??0);if(s!==0)return s}return 0}function tm(e,t){return FM.filter(n=>n.announce&&$y(n.version,t)<=0&&(e===null||$y(n.version,e)>0))}const Wy="thoughtdag.whatsNewSeen",cue=new URLSearchParams(window.location.search);function uue(){if(!_s)return[];const e=cue.get("wn");if(e==="1")return tm(null,_s);if(e)return tm(e,_s);let t=null;try{t=localStorage.getItem(Wy)}catch{}if(t===null){let n=!1;try{n=!!(localStorage.getItem("thoughtdag.tutorialDone")||localStorage.getItem("thoughtdag.lastBackupAt"))}catch{}if(!n){try{localStorage.setItem(Wy,_s)}catch{}return[]}return tm(null,_s)}return t===_s?[]:tm(t,_s)}function UM({media:e,lang:t}){const n=e.src[t],a=/\.(mp4|webm)$/i.test(n);return l.jsx("div",{className:"mt-3 rounded-xl border border-line overflow-hidden bg-wash",style:{aspectRatio:`${e.width} / ${e.height}`},"data-whats-new-media":!0,children:a?l.jsx("video",{src:`/thoughtdag/${n}`,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-full object-cover","aria-label":e.alt[t]}):l.jsx("img",{src:`/thoughtdag/${n}`,alt:e.alt[t],className:"w-full h-full object-cover"})})}function qM({items:e,lang:t}){return e.length===0?null:l.jsx("ol",{className:"divide-y divide-line",children:e.map((n,a)=>l.jsxs("li",{className:"py-3 flex gap-3.5",children:[l.jsx("span",{className:"shrink-0 w-6 h-6 rounded-full bg-accent/10 text-accent text-xs font-semibold flex items-center justify-center mt-0.5",children:a+1}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-ink",children:n.title[t]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1 [overflow-wrap:anywhere]",children:n.body[t]}),n.media&&l.jsx(UM,{media:n.media,lang:t}),n.link&&l.jsxs("a",{href:n.link.href,target:"_blank",rel:"noreferrer",className:"inline-block mt-1.5 text-xs font-medium text-accent hover:underline",children:[n.link.label[t]," →"]})]})]},a))})}function due(){const[e,t]=D.useState(()=>uue()),n=e.length>0,a=Da(u=>u.lang),r=St(),s=D.useRef(null),o=()=>{if(_s)try{localStorage.setItem(Wy,_s)}catch{}t([])};return D.useEffect(()=>{if(!n)return;s.current?.focus({preventScroll:!0});const u=d=>{d.stopPropagation(),(d.key==="Escape"||d.key==="Enter")&&o()};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[n]),n?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:o,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:u=>u.stopPropagation(),role:"dialog","aria-labelledby":"whats-new-title","data-whats-new":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"whats-new-title",className:"text-base font-semibold text-ink mt-0.5",children:ye(r("whatsNew.title"),{v:_s??""})}),e.length>1&&l.jsx("p",{className:"text-xs text-ink-faint mt-1",children:r("whatsNew.multi")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:e.map(u=>l.jsxs("li",{className:"py-4","data-release":u.version,children:[e.length>1&&l.jsxs("div",{className:"flex items-baseline gap-2.5 mb-1.5",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",u.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:u.date})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed [overflow-wrap:anywhere]",children:u.lead[a]}),u.media&&l.jsx(UM,{media:u.media,lang:a}),l.jsx(qM,{items:u.items,lang:a})]},u.version))}),l.jsxs("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex items-center justify-between gap-4",children:[l.jsx("button",{onClick:()=>{o(),oe.getState().setReleaseNotesOpen(!0)},className:"text-xs text-ink-muted hover:text-ink hover:underline transition-colors","data-whats-new-all":!0,children:r("whatsNew.seeAll")}),l.jsx("button",{ref:s,onClick:o,className:"text-xs text-white px-4 py-2 rounded-lg bg-accent hover:bg-accent-strong transition-colors",children:r("whatsNew.ok")})]})]})}):null}function hue(){const e=St(),t=oe(a=>a.ladderJob);if(D.useEffect(()=>{if(!t||t.running)return;const a=setTimeout(xT,8e3);return()=>clearTimeout(a)},[t]),!t)return null;const n=t.total?Math.min(1,(t.done+t.failed)/t.total):1;return l.jsxs("div",{className:"fixed bottom-4 right-4 z-[85] w-[300px] bg-card border border-line rounded-xl shadow-lg px-4 py-3 animate-fade-in","data-ladder-job":!0,"data-ladder-job-running":t.running?"yes":"no",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(h2,{size:14,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-ink flex-1",children:e("ladder.jobTitle")}),t.running?l.jsxs("button",{onClick:kle,disabled:t.cancelled,className:"flex items-center gap-1 text-2xs text-ink-muted hover:text-red-600 disabled:opacity-50","data-ladder-job-stop":!0,children:[l.jsx(q0,{size:10,strokeWidth:1.75,fill:"currentColor"})," ",t.cancelled?e("ladder.jobStopping"):e("ladder.jobStop")]}):l.jsx("button",{onClick:xT,className:"text-ink-faint hover:text-ink",title:e("ladder.jobClose"),"data-ladder-job-close":!0,children:l.jsx(cn,{size:13,strokeWidth:1.75})})]}),l.jsx("div",{className:"mt-2 h-1 rounded-full bg-wash overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent transition-[width] duration-300",style:{width:`${Math.round(n*100)}%`}})}),l.jsx("p",{className:"mt-1.5 text-2xs text-ink-muted tabular-nums","data-ladder-job-line":!0,children:t.running?ye(e("ladder.jobProgress"),{n:t.done+t.failed,m:t.total,model:t.model}):(t.cancelled?ye(e("ladder.jobStopped"),{n:t.done}):ye(e("ladder.jobDone"),{n:t.done,k:t.skipped}))+(t.failed?ye(e("ladder.jobFailed"),{f:t.failed}):"")}),!t.running&&t.failed>0&&t.lastError&&l.jsx("p",{className:"mt-1 text-2xs text-red-500 break-words","data-ladder-job-error":!0,children:t.lastError})]})}function fue(){const e=oe(r=>r.releaseNotesOpen),t=oe(r=>r.setReleaseNotesOpen),n=Da(r=>r.lang),a=St();return D.useEffect(()=>{if(!e)return;const r=s=>{s.key==="Escape"&&(s.stopPropagation(),t(!1))};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t]),e?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:r=>r.stopPropagation(),role:"dialog","aria-labelledby":"release-notes-title","data-release-notes":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"release-notes-title",className:"text-base font-semibold text-ink mt-0.5",children:a("releaseNotes.title")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:FM.map(r=>{const s=_s===r.version;return l.jsxs("li",{className:"py-4","data-release":r.version,children:[l.jsxs("div",{className:"flex items-baseline gap-2.5 flex-wrap",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",r.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:r.date}),s&&l.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-accent bg-accent/10 rounded-full px-2 py-0.5",children:a("releaseNotes.current")})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1.5 [overflow-wrap:anywhere]",children:r.lead[n]}),l.jsx(qM,{items:r.items,lang:n})]},r.version)})}),l.jsx("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex justify-end",children:l.jsx("button",{onClick:()=>t(!1),className:"text-xs text-ink px-4 py-2 rounded-lg border border-line hover:bg-wash transition-colors",children:a("common.close")})})]})}):null}const Nb=e=>e.split("/").filter(Boolean).slice(-1)[0]??e;function mue(){const e=St(),t=oe(_=>_.selectedModel),n=sn(_=>_.activeId),a=sn(_=>_.projects),r=se(_=>_.nodes.length),[s,o]=D.useState(null),[u,d]=D.useState(null),[h,m]=D.useState(!1),[p,x]=D.useState(""),[,b]=D.useState(0),y=D.useRef(null),w=!!window.desktopSessions&&N2(t),E=!!window.desktopAgents&&(si(t)||w);if(D.useEffect(()=>{if(!E)return;let _=!0;return F2(w).then(S=>{_&&o(S)}),DV().then(S=>{_&&d(S)}),()=>{_=!1}},[E,w,n,a,r]),D.useEffect(()=>{if(!h)return;const _=z=>{y.current&&!y.current.contains(z.target)&&m(!1)},S=z=>{z.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",S)}},[h]),!E||!s)return null;const v=a.find(_=>_.id===n),A=[...new Set(a.map(_=>_.agentCwd).filter(_=>!!_))].filter(_=>_!==v?.agentCwd).slice(0,5),T=async _=>{n&&(await G2(n,_),m(!1))},C=window.desktopAgents?.capabilities?.nativePicker!==!1,I=async()=>{const _=await window.desktopAgents.pickCwd();_?await T(_):window.desktopAgents?.capabilities?.nativePicker===!1&&b(S=>S+1)},O=async()=>{const _=p.trim();_.startsWith("/")&&await T(_)};return l.jsxs("div",{ref:y,className:"relative",children:[l.jsxs("button",{onClick:_=>{_.stopPropagation(),m(S=>!S)},className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-2.5 flex items-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-xs text-ink max-w-[220px]",title:`${e("agent.cwd")} · ${s.cwd}`,"data-agent-cwd":s.kind,children:[l.jsx(lu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate",children:s.kind==="workspace"?e("agent.cwdWorkspace"):Nb(s.cwd)}),l.jsx(cr,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"})]}),h&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 w-[320px] bg-card border border-line rounded-xl shadow-lg py-1.5 z-50 animate-fade-in",onClick:_=>_.stopPropagation(),children:[l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.cwd")}),l.jsxs("button",{onClick:()=>{T(void 0)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:u?e("agent.cwdMirrored"):s.kind==="session"?e("agent.cwdSession"):e("agent.cwdWorkspace")}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:u??(s.kind==="session"?s.cwd:e("agent.cwdWorkspaceHint"))})]}),!v?.agentCwd&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),v?.agentCwd&&l.jsxs("button",{onClick:()=>{T(v.agentCwd)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Nb(v.agentCwd)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:v.agentCwd})]}),l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),A.length>0&&l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-2 pb-1",children:e("agent.cwdRecent")}),A.map(_=>l.jsx("button",{onClick:()=>{T(_)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2",children:l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Nb(_)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:_})]})},_)),l.jsx("div",{className:"border-t border-line/60 my-1"}),C?l.jsxs("button",{onClick:()=>{I()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash flex items-center gap-2","data-agent-cwd-pick":!0,children:[l.jsx(lu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",e("agent.cwdPick")]}):l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("input",{value:p,onChange:_=>x(_.target.value),onKeyDown:_=>{_.stopPropagation(),_.key==="Enter"&&O()},placeholder:e("agent.cwdType"),className:"flex-1 min-w-0 text-xs font-mono bg-wash border border-line rounded-md px-2 py-1 focus:outline-none focus:border-accent/60","data-agent-cwd-input":!0}),l.jsx("button",{onClick:()=>{O()},className:"text-xs text-accent hover:underline shrink-0",children:e("agent.cwdUse")})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.guard")}),l.jsxs("button",{onClick:()=>{qE("ask"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"ask",children:[l.jsx(IU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAsk")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAskHint")})]}),(v?.agentGuard?.mode??"ask")==="ask"&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),l.jsxs("button",{onClick:()=>{qE("allow"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"allow",children:[l.jsx(DU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAllow")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAllowHint")})]}),v?.agentGuard?.mode==="allow"&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),(v?.agentGuard?.allow?.length??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-2xs text-ink-faint px-3 pt-2 pb-1",children:e("agent.guardAllowed")}),v.agentGuard.allow.map(_=>l.jsxs("div",{className:"px-3 py-1 text-xs flex items-center gap-2 min-w-0","data-agent-guard-allowed":_,children:[l.jsx("span",{className:"flex-1 min-w-0 truncate text-ink-muted font-mono",title:_,children:_}),l.jsx("button",{onClick:()=>{M7(_,!0)},className:"text-ink-faint hover:text-red-500 shrink-0",title:e("agent.guardRemove"),children:l.jsx(cn,{size:12,strokeWidth:2})})]},_))]})]})]})}const qT="thoughtdag.pluginUpdateNotified";function Vy(e){return`dsh plugin --profile web add dsh-thoughtdag@${e||"latest"}`}async function pue(e){try{const t=await fetch(e.replace(/\/+$/,"")+"/version",{credentials:"same-origin"});if(!t.ok)return;const n=await t.json();if(!n.version||!n.latest||$y(n.latest,n.version)<=0)return;oe.getState().setPluginUpdate({current:n.version,latest:n.latest});let a=null;try{a=localStorage.getItem(qT)}catch{}if(a!==n.latest){try{localStorage.setItem(qT,n.latest)}catch{}const r=oe.getState().harnessHost?.desktop??(()=>{try{const s=window.parent?.document?.documentElement;return!!s&&(s.dataset.platform!==void 0||s.hasAttribute("data-windows-titlebar"))}catch{return!1}})();We("info",ye(Te("plugin.updateAvailable"),{v:n.latest})+(r?" "+ye(Te("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${n.latest}`}):""),12e3)}}catch{}}const gue=Object.freeze(Object.defineProperty({__proto__:null,bootPluginUpdateCheck:pue,pluginUpdateCommand:Vy},Symbol.toStringTag,{value:"Module"})),xue={ruleout:"#ef4444",decision:"#6B5CE7",pivot:"#e8890c",open:"#d97706",insight:"#0284c7"},$T=e=>{if(e){for(let t=e.length-1;t>=0;t--)if(e[t])return e[t]}};function bue(e){if(e.stepKind==="file")return e.attachments?.[0]?.name;if(e.stepKind==="link")return e.linkTitle||e.linkUrl;if(e.stepKind==="note")return e.question?.split(`
|
|
907
|
+
${m}`.slice(-1500)}const d=nue(e,o,t);if(Tl!==a)return;oe.getState().setCondenseRun({status:"done",streaming:"",distillIds:d.distillIds}),We("success",Te("condense.copyReady"),8e3,{label:Te("tmap.export"),run:()=>oe.getState().setThoughtMapOpen(!0)})}catch(o){if(Tl!==a)return;oe.getState().setCondenseRun({status:"error",error:o instanceof Error?o.message:String(o)})}}function sue({onFocusSegment:e}){const t=oe(P=>P.condenseDialogOpen),n=oe(P=>P.condenseRun),a=St(),r=Da(P=>P.lang),s=se(P=>P.nodes),o=se(P=>P.edges),[u,d]=D.useState(0),h=D.useMemo(()=>t&&n.status==="idle"?Zce(s,o):[],[t,n.status,s,o,u]),m=oe(P=>P.selectedModel),p=Yl()?.models??[],[x,b]=D.useState(""),[y,w]=D.useState(new Set),[E,v]=D.useState(null),A=D.useRef(null),T=P=>{const L=A.current?.getBoundingClientRect();if(!L)return;const Y=P.clientX-L.left,q=P.clientY-L.top,B=$=>v({x:Math.min(window.innerWidth-120,Math.max(0,$.clientX-Y)),y:Math.min(window.innerHeight-80,Math.max(0,$.clientY-q))}),j=()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",j)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",j)},C=P=>P.nodeIds.join(","),I=h.filter(P=>!y.has(C(P))),O=I.reduce((P,L)=>P+L.saving,0),_=()=>{oe.getState().setCondenseDialogOpen(!1),oe.getState().setCondenseHighlightIds([])};if(D.useEffect(()=>{if(!t)return;const P=L=>{L.key==="Escape"&&_()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),!t)return null;const S=()=>{I.length!==0&&rue(I,r,x||m||void 0)},z=()=>{se.getState().setArchived(n.originalIds,!0),We("success",a("condense.originalArchived")),oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:"",originalIds:[],distillIds:[]}),_()},V=()=>{const L=se.getState().nodes.filter(Y=>n.distillIds.includes(Y.id));L.length&&e?.(L.map(Y=>Y.id))};return ur.createPortal(l.jsxs("div",{ref:A,className:"fixed z-[70] bg-surface border border-line rounded-2xl shadow-2xl w-[400px] max-h-[72vh] flex flex-col p-4 animate-fade-in",style:E?{left:E.x,top:E.y}:{left:80,bottom:16},"data-condense-dialog":!0,onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between mb-1 cursor-grab active:cursor-grabbing select-none",onMouseDown:T,children:[l.jsxs("div",{className:"text-sm font-semibold text-ink flex items-center gap-2",children:[l.jsx(bp,{size:15,strokeWidth:1.75,className:"text-accent"})," ",a("condense.title")]}),l.jsx("button",{onClick:_,title:n.status==="building"?a("condense.runningBg"):void 0,className:"text-ink-faint hover:text-ink rounded-lg w-7 h-7 flex items-center justify-center hover:bg-wash transition-colors",children:l.jsx(cn,{size:15})})]}),n.status==="idle"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsx("p",{className:"text-2xs text-ink-faint leading-snug",title:a("condense.copyIntroFull"),children:a("condense.copyIntroShort")}),l.jsxs("button",{onClick:()=>d(P=>P+1),title:a("condense.rescanTitle"),"data-condense-rescan":!0,className:"text-2xs text-ink-muted hover:text-accent px-2 py-1 rounded-lg hover:bg-wash transition-colors shrink-0",children:["⟳ ",a("condense.rescan")]})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2","data-condense-scanline":!0,children:ye(a("condense.scanLine"),{turns:String(s.filter(P=>P.data.response&&!P.data.stepKind).length),n:String(h.length)})}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("label",{className:"text-2xs text-ink-muted shrink-0",children:a("condense.modelLabel")}),l.jsxs("select",{value:x,onChange:P=>b(P.target.value),"data-condense-model":!0,className:"text-xs bg-wash text-ink rounded-lg px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-accent/40 max-w-[220px] truncate",children:[l.jsx("option",{value:"",children:ye(a("condense.modelGlobal"),{model:m||"auto"})}),p.map(P=>l.jsx("option",{value:P.id,children:P.id},P.id))]})]}),h.length===0?l.jsx("p",{className:"text-xs text-ink-muted py-4",children:a("condense.segNothing")}):l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:h.map(P=>{const L=C(P),Y=!y.has(L);return l.jsxs("div",{"data-condense-item":!0,className:`border rounded-xl p-3 transition-colors cursor-pointer ${Y?"border-accent/60 bg-accent/5":"border-line opacity-60"}`,onClick:()=>{oe.getState().setCondenseHighlightIds(P.nodeIds),e?.(P.nodeIds)},children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("input",{type:"checkbox",checked:Y,onClick:q=>q.stopPropagation(),onChange:()=>w(q=>{const B=new Set(q);return B.has(L)?B.delete(L):B.add(L),B}),className:"accent-[var(--color-accent)]","data-condense-check":!0}),l.jsx("span",{className:"text-2xs text-ink-faint font-mono",children:ye(a("condense.segMeta"),{n:String(P.nodeIds.length),tok:String(P.saving)})})]}),l.jsx("p",{className:"text-xs text-ink mt-1 leading-snug line-clamp-2",children:P.headQuestion})]},L)})}),h.length>0&&l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-3 mt-2 border-t border-line",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:a("condense.copyFootnote")}),l.jsxs("button",{onClick:S,disabled:I.length===0,"data-condense-build":!0,className:"text-xs bg-accent text-white px-3.5 py-2 rounded-lg disabled:opacity-40 transition-colors flex items-center gap-1.5 shrink-0",children:[l.jsx(to,{size:13,strokeWidth:1.75}),ye(a("condense.buildCopy"),{n:String(I.length),tok:String(O)})]})]})]}),n.status==="building"&&l.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted mb-1.5",children:[l.jsx(nn,{size:15,className:"animate-spin text-accent"}),ye(a("condense.buildingRun"),{i:String(n.current),n:String(n.total)})]}),l.jsx("p",{className:"text-2xs text-ink-faint mb-2",children:a("condense.runningBg")}),n.streaming&&l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto text-2xs text-ink-muted bg-wash rounded-lg p-2.5 whitespace-pre-wrap leading-relaxed","data-condense-streaming":!0,children:n.streaming}),l.jsx("button",{onClick:()=>aue(),"data-condense-cancel":!0,className:"self-start mt-3 text-xs text-ink-muted hover:text-red-600 px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="error"&&l.jsxs("div",{className:"flex flex-col gap-2 py-3",children:[l.jsx("p",{className:"text-2xs text-red-600",children:n.error}),l.jsx("button",{onClick:()=>oe.getState().setCondenseRun({status:"idle",error:void 0}),className:"self-start text-xs text-ink-muted hover:text-ink px-3 py-1.5 rounded-lg hover:bg-wash transition-colors",children:a("common.cancel")})]}),n.status==="done"&&l.jsxs("div",{className:"flex flex-col gap-3 py-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-700",children:[l.jsx(Jr,{size:16})," ",a("condense.copyReady")]}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:a("condense.copyCompareHint")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:V,className:"text-xs bg-accent/10 text-accent hover:bg-accent/20 px-3 py-2 rounded-lg transition-colors",children:a("condense.viewCopy")}),l.jsxs("button",{onClick:z,"data-condense-archive-original":!0,className:"text-xs border border-line text-ink-muted hover:text-ink hover:bg-wash px-3 py-2 rounded-lg transition-colors flex items-center gap-1.5",children:[l.jsx(el,{size:13,strokeWidth:1.75})," ",a("condense.archiveOriginal")]})]}),l.jsx("button",{onClick:()=>{oe.getState().setCondenseRun({status:"idle"}),_()},className:"self-start text-xs text-ink-faint hover:text-ink transition-colors",children:a("common.close")})]})]}),document.body)}function FT(){const e=Da(n=>n.lang),t=Da(n=>n.setLang);return l.jsx("div",{className:"flex items-center bg-card/90 backdrop-blur border border-line rounded-lg shadow-sm overflow-hidden",children:["en","zh"].map(n=>l.jsx("button",{onClick:()=>t(n),className:`px-2 h-8 text-2xs font-medium transition-colors ${e===n?"bg-accent text-white":"text-ink-muted hover:bg-wash"}`,children:n==="en"?"EN":"中"},n))})}function ma({x:e,y:t,w:n=34,h:a=20,tone:r="plain"}){return l.jsxs("g",{children:[l.jsx("rect",{x:e,y:t,width:n,height:a,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),r!=="plain"&&l.jsx("rect",{x:e,y:t,width:2.5,height:a,rx:1.25,fill:r==="accent"?it.accent:it.warm})]})}const iue={1:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:32,tone:"accent"}),l.jsx("circle",{cx:60,cy:28,r:2.5,fill:it.accent})]}),2:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:12,tone:"accent"}),l.jsx("line",{x1:60,y1:32,x2:60,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 47 L 60 52 L 63 47 Z",fill:it.accent}),l.jsx(ma,{x:43,y:52})]}),3:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:20,y:12,tone:"accent"}),l.jsx("line",{x1:37,y1:32,x2:37,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 34 47 L 37 52 L 40 47 Z",fill:it.accent}),l.jsx(ma,{x:20,y:52}),l.jsx("rect",{x:26,y:58,width:14,height:3,rx:1.5,fill:it.trace,opacity:.6}),l.jsx("path",{d:"M 54 62 C 64 62, 62 40, 72 38",stroke:it.warm,strokeWidth:1.75,fill:"none",strokeDasharray:"4 3"}),l.jsx("path",{d:"M 69 35.5 L 74 38 L 70 41 Z",fill:it.warm}),l.jsx(ma,{x:74,y:28,tone:"warm"})]}),4:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:52,stroke:it.line,strokeWidth:1.75,strokeDasharray:"3 3"}),l.jsx("circle",{cx:60,cy:41,r:7,fill:"white",stroke:"#FCA5A5",strokeWidth:1}),l.jsx("line",{x1:57,y1:38,x2:63,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx("line",{x1:63,y1:38,x2:57,y2:44,stroke:"#EF4444",strokeWidth:1.5,strokeLinecap:"round"}),l.jsx(ma,{x:43,y:54})]}),5:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:12,y:14,w:40,h:15}),l.jsx("circle",{cx:14,cy:16,r:4.5,fill:"#D64533"}),l.jsx("text",{x:14,y:18.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"✕"}),l.jsx(ma,{x:12,y:35,w:40,h:15}),l.jsx("circle",{cx:14,cy:37,r:4.5,fill:it.accent}),l.jsx("text",{x:14,y:39.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"⚖"}),l.jsx(ma,{x:12,y:56,w:40,h:15}),l.jsx("circle",{cx:14,cy:58,r:4.5,fill:"#C9A227"}),l.jsx("text",{x:14,y:60.4,textAnchor:"middle",fontSize:6,fontWeight:700,fill:"white",children:"?"}),l.jsx("path",{d:"M 62 42 L 74 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 71.5 39.5 L 76 42 L 71.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:86,y:14,width:13,height:13,rx:4.5,fill:"#D64533"}),l.jsx("line",{x1:92.5,y1:27,x2:92.5,y2:35,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:35,width:13,height:13,rx:4.5,fill:it.accent}),l.jsx("line",{x1:92.5,y1:48,x2:92.5,y2:56,stroke:it.accent,strokeWidth:1.4}),l.jsx("rect",{x:86,y:56,width:13,height:13,rx:4.5,fill:"#C9A227"})]}),7:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:14,y:12,width:30,height:22,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("line",{x1:29,y1:34,x2:29,y2:50,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 26 47 L 29 52 L 32 47 Z",fill:it.accent}),l.jsx(ma,{x:12,y:52,tone:"accent"}),l.jsx("path",{d:"M 100 22 C 80 22, 70 55, 50 60",stroke:it.accent,strokeWidth:1.75,fill:"none",strokeDasharray:"5 3"}),l.jsx("path",{d:"M 52 57 L 47 61 L 52 64 Z",fill:it.accent}),l.jsx(ma,{x:82,y:12})]}),9:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:43,y:10,tone:"accent"}),l.jsx("line",{x1:60,y1:30,x2:60,y2:48,stroke:it.accent,strokeWidth:1.75}),l.jsx("path",{d:"M 57 45 L 60 50 L 63 45 Z",fill:it.accent}),l.jsx(ma,{x:43,y:50}),l.jsx("circle",{cx:75,cy:53,r:4,fill:"#F59E0B"}),l.jsx("path",{d:"M 73.5 53 a 1.5 1.5 0 1 1 3 0",stroke:"white",strokeWidth:.9,fill:"none"}),l.jsx("text",{x:60,y:80,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"v2/2 · replay"})]}),6:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:18,width:14,height:48,rx:4,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:15,cy:27,r:3,fill:it.accent,opacity:.7}),l.jsx("rect",{x:12,y:37,width:6,height:6,rx:1,fill:"#F59E0B",opacity:.8}),l.jsx("rect",{x:12,y:49,width:6,height:6,rx:1,fill:it.inkMuted,opacity:.5}),l.jsx("rect",{x:38,y:14,width:32,height:24,rx:3,fill:"#FEF3C7",stroke:"#F59E0B",strokeWidth:.8}),l.jsx("rect",{x:80,y:14,width:32,height:24,rx:3,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx("circle",{cx:88,cy:22,r:3,fill:it.line}),l.jsx("path",{d:"M 82 34 L 92 26 L 100 32 L 108 24",stroke:it.inkMuted,strokeWidth:1.2,fill:"none"}),l.jsx("text",{x:72,y:62,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"⌘V paste anything"})]}),8:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx("rect",{x:8,y:8,width:70,height:52,rx:3,fill:it.accent,opacity:.06,stroke:it.accent,strokeWidth:.8,strokeDasharray:"3 2"}),l.jsx(ma,{x:14,y:14,w:26,h:16}),l.jsx(ma,{x:46,y:14,w:26,h:16}),l.jsx(ma,{x:30,y:38,w:26,h:16}),l.jsx("path",{d:"M 40 46 C 60 50, 70 50, 84 48",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 59 30 C 70 36, 76 42, 84 46",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx("path",{d:"M 43 22 C 66 24, 76 38, 84 44",stroke:it.accent,strokeWidth:1.4,fill:"none"}),l.jsx(ma,{x:84,y:40,w:28,h:18,tone:"accent"})]}),10:l.jsxs("svg",{viewBox:"0 0 120 84",className:"w-full h-full",children:[l.jsx(ma,{x:10,y:18,w:30,h:17,tone:"accent"}),l.jsx("line",{x1:25,y1:35,x2:25,y2:48,stroke:it.accent,strokeWidth:1.5}),l.jsx("path",{d:"M 22.5 45.5 L 25 50 L 27.5 45.5 Z",fill:it.accent}),l.jsx(ma,{x:10,y:50,w:30,h:17}),l.jsx("path",{d:"M 46 42 L 60 42",stroke:it.inkMuted,strokeWidth:1.2}),l.jsx("path",{d:"M 57.5 39.5 L 62 42 L 57.5 44.5 Z",fill:it.inkMuted}),l.jsx("rect",{x:68,y:20,width:44,height:44,rx:5,fill:"white",stroke:it.line,strokeWidth:1}),l.jsx(ma,{x:74,y:30,w:20,h:11,tone:"accent"}),l.jsx(ma,{x:88,y:46,w:20,h:11}),l.jsx("rect",{x:76,y:14,width:28,height:11,rx:5.5,fill:"#2B2A28"}),l.jsx("circle",{cx:84,cy:19.5,r:2.6,fill:"none",stroke:"white",strokeWidth:1}),l.jsx("circle",{cx:84,cy:19.5,r:.9,fill:"white"}),l.jsx("text",{x:90,y:22,fontSize:6,fill:"white",fontFamily:"JetBrains Mono Variable, monospace",children:"view"}),l.jsx("text",{x:60,y:78,textAnchor:"middle",fontSize:7,fill:it.inkMuted,fontFamily:"JetBrains Mono Variable, monospace",children:"#view= · read-only"})]})},UT={4:"prune",5:"map",6:"reading",7:"ref"};function oue(){const e=oe(h=>h.tutorialOpen),t=oe(h=>h.setTutorialOpen);D.useEffect(()=>{if(!e)return;const h=m=>{m.key==="Escape"&&t(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t]);const n=St(),a=Da(h=>h.lang),[r,s]=D.useState(0),o=[{label:n("tutorial.pg1"),steps:[1,2,3]},{label:n("tutorial.pg2"),steps:[4,5]},{label:n("tutorial.pg3"),steps:[6,7]},{label:n("tutorial.pg4"),steps:[8,9,10]}],u=r===o.length-1;if(D.useEffect(()=>{if(!e)return;s(0);const h=m=>{m.key==="ArrowRight"&&s(p=>Math.min(p+1,o.length-1)),m.key==="ArrowLeft"&&s(p=>Math.max(p-1,0))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e]),!e)return null;const d=o[r];return l.jsx("div",{className:"fixed inset-0 z-[95] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-2xl w-[min(980px,94vw)] flex flex-col",onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start justify-between px-7 pt-5 pb-1 shrink-0",children:[l.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[l.jsx("h2",{className:"text-lg font-semibold text-ink tracking-tight shrink-0",children:n("tutorial.title")}),l.jsx("p",{className:"text-xs text-ink-faint truncate",children:n("tutorial.subtitle")})]}),l.jsx("button",{onClick:()=>t(!1),className:"text-ink-faint hover:text-ink transition-colors mt-1",children:l.jsx(cn,{size:18,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 pt-3 pb-1 min-h-[380px]",children:[l.jsx("p",{className:"text-2xs font-semibold text-accent mb-3 uppercase tracking-wider",children:d.label}),l.jsx("div",{className:`grid gap-4 ${d.steps.length===3?"grid-cols-1 sm:grid-cols-3":"grid-cols-1 sm:grid-cols-2"}`,children:d.steps.map(h=>l.jsxs("div",{className:"bg-surface border border-line/70 rounded-xl p-4 flex flex-col animate-fade-in",children:[l.jsx("div",{className:"w-full aspect-[120/72] bg-card rounded-lg border border-line/60 mb-3 overflow-hidden",children:UT[h]?l.jsx("img",{src:`/thoughtdag/tutorial/${UT[h]}-${a}.gif`,loading:"lazy",alt:"",className:"w-full h-full object-cover"}):iue[h]}),l.jsx("h3",{className:"text-[13px] font-semibold text-ink leading-snug",children:n(`tutorial.step${h}.title`)}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed mt-1.5",children:n(`tutorial.step${h}.desc`)})]},h))})]}),l.jsxs("div",{className:"px-7 py-4 shrink-0 flex items-center justify-between",children:[l.jsx("button",{onClick:()=>s(h=>Math.max(h-1,0)),disabled:r===0,className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center disabled:opacity-25 disabled:cursor-not-allowed",children:l.jsx(Nm,{size:16,strokeWidth:1.75})}),l.jsx("div",{className:"flex items-center gap-2",children:o.map((h,m)=>l.jsx("button",{onClick:()=>s(m),className:`h-2 rounded-full transition-all ${m===r?"w-6 bg-accent":"w-2 bg-line hover:bg-line-strong"}`,"aria-label":`${m+1}/${o.length}`},m))}),u?l.jsx("button",{onClick:()=>t(!1),className:"text-xs bg-accent hover:bg-accent-strong text-white px-5 py-2 rounded-lg transition-colors",children:n("tutorial.close")}):l.jsx("button",{onClick:()=>s(h=>h+1),className:"w-8 h-8 rounded-lg border border-line text-ink-muted hover:bg-wash transition-colors flex items-center justify-center",children:l.jsx(Ba,{size:16,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-7 py-2.5 border-t border-line/60 shrink-0 flex flex-wrap gap-x-4 gap-y-1 text-2xs text-ink-faint font-mono",children:[l.jsxs("span",{children:[n("shortcut.panKeys")," ",n("shortcut.pan")]}),l.jsxs("span",{children:[n("shortcut.marqueeKeys")," ",n("shortcut.marquee")]}),l.jsxs("span",{children:["⌘","F ",n("shortcut.search")]}),l.jsxs("span",{children:["Space ",n("shortcut.collapse")]}),l.jsxs("span",{children:["R ",n("shortcut.regenerate")]}),l.jsxs("span",{children:["↑↓←→"," ",n("shortcut.navigate")]}),l.jsxs("span",{children:["⌘","Z/","⇧","⌘","Z ",n("shortcut.undo")]}),l.jsxs("span",{children:["Del ",n("shortcut.delete")]}),l.jsxs("span",{children:["Esc ",n("shortcut.escape")]})]})]})})}const lue=new URLSearchParams(window.location.search),_s=lue.get("dv"),Lc="https://chenxiachan.github.io/thoughtdag/docs",FM=[{version:"0.5.10",date:"2026-10-01",announce:!1,lead:{zh:"修复 0.5.9 带出的一处:索引升级后、第一次搜索之前,「全量」回忆的确认框把索引读成 0 条、0 秒、0 美元。现在计数会先把索引更新到位;索引真的空着或还在重建时,只提示一句,不弹确认框。",en:"Fixes one thing 0.5.9 brought: after the index upgrade and before the first search, the confirm dialog for a full recall read the index as 0 turns, 0 seconds, $0.00. The count now brings the index up to date first; an index that is empty or still rebuilding gets a notice instead of a dialog."},items:[]},{version:"0.5.9",date:"2026-10-01",announce:!1,lead:{zh:"回忆与记忆的四处收口,都出自 #51 的复审:归档的节点退出回忆索引(这次启动会把索引重建一遍);画像文档的每一行记着来自哪个画布、哪天、是本人说的还是推断的,模型改写后不再丢;新拉出的空节点和阅读器底栏有了和追问框一样的联网、学术、回忆开关;基准的 repair 用例多了一格带陈旧标记的条件。",en:"Four follow-ups from the #51 review, all on recall and memory: archived nodes leave the recall index (the index rebuilds once on this start); every line of the profile documents keeps which canvas it came from, when, and whether you said it or it was inferred, through the model's rewrites; a fresh node and the reader's footer carry the same web, scholar and recall switches as a follow-up; the benchmark's repair cases gain a condition that carries the stale mark."},items:[]},{version:"0.5.8",date:"2026-09-30",announce:!1,lead:{zh:"修复 0.5.7 的一处遗漏:回答里的消毒把画布自己加的标记也剥掉了,从回答文字跳到分支的入口失效,用户高亮和探索标记都退化成默认黄底。现在两种标记保留各自的类和目标,跳转、点状下划线、高亮填色都回来了。",en:"Fixes an oversight in 0.5.7: the answer sanitizer also stripped the marks the canvas adds itself, so the jump from an answer to the branch it bore stopped working and highlights and explore marks fell back to the browser's plain yellow. Both marks keep their class and target again; the jump, the dotted underline and the highlight fill are back."},items:[]},{version:"0.5.7",date:"2026-09-30",announce:!1,lead:{zh:"安全修补:回答里的原始 HTML 先经过消毒再渲染,折叠块、上下标、键帽、高亮、表格、换行照旧,能执行脚本或嵌入外部页面的标签(iframe、object、script、style、form 等)被去掉;此前分享链接、导入的画布或模型引用的网页都能借 srcdoc 的 iframe 在本页面的源里执行代码。托管代理的模型探测只接受公网 https 地址,两处网页快照抓取共用一套地址检查并逐跳核对重定向。另外两处小修:「重跑上游已变」只跑确认框里数到的那些,牌子摘要不再参考已归档的步骤。",en:"Security: raw HTML in an answer is sanitized before rendering; folds, sub/sup, kbd, highlights, tables and line breaks stay, while tags that run scripts or embed pages (iframe, object, script, style, form and the like) are stripped. Until now a shared link, an imported canvas or a page the model quoted could run code in this origin through a srcdoc iframe. The hosted proxy's model probe takes public https endpoints only, and both page-snapshot fetchers share one address guard and check every redirect hop. Two small fixes: replay reruns exactly the stale nodes the dialog counts, and plaque summaries no longer read archived steps."},items:[]},{version:"0.5.6",date:"2026-09-30",announce:!1,lead:{zh:"回忆改成安静的小标签,默认关:输入框旁一个「回忆」,点开是开关、搜索范围(轻量 40 条 / 深挖 2,000 条 / 全量)和带入上下文,改的只对这一次提问生效,「设为默认」写回全局;深挖和全量由判断模型分批看候选,全量先告诉你条数、秒数和费用。判断模型页的开关并进供应商下拉(最后一项「关闭,按规则」);联网和学术搜索也默认关。每个节点都有可缩放的摘要:一句话的回答、笔记、文件都上梯子。双击卡片上的问题,侧栏编辑框带着原文打开。Harness 插件:思维图顶上是自己的标题带(不再压住红绿灯);自己的模型接口回来了,添加、拉模型列表、调用都走插件;不再提示桌面版新版本,插件更新提示直接说在插件页重新添加哪个包;桌面版 0.2 写的 v4 会话文件进得了对话地图。",en:`Recall is a quiet chip, off by default: a "Recall" beside the composer opens the switch, the search reach (light 40 / deep 2,000 / full) and the context brought in; a change there holds for the next ask only, "set as default" writes it back. Deep and full have the decision model read candidates in batches; full first says how many turns, seconds and dollars. The decision model page folds its switch into the provider dropdown (last entry: off, rules decide); web and scholar search start off too. Every node zooms: one-line answers, notes and files get a ladder. Double-clicking a card's question opens the side panel editor with the text in place. Harness plugin: the map wears its own title band (clear of the traffic lights); its own model interfaces are back, added, listed and called through the plugin; no more desktop-app update nudge, and the plugin's own notice names the package to re-add on the Plugins page; the 0.2 desktop's v4 session files reach the atlas.`},items:[]},{version:"0.5.5",date:"2026-09-29",announce:!1,lead:{zh:"换档不再互相盖住:缩小到地图层时,节点的牌子不会超出布局留给它的位置,写不下的摘要在底部渐隐,再放大一档就能看全;折叠卡显示和牌子同一段摘要,放大缩小之间只是字号在变。节点间距略微拉开,已有画布的位置不动,按「一键排版」才换成新间距。另外:从 Finder 启动时也能找到本机的 Pi、Codex、Claude Code 命令行,找不到会说明查过哪些地方,可重新检测;子 Agent 的运行展开在父画布上,作为那一轮旁边的分支;模型接口分成「慢思考 · 回答模型」和「快思考 · 判断模型」两页,只用 Agent 的人也能单独接判断模型;新装机没有模型时会先问一次本机的 Agent。",en:"Zoom tiers no longer cover each other: at map zoom a node's plaque stays inside the room the layout keeps for it, an abstract that runs past it fades out at the bottom and shows in full one step in; the folded card carries the same abstract as the plaque, so zooming only changes the type size. Node gaps open slightly; existing canvases keep their positions until you choose Tidy layout. Also: the Pi, Codex and Claude Code CLIs are found under a Finder launch, and a missing one says where it looked, with a recheck; a subagent's run unfolds on the parent canvas as a branch beside its turn; the model dialog has two pages, slow thinking for answering models and fast thinking for the decision model, which agent-only users can connect on its own; a fresh install with no model asks the local agents first."},items:[]},{version:"0.5.4",date:"2026-09-29",announce:!1,lead:{zh:"鼠标滚轮恢复缩放画布,和 0.5.2 一样。0.5.3 起滚轮改成了平移,这对触控板顺手,却让鼠标用户没法用滚轮缩放。触控板用户可以在画布 ⋯ 菜单打开「滚轮平移画布」:双指滑动即平移,捏合或按住 ⌘/Ctrl 滚动来缩放。",en:"The mouse wheel zooms the canvas again, as in 0.5.2. Since 0.5.3 it panned, which suits a trackpad but left mouse users without wheel zoom. On a trackpad, turn on ⋯ → Wheel pans the canvas: a two-finger scroll pans, pinch or hold ⌘/Ctrl while scrolling to zoom."},items:[]},{version:"0.5.3",date:"2026-09-27",announce:!1,lead:{zh:"圈选多个节点后,工具栏多了「更新节点摘要」:用当前选中的模型为它们一次更新四层摘要,文件、便签和短回答自动跳过。进度在右下角,随时可停。旧画布想整体升级到新摘要,圈一下就行。右键单个节点也是同一个入口。",en:'With several nodes selected, the toolbar gains "Update node summaries": the picked model updates their four summary levels in one go, files, notes and short answers skipped. Progress shows bottom right and can be stopped any time. An older canvas upgrades to the new summaries with one lasso; the right-click item on a single node is the same door.'},items:[{title:{zh:"🧭 摘要写的是这一步新增了什么",en:"🧭 Summaries say what the step adds"},body:{zh:"结论与短述改为由模型撰写。写之前它先读这条思路里前面各步的牌匾,只写本步新增的结论、决定或转向,不重复前面已经说过的;概要仍是原答里的原文摘句,作为证据。旧节点用「更新节点摘要」换新即可。",en:'The takeaway and brief are now written by the model. It first reads the plaques of the earlier steps in the thread, then writes only what this step adds, a conclusion, a decision or a turn, without repeating what came before; the abstract stays verbatim sentences of the answer, as evidence. Older nodes switch over with "Update node summaries".'}},{title:{zh:"🖐️ 触控板双指滑动即平移",en:"🖐️ Two-finger scroll pans"},body:{zh:"在触控板上双指滑动就能移动画布,不用再按住按键拖。捏合缩放不变。鼠标滚轮现在同样是平移,缩放请按住 ⌘(Windows 上是 Ctrl)再滚。感谢 @Pireirik 的贡献。",en:"On a trackpad, a two-finger scroll moves the canvas; no button to hold. Pinch still zooms. A mouse wheel now pans too; hold ⌘ (Ctrl on Windows) to zoom with it. Contributed by @Pireirik."}}]},{version:"0.5.2",date:"2026-09-27",announce:!0,lead:{zh:"🔍 上下文管理重大更新!现在,无论画布缩放至何种比例,节点内容始终保持极佳的阅读体验。",en:"🔍 A major update to context management! Whatever the zoom, every node on the canvas now stays a pleasure to read."},media:{src:{zh:"whats-new/zoom-ladder-zh.mp4",en:"whats-new/zoom-ladder-en.mp4"},alt:{zh:"缩小画布时,牌匾上的结论逐词长成短述再长成摘要",en:"Zooming out, a plaque's takeaway grows word by word into a brief, then an abstract"},width:960,height:600},items:[{title:{zh:"🪜 智能四层摘要",en:"🪜 Four smart summary levels"},body:{zh:"每个回答自动构建「主题、结论、短述、完整概要」四个递进层级,随缩放比例自动无缝切换。",en:"Every answer builds four progressive levels, topic, takeaway, brief and full abstract, and switches between them seamlessly as you zoom."}},{title:{zh:"✨ 丝滑的视觉过渡",en:"✨ Silky visual transitions"},body:{zh:"缩放时,文字会逐词自然展开或收起。保留的关键词会平滑移动,新文本自然淡入,核心重点始终高亮加深。视线聚焦零中断,数十个节点的全局脉络一眼即达。",en:"As you zoom, text unfolds or folds word by word. The words that stay glide into place, new text fades in, and the key points stay highlighted in full ink. Your focus is never broken, and the shape of dozens of nodes reads at a glance."}},{title:{zh:"🔁 新旧节点全面兼容",en:"🔁 New and old nodes alike"},body:{zh:"新回答自动生效该特性;旧节点会在浏览时实时生成摘要层级,若需更精准的 AI 总结,只需右键一键生成。",en:"New answers get it automatically; older nodes build their levels live as you browse, and for a sharper AI-selected summary, one right-click does it."}},{title:{zh:"🎚️ 时间线详略随手调",en:"🎚️ Timeline detail at your fingertips"},body:{zh:"时间线弹窗新增详略滑块,从主题一路拉到完整概要,字号与行距随手指流动,每一步文字完整呈现,告别省略号。",en:"The timeline overview gains a detail slider: glide from topic to full abstract, type and spacing flowing with your drag, every step shown whole, no ellipsis anywhere."},media:{src:{zh:"whats-new/timeline-detail-zh.mp4",en:"whats-new/timeline-detail-en.mp4"},alt:{zh:"拖动时间线弹窗的详略滑块,每一步的文字逐词展开",en:"Dragging the timeline overview's detail slider, each step's text unfolds word by word"},width:720,height:760}},{title:{zh:"🛡️ 所见即所发",en:"🛡️ What you see is what is sent"},body:{zh:"判断模型认定上游改动与答案无关时,「上游已变」标记现在同时从预览和请求中退场,两者始终一致。感谢 Agent Memory Atlas 的审阅指出这一点。",en:'When the decision model rules an upstream change irrelevant, the "upstream changed" mark now leaves the preview and the request together, always in step. Thanks to the Agent Memory Atlas review for catching it.'}},{title:{zh:"🧹 右键菜单焕新",en:"🧹 A refreshed right-click menu"},body:{zh:"「重新生成」更简洁,CLI 相关操作合并为一项,新增「用模型重选摘要」。手动修改过的回答会自动重做摘要。",en:'"Regenerate" is simpler, the CLI actions merge into one, and "Update node summary" joins the menu. Hand-edited answers get their summaries redone automatically.'}}]},{version:"0.5.1",date:"2026-09-26",announce:!1,lead:{zh:"0.5 之后的一批修正。删除正在生成的节点时,那一轮生成随之中止,不再在后台跑完。记忆的自动写入上限按画布分开计,切换画布后重新计;之前是全局三条写满就静默。档案更新只带走模型读过的那几条待归档事实,更新期间新归档的保留下来;档案文件的写入排队进行,不再互相覆盖。why 层不再把执行失败的文件操作算作改动足迹,更新后索引会重建一次。判断模型直接沿用模型接入里保存的 OpenRouter key,不再显示为空、测试不可点。",en:"A round of fixes after 0.5. Deleting a node that is still generating stops that generation instead of letting it run on in the background. The memory judge's automatic-write cap counts per canvas and starts over on a canvas switch; it used to be one global count of three, after which memory went quiet. A dossier update takes only the filed facts the model read and keeps anything filed while it was writing; dossier writes queue instead of overwriting one another. The why layer no longer counts a file operation the harness answered with an error as a change, and the index rebuilds once. The decision model uses the OpenRouter key saved with your model providers, instead of showing an empty field with a disabled test."},items:[]},{version:"0.5.0",date:"2026-09-26",announce:!0,lead:{zh:"🎉 ThoughtDAG 0.5:记忆上线。你在 Pi、Codex、Claude Code、DeepSeek Harness 里聊过的一切,现在接成一个可以回忆的整体。散在几百个会话里的碎片,按主题整理成档案;提问时相关的档案和对话自动带进上下文,跨 Agent、跨时间。背后是快思考与慢思考的分工:慢思考模型回答,快思考模型判断。所有信息都在你自己的机器上。",en:"🎉 ThoughtDAG 0.5: memory. Everything you discussed in Pi, Codex, Claude Code and DeepSeek Harness now forms one whole you can recall. Fragments scattered across hundreds of sessions are organised into dossiers by topic; when you ask, the relevant dossiers and conversations ride into the context, across agents and across time. Behind it, a division of labour: a slow-thinking model answers, a fast-thinking model decides. Everything stays on your machine."},items:[{title:{zh:"碎片串成一条线",en:"Fragments become a thread"},body:{zh:"昨天在 Codex 里定的阈值,上周在 Claude Code 里排除的方案,今天在画布上问起时都在。每个主题一份档案:是什么、定过什么、到哪一步、还没解决什么,每句都能点回原来的那轮对话。「你」是两份文档:偏好与身份,记到新东西时改写而不是堆砌。原来的记忆条目已并入。",en:"The threshold you settled in Codex yesterday and the approach you ruled out in Claude Code last week are there when you ask on the canvas today. Every topic keeps a dossier: what it is, what was decided, where it stands, what is still open, each line pointing back to its turn. Your profile is two documents, preferences and identity, rewritten rather than piled up. Earlier memory entries were folded in."},link:{label:{zh:"记忆指南",en:"The memory guide"},href:`${Lc}/zh/guides/memory`}},{title:{zh:"提问时自动回忆",en:"Recall as you ask"},media:{src:{zh:"whats-new/jev-recall.mp4",en:"whats-new/jev-recall.mp4"},alt:{zh:"回忆流程里,判断模型半秒内从候选片段中选出相关的几条",en:"In the recall flow the decision model picks the relevant excerpts from the candidates in under a second"},width:1200,height:720},body:{zh:"开着「回忆」提问,先判断问题涉及哪些主题,把档案整份带进去;问的是细节时再补几条原话。带了什么、花了多少,面板上一条一条看得见,不想要的划掉就不带。带入量三档:省、标准、多带。",en:"With recall on, a question is first matched to its topics and their dossiers ride in whole; a question about a detail brings a few verbatim excerpts too. What came in and what it cost is listed item by item; strike one and it stays out. Three amounts: lean, standard, generous."}},{title:{zh:"快思考,慢思考",en:"Fast thinking, slow thinking"},body:{zh:"回答你的是慢思考模型。判断「这条相关吗」「这句是决定吗」「这处改动影响吗」的是快思考模型:半秒一次,返回校准过的概率,让回忆、地图徽章和「上游已变」都有依据。模型选择器里一行开关,默认开;关掉全部退回规则,功能不变。",en:"The slow-thinking model answers you. The fast-thinking model decides — is this relevant, is this line a decision, does this change matter — in half a second, with calibrated probabilities, so recall, map badges and “upstream changed” rest on evidence. One switch in the model picker, on by default; off, every decision falls back to a rule and nothing stops working."}},{title:{zh:"接入一个快思考模型",en:"Connect a fast-thinking model"},body:{zh:"Jev 类判断模型可以经你已保存的聚合商接入直接使用,也支持官方接口和自建服务;没有接入时会提示,一切照常。",en:"A Jev-class decision model runs through the aggregator access you already saved, through the official endpoint, or from a self-hosted server; without one you are told, and everything still works."},link:{label:{zh:"怎么接入",en:"How to connect one"},href:`${Lc}/zh/setup#decision-model`}},{title:{zh:"一切都在本地",en:"All of it stays local"},body:{zh:"索引、主题标签、档案存在本机 .thoughtdag 目录,画像文档存在应用本地。判断时发出去的只有问题和候选片段,发给你自己选的接入。",en:"The index, topic labels and dossiers live in your machine's .thoughtdag folder; your profile lives in the app's own storage. A decision sends only the question and the candidate excerpts, to the access you chose."}}]},{version:"0.4.20",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件一轮实测后的整理。「对话 | 思维图」开关:对话页顶部仍是浮动的,切到思维图后它移到画布顶栏「画布名」右侧,不再压住画布工具栏。工作目录改用 Harness 自己的目录选择器:本机运行时弹的就是系统的文件夹对话框,远程访问时回落为输入路径;0.4.19 里自带的目录浏览器撤掉。Harness Agent 也能选工作目录,新会话按所选目录运行。插件里去掉配置模型 API 的入口。实时镜像刷新会话时不再把镜头拉回节点。节点记录的是发起请求时的模型,执行中切换选择器不再改写徽章。Harness 执行中的每个工具调用都列为一条步骤,思考尾巴显示在下方。备份提醒去掉。",en:"DeepSeek Harness plugin, after a round of hands-on testing. The 对话 | 思维图 switch still floats over the chat; on the canvas it sits in the canvas's own top bar next to the canvas chip, so it never covers the toolbar. The working directory is chosen in the harness's own picker: the system folder dialog when the harness runs on this machine, a typed path when reached remotely; the folder browser 0.4.19 carried is withdrawn. The Harness Agent gets the folder chip too, and a fresh session runs where it says. The API-key door is gone inside the plugin. The live mirror no longer drags the camera back to a node while its session refreshes. A node records the model it was asked with; switching the picker mid-run no longer relabels it. Every tool call of a harness run is listed as a step, the thinking beneath. The backup reminder is removed."},items:[]},{version:"0.4.19",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:Harness Agent 节点的回答不再「闪一下就没了」。新版 Harness(0.1.5-rc.3)不再把逐字流写进会话日志,一步只落一条 assistant/message;画布续读实时日志时按会话列表报的序号少读了一条,恰好是带答案的那条,节点随后被镜像成空回答。现在按实际持有的最后一条事件续读,且镜像永不把已有回答改写为空。思考过程重新同步显示:宿主订阅 Harness 新的流事件(agent/assistant-stream),正文和思考逐字到达节点,没有流的运行时从每步的 reasoning 块补发。「对话 | 思维图」开关回到浮动位置,空态也能切换(0.4.18 的标题栏开关撤回)。Agent 的工作目录改为浏览宿主机的文件夹来选,也仍可直接输入路径。",en:"DeepSeek Harness plugin: a Harness Agent node no longer shows its answer for a moment and then loses it. Newer Harness builds (0.1.5-rc.3) stop writing the token stream into the session log; a step lands as one assistant/message. When the canvas read the live log incrementally it asked from the seq the session list reported and skipped exactly one event, the one carrying the answer, and the node was then mirrored as an empty reply. It now continues from the last event it actually holds, and a mirror never rewrites an existing answer to nothing. Reasoning shows live again: the host subscribes to the Harness's new stream event (agent/assistant-stream), so text and reasoning reach the node as they are produced; a runtime without that stream gets each step's reasoning block instead. The 对话 | 思维图 switch floats again and works on the empty page (the 0.4.18 header switch is withdrawn). An agent's working directory is chosen by browsing the host's folders, with a path field still there for typing."},items:[]},{version:"0.4.18",date:"2026-09-23",announce:!1,lead:{zh:"DeepSeek Harness 插件:历史会话列表在新版 Harness 上不再为空。dsh 从 0.1.5-rc.2 起把会话格式版本写进日志文件名(session.v3.jsonl.zstd),插件现在按已知文件名探测,新旧两种都认(#44,感谢 @LHN-xiao-hai-tun)。模型选择器加宽,条目悬停显示完整名称,Agent 执行组的长名字改为换行而不是截断,flash 与 flash-vision 一眼可辨(#43)。",en:"DeepSeek Harness plugin: the list of past sessions is no longer empty on newer Harness builds. From 0.1.5-rc.2 dsh writes the session format version into the log file name (session.v3.jsonl.zstd); the plugin now probes the known names and reads both (#44, thanks @LHN-xiao-hai-tun). The model picker is wider, every entry shows its full name on hover, and long names in the agent group wrap instead of being cut, so flash and flash-vision tell apart at a glance (#43)."},items:[]},{version:"0.4.17",date:"2026-09-21",announce:!1,lead:{zh:"DeepSeek Harness 插件:从画布向 Harness 提问时,节点只接自己那一轮。此前如果你同时在聊天框里发消息,画布节点会拿到你那轮的回答、在你那轮结束时提前收尾,并把镜像标记挂到错误的轮次上,产生重复节点;工具审批也可能被画布抢走。现在 Host 用 dsh 记在消息上的请求 id 精确认出自己的那一轮,文本、工具调用、审批、结束全部按这一轮过滤(#42,感谢 @nanami-0713)。桌面版本次只同步版本号。",en:"DeepSeek Harness plugin: a question asked from the canvas now receives only its own turn. Before, if you were also typing in the chat, the canvas node could receive your turn's answer, finish early when your turn ended, and stamp its mirror mark on the wrong turn, leaving duplicate nodes; tool approvals could be captured by the canvas as well. The host now recognises its own turn by the request id dsh records on the message, and filters text, tool calls, approvals and the end of turn to that turn alone (#42, thanks @nanami-0713). The desktop app only moves its version number."},items:[]},{version:"0.4.16",date:"2026-09-17",announce:!1,lead:{zh:"分区框:两个只是部分重叠的框不再互相收编。拖动大框时,重叠的小框和它自己的节点留在原地;拖动和一键排版现在用同一条成员规则,普通节点按中心点归属,框只有完整落在另一个框里才算它的成员(#40,感谢 @nanami-0713)。DeepSeek Harness 插件:「插件有新版本」提示复制的命令带上具体版本号,发版当天也能立刻装到新版。",en:"Frames: two frames that merely overlap no longer own each other. Dragging the larger one leaves the overlapping smaller frame and its own nodes in place; dragging and auto layout now share one membership rule, nodes by centre and a frame only when it lies fully inside another (#40, thanks @nanami-0713). DeepSeek Harness plugin: the update hint now copies a command naming the exact version, so a release installs on its first day too."},items:[]},{version:"0.4.15",date:"2026-09-15",announce:!1,lead:{zh:"分区框三件事:一键排版后,框跟着框内的节点重新包好(#32);拖动外框会带动嵌套在里面的框;重叠时小框叠在大框上面,标题栏不再被盖住。三项均来自 @hexu321。DeepSeek Harness 插件:「对话 | 思维图」切换器移进会话标题栏,不再遮挡标题;返回按钮居中,画布右上的工具栏保持可见;从画布切回会话的跳转修好了(#30,来自 @nanami-0713)。插件重新在 npm 上发布,安装命令恢复为包名。",en:"Frames, three fixes: after auto layout a frame re-wraps the nodes it held (#32); dragging an outer frame carries the frames nested inside it; where frames overlap, the smaller one stacks on top so its title bar stays reachable. All three by @hexu321. DeepSeek Harness plugin: the 对话 | 思维图 switch moves into the session header and no longer covers the title; the back button sits top centre, clear of the canvas toolbar; jumping from the canvas back to a session works again (#30, by @nanami-0713). The plugin is back on npm and the install command is the package name again."},items:[]},{version:"0.4.14",date:"2026-09-11",announce:!1,lead:{zh:"插件的「有新版本」提示现在复制 dsh plugin --profile web add dsh-thoughtdag@latest,这条命令对从 npm 装和从 Release 文件装的用户都有效(update 对文件安装无效)。其余同 0.4.13。",en:"The plugin's update hint now copies dsh plugin --profile web add dsh-thoughtdag@latest, which works for installs from npm and from a release file alike (update does nothing for a file install). Otherwise the same as 0.4.13."},items:[]},{version:"0.4.13",date:"2026-09-11",announce:!1,lead:{zh:"修复:DeepSeek Harness 插件里,模型选择器丢失了「Harness · 模型」这一组 Agent 条目(0.4.11 起,机器上没装 Pi、Codex 等命令行时整组消失)。原因是思维图把 Harness 给的条目当成本机命令行的探测结果替换掉了,现在只替换命令行报来的那几种。插件里「如何使用」的教程动图也能显示了(#35,感谢 @Moya-Doc)。",en:`Fix: inside the DeepSeek Harness plugin, the model picker lost the "Harness · model" agent entries (since 0.4.11; with no Pi or Codex CLI on the machine the whole group vanished). The canvas had been replacing the harness's entries with the local CLI probe; now only the entries the CLIs report get replaced. The tutorial gifs inside the plugin load again (#35, thanks @Moya-Doc).`},items:[]},{version:"0.4.12",date:"2026-09-10",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 子节点现在续接父节点的会话;同一父节点下的第二个分支从父节点那一轮分叉出自己的会话,preset 的会话状态不再在每个子节点重头开始(#28、#29)。插件的构建脚本在 Windows 上也能跑了(#24、#26)。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an agent child node now continues its parent's session, and a second branch off the same parent forks its own session at that parent's turn, so a preset's session state no longer restarts at every child (#28, #29). The plugin's build script runs on Windows too (#24, #26). The desktop app only moves its version number."},items:[]},{version:"0.4.11",date:"2026-09-08",announce:!1,lead:{zh:"性能优化:启动更快,后台更省,多个工具调用并行时更稳;300 节点以上的画布实测流畅。ThoughtDAG 现在可以用 Claude Code、Codex、Pi 作为节点的 Agent 运行时,处于测试阶段。",en:"Performance: faster launch, lighter in the background, steadier when several tool calls run in parallel; canvases past 300 nodes measured smooth. ThoughtDAG can now run a node through Claude Code, Codex or Pi as its agent runtime, in testing."},items:[]},{version:"0.4.10",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览继续:Codex 加入,和 Pi 一样在画布里带工具作答;这条通道现在在桌面版、本地网页版和 DeepSeek Harness 插件里都可用;插件里的 Harness Agent 按模型平铺;插件有新版本时画布会提示。",en:"Agent runs, preview continued: Codex joins Pi, answering with tools right from the canvas; the lane now works in the desktop app, the local web app and the DeepSeek Harness plugin alike; inside the plugin the Harness agent lists one entry per model; the canvas tells you when a newer plugin is out."},items:[]},{version:"0.4.9",date:"2026-09-07",announce:!1,lead:{zh:"Agent 执行预览:桌面版的模型选择器多了「Agent 执行」组,装了 Pi 的话可以直接在画布里让它带工具作答,轨迹、足迹、审批和提问都落在节点上,工作目录在顶栏可见可改。正式版会连同 Claude Code 与 Codex 一起发布。DeepSeek Harness 插件里的审批卡片同步更新。",en:'Agent runs, preview: the desktop picker gains an "Agent runs" group; with Pi installed, a question runs through it with tools right from the canvas, and the trace, footprints, approvals and questions land on the node, with the working directory visible on the toolbar. The full release will arrive together with Claude Code and Codex. The approval card inside the DeepSeek Harness plugin is updated alike.'},items:[]},{version:"0.4.8",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件在 Windows 上能打开了:静态资源和会话目录的路径守卫此前只认正斜杠,Windows 用户看到的是一片 403。感谢 GitHub 上的报告(#23)。桌面版本次只同步版本号。",en:"The DeepSeek Harness plugin now opens on Windows: the path guards for static assets and session directories only accepted forward slashes, so Windows users saw nothing but 403s. Thanks to the report on GitHub (#23). The desktop app only moves its version number this time."},items:[]},{version:"0.4.7",date:"2026-09-07",announce:!1,lead:{zh:"DeepSeek Harness 插件里,Agent 需要你批准的操作现在直接出现在节点上:工具、命令、理由,允许一次或拒绝,决定留在节点记录里。桌面版本次只同步版本号。",en:"Inside the DeepSeek Harness plugin, an action the agent needs approved now appears on the node itself: tool, command, reason, allow once or reject, and the decision stays in the node's record. The desktop app only moves its version number this time."},items:[]},{version:"0.4.6",date:"2026-09-06",announce:!0,lead:{zh:"🎉 Pi 的会话进了对话地图,「⋯」菜单里多了更新历史,随时能回看每一版改了什么。",en:"🎉 Pi sessions join the Session Atlas, and the ⋯ menu gains a release history, so what every version changed is one click away."},items:[{title:{zh:"Pi 的会话也在地图上了",en:"Pi sessions are on the map"},body:{zh:"本地 Pi 会话按项目聚在一起,打开就是一张图。Pi 里的每次分叉在图上就是一条支线,不再压成一条直线。命令行 why 和 MCP 也同步认识 Pi 留下的文件足迹。",en:"Local Pi sessions group by project and open as a graph. Every fork you made in Pi shows up as a branch instead of being flattened into one line. The why command and MCP index Pi's file footprints too."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"更新历史,随时补看",en:"Release history, whenever you like"},body:{zh:"右上「⋯」菜单,「如何使用」下面。每个版本改了什么都在这里,从新到旧,当前版本有标记。",en:"In the ⋯ menu, under How it works: what each release changed, newest first, with the version you are running marked."}}]},{version:"0.4.5",date:"2026-09-06",announce:!0,lead:{zh:"🎉 这是 ThoughtDAG 到目前为止最大的一次升级:散在各个 Agent 里的对话接成了一张地图,能从画布里查,还能直接在 DeepSeek Harness 里用。四件新东西,都值得试一试。",en:"🎉 The biggest ThoughtDAG release so far: the conversations scattered across your agents become one map, you can query them, and it all runs inside DeepSeek Harness. Four new things, each worth a try."},items:[{title:{zh:"跨 Agent 的对话地图,终于连成一张",en:"Session Atlas: all your agents, one map"},body:{zh:"Claude Code、Codex 和 DeepSeek Harness 的本地会话按项目文件夹聚在一起,点开就是一张图,随对话实时生长。",en:"Local Claude Code, Codex and DeepSeek Harness sessions, grouped by project; open one as a graph and it follows the conversation live."},link:{label:{zh:"怎么用",en:"How it works"},href:`${Lc}/zh/guides/session-atlas`}},{title:{zh:"命令行 why:一条命令找回塑造文件的那些对话",en:"thoughtdag why: one command finds the conversations that shaped a file"},body:{zh:"npx thoughtdag why <文件> 列出哪些轮次读过、改过它,当时问了什么、改了什么;find 按原话搜,MCP 让 Agent 自己来查。",en:"npx thoughtdag why <file> lists the turns that read or changed it, what was asked and what changed; find searches verbatim; MCP lets your agent ask."},link:{label:{zh:"命令与 MCP",en:"CLI and MCP"},href:`${Lc}/zh/guides/why-layer`}},{title:{zh:"DeepSeek Harness 插件上线",en:"DeepSeek Harness plugin is live"},body:{zh:'dsh plugin --profile web add dsh-thoughtdag,Harness 的网页里多一个"思维图"视图:在画布上提问、让 Harness 的 Agent 带工具作答,why 也成了它的原生工具。',en:"dsh plugin --profile web add dsh-thoughtdag adds a canvas view to the Harness web UI: ask from the canvas, let its agent answer with tools, and why becomes a native tool there."},link:{label:{zh:"插件说明",en:"Plugin README"},href:"https://github.com/chenxiachan/thoughtdag/tree/main/dsh#readme"}},{title:{zh:"文档站上线",en:"The docs site is live"},body:{zh:"概念、任务指南、命令字典和隐私说明各有一页,中英文对照。感谢一路同行,欢迎来 Discussions 说说你怎么用它。",en:"Concepts, task guides, the command dictionary and the privacy notes, each on its own page, in both languages. Thank you for coming this far with us; tell us how you use it in Discussions."},link:{label:{zh:"打开文档",en:"Open the docs"},href:`${Lc}/zh/`}}]},{version:"0.4.4",date:"2026-09-04",announce:!1,lead:{zh:"DeepSeek Harness 成为对话地图的内置来源:它的 zstd 日志由桌面壳逐帧解码,每条消息一个节点,工具调用与结果配对成附件。",en:"DeepSeek Harness becomes a built-in Atlas source: the shell decodes its zstd logs frame by frame, one node per message, tool calls paired with their results as attachments."},items:[]},{version:"0.4.3",date:"2026-09-03",announce:!1,lead:{zh:"深链接可以直达某一轮,画布可以按稳定 id 打开;子 Agent 的会话文件不再打扰实时监听。",en:"A deep link can land on a turn and a canvas opens by its stable id; subagent session files no longer disturb the live watcher."},items:[]},{version:"0.4.2",date:"2026-09-02",announce:!1,lead:{zh:"镜像节点列出那一轮碰过的文件(✏️ 改过、📖 读过),预览用结论而不是开头;子 Agent 的会话作为子线程识别,报告折回发起它的那一轮。",en:"A mirrored node lists the files its turn touched (✏️ edited, 📖 read) and previews the conclusion rather than the opening line; subagent files are recognized as sub-threads and their reports fold into the launching turn."},items:[]},{version:"0.4.1",date:"2026-09-01",announce:!1,lead:{zh:"Agent 对话地图首发:本地 Claude Code 与 Codex 的会话按项目文件夹聚成一张图,一键接入,随对话实时生长。",en:"Session Atlas debuts: local Claude Code and Codex sessions group by project folder into one map, connect in one click, and grow with the conversation."},items:[]}];function $y(e,t){const n=e.split(".").map(r=>parseInt(r,10)||0),a=t.split(".").map(r=>parseInt(r,10)||0);for(let r=0;r<Math.max(n.length,a.length);r++){const s=(n[r]??0)-(a[r]??0);if(s!==0)return s}return 0}function tm(e,t){return FM.filter(n=>n.announce&&$y(n.version,t)<=0&&(e===null||$y(n.version,e)>0))}const Wy="thoughtdag.whatsNewSeen",cue=new URLSearchParams(window.location.search);function uue(){if(!_s)return[];const e=cue.get("wn");if(e==="1")return tm(null,_s);if(e)return tm(e,_s);let t=null;try{t=localStorage.getItem(Wy)}catch{}if(t===null){let n=!1;try{n=!!(localStorage.getItem("thoughtdag.tutorialDone")||localStorage.getItem("thoughtdag.lastBackupAt"))}catch{}if(!n){try{localStorage.setItem(Wy,_s)}catch{}return[]}return tm(null,_s)}return t===_s?[]:tm(t,_s)}function UM({media:e,lang:t}){const n=e.src[t],a=/\.(mp4|webm)$/i.test(n);return l.jsx("div",{className:"mt-3 rounded-xl border border-line overflow-hidden bg-wash",style:{aspectRatio:`${e.width} / ${e.height}`},"data-whats-new-media":!0,children:a?l.jsx("video",{src:`/thoughtdag/${n}`,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-full object-cover","aria-label":e.alt[t]}):l.jsx("img",{src:`/thoughtdag/${n}`,alt:e.alt[t],className:"w-full h-full object-cover"})})}function qM({items:e,lang:t}){return e.length===0?null:l.jsx("ol",{className:"divide-y divide-line",children:e.map((n,a)=>l.jsxs("li",{className:"py-3 flex gap-3.5",children:[l.jsx("span",{className:"shrink-0 w-6 h-6 rounded-full bg-accent/10 text-accent text-xs font-semibold flex items-center justify-center mt-0.5",children:a+1}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-ink",children:n.title[t]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1 [overflow-wrap:anywhere]",children:n.body[t]}),n.media&&l.jsx(UM,{media:n.media,lang:t}),n.link&&l.jsxs("a",{href:n.link.href,target:"_blank",rel:"noreferrer",className:"inline-block mt-1.5 text-xs font-medium text-accent hover:underline",children:[n.link.label[t]," →"]})]})]},a))})}function due(){const[e,t]=D.useState(()=>uue()),n=e.length>0,a=Da(u=>u.lang),r=St(),s=D.useRef(null),o=()=>{if(_s)try{localStorage.setItem(Wy,_s)}catch{}t([])};return D.useEffect(()=>{if(!n)return;s.current?.focus({preventScroll:!0});const u=d=>{d.stopPropagation(),(d.key==="Escape"||d.key==="Enter")&&o()};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[n]),n?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:o,children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:u=>u.stopPropagation(),role:"dialog","aria-labelledby":"whats-new-title","data-whats-new":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"whats-new-title",className:"text-base font-semibold text-ink mt-0.5",children:ye(r("whatsNew.title"),{v:_s??""})}),e.length>1&&l.jsx("p",{className:"text-xs text-ink-faint mt-1",children:r("whatsNew.multi")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:e.map(u=>l.jsxs("li",{className:"py-4","data-release":u.version,children:[e.length>1&&l.jsxs("div",{className:"flex items-baseline gap-2.5 mb-1.5",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",u.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:u.date})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed [overflow-wrap:anywhere]",children:u.lead[a]}),u.media&&l.jsx(UM,{media:u.media,lang:a}),l.jsx(qM,{items:u.items,lang:a})]},u.version))}),l.jsxs("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex items-center justify-between gap-4",children:[l.jsx("button",{onClick:()=>{o(),oe.getState().setReleaseNotesOpen(!0)},className:"text-xs text-ink-muted hover:text-ink hover:underline transition-colors","data-whats-new-all":!0,children:r("whatsNew.seeAll")}),l.jsx("button",{ref:s,onClick:o,className:"text-xs text-white px-4 py-2 rounded-lg bg-accent hover:bg-accent-strong transition-colors",children:r("whatsNew.ok")})]})]})}):null}function hue(){const e=St(),t=oe(a=>a.ladderJob);if(D.useEffect(()=>{if(!t||t.running)return;const a=setTimeout(xT,8e3);return()=>clearTimeout(a)},[t]),!t)return null;const n=t.total?Math.min(1,(t.done+t.failed)/t.total):1;return l.jsxs("div",{className:"fixed bottom-4 right-4 z-[85] w-[300px] bg-card border border-line rounded-xl shadow-lg px-4 py-3 animate-fade-in","data-ladder-job":!0,"data-ladder-job-running":t.running?"yes":"no",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(h2,{size:14,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-ink flex-1",children:e("ladder.jobTitle")}),t.running?l.jsxs("button",{onClick:kle,disabled:t.cancelled,className:"flex items-center gap-1 text-2xs text-ink-muted hover:text-red-600 disabled:opacity-50","data-ladder-job-stop":!0,children:[l.jsx(q0,{size:10,strokeWidth:1.75,fill:"currentColor"})," ",t.cancelled?e("ladder.jobStopping"):e("ladder.jobStop")]}):l.jsx("button",{onClick:xT,className:"text-ink-faint hover:text-ink",title:e("ladder.jobClose"),"data-ladder-job-close":!0,children:l.jsx(cn,{size:13,strokeWidth:1.75})})]}),l.jsx("div",{className:"mt-2 h-1 rounded-full bg-wash overflow-hidden",children:l.jsx("div",{className:"h-full bg-accent transition-[width] duration-300",style:{width:`${Math.round(n*100)}%`}})}),l.jsx("p",{className:"mt-1.5 text-2xs text-ink-muted tabular-nums","data-ladder-job-line":!0,children:t.running?ye(e("ladder.jobProgress"),{n:t.done+t.failed,m:t.total,model:t.model}):(t.cancelled?ye(e("ladder.jobStopped"),{n:t.done}):ye(e("ladder.jobDone"),{n:t.done,k:t.skipped}))+(t.failed?ye(e("ladder.jobFailed"),{f:t.failed}):"")}),!t.running&&t.failed>0&&t.lastError&&l.jsx("p",{className:"mt-1 text-2xs text-red-500 break-words","data-ladder-job-error":!0,children:t.lastError})]})}function fue(){const e=oe(r=>r.releaseNotesOpen),t=oe(r=>r.setReleaseNotesOpen),n=Da(r=>r.lang),a=St();return D.useEffect(()=>{if(!e)return;const r=s=>{s.key==="Escape"&&(s.stopPropagation(),t(!1))};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t]),e?l.jsx("div",{className:"fixed inset-0 z-[100] bg-black/25 flex items-center justify-center animate-fade-in p-6",onClick:()=>t(!1),children:l.jsxs("div",{className:"bg-card border border-line rounded-2xl shadow-xl w-[680px] max-w-full max-h-[85vh] overflow-y-auto",onClick:r=>r.stopPropagation(),role:"dialog","aria-labelledby":"release-notes-title","data-release-notes":!0,children:[l.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-line",children:[l.jsx("div",{className:"text-2xs uppercase tracking-wide text-ink-faint",children:"ThoughtDAG"}),l.jsx("h2",{id:"release-notes-title",className:"text-base font-semibold text-ink mt-0.5",children:a("releaseNotes.title")})]}),l.jsx("ol",{className:"px-6 divide-y divide-line",children:FM.map(r=>{const s=_s===r.version;return l.jsxs("li",{className:"py-4","data-release":r.version,children:[l.jsxs("div",{className:"flex items-baseline gap-2.5 flex-wrap",children:[l.jsxs("span",{className:"text-sm font-semibold text-ink tabular-nums",children:["v",r.version]}),l.jsx("span",{className:"text-xs text-ink-faint tabular-nums",children:r.date}),s&&l.jsx("span",{className:"text-2xs font-medium uppercase tracking-wide text-accent bg-accent/10 rounded-full px-2 py-0.5",children:a("releaseNotes.current")})]}),l.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mt-1.5 [overflow-wrap:anywhere]",children:r.lead[n]}),l.jsx(qM,{items:r.items,lang:n})]},r.version)})}),l.jsx("div",{className:"sticky bottom-0 bg-card px-6 py-4 border-t border-line flex justify-end",children:l.jsx("button",{onClick:()=>t(!1),className:"text-xs text-ink px-4 py-2 rounded-lg border border-line hover:bg-wash transition-colors",children:a("common.close")})})]})}):null}const Nb=e=>e.split("/").filter(Boolean).slice(-1)[0]??e;function mue(){const e=St(),t=oe(_=>_.selectedModel),n=sn(_=>_.activeId),a=sn(_=>_.projects),r=se(_=>_.nodes.length),[s,o]=D.useState(null),[u,d]=D.useState(null),[h,m]=D.useState(!1),[p,x]=D.useState(""),[,b]=D.useState(0),y=D.useRef(null),w=!!window.desktopSessions&&N2(t),E=!!window.desktopAgents&&(si(t)||w);if(D.useEffect(()=>{if(!E)return;let _=!0;return F2(w).then(S=>{_&&o(S)}),DV().then(S=>{_&&d(S)}),()=>{_=!1}},[E,w,n,a,r]),D.useEffect(()=>{if(!h)return;const _=z=>{y.current&&!y.current.contains(z.target)&&m(!1)},S=z=>{z.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",S)}},[h]),!E||!s)return null;const v=a.find(_=>_.id===n),A=[...new Set(a.map(_=>_.agentCwd).filter(_=>!!_))].filter(_=>_!==v?.agentCwd).slice(0,5),T=async _=>{n&&(await G2(n,_),m(!1))},C=window.desktopAgents?.capabilities?.nativePicker!==!1,I=async()=>{const _=await window.desktopAgents.pickCwd();_?await T(_):window.desktopAgents?.capabilities?.nativePicker===!1&&b(S=>S+1)},O=async()=>{const _=p.trim();_.startsWith("/")&&await T(_)};return l.jsxs("div",{ref:y,className:"relative",children:[l.jsxs("button",{onClick:_=>{_.stopPropagation(),m(S=>!S)},className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-2.5 flex items-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-xs text-ink max-w-[220px]",title:`${e("agent.cwd")} · ${s.cwd}`,"data-agent-cwd":s.kind,children:[l.jsx(lu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsx("span",{className:"truncate",children:s.kind==="workspace"?e("agent.cwdWorkspace"):Nb(s.cwd)}),l.jsx(cr,{size:12,strokeWidth:1.75,className:"text-ink-faint shrink-0"})]}),h&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 w-[320px] bg-card border border-line rounded-xl shadow-lg py-1.5 z-50 animate-fade-in",onClick:_=>_.stopPropagation(),children:[l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.cwd")}),l.jsxs("button",{onClick:()=>{T(void 0)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:u?e("agent.cwdMirrored"):s.kind==="session"?e("agent.cwdSession"):e("agent.cwdWorkspace")}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:u??(s.kind==="session"?s.cwd:e("agent.cwdWorkspaceHint"))})]}),!v?.agentCwd&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),v?.agentCwd&&l.jsxs("button",{onClick:()=>{T(v.agentCwd)},className:"w-full text-left px-3 py-2 text-xs hover:bg-wash flex items-center gap-2",children:[l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Nb(v.agentCwd)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:v.agentCwd})]}),l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),A.length>0&&l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-2 pb-1",children:e("agent.cwdRecent")}),A.map(_=>l.jsx("button",{onClick:()=>{T(_)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2",children:l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:Nb(_)}),l.jsx("span",{className:"block text-2xs text-ink-faint truncate",children:_})]})},_)),l.jsx("div",{className:"border-t border-line/60 my-1"}),C?l.jsxs("button",{onClick:()=>{I()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash flex items-center gap-2","data-agent-cwd-pick":!0,children:[l.jsx(lu,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",e("agent.cwdPick")]}):l.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",children:[l.jsx("input",{value:p,onChange:_=>x(_.target.value),onKeyDown:_=>{_.stopPropagation(),_.key==="Enter"&&O()},placeholder:e("agent.cwdType"),className:"flex-1 min-w-0 text-xs font-mono bg-wash border border-line rounded-md px-2 py-1 focus:outline-none focus:border-accent/60","data-agent-cwd-input":!0}),l.jsx("button",{onClick:()=>{O()},className:"text-xs text-accent hover:underline shrink-0",children:e("agent.cwdUse")})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsx("p",{className:"text-2xs text-ink-faint uppercase tracking-wider font-medium px-3 pt-1 pb-1",children:e("agent.guard")}),l.jsxs("button",{onClick:()=>{qE("ask"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"ask",children:[l.jsx(IU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAsk")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAskHint")})]}),(v?.agentGuard?.mode??"ask")==="ask"&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),l.jsxs("button",{onClick:()=>{qE("allow"),m(!1)},className:"w-full text-left px-3 py-1.5 text-xs hover:bg-wash flex items-center gap-2","data-agent-guard":"allow",children:[l.jsx(DU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"}),l.jsxs("span",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"block text-ink",children:e("agent.guardAllow")}),l.jsx("span",{className:"block text-2xs text-ink-faint",children:e("agent.guardAllowHint")})]}),v?.agentGuard?.mode==="allow"&&l.jsx(Jr,{size:13,strokeWidth:2,className:"shrink-0 text-accent"})]}),(v?.agentGuard?.allow?.length??0)>0&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-2xs text-ink-faint px-3 pt-2 pb-1",children:e("agent.guardAllowed")}),v.agentGuard.allow.map(_=>l.jsxs("div",{className:"px-3 py-1 text-xs flex items-center gap-2 min-w-0","data-agent-guard-allowed":_,children:[l.jsx("span",{className:"flex-1 min-w-0 truncate text-ink-muted font-mono",title:_,children:_}),l.jsx("button",{onClick:()=>{M7(_,!0)},className:"text-ink-faint hover:text-red-500 shrink-0",title:e("agent.guardRemove"),children:l.jsx(cn,{size:12,strokeWidth:2})})]},_))]})]})]})}const qT="thoughtdag.pluginUpdateNotified";function Vy(e){return`dsh plugin --profile web add dsh-thoughtdag@${e||"latest"}`}async function pue(e){try{const t=await fetch(e.replace(/\/+$/,"")+"/version",{credentials:"same-origin"});if(!t.ok)return;const n=await t.json();if(!n.version||!n.latest||$y(n.latest,n.version)<=0)return;oe.getState().setPluginUpdate({current:n.version,latest:n.latest});let a=null;try{a=localStorage.getItem(qT)}catch{}if(a!==n.latest){try{localStorage.setItem(qT,n.latest)}catch{}const r=oe.getState().harnessHost?.desktop??(()=>{try{const s=window.parent?.document?.documentElement;return!!s&&(s.dataset.platform!==void 0||s.hasAttribute("data-windows-titlebar"))}catch{return!1}})();We("info",ye(Te("plugin.updateAvailable"),{v:n.latest})+(r?" "+ye(Te("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${n.latest}`}):""),12e3)}}catch{}}const gue=Object.freeze(Object.defineProperty({__proto__:null,bootPluginUpdateCheck:pue,pluginUpdateCommand:Vy},Symbol.toStringTag,{value:"Module"})),xue={ruleout:"#ef4444",decision:"#6B5CE7",pivot:"#e8890c",open:"#d97706",insight:"#0284c7"},$T=e=>{if(e){for(let t=e.length-1;t>=0;t--)if(e[t])return e[t]}};function bue(e){if(e.stepKind==="file")return e.attachments?.[0]?.name;if(e.stepKind==="link")return e.linkTitle||e.linkUrl;if(e.stepKind==="note")return e.question?.split(`
|
|
908
908
|
`)[0].replace(/^#+\s*/,"")||void 0}function Yv(e,t,n={}){return e.filter(a=>a.data.stepKind!=="frame").map((a,r)=>{const s=a.data,o=s.createdAt??s.askedAt??s.generatedAts?.[0]??s.lastGeneratedAt,u=[s.askedAt,$T(s.generatedAts),$T(s.editedAts)].filter(Boolean).sort().pop(),d=s.summaryTypes?.[s.responseIndex??0]??void 0,h=s.summaries?.[s.responseIndex??0],m=s.summaryTopics?.[s.responseIndex??0]??void 0,p=n.ladders?s.summaryLadders?.[s.responseIndex??0]??B2(a.id,s.question,s.response,h,m):null,x=o?Date.parse(o):NaN,b=u?Date.parse(u):NaN;return{entry:{id:a.id,label:(h||bue(s)||s.question||"").slice(0,120),topic:m,...p?{ladder:p}:{},badged:!!d&&d!=="insight",type:d??void 0,createdAt:o,modifiedAt:u,color:d&&xue[d]||"#b8b3c7",archived:!!s.archived,recentlyEdited:!isNaN(x)&&!isNaN(b)&&b-x>6e4&&t-b<30*6e4,x:a.position.x,y:a.position.y},i:r}}).sort((a,r)=>{const s=a.entry.createdAt??"",o=r.entry.createdAt??"";return s<o?-1:s>o?1:a.i-r.i}).map(({entry:a})=>a)}const yue=e=>e?24:16,vue=(e,t,n)=>{const a=yue(n);if(t==null)return a;const r=Math.abs(e-t);return r===0?a+14:r===1?a+7:r===2?a+3:a};function wue(){const e=Y0(),t=se(C=>C.nodes),n=se(C=>C.setSelectedNodeId),a=oe(C=>C.setTimelineOverviewOpen),r=Vl(),s=St(),o=JA(),[u,d]=D.useState(null),[h,m]=D.useState(()=>Date.now());D.useEffect(()=>{const C=setInterval(()=>m(Date.now()),6e4);return()=>clearInterval(C)},[]);const p=ln(C=>C.transform),x=ln(C=>C.width),b=ln(C=>C.height),y=D.useMemo(()=>Yv(t,h),[t,h]),w=D.useMemo(()=>{const[C,I,O]=p,_=-C/O,S=-I/O,z=(x-C)/O,V=(b-I)/O,P=new Set;for(const L of y)L.x+520>_&&L.x<z&&L.y+220>S&&L.y<V&&P.add(L.id);return P},[y,p,x,b]);if(e==="work"||y.length<2)return null;const E=C=>C?C.slice(0,10):"",v=C=>C.slice(5).replace("-","/"),A=C=>C?new Date(C).toLocaleString(o):"",T=u?y.find(C=>C.id===u.id):null;return l.jsxs("div",{className:"absolute left-[2px] top-[calc(38%+116px)] w-[100px] z-10 tdag-timeline pointer-events-none flex flex-col items-stretch","data-timeline-bar":!0,role:"navigation","aria-label":s("timeline.label"),children:[T&&u&&l.jsxs("div",{className:"fixed left-[108px] max-w-[320px] bg-card border border-line rounded-lg shadow-md px-3 py-2 text-xs pointer-events-none z-20",style:{top:u.y-14},children:[l.jsxs("div",{className:"font-medium text-ink truncate",children:[T.topic&&l.jsxs("span",{className:"text-accent",children:[T.topic," · "]}),T.label||"…"]}),T.createdAt&&l.jsxs("div",{className:"text-ink-faint mt-0.5",children:[s("timeline.created")," ",A(T.createdAt)]}),T.modifiedAt&&T.modifiedAt!==T.createdAt&&l.jsxs("div",{className:"text-ink-faint",children:[s("timeline.modified")," ",A(T.modifiedAt)]}),l.jsx("div",{className:"text-[10px] text-ink-faint/80 mt-1",children:s("timeline.clickHint")})]}),l.jsx("button",{onClick:()=>a(!0),title:s("timeline.openOverview"),"data-timeline-overview-btn":!0,className:"pointer-events-auto self-start ml-[25px] w-7 h-7 rounded-lg flex items-center justify-center text-ink-faint/70 hover:text-accent hover:bg-accent/10 transition-colors",children:l.jsx(xp,{size:14,strokeWidth:1.75})}),l.jsx("div",{className:"pointer-events-auto overflow-y-auto tdag-noscrollbar max-h-[170px] mt-0.5",children:l.jsx("div",{className:"flex flex-col py-1",children:y.map((C,I)=>{const O=I>0?E(y[I-1].createdAt):"",_=E(C.createdAt),S=_!==""&&_!==O;return l.jsxs("button",{"data-timeline-dot":C.id,onMouseEnter:z=>d({id:C.id,idx:I,y:z.currentTarget.getBoundingClientRect().top}),onMouseLeave:()=>d(z=>z?.id===C.id?null:z),onClick:()=>{n(C.id);const z=r.getViewport().zoom;r.setCenter(C.x+260+ap(C.id)/(2*z),C.y+110,{zoom:z,duration:300})},onDoubleClick:()=>{n(C.id),r.setCenter(C.x+260+ap(C.id)/2,C.y+110,{zoom:1,duration:350})},className:"relative flex items-center w-full h-[14px] shrink-0 pl-[29px] cursor-pointer","aria-label":C.label,children:[l.jsx("span",{className:`rounded-full ${C.recentlyEdited?"tdag-timeline-pulse":""}`,style:{width:vue(I,u?.idx??null,C.badged),height:4,background:C.color,opacity:C.archived?.3:w.has(C.id)?1:.45,transition:"width .18s ease, opacity .3s ease"}}),S&&l.jsx("span",{className:"absolute left-[67px] top-1/2 -translate-y-1/2 text-[10px] leading-none text-ink-faint select-none whitespace-nowrap",children:v(_)})]},C.id)})})})]})}function $M(e){const t=e.filter(a=>!a.data.archived).map(a=>`${a.id}:${Ko(a.data)??""}:${a.data.summaryTypes?.[a.data.responseIndex]??""}`).sort();let n=5381;for(const a of t)for(let r=0;r<a.length;r++)n=(n<<5)+n+a.charCodeAt(r)|0;return String(n>>>0)}const Gy=new Map,kue=(e,t)=>Gy.get(`${t}:${e}`),WT={ruleout:"RULEOUT",decision:"DECISION",pivot:"PIVOT",open:"OPEN",insight:"INSIGHT"};async function Eue(e,t,n){const a=$M(e),r=Gy.get(`${n}:${a}`);if(r)return r;const s=e.find(b=>b.data.isRoot),o=Yv(e.filter(b=>!b.data.archived),0),d=o.length>60?o.filter((b,y)=>b.badged||y<10||y>=o.length-10):o,h=o.length-d.length,m=d.map(b=>{const y=e.find(A=>A.id===b.id);if(!y)return null;const w=y.data,E=Ko(w);if(!E)return null;const v=w.summaryTypes?.[w.responseIndex]??void 0;return`- ${v&&WT[v]?`${WT[v]}: `:""}${b.topic?`[${b.topic}] `:""}${E}`}).filter(b=>!!b);h>0&&m.push(`(${h} plain steps omitted from this list)`);const x={text:(await er([{role:"user",content:`Opening question of a thinking map: ${s?.data.question?.slice(0,300)??"(untitled)"}
|
|
909
909
|
|
|
910
910
|
The takeaway of every step, in the order they were thought (tags: RULEOUT = killed an option, DECISION = chose, PIVOT = reframed, OPEN = still unresolved):
|
|
911
911
|
${m.join(`
|
|
912
912
|
`)}
|
|
913
913
|
|
|
914
|
-
Write the JOURNEY of this thinking as one flowing paragraph a reader absorbs in twenty seconds: where it started, what got ruled out, where it turned, where it landed, what remains open. Only the turns that mattered — do not enumerate every step. Hard limit: 250 characters for CJK languages, 500 characters otherwise. Write in ${n==="zh"?"Chinese":"English"} (the reader's interface language), even if the takeaway lines mix languages. Never use dash characters (—, –, -); use commas, colons or full stops. Output only the paragraph.`}])).trim(),fp:a,at:new Date().toISOString(),lang:n};return Gy.set(`${n}:${a}`,x),x}function Sue({onLocate:e}){const t=oe(B=>B.timelineOverviewOpen),n=oe(B=>B.setTimelineOverviewOpen),a=se(B=>B.nodes),r=St(),s=JA(),o=Da(B=>B.lang),u=bV(),d=D.useMemo(()=>Yv(a,0,{ladders:!0}),[a,u]),[h,m]=D.useState(1),p=Math.round(h),x={paddingTop:4+h*5,paddingBottom:4+h*5},b=D.useRef(null),y=D.useRef(null),w=D.useRef(null),E=B=>{const j=b.current;if(j){const $=j.getBoundingClientRect().top,X=[...j.querySelectorAll("[data-entry]")];let Q=y.current?X.find(F=>F.dataset.entry===y.current)??null:null;if(!Q){const F=$+j.clientHeight/2;Q=X.reduce((G,J)=>{const K=J.getBoundingClientRect(),ee=Math.abs((K.top+K.bottom)/2-F);return!G||ee<Math.abs((G.getBoundingClientRect().top+G.getBoundingClientRect().bottom)/2-F)?J:G},null)}w.current=Q?{id:Q.dataset.entry,y:Q.getBoundingClientRect().top-$}:null}m(B)};D.useLayoutEffect(()=>{const B=b.current,j=w.current;if(!B||!j)return;const $=B.querySelector(`[data-entry="${j.id}"]`);if(!$)return;const X=$.getBoundingClientRect().top-B.getBoundingClientRect().top;B.scrollTop+=X-j.y},[h]);const v=13+h*.9,A=D.useMemo(()=>$M(a),[a]),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(!1),z=kue(A,o)??T,V=!!z&&(z.fp!==A||z.lang!==o),P=()=>{O(!0),S(!1);const{nodes:B,edges:j}=se.getState();Eue(B,j,o).then(C).catch(()=>S(!0)).finally(()=>O(!1))};if(!t)return null;const L=()=>n(!1),Y=B=>B?B.slice(0,10):"",q=B=>B?new Date(B).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit"}):"—";return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:L,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(xp,{size:15,strokeWidth:1.75,className:"text-accent"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("tlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ye(r("tlov.count"),{n:d.length})}),l.jsxs("label",{className:"flex items-center gap-2 ml-3 text-2xs text-ink-faint",title:r("tlov.detailTitle"),children:[l.jsx("span",{children:r("tlov.detail")}),l.jsx("input",{type:"range",min:0,max:3,step:.01,value:h,onChange:B=>E(Number(B.target.value)),className:"w-28 accent-accent","data-tlov-detail":!0}),l.jsx("span",{className:"text-ink-muted w-8",children:r(`ladder.level${p}`)})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{L(),oe.getState().setThoughtMapOpen(!0)},disabled:d.length===0,"data-tmap-from-timeline":!0,className:"flex items-center gap-1.5 text-2xs text-ink-muted hover:text-accent hover:bg-accent/10 rounded-full px-2.5 py-1 transition-colors disabled:opacity-50",children:[l.jsx(d2,{size:13,strokeWidth:1.75}),r("tmap.export")]}),l.jsx("button",{onClick:L,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-5 pt-3 shrink-0","data-gedankengang":!0,children:[!z&&!I&&l.jsxs("button",{onClick:P,className:"flex items-center gap-1.5 text-2xs text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-3 py-1.5 transition-colors",children:[l.jsx(Hl,{size:12,strokeWidth:1.75}),r("tlov.gedankenGenerate")]}),I&&l.jsx("p",{className:"text-2xs text-ink-faint italic py-1.5",children:r("tlov.gedankenLoading")}),_&&!I&&l.jsx("p",{className:"text-2xs text-red-500 py-1",children:r("tlov.gedankenFailed")}),z&&!I&&l.jsxs("div",{className:`rounded-xl bg-wash px-4 py-3 ${V?"opacity-60":""}`,children:[l.jsx("p",{className:"text-sm text-ink leading-relaxed",children:z.text}),l.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:V?r("tlov.gedankenStale"):new Date(z.at).toLocaleString(s)}),V&&l.jsx("button",{onClick:P,className:"text-2xs text-accent hover:underline",children:r("tlov.gedankenRedo")})]})]})]}),l.jsxs("div",{ref:b,className:"flex-1 min-h-0 overflow-y-auto px-5 py-3","data-timeline-overview":!0,children:[d.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("tlov.empty")}),d.map((B,j)=>{const $=j>0?Y(d[j-1].createdAt):void 0,X=Y(B.createdAt),Q=j===0||X!==$;return l.jsxs("div",{children:[Q&&l.jsx("div",{className:"sticky top-0 bg-card text-2xs text-ink-faint font-medium pt-3 pb-1 first:pt-0",children:X||r("tlov.undated")}),l.jsxs("div",{className:"group flex items-start gap-2.5 border-b border-line/50 last:border-0",style:x,"data-entry":B.id,onMouseEnter:()=>{y.current=B.id},onMouseLeave:()=>{y.current===B.id&&(y.current=null)},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:B.color,opacity:B.archived?.35:1}}),l.jsx("span",{className:"text-2xs font-mono text-ink-faint shrink-0 w-11",children:q(B.createdAt)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[B.ladder?l.jsx("div",{className:B.archived?"opacity-50 line-through":"",children:l.jsx(hM,{ladder:B.ladder,level:p,fontSize:v,weight:B.badged?"font-semibold":"font-medium",className:"whitespace-pre-wrap break-words"})}):l.jsx("p",{className:`leading-snug whitespace-pre-wrap break-words ${B.archived?"text-ink-faint line-through":B.badged?"text-ink":"text-ink-muted"}`,style:{fontSize:v,transition:"font-size 160ms ease-out"},children:p===0?B.topic||B.label||"…":l.jsxs(l.Fragment,{children:[B.topic&&l.jsxs("span",{className:"font-medium text-accent",children:[B.topic," · "]}),B.label||"…"]})}),B.modifiedAt&&B.modifiedAt!==B.createdAt&&l.jsxs("p",{className:"text-2xs text-ink-faint",children:[r("timeline.modified")," ",new Date(B.modifiedAt).toLocaleString(s)]})]}),l.jsx("button",{className:"shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors opacity-0 group-hover:opacity-100",onClick:()=>{L(),e(B.id)},title:r("hlov.locateTitle"),children:r("tlov.locate")})]})]},B.id)})]})]})}),document.body)}const Tue=D.memo(function(t){const n=sn(a=>a.projects.find(r=>r.id===a.activeId)?.kind==="paradigm");return t.data?.stepKind==="frame"?l.jsx(qoe,{...t}):Rm(t.data?.stepKind)?l.jsx(Uoe,{...t}):n?l.jsx(zoe,{...t}):l.jsx(joe,{...t})}),Nue={thought:Tue},Aue={smoothstep:D.memo(Voe)};function Cue(){const[e,t]=D.useState(Et||se.persist.hasHydrated());return D.useEffect(()=>se.persist.onFinishHydration(()=>t(!0)),[]),D.useEffect(()=>{if(!e||Et)return;let n;const a=()=>{clearTimeout(n),n=setTimeout(()=>{gce()},800)},r=se.subscribe((s,o)=>{s.nodes!==o.nodes&&a()});return a(),()=>{r(),clearTimeout(n)}},[e]),D.useEffect(()=>{oe.getState().condenseRun.status==="building"&&oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})},[]),D.useEffect(()=>{if(Et)return;const n=setTimeout(()=>{xce()},6e3);return()=>clearTimeout(n)},[]),D.useEffect(()=>{if(!e||Et||localStorage.getItem("thoughtdag.tutorialDone")||se.getState().nodes.length>0)return;const n=setTimeout(()=>oe.getState().setTutorialOpen(!0),900);return()=>clearTimeout(n)},[e]),D.useEffect(()=>{kce()},[]),D.useEffect(()=>{Et||(ft(()=>import("./session-handoff-AggmklDT.js"),[]).then(n=>n.consumeSessionHandoff()),ft(()=>Promise.resolve().then(()=>Y8),void 0).then(n=>n.startLiveMirror()),ft(()=>import("./canvas-record-D3HdLWps.js"),[]).then(n=>n.startCanvasRecord()),ft(()=>import("./canonical-BuO7_FJb.js"),[]).then(n=>n.unsubscribeOrphanedSessions()))},[]),D.useEffect(()=>{Et||wce().then(n=>{n&&(n.status==="minted"?(We("success",Te("provider.oauthMinted")),jM(n.key)):We("error",ye(Te("provider.oauthFailed"),{error:n.error})))})},[]),l.jsxs(l.Fragment,{children:[e&&l.jsx(_ue,{}),l.jsx(Nce,{}),l.jsx(hue,{}),l.jsx(Cce,{}),l.jsx(Ice,{}),l.jsx(Oce,{}),l.jsx(jce,{}),l.jsx(Lce,{}),l.jsx(Pce,{}),l.jsx(qce,{}),l.jsx(Kce,{}),l.jsx(Ece,{}),l.jsx(oue,{}),l.jsx(due,{}),l.jsx(fue,{})]})}function _ue(){const{nodes:e,edges:t,setNodes:n,setEdges:a,addQuestion:r,undo:s,redo:o,addCrossLink:u,setSelectedNodeId:d,setSelectedNodeIds:h,history:m,historyIndex:p,relayout:x}=se(),b=St(),y=oe(H=>H.setTutorialOpen),w=oe(H=>H.annotationsHidden),E=oe(H=>H.setAnnotationsHidden),v=oe(H=>H.wheelPans),A=oe(H=>H.setWheelPans),[T,C]=D.useState(""),[I,O]=D.useState(!1),[_,S]=D.useState(""),[z,V]=D.useState(!1),[P,L]=D.useState(!1),[Y,q]=D.useState([]),[B,j]=D.useState(!1),$=D.useRef(null),X=D.useRef(null),Q=e.length>0,F=se(H=>H.events.length>0),G=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.highlights?.length??0),0)),J=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.attachments?.length??0)+(["note","link"].includes(we.data.stepKind??"")?1:0),0)),K=D.useRef(null),ee=oe(H=>H.arrivalFocusNodeId);D.useEffect(()=>{if(!ee)return;const H=se.getState().nodes.find(ce=>ce.id===ee);H&&(oe.getState().setArrivalFocusNodeId(null),window.setTimeout(()=>{K.current?.setCenter(H.position.x+260,H.position.y+140,{zoom:.9,duration:400})},150))},[ee]);const ue=Hi(H=>H.paper),pe=Hi(H=>H.lighting),be=Hi(H=>H.resolved),ae=D.useMemo(()=>Foe(),[be]),xe=D.useMemo(()=>{const H=getComputedStyle(document.documentElement),ce=(H.getPropertyValue("--color-surface").trim()||"#FAF9F7").replace("#",""),[we,Ne,Xe]=[0,2,4].map(vt=>parseInt(ce.slice(vt,vt+2),16));return{mask:`rgba(${we},${Ne},${Xe},0.7)`,archived:H.getPropertyValue("--color-wash").trim()||"#EFEDE9",ordinary:be==="dark"?"#6E6759":"#B9B3AB"}},[be]),Ce=D.useRef(e.length),ze=D.useCallback((H,ce={})=>{const we=K.current;if(!we)return;const Ne=ce.zoom??we.getZoom();we.setCenter(H.position.x+(ce.offX??260)+ap(H.id)/(2*Ne),H.position.y+110,{zoom:Ne,duration:ce.duration??350})},[]),Ie=Da(H=>H.lang),Fe=oe(H=>H.condenseRun),Ee=Fe.status==="building",Me=sn(H=>H.projects.find(ce=>ce.id===H.activeId)?.kind==="paradigm"),De=Yl(),bt=D.useCallback(()=>{const{nodes:H,edges:ce}=pce(Ie),we=se.getState();we.setNodes([...we.nodes,...H.filter(Ne=>!we.nodes.some(Xe=>Xe.id===Ne.id))]),we.setEdges([...we.edges,...ce.filter(Ne=>!we.edges.some(Xe=>Xe.id===Ne.id))]),we.pushHistory(),setTimeout(()=>{const Ne=K.current;Ne&&(Ne.fitView({duration:500,padding:.1}),setTimeout(()=>{if(Ne.getViewport().zoom<.34){const Xe=[...se.getState().nodes].sort((vt,wt)=>(vt.data.createdAt??"").localeCompare(wt.data.createdAt??""))[0];Xe&&Ne.setCenter(Xe.position.x+300,Xe.position.y+240,{zoom:.6,duration:550})}},680))},100),localStorage.getItem("thoughtdag.tutorialDone")||y(!0)},[Ie,y]),mt=D.useCallback(H=>{const ce=se.getState(),we=ce.nodes[ce.nodes.length-1],Ne=we?{x:we.position.x,y:we.position.y+340}:{x:120,y:80},Xe=Tn();ce.setNodes([...ce.nodes,{id:Xe,type:"thought",position:Ne,dragHandle:".drag-handle",data:{question:"",instruction:"",stepKind:H,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:ce.nodes.length===0,isBranch:!1}}]),ce.pushHistory()},[]),Ye=D.useCallback(()=>{Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:300,padding:.2}),50)},[]);D.useEffect(()=>{const H=()=>Ye();return window.addEventListener("td:project-switched",H),()=>window.removeEventListener("td:project-switched",H)},[Ye]);const at=D.useRef(null),rt=D.useCallback(H=>{const ce=se.getState(),we=Tn();ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,width:640,height:420,zIndex:-1,dragHandle:".drag-handle",data:{question:"",stepKind:"frame",frameCarry:!1,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}]),ce.pushHistory()},[]),Ue=D.useCallback(H=>{const ce=[];for(const we of Array.from(H)){const Ne=we.name.split(".").pop()?.toLowerCase()??"";we.type.startsWith("image/")||we.type==="application/pdf"||we.type.startsWith("text/")||["pdf","docx","txt","md","csv","json","yaml","yml","toml","js","ts","tsx","jsx","py","sh","c","cpp","h","java","rs","go","rb","swift","css","html","xml","sql","tex","bib"].includes(Ne)?ce.push(we):We("info",ye(Te("toast.unsupportedFile"),{name:we.name}))}return ce},[]),Ct=D.useCallback(H=>{const ce=se.getState(),we=Tn();return ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,dragHandle:".drag-handle",data:{question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled}}]),ce.pushHistory(),we},[]),ot=D.useCallback(H=>{const ce=Ue(H);if(ce.length===0)return;let we=null;ce.forEach((Ne,Xe)=>{const vt=ps("file",{x:120+Xe%3*480,y:120+Math.floor(Xe/3)*620});Gd(vt,[Ne]),!we&&!Ne.type.startsWith("image/")&&(we=vt)}),we&&oe.getState().setReaderNodeId(we),setTimeout(()=>K.current?.fitView({duration:400,padding:.2}),120)},[Ue]),It=D.useCallback((H,ce)=>{const we=H.clientX,Ne=H.clientY,Xe=H.currentTarget;let vt=null;const wt=$t=>{!vt&&Math.hypot($t.clientX-we,$t.clientY-Ne)>6&&(vt=document.createElement("div"),vt.innerHTML=Xe.innerHTML,vt.style.cssText="position:fixed;z-index:300;pointer-events:none;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--color-card);border:1px solid var(--color-accent);border-radius:10px;box-shadow:0 4px 14px rgba(0,0,0,.18);opacity:.92;",document.body.appendChild(vt)),vt&&(vt.style.left=`${$t.clientX-18}px`,vt.style.top=`${$t.clientY-18}px`)},Ot=$t=>{window.removeEventListener("pointermove",wt),window.removeEventListener("pointerup",Ot);const fn=!!vt;vt?.remove(),ce(fn?{x:$t.clientX,y:$t.clientY}:null)};window.addEventListener("pointermove",wt),window.addEventListener("pointerup",Ot)},[]),_e=D.useCallback(H=>{const ce=K.current?.screenToFlowPosition(H??{x:window.innerWidth/2,y:window.innerHeight/2})??{x:140,y:140};return{x:ce.x-200,y:ce.y-60}},[]);D.useEffect(()=>{const H=we=>{at.current={x:we.clientX,y:we.clientY}},ce=we=>{if(Et)return;const Ne=we.target;if(Ne&&(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.isContentEditable))return;const Xe=sn.getState(),vt=Xe.projects.find(Kn=>Kn.id===Xe.activeId)?.kind==="paradigm";if(se.getState().nodes.length===0&&!vt)return;const wt=we.clipboardData;if(!wt)return;const Ot=_e(at.current),$t=wt.getData("text/plain").trim(),fn=Array.from(wt.files),Ga=fn.some(Kn=>!Kn.type.startsWith("image/"));if(fn.length>0&&(Ga||!$t)){we.preventDefault();const Kn=ps("file",Ot);Gd(Kn,fn);return}if($t)if(we.preventDefault(),/^https?:\/\/\S+$/.test($t)){const Kn=ps("link",Ot,{linkUrl:$t});W8(Kn,$t)}else ps("note",Ot,{question:gW($t)})};return window.addEventListener("mousemove",H),window.addEventListener("paste",ce),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("paste",ce)}},[_e]);const Ze=D.useCallback(async()=>{const H=se.getState();if(H.nodes.length===0)return;const{nodes:ce,edges:we}=dG(H.nodes,H.edges),Ne=sn.getState(),Xe=Ne.projects.find(wt=>wt.id===Ne.activeId)?.name??"Paradigm",vt=crypto.randomUUID();await jr(ws(vt),JSON.stringify({state:{nodes:ce,edges:we},version:1})),await vu(vt,`▶ ${Xe}`,"chat"),await j7(vt,Xe),Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),150)},[]);D.useEffect(()=>{e.length===0&&!Me&&!localStorage.getItem("thoughtdag.seeded")&&localStorage.setItem("thoughtdag.seeded","yes")},[]),D.useEffect(()=>{if(e.length>Ce.current&&K.current){const H=e[e.length-1];H&&setTimeout(()=>ze(H,{zoom:1,duration:400,offX:220}),100)}Ce.current=e.length},[e,ze]);const ie=D.useCallback(H=>{const ce=se.getState().nodes;n(rA(H,ce))},[n]),Be=D.useCallback(H=>a(sA(H,se.getState().edges)),[a]),Je=D.useRef(null),Ht=D.useCallback((H,ce)=>{if(ce.data.stepKind!=="frame"||ce.data.frameCarry===!1)return;const we=se.getState(),Ne=we.nodes.find(vt=>vt.id===ce.id);if(!Ne)return;const Xe=N8(Ne,we.nodes).filter(vt=>!vt.selected).map(vt=>({id:vt.id,start:vt.position}));Xe.length!==0&&(Je.current={frameId:Ne.id,start:Ne.position,members:Xe})},[]),Kt=D.useCallback((H,ce)=>{const we=Je.current;if(!we||ce.id!==we.frameId)return;const Ne=ce.position.x-we.start.x,Xe=ce.position.y-we.start.y,vt=new Map(we.members.map(wt=>[wt.id,{x:wt.start.x+Ne,y:wt.start.y+Xe}]));se.setState(wt=>({nodes:wt.nodes.map(Ot=>{const $t=vt.get(Ot.id);return $t?{...Ot,position:$t}:Ot})}))},[]),qt=D.useCallback(()=>{Je.current=null},[]),[Rt,en]=D.useState(null),[Gt,ha]=D.useState(null),zn=D.useCallback((H,ce)=>{Et||window.getSelection()?.toString()||(H.preventDefault(),ha({x:H.clientX,y:H.clientY,nodeId:ce.id}))},[]),tr=D.useCallback((H,ce)=>{H.preventDefault(),en({x:H.clientX,y:H.clientY,edgeId:ce.id})},[]);D.useEffect(()=>{if(!Rt)return;const H=()=>en(null);return window.addEventListener("click",H),()=>window.removeEventListener("click",H)},[Rt]);const La=se(H=>H.deleteEdges),na=D.useCallback(H=>{La([H]),en(null)},[La]),Wa=D.useCallback(H=>{H.source&&H.target&&u(H.source,H.target)},[u]),ia=D.useCallback(()=>{window.getSelection()?.removeAllRanges(),document.body.classList.add("tdag-connecting")},[]),me=D.useCallback((H,ce)=>{if(document.body.classList.remove("tdag-connecting"),Me||ce.isValid||ce.fromHandle?.type!=="source"||!ce.fromNode)return;const we=ce.fromNode.id,Ne=H.target?.closest?.(".react-flow__node");if(Ne){const fn=Ne.getAttribute("data-id");if(fn&&fn!==we){const Ga=se.getState().nodes.find(Hr=>Hr.id===fn),Kn=Ga?.data.stepKind??"";Ga&&!["note","file","link","frame"].includes(Kn)&&se.getState().addCrossLink(we,fn)}return}const{clientX:Xe,clientY:vt}="changedTouches"in H?H.changedTouches[0]:H,wt=_e({x:Xe,y:vt}),Ot=se.getState();if(Ot.nodes.find(fn=>fn.id===we)?.data.stepKind==="frame")return;const $t=Ct(wt);Ot.setEdges([...se.getState().edges,{id:`edge-${we}-${$t}`,source:we,target:$t,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}]),se.getState().pushHistory()},[Me,_e,Ct]),Pe=se(H=>H.selectedNodeId),lt=se(H=>H.selectedNodeIds),zt=oe(H=>H.panelOpen),_n=oe(H=>H.viewerLoadError),mn=se(H=>Xr(H).length),Nt=oe(H=>H.panelWidth),pt=e.find(H=>H.id===Pe),Mt=pt?.data.stepKind,Mn=Rm(Mt)||Mt==="frame",pn=zt&&!!pt&&!Me&&!Mn;D.useEffect(()=>{Pe&&!pt&&se.getState().setSelectedNodeId(null)},[Pe,pt]);const ve=lt.length>1,tt=se(H=>H.batchDelete);D.useEffect(()=>{const H=ce=>{if(!oe.getState().confirmRequest&&!(Et&&!((ce.metaKey||ce.ctrlKey)&&ce.key==="f"))){if((ce.metaKey||ce.ctrlKey)&&ce.key==="z"&&(ce.shiftKey?(ce.preventDefault(),o()):(ce.preventDefault(),s())),(ce.metaKey||ce.ctrlKey)&&ce.key==="f"){ce.preventDefault(),O(!0);return}{const we=ce.target;if(!(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)&&Pe&&!Me&&!ce.metaKey&&!ce.ctrlKey&&!ce.altKey){const{nodes:Xe,edges:vt}=se.getState();if(ce.key===" "){ce.preventDefault(),se.getState().toggleCollapse(Pe);return}if(ce.key==="r"||ce.key==="R"){ce.preventDefault(),se.getState().rerunNode(Pe,{});return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(ce.key)){const wt=vt.filter($t=>!$t.data?.isCrossLink);let Ot;if(ce.key==="ArrowUp")Ot=wt.find($t=>$t.target===Pe)?.source;else if(ce.key==="ArrowDown")Ot=wt.find($t=>$t.source===Pe)?.target;else{const $t=wt.find(Kn=>Kn.target===Pe),fn=$t?wt.filter(Kn=>Kn.source===$t.source).map(Kn=>Kn.target):Xe.filter(Kn=>!wt.some(Hr=>Hr.target===Kn.id)).map(Kn=>Kn.id),Ga=fn.indexOf(Pe);Ga!==-1&&fn.length>1&&(Ot=fn[(Ga+(ce.key==="ArrowRight"?1:fn.length-1))%fn.length])}if(Ot){ce.preventDefault(),d(Ot);const $t=Xe.find(fn=>fn.id===Ot);$t&&ze($t,{zoom:1,duration:300})}return}}}if(ce.key==="Escape"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;lt.length>1?h([]):Pe&&d(null);return}if(ce.key==="Delete"||ce.key==="Backspace"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;if(lt.length>1)ce.preventDefault(),ri({title:Te("confirm.deleteNodesTitle"),message:ye(Te("confirm.deleteNodes"),{n:lt.length}),confirmLabel:Te("common.delete"),danger:!0}).then(Ne=>{Ne&&tt(lt)});else{const Ne=t.filter(Xe=>Xe.selected).map(Xe=>Xe.id);Ne.length>0&&(ce.preventDefault(),La(Ne))}}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[s,o,Pe,lt,d,h,tt,t,La,Me,ze]);const kt=()=>{T.trim()&&(r(T.trim(),{rolePrompt:_.trim()||void 0,initialAttachments:Y.length>0?Y:void 0}),C(""),S(""),V(!1),q([]))},jt=async H=>{for(const ce of Array.from(H))await V0(ce,{add:we=>q(Ne=>[...Ne,we]),update:(we,Ne)=>q(Xe=>Xe.map(vt=>vt.id===we?{...vt,...Ne}:vt))})},yt=H=>{H.key==="Enter"&&!H.shiftKey&&!lr(H)&&(H.preventDefault(),kt())},Ut=D.useCallback(({nodes:H})=>{const ce=H.map(we=>we.id);ce.length>1?h(ce):ce.length===1&&d(ce[0])},[d,h]),Qt=D.useMemo(()=>e.filter(H=>H.data.stepKind==="frame"),[e]),[Zt,Yn]=D.useState(!1),tn=D.useRef(null);D.useEffect(()=>{if(!Zt)return;const H=ce=>{tn.current?.contains(ce.target)||Yn(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[Zt]);const[wn,An]=D.useState(!1),xa=oe(H=>H.pluginUpdate),Ln=oe(H=>!!H.harnessHost?.desktop),[Jn,Pa]=D.useState(0),Bn=oe(H=>H.searchHitIds!==null),Hn=D.useRef(null);D.useEffect(()=>{if(!wn)return;const H=ce=>{Hn.current?.contains(ce.target)||An(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[wn]);const Va=oe(H=>H.searchHitIds),oa=D.useMemo(()=>{if(!Pe||lt.length>1||!e.some(wt=>wt.id===Pe))return null;const H=vp(Pe,e,t),ce=new Set;for(const wt of H.mainline)wt.id!==Pe&&ce.add(wt.id);for(const wt of H.materials)ce.add(wt.id);for(const wt of H.references)ce.add(wt.source.id);const we=t.filter(wt=>!wt.data?.isCrossLink),Ne=Lr(Pe,e,we).visitedEdgeIds,Xe=new Set(H.references.map(wt=>wt.edge.id)),vt=we.filter(wt=>wt.source===Pe);return{ctx:ce,down:new Set(vt.map(wt=>wt.target)),pathEdgeIds:Ne,refEdgeIds:Xe,downEdgeIds:new Set(vt.map(wt=>wt.id))}},[Pe,lt,e,t]),nr=D.useMemo(()=>{const H=e.filter(Ne=>Ne.data.stepKind==="frame").map((Ne,Xe)=>({id:Ne.id,order:Xe,area:(Ne.measured?.width??Ne.width??640)*(Ne.measured?.height??Ne.height??420)})).sort((Ne,Xe)=>Xe.area-Ne.area||Ne.order-Xe.order),ce=new Map(H.map((Ne,Xe)=>[Ne.id,Xe-H.length]));let we=e.map(Ne=>Ne.data.stepKind==="frame"?{...Ne,zIndex:ce.get(Ne.id)??-1}:Ne);return w&&(we=we.map(Ne=>{const Xe=Ne.data.stepKind,vt=Rm(Xe)&&!t.some(wt=>wt.source===Ne.id||wt.target===Ne.id);return Xe==="frame"||vt?{...Ne,hidden:!0}:Ne})),Va!==null&&(we=we.map(Ne=>Va.has(Ne.id)||Ne.data.stepKind==="frame"?{...Ne,className:"search-hit"}:Ne.className==="search-hit"?{...Ne,className:void 0}:Ne)),oa&&(we=we.map(Ne=>{const Xe=Ne.id===Pe?"target":oa.ctx.has(Ne.id)?"ctx":oa.down.has(Ne.id)?"down":Ne.data.stepKind==="frame"?void 0:"dim";return Xe?{...Ne,className:[Ne.className,`focus-${Xe}`].filter(Boolean).join(" "),...Xe!=="dim"?{data:{...Ne.data,focusRole:Xe}}:{}}:Ne})),we},[e,t,w,Va,oa,Pe]),st=D.useMemo(()=>{const H=t.map(Ne=>{const Xe=Ne.data?.isBranchFromSelection?{...Ne,animated:!1,style:{...Ne.style,strokeDasharray:void 0}}:Ne,vt=typeof Xe.style?.stroke=="string"?uT[Xe.style.stroke.toUpperCase()]:void 0,wt=Xe.markerEnd&&typeof Xe.markerEnd=="object"?Xe.markerEnd:void 0,Ot=typeof wt?.color=="string"?uT[wt.color.toUpperCase()]:void 0;return!vt&&!Ot?Xe:{...Xe,...vt?{style:{...Xe.style,stroke:ae[vt]}}:{},...Ot&&wt?{markerEnd:{...wt,color:ae[Ot]}}:{}}});if(oa)return H.map(Ne=>oa.pathEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-path",style:{...Ne.style,stroke:ae.accent,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.accent},zIndex:10,data:{...Ne.data,focusRole:"path"}}:oa.refEdgeIds.has(Ne.id)?{...Ne,style:{...Ne.style,opacity:.9},zIndex:5,data:{...Ne.data,focusRole:"ref"}}:oa.downEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-down",style:{...Ne.style,strokeWidth:2.5,opacity:.85},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{}},zIndex:5,data:{...Ne.data,focusRole:"down"}}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0});const ce=lt.length>1?lt:[];if(ce.length===0)return H;const{visitedEdgeIds:we}=Lr(ce,e,t);return H.map(Ne=>we.has(Ne.id)?{...Ne,style:{...Ne.style,stroke:ae.trace,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.trace},zIndex:10}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0})},[e,t,lt,ae,oa]);return D.useEffect(()=>{if(!pn||!Pe)return;const H=setTimeout(()=>{const ce=K.current;if(!ce)return;const we=se.getState().nodes.find(Ot=>Ot.id===Pe);if(!we)return;const Ne=ce.getViewport(),Xe=we.measured?.width??we.width??480,vt=(we.position.x+Xe)*Ne.zoom+Ne.x,wt=window.innerWidth-oe.getState().panelWidth-Wd-24;if(vt>wt){const Ot=(we.position.x+Xe/2)*Ne.zoom+Ne.x;ce.setViewport({...Ne,x:Ne.x-(Ot-wt/2)},{duration:300})}},60);return()=>clearTimeout(H)},[pn,Pe]),l.jsxs("div",{className:"relative w-full h-full","data-searching":Bn||void 0,children:[l.jsxs("div",{className:"relative h-full w-full",onDoubleClick:H=>{H.target.classList.contains("react-flow__pane")&&!Me&&Ct(_e({x:H.clientX,y:H.clientY}))},onDragOver:H=>{(H.dataTransfer.types.includes("application/thoughtdag-content")||H.dataTransfer.types.includes("Files"))&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",!Q&&!Me&&j(!0))},onDrop:H=>{if(Et)return;const ce=H.target;if(!Q&&!Me&&H.dataTransfer.files.length>0){H.preventDefault(),j(!1),ot(H.dataTransfer.files);return}const we=ce.closest?.(".react-flow__node"),Ne=we&&se.getState().nodes.find(wt=>wt.id===we.getAttribute("data-id"))?.data.stepKind==="frame";if(!ce.classList?.contains("react-flow__pane")&&!Ne)return;const Xe=_e({x:H.clientX,y:H.clientY}),vt=H.dataTransfer.getData("application/thoughtdag-content");if(vt==="ask"){H.preventDefault(),Ct(Xe);return}if(vt==="frame"){H.preventDefault(),rt(Xe);return}if(vt==="note"||vt==="file"){H.preventDefault(),ps(vt,Xe);return}if(H.dataTransfer.files.length>0){H.preventDefault();const wt=Ue(H.dataTransfer.files);if(wt.length===0)return;const Ot=ps("file",Xe);Gd(Ot,wt)}},children:[l.jsxs(LB,{onInit:H=>{K.current=H,AM.current=H;const ce=oe.getState().arrivalFocusNodeId;if(ce){oe.getState().setArrivalFocusNodeId(null);const we=se.getState().nodes.find(Ne=>Ne.id===ce);we&&window.setTimeout(()=>{H.setCenter(we.position.x+260,we.position.y+140,{zoom:.9,duration:400})},150)}},nodes:nr,edges:st,onNodesChange:ie,onEdgesChange:Be,onNodeDragStart:Ht,onNodeDrag:Kt,onNodeDragStop:qt,onConnect:Wa,onConnectStart:ia,onConnectEnd:me,onEdgeContextMenu:tr,onNodeContextMenu:zn,nodeTypes:Nue,edgeTypes:Aue,deleteKeyCode:null,fitView:!0,onlyRenderVisibleElements:!0,minZoom:.04,maxZoom:2,defaultEdgeOptions:{type:"smoothstep",animated:!1,style:{stroke:ae.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:ae.accent,width:18,height:18}},snapToGrid:ue==="grid",snapGrid:[22,22],proOptions:{hideAttribution:!0},nodeDragThreshold:5,connectionRadius:40,selectionMode:ru.Partial,selectionOnDrag:!Et,nodesDraggable:!Et,nodesConnectable:!Et,panOnDrag:Et?!0:[1,2],panOnScroll:v,zoomOnScroll:!v,zoomOnPinch:!0,zoomOnDoubleClick:!1,connectionLineStyle:{stroke:ae.accent,strokeDasharray:"8 4",strokeWidth:2},onSelectionChange:Ut,onPaneClick:()=>{d(null),h([]),ha(null)},children:[ue==="grid"?l.jsxs(l.Fragment,{children:[l.jsx(dx,{id:"grid-fine",variant:Rs.Lines,gap:22,color:"var(--canvas-grid-fine)"}),l.jsx(dx,{id:"grid-major",variant:Rs.Lines,gap:110,color:"var(--canvas-grid-major)"})]}):l.jsx(dx,{variant:Rs.Dots,gap:24,size:1,color:"var(--canvas-dot)"}),l.jsx(Iue,{}),l.jsx(Mue,{panelShiftWidth:pn?Nt:0}),l.jsx(wue,{}),l.jsx(YB,{position:"bottom-left"}),e.length>0&&l.jsx(oH,{nodeColor:H=>{const ce=H.data;if(ce.archived)return xe.archived;const we=ce.stepKind;return we==="note"?"#D97706":we==="file"||we==="link"?"#64748B":Array.isArray(ce.condensedFrom)&&ce.condensedFrom.length?"#8B7CF0":ce.isRoot?ae.accent:ce.isBranch?ae.warm:xe.ordinary},maskColor:xe.mask,style:{width:200,height:140},pannable:!0,zoomable:!0,position:"bottom-right"})]}),!Q&&Me&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"text-center pointer-events-auto",children:[l.jsx("p",{className:"text-sm text-ink-muted mb-1 font-medium",children:b("paradigm.emptyTitle")}),l.jsx("p",{className:"text-xs text-ink-faint mb-4 max-w-sm leading-relaxed",children:b("paradigm.emptyHint")}),l.jsxs("div",{className:"flex items-center justify-center gap-2",children:[l.jsxs("button",{onClick:()=>mt("human"),className:"text-sm border-2 border-dashed border-warm/60 text-warm hover:bg-warm/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(qd,{size:15,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"text-sm border-2 border-dashed border-accent/50 text-accent hover:bg-accent/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(Go,{size:15,strokeWidth:1.75})," ",b("paradigm.addPrompt")]})]})]})}),Et&&!Q&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("div",{className:"text-center max-w-[420px] px-6",children:_n?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-3xl mb-3",children:"🔗"}),l.jsx("div",{className:"text-sm font-semibold text-ink mb-1.5",children:b("viewer.loadError")}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:b("viewer.loadErrorHint")})]}):l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted justify-center",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",b("viewer.loading")]})})}),!Q&&!Me&&!Et&&l.jsxs("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none overflow-hidden",children:[l.jsxs("svg",{className:"absolute -left-10 top-[8%] w-[360px] h-[300px] opacity-[0.35] pointer-events-none",viewBox:"0 0 360 300","aria-hidden":!0,children:[l.jsx("path",{d:"M80 40 C80 90 80 90 80 130 M80 170 C80 210 80 210 80 250",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M95 150 C150 150 150 90 205 88",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"80",cy:"30",r:"7",fill:it.line}),l.jsx("circle",{cx:"80",cy:"150",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"80",cy:"262",r:"7",fill:it.line}),l.jsx("circle",{cx:"218",cy:"88",r:"7",fill:it.line})]}),l.jsxs("svg",{className:"absolute right-[-30px] bottom-[10%] w-[320px] h-[280px] opacity-[0.35] pointer-events-none",viewBox:"0 0 320 280","aria-hidden":!0,children:[l.jsx("path",{d:"M240 30 C240 80 240 80 240 120 M240 160 C240 200 240 200 240 240",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M225 140 C170 140 170 210 115 212",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"240",cy:"20",r:"7",fill:it.line}),l.jsx("circle",{cx:"240",cy:"140",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"240",cy:"252",r:"7",fill:it.line}),l.jsx("circle",{cx:"102",cy:"212",r:"7",fill:it.line})]}),l.jsxs("div",{className:"pointer-events-auto w-[560px] animate-fade-in relative",children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsxs("svg",{width:"52",height:"52",viewBox:"0 0 44 44",className:"mx-auto mb-4","aria-hidden":!0,children:[l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.05s"},cx:"22",cy:"7",r:"3.5",fill:it.accent}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.2s"},x1:"22",y1:"11",x2:"22",y2:"19",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.35s"},cx:"22",cy:"22",r:"3.5",fill:"none",stroke:it.accent,strokeWidth:"2.5"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.5s"},x1:"22",y1:"25",x2:"22",y2:"33",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.65s"},cx:"22",cy:"37",r:"3.5",fill:it.accent,opacity:"0.35"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.8s"},x1:"25.5",y1:"23.5",x2:"33",y2:"28.5",stroke:it.warm,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"3 3"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.95s"},cx:"36",cy:"30",r:"3.5",fill:it.warm})]}),l.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-ink mb-2.5",children:"ThoughtDAG"}),l.jsx("p",{className:"text-sm text-ink-muted",children:b("landing.tagline")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1.5 font-medium",children:b("landing.mechanism")})]}),l.jsxs("div",{className:"bg-card border border-line rounded-xl px-5 py-4 shadow-lg transition-all focus-within:border-accent/50 focus-within:shadow-xl",children:[l.jsx("textarea",{value:T,onChange:H=>C(H.target.value),onKeyDown:yt,onPaste:H=>{if(H.clipboardData.getData("text/plain").trim())return;const ce=Array.from(H.clipboardData.items).filter(we=>we.kind==="file").map(we=>we.getAsFile()).filter(Boolean);ce.length&&jt(ce)},placeholder:b("landing.placeholder"),className:"w-full bg-transparent text-ink text-sm leading-relaxed resize-none focus:outline-none placeholder-ink-faint",rows:3,autoFocus:!0}),Y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mt-2 pb-1",children:Y.map(H=>l.jsxs("div",{className:"flex items-center gap-1.5 bg-wash rounded-lg px-2.5 py-1.5 group",children:[H.thumbnailUrl?l.jsx("img",{src:H.thumbnailUrl,className:"w-6 h-6 rounded object-cover",alt:H.name}):l.jsx("span",{className:"text-xs",children:l.jsx(js,{size:16,strokeWidth:1.75})}),l.jsx("span",{className:"text-xs text-ink-muted max-w-[100px] truncate",children:H.name}),H.isExtracting&&l.jsx("span",{className:"text-2xs text-accent",children:l.jsx(nn,{className:"animate-spin",size:12,strokeWidth:1.75})}),H.numPages!=null&&l.jsxs("span",{className:"text-2xs text-ink-faint",children:[H.numPages,"p"]}),l.jsx("button",{onClick:()=>q(ce=>ce.filter(we=>we.id!==H.id)),className:"text-ink-faint hover:text-red-500 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]},H.id))}),z&&l.jsxs("div",{className:"space-y-1 mt-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-xs text-ink-muted font-medium",children:b("landing.roleLabel")}),l.jsx("button",{onClick:()=>{V(!1),S("")},className:"text-xs text-ink-faint hover:text-ink-muted",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),l.jsx("textarea",{value:_,onChange:H=>S(H.target.value),placeholder:b("landing.rolePlaceholder"),className:"w-full text-xs border border-line rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-accent bg-surface resize-none leading-relaxed",rows:2,autoFocus:!0}),l.jsx(vM,{onPick:S})]}),l.jsxs("div",{className:"flex items-center justify-end mt-2 gap-2",children:[l.jsx(T0,{}),l.jsx("button",{onClick:()=>V(!z),title:b("landing.roleTrayTitle"),className:`rounded-full w-8 h-8 flex items-center justify-center transition-colors shrink-0 ${z||_?"text-accent bg-accent/10 hover:bg-accent/20":"text-ink-faint hover:text-ink-muted hover:bg-line"}`,children:l.jsx(hF,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:()=>$.current?.click(),className:"text-ink-faint hover:text-accent hover:bg-wash rounded-xl px-3 py-2 transition-colors text-sm",title:b("landing.attach"),children:l.jsx(Ls,{size:16,strokeWidth:1.75})}),l.jsx("input",{ref:$,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{jt(H.target.files||[]),H.target.value=""}}),l.jsx("button",{onClick:kt,disabled:!T.trim()||Y.some(H=>H.isExtracting),className:"bg-accent hover:bg-accent-strong disabled:opacity-30 disabled:cursor-not-allowed text-white text-sm px-5 py-2 rounded-xl transition-all",children:Y.some(H=>H.isExtracting)?b("landing.extracting"):b("landing.send")})]})]}),l.jsxs("div",{onClick:()=>X.current?.click(),className:`mt-3 border-2 border-dashed rounded-xl px-5 py-3.5 cursor-pointer transition-all text-center bg-card/60 backdrop-blur ${B?"border-accent bg-accent/5 ring-2 ring-accent/20":"border-line hover:border-accent/40 hover:bg-accent/5"}`,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(Bl,{size:15,strokeWidth:1.75,className:"text-accent"})," ",b("landing.docStart")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.docFormats")}),l.jsx("p",{className:"text-2xs text-ink-faint mt-0.5",children:b("landing.docPrivacy")})]}),!!window.desktopSessions&&l.jsxs("button",{onClick:()=>L(!0),className:"w-full mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 hover:border-accent/40 hover:bg-accent/5 transition-all text-center","data-landing-atlas":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(PH,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{children:b("landing.atlasStart")}),l.jsx(IH,{size:13,strokeWidth:1.75,className:"text-accent shrink-0"})]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.atlasDesc")})]}),l.jsx("input",{ref:X,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{ot(H.target.files||[]),H.target.value=""}}),P&&l.jsx(Vv,{onClose:()=>L(!1),onSwitched:()=>{L(!1),Ye()}}),(!De||(De.models?.length??0)===0)&&l.jsxs("div",{className:"mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 text-center","data-quick-connect":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(p0,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"})," ",b("landing.quickTitle")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.quickDesc")}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-center flex-wrap gap-2",children:[Ie==="zh"&&l.jsx("button",{onClick:()=>{oe.getState().setApiKeyPresetHint("zhipu"),oe.getState().setApiKeyModalOpen(!0)},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-zhipu":!0,children:b("landing.quickZhipu")}),l.jsx("button",{onClick:()=>{RM()},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-primary":!0,children:b("landing.quickOpenRouter")}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"text-2xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0",children:b("landing.quickOther")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"mt-2 mx-auto text-2xs text-ink-faint hover:text-accent transition-colors block","data-quick-subs":!0,children:b("landing.quickSubs")})]}),l.jsx("div",{className:"grid grid-cols-3 gap-3 mt-6",children:[{icon:ai,title:"landing.feature1.title",desc:"landing.feature1.desc"},{icon:Qk,title:"landing.feature2.title",desc:"landing.feature2.desc"},{icon:VA,title:"landing.feature3.title",desc:"landing.feature3.desc"}].map(({icon:H,title:ce,desc:we})=>l.jsxs("div",{className:"bg-card/60 backdrop-blur border border-line rounded-xl px-4 py-3.5",children:[l.jsx(H,{size:16,strokeWidth:1.75,className:"text-accent mb-2"}),l.jsx("h3",{className:"text-xs font-semibold text-ink mb-1",children:b(ce)}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:b(we)})]},ce))}),l.jsxs("div",{className:"text-center mt-6 flex items-center justify-center gap-5",children:[l.jsxs("button",{onClick:bt,className:"text-xs text-accent hover:text-accent-strong font-medium transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Qk,{size:14,strokeWidth:1.75})," ",b("landing.loadExample")]}),l.jsxs("button",{onClick:()=>y(!0),className:"text-xs text-ink-muted hover:text-accent transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Vk,{size:14,strokeWidth:1.75})," ",b("landing.howItWorks")]})]})]})]}),!Et&&l.jsx(dce,{onSwitched:Ye}),(Q||Me)&&!Et&&l.jsxs("div",{className:"absolute top-[38%] -translate-y-1/2 left-4 z-10 flex flex-col gap-1.5 bg-card/90 backdrop-blur border border-line rounded-xl p-1.5 shadow-sm",children:[!Me&&l.jsx("button",{onClick:()=>Ct(_e(null)),draggable:!0,onDragStart:H=>{H.dataTransfer.setData("application/thoughtdag-content","ask"),H.dataTransfer.effectAllowed="copy"},title:b("palette.askTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-accent hover:bg-accent/10 transition-colors cursor-grab",children:l.jsx(qd,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("note",_e(ce))),title:b("palette.noteTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-amber-600 hover:bg-amber-500/10 transition-colors",children:l.jsx(oi,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("file",_e(ce))),title:b("palette.fileTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ls,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>rt(_e(ce))),title:b("palette.frameTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ub,{size:17,strokeWidth:1.75})})]}),Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Wd+12:16},"data-top-toolbar":!0,children:[l.jsxs("span",{className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm text-ink-muted text-xs font-medium","data-viewer-badge":!0,children:[l.jsx(f0,{size:14,strokeWidth:1.75})," ",b("viewer.badge")]}),l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(FT,{}),l.jsx("button",{onClick:()=>hy(),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("viewer.downloadJson"),children:l.jsx(Ml,{size:15,strokeWidth:1.75})}),l.jsx("a",{href:"https://github.com/chenxiachan/thoughtdag",target:"_blank",rel:"noreferrer",className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:b("viewer.openApp")})]}),!Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Wd+12:16},"data-top-toolbar":!0,children:[Me&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>mt("human"),className:"bg-card/90 backdrop-blur border border-warm/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-warm/10 transition-colors text-warm text-xs font-medium",children:[l.jsx(qd,{size:14,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"bg-card/90 backdrop-blur border border-accent/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-accent/10 transition-colors text-accent text-xs font-medium",children:[l.jsx(Go,{size:14,strokeWidth:1.75})," ",b("paradigm.addPrompt")]}),l.jsxs("button",{onClick:()=>{Ze()},title:b("paradigm.instantiateTitle"),className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:["▶ ",b("paradigm.instantiate")]})]}),!Me&&l.jsx(mue,{}),!Me&&l.jsx(SM,{}),!Q&&l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("apikey.entryTitle"),"data-apikey-entry":!0,children:l.jsx(p0,{size:15,strokeWidth:1.75})}),mn>0&&!Me&&l.jsxs("button",{onClick:()=>{const{nodes:H,edges:ce}=se.getState(),Ne=Xr(se.getState()).reduce((Xe,vt)=>{const wt=H.map(fn=>fn.id===vt?{...fn,data:{...fn.data,question:"",response:""}}:fn),{layerTokens:Ot}=br(vt,wt,ce),$t=H.find(fn=>fn.id===vt)?.data.question??"";return Xe+Ot.material+Ot.reference+Ot.chain+Nn($t)},0);ri({title:b("replay.confirmTitle"),message:ye(b("replay.confirmMsg"),{n:mn,tok:Ne.toLocaleString()}),confirmLabel:b("replay.confirmBtn")}).then(Xe=>{Xe&&se.getState().replayStale()})},className:"bg-amber-500/10 backdrop-blur border border-amber-500/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-amber-500/20 transition-colors text-amber-600 text-xs font-medium",title:b("replay.chipTitle"),children:[l.jsx(ZF,{size:14,strokeWidth:1.75})," ",mn]}),Q&&Qt.length>0&&l.jsxs("div",{ref:tn,className:"relative",children:[l.jsx("button",{onClick:()=>Yn(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${Zt?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.frames"),children:l.jsx(Ub,{size:15,strokeWidth:1.75})}),Zt&&l.jsx("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[230px] max-h-[320px] overflow-y-auto z-30 animate-fade-in",children:Qt.map(H=>l.jsxs("button",{onClick:()=>{Yn(!1),K.current?.fitBounds({x:H.position.x,y:H.position.y,width:H.width??640,height:H.height??420},{duration:400,padding:.15})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx("span",{className:`w-2.5 h-2.5 rounded-sm shrink-0 ${($d[H.data.frameColor??"gray"]??$d.gray).dot}`}),l.jsx("span",{className:"truncate",children:H.data.question||b("frame.untitled")})]},H.id))})]}),Q&&l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(FT,{}),Q&&!Me&&l.jsx(Lle,{showTrigger:!1,openPing:Jn,onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Ee&&!Et&&l.jsxs("button",{onClick:()=>oe.getState().setCondenseDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-accent/50 rounded-lg h-8 px-2 flex items-center justify-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-accent",title:ye(b("condense.entryBuilding"),{i:String(Fe.current),n:String(Fe.total)}),"data-condense-entry":!0,children:[l.jsx(nn,{size:14,strokeWidth:1.75,className:"animate-spin"}),l.jsxs("span",{className:"text-2xs font-mono",children:[Fe.current,"/",Fe.total]})]}),Wp&&l.jsx("button",{onClick:()=>oe.getState().setBackupDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("backup.dialogTitle"),"data-backup-entry":!0,children:l.jsx(zA,{size:15,strokeWidth:1.75})}),l.jsxs("div",{ref:Hn,className:"relative",children:[l.jsx("button",{onClick:()=>An(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${wn?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.more"),"data-toolbar-more":!0,children:l.jsx(LA,{size:15,strokeWidth:1.75})}),wn&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[220px] z-30 animate-fade-in",children:[Q&&l.jsxs("button",{onClick:()=>{An(!1),E(!w)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b(w?"toolbar.showAnnotations":"toolbar.hideAnnotations"),children:[l.jsx(oi,{size:14,strokeWidth:1.75,className:`shrink-0 ${w?"text-accent":"text-ink-faint"}`})," ",b(w?"toolbar.menuAnnotationsShow":"toolbar.menuAnnotationsHide")]}),l.jsxs("button",{onClick:()=>{An(!1),A(!v)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.wheelPansTitle"),"aria-pressed":v,"data-wheel-pans":!0,children:[l.jsx(RF,{size:14,strokeWidth:1.75,className:`shrink-0 ${v?"text-accent":"text-ink-faint"}`})," ",l.jsx("span",{className:"flex-1",children:b("toolbar.menuWheelPans")}),v&&l.jsx("span",{className:"text-accent",children:"✓"})]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),ri({title:b("confirm.relayoutTitle"),message:b("confirm.relayoutMsg"),confirmLabel:b("toolbar.relayout")}).then(H=>{H&&(x(),setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),50))})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(YF,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.relayout")]}),G>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setHighlightsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("hlov.entryTitle"),"data-hlov-entry":!0,children:[l.jsx(m0,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ye(b("hlov.entry"),{n:G})]}),J>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMaterialsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("matov.entryTitle"),"data-matov-entry":!0,children:[l.jsx(Ls,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ye(b("matov.entry"),{n:J})]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),Q&&!Me&&!Et&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setCondenseDialogOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("condense.entryTitle"),children:[l.jsx(bp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("condense.title"),"…"]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),Pa(H=>H+1)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.diagnose"),"data-menu-diagnose":!0,children:[l.jsx(GA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuDiagnose")]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),(async()=>{const{nodes:H,edges:ce}=se.getState(),{confirmIfSensitive:we}=await ft(async()=>{const{confirmIfSensitive:Xe}=await import("./sensitive-scan-C8VYATus.js");return{confirmIfSensitive:Xe}},[]);if(!await we(H))return;const Ne=await Lq(H,ce);await navigator.clipboard.writeText(Ne).catch(()=>{}),oe.getState().setShareDialogUrl(Ne)})()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-share-link":!0,title:b("viewer.shareTitle"),children:[l.jsx(AU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuShare")]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),Me?hG():hy()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-menu-export":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b(Me?"paradigm.exportParadigm":"switcher.exportBackup")]}),F&&l.jsxs("button",{onClick:()=>{An(!1),xG()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.exportEventsTitle"),children:[l.jsx(js,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.exportEvents")]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("div",{className:"px-3 pt-2 pb-1","data-appearance-lighting":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.lighting")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["light",b("appearance.light")],["dark",b("appearance.dark")],["system",b("appearance.system")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Hi.getState().setLighting(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${pe===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsxs("div",{className:"px-3 pt-1 pb-2","data-appearance-paper":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.paper")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["plain",b("appearance.plain")],["grid",b("appearance.grid")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Hi.getState().setPaper(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${ue===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMemoryManagerOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("memory.entryTitle"),children:[l.jsx(BH,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("memory.managerTitle")]}),l.jsxs("button",{onClick:()=>{An(!1),y(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(Vk,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("landing.howItWorks")]}),xa&&l.jsxs("button",{onClick:()=>{An(!1);const H=Ln?`dsh-thoughtdag@${xa.latest}`:Vy(xa.latest);navigator.clipboard.writeText(H).then(()=>We("success",b(Ln?"plugin.updateCopiedDesktop":"plugin.updateCopied")))},className:"w-full text-left px-3 py-2 text-xs text-accent hover:bg-wash transition-colors flex items-center gap-2.5",title:Ln?ye(b("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${xa.latest}`}):ye(b("plugin.updateHint"),{cmd:Vy(xa.latest)}),"data-plugin-update":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",ye(b("plugin.updateAvailable"),{v:xa.latest})]}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setReleaseNotesOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-open-release-notes":!0,children:[l.jsx(xp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("releaseNotes.entry")]})]})]}),l.jsx("button",{onClick:s,disabled:p<=0,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.undo"),children:l.jsx(XA,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:o,disabled:p>=m.length-1,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.redo"),children:l.jsx(gU,{size:16,strokeWidth:1.75})})]}),ve&&!Et&&l.jsx(Ele,{}),l.jsx(Rle,{open:I,onClose:()=>O(!1),onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Gt&&l.jsx(Tle,{x:Gt.x,y:Gt.y,nodeId:Gt.nodeId,onClose:()=>ha(null)}),l.jsx(Cle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Sue,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Nle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Rt&&l.jsx("div",{className:"fixed z-50 bg-card border border-line rounded-xl shadow-lg py-1 min-w-[120px]",style:{left:Rt.x,top:Rt.y},children:l.jsxs("button",{onClick:()=>na(Rt.edgeId),className:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors flex items-center gap-1.5",children:[l.jsx(Ja,{size:14,strokeWidth:1.75}),b("canvas.deleteEdge")]})})]}),l.jsx(sue,{onFocusSegment:H=>{const ce=K.current,we=se.getState().nodes.filter(fn=>H.includes(fn.id));if(!ce||we.length===0)return;const Ne=we.map(fn=>fn.position.x),Xe=we.map(fn=>fn.position.y),vt=Math.min(...Ne),wt=Math.min(...Xe),Ot=Math.max(...Ne)+520-vt,$t=Math.max(...Xe)+240-wt;ce.fitBounds({x:vt,y:wt,width:Ot+700,height:$t},{duration:350,padding:.15})}}),pn&&l.jsx(yle,{onFocusNode:H=>{const ce=e.find(we=>we.id===H);ce&&ze(ce,{duration:300})}}),l.jsx(Gle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}})]})}function Mue({panelShiftWidth:e}){const t=Y0(),n=St(),a=Vl(),r=se(d=>d.nodes.length),s=se(d=>d.nodes),o=D.useMemo(()=>{let d=null,h="";for(const m of s){if(m.data.stepKind&&m.data.stepKind!=="human"&&m.data.stepKind!=="prompt")continue;const p=[m.data.lastGeneratedAt,m.data.askedAt,m.data.createdAt,...m.data.editedAts??[]].filter(Boolean).sort().pop();p&&p>h&&(h=p,d=m)}return d?{node:d,at:h}:null},[s]);if(Et||t==="work"||r<2)return null;const u=()=>{if(!o)return;oe.getState().setBeaconNodeId(null);const{node:d}=o;a.setCenter(d.position.x+260,d.position.y+110,{zoom:1,duration:1100}),window.setTimeout(()=>{se.getState().setSelectedNodeId(d.id),oe.getState().setPanelOpen(!0),window.setTimeout(()=>{a.setCenter(d.position.x+260+ap(d.id)/2,d.position.y+110,{zoom:1,duration:300})},60)},1150),window.setTimeout(()=>{We("success",n("continue.arrived"),12e3,{label:n("continue.summarize"),run:()=>{CM(d.id)}})},1550)};return l.jsxs("div",{className:"absolute bottom-6 z-10 flex items-center gap-2 -translate-x-1/2 transition-[left] duration-300",style:{left:`calc((100% - ${e}px) / 2)`},"data-map-dock":!0,children:[l.jsxs("button",{onClick:()=>oe.getState().setThoughtMapOpen(!0),"data-tmap-pill":!0,className:"flex items-center gap-2 bg-card/95 backdrop-blur border border-line-strong rounded-full px-5 py-2.5 text-sm text-ink shadow-lg hover:border-accent/40 hover:text-accent transition-colors",children:[l.jsx(d2,{size:16,strokeWidth:1.75})," ",n("tmap.export")]}),o&&l.jsxs("button",{onClick:u,onMouseEnter:()=>oe.getState().setBeaconNodeId(o.node.id),onMouseLeave:()=>oe.getState().setBeaconNodeId(null),title:n("continue.buttonTitle"),"data-continue-pill":!0,className:"flex items-center gap-2 bg-accent text-white rounded-full px-5 py-2.5 text-sm shadow-lg hover:bg-accent-strong transition-colors",children:[l.jsx(yU,{size:16,strokeWidth:1.75})," ",n("continue.button")]})]})}function Iue(){const e=Y0(),t=ln(n=>n.transform[2]);return D.useEffect(()=>{document.querySelector(".react-flow")?.setAttribute("data-zoom-tier",e)},[e]),D.useEffect(()=>{document.querySelector(".react-flow")?.style.setProperty("--tdag-zoom",String(t))},[t]),null}Hoe();const Kv="/thoughtdag/api";window.desktopSessions||A8(Kv);ft(()=>Promise.resolve().then(()=>gue),void 0).then(e=>e.bootPluginUpdateCheck(Kv));if(!window.desktopAgents){const e=Kv;ft(()=>import("./http-bridge-DOGmFOH2.js"),[]).then(async t=>{await t.installAgentsHttpBridge(e)&&window.dispatchEvent(new CustomEvent("td:agents-ready"))})}Et?zq():(L7(),navigator.storage?.persist&&navigator.storage.persist(),ft(()=>Promise.resolve().then(()=>Yce),void 0).then(e=>e.bootAutoBackup()));ft(()=>import("./update-check-KJ2ZKsng.js"),[]).then(e=>e.bootUpdateCheck());window.addEventListener("hashchange",()=>{window.location.hash.startsWith("#view=")!==Et&&window.location.reload()});aD.createRoot(document.getElementById("root")).render(l.jsx(D.StrictMode,{children:l.jsx(Cue,{})}));export{D0 as A,xr as B,XV as C,Rue as D,W7 as E,Sa as F,R$ as I,ft as _,Te as a,se as b,sn as c,qi as d,P7 as e,ye as f,Ui as g,jr as h,Et as i,vu as j,Np as k,uy as l,tG as m,Tn as n,JV as o,ws as p,F7 as q,eG as r,Xo as s,We as t,oe as u,ri as v,jue as w,Xr as x,Due as y,Oue as z};
|
|
914
|
+
Write the JOURNEY of this thinking as one flowing paragraph a reader absorbs in twenty seconds: where it started, what got ruled out, where it turned, where it landed, what remains open. Only the turns that mattered — do not enumerate every step. Hard limit: 250 characters for CJK languages, 500 characters otherwise. Write in ${n==="zh"?"Chinese":"English"} (the reader's interface language), even if the takeaway lines mix languages. Never use dash characters (—, –, -); use commas, colons or full stops. Output only the paragraph.`}])).trim(),fp:a,at:new Date().toISOString(),lang:n};return Gy.set(`${n}:${a}`,x),x}function Sue({onLocate:e}){const t=oe(B=>B.timelineOverviewOpen),n=oe(B=>B.setTimelineOverviewOpen),a=se(B=>B.nodes),r=St(),s=JA(),o=Da(B=>B.lang),u=bV(),d=D.useMemo(()=>Yv(a,0,{ladders:!0}),[a,u]),[h,m]=D.useState(1),p=Math.round(h),x={paddingTop:4+h*5,paddingBottom:4+h*5},b=D.useRef(null),y=D.useRef(null),w=D.useRef(null),E=B=>{const j=b.current;if(j){const $=j.getBoundingClientRect().top,X=[...j.querySelectorAll("[data-entry]")];let Q=y.current?X.find(F=>F.dataset.entry===y.current)??null:null;if(!Q){const F=$+j.clientHeight/2;Q=X.reduce((G,J)=>{const K=J.getBoundingClientRect(),ee=Math.abs((K.top+K.bottom)/2-F);return!G||ee<Math.abs((G.getBoundingClientRect().top+G.getBoundingClientRect().bottom)/2-F)?J:G},null)}w.current=Q?{id:Q.dataset.entry,y:Q.getBoundingClientRect().top-$}:null}m(B)};D.useLayoutEffect(()=>{const B=b.current,j=w.current;if(!B||!j)return;const $=B.querySelector(`[data-entry="${j.id}"]`);if(!$)return;const X=$.getBoundingClientRect().top-B.getBoundingClientRect().top;B.scrollTop+=X-j.y},[h]);const v=13+h*.9,A=D.useMemo(()=>$M(a),[a]),[T,C]=D.useState(null),[I,O]=D.useState(!1),[_,S]=D.useState(!1),z=kue(A,o)??T,V=!!z&&(z.fp!==A||z.lang!==o),P=()=>{O(!0),S(!1);const{nodes:B,edges:j}=se.getState();Eue(B,j,o).then(C).catch(()=>S(!0)).finally(()=>O(!1))};if(!t)return null;const L=()=>n(!1),Y=B=>B?B.slice(0,10):"",q=B=>B?new Date(B).toLocaleTimeString(s,{hour:"2-digit",minute:"2-digit"}):"—";return ur.createPortal(l.jsx("div",{className:"fixed inset-0 z-[60] bg-ink/30 backdrop-blur-sm flex items-center justify-center p-6",onClick:L,children:l.jsxs("div",{className:"bg-card rounded-2xl shadow-2xl border border-line w-[640px] h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 px-5 py-3 border-b border-line shrink-0",children:[l.jsx(xp,{size:15,strokeWidth:1.75,className:"text-accent"}),l.jsx("span",{className:"text-sm font-semibold text-ink",children:r("tlov.title")}),l.jsx("span",{className:"text-2xs text-ink-faint",children:ye(r("tlov.count"),{n:d.length})}),l.jsxs("label",{className:"flex items-center gap-2 ml-3 text-2xs text-ink-faint",title:r("tlov.detailTitle"),children:[l.jsx("span",{children:r("tlov.detail")}),l.jsx("input",{type:"range",min:0,max:3,step:.01,value:h,onChange:B=>E(Number(B.target.value)),className:"w-28 accent-accent","data-tlov-detail":!0}),l.jsx("span",{className:"text-ink-muted w-8",children:r(`ladder.level${p}`)})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{L(),oe.getState().setThoughtMapOpen(!0)},disabled:d.length===0,"data-tmap-from-timeline":!0,className:"flex items-center gap-1.5 text-2xs text-ink-muted hover:text-accent hover:bg-accent/10 rounded-full px-2.5 py-1 transition-colors disabled:opacity-50",children:[l.jsx(d2,{size:13,strokeWidth:1.75}),r("tmap.export")]}),l.jsx("button",{onClick:L,className:"text-ink-faint hover:text-ink w-7 h-7 rounded-lg hover:bg-wash flex items-center justify-center transition-colors",children:l.jsx(cn,{size:15,strokeWidth:1.75})})]}),l.jsxs("div",{className:"px-5 pt-3 shrink-0","data-gedankengang":!0,children:[!z&&!I&&l.jsxs("button",{onClick:P,className:"flex items-center gap-1.5 text-2xs text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-3 py-1.5 transition-colors",children:[l.jsx(Hl,{size:12,strokeWidth:1.75}),r("tlov.gedankenGenerate")]}),I&&l.jsx("p",{className:"text-2xs text-ink-faint italic py-1.5",children:r("tlov.gedankenLoading")}),_&&!I&&l.jsx("p",{className:"text-2xs text-red-500 py-1",children:r("tlov.gedankenFailed")}),z&&!I&&l.jsxs("div",{className:`rounded-xl bg-wash px-4 py-3 ${V?"opacity-60":""}`,children:[l.jsx("p",{className:"text-sm text-ink leading-relaxed",children:z.text}),l.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[l.jsx("span",{className:"text-2xs text-ink-faint",children:V?r("tlov.gedankenStale"):new Date(z.at).toLocaleString(s)}),V&&l.jsx("button",{onClick:P,className:"text-2xs text-accent hover:underline",children:r("tlov.gedankenRedo")})]})]})]}),l.jsxs("div",{ref:b,className:"flex-1 min-h-0 overflow-y-auto px-5 py-3","data-timeline-overview":!0,children:[d.length===0&&l.jsx("p",{className:"text-xs text-ink-faint italic py-2",children:r("tlov.empty")}),d.map((B,j)=>{const $=j>0?Y(d[j-1].createdAt):void 0,X=Y(B.createdAt),Q=j===0||X!==$;return l.jsxs("div",{children:[Q&&l.jsx("div",{className:"sticky top-0 bg-card text-2xs text-ink-faint font-medium pt-3 pb-1 first:pt-0",children:X||r("tlov.undated")}),l.jsxs("div",{className:"group flex items-start gap-2.5 border-b border-line/50 last:border-0",style:x,"data-entry":B.id,onMouseEnter:()=>{y.current=B.id},onMouseLeave:()=>{y.current===B.id&&(y.current=null)},children:[l.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:B.color,opacity:B.archived?.35:1}}),l.jsx("span",{className:"text-2xs font-mono text-ink-faint shrink-0 w-11",children:q(B.createdAt)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[B.ladder?l.jsx("div",{className:B.archived?"opacity-50 line-through":"",children:l.jsx(hM,{ladder:B.ladder,level:p,fontSize:v,weight:B.badged?"font-semibold":"font-medium",className:"whitespace-pre-wrap break-words"})}):l.jsx("p",{className:`leading-snug whitespace-pre-wrap break-words ${B.archived?"text-ink-faint line-through":B.badged?"text-ink":"text-ink-muted"}`,style:{fontSize:v,transition:"font-size 160ms ease-out"},children:p===0?B.topic||B.label||"…":l.jsxs(l.Fragment,{children:[B.topic&&l.jsxs("span",{className:"font-medium text-accent",children:[B.topic," · "]}),B.label||"…"]})}),B.modifiedAt&&B.modifiedAt!==B.createdAt&&l.jsxs("p",{className:"text-2xs text-ink-faint",children:[r("timeline.modified")," ",new Date(B.modifiedAt).toLocaleString(s)]})]}),l.jsx("button",{className:"shrink-0 text-2xs font-mono text-accent bg-accent/10 hover:bg-accent/20 rounded-full px-1.5 py-0.5 transition-colors opacity-0 group-hover:opacity-100",onClick:()=>{L(),e(B.id)},title:r("hlov.locateTitle"),children:r("tlov.locate")})]})]},B.id)})]})]})}),document.body)}const Tue=D.memo(function(t){const n=sn(a=>a.projects.find(r=>r.id===a.activeId)?.kind==="paradigm");return t.data?.stepKind==="frame"?l.jsx(qoe,{...t}):Rm(t.data?.stepKind)?l.jsx(Uoe,{...t}):n?l.jsx(zoe,{...t}):l.jsx(joe,{...t})}),Nue={thought:Tue},Aue={smoothstep:D.memo(Voe)};function Cue(){const[e,t]=D.useState(Et||se.persist.hasHydrated());return D.useEffect(()=>se.persist.onFinishHydration(()=>t(!0)),[]),D.useEffect(()=>{if(!e||Et)return;let n;const a=()=>{clearTimeout(n),n=setTimeout(()=>{gce()},800)},r=se.subscribe((s,o)=>{s.nodes!==o.nodes&&a()});return a(),()=>{r(),clearTimeout(n)}},[e]),D.useEffect(()=>{oe.getState().condenseRun.status==="building"&&oe.getState().setCondenseRun({status:"idle",current:0,total:0,streaming:""})},[]),D.useEffect(()=>{if(Et)return;const n=setTimeout(()=>{xce()},6e3);return()=>clearTimeout(n)},[]),D.useEffect(()=>{if(!e||Et||localStorage.getItem("thoughtdag.tutorialDone")||se.getState().nodes.length>0)return;const n=setTimeout(()=>oe.getState().setTutorialOpen(!0),900);return()=>clearTimeout(n)},[e]),D.useEffect(()=>{kce()},[]),D.useEffect(()=>{Et||(ft(()=>import("./session-handoff-BPugrCrq.js"),[]).then(n=>n.consumeSessionHandoff()),ft(()=>Promise.resolve().then(()=>Y8),void 0).then(n=>n.startLiveMirror()),ft(()=>import("./canvas-record-BHE3oU8V.js"),[]).then(n=>n.startCanvasRecord()),ft(()=>import("./canonical-wWV9jbzN.js"),[]).then(n=>n.unsubscribeOrphanedSessions()))},[]),D.useEffect(()=>{Et||wce().then(n=>{n&&(n.status==="minted"?(We("success",Te("provider.oauthMinted")),jM(n.key)):We("error",ye(Te("provider.oauthFailed"),{error:n.error})))})},[]),l.jsxs(l.Fragment,{children:[e&&l.jsx(_ue,{}),l.jsx(Nce,{}),l.jsx(hue,{}),l.jsx(Cce,{}),l.jsx(Ice,{}),l.jsx(Oce,{}),l.jsx(jce,{}),l.jsx(Lce,{}),l.jsx(Pce,{}),l.jsx(qce,{}),l.jsx(Kce,{}),l.jsx(Ece,{}),l.jsx(oue,{}),l.jsx(due,{}),l.jsx(fue,{})]})}function _ue(){const{nodes:e,edges:t,setNodes:n,setEdges:a,addQuestion:r,undo:s,redo:o,addCrossLink:u,setSelectedNodeId:d,setSelectedNodeIds:h,history:m,historyIndex:p,relayout:x}=se(),b=St(),y=oe(H=>H.setTutorialOpen),w=oe(H=>H.annotationsHidden),E=oe(H=>H.setAnnotationsHidden),v=oe(H=>H.wheelPans),A=oe(H=>H.setWheelPans),[T,C]=D.useState(""),[I,O]=D.useState(!1),[_,S]=D.useState(""),[z,V]=D.useState(!1),[P,L]=D.useState(!1),[Y,q]=D.useState([]),[B,j]=D.useState(!1),$=D.useRef(null),X=D.useRef(null),Q=e.length>0,F=se(H=>H.events.length>0),G=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.highlights?.length??0),0)),J=se(H=>H.nodes.reduce((ce,we)=>ce+(we.data.attachments?.length??0)+(["note","link"].includes(we.data.stepKind??"")?1:0),0)),K=D.useRef(null),ee=oe(H=>H.arrivalFocusNodeId);D.useEffect(()=>{if(!ee)return;const H=se.getState().nodes.find(ce=>ce.id===ee);H&&(oe.getState().setArrivalFocusNodeId(null),window.setTimeout(()=>{K.current?.setCenter(H.position.x+260,H.position.y+140,{zoom:.9,duration:400})},150))},[ee]);const ue=Hi(H=>H.paper),pe=Hi(H=>H.lighting),be=Hi(H=>H.resolved),ae=D.useMemo(()=>Foe(),[be]),xe=D.useMemo(()=>{const H=getComputedStyle(document.documentElement),ce=(H.getPropertyValue("--color-surface").trim()||"#FAF9F7").replace("#",""),[we,Ne,Xe]=[0,2,4].map(vt=>parseInt(ce.slice(vt,vt+2),16));return{mask:`rgba(${we},${Ne},${Xe},0.7)`,archived:H.getPropertyValue("--color-wash").trim()||"#EFEDE9",ordinary:be==="dark"?"#6E6759":"#B9B3AB"}},[be]),Ce=D.useRef(e.length),ze=D.useCallback((H,ce={})=>{const we=K.current;if(!we)return;const Ne=ce.zoom??we.getZoom();we.setCenter(H.position.x+(ce.offX??260)+ap(H.id)/(2*Ne),H.position.y+110,{zoom:Ne,duration:ce.duration??350})},[]),Ie=Da(H=>H.lang),Fe=oe(H=>H.condenseRun),Ee=Fe.status==="building",Me=sn(H=>H.projects.find(ce=>ce.id===H.activeId)?.kind==="paradigm"),De=Yl(),bt=D.useCallback(()=>{const{nodes:H,edges:ce}=pce(Ie),we=se.getState();we.setNodes([...we.nodes,...H.filter(Ne=>!we.nodes.some(Xe=>Xe.id===Ne.id))]),we.setEdges([...we.edges,...ce.filter(Ne=>!we.edges.some(Xe=>Xe.id===Ne.id))]),we.pushHistory(),setTimeout(()=>{const Ne=K.current;Ne&&(Ne.fitView({duration:500,padding:.1}),setTimeout(()=>{if(Ne.getViewport().zoom<.34){const Xe=[...se.getState().nodes].sort((vt,wt)=>(vt.data.createdAt??"").localeCompare(wt.data.createdAt??""))[0];Xe&&Ne.setCenter(Xe.position.x+300,Xe.position.y+240,{zoom:.6,duration:550})}},680))},100),localStorage.getItem("thoughtdag.tutorialDone")||y(!0)},[Ie,y]),mt=D.useCallback(H=>{const ce=se.getState(),we=ce.nodes[ce.nodes.length-1],Ne=we?{x:we.position.x,y:we.position.y+340}:{x:120,y:80},Xe=Tn();ce.setNodes([...ce.nodes,{id:Xe,type:"thought",position:Ne,dragHandle:".drag-handle",data:{question:"",instruction:"",stepKind:H,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:ce.nodes.length===0,isBranch:!1}}]),ce.pushHistory()},[]),Ye=D.useCallback(()=>{Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:300,padding:.2}),50)},[]);D.useEffect(()=>{const H=()=>Ye();return window.addEventListener("td:project-switched",H),()=>window.removeEventListener("td:project-switched",H)},[Ye]);const at=D.useRef(null),rt=D.useCallback(H=>{const ce=se.getState(),we=Tn();ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,width:640,height:420,zIndex:-1,dragHandle:".drag-handle",data:{question:"",stepKind:"frame",frameCarry:!1,response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1}}]),ce.pushHistory()},[]),Ue=D.useCallback(H=>{const ce=[];for(const we of Array.from(H)){const Ne=we.name.split(".").pop()?.toLowerCase()??"";we.type.startsWith("image/")||we.type==="application/pdf"||we.type.startsWith("text/")||["pdf","docx","txt","md","csv","json","yaml","yml","toml","js","ts","tsx","jsx","py","sh","c","cpp","h","java","rs","go","rb","swift","css","html","xml","sql","tex","bib"].includes(Ne)?ce.push(we):We("info",ye(Te("toast.unsupportedFile"),{name:we.name}))}return ce},[]),Ct=D.useCallback(H=>{const ce=se.getState(),we=Tn();return ce.setNodes([...ce.nodes,{id:we,type:"thought",position:H,dragHandle:".drag-handle",data:{question:"",response:"",responses:[],responseIndex:-1,isCollapsed:!1,isEditing:!1,isEditingResponse:!1,isLoading:!1,tokenCount:0,highlights:[],highlightMode:"tag",attachments:[],excludedAttachmentIds:[],includedAttachmentIds:[],roleMode:"inherit",isRoot:!1,isBranch:!1,webSearch:oe.getState().webSearchEnabled,scholarSearch:oe.getState().scholarSearchEnabled}}]),ce.pushHistory(),we},[]),ot=D.useCallback(H=>{const ce=Ue(H);if(ce.length===0)return;let we=null;ce.forEach((Ne,Xe)=>{const vt=ps("file",{x:120+Xe%3*480,y:120+Math.floor(Xe/3)*620});Gd(vt,[Ne]),!we&&!Ne.type.startsWith("image/")&&(we=vt)}),we&&oe.getState().setReaderNodeId(we),setTimeout(()=>K.current?.fitView({duration:400,padding:.2}),120)},[Ue]),It=D.useCallback((H,ce)=>{const we=H.clientX,Ne=H.clientY,Xe=H.currentTarget;let vt=null;const wt=$t=>{!vt&&Math.hypot($t.clientX-we,$t.clientY-Ne)>6&&(vt=document.createElement("div"),vt.innerHTML=Xe.innerHTML,vt.style.cssText="position:fixed;z-index:300;pointer-events:none;width:36px;height:36px;display:flex;align-items:center;justify-content:center;background:var(--color-card);border:1px solid var(--color-accent);border-radius:10px;box-shadow:0 4px 14px rgba(0,0,0,.18);opacity:.92;",document.body.appendChild(vt)),vt&&(vt.style.left=`${$t.clientX-18}px`,vt.style.top=`${$t.clientY-18}px`)},Ot=$t=>{window.removeEventListener("pointermove",wt),window.removeEventListener("pointerup",Ot);const fn=!!vt;vt?.remove(),ce(fn?{x:$t.clientX,y:$t.clientY}:null)};window.addEventListener("pointermove",wt),window.addEventListener("pointerup",Ot)},[]),_e=D.useCallback(H=>{const ce=K.current?.screenToFlowPosition(H??{x:window.innerWidth/2,y:window.innerHeight/2})??{x:140,y:140};return{x:ce.x-200,y:ce.y-60}},[]);D.useEffect(()=>{const H=we=>{at.current={x:we.clientX,y:we.clientY}},ce=we=>{if(Et)return;const Ne=we.target;if(Ne&&(Ne.tagName==="INPUT"||Ne.tagName==="TEXTAREA"||Ne.isContentEditable))return;const Xe=sn.getState(),vt=Xe.projects.find(Kn=>Kn.id===Xe.activeId)?.kind==="paradigm";if(se.getState().nodes.length===0&&!vt)return;const wt=we.clipboardData;if(!wt)return;const Ot=_e(at.current),$t=wt.getData("text/plain").trim(),fn=Array.from(wt.files),Ga=fn.some(Kn=>!Kn.type.startsWith("image/"));if(fn.length>0&&(Ga||!$t)){we.preventDefault();const Kn=ps("file",Ot);Gd(Kn,fn);return}if($t)if(we.preventDefault(),/^https?:\/\/\S+$/.test($t)){const Kn=ps("link",Ot,{linkUrl:$t});W8(Kn,$t)}else ps("note",Ot,{question:gW($t)})};return window.addEventListener("mousemove",H),window.addEventListener("paste",ce),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("paste",ce)}},[_e]);const Ze=D.useCallback(async()=>{const H=se.getState();if(H.nodes.length===0)return;const{nodes:ce,edges:we}=dG(H.nodes,H.edges),Ne=sn.getState(),Xe=Ne.projects.find(wt=>wt.id===Ne.activeId)?.name??"Paradigm",vt=crypto.randomUUID();await jr(ws(vt),JSON.stringify({state:{nodes:ce,edges:we},version:1})),await vu(vt,`▶ ${Xe}`,"chat"),await j7(vt,Xe),Ce.current=se.getState().nodes.length,setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),150)},[]);D.useEffect(()=>{e.length===0&&!Me&&!localStorage.getItem("thoughtdag.seeded")&&localStorage.setItem("thoughtdag.seeded","yes")},[]),D.useEffect(()=>{if(e.length>Ce.current&&K.current){const H=e[e.length-1];H&&setTimeout(()=>ze(H,{zoom:1,duration:400,offX:220}),100)}Ce.current=e.length},[e,ze]);const ie=D.useCallback(H=>{const ce=se.getState().nodes;n(rA(H,ce))},[n]),Be=D.useCallback(H=>a(sA(H,se.getState().edges)),[a]),Je=D.useRef(null),Ht=D.useCallback((H,ce)=>{if(ce.data.stepKind!=="frame"||ce.data.frameCarry===!1)return;const we=se.getState(),Ne=we.nodes.find(vt=>vt.id===ce.id);if(!Ne)return;const Xe=N8(Ne,we.nodes).filter(vt=>!vt.selected).map(vt=>({id:vt.id,start:vt.position}));Xe.length!==0&&(Je.current={frameId:Ne.id,start:Ne.position,members:Xe})},[]),Kt=D.useCallback((H,ce)=>{const we=Je.current;if(!we||ce.id!==we.frameId)return;const Ne=ce.position.x-we.start.x,Xe=ce.position.y-we.start.y,vt=new Map(we.members.map(wt=>[wt.id,{x:wt.start.x+Ne,y:wt.start.y+Xe}]));se.setState(wt=>({nodes:wt.nodes.map(Ot=>{const $t=vt.get(Ot.id);return $t?{...Ot,position:$t}:Ot})}))},[]),qt=D.useCallback(()=>{Je.current=null},[]),[Rt,en]=D.useState(null),[Gt,ha]=D.useState(null),zn=D.useCallback((H,ce)=>{Et||window.getSelection()?.toString()||(H.preventDefault(),ha({x:H.clientX,y:H.clientY,nodeId:ce.id}))},[]),tr=D.useCallback((H,ce)=>{H.preventDefault(),en({x:H.clientX,y:H.clientY,edgeId:ce.id})},[]);D.useEffect(()=>{if(!Rt)return;const H=()=>en(null);return window.addEventListener("click",H),()=>window.removeEventListener("click",H)},[Rt]);const La=se(H=>H.deleteEdges),na=D.useCallback(H=>{La([H]),en(null)},[La]),Wa=D.useCallback(H=>{H.source&&H.target&&u(H.source,H.target)},[u]),ia=D.useCallback(()=>{window.getSelection()?.removeAllRanges(),document.body.classList.add("tdag-connecting")},[]),me=D.useCallback((H,ce)=>{if(document.body.classList.remove("tdag-connecting"),Me||ce.isValid||ce.fromHandle?.type!=="source"||!ce.fromNode)return;const we=ce.fromNode.id,Ne=H.target?.closest?.(".react-flow__node");if(Ne){const fn=Ne.getAttribute("data-id");if(fn&&fn!==we){const Ga=se.getState().nodes.find(Hr=>Hr.id===fn),Kn=Ga?.data.stepKind??"";Ga&&!["note","file","link","frame"].includes(Kn)&&se.getState().addCrossLink(we,fn)}return}const{clientX:Xe,clientY:vt}="changedTouches"in H?H.changedTouches[0]:H,wt=_e({x:Xe,y:vt}),Ot=se.getState();if(Ot.nodes.find(fn=>fn.id===we)?.data.stepKind==="frame")return;const $t=Ct(wt);Ot.setEdges([...se.getState().edges,{id:`edge-${we}-${$t}`,source:we,target:$t,sourceHandle:"continue",targetHandle:"top",type:"smoothstep",style:{stroke:it.accent,strokeWidth:2},animated:!1,markerEnd:{type:"arrowclosed",color:it.accent,width:18,height:18},data:{}}]),se.getState().pushHistory()},[Me,_e,Ct]),Pe=se(H=>H.selectedNodeId),lt=se(H=>H.selectedNodeIds),zt=oe(H=>H.panelOpen),_n=oe(H=>H.viewerLoadError),mn=se(H=>Xr(H).length),Nt=oe(H=>H.panelWidth),pt=e.find(H=>H.id===Pe),Mt=pt?.data.stepKind,Mn=Rm(Mt)||Mt==="frame",pn=zt&&!!pt&&!Me&&!Mn;D.useEffect(()=>{Pe&&!pt&&se.getState().setSelectedNodeId(null)},[Pe,pt]);const ve=lt.length>1,tt=se(H=>H.batchDelete);D.useEffect(()=>{const H=ce=>{if(!oe.getState().confirmRequest&&!(Et&&!((ce.metaKey||ce.ctrlKey)&&ce.key==="f"))){if((ce.metaKey||ce.ctrlKey)&&ce.key==="z"&&(ce.shiftKey?(ce.preventDefault(),o()):(ce.preventDefault(),s())),(ce.metaKey||ce.ctrlKey)&&ce.key==="f"){ce.preventDefault(),O(!0);return}{const we=ce.target;if(!(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)&&Pe&&!Me&&!ce.metaKey&&!ce.ctrlKey&&!ce.altKey){const{nodes:Xe,edges:vt}=se.getState();if(ce.key===" "){ce.preventDefault(),se.getState().toggleCollapse(Pe);return}if(ce.key==="r"||ce.key==="R"){ce.preventDefault(),se.getState().rerunNode(Pe,{});return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(ce.key)){const wt=vt.filter($t=>!$t.data?.isCrossLink);let Ot;if(ce.key==="ArrowUp")Ot=wt.find($t=>$t.target===Pe)?.source;else if(ce.key==="ArrowDown")Ot=wt.find($t=>$t.source===Pe)?.target;else{const $t=wt.find(Kn=>Kn.target===Pe),fn=$t?wt.filter(Kn=>Kn.source===$t.source).map(Kn=>Kn.target):Xe.filter(Kn=>!wt.some(Hr=>Hr.target===Kn.id)).map(Kn=>Kn.id),Ga=fn.indexOf(Pe);Ga!==-1&&fn.length>1&&(Ot=fn[(Ga+(ce.key==="ArrowRight"?1:fn.length-1))%fn.length])}if(Ot){ce.preventDefault(),d(Ot);const $t=Xe.find(fn=>fn.id===Ot);$t&&ze($t,{zoom:1,duration:300})}return}}}if(ce.key==="Escape"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;lt.length>1?h([]):Pe&&d(null);return}if(ce.key==="Delete"||ce.key==="Backspace"){const we=ce.target;if(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)return;if(lt.length>1)ce.preventDefault(),ri({title:Te("confirm.deleteNodesTitle"),message:ye(Te("confirm.deleteNodes"),{n:lt.length}),confirmLabel:Te("common.delete"),danger:!0}).then(Ne=>{Ne&&tt(lt)});else{const Ne=t.filter(Xe=>Xe.selected).map(Xe=>Xe.id);Ne.length>0&&(ce.preventDefault(),La(Ne))}}}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[s,o,Pe,lt,d,h,tt,t,La,Me,ze]);const kt=()=>{T.trim()&&(r(T.trim(),{rolePrompt:_.trim()||void 0,initialAttachments:Y.length>0?Y:void 0}),C(""),S(""),V(!1),q([]))},jt=async H=>{for(const ce of Array.from(H))await V0(ce,{add:we=>q(Ne=>[...Ne,we]),update:(we,Ne)=>q(Xe=>Xe.map(vt=>vt.id===we?{...vt,...Ne}:vt))})},yt=H=>{H.key==="Enter"&&!H.shiftKey&&!lr(H)&&(H.preventDefault(),kt())},Ut=D.useCallback(({nodes:H})=>{const ce=H.map(we=>we.id);ce.length>1?h(ce):ce.length===1&&d(ce[0])},[d,h]),Qt=D.useMemo(()=>e.filter(H=>H.data.stepKind==="frame"),[e]),[Zt,Yn]=D.useState(!1),tn=D.useRef(null);D.useEffect(()=>{if(!Zt)return;const H=ce=>{tn.current?.contains(ce.target)||Yn(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[Zt]);const[wn,An]=D.useState(!1),xa=oe(H=>H.pluginUpdate),Ln=oe(H=>!!H.harnessHost?.desktop),[Jn,Pa]=D.useState(0),Bn=oe(H=>H.searchHitIds!==null),Hn=D.useRef(null);D.useEffect(()=>{if(!wn)return;const H=ce=>{Hn.current?.contains(ce.target)||An(!1)};return window.addEventListener("mousedown",H),()=>window.removeEventListener("mousedown",H)},[wn]);const Va=oe(H=>H.searchHitIds),oa=D.useMemo(()=>{if(!Pe||lt.length>1||!e.some(wt=>wt.id===Pe))return null;const H=vp(Pe,e,t),ce=new Set;for(const wt of H.mainline)wt.id!==Pe&&ce.add(wt.id);for(const wt of H.materials)ce.add(wt.id);for(const wt of H.references)ce.add(wt.source.id);const we=t.filter(wt=>!wt.data?.isCrossLink),Ne=Lr(Pe,e,we).visitedEdgeIds,Xe=new Set(H.references.map(wt=>wt.edge.id)),vt=we.filter(wt=>wt.source===Pe);return{ctx:ce,down:new Set(vt.map(wt=>wt.target)),pathEdgeIds:Ne,refEdgeIds:Xe,downEdgeIds:new Set(vt.map(wt=>wt.id))}},[Pe,lt,e,t]),nr=D.useMemo(()=>{const H=e.filter(Ne=>Ne.data.stepKind==="frame").map((Ne,Xe)=>({id:Ne.id,order:Xe,area:(Ne.measured?.width??Ne.width??640)*(Ne.measured?.height??Ne.height??420)})).sort((Ne,Xe)=>Xe.area-Ne.area||Ne.order-Xe.order),ce=new Map(H.map((Ne,Xe)=>[Ne.id,Xe-H.length]));let we=e.map(Ne=>Ne.data.stepKind==="frame"?{...Ne,zIndex:ce.get(Ne.id)??-1}:Ne);return w&&(we=we.map(Ne=>{const Xe=Ne.data.stepKind,vt=Rm(Xe)&&!t.some(wt=>wt.source===Ne.id||wt.target===Ne.id);return Xe==="frame"||vt?{...Ne,hidden:!0}:Ne})),Va!==null&&(we=we.map(Ne=>Va.has(Ne.id)||Ne.data.stepKind==="frame"?{...Ne,className:"search-hit"}:Ne.className==="search-hit"?{...Ne,className:void 0}:Ne)),oa&&(we=we.map(Ne=>{const Xe=Ne.id===Pe?"target":oa.ctx.has(Ne.id)?"ctx":oa.down.has(Ne.id)?"down":Ne.data.stepKind==="frame"?void 0:"dim";return Xe?{...Ne,className:[Ne.className,`focus-${Xe}`].filter(Boolean).join(" "),...Xe!=="dim"?{data:{...Ne.data,focusRole:Xe}}:{}}:Ne})),we},[e,t,w,Va,oa,Pe]),st=D.useMemo(()=>{const H=t.map(Ne=>{const Xe=Ne.data?.isBranchFromSelection?{...Ne,animated:!1,style:{...Ne.style,strokeDasharray:void 0}}:Ne,vt=typeof Xe.style?.stroke=="string"?uT[Xe.style.stroke.toUpperCase()]:void 0,wt=Xe.markerEnd&&typeof Xe.markerEnd=="object"?Xe.markerEnd:void 0,Ot=typeof wt?.color=="string"?uT[wt.color.toUpperCase()]:void 0;return!vt&&!Ot?Xe:{...Xe,...vt?{style:{...Xe.style,stroke:ae[vt]}}:{},...Ot&&wt?{markerEnd:{...wt,color:ae[Ot]}}:{}}});if(oa)return H.map(Ne=>oa.pathEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-path",style:{...Ne.style,stroke:ae.accent,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.accent},zIndex:10,data:{...Ne.data,focusRole:"path"}}:oa.refEdgeIds.has(Ne.id)?{...Ne,style:{...Ne.style,opacity:.9},zIndex:5,data:{...Ne.data,focusRole:"ref"}}:oa.downEdgeIds.has(Ne.id)?{...Ne,className:"focus-e-down",style:{...Ne.style,strokeWidth:2.5,opacity:.85},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{}},zIndex:5,data:{...Ne.data,focusRole:"down"}}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0});const ce=lt.length>1?lt:[];if(ce.length===0)return H;const{visitedEdgeIds:we}=Lr(ce,e,t);return H.map(Ne=>we.has(Ne.id)?{...Ne,style:{...Ne.style,stroke:ae.trace,strokeWidth:3.5,opacity:1},markerEnd:{type:"arrowclosed",...Ne.markerEnd&&typeof Ne.markerEnd=="object"?Ne.markerEnd:{},color:ae.trace},zIndex:10}:{...Ne,style:{...Ne.style,strokeWidth:1.5,opacity:.2},zIndex:0})},[e,t,lt,ae,oa]);return D.useEffect(()=>{if(!pn||!Pe)return;const H=setTimeout(()=>{const ce=K.current;if(!ce)return;const we=se.getState().nodes.find(Ot=>Ot.id===Pe);if(!we)return;const Ne=ce.getViewport(),Xe=we.measured?.width??we.width??480,vt=(we.position.x+Xe)*Ne.zoom+Ne.x,wt=window.innerWidth-oe.getState().panelWidth-Wd-24;if(vt>wt){const Ot=(we.position.x+Xe/2)*Ne.zoom+Ne.x;ce.setViewport({...Ne,x:Ne.x-(Ot-wt/2)},{duration:300})}},60);return()=>clearTimeout(H)},[pn,Pe]),l.jsxs("div",{className:"relative w-full h-full","data-searching":Bn||void 0,children:[l.jsxs("div",{className:"relative h-full w-full",onDoubleClick:H=>{H.target.classList.contains("react-flow__pane")&&!Me&&Ct(_e({x:H.clientX,y:H.clientY}))},onDragOver:H=>{(H.dataTransfer.types.includes("application/thoughtdag-content")||H.dataTransfer.types.includes("Files"))&&(H.preventDefault(),H.dataTransfer.dropEffect="copy",!Q&&!Me&&j(!0))},onDrop:H=>{if(Et)return;const ce=H.target;if(!Q&&!Me&&H.dataTransfer.files.length>0){H.preventDefault(),j(!1),ot(H.dataTransfer.files);return}const we=ce.closest?.(".react-flow__node"),Ne=we&&se.getState().nodes.find(wt=>wt.id===we.getAttribute("data-id"))?.data.stepKind==="frame";if(!ce.classList?.contains("react-flow__pane")&&!Ne)return;const Xe=_e({x:H.clientX,y:H.clientY}),vt=H.dataTransfer.getData("application/thoughtdag-content");if(vt==="ask"){H.preventDefault(),Ct(Xe);return}if(vt==="frame"){H.preventDefault(),rt(Xe);return}if(vt==="note"||vt==="file"){H.preventDefault(),ps(vt,Xe);return}if(H.dataTransfer.files.length>0){H.preventDefault();const wt=Ue(H.dataTransfer.files);if(wt.length===0)return;const Ot=ps("file",Xe);Gd(Ot,wt)}},children:[l.jsxs(LB,{onInit:H=>{K.current=H,AM.current=H;const ce=oe.getState().arrivalFocusNodeId;if(ce){oe.getState().setArrivalFocusNodeId(null);const we=se.getState().nodes.find(Ne=>Ne.id===ce);we&&window.setTimeout(()=>{H.setCenter(we.position.x+260,we.position.y+140,{zoom:.9,duration:400})},150)}},nodes:nr,edges:st,onNodesChange:ie,onEdgesChange:Be,onNodeDragStart:Ht,onNodeDrag:Kt,onNodeDragStop:qt,onConnect:Wa,onConnectStart:ia,onConnectEnd:me,onEdgeContextMenu:tr,onNodeContextMenu:zn,nodeTypes:Nue,edgeTypes:Aue,deleteKeyCode:null,fitView:!0,onlyRenderVisibleElements:!0,minZoom:.04,maxZoom:2,defaultEdgeOptions:{type:"smoothstep",animated:!1,style:{stroke:ae.accent,strokeWidth:2},markerEnd:{type:"arrowclosed",color:ae.accent,width:18,height:18}},snapToGrid:ue==="grid",snapGrid:[22,22],proOptions:{hideAttribution:!0},nodeDragThreshold:5,connectionRadius:40,selectionMode:ru.Partial,selectionOnDrag:!Et,nodesDraggable:!Et,nodesConnectable:!Et,panOnDrag:Et?!0:[1,2],panOnScroll:v,zoomOnScroll:!v,zoomOnPinch:!0,zoomOnDoubleClick:!1,connectionLineStyle:{stroke:ae.accent,strokeDasharray:"8 4",strokeWidth:2},onSelectionChange:Ut,onPaneClick:()=>{d(null),h([]),ha(null)},children:[ue==="grid"?l.jsxs(l.Fragment,{children:[l.jsx(dx,{id:"grid-fine",variant:Rs.Lines,gap:22,color:"var(--canvas-grid-fine)"}),l.jsx(dx,{id:"grid-major",variant:Rs.Lines,gap:110,color:"var(--canvas-grid-major)"})]}):l.jsx(dx,{variant:Rs.Dots,gap:24,size:1,color:"var(--canvas-dot)"}),l.jsx(Iue,{}),l.jsx(Mue,{panelShiftWidth:pn?Nt:0}),l.jsx(wue,{}),l.jsx(YB,{position:"bottom-left"}),e.length>0&&l.jsx(oH,{nodeColor:H=>{const ce=H.data;if(ce.archived)return xe.archived;const we=ce.stepKind;return we==="note"?"#D97706":we==="file"||we==="link"?"#64748B":Array.isArray(ce.condensedFrom)&&ce.condensedFrom.length?"#8B7CF0":ce.isRoot?ae.accent:ce.isBranch?ae.warm:xe.ordinary},maskColor:xe.mask,style:{width:200,height:140},pannable:!0,zoomable:!0,position:"bottom-right"})]}),!Q&&Me&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"text-center pointer-events-auto",children:[l.jsx("p",{className:"text-sm text-ink-muted mb-1 font-medium",children:b("paradigm.emptyTitle")}),l.jsx("p",{className:"text-xs text-ink-faint mb-4 max-w-sm leading-relaxed",children:b("paradigm.emptyHint")}),l.jsxs("div",{className:"flex items-center justify-center gap-2",children:[l.jsxs("button",{onClick:()=>mt("human"),className:"text-sm border-2 border-dashed border-warm/60 text-warm hover:bg-warm/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(qd,{size:15,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"text-sm border-2 border-dashed border-accent/50 text-accent hover:bg-accent/10 px-4 py-2.5 rounded-xl transition-colors flex items-center gap-1.5",children:[l.jsx(Go,{size:15,strokeWidth:1.75})," ",b("paradigm.addPrompt")]})]})]})}),Et&&!Q&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("div",{className:"text-center max-w-[420px] px-6",children:_n?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"text-3xl mb-3",children:"🔗"}),l.jsx("div",{className:"text-sm font-semibold text-ink mb-1.5",children:b("viewer.loadError")}),l.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:b("viewer.loadErrorHint")})]}):l.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-muted justify-center",children:[l.jsx(nn,{size:16,strokeWidth:1.75,className:"animate-spin text-accent"})," ",b("viewer.loading")]})})}),!Q&&!Me&&!Et&&l.jsxs("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none overflow-hidden",children:[l.jsxs("svg",{className:"absolute -left-10 top-[8%] w-[360px] h-[300px] opacity-[0.35] pointer-events-none",viewBox:"0 0 360 300","aria-hidden":!0,children:[l.jsx("path",{d:"M80 40 C80 90 80 90 80 130 M80 170 C80 210 80 210 80 250",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M95 150 C150 150 150 90 205 88",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"80",cy:"30",r:"7",fill:it.line}),l.jsx("circle",{cx:"80",cy:"150",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"80",cy:"262",r:"7",fill:it.line}),l.jsx("circle",{cx:"218",cy:"88",r:"7",fill:it.line})]}),l.jsxs("svg",{className:"absolute right-[-30px] bottom-[10%] w-[320px] h-[280px] opacity-[0.35] pointer-events-none",viewBox:"0 0 320 280","aria-hidden":!0,children:[l.jsx("path",{d:"M240 30 C240 80 240 80 240 120 M240 160 C240 200 240 200 240 240",stroke:it.line,strokeWidth:"2",fill:"none"}),l.jsx("path",{d:"M225 140 C170 140 170 210 115 212",stroke:it.line,strokeWidth:"2",strokeDasharray:"6 5",fill:"none"}),l.jsx("circle",{cx:"240",cy:"20",r:"7",fill:it.line}),l.jsx("circle",{cx:"240",cy:"140",r:"7",fill:"none",stroke:it.line,strokeWidth:"2.5"}),l.jsx("circle",{cx:"240",cy:"252",r:"7",fill:it.line}),l.jsx("circle",{cx:"102",cy:"212",r:"7",fill:it.line})]}),l.jsxs("div",{className:"pointer-events-auto w-[560px] animate-fade-in relative",children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsxs("svg",{width:"52",height:"52",viewBox:"0 0 44 44",className:"mx-auto mb-4","aria-hidden":!0,children:[l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.05s"},cx:"22",cy:"7",r:"3.5",fill:it.accent}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.2s"},x1:"22",y1:"11",x2:"22",y2:"19",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.35s"},cx:"22",cy:"22",r:"3.5",fill:"none",stroke:it.accent,strokeWidth:"2.5"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.5s"},x1:"22",y1:"25",x2:"22",y2:"33",stroke:it.accent,strokeWidth:"2",strokeLinecap:"round"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.65s"},cx:"22",cy:"37",r:"3.5",fill:it.accent,opacity:"0.35"}),l.jsx("line",{className:"dag-pop",style:{animationDelay:"0.8s"},x1:"25.5",y1:"23.5",x2:"33",y2:"28.5",stroke:it.warm,strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"3 3"}),l.jsx("circle",{className:"dag-pop",style:{animationDelay:"0.95s"},cx:"36",cy:"30",r:"3.5",fill:it.warm})]}),l.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-ink mb-2.5",children:"ThoughtDAG"}),l.jsx("p",{className:"text-sm text-ink-muted",children:b("landing.tagline")}),l.jsx("p",{className:"text-xs text-ink-muted mt-1.5 font-medium",children:b("landing.mechanism")})]}),l.jsxs("div",{className:"bg-card border border-line rounded-xl px-5 py-4 shadow-lg transition-all focus-within:border-accent/50 focus-within:shadow-xl",children:[l.jsx("textarea",{value:T,onChange:H=>C(H.target.value),onKeyDown:yt,onPaste:H=>{if(H.clipboardData.getData("text/plain").trim())return;const ce=Array.from(H.clipboardData.items).filter(we=>we.kind==="file").map(we=>we.getAsFile()).filter(Boolean);ce.length&&jt(ce)},placeholder:b("landing.placeholder"),className:"w-full bg-transparent text-ink text-sm leading-relaxed resize-none focus:outline-none placeholder-ink-faint",rows:3,autoFocus:!0}),Y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 mt-2 pb-1",children:Y.map(H=>l.jsxs("div",{className:"flex items-center gap-1.5 bg-wash rounded-lg px-2.5 py-1.5 group",children:[H.thumbnailUrl?l.jsx("img",{src:H.thumbnailUrl,className:"w-6 h-6 rounded object-cover",alt:H.name}):l.jsx("span",{className:"text-xs",children:l.jsx(js,{size:16,strokeWidth:1.75})}),l.jsx("span",{className:"text-xs text-ink-muted max-w-[100px] truncate",children:H.name}),H.isExtracting&&l.jsx("span",{className:"text-2xs text-accent",children:l.jsx(nn,{className:"animate-spin",size:12,strokeWidth:1.75})}),H.numPages!=null&&l.jsxs("span",{className:"text-2xs text-ink-faint",children:[H.numPages,"p"]}),l.jsx("button",{onClick:()=>q(ce=>ce.filter(we=>we.id!==H.id)),className:"text-ink-faint hover:text-red-500 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]},H.id))}),z&&l.jsxs("div",{className:"space-y-1 mt-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-xs text-ink-muted font-medium",children:b("landing.roleLabel")}),l.jsx("button",{onClick:()=>{V(!1),S("")},className:"text-xs text-ink-faint hover:text-ink-muted",children:l.jsx(cn,{size:14,strokeWidth:1.75})})]}),l.jsx("textarea",{value:_,onChange:H=>S(H.target.value),placeholder:b("landing.rolePlaceholder"),className:"w-full text-xs border border-line rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-accent bg-surface resize-none leading-relaxed",rows:2,autoFocus:!0}),l.jsx(vM,{onPick:S})]}),l.jsxs("div",{className:"flex items-center justify-end mt-2 gap-2",children:[l.jsx(T0,{}),l.jsx("button",{onClick:()=>V(!z),title:b("landing.roleTrayTitle"),className:`rounded-full w-8 h-8 flex items-center justify-center transition-colors shrink-0 ${z||_?"text-accent bg-accent/10 hover:bg-accent/20":"text-ink-faint hover:text-ink-muted hover:bg-line"}`,children:l.jsx(hF,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:()=>$.current?.click(),className:"text-ink-faint hover:text-accent hover:bg-wash rounded-xl px-3 py-2 transition-colors text-sm",title:b("landing.attach"),children:l.jsx(Ls,{size:16,strokeWidth:1.75})}),l.jsx("input",{ref:$,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{jt(H.target.files||[]),H.target.value=""}}),l.jsx("button",{onClick:kt,disabled:!T.trim()||Y.some(H=>H.isExtracting),className:"bg-accent hover:bg-accent-strong disabled:opacity-30 disabled:cursor-not-allowed text-white text-sm px-5 py-2 rounded-xl transition-all",children:Y.some(H=>H.isExtracting)?b("landing.extracting"):b("landing.send")})]})]}),l.jsxs("div",{onClick:()=>X.current?.click(),className:`mt-3 border-2 border-dashed rounded-xl px-5 py-3.5 cursor-pointer transition-all text-center bg-card/60 backdrop-blur ${B?"border-accent bg-accent/5 ring-2 ring-accent/20":"border-line hover:border-accent/40 hover:bg-accent/5"}`,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(Bl,{size:15,strokeWidth:1.75,className:"text-accent"})," ",b("landing.docStart")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.docFormats")}),l.jsx("p",{className:"text-2xs text-ink-faint mt-0.5",children:b("landing.docPrivacy")})]}),!!window.desktopSessions&&l.jsxs("button",{onClick:()=>L(!0),className:"w-full mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 hover:border-accent/40 hover:bg-accent/5 transition-all text-center","data-landing-atlas":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(PH,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"}),l.jsx("span",{children:b("landing.atlasStart")}),l.jsx(IH,{size:13,strokeWidth:1.75,className:"text-accent shrink-0"})]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.atlasDesc")})]}),l.jsx("input",{ref:X,type:"file",multiple:!0,accept:b0,className:"hidden",onChange:H=>{ot(H.target.files||[]),H.target.value=""}}),P&&l.jsx(Vv,{onClose:()=>L(!1),onSwitched:()=>{L(!1),Ye()}}),(!De||(De.models?.length??0)===0)&&l.jsxs("div",{className:"mt-3 bg-card/60 backdrop-blur border border-line rounded-xl px-5 py-3.5 text-center","data-quick-connect":!0,children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-ink-muted font-medium",children:[l.jsx(p0,{size:15,strokeWidth:1.75,className:"text-accent shrink-0"})," ",b("landing.quickTitle")]}),l.jsx("p",{className:"text-2xs text-ink-faint mt-1.5",children:b("landing.quickDesc")}),l.jsxs("div",{className:"mt-2.5 flex items-center justify-center flex-wrap gap-2",children:[Ie==="zh"&&l.jsx("button",{onClick:()=>{oe.getState().setApiKeyPresetHint("zhipu"),oe.getState().setApiKeyModalOpen(!0)},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-zhipu":!0,children:b("landing.quickZhipu")}),l.jsx("button",{onClick:()=>{RM()},className:"text-2xs bg-accent/10 text-accent hover:bg-accent/20 font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0","data-quick-primary":!0,children:b("landing.quickOpenRouter")}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"text-2xs text-ink-muted hover:text-ink hover:bg-wash font-medium px-3 py-1.5 rounded-lg transition-colors shrink-0",children:b("landing.quickOther")})]}),l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"mt-2 mx-auto text-2xs text-ink-faint hover:text-accent transition-colors block","data-quick-subs":!0,children:b("landing.quickSubs")})]}),l.jsx("div",{className:"grid grid-cols-3 gap-3 mt-6",children:[{icon:ai,title:"landing.feature1.title",desc:"landing.feature1.desc"},{icon:Qk,title:"landing.feature2.title",desc:"landing.feature2.desc"},{icon:VA,title:"landing.feature3.title",desc:"landing.feature3.desc"}].map(({icon:H,title:ce,desc:we})=>l.jsxs("div",{className:"bg-card/60 backdrop-blur border border-line rounded-xl px-4 py-3.5",children:[l.jsx(H,{size:16,strokeWidth:1.75,className:"text-accent mb-2"}),l.jsx("h3",{className:"text-xs font-semibold text-ink mb-1",children:b(ce)}),l.jsx("p",{className:"text-2xs text-ink-faint leading-relaxed",children:b(we)})]},ce))}),l.jsxs("div",{className:"text-center mt-6 flex items-center justify-center gap-5",children:[l.jsxs("button",{onClick:bt,className:"text-xs text-accent hover:text-accent-strong font-medium transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Qk,{size:14,strokeWidth:1.75})," ",b("landing.loadExample")]}),l.jsxs("button",{onClick:()=>y(!0),className:"text-xs text-ink-muted hover:text-accent transition-colors inline-flex items-center gap-1.5",children:[l.jsx(Vk,{size:14,strokeWidth:1.75})," ",b("landing.howItWorks")]})]})]})]}),!Et&&l.jsx(dce,{onSwitched:Ye}),(Q||Me)&&!Et&&l.jsxs("div",{className:"absolute top-[38%] -translate-y-1/2 left-4 z-10 flex flex-col gap-1.5 bg-card/90 backdrop-blur border border-line rounded-xl p-1.5 shadow-sm",children:[!Me&&l.jsx("button",{onClick:()=>Ct(_e(null)),draggable:!0,onDragStart:H=>{H.dataTransfer.setData("application/thoughtdag-content","ask"),H.dataTransfer.effectAllowed="copy"},title:b("palette.askTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-accent hover:bg-accent/10 transition-colors cursor-grab",children:l.jsx(qd,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("note",_e(ce))),title:b("palette.noteTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-amber-600 hover:bg-amber-500/10 transition-colors",children:l.jsx(oi,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>ps("file",_e(ce))),title:b("palette.fileTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ls,{size:17,strokeWidth:1.75})}),l.jsx("button",{onPointerDown:H=>It(H,ce=>rt(_e(ce))),title:b("palette.frameTitle"),className:"w-9 h-9 rounded-lg flex items-center justify-center text-ink-muted hover:bg-wash transition-colors",children:l.jsx(Ub,{size:17,strokeWidth:1.75})})]}),Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Wd+12:16},"data-top-toolbar":!0,children:[l.jsxs("span",{className:"bg-card/90 backdrop-blur border border-line rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm text-ink-muted text-xs font-medium","data-viewer-badge":!0,children:[l.jsx(f0,{size:14,strokeWidth:1.75})," ",b("viewer.badge")]}),l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(FT,{}),l.jsx("button",{onClick:()=>hy(),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("viewer.downloadJson"),children:l.jsx(Ml,{size:15,strokeWidth:1.75})}),l.jsx("a",{href:"https://github.com/chenxiachan/thoughtdag",target:"_blank",rel:"noreferrer",className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:b("viewer.openApp")})]}),!Et&&l.jsxs("div",{className:"absolute top-4 z-10 flex gap-1.5 items-center transition-[right] duration-200",style:{right:pn?Nt+Wd+12:16},"data-top-toolbar":!0,children:[Me&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>mt("human"),className:"bg-card/90 backdrop-blur border border-warm/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-warm/10 transition-colors text-warm text-xs font-medium",children:[l.jsx(qd,{size:14,strokeWidth:1.75})," ",b("paradigm.addHuman")]}),l.jsxs("button",{onClick:()=>mt("prompt"),className:"bg-card/90 backdrop-blur border border-accent/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-accent/10 transition-colors text-accent text-xs font-medium",children:[l.jsx(Go,{size:14,strokeWidth:1.75})," ",b("paradigm.addPrompt")]}),l.jsxs("button",{onClick:()=>{Ze()},title:b("paradigm.instantiateTitle"),className:"bg-ink text-white rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-ink/85 transition-colors text-xs font-medium",children:["▶ ",b("paradigm.instantiate")]})]}),!Me&&l.jsx(mue,{}),!Me&&l.jsx(SM,{}),!Q&&l.jsx("button",{onClick:()=>oe.getState().setApiKeyModalOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("apikey.entryTitle"),"data-apikey-entry":!0,children:l.jsx(p0,{size:15,strokeWidth:1.75})}),mn>0&&!Me&&l.jsxs("button",{onClick:()=>{const{nodes:H,edges:ce}=se.getState(),Ne=Xr(se.getState()).reduce((Xe,vt)=>{const wt=H.map(fn=>fn.id===vt?{...fn,data:{...fn.data,question:"",response:""}}:fn),{layerTokens:Ot}=br(vt,wt,ce),$t=H.find(fn=>fn.id===vt)?.data.question??"";return Xe+Ot.material+Ot.reference+Ot.chain+Nn($t)},0);ri({title:b("replay.confirmTitle"),message:ye(b("replay.confirmMsg"),{n:mn,tok:Ne.toLocaleString()}),confirmLabel:b("replay.confirmBtn")}).then(Xe=>{Xe&&se.getState().replayStale()})},className:"bg-amber-500/10 backdrop-blur border border-amber-500/40 rounded-lg h-8 px-3 flex items-center gap-1.5 shadow-sm hover:bg-amber-500/20 transition-colors text-amber-600 text-xs font-medium",title:b("replay.chipTitle"),children:[l.jsx(ZF,{size:14,strokeWidth:1.75})," ",mn]}),Q&&Qt.length>0&&l.jsxs("div",{ref:tn,className:"relative",children:[l.jsx("button",{onClick:()=>Yn(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${Zt?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.frames"),children:l.jsx(Ub,{size:15,strokeWidth:1.75})}),Zt&&l.jsx("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[230px] max-h-[320px] overflow-y-auto z-30 animate-fade-in",children:Qt.map(H=>l.jsxs("button",{onClick:()=>{Yn(!1),K.current?.fitBounds({x:H.position.x,y:H.position.y,width:H.width??640,height:H.height??420},{duration:400,padding:.15})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2",children:[l.jsx("span",{className:`w-2.5 h-2.5 rounded-sm shrink-0 ${($d[H.data.frameColor??"gray"]??$d.gray).dot}`}),l.jsx("span",{className:"truncate",children:H.data.question||b("frame.untitled")})]},H.id))})]}),Q&&l.jsx("button",{onClick:()=>O(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-faint hover:text-accent",title:b("search.entryTitle"),"data-search-entry":!0,children:l.jsx(g0,{size:15,strokeWidth:1.75})}),l.jsx(FT,{}),Q&&!Me&&l.jsx(Lle,{showTrigger:!1,openPing:Jn,onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Ee&&!Et&&l.jsxs("button",{onClick:()=>oe.getState().setCondenseDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-accent/50 rounded-lg h-8 px-2 flex items-center justify-center gap-1.5 shadow-sm hover:bg-wash transition-colors text-accent",title:ye(b("condense.entryBuilding"),{i:String(Fe.current),n:String(Fe.total)}),"data-condense-entry":!0,children:[l.jsx(nn,{size:14,strokeWidth:1.75,className:"animate-spin"}),l.jsxs("span",{className:"text-2xs font-mono",children:[Fe.current,"/",Fe.total]})]}),Wp&&l.jsx("button",{onClick:()=>oe.getState().setBackupDialogOpen(!0),className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors text-ink-muted hover:text-accent",title:b("backup.dialogTitle"),"data-backup-entry":!0,children:l.jsx(zA,{size:15,strokeWidth:1.75})}),l.jsxs("div",{ref:Hn,className:"relative",children:[l.jsx("button",{onClick:()=>An(H=>!H),className:`bg-card/90 backdrop-blur border rounded-lg w-8 h-8 flex items-center justify-center shadow-sm transition-colors ${wn?"border-accent/40 text-accent":"border-line text-ink-faint hover:bg-wash"}`,title:b("toolbar.more"),"data-toolbar-more":!0,children:l.jsx(LA,{size:15,strokeWidth:1.75})}),wn&&l.jsxs("div",{className:"absolute right-0 top-full mt-1.5 bg-card border border-line rounded-xl shadow-lg py-1 w-[220px] z-30 animate-fade-in",children:[Q&&l.jsxs("button",{onClick:()=>{An(!1),E(!w)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b(w?"toolbar.showAnnotations":"toolbar.hideAnnotations"),children:[l.jsx(oi,{size:14,strokeWidth:1.75,className:`shrink-0 ${w?"text-accent":"text-ink-faint"}`})," ",b(w?"toolbar.menuAnnotationsShow":"toolbar.menuAnnotationsHide")]}),l.jsxs("button",{onClick:()=>{An(!1),A(!v)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.wheelPansTitle"),"aria-pressed":v,"data-wheel-pans":!0,children:[l.jsx(RF,{size:14,strokeWidth:1.75,className:`shrink-0 ${v?"text-accent":"text-ink-faint"}`})," ",l.jsx("span",{className:"flex-1",children:b("toolbar.menuWheelPans")}),v&&l.jsx("span",{className:"text-accent",children:"✓"})]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),ri({title:b("confirm.relayoutTitle"),message:b("confirm.relayoutMsg"),confirmLabel:b("toolbar.relayout")}).then(H=>{H&&(x(),setTimeout(()=>K.current?.fitView({duration:400,padding:.15}),50))})},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(YF,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.relayout")]}),G>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setHighlightsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("hlov.entryTitle"),"data-hlov-entry":!0,children:[l.jsx(m0,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ye(b("hlov.entry"),{n:G})]}),J>0&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMaterialsOverviewOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("matov.entryTitle"),"data-matov-entry":!0,children:[l.jsx(Ls,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",ye(b("matov.entry"),{n:J})]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),Q&&!Me&&!Et&&l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setCondenseDialogOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("condense.entryTitle"),children:[l.jsx(bp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("condense.title"),"…"]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),Pa(H=>H+1)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.diagnose"),"data-menu-diagnose":!0,children:[l.jsx(GA,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuDiagnose")]}),Q&&!Me&&l.jsxs("button",{onClick:()=>{An(!1),(async()=>{const{nodes:H,edges:ce}=se.getState(),{confirmIfSensitive:we}=await ft(async()=>{const{confirmIfSensitive:Xe}=await import("./sensitive-scan-CUWgeb_A.js");return{confirmIfSensitive:Xe}},[]);if(!await we(H))return;const Ne=await Lq(H,ce);await navigator.clipboard.writeText(Ne).catch(()=>{}),oe.getState().setShareDialogUrl(Ne)})()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-share-link":!0,title:b("viewer.shareTitle"),children:[l.jsx(AU,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.menuShare")]}),Q&&l.jsxs("button",{onClick:()=>{An(!1),Me?hG():hy()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-menu-export":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b(Me?"paradigm.exportParadigm":"switcher.exportBackup")]}),F&&l.jsxs("button",{onClick:()=>{An(!1),xG()},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("toolbar.exportEventsTitle"),children:[l.jsx(js,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("toolbar.exportEvents")]}),Q&&l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("div",{className:"px-3 pt-2 pb-1","data-appearance-lighting":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.lighting")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["light",b("appearance.light")],["dark",b("appearance.dark")],["system",b("appearance.system")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Hi.getState().setLighting(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${pe===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsxs("div",{className:"px-3 pt-1 pb-2","data-appearance-paper":!0,children:[l.jsx("div",{className:"text-2xs text-ink-faint mb-1.5",children:b("appearance.paper")}),l.jsx("div",{className:"flex rounded-lg border border-line overflow-hidden text-2xs",children:[["plain",b("appearance.plain")],["grid",b("appearance.grid")]].map(([H,ce],we)=>l.jsx("button",{onClick:()=>Hi.getState().setPaper(H),className:`flex-1 px-1 py-1.5 transition-colors ${we>0?"border-l border-line":""} ${ue===H?"bg-accent/10 text-accent font-medium":"text-ink-muted hover:bg-wash"}`,children:ce},H))})]}),l.jsx("div",{className:"border-t border-line/60 my-1"}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setMemoryManagerOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",title:b("memory.entryTitle"),children:[l.jsx(BH,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("memory.managerTitle")]}),l.jsxs("button",{onClick:()=>{An(!1),y(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5",children:[l.jsx(Vk,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("landing.howItWorks")]}),xa&&l.jsxs("button",{onClick:()=>{An(!1);const H=Ln?`dsh-thoughtdag@${xa.latest}`:Vy(xa.latest);navigator.clipboard.writeText(H).then(()=>We("success",b(Ln?"plugin.updateCopiedDesktop":"plugin.updateCopied")))},className:"w-full text-left px-3 py-2 text-xs text-accent hover:bg-wash transition-colors flex items-center gap-2.5",title:Ln?ye(b("plugin.updateHintDesktop"),{pkg:`dsh-thoughtdag@${xa.latest}`}):ye(b("plugin.updateHint"),{cmd:Vy(xa.latest)}),"data-plugin-update":!0,children:[l.jsx(Ml,{size:14,strokeWidth:1.75,className:"shrink-0"})," ",ye(b("plugin.updateAvailable"),{v:xa.latest})]}),l.jsxs("button",{onClick:()=>{An(!1),oe.getState().setReleaseNotesOpen(!0)},className:"w-full text-left px-3 py-2 text-xs text-ink hover:bg-wash transition-colors flex items-center gap-2.5","data-open-release-notes":!0,children:[l.jsx(xp,{size:14,strokeWidth:1.75,className:"text-ink-faint shrink-0"})," ",b("releaseNotes.entry")]})]})]}),l.jsx("button",{onClick:s,disabled:p<=0,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.undo"),children:l.jsx(XA,{size:16,strokeWidth:1.75})}),l.jsx("button",{onClick:o,disabled:p>=m.length-1,className:"bg-card/90 backdrop-blur border border-line rounded-lg w-8 h-8 flex items-center justify-center shadow-sm hover:bg-wash transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:b("canvas.redo"),children:l.jsx(gU,{size:16,strokeWidth:1.75})})]}),ve&&!Et&&l.jsx(Ele,{}),l.jsx(Rle,{open:I,onClose:()=>O(!1),onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Gt&&l.jsx(Tle,{x:Gt.x,y:Gt.y,nodeId:Gt.nodeId,onClose:()=>ha(null)}),l.jsx(Cle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Sue,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),l.jsx(Nle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}}),Rt&&l.jsx("div",{className:"fixed z-50 bg-card border border-line rounded-xl shadow-lg py-1 min-w-[120px]",style:{left:Rt.x,top:Rt.y},children:l.jsxs("button",{onClick:()=>na(Rt.edgeId),className:"w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors flex items-center gap-1.5",children:[l.jsx(Ja,{size:14,strokeWidth:1.75}),b("canvas.deleteEdge")]})})]}),l.jsx(sue,{onFocusSegment:H=>{const ce=K.current,we=se.getState().nodes.filter(fn=>H.includes(fn.id));if(!ce||we.length===0)return;const Ne=we.map(fn=>fn.position.x),Xe=we.map(fn=>fn.position.y),vt=Math.min(...Ne),wt=Math.min(...Xe),Ot=Math.max(...Ne)+520-vt,$t=Math.max(...Xe)+240-wt;ce.fitBounds({x:vt,y:wt,width:Ot+700,height:$t},{duration:350,padding:.15})}}),pn&&l.jsx(yle,{onFocusNode:H=>{const ce=e.find(we=>we.id===H);ce&&ze(ce,{duration:300})}}),l.jsx(Gle,{onLocate:H=>{const ce=se.getState().nodes.find(we=>we.id===H);ce&&(d(H),ze(ce,{zoom:1}))}})]})}function Mue({panelShiftWidth:e}){const t=Y0(),n=St(),a=Vl(),r=se(d=>d.nodes.length),s=se(d=>d.nodes),o=D.useMemo(()=>{let d=null,h="";for(const m of s){if(m.data.stepKind&&m.data.stepKind!=="human"&&m.data.stepKind!=="prompt")continue;const p=[m.data.lastGeneratedAt,m.data.askedAt,m.data.createdAt,...m.data.editedAts??[]].filter(Boolean).sort().pop();p&&p>h&&(h=p,d=m)}return d?{node:d,at:h}:null},[s]);if(Et||t==="work"||r<2)return null;const u=()=>{if(!o)return;oe.getState().setBeaconNodeId(null);const{node:d}=o;a.setCenter(d.position.x+260,d.position.y+110,{zoom:1,duration:1100}),window.setTimeout(()=>{se.getState().setSelectedNodeId(d.id),oe.getState().setPanelOpen(!0),window.setTimeout(()=>{a.setCenter(d.position.x+260+ap(d.id)/2,d.position.y+110,{zoom:1,duration:300})},60)},1150),window.setTimeout(()=>{We("success",n("continue.arrived"),12e3,{label:n("continue.summarize"),run:()=>{CM(d.id)}})},1550)};return l.jsxs("div",{className:"absolute bottom-6 z-10 flex items-center gap-2 -translate-x-1/2 transition-[left] duration-300",style:{left:`calc((100% - ${e}px) / 2)`},"data-map-dock":!0,children:[l.jsxs("button",{onClick:()=>oe.getState().setThoughtMapOpen(!0),"data-tmap-pill":!0,className:"flex items-center gap-2 bg-card/95 backdrop-blur border border-line-strong rounded-full px-5 py-2.5 text-sm text-ink shadow-lg hover:border-accent/40 hover:text-accent transition-colors",children:[l.jsx(d2,{size:16,strokeWidth:1.75})," ",n("tmap.export")]}),o&&l.jsxs("button",{onClick:u,onMouseEnter:()=>oe.getState().setBeaconNodeId(o.node.id),onMouseLeave:()=>oe.getState().setBeaconNodeId(null),title:n("continue.buttonTitle"),"data-continue-pill":!0,className:"flex items-center gap-2 bg-accent text-white rounded-full px-5 py-2.5 text-sm shadow-lg hover:bg-accent-strong transition-colors",children:[l.jsx(yU,{size:16,strokeWidth:1.75})," ",n("continue.button")]})]})}function Iue(){const e=Y0(),t=ln(n=>n.transform[2]);return D.useEffect(()=>{document.querySelector(".react-flow")?.setAttribute("data-zoom-tier",e)},[e]),D.useEffect(()=>{document.querySelector(".react-flow")?.style.setProperty("--tdag-zoom",String(t))},[t]),null}Hoe();const Kv="/thoughtdag/api";window.desktopSessions||A8(Kv);ft(()=>Promise.resolve().then(()=>gue),void 0).then(e=>e.bootPluginUpdateCheck(Kv));if(!window.desktopAgents){const e=Kv;ft(()=>import("./http-bridge-DOG0Sv0E.js"),[]).then(async t=>{await t.installAgentsHttpBridge(e)&&window.dispatchEvent(new CustomEvent("td:agents-ready"))})}Et?zq():(L7(),navigator.storage?.persist&&navigator.storage.persist(),ft(()=>Promise.resolve().then(()=>Yce),void 0).then(e=>e.bootAutoBackup()));ft(()=>import("./update-check-CLgVgdNf.js"),[]).then(e=>e.bootUpdateCheck());window.addEventListener("hashchange",()=>{window.location.hash.startsWith("#view=")!==Et&&window.location.reload()});aD.createRoot(document.getElementById("root")).render(l.jsx(D.StrictMode,{children:l.jsx(Cue,{})}));export{D0 as A,xr as B,XV as C,Rue as D,W7 as E,Sa as F,R$ as I,ft as _,Te as a,se as b,sn as c,qi as d,P7 as e,ye as f,Ui as g,jr as h,Et as i,vu as j,Np as k,uy as l,tG as m,Tn as n,JV as o,ws as p,F7 as q,eG as r,Xo as s,We as t,oe as u,ri as v,jue as w,Xr as x,Due as y,Oue as z};
|