@vantaloom/runtime-win32-x64 0.6.45 → 0.6.46

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.
@@ -1,5 +1,5 @@
1
1
  (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,25661,(e,t,n)=>{"use strict";var r=e.r(44440),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=r.useState,o=r.useEffect,l=r.useLayoutEffect,s=r.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!a(e,n)}catch(e){return!0}}var d="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,d=r[1];return l(function(){a.value=n,a.getSnapshot=t,c(a)&&d({inst:a})},[e,n,t]),o(function(){return c(a)&&d({inst:a}),e(function(){c(a)&&d({inst:a})})},[e]),s(n),n};n.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:d},56032,(e,t,n)=>{"use strict";t.exports=e.r(25661)},20206,(e,t,n)=>{"use strict";var r=e.r(44440),a=e.r(56032),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=a.useSyncExternalStore,l=r.useRef,s=r.useEffect,c=r.useMemo,d=r.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var u=l(null);if(null===u.current){var f={hasValue:!1,value:null};u.current=f}else f=u.current;var h=o(e,(u=c(function(){function e(e){if(!s){if(s=!0,o=e,e=r(e),void 0!==a&&f.hasValue){var t=f.value;if(a(t,e))return l=t}return l=e}if(t=l,i(o,e))return t;var n=r(e);return void 0!==a&&a(t,n)?(o=e,t):(o=e,l=n)}var o,l,s=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,r,a]))[0],u[1]);return s(function(){f.hasValue=!0,f.value=h},[h]),d(h),h}},96482,(e,t,n)=>{"use strict";t.exports=e.r(20206)},86416,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isUnsafeProperty=function(e){return"__proto__"===e}},73782,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isDeepKey=function(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}},47987,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.toKey=function(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}},99807,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.toString=function e(t){if(null==t)return"";if("string"==typeof t)return t;if(Array.isArray(t))return t.map(e).join(",");let n=String(t);return"0"===n&&Object.is(Number(t),-0)?"-0":n}},91945,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(99807),a=e.r(47987);n.toPath=function(e){if(Array.isArray(e))return e.map(a.toKey);if("symbol"==typeof e)return[e];e=r.toString(e);let t=[],n=e.length;if(0===n)return t;let i=0,o="",l="",s=!1;for(46===e.charCodeAt(0)&&(t.push(""),i++);i<n;){let r=e[i];l?"\\"===r&&i+1<n?o+=e[++i]:r===l?l="":o+=r:s?'"'===r||"'"===r?l=r:"]"===r?(s=!1,t.push(o),o=""):o+=r:"["===r?(s=!0,o&&(t.push(o),o="")):"."===r?o&&(t.push(o),o=""):o+=r,i++}return o&&t.push(o),t}},59528,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(86416),a=e.r(73782),i=e.r(47987),o=e.r(91945);n.get=function e(t,n,l){if(null==t)return l;switch(typeof n){case"string":{if(r.isUnsafeProperty(n))return l;let i=t[n];if(void 0===i)if(a.isDeepKey(n))return e(t,o.toPath(n),l);else return l;return i}case"number":case"symbol":{"number"==typeof n&&(n=i.toKey(n));let e=t[n];if(void 0===e)return l;return e}default:{if(Array.isArray(n)){var s=t,c=n,d=l;if(0===c.length)return d;let e=s;for(let t=0;t<c.length;t++){if(null==e||r.isUnsafeProperty(c[t]))return d;e=e[c[t]]}return void 0===e?d:e}if(n=Object.is(n?.valueOf(),-0)?"-0":String(n),r.isUnsafeProperty(n))return l;let e=t[n];if(void 0===e)return l;return e}}}},23251,(e,t,n)=>{t.exports=e.r(59528).get},41445,(e,t,n)=>{"use strict";function r(e){return"symbol"==typeof e?1:null===e?2:void 0===e?3:4*(e!=e)}Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.compareValues=(e,t,n)=>{if(e!==t){let a=r(e),i=r(t);if(a===i&&0===a){if(e<t)return"desc"===n?1:-1;if(e>t)return"desc"===n?-1:1}return"desc"===n?i-a:a-i}return 0}},69927,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isSymbol=function(e){return"symbol"==typeof e||e instanceof Symbol}},81560,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(69927),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;n.isKey=function(e,t){return!Array.isArray(e)&&(!!("number"==typeof e||"boolean"==typeof e||null==e||r.isSymbol(e))||"string"==typeof e&&(i.test(e)||!a.test(e))||null!=t&&Object.hasOwn(t,e))}},27157,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(41445),a=e.r(81560),i=e.r(91945);n.orderBy=function(e,t,n,o){if(null==e)return[];n=o?void 0:n,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=null==t?[null]:[t]),0===t.length&&(t=[null]),Array.isArray(n)||(n=null==n?[]:[n]),n=n.map(e=>String(e));let l=(e,t)=>{let n=e;for(let e=0;e<t.length&&null!=n;++e)n=n[t[e]];return n},s=t.map(e=>(Array.isArray(e)&&1===e.length&&(e=e[0]),null==e||"function"==typeof e||Array.isArray(e)||a.isKey(e))?e:{key:e,path:i.toPath(e)});return e.map(e=>({original:e,criteria:s.map(t=>{var n,r;return n=t,null==(r=e)||null==n?r:"object"==typeof n&&"key"in n?Object.hasOwn(r,n.key)?r[n.key]:l(r,n.path):"function"==typeof n?n(r):Array.isArray(n)?l(r,n):"object"==typeof r?r[n]:r})})).slice().sort((e,t)=>{for(let a=0;a<s.length;a++){let i=r.compareValues(e.criteria[a],t.criteria[a],n[a]);if(0!==i)return i}return 0}).map(e=>e.original)}},45856,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.flatten=function(e,t=1){let n=[],r=Math.floor(t),a=(e,t)=>{for(let i=0;i<e.length;i++){let o=e[i];Array.isArray(o)&&t<r?a(o,t+1):n.push(o)}};return a(e,0),n}},77141,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=/^(?:0|[1-9]\d*)$/;n.isIndex=function(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return r.test(e)}}},42389,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isLength=function(e){return Number.isSafeInteger(e)&&e>=0}},54116,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(42389);n.isArrayLike=function(e){return null!=e&&"function"!=typeof e&&r.isLength(e.length)}},68143,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isObject=function(e){return null!==e&&("object"==typeof e||"function"==typeof e)}},25639,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isEqualsSameValueZero=function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}},56170,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(77141),a=e.r(54116),i=e.r(68143),o=e.r(25639);n.isIterateeCall=function(e,t,n){return!!i.isObject(n)&&(!!("number"==typeof t&&a.isArrayLike(n)&&r.isIndex(t))&&t<n.length||"string"==typeof t&&t in n)&&o.isEqualsSameValueZero(n[t],e)}},18763,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(27157),a=e.r(45856),i=e.r(56170);n.sortBy=function(e,...t){let n=t.length;return n>1&&i.isIterateeCall(e,t[0],t[1])?t=[]:n>2&&i.isIterateeCall(t[0],t[1],t[2])&&(t=[t[0]]),r.orderBy(e,a.flatten(t),["asc"])}},41214,(e,t,n)=>{t.exports=e.r(18763).sortBy},40734,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(69927);n.toNumber=function(e){return r.isSymbol(e)?NaN:Number(e)}},962,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(40734);n.toFinite=function(e){return e?(e=r.toNumber(e))===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e==e?e:0:0===e?e:0}},72429,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(56170),a=e.r(962);n.range=function(e,t,n){n&&"number"!=typeof n&&r.isIterateeCall(e,t,n)&&(t=n=void 0),e=a.toFinite(e),void 0===t?(t=e,e=0):t=a.toFinite(t),n=void 0===n?e<t?1:-1:a.toFinite(n);let i=Math.max(Math.ceil((t-e)/(n||1)),0),o=Array(i);for(let t=0;t<i;t++)o[t]=e,e+=n;return o}},6030,(e,t,n)=>{t.exports=e.r(72429).range},38518,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.debounce=function(e,t,{signal:n,edges:r}={}){let a,i=null,o=null!=r&&r.includes("leading"),l=null==r||r.includes("trailing"),s=()=>{null!==i&&(e.apply(a,i),a=void 0,i=null)},c=null,d=()=>{null!=c&&clearTimeout(c),c=setTimeout(()=>{c=null,l&&s(),u()},t)},u=()=>{null!==c&&(clearTimeout(c),c=null),a=void 0,i=null},f=function(...e){if(n?.aborted)return;a=this,i=e;let t=null==c;d(),o&&t&&s()};return f.schedule=d,f.cancel=u,f.flush=()=>{s()},n?.addEventListener("abort",u,{once:!0}),f}},32251,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(38518);n.debounce=function(e,t=0,n={}){let a;"object"!=typeof n&&(n={});let{leading:i=!1,trailing:o=!0,maxWait:l}=n,s=[,,];i&&(s[0]="leading"),o&&(s[1]="trailing");let c=null,d=r.debounce(function(...t){a=e.apply(this,t),c=null},t,{edges:s}),u=function(...t){return null!=l&&(null===c&&(c=Date.now()),Date.now()-c>=l)?(a=e.apply(this,t),c=Date.now(),d.cancel(),d.schedule(),a):(d.apply(this,t),a)};return u.cancel=d.cancel,u.flush=()=>(d.flush(),a),u}},37622,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(32251);n.throttle=function(e,t=0,n={}){let{leading:a=!0,trailing:i=!0}=n;return r.debounce(e,t,{leading:a,maxWait:t,trailing:i})}},78802,(e,t,n)=>{t.exports=e.r(37622).throttle},60600,(e,t,n)=>{!function(n){"use strict";var r,a={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},i=!0,o="[DecimalError] ",l=o+"Invalid argument: ",s=o+"Exponent out of range: ",c=Math.floor,d=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,f=c(1286742750677284.5),h={};function p(e,t){var n,r,a,o,l,s,c,d,u=e.constructor,f=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),i?S(t,f):t;if(c=e.d,d=t.d,l=e.e,a=t.e,c=c.slice(),o=l-a){for(o<0?(r=c,o=-o,s=d.length):(r=d,a=l,s=c.length),o>(s=(l=Math.ceil(f/7))>s?l+1:s+1)&&(o=s,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for((s=c.length)-(o=d.length)<0&&(o=s,r=d,d=c,c=r),n=0;o;)n=(c[--o]=c[o]+d[o]+n)/1e7|0,c[o]%=1e7;for(n&&(c.unshift(n),++a),s=c.length;0==c[--s];)c.pop();return t.d=c,t.e=a,i?S(t,f):t}function m(e,t,n){if(e!==~~e||e<t||e>n)throw Error(l+e)}function g(e){var t,n,r,a=e.length-1,i="",o=e[0];if(a>0){for(i+=o,t=1;t<a;t++)(n=7-(r=e[t]+"").length)&&(i+=w(n)),i+=r;(n=7-(r=(o=e[t])+"").length)&&(i+=w(n))}else if(0===o)return"0";for(;o%10==0;)o/=10;return i+o}h.absoluteValue=h.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e},h.comparedTo=h.cmp=function(e){var t,n,r,a;if(e=new this.constructor(e),this.s!==e.s)return this.s||-e.s;if(this.e!==e.e)return this.e>e.e^this.s<0?1:-1;for(t=0,n=(r=this.d.length)<(a=e.d.length)?r:a;t<n;++t)if(this.d[t]!==e.d[t])return this.d[t]>e.d[t]^this.s<0?1:-1;return r===a?0:r>a^this.s<0?1:-1},h.decimalPlaces=h.dp=function(){var e=this.d.length-1,t=(e-this.e)*7;if(e=this.d[e])for(;e%10==0;e/=10)t--;return t<0?0:t},h.dividedBy=h.div=function(e){return v(this,new this.constructor(e))},h.dividedToIntegerBy=h.idiv=function(e){var t=this.constructor;return S(v(this,new t(e),0,1),t.precision)},h.equals=h.eq=function(e){return!this.cmp(e)},h.exponent=function(){return y(this)},h.greaterThan=h.gt=function(e){return this.cmp(e)>0},h.greaterThanOrEqualTo=h.gte=function(e){return this.cmp(e)>=0},h.isInteger=h.isint=function(){return this.e>this.d.length-2},h.isNegative=h.isneg=function(){return this.s<0},h.isPositive=h.ispos=function(){return this.s>0},h.isZero=function(){return 0===this.s},h.lessThan=h.lt=function(e){return 0>this.cmp(e)},h.lessThanOrEqualTo=h.lte=function(e){return 1>this.cmp(e)},h.logarithm=h.log=function(e){var t,n=this.constructor,a=n.precision,l=a+5;if(void 0===e)e=new n(10);else if((e=new n(e)).s<1||e.eq(r))throw Error(o+"NaN");if(this.s<1)throw Error(o+(this.s?"NaN":"-Infinity"));return this.eq(r)?new n(0):(i=!1,t=v(j(this,l),j(e,l),l),i=!0,S(t,a))},h.minus=h.sub=function(e){return e=new this.constructor(e),this.s==e.s?N(this,e):p(this,(e.s=-e.s,e))},h.modulo=h.mod=function(e){var t,n=this.constructor,r=n.precision;if(!(e=new n(e)).s)throw Error(o+"NaN");return this.s?(i=!1,t=v(this,e,0,1).times(e),i=!0,this.minus(t)):S(new n(this),r)},h.naturalExponential=h.exp=function(){return x(this)},h.naturalLogarithm=h.ln=function(){return j(this)},h.negated=h.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},h.plus=h.add=function(e){return e=new this.constructor(e),this.s==e.s?p(this,e):N(this,(e.s=-e.s,e))},h.precision=h.sd=function(e){var t,n,r;if(void 0!==e&&!!e!==e&&1!==e&&0!==e)throw Error(l+e);if(t=y(this)+1,n=7*(r=this.d.length-1)+1,r=this.d[r]){for(;r%10==0;r/=10)n--;for(r=this.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},h.squareRoot=h.sqrt=function(){var e,t,n,r,a,l,s,d=this.constructor;if(this.s<1){if(!this.s)return new d(0);throw Error(o+"NaN")}for(e=y(this),i=!1,0==(a=Math.sqrt(+this))||a==1/0?(((t=g(this.d)).length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),r=new d(t=a==1/0?"5e"+e:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+e)):r=new d(a.toString()),a=s=(n=d.precision)+3;;)if(r=(l=r).plus(v(this,l,s+2)).times(.5),g(l.d).slice(0,s)===(t=g(r.d)).slice(0,s)){if(t=t.slice(s-3,s+1),a==s&&"4999"==t){if(S(l,n+1,0),l.times(l).eq(this)){r=l;break}}else if("9999"!=t)break;s+=4}return i=!0,S(r,n)},h.times=h.mul=function(e){var t,n,r,a,o,l,s,c,d,u=this.constructor,f=this.d,h=(e=new u(e)).d;if(!this.s||!e.s)return new u(0);for(e.s*=this.s,n=this.e+e.e,(c=f.length)<(d=h.length)&&(o=f,f=h,h=o,l=c,c=d,d=l),o=[],r=l=c+d;r--;)o.push(0);for(r=d;--r>=0;){for(t=0,a=c+r;a>r;)s=o[a]+h[r]*f[a-r-1]+t,o[a--]=s%1e7|0,t=s/1e7|0;o[a]=(o[a]+t)%1e7|0}for(;!o[--l];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?S(e,u.precision):e},h.toDecimalPlaces=h.todp=function(e,t){var n=this,r=n.constructor;return(n=new r(n),void 0===e)?n:(m(e,0,1e9),void 0===t?t=r.rounding:m(t,0,8),S(n,e+y(n)+1,t))},h.toExponential=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=C(r,!0):(m(e,0,1e9),void 0===t?t=a.rounding:m(t,0,8),n=C(r=S(new a(r),e+1,t),!0,e+1)),n},h.toFixed=function(e,t){var n,r,a=this.constructor;return void 0===e?C(this):(m(e,0,1e9),void 0===t?t=a.rounding:m(t,0,8),n=C((r=S(new a(this),e+y(this)+1,t)).abs(),!1,e+y(r)+1),this.isneg()&&!this.isZero()?"-"+n:n)},h.toInteger=h.toint=function(){var e=this.constructor;return S(new e(this),y(this)+1,e.rounding)},h.toNumber=function(){return+this},h.toPower=h.pow=function(e){var t,n,a,l,s,d,u=this,f=u.constructor,h=+(e=new f(e));if(!e.s)return new f(r);if(!(u=new f(u)).s){if(e.s<1)throw Error(o+"Infinity");return u}if(u.eq(r))return u;if(a=f.precision,e.eq(r))return S(u,a);if(d=(t=e.e)>=(n=e.d.length-1),s=u.s,d){if((n=h<0?-h:h)<=0x1fffffffffffff){for(l=new f(r),t=Math.ceil(a/7+4),i=!1;n%2&&M((l=l.times(u)).d,t),0!==(n=c(n/2));)M((u=u.times(u)).d,t);return i=!0,e.s<0?new f(r).div(l):S(l,a)}}else if(s<0)throw Error(o+"NaN");return s=s<0&&1&e.d[Math.max(t,n)]?-1:1,u.s=1,i=!1,l=e.times(j(u,a+12)),i=!0,(l=x(l)).s=s,l},h.toPrecision=function(e,t){var n,r,a=this,i=a.constructor;return void 0===e?(n=y(a),r=C(a,n<=i.toExpNeg||n>=i.toExpPos)):(m(e,1,1e9),void 0===t?t=i.rounding:m(t,0,8),n=y(a=S(new i(a),e,t)),r=C(a,e<=n||n<=i.toExpNeg,e)),r},h.toSignificantDigits=h.tosd=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(m(e,1,1e9),void 0===t?t=n.rounding:m(t,0,8)),S(new n(this),e,t)},h.toString=h.valueOf=h.val=h.toJSON=function(){var e=y(this),t=this.constructor;return C(this,e<=t.toExpNeg||e>=t.toExpPos)};var v=function(){function e(e,t){var n,r=0,a=e.length;for(e=e.slice();a--;)n=e[a]*t+r,e[a]=n%1e7|0,r=n/1e7|0;return r&&e.unshift(r),e}function t(e,t,n,r){var a,i;if(n!=r)i=n>r?1:-1;else for(a=i=0;a<n;a++)if(e[a]!=t[a]){i=e[a]>t[a]?1:-1;break}return i}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=1e7*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,a,i,l){var s,c,d,u,f,h,p,m,g,v,x,b,w,j,k,N,C,M,E=r.constructor,O=r.s==a.s?1:-1,P=r.d,A=a.d;if(!r.s)return new E(r);if(!a.s)throw Error(o+"Division by zero");for(d=0,c=r.e-a.e,C=A.length,k=P.length,m=(p=new E(O)).d=[];A[d]==(P[d]||0);)++d;if(A[d]>(P[d]||0)&&--c,(b=null==i?i=E.precision:l?i+(y(r)-y(a))+1:i)<0)return new E(0);if(b=b/7+2|0,d=0,1==C)for(u=0,A=A[0],b++;(d<k||u)&&b--;d++)w=1e7*u+(P[d]||0),m[d]=w/A|0,u=w%A|0;else{for((u=1e7/(A[0]+1)|0)>1&&(A=e(A,u),P=e(P,u),C=A.length,k=P.length),j=C,v=(g=P.slice(0,C)).length;v<C;)g[v++]=0;(M=A.slice()).unshift(0),N=A[0],A[1]>=1e7/2&&++N;do u=0,(s=t(A,g,C,v))<0?(x=g[0],C!=v&&(x=1e7*x+(g[1]||0)),(u=x/N|0)>1?(u>=1e7&&(u=1e7-1),h=(f=e(A,u)).length,v=g.length,1==(s=t(f,g,h,v))&&(u--,n(f,C<h?M:A,h))):(0==u&&(s=u=1),f=A.slice()),(h=f.length)<v&&f.unshift(0),n(g,f,v),-1==s&&(v=g.length,(s=t(A,g,C,v))<1&&(u++,n(g,C<v?M:A,v))),v=g.length):0===s&&(u++,g=[0]),m[d++]=u,s&&g[0]?g[v++]=P[j]||0:(g=[P[j]],v=1);while((j++<k||void 0!==g[0])&&b--)}return m[0]||m.shift(),p.e=c,S(p,l?i+y(p)+1:i)}}();function x(e,t){var n,a,o,l,c,u=0,f=0,h=e.constructor,p=h.precision;if(y(e)>16)throw Error(s+y(e));if(!e.s)return new h(r);for(null==t?(i=!1,c=p):c=t,l=new h(.03125);e.abs().gte(.1);)e=e.times(l),f+=5;for(c+=Math.log(d(2,f))/Math.LN10*2+5|0,n=a=o=new h(r),h.precision=c;;){if(a=S(a.times(e),c),n=n.times(++u),g((l=o.plus(v(a,n,c))).d).slice(0,c)===g(o.d).slice(0,c)){for(;f--;)o=S(o.times(o),c);return h.precision=p,null==t?(i=!0,S(o,p)):o}o=l}}function y(e){for(var t=7*e.e,n=e.d[0];n>=10;n/=10)t++;return t}function b(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(o+"LN10 precision limit exceeded");return S(new e(e.LN10),t)}function w(e){for(var t="";e--;)t+="0";return t}function j(e,t){var n,a,l,s,c,d,u,f,h,p=1,m=e,x=m.d,w=m.constructor,k=w.precision;if(m.s<1)throw Error(o+(m.s?"NaN":"-Infinity"));if(m.eq(r))return new w(0);if(null==t?(i=!1,f=k):f=t,m.eq(10))return null==t&&(i=!0),b(w,f);if(w.precision=f+=10,a=(n=g(x)).charAt(0),!(15e14>Math.abs(s=y(m))))return u=b(w,f+2,k).times(s+""),m=j(new w(a+"."+n.slice(1)),f-10).plus(u),w.precision=k,null==t?(i=!0,S(m,k)):m;for(;a<7&&1!=a||1==a&&n.charAt(1)>3;)a=(n=g((m=m.times(e)).d)).charAt(0),p++;for(s=y(m),a>1?(m=new w("0."+n),s++):m=new w(a+"."+n.slice(1)),d=c=m=v(m.minus(r),m.plus(r),f),h=S(m.times(m),f),l=3;;){if(c=S(c.times(h),f),g((u=d.plus(v(c,new w(l),f))).d).slice(0,f)===g(d.d).slice(0,f))return d=d.times(2),0!==s&&(d=d.plus(b(w,f+2,k).times(s+""))),d=v(d,new w(p),f),w.precision=k,null==t?(i=!0,S(d,k)):d;d=u,l+=2}}function k(e,t){var n,r,a;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);)++r;for(a=t.length;48===t.charCodeAt(a-1);)--a;if(t=t.slice(r,a)){if(a-=r,e.e=c((n=n-r-1)/7),e.d=[],r=(n+1)%7,n<0&&(r+=7),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=7;r<a;)e.d.push(+t.slice(r,r+=7));r=7-(t=t.slice(r)).length}else r-=a;for(;r--;)t+="0";if(e.d.push(+t),i&&(e.e>f||e.e<-f))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function S(e,t,n){var r,a,o,l,u,h,p,m,g=e.d;for(l=1,o=g[0];o>=10;o/=10)l++;if((r=t-l)<0)r+=7,a=t,p=g[m=0];else{if((m=Math.ceil((r+1)/7))>=(o=g.length))return e;for(l=1,p=o=g[m];o>=10;o/=10)l++;r%=7,a=r-7+l}if(void 0!==n&&(u=p/(o=d(10,l-a-1))%10|0,h=t<0||void 0!==g[m+1]||p%o,h=n<4?(u||h)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||h||6==n&&(r>0?a>0?p/d(10,l-a):0:g[m-1])%10&1||n==(e.s<0?8:7))),t<1||!g[0])return h?(o=y(e),g.length=1,t=t-o-1,g[0]=d(10,(7-t%7)%7),e.e=c(-t/7)||0):(g.length=1,g[0]=e.e=e.s=0),e;if(0==r?(g.length=m,o=1,m--):(g.length=m+1,o=d(10,7-r),g[m]=a>0?(p/d(10,l-a)%d(10,a)|0)*o:0),h)for(;;)if(0==m){1e7==(g[0]+=o)&&(g[0]=1,++e.e);break}else{if(g[m]+=o,1e7!=g[m])break;g[m--]=0,o=1}for(r=g.length;0===g[--r];)g.pop();if(i&&(e.e>f||e.e<-f))throw Error(s+y(e));return e}function N(e,t){var n,r,a,o,l,s,c,d,u,f,h=e.constructor,p=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?S(t,p):t;if(c=e.d,f=t.d,r=t.e,d=e.e,c=c.slice(),l=d-r){for((u=l<0)?(n=c,l=-l,s=f.length):(n=f,r=d,s=c.length),l>(a=Math.max(Math.ceil(p/7),s)+2)&&(l=a,n.length=1),n.reverse(),a=l;a--;)n.push(0);n.reverse()}else{for((u=(a=c.length)<(s=f.length))&&(s=a),a=0;a<s;a++)if(c[a]!=f[a]){u=c[a]<f[a];break}l=0}for(u&&(n=c,c=f,f=n,t.s=-t.s),s=c.length,a=f.length-s;a>0;--a)c[s++]=0;for(a=f.length;a>l;){if(c[--a]<f[a]){for(o=a;o&&0===c[--o];)c[o]=1e7-1;--c[o],c[a]+=1e7}c[a]-=f[a]}for(;0===c[--s];)c.pop();for(;0===c[0];c.shift())--r;return c[0]?(t.d=c,t.e=r,i?S(t,p):t):new h(0)}function C(e,t,n){var r,a=y(e),i=g(e.d),o=i.length;return t?(n&&(r=n-o)>0?i=i.charAt(0)+"."+i.slice(1)+w(r):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+w(-a-1)+i,n&&(r=n-o)>0&&(i+=w(r))):a>=o?(i+=w(a+1-o),n&&(r=n-a-1)>0&&(i=i+"."+w(r))):((r=a+1)<o&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-o)>0&&(a+1===o&&(i+="."),i+=w(r))),e.s<0?"-"+i:i}function M(e,t){if(e.length>t)return e.length=t,!0}function E(e){if(!e||"object"!=typeof e)throw Error(o+"Object expected");var t,n,r,a=["precision",1,1e9,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(t=0;t<a.length;t+=3)if(void 0!==(r=e[n=a[t]]))if(c(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(l+n+": "+r);if(void 0!==(r=e[n="LN10"]))if(r==Math.LN10)this[n]=new this(r);else throw Error(l+n+": "+r);return this}if((a=function e(t){var n,r,a;function i(e){if(!(this instanceof i))return new i(e);if(this.constructor=i,e instanceof i){this.s=e.s,this.e=e.e,this.d=(e=e.d)?e.slice():e;return}if("number"==typeof e){if(0*e!=0)throw Error(l+e);if(e>0)this.s=1;else if(e<0)e=-e,this.s=-1;else{this.s=0,this.e=0,this.d=[0];return}if(e===~~e&&e<1e7){this.e=0,this.d=[e];return}return k(this,e.toString())}if("string"!=typeof e)throw Error(l+e);if(45===e.charCodeAt(0)?(e=e.slice(1),this.s=-1):this.s=1,u.test(e))k(this,e);else throw Error(l+e)}if(i.prototype=h,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=e,i.config=i.set=E,void 0===t&&(t={}),t)for(n=0,a=["precision","rounding","toExpNeg","toExpPos","LN10"];n<a.length;)t.hasOwnProperty(r=a[n++])||(t[r]=this[r]);return i.config(t),i}(a)).default=a.Decimal=a,r=new a(1),"function"==typeof define&&define.amd){let t;e.r,void 0!==(t=a)&&e.v(t)}else t.exports?t.exports=a:(n||(n="u">typeof self&&self&&self.self==self?self:Function("return this")()),n.Decimal=a)}(e.e)},742,(e,t,n)=>{"use strict";var r="function"==typeof Symbol&&Symbol.for,a=r?Symbol.for("react.element"):60103,i=r?Symbol.for("react.portal"):60106,o=r?Symbol.for("react.fragment"):60107,l=r?Symbol.for("react.strict_mode"):60108,s=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,d=r?Symbol.for("react.context"):60110,u=r?Symbol.for("react.async_mode"):60111,f=r?Symbol.for("react.concurrent_mode"):60111,h=r?Symbol.for("react.forward_ref"):60112,p=r?Symbol.for("react.suspense"):60113,m=r?Symbol.for("react.suspense_list"):60120,g=r?Symbol.for("react.memo"):60115,v=r?Symbol.for("react.lazy"):60116,x=r?Symbol.for("react.block"):60121,y=r?Symbol.for("react.fundamental"):60117,b=r?Symbol.for("react.responder"):60118,w=r?Symbol.for("react.scope"):60119;function j(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case u:case f:case o:case s:case l:case p:return e;default:switch(e=e&&e.$$typeof){case d:case h:case v:case g:case c:return e;default:return t}}case i:return t}}}function k(e){return j(e)===f}n.AsyncMode=u,n.ConcurrentMode=f,n.ContextConsumer=d,n.ContextProvider=c,n.Element=a,n.ForwardRef=h,n.Fragment=o,n.Lazy=v,n.Memo=g,n.Portal=i,n.Profiler=s,n.StrictMode=l,n.Suspense=p,n.isAsyncMode=function(e){return k(e)||j(e)===u},n.isConcurrentMode=k,n.isContextConsumer=function(e){return j(e)===d},n.isContextProvider=function(e){return j(e)===c},n.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},n.isForwardRef=function(e){return j(e)===h},n.isFragment=function(e){return j(e)===o},n.isLazy=function(e){return j(e)===v},n.isMemo=function(e){return j(e)===g},n.isPortal=function(e){return j(e)===i},n.isProfiler=function(e){return j(e)===s},n.isStrictMode=function(e){return j(e)===l},n.isSuspense=function(e){return j(e)===p},n.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===f||e===s||e===l||e===p||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===g||e.$$typeof===c||e.$$typeof===d||e.$$typeof===h||e.$$typeof===y||e.$$typeof===b||e.$$typeof===w||e.$$typeof===x)},n.typeOf=j},27142,(e,t,n)=>{"use strict";t.exports=e.r(742)},9590,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isPlainObject=function(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){let t=e[Symbol.toStringTag];return null!=t&&!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}},19003,(e,t,n)=>{t.exports=e.r(9590).isPlainObject},66631,(e,t,n)=>{"use strict";var r=e.r(44440),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=r.useSyncExternalStore,o=r.useRef,l=r.useEffect,s=r.useMemo,c=r.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,r,d){var u=o(null);if(null===u.current){var f={hasValue:!1,value:null};u.current=f}else f=u.current;var h=i(e,(u=s(function(){function e(e){if(!l){if(l=!0,i=e,e=r(e),void 0!==d&&f.hasValue){var t=f.value;if(d(t,e))return o=t}return o=e}if(t=o,a(i,e))return t;var n=r(e);return void 0!==d&&d(t,n)?(i=e,t):(i=e,o=n)}var i,o,l=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]},[t,n,r,d]))[0],u[1]);return l(function(){f.hasValue=!0,f.value=h},[h]),c(h),h}},64675,(e,t,n)=>{"use strict";t.exports=e.r(66631)},71650,(e,t,n)=>{"use strict";var r=Object.prototype.hasOwnProperty,a="~";function i(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function l(e,t,n,r,i){if("function"!=typeof n)throw TypeError("The listener must be a function");var l=new o(n,r||e,i),s=a?a+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],l]:e._events[s].push(l):(e._events[s]=l,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(a=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=a?a+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,o=Array(i);r<i;r++)o[r]=n[r].fn;return o},c.prototype.listenerCount=function(e){var t=a?a+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,r,i,o){var l=a?a+e:e;if(!this._events[l])return!1;var s,c,d=this._events[l],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,r),!0;case 5:return d.fn.call(d.context,t,n,r,i),!0;case 6:return d.fn.call(d.context,t,n,r,i,o),!0}for(c=1,s=Array(u-1);c<u;c++)s[c-1]=arguments[c];d.fn.apply(d.context,s)}else{var f,h=d.length;for(c=0;c<h;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,n);break;case 4:d[c].fn.call(d[c].context,t,n,r);break;default:if(!s)for(f=1,s=Array(u-1);f<u;f++)s[f-1]=arguments[f];d[c].fn.apply(d[c].context,s)}}return!0},c.prototype.on=function(e,t,n){return l(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return l(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,r){var i=a?a+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var o=this._events[i];if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||s(this,i);else{for(var l=0,c=[],d=o.length;l<d;l++)(o[l].fn!==t||r&&!o[l].once||n&&o[l].context!==n)&&c.push(o[l]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=a,c.EventEmitter=c,t.exports=c},47063,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.uniqBy=function(e,t){let n=new Map;for(let r=0;r<e.length;r++){let a=e[r],i=t(a,r,e);n.has(i)||n.set(i,a)}return Array.from(n.values())}},62192,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.ary=function(e,t){return function(...n){return e.apply(this,n.slice(0,t))}}},8478,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.identity=function(e){return e}},6437,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isObjectLike=function(e){return"object"==typeof e&&null!==e}},39600,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(54116),a=e.r(6437);n.isArrayLikeObject=function(e){return a.isObjectLike(e)&&r.isArrayLike(e)}},85912,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(59528);n.property=function(e){return function(t){return r.get(t,e)}}},83279,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isPrimitive=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e}},79717,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(68143),a=e.r(83279),i=e.r(25639);function o(e,t,n,c){if(t===e)return!0;switch(typeof t){case"object":return function(e,t,n,r){if(null==t)return!0;if(Array.isArray(t))return l(e,t,n,r);if(t instanceof Map){var i=e,o=t,c=n,d=r;if(0===o.size)return!0;if(!(i instanceof Map))return!1;for(let[e,t]of o.entries())if(!1===c(i.get(e),t,e,i,o,d))return!1;return!0}if(t instanceof Set)return s(e,t,n,r);let u=Object.keys(t);if(null==e||a.isPrimitive(e))return 0===u.length;if(0===u.length)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;i<u.length;i++){let o=u[i];if(!a.isPrimitive(e)&&!(o in e)||void 0===t[o]&&void 0!==e[o]||null===t[o]&&null!==e[o]||!n(e[o],t[o],o,e,t,r))return!1}return!0}finally{r?.delete(t)}}(e,t,n,c);case"function":if(Object.keys(t).length>0)return o(e,{...t},n,c);return i.isEqualsSameValueZero(e,t);default:if(!r.isObject(e))return i.isEqualsSameValueZero(e,t);if("string"==typeof t)return""===t;return!0}}function l(e,t,n,r){if(0===t.length)return!0;if(!Array.isArray(e))return!1;let a=new Set;for(let i=0;i<t.length;i++){let o=t[i],l=!1;for(let s=0;s<e.length;s++){if(a.has(s))continue;let c=e[s],d=!1;if(n(c,o,i,e,t,r)&&(d=!0),d){a.add(s),l=!0;break}}if(!l)return!1}return!0}function s(e,t,n,r){return 0===t.size||e instanceof Set&&l([...e],[...t],n,r)}n.isMatchWith=function e(t,n,r){return"function"!=typeof r?e(t,n,()=>void 0):o(t,n,function e(t,n,a,i,l,s){let c=r(t,n,a,i,l,s);return void 0!==c?!!c:o(t,n,e,s)},new Map)},n.isSetMatch=s},86949,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(79717);n.isMatch=function(e,t){return r.isMatchWith(e,t,()=>void 0)}},24401,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.getSymbols=function(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}},42064,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.getTag=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}},88530,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.argumentsTag="[object Arguments]",n.arrayBufferTag="[object ArrayBuffer]",n.arrayTag="[object Array]",n.bigInt64ArrayTag="[object BigInt64Array]",n.bigUint64ArrayTag="[object BigUint64Array]",n.booleanTag="[object Boolean]",n.dataViewTag="[object DataView]",n.dateTag="[object Date]",n.errorTag="[object Error]",n.float32ArrayTag="[object Float32Array]",n.float64ArrayTag="[object Float64Array]",n.functionTag="[object Function]",n.int16ArrayTag="[object Int16Array]",n.int32ArrayTag="[object Int32Array]",n.int8ArrayTag="[object Int8Array]",n.mapTag="[object Map]",n.numberTag="[object Number]",n.objectTag="[object Object]",n.regexpTag="[object RegExp]",n.setTag="[object Set]",n.stringTag="[object String]",n.symbolTag="[object Symbol]",n.uint16ArrayTag="[object Uint16Array]",n.uint32ArrayTag="[object Uint32Array]",n.uint8ArrayTag="[object Uint8Array]",n.uint8ClampedArrayTag="[object Uint8ClampedArray]"},88005,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.globalThis="object"==typeof globalThis&&globalThis||"object"==typeof window&&window||"object"==typeof self&&self||e.g||function(){return this}()||Function("return this")()},81893,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(88005);n.isBuffer=function(e){return void 0!==r.globalThis.Buffer&&r.globalThis.Buffer.isBuffer(e)}},15180,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n.isTypedArray=function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}},65241,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(24401),a=e.r(42064),i=e.r(88530),o=e.r(81893),l=e.r(83279),s=e.r(15180);function c(e,t,n,r=new Map,u){let f=u?.(e,t,n,r);if(void 0!==f)return f;if(l.isPrimitive(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=c(e[a],a,n,r,u);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;for(let[a,i]of(r.set(e,t),e))t.set(a,c(i,a,n,r,u));return t}if(e instanceof Set){let t=new Set;for(let a of(r.set(e,t),e))t.add(c(a,void 0,n,r,u));return t}if(o.isBuffer(e))return e.subarray();if(s.isTypedArray(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=c(e[a],a,n,r,u);return t}if(e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return r.set(e,t),d(t,e,n,r,u),t}if("u">typeof File&&e instanceof File){let t=new File([e],e.name,{type:e.type});return r.set(e,t),d(t,e,n,r,u),t}if("u">typeof Blob&&e instanceof Blob){let t=new Blob([e],{type:e.type});return r.set(e,t),d(t,e,n,r,u),t}if(e instanceof Error){let t=structuredClone(e);return r.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,d(t,e,n,r,u),t}if(e instanceof Boolean){let t=new Boolean(e.valueOf());return r.set(e,t),d(t,e,n,r,u),t}if(e instanceof Number){let t=new Number(e.valueOf());return r.set(e,t),d(t,e,n,r,u),t}if(e instanceof String){let t=new String(e.valueOf());return r.set(e,t),d(t,e,n,r,u),t}if("object"==typeof e&&function(e){switch(a.getTag(e)){case i.argumentsTag:case i.arrayTag:case i.arrayBufferTag:case i.dataViewTag:case i.booleanTag:case i.dateTag:case i.float32ArrayTag:case i.float64ArrayTag:case i.int8ArrayTag:case i.int16ArrayTag:case i.int32ArrayTag:case i.mapTag:case i.numberTag:case i.objectTag:case i.regexpTag:case i.setTag:case i.stringTag:case i.symbolTag:case i.uint8ArrayTag:case i.uint8ClampedArrayTag:case i.uint16ArrayTag:case i.uint32ArrayTag:return!0;default:return!1}}(e)){let t=Object.create(Object.getPrototypeOf(e));return r.set(e,t),d(t,e,n,r,u),t}return e}function d(e,t,n=e,a,i){let o=[...Object.keys(t),...r.getSymbols(t)];for(let r=0;r<o.length;r++){let l=o[r],s=Object.getOwnPropertyDescriptor(e,l);(null==s||s.writable)&&(e[l]=c(t[l],l,n,a,i))}}n.cloneDeepWith=function(e,t){return c(e,void 0,e,new Map,t)},n.cloneDeepWithImpl=c,n.copyProperties=d},73002,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(65241);n.cloneDeep=function(e){return r.cloneDeepWithImpl(e,void 0,e,new Map,void 0)}},143,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(86949),a=e.r(73002);n.matches=function(e){return e=a.cloneDeep(e),t=>r.isMatch(t,e)}},15479,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(65241),a=e.r(42064),i=e.r(88530);n.cloneDeepWith=function(e,t){return r.cloneDeepWith(e,(n,o,l,s)=>{let c=t?.(n,o,l,s);if(void 0!==c)return c;if("object"==typeof e){if(a.getTag(e)===i.objectTag&&"function"!=typeof e.constructor){let t={};return s.set(e,t),r.copyProperties(t,e,l,s),t}switch(Object.prototype.toString.call(e)){case i.numberTag:case i.stringTag:case i.booleanTag:{let t=new e.constructor(e?.valueOf());return r.copyProperties(t,e),t}case i.argumentsTag:{let t={};return r.copyProperties(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}},13109,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(15479);n.cloneDeep=function(e){return r.cloneDeepWith(e)}},14691,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(42064);n.isArguments=function(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===r.getTag(e)}},93145,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(73782),a=e.r(77141),i=e.r(14691),o=e.r(91945);n.has=function(e,t){let n;if(0===(n=Array.isArray(t)?t:"string"==typeof t&&r.isDeepKey(t)&&e?.[t]==null?o.toPath(t):[t]).length)return!1;let l=e;for(let e=0;e<n.length;e++){let t=n[e];if((null==l||!Object.hasOwn(l,t))&&!((Array.isArray(l)||i.isArguments(l))&&a.isIndex(t)&&t<l.length))return!1;l=l[t]}return!0}},70620,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(86949),a=e.r(47987),i=e.r(13109),o=e.r(59528),l=e.r(93145);n.matchesProperty=function(e,t){switch(typeof e){case"object":Object.is(e?.valueOf(),-0)&&(e="-0");break;case"number":e=a.toKey(e)}return t=i.cloneDeep(t),function(n){let a=o.get(n,e);return void 0===a?l.has(n,e):void 0===t?void 0===a:r.isMatch(a,t)}}},30423,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(8478),a=e.r(85912),i=e.r(143),o=e.r(70620);n.iteratee=function(e){if(null==e)return r.identity;switch(typeof e){case"function":return e;case"object":if(Array.isArray(e)&&2===e.length)return o.matchesProperty(e[0],e[1]);return i.matches(e);case"string":case"symbol":case"number":return a.property(e)}}},19022,(e,t,n)=>{"use strict";Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});let r=e.r(47063),a=e.r(62192),i=e.r(8478),o=e.r(39600),l=e.r(30423);n.uniqBy=function(e,t=i.identity){return o.isArrayLikeObject(e)?r.uniqBy(Array.from(e),a.ary(l.iteratee(t),1)):[]}},7602,(e,t,n)=>{t.exports=e.r(19022).uniqBy},66204,e=>{"use strict";let t,n,r,a,i,o,l,s,c,d;var u,f,h,p,m,g,v,x,y,b,w,j,k,S,N,C,M,E,O,P,A,I,z,T,D,_,R,L,$,F,B,V,H,U,W,q,K,G,X,Y,Z,J,Q,ee,et,en,er,ea,ei,eo,el,es,ec,ed,eu,ef,eh,ep,em,eg,ev,ex,ey=e.i(87433),eb=e.i(17141),ew=e.i(44440),ej=e.i(77380),ek=e.i(97012);let eS=(0,ek.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),eN=(0,ek.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),eC=(0,ek.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),eM=(0,ek.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),eE=(0,ek.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),eO=(0,ek.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),eP=(0,ek.default)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);var eA=e.i(81831),eI=e.i(32137);function ez({className:e,type:t,...n}){return(0,ey.jsx)("input",{type:t,"data-slot":"input",className:(0,eI.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...n})}let eT="8780";function eD(e){var t;let{protocol:n,hostname:r,port:a}=window.location;if(""===a||a===eT)return e;let i="0.0.0.0"===(t=r)||"::"===t?"127.0.0.1":t.includes(":")?`[${t}]`:t;return`${n}//${i}:${eT}${e}`}async function e_(){try{let e=await fetch(eD("/v1/dev-servers"),{cache:"no-store"});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.urls)?t.urls:[]}catch{return[]}}let eR=eb.default.env.NEXT_PUBLIC_HUB_URL??"http://vanta.timefiles.online",eL={token:"vtl_hub_token",user:"vtl_hub_user",machine:"vtl_hub_machine",machineToken:"vtl_hub_machine_jwt"};class e$ extends Error{status;constructor(e,t){super(t),this.status=e,this.name="HubApiError"}}async function eF(e,t={}){let{method:n="GET",body:r,token:a}=t,i={"Content-Type":"application/json"};a&&(i.Authorization=`Bearer ${a}`);let o=await fetch(`${eR}${e}`,{method:n,headers:i,body:r?JSON.stringify(r):void 0});if(!o.ok){let e=await o.json().catch(()=>({}));throw new e$(o.status,e.error||o.statusText)}return o.json()}function eB(e){localStorage.setItem(eL.token,e)}function eV(){return localStorage.getItem(eL.token)}function eH(e){localStorage.setItem(eL.user,JSON.stringify(e))}function eU(e){localStorage.setItem(eL.machine,JSON.stringify(e))}function eW(){try{let e=localStorage.getItem(eL.machine);return e?JSON.parse(e):null}catch{return null}}function eq(){Object.values(eL).forEach(e=>localStorage.removeItem(e))}async function eK(e,t){let n=await eF("/api/auth/login",{method:"POST",body:{email:e,password:t}});return eB(n.token),eH(n.user),n}async function eG(e,t,n){let r=await eF("/api/auth/register",{method:"POST",body:{name:e,email:t,password:n}});return eB(r.token),eH(r.user),r}async function eX(){let e=eV();if(!e)throw new e$(401,"not authenticated");return eF("/api/auth/me",{token:e})}async function eY(){try{let e=eD("/v1/hub/status"),t=await fetch(e);if(!t.ok)return null;let n=await t.json();return{hardwareId:n.hardwareId??null,name:n.name??null,localIp:n.localIp??null}}catch{return null}}async function eZ(){var e;let t,n,r,a,i=eV();if(!i)throw new e$(401,"not authenticated");let o=await eY(),l=o?.hardwareId??null;if(!l){let e=eW(),t=localStorage.getItem(eL.machineToken);if(e&&t)return{machine:e,token:t}}let{deviceToken:s}=await eF("/api/machines/token",{method:"POST",token:i}),c=(t=navigator.userAgent.toLowerCase(),n="unknown",t.includes("win")?n="windows":t.includes("mac")?n="darwin":t.includes("linux")&&(n="linux"),r="amd64","userAgentData"in navigator&&"arm"===navigator.userAgentData.architecture&&(r="arm64"),a=window.location.hostname,{name:o?.name?.trim()||`${n}-${a}`,platform:n,arch:r,localIp:o?.localIp?.trim()??""}),d=await eF("/api/connect",{method:"POST",body:{deviceToken:s,hardwareId:l??void 0,...c}});return eU(d.machine),e=d.token,localStorage.setItem(eL.machineToken,e),d}async function eJ(e="online"){let t=eV(),n=eW();if(t&&n)try{await eF("/api/machines/heartbeat",{method:"POST",token:t,body:{machineId:n.id,status:e,publicIp:null}})}catch{}}async function eQ(){let e=eV(),t=eW();e&&t&&await eF(`/api/machines/${t.id}`,{method:"DELETE",token:e})}async function e0(e){let t=eV(),n=eW();if(!t||!n)throw new e$(401,"not authenticated");let r=await eF(`/api/machines/${n.id}`,{method:"PUT",token:t,body:{name:e}});return eU({...n,name:r.name}),r.name}async function e1(e,t){let n=eV();if(!n)throw new e$(401,"not authenticated");return eF("/api/auth/password",{method:"POST",token:n,body:{currentPassword:e,newPassword:t}})}async function e2(){let e=eV(),t=eW();if(e)try{let n=eD("/v1/hub/connect");await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hubUrl:eR,hubToken:e,machineId:t?.id??void 0})})}catch{}}async function e5(){try{let e=await fetch(eD("/v1/preferences/export"));if(!e.ok)return!1;let t=await e.json();if((t?.modelRoutes?.length??0)!==0||t?.agentIsDefault!==!0)return!1;let n=await fetch(eD("/v1/remote/machines"));if(!n.ok)return!1;let{machines:r}=await n.json();for(let e of(r??[]).filter(e=>!e.isLocal&&"online"===e.status))try{let t=await fetch(eD(`/v1/remote/${e.id}/preferences/export`));if(!t.ok)continue;let n=await t.json();if(!((n?.modelRoutes?.length??0)>0||n?.agentIsDefault===!1))continue;return await fetch(eD("/v1/preferences/adopt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),!0}catch{}}catch{}return!1}function e4(e,t=2){return`$${(e/1e6).toFixed(t)}`}function e3(){let e=eV();if(!e)throw new e$(401,"not authenticated");return e}async function e6(){return eF("/api/billing/balance",{token:e3()})}async function e8(e,t){let n=new URLSearchParams({range:e});return t&&n.set("model",t),eF(`/api/billing/usage?${n.toString()}`,{token:e3()})}async function e7(e){return eF("/api/billing/redeem",{method:"POST",token:e3(),body:{code:e}})}async function e9(){return eF("/api/models/catalog",{token:e3()})}async function te(e){return eF("/api/issues",{method:"POST",token:e3(),body:e})}async function tt(){return eF("/api/issues",{token:e3()})}async function tn(e,t){let n=e3(),r=new FormData;r.append("image",t);let a=await fetch(`${eR}/api/issues/${e}/images`,{method:"POST",headers:{Authorization:`Bearer ${n}`},body:r});if(!a.ok){let e=await a.json().catch(()=>({}));throw new e$(a.status,e.error||a.statusText)}return a.json()}async function tr(e,t){let n=e3(),r=await fetch(`${eR}/api/issues/${e}/images/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!r.ok){let e=await r.json().catch(()=>({}));throw new e$(r.status,e.error||r.statusText)}let a=await r.blob();return URL.createObjectURL(a)}function ta({onComplete:e}){let[t,n]=ew.useState("login"),[r,a]=ew.useState(!1),[i,o]=ew.useState(!1),[l,s]=ew.useState(""),[c,d]=ew.useState("idle"),u="register"===t;async function f(t){t.preventDefault(),s(""),o(!0);let n=new FormData(t.currentTarget),r=n.get("email").trim(),a=n.get("password");if(!r||!a){s("请填写完整信息"),o(!1);return}try{if(d("auth"),u){let e=n.get("name").trim();if(!e){s("请填写显示名称"),o(!1),d("idle");return}await eG(e,r,a)}else await eK(r,a);d("register-machine");try{await eZ(),await eJ("online")}catch{}e()}catch(e){e instanceof e$?401===e.status?s("邮箱或密码错误"):409===e.status?s("该邮箱已注册,请直接登录"):s(e.message||"操作失败,请重试"):s("无法连接到 Vantaloom Hub,请检查网络"),d("idle")}finally{o(!1)}}return(0,ey.jsx)("main",{className:"grid min-h-svh place-items-center bg-background p-4 text-foreground",children:(0,ey.jsxs)("section",{className:"w-full max-w-sm",children:[(0,ey.jsxs)("div",{className:"mb-8 flex flex-col items-center text-center",children:[(0,ey.jsx)("div",{className:"flex size-12 items-center justify-center rounded-2xl bg-primary/10",children:(0,ey.jsx)(eC,{className:"size-6 text-primary"})}),(0,ey.jsx)("h1",{className:"mt-4 text-xl font-semibold tracking-tight",children:"连接到 Vantaloom Hub"}),(0,ey.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"登录你的 Hub 账户以启用云端同步和多机协同"})]}),(0,ey.jsxs)("div",{className:"rounded-xl border bg-background p-5 shadow-md shadow-black/5",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:u?"注册新账户":"登录"}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>{n(u?"login":"register"),s("")},children:u?"已有账户":"注册新账户"})]}),l&&(0,ey.jsxs)("div",{className:"mt-4 flex items-start gap-2 rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive",children:[(0,ey.jsx)(eE,{className:"mt-0.5 size-4 shrink-0"}),(0,ey.jsx)("span",{children:l})]}),(0,ey.jsxs)("form",{className:"mt-5 grid gap-3.5",onSubmit:f,children:[u&&(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"显示名称"}),(0,ey.jsx)(ez,{name:"name",placeholder:"你的名字",autoComplete:"name",disabled:i})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"邮箱"}),(0,ey.jsx)(ez,{name:"email",type:"email",placeholder:"name@example.com",autoComplete:"email",disabled:i})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsxs)("span",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"密码"}),!u&&(0,ey.jsx)(eA.Button,{type:"button",variant:"link",size:"xs",className:"h-auto px-0 text-muted-foreground hover:text-foreground",children:"忘记密码?"})]}),(0,ey.jsxs)("span",{className:"relative",children:[(0,ey.jsx)(ez,{name:"password",type:r?"text":"password",placeholder:u?"至少 8 位字符":"",className:"pr-9",autoComplete:u?"new-password":"current-password",disabled:i}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"显示密码",className:"absolute top-0.5 right-0.5",onClick:()=>a(e=>!e),children:r?(0,ey.jsx)(eN,{}):(0,ey.jsx)(eS,{})})]})]}),(0,ey.jsx)(eA.Button,{type:"submit",className:"mt-2 w-full",disabled:i,children:i?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"auth"===c?"正在验证身份...":"正在注册设备..."]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ej.ArrowRightIcon,{}),u?"注册并连接":"登录并连接"]})})]}),(0,ey.jsxs)("div",{className:"mt-5 space-y-2.5 rounded-lg bg-muted/50 p-3.5",children:[(0,ey.jsxs)("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,ey.jsx)(eO,{className:"mt-0.5 size-3.5 shrink-0 text-primary"}),(0,ey.jsx)("span",{children:"登录后自动将此设备注册到你的 Hub 账户"})]}),(0,ey.jsxs)("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,ey.jsx)(eP,{className:"mt-0.5 size-3.5 shrink-0 text-primary"}),(0,ey.jsx)("span",{children:"在 Hub 控制台中管理和监控所有已连接的设备"})]})]})]}),(0,ey.jsxs)("p",{className:"mt-4 text-center text-xs text-muted-foreground/60",children:["Hub 地址:",eb.default.env.NEXT_PUBLIC_HUB_URL??"vanta.timefiles.online"]})]})})}let ti=ew.createContext(null);function to({children:e}){let[t,n]=ew.useState({ready:!1,user:null,machine:null});ew.useEffect(()=>{eV()?eX().then(async e=>{eH(e);let t=eW();try{t=(await eZ()).machine}catch{}n({ready:!0,user:e,machine:t}),e2()}).catch(e=>{if(e instanceof e$&&[401,403,404].includes(e.status)){eq(),n({ready:!0,user:null,machine:null});return}let t=function(){try{let e=localStorage.getItem(eL.user);return e?JSON.parse(e):null}catch{return null}}(),r=eW();t?n({ready:!0,user:t,machine:r}):n({ready:!0,user:null,machine:null})}):n({ready:!0,user:null,machine:null})},[]),ew.useEffect(()=>{if(!t.user||!t.machine)return;eJ("online");let e=setTimeout(()=>{e5()},4e3),n=setInterval(()=>{eJ("online")},3e5);function r(){eJ("offline")}return window.addEventListener("beforeunload",r),()=>{clearInterval(n),clearTimeout(e),window.removeEventListener("beforeunload",r)}},[t.user,t.machine]);let r=ew.useCallback(async()=>{await eJ("offline"),eq(),n({ready:!0,user:null,machine:null})},[]),a=ew.useCallback(async()=>{try{await eQ()}catch{}await r()},[r]),i=ew.useCallback(async()=>{try{let e=await eX();eH(e);let t=eW();n(n=>({...n,user:e,machine:t}))}catch{}},[]),o=ew.useMemo(()=>({...t,logout:r,unbind:a,refreshUser:i}),[t,r,a,i]);return(0,ey.jsx)(ti.Provider,{value:o,children:e})}function tl(){let e=ew.useContext(ti);if(!e)throw Error("useHubAuth must be used within a HubAuthProvider");return e}let ts=(0,ek.default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),tc=(0,ek.default)("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]),td=(0,ek.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]),tu=(0,ek.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);function tf(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)""!==(r=tf(e[n]))&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var th={value:()=>{}};function tp(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw Error("illegal type: "+e);r[e]=[]}return new tm(r)}function tm(e){this._=e}function tg(e,t,n){for(var r=0,a=e.length;r<a;++r)if(e[r].name===t){e[r]=th,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}function tv(){}function tx(e){return null==e?tv:function(){return this.querySelector(e)}}function ty(){return[]}function tb(e){return null==e?ty:function(){return this.querySelectorAll(e)}}function tw(e){return function(){return this.matches(e)}}function tj(e){return function(t){return t.matches(e)}}tm.prototype=tp.prototype={constructor:tm,on:function(e,t){var n,r=this._,a=(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!r.hasOwnProperty(e))throw Error("unknown type: "+e);return{type:e,name:t}}),i=-1,o=a.length;if(arguments.length<2){for(;++i<o;)if((n=(e=a[i]).type)&&(n=function(e,t){for(var n,r=0,a=e.length;r<a;++r)if((n=e[r]).name===t)return n.value}(r[n],e.name)))return n;return}if(null!=t&&"function"!=typeof t)throw Error("invalid callback: "+t);for(;++i<o;)if(n=(e=a[i]).type)r[n]=tg(r[n],e.name,t);else if(null==t)for(n in r)r[n]=tg(r[n],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new tm(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,a=Array(n),i=0;i<n;++i)a[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(r=this._[e],i=0,n=r.length;i<n;++i)r[i].value.apply(t,a)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(var r=this._[e],a=0,i=r.length;a<i;++a)r[a].value.apply(t,n)}};var tk=Array.prototype.find;function tS(){return this.firstElementChild}var tN=Array.prototype.filter;function tC(){return Array.from(this.children)}function tM(e){return Array(e.length)}function tE(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function tO(e,t,n,r,a,i){for(var o,l=0,s=t.length,c=i.length;l<c;++l)(o=t[l])?(o.__data__=i[l],r[l]=o):n[l]=new tE(e,i[l]);for(;l<s;++l)(o=t[l])&&(a[l]=o)}function tP(e,t,n,r,a,i,o){var l,s,c,d=new Map,u=t.length,f=i.length,h=Array(u);for(l=0;l<u;++l)(s=t[l])&&(h[l]=c=o.call(s,s.__data__,l,t)+"",d.has(c)?a[l]=s:d.set(c,s));for(l=0;l<f;++l)c=o.call(e,i[l],l,i)+"",(s=d.get(c))?(r[l]=s,s.__data__=i[l],d.delete(c)):n[l]=new tE(e,i[l]);for(l=0;l<u;++l)(s=t[l])&&d.get(h[l])===s&&(a[l]=s)}function tA(e){return e.__data__}function tI(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}tE.prototype={constructor:tE,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};var tz="http://www.w3.org/1999/xhtml";let tT={svg:"http://www.w3.org/2000/svg",xhtml:tz,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function tD(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),tT.hasOwnProperty(t)?{space:tT[t],local:e}:e}function t_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tR(e,t){return e.style.getPropertyValue(t)||t_(e).getComputedStyle(e,null).getPropertyValue(t)}function tL(e){return e.trim().split(/^|\s+/)}function t$(e){return e.classList||new tF(e)}function tF(e){this._node=e,this._names=tL(e.getAttribute("class")||"")}function tB(e,t){for(var n=t$(e),r=-1,a=t.length;++r<a;)n.add(t[r])}function tV(e,t){for(var n=t$(e),r=-1,a=t.length;++r<a;)n.remove(t[r])}function tH(){this.textContent=""}function tU(){this.innerHTML=""}function tW(){this.nextSibling&&this.parentNode.appendChild(this)}function tq(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tK(e){var t=tD(e);return(t.local?function(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}:function(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===tz&&t.documentElement.namespaceURI===tz?t.createElement(e):t.createElementNS(n,e)}})(t)}function tG(){return null}function tX(){var e=this.parentNode;e&&e.removeChild(this)}function tY(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tZ(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tJ(e){return function(){var t=this.__on;if(t){for(var n,r=0,a=-1,i=t.length;r<i;++r)(n=t[r],e.type&&n.type!==e.type||n.name!==e.name)?t[++a]=n:this.removeEventListener(n.type,n.listener,n.options);++a?t.length=a:delete this.__on}}}function tQ(e,t,n){return function(){var r,a=this.__on,i=function(e){t.call(this,e,this.__data__)};if(a){for(var o=0,l=a.length;o<l;++o)if((r=a[o]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},a?a.push(r):this.__on=[r]}}function t0(e,t,n){var r=t_(e),a=r.CustomEvent;"function"==typeof a?a=new a(t,n):(a=r.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}tF.prototype={add:function(e){0>this._names.indexOf(e)&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var t1=[null];function t2(e,t){this._groups=e,this._parents=t}function t5(){return new t2([[document.documentElement]],t1)}function t4(e){return"string"==typeof e?new t2([[document.querySelector(e)]],[document.documentElement]):new t2([[e]],t1)}function t3(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}t2.prototype=t5.prototype={constructor:t2,select:function(e){"function"!=typeof e&&(e=tx(e));for(var t=this._groups,n=t.length,r=Array(n),a=0;a<n;++a)for(var i,o,l=t[a],s=l.length,c=r[a]=Array(s),d=0;d<s;++d)(i=l[d])&&(o=e.call(i,i.__data__,d,l))&&("__data__"in i&&(o.__data__=i.__data__),c[d]=o);return new t2(r,this._parents)},selectAll:function(e){if("function"==typeof e){var t;t=e,e=function(){var e;return e=t.apply(this,arguments),null==e?[]:Array.isArray(e)?e:Array.from(e)}}else e=tb(e);for(var n=this._groups,r=n.length,a=[],i=[],o=0;o<r;++o)for(var l,s=n[o],c=s.length,d=0;d<c;++d)(l=s[d])&&(a.push(e.call(l,l.__data__,d,s)),i.push(l));return new t2(a,i)},selectChild:function(e){var t;return this.select(null==e?tS:(t="function"==typeof e?e:tj(e),function(){return tk.call(this.children,t)}))},selectChildren:function(e){var t;return this.selectAll(null==e?tC:(t="function"==typeof e?e:tj(e),function(){return tN.call(this.children,t)}))},filter:function(e){"function"!=typeof e&&(e=tw(e));for(var t=this._groups,n=t.length,r=Array(n),a=0;a<n;++a)for(var i,o=t[a],l=o.length,s=r[a]=[],c=0;c<l;++c)(i=o[c])&&e.call(i,i.__data__,c,o)&&s.push(i);return new t2(r,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,tA);var n=t?tP:tO,r=this._parents,a=this._groups;"function"!=typeof e&&(x=e,e=function(){return x});for(var i=a.length,o=Array(i),l=Array(i),s=Array(i),c=0;c<i;++c){var d=r[c],u=a[c],f=u.length,h="object"==typeof(v=e.call(d,d&&d.__data__,c,r))&&"length"in v?v:Array.from(v),p=h.length,m=l[c]=Array(p),g=o[c]=Array(p);n(d,u,m,g,s[c]=Array(f),h,t);for(var v,x,y,b,w=0,j=0;w<p;++w)if(y=m[w]){for(w>=j&&(j=w+1);!(b=g[j])&&++j<p;);y._next=b||null}}return(o=new t2(o,r))._enter=l,o._exit=s,o},enter:function(){return new t2(this._enter||this._groups.map(tM),this._parents)},exit:function(){return new t2(this._exit||this._groups.map(tM),this._parents)},join:function(e,t,n){var r=this.enter(),a=this,i=this.exit();return"function"==typeof e?(r=e(r))&&(r=r.selection()):r=r.append(e+""),null!=t&&(a=t(a))&&(a=a.selection()),null==n?i.remove():n(i),r&&a?r.merge(a).order():a},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,a=n.length,i=r.length,o=Math.min(a,i),l=Array(a),s=0;s<o;++s)for(var c,d=n[s],u=r[s],f=d.length,h=l[s]=Array(f),p=0;p<f;++p)(c=d[p]||u[p])&&(h[p]=c);for(;s<a;++s)l[s]=n[s];return new t2(l,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r,a=e[t],i=a.length-1,o=a[i];--i>=0;)(r=a[i])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=tI);for(var n=this._groups,r=n.length,a=Array(r),i=0;i<r;++i){for(var o,l=n[i],s=l.length,c=a[i]=Array(s),d=0;d<s;++d)(o=l[d])&&(c[d]=o);c.sort(t)}return new t2(a,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],a=0,i=r.length;a<i;++a){var o=r[a];if(o)return o}return null},size:function(){let e=0;for(let t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var a,i=t[n],o=0,l=i.length;o<l;++o)(a=i[o])&&e.call(a,a.__data__,o,i);return this},attr:function(e,t){var n=tD(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==t?n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}}:"function"==typeof t?n.local?function(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}:function(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}:n.local?function(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}:function(e,t){return function(){this.setAttribute(e,t)}})(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?function(e){return function(){this.style.removeProperty(e)}}:"function"==typeof t?function(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}:function(e,t,n){return function(){this.style.setProperty(e,t,n)}})(e,t,null==n?"":n)):tR(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?function(e){return function(){delete this[e]}}:"function"==typeof t?function(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}:function(e,t){return function(){this[e]=t}})(e,t)):this.node()[e]},classed:function(e,t){var n=tL(e+"");if(arguments.length<2){for(var r=t$(this.node()),a=-1,i=n.length;++a<i;)if(!r.contains(n[a]))return!1;return!0}return this.each(("function"==typeof t?function(e,t){return function(){(t.apply(this,arguments)?tB:tV)(this,e)}}:t?function(e){return function(){tB(this,e)}}:function(e){return function(){tV(this,e)}})(n,t))},text:function(e){return arguments.length?this.each(null==e?tH:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}:function(e){return function(){this.textContent=e}})(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?tU:("function"==typeof e?function(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}:function(e){return function(){this.innerHTML=e}})(e)):this.node().innerHTML},raise:function(){return this.each(tW)},lower:function(){return this.each(tq)},append:function(e){var t="function"==typeof e?e:tK(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})},insert:function(e,t){var n="function"==typeof e?e:tK(e),r=null==t?tG:"function"==typeof t?t:tx(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(tX)},clone:function(e){return this.select(e?tZ:tY)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var r,a,i=(e+"").trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}),o=i.length;if(arguments.length<2){var l=this.node().__on;if(l){for(var s,c=0,d=l.length;c<d;++c)for(r=0,s=l[c];r<o;++r)if((a=i[r]).type===s.type&&a.name===s.name)return s.value}return}for(r=0,l=t?tQ:tJ;r<o;++r)this.each(l(i[r],t,n));return this},dispatch:function(e,t){return this.each(("function"==typeof t?function(e,t){return function(){return t0(this,e,t.apply(this,arguments))}}:function(e,t){return function(){return t0(this,e,t)}})(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r,a=e[t],i=0,o=a.length;i<o;++i)(r=a[i])&&(yield r)}};let t6={passive:!1},t8={capture:!0,passive:!1};function t7(e){e.stopImmediatePropagation()}function t9(e){e.preventDefault(),e.stopImmediatePropagation()}function ne(e){var t=e.document.documentElement,n=t4(e).on("dragstart.drag",t9,t8);"onselectstart"in t?n.on("selectstart.drag",t9,t8):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nt(e,t){var n=e.document.documentElement,r=t4(e).on("dragstart.drag",null);t&&(r.on("click.drag",t9,t8),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}let nn=e=>()=>e;function nr(e,{sourceEvent:t,subject:n,target:r,identifier:a,active:i,x:o,y:l,dx:s,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:s,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function na(e){return!e.ctrlKey&&!e.button}function ni(){return this.parentNode}function no(e,t){return null==t?{x:e.x,y:e.y}:t}function nl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ns(){var e,t,n,r,a=na,i=ni,o=no,l=nl,s={},c=tp("start","drag","end"),d=0,u=0;function f(e){e.on("mousedown.drag",h).filter(l).on("touchstart.drag",g).on("touchmove.drag",v,t6).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(o,l){if(!r&&a.call(this,o,l)){var s=y(this,i.call(this,o,l),o,l,"mouse");s&&(t4(o.view).on("mousemove.drag",p,t8).on("mouseup.drag",m,t8),ne(o.view),t7(o),n=!1,e=o.clientX,t=o.clientY,s("start",o))}}function p(r){if(t9(r),!n){var a=r.clientX-e,i=r.clientY-t;n=a*a+i*i>u}s.mouse("drag",r)}function m(e){t4(e.view).on("mousemove.drag mouseup.drag",null),nt(e.view,n),t9(e),s.mouse("end",e)}function g(e,t){if(a.call(this,e,t)){var n,r,o=e.changedTouches,l=i.call(this,e,t),s=o.length;for(n=0;n<s;++n)(r=y(this,l,e,t,o[n].identifier,o[n]))&&(t7(e),r("start",e,o[n]))}}function v(e){var t,n,r=e.changedTouches,a=r.length;for(t=0;t<a;++t)(n=s[r[t].identifier])&&(t9(e),n("drag",e,r[t]))}function x(e){var t,n,a=e.changedTouches,i=a.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),t=0;t<i;++t)(n=s[a[t].identifier])&&(t7(e),n("end",e,a[t]))}function y(e,t,n,r,a,i){var l,u,h,p=c.copy(),m=t3(i||n,t);if(null!=(h=o.call(e,new nr("beforestart",{sourceEvent:n,target:f,identifier:a,active:d,x:m[0],y:m[1],dx:0,dy:0,dispatch:p}),r)))return l=h.x-m[0]||0,u=h.y-m[1]||0,function n(i,o,c){var g,v=m;switch(i){case"start":s[a]=n,g=d++;break;case"end":delete s[a],--d;case"drag":m=t3(c||o,t),g=d}p.call(i,e,new nr(i,{sourceEvent:o,subject:h,target:f,identifier:a,active:g,x:m[0]+l,y:m[1]+u,dx:m[0]-v[0],dy:m[1]-v[1],dispatch:p}),r)}}return f.filter=function(e){return arguments.length?(a="function"==typeof e?e:nn(!!e),f):a},f.container=function(e){return arguments.length?(i="function"==typeof e?e:nn(e),f):i},f.subject=function(e){return arguments.length?(o="function"==typeof e?e:nn(e),f):o},f.touchable=function(e){return arguments.length?(l="function"==typeof e?e:nn(!!e),f):l},f.on=function(){var e=c.on.apply(c,arguments);return e===c?f:e},f.clickDistance=function(e){return arguments.length?(u=(e*=1)*e,f):Math.sqrt(u)},f}function nc(e){return((e=Math.exp(e))+1/e)/2}nr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};let nd=function e(t,n,r){function a(e,a){var i,o,l=e[0],s=e[1],c=e[2],d=a[0],u=a[1],f=a[2],h=d-l,p=u-s,m=h*h+p*p;if(m<1e-12)o=Math.log(f/c)/t,i=function(e){return[l+e*h,s+e*p,c*Math.exp(t*e*o)]};else{var g=Math.sqrt(m),v=(f*f-c*c+r*m)/(2*c*n*g),x=(f*f-c*c-r*m)/(2*f*n*g),y=Math.log(Math.sqrt(v*v+1)-v);o=(Math.log(Math.sqrt(x*x+1)-x)-y)/t,i=function(e){var r,a,i=e*o,d=nc(y),u=c/(n*g)*(d*(((r=Math.exp(2*(r=t*i+y)))-1)/(r+1))-((a=Math.exp(a=y))-1/a)/2);return[l+u*h,s+u*p,c*d/nc(t*i+y)]}}return i.duration=1e3*o*t/Math.SQRT2,i}return a.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},a}(Math.SQRT2,2,4);var nu,nf,nh=0,np=0,nm=0,ng=0,nv=0,nx=0,ny="object"==typeof performance&&performance.now?performance:Date,nb="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function nw(){return nv||(nb(nj),nv=ny.now()+nx)}function nj(){nv=0}function nk(){this._call=this._time=this._next=null}function nS(e,t,n){var r=new nk;return r.restart(e,t,n),r}function nN(){nv=(ng=ny.now())+nx,nh=np=0;try{nw(),++nh;for(var e,t=nu;t;)(e=nv-t._time)>=0&&t._call.call(void 0,e),t=t._next;--nh}finally{nh=0,function(){for(var e,t,n=nu,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:nu=t);nf=e,nM(r)}(),nv=0}}function nC(){var e=ny.now(),t=e-ng;t>1e3&&(nx-=t,ng=e)}function nM(e){!nh&&(np&&(np=clearTimeout(np)),e-nv>24?(e<1/0&&(np=setTimeout(nN,e-ny.now()-nx)),nm&&(nm=clearInterval(nm))):(nm||(ng=ny.now(),nm=setInterval(nC,1e3)),nh=1,nb(nN)))}function nE(e,t,n){var r=new nk;return t=null==t?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}nk.prototype=nS.prototype={constructor:nk,restart:function(e,t,n){if("function"!=typeof e)throw TypeError("callback is not a function");n=(null==n?nw():+n)+(null==t?0:+t),this._next||nf===this||(nf?nf._next=this:nu=this,nf=this),this._call=e,this._time=n,nM()},stop:function(){this._call&&(this._call=null,this._time=1/0,nM())}};var nO=tp("start","end","cancel","interrupt"),nP=[];function nA(e,t,n,r,a,i){var o=e.__transition;if(o){if(n in o)return}else e.__transition={};!function(e,t,n){var r,a=e.__transition;function i(s){var c,d,u,f;if(1!==n.state)return l();for(c in a)if((f=a[c]).name===n.name){if(3===f.state)return nE(i);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete a[c]):+c<t&&(f.state=6,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete a[c])}if(nE(function(){3===n.state&&(n.state=4,n.timer.restart(o,n.delay,n.time),o(s))}),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(c=0,n.state=3,r=Array(u=n.tween.length),d=-1;c<u;++c)(f=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++d]=f);r.length=d+1}}function o(t){for(var a=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=5,1),i=-1,o=r.length;++i<o;)r[i].call(e,a);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete a[t],a)return;delete e.__transition}a[t]=n,n.timer=nS(function(e){n.state=1,n.timer.restart(i,n.delay,n.time),n.delay<=e&&i(e-n.delay)},0,n.time)}(e,n,{name:t,index:r,group:a,on:nO,tween:nP,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:0})}function nI(e,t){var n=nT(e,t);if(n.state>0)throw Error("too late; already scheduled");return n}function nz(e,t){var n=nT(e,t);if(n.state>3)throw Error("too late; already running");return n}function nT(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error("transition not found");return n}function nD(e,t){var n,r,a,i=e.__transition,o=!0;if(i){for(a in t=null==t?null:t+"",i){if((n=i[a]).name!==t){o=!1;continue}r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[a]}o&&delete e.__transition}}function n_(e,t){return e*=1,t*=1,function(n){return e*(1-n)+t*n}}var nR=180/Math.PI,nL={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function n$(e,t,n,r,a,i){var o,l,s;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(s=e*n+t*r)&&(n-=e*s,r-=t*s),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,s/=l),e*r<t*n&&(e=-e,t=-t,s=-s,o=-o),{translateX:a,translateY:i,rotate:Math.atan2(t,e)*nR,skewX:Math.atan(s)*nR,scaleX:o,scaleY:l}}function nF(e,t,n,r){function a(e){return e.length?e.pop()+" ":""}return function(i,o){var l,s,c,d,u=[],f=[];return i=e(i),o=e(o),!function(e,r,a,i,o,l){if(e!==a||r!==i){var s=o.push("translate(",null,t,null,n);l.push({i:s-4,x:n_(e,a)},{i:s-2,x:n_(r,i)})}else(a||i)&&o.push("translate("+a+t+i+n)}(i.translateX,i.translateY,o.translateX,o.translateY,u,f),l=i.rotate,s=o.rotate,l!==s?(l-s>180?s+=360:s-l>180&&(l+=360),f.push({i:u.push(a(u)+"rotate(",null,r)-2,x:n_(l,s)})):s&&u.push(a(u)+"rotate("+s+r),c=i.skewX,d=o.skewX,c!==d?f.push({i:u.push(a(u)+"skewX(",null,r)-2,x:n_(c,d)}):d&&u.push(a(u)+"skewX("+d+r),!function(e,t,n,r,i,o){if(e!==n||t!==r){var l=i.push(a(i)+"scale(",null,",",null,")");o.push({i:l-4,x:n_(e,n)},{i:l-2,x:n_(t,r)})}else(1!==n||1!==r)&&i.push(a(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,o.scaleX,o.scaleY,u,f),i=o=null,function(e){for(var t,n=-1,r=f.length;++n<r;)u[(t=f[n]).i]=t.x(e);return u.join("")}}}var nB=nF(function(e){let t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?nL:n$(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),nV=nF(function(e){return null==e?nL:(P||(P=document.createElementNS("http://www.w3.org/2000/svg","g")),P.setAttribute("transform",e),e=P.transform.baseVal.consolidate())?n$((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):nL},", ",")",")");function nH(e,t,n){var r=e._id;return e.each(function(){var e=nz(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)}),function(e){return nT(e,r).value[t]}}function nU(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function nW(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function nq(){}var nK="\\s*([+-]?\\d+)\\s*",nG="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",nX="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nY=/^#([0-9a-f]{3,8})$/,nZ=RegExp(`^rgb\\(${nK},${nK},${nK}\\)$`),nJ=RegExp(`^rgb\\(${nX},${nX},${nX}\\)$`),nQ=RegExp(`^rgba\\(${nK},${nK},${nK},${nG}\\)$`),n0=RegExp(`^rgba\\(${nX},${nX},${nX},${nG}\\)$`),n1=RegExp(`^hsl\\(${nG},${nX},${nX}\\)$`),n2=RegExp(`^hsla\\(${nG},${nX},${nX},${nG}\\)$`),n5={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function n4(){return this.rgb().formatHex()}function n3(){return this.rgb().formatRgb()}function n6(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=nY.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?n8(t):3===n?new re(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?n7(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?n7(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=nZ.exec(e))?new re(t[1],t[2],t[3],1):(t=nJ.exec(e))?new re(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=nQ.exec(e))?n7(t[1],t[2],t[3],t[4]):(t=n0.exec(e))?n7(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=n1.exec(e))?ro(t[1],t[2]/100,t[3]/100,1):(t=n2.exec(e))?ro(t[1],t[2]/100,t[3]/100,t[4]):n5.hasOwnProperty(e)?n8(n5[e]):"transparent"===e?new re(NaN,NaN,NaN,0):null}function n8(e){return new re(e>>16&255,e>>8&255,255&e,1)}function n7(e,t,n,r){return r<=0&&(e=t=n=NaN),new re(e,t,n,r)}function n9(e,t,n,r){var a;return 1==arguments.length?((a=e)instanceof nq||(a=n6(a)),a)?new re((a=a.rgb()).r,a.g,a.b,a.opacity):new re:new re(e,t,n,null==r?1:r)}function re(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function rt(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}`}function rn(){let e=rr(this.opacity);return`${1===e?"rgb(":"rgba("}${ra(this.r)}, ${ra(this.g)}, ${ra(this.b)}${1===e?")":`, ${e})`}`}function rr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ra(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ri(e){return((e=ra(e))<16?"0":"")+e.toString(16)}function ro(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rs(e,t,n,r)}function rl(e){if(e instanceof rs)return new rs(e.h,e.s,e.l,e.opacity);if(e instanceof nq||(e=n6(e)),!e)return new rs;if(e instanceof rs)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,l=i-a,s=(i+a)/2;return l?(o=t===i?(n-r)/l+(n<r)*6:n===i?(r-t)/l+2:(t-n)/l+4,l/=s<.5?i+a:2-i-a,o*=60):l=s>0&&s<1?0:o,new rs(o,l,s,e.opacity)}function rs(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function rc(e){return(e=(e||0)%360)<0?e+360:e}function rd(e){return Math.max(0,Math.min(1,e||0))}function ru(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function rf(e,t,n,r,a){var i=e*e,o=i*e;return((1-3*e+3*i-o)*t+(4-6*i+3*o)*n+(1+3*e+3*i-3*o)*r+o*a)/6}nU(nq,n6,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:n4,formatHex:n4,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return rl(this).formatHsl()},formatRgb:n3,toString:n3}),nU(re,n9,nW(nq,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new re(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new re(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new re(ra(this.r),ra(this.g),ra(this.b),rr(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rt,formatHex:rt,formatHex8:function(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}${ri((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:rn,toString:rn})),nU(rs,function(e,t,n,r){return 1==arguments.length?rl(e):new rs(e,t,n,null==r?1:r)},nW(nq,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new rs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new rs(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,a=2*n-r;return new re(ru(e>=240?e-240:e+120,a,r),ru(e,a,r),ru(e<120?e+240:e-120,a,r),this.opacity)},clamp(){return new rs(rc(this.h),rd(this.s),rd(this.l),rr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=rr(this.opacity);return`${1===e?"hsl(":"hsla("}${rc(this.h)}, ${100*rd(this.s)}%, ${100*rd(this.l)}%${1===e?")":`, ${e})`}`}}));let rh=e=>()=>e;function rp(e,t){var n=t-e;return n?function(t){return e+t*n}:rh(isNaN(e)?t:e)}let rm=function e(t){var n,r=1==(n=+t)?rp:function(e,t){var r,a,i;return t-e?(r=e,a=t,r=Math.pow(r,i=n),a=Math.pow(a,i)-r,i=1/i,function(e){return Math.pow(r+e*a,i)}):rh(isNaN(e)?t:e)};function a(e,t){var n=r((e=n9(e)).r,(t=n9(t)).r),a=r(e.g,t.g),i=r(e.b,t.b),o=rp(e.opacity,t.opacity);return function(t){return e.r=n(t),e.g=a(t),e.b=i(t),e.opacity=o(t),e+""}}return a.gamma=e,a}(1);function rg(e){return function(t){var n,r,a=t.length,i=Array(a),o=Array(a),l=Array(a);for(n=0;n<a;++n)r=n9(t[n]),i[n]=r.r||0,o[n]=r.g||0,l[n]=r.b||0;return i=e(i),o=e(o),l=e(l),r.opacity=1,function(e){return r.r=i(e),r.g=o(e),r.b=l(e),r+""}}}rg(function(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),a=e[r],i=e[r+1],o=r>0?e[r-1]:2*a-i,l=r<t-1?e[r+2]:2*i-a;return rf((n-r/t)*t,o,a,i,l)}}),rg(function(e){var t=e.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*t),a=e[(r+t-1)%t],i=e[r%t],o=e[(r+1)%t],l=e[(r+2)%t];return rf((n-r/t)*t,a,i,o,l)}});var rv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,rx=RegExp(rv.source,"g");function ry(e,t){var n,r,a,i,o,l=rv.lastIndex=rx.lastIndex=0,s=-1,c=[],d=[];for(e+="",t+="";(a=rv.exec(e))&&(i=rx.exec(t));)(o=i.index)>l&&(o=t.slice(l,o),c[s]?c[s]+=o:c[++s]=o),(a=a[0])===(i=i[0])?c[s]?c[s]+=i:c[++s]=i:(c[++s]=null,d.push({i:s,x:n_(a,i)})),l=rx.lastIndex;return l<t.length&&(o=t.slice(l),c[s]?c[s]+=o:c[++s]=o),c.length<2?d[0]?(n=d[0].x,function(e){return n(e)+""}):(r=t,function(){return r}):(t=d.length,function(e){for(var n,r=0;r<t;++r)c[(n=d[r]).i]=n.x(e);return c.join("")})}function rb(e,t){var n;return("number"==typeof t?n_:t instanceof n6?rm:(n=n6(t))?(t=n,rm):ry)(e,t)}var rw=t5.prototype.constructor;function rj(e){return function(){this.style.removeProperty(e)}}var rk=0;function rS(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}var rN=t5.prototype;rS.prototype=(function(e){return t5().transition(e)}).prototype={constructor:rS,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=tx(e));for(var r=this._groups,a=r.length,i=Array(a),o=0;o<a;++o)for(var l,s,c=r[o],d=c.length,u=i[o]=Array(d),f=0;f<d;++f)(l=c[f])&&(s=e.call(l,l.__data__,f,c))&&("__data__"in l&&(s.__data__=l.__data__),u[f]=s,nA(u[f],t,n,f,u,nT(l,n)));return new rS(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=tb(e));for(var r=this._groups,a=r.length,i=[],o=[],l=0;l<a;++l)for(var s,c=r[l],d=c.length,u=0;u<d;++u)if(s=c[u]){for(var f,h=e.call(s,s.__data__,u,c),p=nT(s,n),m=0,g=h.length;m<g;++m)(f=h[m])&&nA(f,t,n,m,h,p);i.push(h),o.push(s)}return new rS(i,o,t,n)},selectChild:rN.selectChild,selectChildren:rN.selectChildren,filter:function(e){"function"!=typeof e&&(e=tw(e));for(var t=this._groups,n=t.length,r=Array(n),a=0;a<n;++a)for(var i,o=t[a],l=o.length,s=r[a]=[],c=0;c<l;++c)(i=o[c])&&e.call(i,i.__data__,c,o)&&s.push(i);return new rS(r,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,a=n.length,i=Math.min(r,a),o=Array(r),l=0;l<i;++l)for(var s,c=t[l],d=n[l],u=c.length,f=o[l]=Array(u),h=0;h<u;++h)(s=c[h]||d[h])&&(f[h]=s);for(;l<r;++l)o[l]=t[l];return new rS(o,this._parents,this._name,this._id)},selection:function(){return new rw(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=++rk,r=this._groups,a=r.length,i=0;i<a;++i)for(var o,l=r[i],s=l.length,c=0;c<s;++c)if(o=l[c]){var d=nT(o,t);nA(o,e,n,c,l,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new rS(r,this._parents,e,n)},call:rN.call,nodes:rN.nodes,node:rN.node,size:rN.size,empty:rN.empty,each:rN.each,on:function(e,t){var n,r,a,i,o,l,s=this._id;return arguments.length<2?nT(this.node(),s).on.on(e):this.each((n=s,r=e,a=t,l=(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e})?nI:nz,function(){var e=l(this,n),t=e.on;t!==i&&(o=(i=t).copy()).on(r,a),e.on=o}))},attr:function(e,t){var n=tD(e),r="transform"===n?nV:rb;return this.attrTween(e,"function"==typeof t?(n.local?function(e,t,n){var r,a,i;return function(){var o,l,s=n(this);return null==s?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local))===(l=s+"")?null:o===r&&l===a?i:(a=l,i=t(r=o,s))}}:function(e,t,n){var r,a,i;return function(){var o,l,s=n(this);return null==s?void this.removeAttribute(e):(o=this.getAttribute(e))===(l=s+"")?null:o===r&&l===a?i:(a=l,i=t(r=o,s))}})(n,r,nH(this,"attr."+e,t)):null==t?(n.local?function(e){return function(){this.removeAttributeNS(e.space,e.local)}}:function(e){return function(){this.removeAttribute(e)}})(n):(n.local?function(e,t,n){var r,a,i=n+"";return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}:function(e,t,n){var r,a,i=n+"";return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}})(n,r,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw Error();var r=tD(e);return this.tween(n,(r.local?function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(t){this.setAttributeNS(e.space,e.local,a.call(this,t))}),n}return a._value=t,a}:function(e,t){var n,r;function a(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&function(t){this.setAttribute(e,a.call(this,t))}),n}return a._value=t,a})(r,t))},style:function(e,t,n){var r,a,i,o,l,s,c,d,u,f,h,p,m,g,v,x,y,b,w,j,k,S="transform"==(e+="")?nB:rb;return null==t?this.styleTween(e,(r=e,function(){var e=tR(this,r),t=(this.style.removeProperty(r),tR(this,r));return e===t?null:e===a&&t===i?o:o=S(a=e,i=t)})).on("end.style."+e,rj(e)):"function"==typeof t?this.styleTween(e,(l=e,s=nH(this,"style."+e,t),function(){var e=tR(this,l),t=s(this),n=t+"";return null==t&&(this.style.removeProperty(l),n=t=tR(this,l)),e===n?null:e===c&&n===d?u:(d=n,u=S(c=e,t))})).each((f=this._id,y="end."+(x="style."+(h=e)),function(){var e=nz(this,f),t=e.on,n=null==e.value[x]?v||(v=rj(h)):void 0;(t!==p||g!==n)&&(m=(p=t).copy()).on(y,g=n),e.on=m})):this.styleTween(e,(b=e,k=t+"",function(){var e=tR(this,b);return e===k?null:e===w?j:j=S(w=e,t)}),n).on("end.style."+e,null)},styleTween:function(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw Error();return this.tween(r,function(e,t,n){var r,a;function i(){var i=t.apply(this,arguments);return i!==a&&(r=(a=i)&&function(t){this.style.setProperty(e,i.call(this,t),n)}),r}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){var t,n;return this.tween("text","function"==typeof e?(t=nH(this,"text",e),function(){var e=t(this);this.textContent=null==e?"":e}):(n=null==e?"":e+"",function(){this.textContent=n}))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw Error();return this.tween(t,function(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&function(e){this.textContent=r.call(this,e)}),t}return r._value=e,r}(e))},remove:function(){var e;return this.on("end.remove",(e=this._id,function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,a=nT(this.node(),n).tween,i=0,o=a.length;i<o;++i)if((r=a[i]).name===e)return r.value;return null}return this.each((null==t?function(e,t){var n,r;return function(){var a=nz(this,e),i=a.tween;if(i!==n){r=n=i;for(var o=0,l=r.length;o<l;++o)if(r[o].name===t){(r=r.slice()).splice(o,1);break}}a.tween=r}}:function(e,t,n){var r,a;if("function"!=typeof n)throw Error();return function(){var i=nz(this,e),o=i.tween;if(o!==r){a=(r=o).slice();for(var l={name:t,value:n},s=0,c=a.length;s<c;++s)if(a[s].name===t){a[s]=l;break}s===c&&a.push(l)}i.tween=a}})(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){nI(this,e).delay=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){nI(this,e).delay=t}})(t,e)):nT(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?function(e,t){return function(){nz(this,e).duration=+t.apply(this,arguments)}}:function(e,t){return t*=1,function(){nz(this,e).duration=t}})(t,e)):nT(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw Error();return function(){nz(this,e).ease=t}}(t,e)):nT(this.node(),t).ease},easeVarying:function(e){var t;if("function"!=typeof e)throw Error();return this.each((t=this._id,function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw Error();nz(this,t).ease=n}))},end:function(){var e,t,n=this,r=n._id,a=n.size();return new Promise(function(i,o){var l={value:o},s={value:function(){0==--a&&i()}};n.each(function(){var n=nz(this,r),a=n.on;a!==e&&((t=(e=a).copy())._.cancel.push(l),t._.interrupt.push(l),t._.end.push(s)),n.on=t}),0===a&&i()})},[Symbol.iterator]:rN[Symbol.iterator]};var rC={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};t5.prototype.interrupt=function(e){return this.each(function(){nD(this,e)})},t5.prototype.transition=function(e){var t,n;e instanceof rS?(t=e._id,e=e._name):(t=++rk,(n=rC).time=nw(),e=null==e?null:e+"");for(var r=this._groups,a=r.length,i=0;i<a;++i)for(var o,l=r[i],s=l.length,c=0;c<s;++c)(o=l[c])&&nA(o,e,t,c,l,n||function(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}(o,t));return new rS(r,this._parents,e,t)};let rM=e=>()=>e;function rE(e,{sourceEvent:t,target:n,transform:r,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:a}})}function rO(e,t,n){this.k=e,this.x=t,this.y=n}rO.prototype={constructor:rO,scale:function(e){return 1===e?this:new rO(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new rO(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var rP=new rO(1,0,0);function rA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return rP;return e.__zoom}function rI(e){e.stopImmediatePropagation()}function rz(e){e.preventDefault(),e.stopImmediatePropagation()}function rT(e){return(!e.ctrlKey||"wheel"===e.type)&&!e.button}function rD(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function r_(){return this.__zoom||rP}function rR(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function rL(){return navigator.maxTouchPoints||"ontouchstart"in this}function r$(e,t,n){var r=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(a>r?(r+a)/2:Math.min(0,r)||Math.max(0,a),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function rF(){var e,t,n,r=rT,a=rD,i=r$,o=rR,l=rL,s=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=nd,f=tp("start","zoom","end"),h=0,p=10;function m(e){e.property("__zoom",r_).on("wheel.zoom",j,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",S).filter(l).on("touchstart.zoom",N).on("touchmove.zoom",C).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(s[0],Math.min(s[1],t)))===e.k?e:new rO(t,e.x,e.y)}function v(e,t,n){var r=t[0]-n[0]*e.k,a=t[1]-n[1]*e.k;return r===e.x&&a===e.y?e:new rO(e.k,r,a)}function x(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function y(e,t,n,r){e.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var e=arguments,i=b(this,e).event(r),o=a.apply(this,e),l=null==n?x(o):"function"==typeof n?n.apply(this,e):n,s=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),c=this.__zoom,d="function"==typeof t?t.apply(this,e):t,f=u(c.invert(l).concat(s/c.k),d.invert(l).concat(s/d.k));return function(e){if(1===e)e=d;else{var t=f(e),n=s/t[2];e=new rO(n,l[0]-t[0]*n,l[1]-t[1]*n)}i.zoom(null,e)}})}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=a.apply(e,t),this.taps=0}function j(e,...t){if(r.apply(this,arguments)){var n=b(this,t).event(e),a=this.__zoom,l=Math.max(s[0],Math.min(s[1],a.k*Math.pow(2,o.apply(this,arguments)))),d=t3(e);if(n.wheel)(n.mouse[0][0]!==d[0]||n.mouse[0][1]!==d[1])&&(n.mouse[1]=a.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(a.k===l)return;n.mouse=[d,a.invert(d)],nD(this),n.start()}rz(e),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",i(v(g(a,l),n.mouse[0],n.mouse[1]),n.extent,c))}}function k(e,...t){if(!n&&r.apply(this,arguments)){var a=e.currentTarget,o=b(this,t,!0).event(e),l=t4(e.view).on("mousemove.zoom",function(e){if(rz(e),!o.moved){var t=e.clientX-d,n=e.clientY-u;o.moved=t*t+n*n>h}o.event(e).zoom("mouse",i(v(o.that.__zoom,o.mouse[0]=t3(e,a),o.mouse[1]),o.extent,c))},!0).on("mouseup.zoom",function(e){l.on("mousemove.zoom mouseup.zoom",null),nt(e.view,o.moved),rz(e),o.event(e).end()},!0),s=t3(e,a),d=e.clientX,u=e.clientY;ne(e.view),rI(e),o.mouse=[s,this.__zoom.invert(s)],nD(this),o.start()}}function S(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,o=t3(e.changedTouches?e.changedTouches[0]:e,this),l=n.invert(o),s=n.k*(e.shiftKey?.5:2),u=i(v(g(n,s),o,l),a.apply(this,t),c);rz(e),d>0?t4(this).transition().duration(d).call(y,u,o,e):t4(this).call(m.transform,u,o,e)}}function N(n,...a){if(r.apply(this,arguments)){var i,o,l,s,c=n.touches,d=c.length,u=b(this,a,n.changedTouches.length===d).event(n);for(rI(n),o=0;o<d;++o)s=[s=t3(l=c[o],this),this.__zoom.invert(s),l.identifier],u.touch0?u.touch1||u.touch0[2]===s[2]||(u.touch1=s,u.taps=0):(u.touch0=s,i=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(u.taps<2&&(t=s[0],e=setTimeout(function(){e=null},500)),nD(this),u.start())}}function C(e,...t){if(this.__zooming){var n,r,a,o,l=b(this,t).event(e),s=e.changedTouches,d=s.length;for(rz(e),n=0;n<d;++n)a=t3(r=s[n],this),l.touch0&&l.touch0[2]===r.identifier?l.touch0[0]=a:l.touch1&&l.touch1[2]===r.identifier&&(l.touch1[0]=a);if(r=l.that.__zoom,l.touch1){var u=l.touch0[0],f=l.touch0[1],h=l.touch1[0],p=l.touch1[1],m=(m=h[0]-u[0])*m+(m=h[1]-u[1])*m,x=(x=p[0]-f[0])*x+(x=p[1]-f[1])*x;r=g(r,Math.sqrt(m/x)),a=[(u[0]+h[0])/2,(u[1]+h[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!l.touch0)return;a=l.touch0[0],o=l.touch0[1]}l.zoom("touch",i(v(r,a,o),l.extent,c))}}function M(e,...r){if(this.__zooming){var a,i,o=b(this,r).event(e),l=e.changedTouches,s=l.length;for(rI(e),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),a=0;a<s;++a)i=l[a],o.touch0&&o.touch0[2]===i.identifier?delete o.touch0:o.touch1&&o.touch1[2]===i.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(i=t3(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<p)){var c=t4(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var a=e.selection?e.selection():e;a.property("__zoom",r_),e!==a?y(e,t,n,r):a.interrupt().each(function(){b(this,arguments).event(r).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()})},m.scaleBy=function(e,t,n,r){m.scaleTo(e,function(){var e=this.__zoom.k,n="function"==typeof t?t.apply(this,arguments):t;return e*n},n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,function(){var e=a.apply(this,arguments),r=this.__zoom,o=null==n?x(e):"function"==typeof n?n.apply(this,arguments):n,l=r.invert(o),s="function"==typeof t?t.apply(this,arguments):t;return i(v(g(r,s),o,l),e,c)},n,r)},m.translateBy=function(e,t,n,r){m.transform(e,function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),a.apply(this,arguments),c)},null,r)},m.translateTo=function(e,t,n,r,o){m.transform(e,function(){var e=a.apply(this,arguments),o=this.__zoom,l=null==r?x(e):"function"==typeof r?r.apply(this,arguments):r;return i(rP.translate(l[0],l[1]).scale(o.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)},r,o)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=t4(this.that).datum();f.call(e,this.that,new rE(e,{sourceEvent:this.sourceEvent,target:m,type:e,transform:this.that.__zoom,dispatch:f}),t)}},m.wheelDelta=function(e){return arguments.length?(o="function"==typeof e?e:rM(+e),m):o},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:rM(!!e),m):r},m.touchable=function(e){return arguments.length?(l="function"==typeof e?e:rM(!!e),m):l},m.extent=function(e){return arguments.length?(a="function"==typeof e?e:rM([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):a},m.scaleExtent=function(e){return arguments.length?(s[0]=+e[0],s[1]=+e[1],m):[s[0],s[1]]},m.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],m):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},m.constrain=function(e){return arguments.length?(i=e,m):i},m.duration=function(e){return arguments.length?(d=+e,m):d},m.interpolate=function(e){return arguments.length?(u=e,m):u},m.on=function(){var e=f.on.apply(f,arguments);return e===f?m:e},m.clickDistance=function(e){return arguments.length?(h=(e*=1)*e,m):Math.sqrt(h)},m.tapDistance=function(e){return arguments.length?(p=+e,m):p},m}function rB(e,t){var n,r,a=typeof t;return null==t||"boolean"===a?rh(t):("number"===a?n_:"string"===a?(r=n6(t))?(t=r,rm):ry:t instanceof n6?rm:t instanceof Date?function(e,t){var n=new Date;return e*=1,t*=1,function(r){return n.setTime(e*(1-r)+t*r),n}}:!ArrayBuffer.isView(n=t)||n instanceof DataView?Array.isArray(t)?function(e,t){var n,r=t?t.length:0,a=e?Math.min(r,e.length):0,i=Array(a),o=Array(r);for(n=0;n<a;++n)i[n]=rB(e[n],t[n]);for(;n<r;++n)o[n]=t[n];return function(e){for(n=0;n<a;++n)o[n]=i[n](e);return o}}:"function"!=typeof t.valueOf&&"function"!=typeof t.toString||isNaN(t)?function(e,t){var n,r={},a={};for(n in(null===e||"object"!=typeof e)&&(e={}),(null===t||"object"!=typeof t)&&(t={}),t)n in e?r[n]=rB(e[n],t[n]):a[n]=t[n];return function(e){for(n in r)a[n]=r[n](e);return a}}:n_:function(e,t){t||(t=[]);var n,r=e?Math.min(t.length,e.length):0,a=t.slice();return function(i){for(n=0;n<r;++n)a[n]=e[n]*(1-i)+t[n]*i;return a}})(e,t)}rA.prototype=rO.prototype;let rV=[[-1/0,-1/0],[1/0,1/0]],rH=["Enter"," ","Escape"],rU={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(f=A||(A={})).Strict="strict",f.Loose="loose",(h=I||(I={})).Free="free",h.Vertical="vertical",h.Horizontal="horizontal",(p=z||(z={})).Partial="partial",p.Full="full";let rW={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(m=T||(T={})).Bezier="default",m.Straight="straight",m.Step="step",m.SmoothStep="smoothstep",m.SimpleBezier="simplebezier",(g=D||(D={})).Arrow="arrow",g.ArrowClosed="arrowclosed",(v=_||(_={})).Left="left",v.Top="top",v.Right="right",v.Bottom="bottom";let rq={[_.Left]:_.Right,[_.Right]:_.Left,[_.Top]:_.Bottom,[_.Bottom]:_.Top};function rK(e){return null===e?null:e?"valid":"invalid"}let rG=e=>"id"in e&&"source"in e&&"target"in e,rX=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),rY=(e,t=[0,0])=>{let{width:n,height:r}=ap(e),a=e.origin??t,i=n*a[0],o=r*a[1];return{x:e.position.x-i,y:e.position.y-o}},rZ=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(void 0===t.filter||t.filter(e))&&(n=r8(n,at(e)),r=!0)}),r?r9(n):{x:0,y:0,width:0,height:0}},rJ=(e,t,[n,r,a]=[0,0,1],i=!1,o=!1)=>{let l={...as(t,[n,r,a]),width:t.width/a,height:t.height/a},s=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let a=e.width??t.width??t.initialWidth??null,c=e.height??t.height??t.initialHeight??null,d=ar(l,ae(t)),u=(a??0)*(c??0),f=i&&d>0;(!t.internals.handleBounds||f||d>=u||t.dragging)&&s.push(t)}return s};async function rQ({nodes:e,width:t,height:n,panZoom:r,minZoom:a,maxZoom:i},o){let l,s;if(0===e.size)return Promise.resolve(!0);let c=au(rZ((l=new Map,s=o?.nodes?new Set(o.nodes.map(e=>e.id)):null,e.forEach(e=>{e.measured.width&&e.measured.height&&(o?.includeHiddenNodes||!e.hidden)&&(!s||s.has(e.id))&&l.set(e.id,e)}),l)),t,n,o?.minZoom??a,o?.maxZoom??i,o?.padding??.1);return await r.setViewport(c,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function r0({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:a,onError:i}){let o=n.get(e),l=o.parentId?n.get(o.parentId):void 0,{x:s,y:c}=l?l.internals.positionAbsolute:{x:0,y:0},d=o.origin??r,u=o.extent||a;if("parent"!==o.extent||o.expandParent)l&&ah(o.extent)&&(u=[[o.extent[0][0]+s,o.extent[0][1]+c],[o.extent[1][0]+s,o.extent[1][1]+c]]);else if(l){let e=l.measured.width,t=l.measured.height;e&&t&&(u=[[s,c],[s+e,c+t]])}else i?.("005","Only child nodes can use a parent extent.");let f=ah(u)?r5(t,u,o.measured):t;return(void 0===o.measured.width||void 0===o.measured.height)&&i?.("015","It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."),{position:{x:f.x-s+(o.measured.width??0)*d[0],y:f.y-c+(o.measured.height??0)*d[1]},positionAbsolute:f}}async function r1({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:a}){let i,o=new Set(e.map(e=>e.id)),l=[];for(let e of n){if(!1===e.deletable)continue;let t=o.has(e.id),n=!t&&e.parentId&&l.find(t=>t.id===e.parentId);(t||n)&&l.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>!1!==e.deletable),d=(i=new Set,l.forEach(e=>{i.add(e.id)}),c.filter(e=>i.has(e.source)||i.has(e.target)));for(let e of c)s.has(e.id)&&!d.find(t=>t.id===e.id)&&d.push(e);if(!a)return{edges:d,nodes:l};let u=await a({nodes:l,edges:d});return"boolean"==typeof u?u?{edges:d,nodes:l}:{edges:[],nodes:[]}:u}let r2=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),r5=(e={x:0,y:0},t,n)=>({x:r2(e.x,t[0][0],t[1][0]-(n?.width??0)),y:r2(e.y,t[0][1],t[1][1]-(n?.height??0))});function r4(e,t,n){let{width:r,height:a}=ap(n),{x:i,y:o}=n.internals.positionAbsolute;return r5(e,[[i,o],[i+r,o+a]],t)}let r3=(e,t,n)=>e<t?r2(Math.abs(e-t),1,t)/t:e>n?-r2(Math.abs(e-n),1,t)/t:0,r6=(e,t,n=15,r=40)=>[r3(e.x,r,t.width-r)*n,r3(e.y,r,t.height-r)*n],r8=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),r7=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),r9=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ae=(e,t=[0,0])=>{let{x:n,y:r}=rX(e)?e.internals.positionAbsolute:rY(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},at=(e,t=[0,0])=>{let{x:n,y:r}=rX(e)?e.internals.positionAbsolute:rY(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},an=(e,t)=>r9(r8(r7(e),r7(t))),ar=(e,t)=>Math.ceil(Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))),aa=e=>ai(e.width)&&ai(e.height)&&ai(e.x)&&ai(e.y),ai=e=>!isNaN(e)&&isFinite(e),ao=(e,t)=>{},al=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),as=({x:e,y:t},[n,r,a],i=!1,o=[1,1])=>{let l={x:(e-n)/a,y:(t-r)/a};return i?al(l,o):l},ac=({x:e,y:t},[n,r,a])=>({x:e*a+n,y:t*a+r});function ad(e,t){if("number"==typeof e)return Math.floor((t-t/(1+e))*.5);if("string"==typeof e&&e.endsWith("px")){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if("string"==typeof e&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let au=(e,t,n,r,a,i)=>{let o=function(e,t,n){if("string"==typeof e||"number"==typeof e){let r=ad(e,n),a=ad(e,t);return{top:r,right:a,bottom:r,left:a,x:2*a,y:2*r}}if("object"==typeof e){let r=ad(e.top??e.y??0,n),a=ad(e.bottom??e.y??0,n),i=ad(e.left??e.x??0,t),o=ad(e.right??e.x??0,t);return{top:r,right:o,bottom:a,left:i,x:i+o,y:r+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(i,t,n),l=r2(Math.min((t-o.x)/e.width,(n-o.y)/e.height),r,a),s=e.x+e.width/2,c=e.y+e.height/2,d=t/2-s*l,u=n/2-c*l,f=function(e,t,n,r,a,i){let{x:o,y:l}=ac(e,[t,n,r]),{x:s,y:c}=ac({x:e.x+e.width,y:e.y+e.height},[t,n,r]);return{left:Math.floor(o),top:Math.floor(l),right:Math.floor(a-s),bottom:Math.floor(i-c)}}(e,d,u,l,t,n),h={left:Math.min(f.left-o.left,0),top:Math.min(f.top-o.top,0),right:Math.min(f.right-o.right,0),bottom:Math.min(f.bottom-o.bottom,0)};return{x:d-h.left+h.right,y:u-h.top+h.bottom,zoom:l}},af=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function ah(e){return null!=e&&"parent"!==e}function ap(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function am(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function ag(e,t={width:0,height:0},n,r,a){let i={...e},o=r.get(n);if(o){let e=o.origin||a;i.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],i.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return i}function av(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ax(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:a}){let{x:i,y:o}=ak(e),l=as({x:i-(a?.left??0),y:o-(a?.top??0)},r),{x:s,y:c}=n?al(l,t):l;return{xSnapped:s,ySnapped:c,...l}}let ay=e=>({width:e.offsetWidth,height:e.offsetHeight}),ab=e=>e?.getRootNode?.()||window?.document,aw=["INPUT","SELECT","TEXTAREA"];function aj(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1&&(aw.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey"))}let ak=(e,t)=>{let n="clientX"in e,r=n?e.clientX:e.touches?.[0].clientX,a=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:a-(t?.top??0)}},aS=(e,t,n,r,a)=>{let i=t.querySelectorAll(`.${e}`);return i&&i.length?Array.from(i).map(t=>{let i=t.getBoundingClientRect();return{id:t.getAttribute("data-handleid"),type:e,nodeId:a,position:t.getAttribute("data-handlepos"),x:(i.left-n.left)/r,y:(i.top-n.top)/r,...ay(t)}}):null};function aN({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:a,sourceControlY:i,targetControlX:o,targetControlY:l}){let s=.125*e+.375*a+.375*o+.125*n,c=.125*t+.375*i+.375*l+.125*r,d=Math.abs(s-e),u=Math.abs(c-t);return[s,c,d,u]}function aC(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function aM({pos:e,x1:t,y1:n,x2:r,y2:a,c:i}){switch(e){case _.Left:return[t-aC(t-r,i),n];case _.Right:return[t+aC(r-t,i),n];case _.Top:return[t,n-aC(n-a,i)];case _.Bottom:return[t,n+aC(a-n,i)]}}function aE({sourceX:e,sourceY:t,sourcePosition:n=_.Bottom,targetX:r,targetY:a,targetPosition:i=_.Top,curvature:o=.25}){let[l,s]=aM({pos:n,x1:e,y1:t,x2:r,y2:a,c:o}),[c,d]=aM({pos:i,x1:r,y1:a,x2:e,y2:t,c:o}),[u,f,h,p]=aN({sourceX:e,sourceY:t,targetX:r,targetY:a,sourceControlX:l,sourceControlY:s,targetControlX:c,targetControlY:d});return[`M${e},${t} C${l},${s} ${c},${d} ${r},${a}`,u,f,h,p]}function aO({sourceX:e,sourceY:t,targetX:n,targetY:r}){let a=Math.abs(n-e)/2,i=Math.abs(r-t)/2;return[n<e?n+a:n-a,r<t?r+i:r-i,a,i]}let aP=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`;function aA({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[a,i,o,l]=aO({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,a,i,o,l]}let aI={[_.Left]:{x:-1,y:0},[_.Right]:{x:1,y:0},[_.Top]:{x:0,y:-1},[_.Bottom]:{x:0,y:1}},az=({source:e,sourcePosition:t=_.Bottom,target:n})=>t===_.Left||t===_.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},aT=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function aD({sourceX:e,sourceY:t,sourcePosition:n=_.Bottom,targetX:r,targetY:a,targetPosition:i=_.Top,borderRadius:o=5,centerX:l,centerY:s,offset:c=20,stepPosition:d=.5}){let[u,f,h,p,m]=function({source:e,sourcePosition:t=_.Bottom,target:n,targetPosition:r=_.Top,center:a,offset:i,stepPosition:o}){let l,s,c=aI[t],d=aI[r],u={x:e.x+c.x*i,y:e.y+c.y*i},f={x:n.x+d.x*i,y:n.y+d.y*i},h=az({source:u,sourcePosition:t,target:f}),p=0!==h.x?"x":"y",m=h[p],g=[],v={x:0,y:0},x={x:0,y:0},[,,y,b]=aO({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[p]*d[p]==-1){"x"===p?(l=a.x??u.x+(f.x-u.x)*o,s=a.y??(u.y+f.y)/2):(l=a.x??(u.x+f.x)/2,s=a.y??u.y+(f.y-u.y)*o);let e=[{x:l,y:u.y},{x:l,y:f.y}],t=[{x:u.x,y:s},{x:f.x,y:s}];g=c[p]===m?"x"===p?e:t:"x"===p?t:e}else{let a=[{x:u.x,y:f.y}],o=[{x:f.x,y:u.y}];if(g="x"===p?c.x===m?o:a:c.y===m?a:o,t===r){let t=Math.abs(e[p]-n[p]);if(t<=i){let r=Math.min(i-1,i-t);c[p]===m?v[p]=(u[p]>e[p]?-1:1)*r:x[p]=(f[p]>n[p]?-1:1)*r}}if(t!==r){let e="x"===p?"y":"x",t=c[p]===d[e],n=u[e]>f[e],r=u[e]<f[e];(1===c[p]&&(!t&&n||t&&r)||1!==c[p]&&(!t&&r||t&&n))&&(g="x"===p?a:o)}let h={x:u.x+v.x,y:u.y+v.y},y={x:f.x+x.x,y:f.y+x.y};Math.max(Math.abs(h.x-g[0].x),Math.abs(y.x-g[0].x))>=Math.max(Math.abs(h.y-g[0].y),Math.abs(y.y-g[0].y))?(l=(h.x+y.x)/2,s=g[0].y):(l=g[0].x,s=(h.y+y.y)/2)}let w={x:u.x+v.x,y:u.y+v.y},j={x:f.x+x.x,y:f.y+x.y};return[[e,...w.x!==g[0].x||w.y!==g[0].y?[w]:[],...g,...j.x!==g[g.length-1].x||j.y!==g[g.length-1].y?[j]:[],n],l,s,y,b]}({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:a},targetPosition:i,center:{x:l,y:s},offset:c,stepPosition:d}),g=`M${u[0].x} ${u[0].y}`;for(let e=1;e<u.length-1;e++)g+=function(e,t,n,r){let a=Math.min(aT(e,t)/2,aT(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${i+a*t},${o}Q ${i},${o} ${i},${o+a*r}`}let l=e.x<n.x?1:-1,s=e.y<n.y?-1:1;return`L ${i},${o+a*s}Q ${i},${o} ${i+a*l},${o}`}(u[e-1],u[e],u[e+1],o);return[g+=`L${u[u.length-1].x} ${u[u.length-1].y}`,f,h,p,m]}function a_(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function aR(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,"source"===r.type?t.push(r):"target"===r.type&&n.push(r);return{source:t,target:n}}function aL(e,t,n=_.Left,r=!1){let a=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:l}=t??ap(e);if(r)return{x:a+o/2,y:i+l/2};switch(t?.position??n){case _.Top:return{x:a+o/2,y:i};case _.Right:return{x:a+o,y:i+l/2};case _.Bottom:return{x:a+o/2,y:i+l};case _.Left:return{x:a,y:i+l/2}}}function a$(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function aF(e,t){if(!e)return"";if("string"==typeof e)return e;let n=t?`${t}__`:"";return`${n}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("&")}`}let aB={nodeOrigin:[0,0],nodeExtent:rV,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},aV={...aB,checkEquality:!0};function aH(e,t){let n={...e};for(let e in t)void 0!==t[e]&&(n[e]=t[e]);return n}function aU(e){return"manual"===e}function aW(e,t,n,r={}){let a=aH(aV,r),i={i:0},o=new Map(t),l=a?.elevateNodesOnSelect&&!aU(a.zIndexMode)?1e3:0,s=e.length>0,c=!1;for(let d of(t.clear(),n.clear(),e)){let e=o.get(d.id);if(a.checkEquality&&d===e?.internals.userNode)t.set(d.id,e);else{let n=r5(rY(d,a.nodeOrigin),ah(d.extent)?d.extent:a.nodeExtent,ap(d));e={...a.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:n,handleBounds:function(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let a={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};"source"===t.type?n.push(a):"target"===t.type&&r.push(a)}return{source:n,target:r}}(d,e),z:aK(d,l,a.zIndexMode),userNode:d}},t.set(d.id,e)}void 0!==e.measured&&void 0!==e.measured.width&&void 0!==e.measured.height||e.hidden||(s=!1),d.parentId&&aq(e,t,n,r,i),c||=d.selected??!1}return{nodesInitialized:s,hasSelectedNodes:c}}function aq(e,t,n,r,a){let{elevateNodesOnSelect:i,nodeOrigin:o,nodeExtent:l,zIndexMode:s}=aH(aB,r),c=e.parentId,d=t.get(c);if(!d)return void console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}(e,n),a&&!d.parentId&&void 0===d.internals.rootParentIndex&&"auto"===s&&(d.internals.rootParentIndex=++a.i,d.internals.z=d.internals.z+10*a.i),a&&void 0!==d.internals.rootParentIndex&&(a.i=d.internals.rootParentIndex);let{x:u,y:f,z:h}=function(e,t,n,r,a,i){let{x:o,y:l}=t.internals.positionAbsolute,s=ap(e),c=rY(e,n),d=ah(e.extent)?r5(c,e.extent,s):c,u=r5({x:o+d.x,y:l+d.y},r,s);"parent"===e.extent&&(u=r4(u,s,t));let f=aK(e,a,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}(e,d,o,l,i&&!aU(s)?1e3:0,s),{positionAbsolute:p}=e.internals,m=u!==p.x||f!==p.y;(m||h!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:u,y:f}:p,z:h}})}function aK(e,t,n){let r=ai(e.zIndex)?e.zIndex:0;return aU(n)?r:r+(e.selected?t:0)}function aG(e,t,n,r=[0,0]){let a=[],i=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=an(i.get(n.parentId)?.expandedRect??ae(e),n.rect);i.set(n.parentId,{expandedRect:r,parent:e})}return i.size>0&&i.forEach(({expandedRect:t,parent:i},o)=>{let l=i.internals.positionAbsolute,s=ap(i),c=i.origin??r,d=t.x<l.x?Math.round(Math.abs(l.x-t.x)):0,u=t.y<l.y?Math.round(Math.abs(l.y-t.y)):0,f=Math.max(s.width,Math.round(t.width)),h=Math.max(s.height,Math.round(t.height)),p=(f-s.width)*c[0],m=(h-s.height)*c[1];(d>0||u>0||p||m)&&(a.push({id:o,type:"position",position:{x:i.position.x-d+p,y:i.position.y-u+m}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||a.push({id:t.id,type:"position",position:{x:t.position.x+d,y:t.position.y+u}})})),(s.width<t.width||s.height<t.height||d||u)&&a.push({id:o,type:"dimensions",setAttributes:!0,dimensions:{width:f+(d?c[0]*d-p:0),height:h+(u?c[1]*u-m:0)}})}),a}async function aX({delta:e,panZoom:t,transform:n,translateExtent:r,width:a,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[a,i]],r);return Promise.resolve(!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]))}function aY(e,t,n,r,a,i){let o=a,l=r.get(o)||new Map;r.set(o,l.set(n,t)),o=`${a}-${e}`;let s=r.get(o)||new Map;if(r.set(o,s.set(n,t)),i){o=`${a}-${e}-${i}`;let l=r.get(o)||new Map;r.set(o,l.set(n,t))}}function aZ(e,t,n){for(let r of(e.clear(),t.clear(),n)){let{source:n,target:a,sourceHandle:i=null,targetHandle:o=null}=r,l={edgeId:r.id,source:n,target:a,sourceHandle:i,targetHandle:o},s=`${n}-${i}--${a}-${o}`;aY("source",l,`${a}-${o}--${n}-${i}`,e,n,i),aY("target",l,s,e,a,o),t.set(r.id,r)}}function aJ(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)break;r=r?.parentElement}while(r)return!1}function aQ({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let a=[];for(let[e,i]of t){let t=n.get(e)?.internals.userNode;t&&a.push({...t,position:i.position,dragging:r})}if(!e)return[a[0],a];let i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:r}:a[0],a]}function a0(e,t,n,r,a,i=!1){let o=r.get(e);if(!o)return null;let l="strict"===a?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],s=(n?l?.find(e=>e.id===n):l?.[0])??null;return s&&i?{...s,...aL(o,s,s.position,!0)}:s}function a1(e,t){return e?e:t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null}let a2=()=>!0;function a5(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:a,fromType:i,doc:o,lib:l,flowId:s,isValidConnection:c=a2,nodeLookup:d}){let u="target"===i,f=t?o.querySelector(`.${l}-flow__handle[data-id="${s}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:p}=ak(e),m=o.elementFromPoint(h,p),g=m?.classList.contains(`${l}-flow__handle`)?m:f,v={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=a1(void 0,g),t=g.getAttribute("data-nodeid"),i=g.getAttribute("data-handleid"),o=g.classList.contains("connectable"),l=g.classList.contains("connectableend");if(!t||!e)return v;let s={source:u?t:r,sourceHandle:u?i:a,target:u?r:t,targetHandle:u?a:i};v.connection=s,v.isValid=o&&l&&(n===A.Strict?u&&"source"===e||!u&&"target"===e:t!==r||i!==a)&&c(s),v.toHandle=a0(t,e,i,d,n,!0)}return v}let a4=function(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:a,edgeUpdaterType:i,isTarget:o,domNode:l,nodeLookup:s,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:p,onConnect:m,onConnectEnd:g,isValidConnection:v=a2,onReconnectEnd:x,updateConnection:y,getTransform:b,getFromHandle:w,autoPanSpeed:j,dragThreshold:k=1,handleDomNode:S}){let N,C=ab(e.target),M=0,{x:E,y:O}=ak(e),P=a1(i,S),A=l?.getBoundingClientRect(),I=!1;if(!A||!P)return;let z=a0(a,P,r,s,t);if(!z)return;let T=ak(e,A),D=!1,R=null,L=!1,$=null,F={...z,nodeId:a,type:P,position:z.position},B=s.get(a),V={inProgress:!0,isValid:null,from:aL(B,F,_.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:B,to:T,toHandle:null,toPosition:rq[F.position],toNode:null,pointer:T};function H(){I=!0,y(V),p?.(e,{nodeId:a,handleId:r,handleType:P})}function U(e){var i,l;let h;if(!I){let{x:t,y:n}=ak(e),r=t-E,a=n-O;if(!(r*r+a*a>k*k))return;H()}if(!w()||!F)return void W(e);let p=b();N=function(e,t,n,r){let a=[],i=1/0;for(let o of function(e,t,n){let r=[],a={x:e.x-n,y:e.y-n,width:2*n,height:2*n};for(let e of t.values())ar(a,ae(e))>0&&r.push(e);return r}(e,n,t+250))for(let n of[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]]){if(r.nodeId===n.nodeId&&r.type===n.type&&r.id===n.id)continue;let{x:l,y:s}=aL(o,n,n.position,!0),c=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(s-e.y,2));c>t||(c<i?(a=[{...n,x:l,y:s}],i=c):c===i&&a.push({...n,x:l,y:s}))}if(!a.length)return null;if(a.length>1){let e="source"===r.type?"target":"source";return a.find(t=>t.type===e)??a[0]}return a[0]}(as(T=ak(e,A),p,!1,[1,1]),n,s,F),D||(!function e(){if(!d||!A)return;let[t,n]=r6(T,A,j);f({x:t,y:n}),M=requestAnimationFrame(e)}(),D=!0);let m=a5(e,{handle:N,connectionMode:t,fromNodeId:a,fromHandleId:r,fromType:o?"target":"source",isValidConnection:v,doc:C,lib:c,flowId:u,nodeLookup:s});$=m.handleDomNode,R=m.connection,i=!!N,l=m.isValid,h=null,l?h=!0:i&&!l&&(h=!1),L=h;let g=s.get(a),x=g?aL(g,F,_.Left,!0):V.from,S={...V,from:x,isValid:L,to:m.toHandle&&L?ac({x:m.toHandle.x,y:m.toHandle.y},p):T,toHandle:m.toHandle,toPosition:L&&m.toHandle?m.toHandle.position:rq[F.position],toNode:m.toHandle?s.get(m.toHandle.nodeId):null,pointer:T};y(S),V=S}function W(e){if(!("touches"in e)||!(e.touches.length>0)){if(I){(N||$)&&R&&L&&m?.(R);let{inProgress:t,...n}=V,r={...n,toPosition:V.toHandle?V.toPosition:null};g?.(e,r),i&&x?.(e,r)}h(),cancelAnimationFrame(M),D=!1,L=!1,R=null,$=null,C.removeEventListener("mousemove",U),C.removeEventListener("mouseup",W),C.removeEventListener("touchmove",U),C.removeEventListener("touchend",W)}}0===k&&H(),C.addEventListener("mousemove",U),C.addEventListener("mouseup",W),C.addEventListener("touchmove",U),C.addEventListener("touchend",W)},a3=e=>({x:e.x,y:e.y,zoom:e.k}),a6=({x:e,y:t,zoom:n})=>rP.translate(e,t).scale(n),a8=(e,t)=>e.target.closest(`.${t}`),a7=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),a9=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ie=(e,t=0,n=a9,r=()=>{})=>{let a="number"==typeof t&&t>0;return a||r(),a?e.transition().duration(t).ease(n).on("end",r):e},it=e=>{let t=e.ctrlKey&&af()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function ir(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:e.includes("left"),affectsY:e.includes("top")}}function ia(e,t){return Math.max(0,t-e)}function ii(e,t){return Math.max(0,e-t)}function io(e,t,n){return Math.max(0,t-e,e-n)}(x=R||(R={})).Line="line",x.Handle="handle";let il={width:0,height:0,x:0,y:0},is={...il,pointerX:0,pointerY:0,aspectRatio:1};var ic=e.i(96482);let id={get url(){return`file://${e.P("node_modules/.pnpm/zustand@4.5.7_@types+react@19.2.14_immer@11.1.8_react@19.2.4/node_modules/zustand/esm/vanilla.mjs")}`}},iu=e=>{let t,n=new Set,r=(e,r)=>{let a="function"==typeof e?e(t):e;if(!Object.is(a,t)){let e=t;t=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},t,a),n.forEach(n=>n(t,e))}},a=()=>t,i={setState:r,getState:a,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{(id.env?id.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},o=t=e(r,a,i);return i},{useDebugValue:ih}=ew.default,{useSyncExternalStoreWithSelector:ip}=ic.default,im=e=>e;function ig(e,t=im,n){let r=ip(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ih(r),r}let iv=(e,t)=>{let n=e?iu(e):iu,r=(e,r=t)=>ig(n,e,r);return Object.assign(r,n),r};function ix(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var iy=e.i(65596);let ib=(0,ew.createContext)(null),iw=ib.Provider,ij="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001";function ik(e,t){let n=(0,ew.useContext)(ib);if(null===n)throw Error(ij);return ig(n,e,t)}function iS(){let e=(0,ew.useContext)(ib);if(null===e)throw Error(ij);return(0,ew.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}let iN={display:"none"},iC={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},iM="react-flow__node-desc",iE="react-flow__edge-desc",iO=e=>e.ariaLiveMessage,iP=e=>e.ariaLabelConfig;function iA({rfId:e}){let t=ik(iO);return(0,ey.jsx)("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:iC,children:t})}function iI({rfId:e,disableKeyboardA11y:t}){let n=ik(iP);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{id:`${iM}-${e}`,style:iN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,ey.jsx)("div",{id:`${iE}-${e}`,style:iN,children:n["edge.a11yDescription.default"]}),!t&&(0,ey.jsx)(iA,{rfId:e})]})}let iz=(0,ew.forwardRef)(({position:e="top-left",children:t,className:n,style:r,...a},i)=>{let o=`${e}`.split("-");return(0,ey.jsx)("div",{className:tf(["react-flow__panel",n,...o]),style:r,ref:i,...a,children:t})});function iT({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:(0,ey.jsx)(iz,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:(0,ey.jsx)("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}iz.displayName="Panel";let iD=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},i_=e=>e.id;function iR(e,t){return ix(e.selectedNodes.map(i_),t.selectedNodes.map(i_))&&ix(e.selectedEdges.map(i_),t.selectedEdges.map(i_))}function iL({onSelectionChange:e}){let t=iS(),{selectedNodes:n,selectedEdges:r}=ik(iD,iR);return(0,ew.useEffect)(()=>{let a={nodes:n,edges:r};e?.(a),t.getState().onSelectionChangeHandlers.forEach(e=>e(a))},[n,r,e]),null}let i$=e=>!!e.onSelectionChangeHandlers;function iF({onSelectionChange:e}){let t=ik(i$);return e||t?(0,ey.jsx)(iL,{onSelectionChange:e}):null}let iB="u">typeof window?ew.useLayoutEffect:ew.useEffect,iV=[0,0],iH={x:0,y:0,zoom:1},iU=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode","rfId"],iW=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),iq={translateExtent:rV,nodeOrigin:iV,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function iK(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:a,setTranslateExtent:i,setNodeExtent:o,reset:l,setDefaultNodesAndEdges:s}=ik(iW,ix),c=iS();iB(()=>(s(e.defaultNodes,e.defaultEdges),()=>{d.current=iq,l()}),[]);let d=(0,ew.useRef)(iq);return iB(()=>{for(let l of iU){let s=e[l];if(s!==d.current[l]&&void 0!==e[l])if("nodes"===l)t(s);else if("edges"===l)n(s);else if("minZoom"===l)r(s);else if("maxZoom"===l)a(s);else if("translateExtent"===l)i(s);else if("nodeExtent"===l)o(s);else if("ariaLabelConfig"===l)c.setState({ariaLabelConfig:{...rU,...s||{}}});else"fitView"===l?c.setState({fitViewQueued:s}):"fitViewOptions"===l?c.setState({fitViewOptions:s}):c.setState({[l]:s})}d.current=e},iU.map(t=>e[t])),null}function iG(){return"u"<typeof window||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}let iX="u">typeof document?document:null;function iY(e=null,t={target:iX,actInsideInputWithModifier:!0}){let[n,r]=(0,ew.useState)(!1),a=(0,ew.useRef)(!1),i=(0,ew.useRef)(new Set([])),[o,l]=(0,ew.useMemo)(()=>{if(null!==e){let t=(Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).map(e=>e.replace("+","\n").replace("\n\n","\n+").split("\n")),n=t.reduce((e,t)=>e.concat(...t),[]);return[t,n]}return[[],[]]},[e]);return(0,ew.useEffect)(()=>{let n=t?.target??iX,s=t?.actInsideInputWithModifier??!0;if(null!==e){let e=e=>{if(a.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!a.current||a.current&&!s)&&aj(e))return!1;let n=iJ(e.code,l);if(i.current.add(e[n]),iZ(o,i.current,!1)){let n=e.composedPath?.()?.[0]||e.target,i=n?.nodeName==="BUTTON"||n?.nodeName==="A";!1!==t.preventDefault&&(a.current||!i)&&e.preventDefault(),r(!0)}},c=e=>{let t=iJ(e.code,l);iZ(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(e[t]),"Meta"===e.key&&i.current.clear(),a.current=!1},d=()=>{i.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",c),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",c),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function iZ(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function iJ(e,t){return t.includes(e)?"code":"key"}function iQ(e,t){let n=[],r=new Map,a=[];for(let t of e)if("add"===t.type){a.push(t);continue}else if("remove"===t.type||"replace"===t.type)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}let a={...e};for(let e of t){var i=e,o=a;switch(i.type){case"select":o.selected=i.selected;break;case"position":void 0!==i.position&&(o.position=i.position),void 0!==i.dragging&&(o.dragging=i.dragging);break;case"dimensions":void 0!==i.dimensions&&(o.measured={...i.dimensions},i.setAttributes&&((!0===i.setAttributes||"width"===i.setAttributes)&&(o.width=i.dimensions.width),(!0===i.setAttributes||"height"===i.setAttributes)&&(o.height=i.dimensions.height))),"boolean"==typeof i.resizing&&(o.resizing=i.resizing)}}n.push(a)}return a.length&&a.forEach(e=>{void 0!==e.index?n.splice(e.index,0,{...e.item}):n.push({...e.item})}),n}function i0(e,t){return{id:e,type:"select",selected:t}}function i1(e,t=new Set,n=!1){let r=[];for(let[a,i]of e){let e=t.has(a);(void 0!==i.selected||e)&&i.selected!==e&&(n&&(i.selected=e),r.push(i0(i.id,e)))}return r}function i2({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,a]of e.entries()){let e=t.get(a.id),i=e?.internals?.userNode??e;void 0!==i&&i!==a&&n.push({id:a.id,item:a,type:"replace"}),void 0===i&&n.push({item:a,type:"add",index:r})}for(let[e]of t)void 0===r.get(e)&&n.push({id:e,type:"remove"});return n}function i5(e){return{id:e.id,type:"remove"}}let i4=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e);function i3(e){return(0,ew.forwardRef)(e)}function i6(e){let[t,n]=(0,ew.useState)(BigInt(0)),[r]=(0,ew.useState)(()=>{var e;let t;return e=()=>n(e=>e+BigInt(1)),t=[],{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}});return iB(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}let i8=(0,ew.createContext)(null);function i7({children:e}){let t=iS(),n=i6((0,ew.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:a,onNodesChange:i,nodeLookup:o,fitViewQueued:l,onNodesChangeMiddlewareMap:s}=t.getState(),c=n;for(let t of e)c="function"==typeof t?t(c):t;let d=i2({items:c,lookup:o});for(let e of s.values())d=e(d);a&&r(c),d.length>0?i?.(d):l&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=i6((0,ew.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:a,onEdgesChange:i,edgeLookup:o}=t.getState(),l=n;for(let t of e)l="function"==typeof t?t(l):t;a?r(l):i&&i(i2({items:l,lookup:o}))},[])),a=(0,ew.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,ey.jsx)(i8.Provider,{value:a,children:e})}let i9=e=>!!e.panZoom;function oe(){let e,t=(e=iS(),(0,ew.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,a,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??a,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:a,minZoom:i,maxZoom:o,panZoom:l}=e.getState(),s=au(t,r,a,i,o,n?.padding??.1);return l?(await l.setViewport(s,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:a,snapToGrid:i,domNode:o}=e.getState();if(!o)return t;let{x:l,y:s}=o.getBoundingClientRect(),c={x:t.x-l,y:t.y-s},d=n.snapGrid??a;return as(c,r,n.snapToGrid??i,d)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:a,y:i}=r.getBoundingClientRect(),o=ac(t,n);return{x:o.x+a,y:o.y+i}}}),[])),n=iS(),r=function(){let e=(0,ew.useContext)(i8);if(!e)throw Error("useBatchContext must be used within a BatchProvider");return e}(),a=ik(i9),i=(0,ew.useMemo)(()=>{let e=e=>n.getState().nodeLookup.get(e),t=e=>{r.nodeQueue.push(e)},a=e=>{r.edgeQueue.push(e)},i=e=>{let{nodeLookup:t,nodeOrigin:r}=n.getState(),a=i4(e)?e:t.get(e.id),i=a.parentId?ag(a.position,a.measured,a.parentId,t,r):a.position;return ae({...a,position:i,width:a.measured?.width??a.width,height:a.measured?.height??a.height})},o=(e,n,r={replace:!1})=>{t(t=>t.map(t=>{if(t.id===e){let e="function"==typeof n?n(t):n;return r.replace&&i4(e)?e:{...t,...e}}return t}))},l=(e,t,n={replace:!1})=>{a(r=>r.map(r=>{if(r.id===e){let e="function"==typeof t?t(r):t;return n.replace&&rG(e)?e:{...r,...e}}return r}))};return{getNodes:()=>n.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=n.getState();return e.map(e=>({...e}))},getEdge:e=>n.getState().edgeLookup.get(e),setNodes:t,setEdges:a,addNodes:e=>{let t=Array.isArray(e)?e:[e];r.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];r.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:t=[],transform:r}=n.getState(),[a,i,o]=r;return{nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),viewport:{x:a,y:i,zoom:o}}},deleteElements:async({nodes:e=[],edges:t=[]})=>{let{nodes:r,edges:a,onNodesDelete:i,onEdgesDelete:o,triggerNodeChanges:l,triggerEdgeChanges:s,onDelete:c,onBeforeDelete:d}=n.getState(),{nodes:u,edges:f}=await r1({nodesToRemove:e,edgesToRemove:t,nodes:r,edges:a,onBeforeDelete:d}),h=f.length>0,p=u.length>0;if(h){let e=f.map(i5);o?.(f),s(e)}if(p){let e=u.map(i5);i?.(u),l(e)}return(p||h)&&c?.({nodes:u,edges:f}),{deletedNodes:u,deletedEdges:f}},getIntersectingNodes:(e,t=!0,r)=>{let a=aa(e),o=a?e:i(e),l=void 0!==r;return o?(r||n.getState().nodes).filter(r=>{let i=n.getState().nodeLookup.get(r.id);if(i&&!a&&(r.id===e.id||!i.internals.positionAbsolute))return!1;let s=ae(l?r:i),c=ar(s,o);return t&&c>0||c>=s.width*s.height||c>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=aa(e)?e:i(e);if(!r)return!1;let a=ar(r,t);return n&&a>0||a>=t.width*t.height||a>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r="function"==typeof t?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:l,updateEdgeData:(e,t,n={replace:!1})=>{l(e,e=>{let r="function"==typeof t?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:t,nodeOrigin:r}=n.getState();return((e,t={nodeOrigin:[0,0]})=>0===e.length?{x:0,y:0,width:0,height:0}:r9(e.reduce((e,n)=>{let r="string"==typeof n,a=t.nodeLookup||r?void 0:n;return t.nodeLookup&&(a=r?t.nodeLookup.get(n):rX(n)?n:t.nodeLookup.get(n.id)),r8(e,a?at(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})))(e,{nodeLookup:t,nodeOrigin:r})},getHandleConnections:({type:e,id:t,nodeId:r})=>Array.from(n.getState().connectionLookup.get(`${r}-${e}${t?`-${t}`:""}`)?.values()??[]),getNodeConnections:({type:e,handleId:t,nodeId:r})=>Array.from(n.getState().connectionLookup.get(`${r}${e?t?`-${e}-${t}`:`-${e}`:""}`)?.values()??[]),fitView:async e=>{let t,a,i=n.getState().fitViewResolver??{promise:new Promise((e,n)=>{t=e,a=n}),resolve:t,reject:a};return n.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:i}),r.nodeQueue.push(e=>[...e]),i.promise}}},[]);return(0,ew.useMemo)(()=>({...i,...t,viewportInitialized:a}),[a])}let ot=e=>e.selected,on="u">typeof window?window:void 0,or={position:"absolute",width:"100%",height:"100%",top:0,left:0},oa=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function oi({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:a=.5,panOnScrollMode:i=I.Free,zoomOnDoubleClick:o=!0,panOnDrag:l=!0,defaultViewport:s,translateExtent:c,minZoom:d,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:h=!0,children:p,noWheelClassName:m,noPanClassName:g,onViewportChange:v,isControlledViewport:x,paneClickDistance:y,selectionOnDrag:b}){let w,j=iS(),k=(0,ew.useRef)(null),{userSelectionActive:S,lib:N,connectionInProgress:C}=ik(oa,ix),M=iY(f),E=(0,ew.useRef)();w=iS(),(0,ew.useEffect)(()=>{let e=()=>{if(!k.current||!(k.current.checkVisibility?.()??!0))return!1;let e=ay(k.current);(0===e.height||0===e.width)&&w.getState().onError?.("004","The React Flow parent container needs a width and a height to render the graph."),w.setState({width:e.width||500,height:e.height||500})};if(k.current){e(),window.addEventListener("resize",e);let t=new ResizeObserver(()=>e());return t.observe(k.current),()=>{window.removeEventListener("resize",e),t&&k.current&&t.unobserve(k.current)}}},[]);let O=(0,ew.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),x||j.setState({transform:e})},[v,x]);return(0,ew.useEffect)(()=>{if(k.current){E.current=function({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:a,onPanZoom:i,onPanZoomStart:o,onPanZoomEnd:l,onDraggingChange:s}){let c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=rF().scaleExtent([t,n]).translateExtent(r),f=t4(e).call(u);v({x:a.x,y:a.y,zoom:r2(a.zoom,t,n)},[[0,0],[d.width,d.height]],r);let h=f.on("wheel.zoom"),p=f.on("dblclick.zoom");function m(e,t){return f?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?rB:nd).transform(ie(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g(){u.on("zoom",null)}async function v(e,t,n){let r=a6(e),a=u?.constrain()(r,t,n);return a&&await m(a),new Promise(e=>e(a))}return u.wheelDelta(it),{update:function({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:a,panOnDrag:d,panOnScrollMode:m,panOnScrollSpeed:v,preventScrolling:x,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:w,zoomActivationKeyPressed:j,lib:k,onTransformChange:S,connectionInProgress:N,paneClickDistance:C,selectionOnDrag:M}){r&&!c.isZoomingOrPanning&&g();let E=a&&!j&&!r;u.clickDistance(M?1/0:!ai(C)||C<0?0:C);let O=E?function({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:a,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:l,onPanZoom:s,onPanZoomEnd:c}){return d=>{if(a8(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();let u=n.property("__zoom").k||1;if(d.ctrlKey&&o){let e=t3(d),t=u*Math.pow(2,it(d));r.scaleTo(n,t,e,d);return}let f=1===d.deltaMode?20:1,h=a===I.Vertical?0:d.deltaX*f,p=a===I.Horizontal?0:d.deltaY*f;!af()&&d.shiftKey&&a!==I.Vertical&&(h=d.deltaY*f,p=0),r.translateBy(n,-(h/u)*i,-(p/u)*i,{internal:!0});let m=a3(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(s?.(d,m),e.panScrollTimeout=setTimeout(()=>{c?.(d,m),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,m))}}({zoomPanValues:c,noWheelClassName:e,d3Selection:f,d3Zoom:u,panOnScrollMode:m,panOnScrollSpeed:v,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:i,onPanZoomEnd:l}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,a){let i="wheel"===r.type,o=!t&&i&&!r.ctrlKey,l=a8(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),o||l)return null;r.preventDefault(),n.call(this,r,a)}}({noWheelClassName:e,preventScrolling:x,d3ZoomHandler:h});if(f.on("wheel.zoom",O,{passive:!1}),!r){let e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let a=a3(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=a,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,a)}}({zoomPanValues:c,onDraggingChange:s,onPanZoomStart:o});u.on("start",e);let t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:a}){return i=>{e.usedRightMouseButton=!!(n&&a7(t,e.mouseButton??0)),i.sourceEvent?.sync||r([i.transform.x,i.transform.y,i.transform.k]),a&&!i.sourceEvent?.internal&&a?.(i.sourceEvent,a3(i.transform))}}({zoomPanValues:c,panOnDrag:d,onPaneContextMenu:!!n,onPanZoom:i,onTransformChange:S});u.on("zoom",t);let r=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:a,onPaneContextMenu:i}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&a7(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&i(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),a)){let t=a3(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a?.(o.sourceEvent,t)},150*!!n)}}}({zoomPanValues:c,panOnDrag:d,panOnScroll:a,onPaneContextMenu:n,onPanZoomEnd:l,onDraggingChange:s});u.on("end",r)}let P=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:a,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:l,noPanClassName:s,lib:c,connectionInProgress:d}){return u=>{let f=e||t,h=n&&u.ctrlKey,p="wheel"===u.type;if(1===u.button&&"mousedown"===u.type&&(a8(u,`${c}-flow__node`)||a8(u,`${c}-flow__edge`)))return!0;if(!r&&!f&&!a&&!i&&!n||o||d&&!p||a8(u,l)&&p||a8(u,s)&&(!p||a&&p&&!e)||!n&&u.ctrlKey&&p)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!a&&!h&&p||!r&&("mousedown"===u.type||"touchstart"===u.type)||Array.isArray(r)&&!r.includes(u.button)&&"mousedown"===u.type)return!1;let m=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||p)&&m}}({zoomActivationKeyPressed:j,panOnDrag:d,zoomOnScroll:b,panOnScroll:a,zoomOnDoubleClick:w,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:k,connectionInProgress:N});u.filter(P),w?f.on("dblclick.zoom",p):f.on("dblclick.zoom",null)},destroy:g,setViewport:async function e(e,t){let n=a6(e);return await m(n,t),new Promise(e=>e(n))},setViewportConstrained:v,getViewport:function(){let e=f?rA(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){return f?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?rB:nd).scaleTo(ie(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},scaleBy:function(e,t){return f?new Promise(n=>{u?.interpolate(t?.interpolate==="linear"?rB:nd).scaleBy(ie(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)},setScaleExtent:function(e){u?.scaleExtent(e)},setTranslateExtent:function(e){u?.translateExtent(e)},syncViewport:function(e){if(f){let t=a6(e),n=f.property("__zoom");(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&u?.transform(f,t,null,{sync:!0})}},setClickDistance:function(e){let t=!ai(e)||e<0?0:e;u?.clickDistance(t)}}}({domNode:k.current,minZoom:d,maxZoom:u,translateExtent:c,viewport:s,onDraggingChange:e=>j.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=j.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=j.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=j.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=E.current.getViewport();return j.setState({panZoom:E.current,transform:[e,t,n],domNode:k.current.closest(".react-flow")}),()=>{E.current?.destroy()}}},[]),(0,ew.useEffect)(()=>{E.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:a,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:l,zoomActivationKeyPressed:M,preventScrolling:h,noPanClassName:g,userSelectionActive:S,noWheelClassName:m,lib:N,onTransformChange:O,connectionInProgress:C,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,a,i,o,l,M,h,g,S,m,N,O,C,b,y]),(0,ey.jsx)("div",{className:"react-flow__renderer",ref:k,style:or,children:p})}let oo=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ol(){let{userSelectionActive:e,userSelectionRect:t}=ik(oo,ix);return e&&t?(0,ey.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}let os=(e,t)=>n=>{n.target===t.current&&e?.(n)},oc=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function od({isSelecting:e,selectionKeyPressed:t,selectionMode:n=z.Full,panOnDrag:r,paneClickDistance:a,selectionOnDrag:i,onSelectionStart:o,onSelectionEnd:l,onPaneClick:s,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:h,children:p}){let m=iS(),{userSelectionActive:g,elementsSelectable:v,dragging:x,connectionInProgress:y}=ik(oc,ix),b=v&&(e||g),w=(0,ew.useRef)(null),j=(0,ew.useRef)(),k=(0,ew.useRef)(new Set),S=(0,ew.useRef)(new Set),N=(0,ew.useRef)(!1),C=e=>{if(N.current||y){N.current=!1;return}s?.(e),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},M=!0===r||Array.isArray(r)&&r.includes(0);return(0,ey.jsxs)("div",{className:tf(["react-flow__pane",{draggable:M,dragging:x,selection:e}]),onClick:b?void 0:os(C,w),onContextMenu:os(e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():c?.(e)},w),onWheel:os(d?e=>d(e):void 0,w),onPointerEnter:b?void 0:u,onPointerMove:b?e=>{let{userSelectionRect:r,transform:i,nodeLookup:l,edgeLookup:s,connectionLookup:c,triggerNodeChanges:d,triggerEdgeChanges:u,defaultEdgeOptions:f,resetSelectedElements:h}=m.getState();if(!j.current||!r)return;let{x:p,y:g}=ak(e.nativeEvent,j.current),{startX:v,startY:x}=r;if(!N.current){if(Math.hypot(p-v,g-x)<=(t?0:a))return;h(),o?.(e)}N.current=!0;let y={startX:v,startY:x,x:p<v?p:v,y:g<x?g:x,width:Math.abs(p-v),height:Math.abs(g-x)},b=k.current,w=S.current;k.current=new Set(rJ(l,y,i,n===z.Partial,!0).map(e=>e.id)),S.current=new Set;let C=f?.selectable??!0;for(let e of k.current){let t=c.get(e);if(t)for(let{edgeId:e}of t.values()){let t=s.get(e);t&&(t.selectable??C)&&S.current.add(e)}}av(b,k.current)||d(i1(l,k.current,!0)),av(w,S.current)||u(i1(s,S.current)),m.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{0===e.button&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===w.current&&m.getState().userSelectionRect&&C?.(e),m.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(l?.(e),m.setState({nodesSelectionActive:k.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=m.getState();if(j.current=r?.getBoundingClientRect(),!j.current)return;let a=n.target===w.current;if(!a&&n.target.closest(".nokey")||!e||!(i&&a||t)||0!==n.button||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),N.current=!1;let{x:o,y:l}=ak(n.nativeEvent,j.current);m.setState({userSelectionRect:{width:0,height:0,startX:o,startY:l,x:o,y:l}}),a||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{N.current&&(e.stopPropagation(),N.current=!1)}:void 0,onPointerLeave:h,ref:w,style:or,children:[p,(0,ey.jsx)(ol,{})]})}function ou({id:e,store:t,unselect:n=!1,nodeRef:r}){let a,{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:l,nodeLookup:s,onError:c}=t.getState(),d=s.get(e);d?(t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&l)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])):c?.("012",(a=e,`Node with id "${a}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`))}function of({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:a,isSelectable:i,nodeClickDistance:o}){let l=iS(),[s,c]=(0,ew.useState)(!1),d=(0,ew.useRef)();return(0,ew.useEffect)(()=>{d.current=function({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:a}){let i={x:null,y:null},o=0,l=new Map,s=!1,c={x:0,y:0},d=null,u=!1,f=null,h=!1,p=!1,m=null;return{update:function({noDragClassName:g,handleSelector:v,domNode:x,isSelectable:y,nodeId:b,nodeClickDistance:w=0}){function j({x:e,y:n}){let{nodeLookup:a,nodeExtent:o,snapGrid:s,snapToGrid:c,nodeOrigin:d,onNodeDrag:u,onSelectionDrag:f,onError:h,updateNodePositions:g}=t();i={x:e,y:n};let v=!1,x=l.size>1,y=x&&o?r7(rZ(l)):null,w=x&&c?function({dragItems:e,snapGrid:t,x:n,y:r}){let a=e.values().next().value;if(!a)return null;let i={x:n-a.distance.x,y:r-a.distance.y},o=al(i,t);return{x:o.x-i.x,y:o.y-i.y}}({dragItems:l,snapGrid:s,x:e,y:n}):null;for(let[t,r]of l){if(!a.has(t))continue;let i={x:e-r.distance.x,y:n-r.distance.y};c&&(i=w?{x:Math.round(i.x+w.x),y:Math.round(i.y+w.y)}:al(i,s));let l=null;if(x&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0];l=[[t,e.y-y.y+o[0][1]],[n,e.y+r.measured.height-y.y2+o[1][1]]]}let{position:u,positionAbsolute:f}=r0({nodeId:t,nextPosition:i,nodeLookup:a,nodeExtent:l||o,nodeOrigin:d,onError:h});v=v||r.position.x!==u.x||r.position.y!==u.y,r.position=u,r.internals.positionAbsolute=f}if(p=p||v,v&&(g(l,!0),m&&(r||u||!b&&f))){let[e,t]=aQ({nodeId:b,dragItems:l,nodeLookup:a});r?.(m,l,e,t),u?.(m,e,t),b||f?.(m,t)}}async function k(){if(!d)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:a}=t();if(!a){s=!1,cancelAnimationFrame(o);return}let[l,u]=r6(c,d,r);(0!==l||0!==u)&&(i.x=(i.x??0)-l/e[2],i.y=(i.y??0)-u/e[2],await n({x:l,y:u})&&j(i)),o=requestAnimationFrame(k)}function S(r){let{nodeLookup:a,multiSelectionActive:o,nodesDraggable:s,transform:c,snapGrid:f,snapToGrid:h,selectNodesOnDrag:p,onNodeDragStart:m,onSelectionDragStart:g,unselectNodesAndEdges:v}=t();u=!0,p&&y||o||!b||a.get(b)?.selected||v(),y&&p&&b&&e?.(b);let x=ax(r.sourceEvent,{transform:c,snapGrid:f,snapToGrid:h,containerBounds:d});if(i=x,(l=function(e,t,n,r){let a=new Map;for(let[i,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!function e(t,n){if(!t.parentId)return!1;let r=n.get(t.parentId);return!!r&&(!!r.selected||e(r,n))}(o,e))&&(o.draggable||t&&void 0===o.draggable)){let t=e.get(i);t&&a.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return a}(a,s,x,b)).size>0&&(n||m||!b&&g)){let[e,t]=aQ({nodeId:b,dragItems:l,nodeLookup:a});n?.(r.sourceEvent,l,e,t),m?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}f=t4(x);let N=ns().clickDistance(w).on("start",e=>{let{domNode:n,nodeDragThreshold:r,transform:a,snapGrid:o,snapToGrid:l}=t();d=n?.getBoundingClientRect()||null,h=!1,p=!1,m=e.sourceEvent,0===r&&S(e),i=ax(e.sourceEvent,{transform:a,snapGrid:o,snapToGrid:l,containerBounds:d}),c=ak(e.sourceEvent,d)}).on("drag",e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:a,snapToGrid:o,nodeDragThreshold:f,nodeLookup:p}=t(),g=ax(e.sourceEvent,{transform:r,snapGrid:a,snapToGrid:o,containerBounds:d});if(m=e.sourceEvent,("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1||b&&!p.has(b))&&(h=!0),!h){if(!s&&n&&u&&(s=!0,k()),!u){let t=ak(e.sourceEvent,d),n=t.x-c.x,r=t.y-c.y;Math.sqrt(n*n+r*r)>f&&S(e)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&l&&u&&(c=ak(e.sourceEvent,d),j(g))}}).on("end",e=>{if(u&&!h&&(s=!1,u=!1,cancelAnimationFrame(o),l.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:i,onSelectionDragStop:o}=t();if(p&&(r(l,!1),p=!1),a||i||!b&&o){let[t,r]=aQ({nodeId:b,dragItems:l,nodeLookup:n,dragging:!1});a?.(e.sourceEvent,l,t,r),i?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!aJ(t,`.${g}`,x))&&(!v||aJ(t,v,x))});f.call(N)},destroy:function(){f?.on(".drag",null)}}}({getStoreItems:()=>l.getState(),onNodeMouseDown:t=>{ou({id:t,store:l,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),(0,ew.useEffect)(()=>{if(!t&&e.current&&d.current)return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:a,nodeClickDistance:o}),()=>{d.current?.destroy()}},[n,r,t,i,e,a,o]),s}function oh(){let e=iS();return(0,ew.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:a,nodesDraggable:i,onError:o,updateNodePositions:l,nodeLookup:s,nodeOrigin:c}=e.getState(),d=new Map,u=e=>e.selected&&(e.draggable||i&&void 0===e.draggable),f=r?a[0]:5,h=r?a[1]:5,p=t.direction.x*f*t.factor,m=t.direction.y*h*t.factor;for(let[,e]of s){if(!u(e))continue;let t={x:e.internals.positionAbsolute.x+p,y:e.internals.positionAbsolute.y+m};r&&(t=al(t,a));let{position:i,positionAbsolute:l}=r0({nodeId:e.id,nextPosition:t,nodeLookup:s,nodeExtent:n,nodeOrigin:c,onError:o});e.position=i,e.internals.positionAbsolute=l,d.set(e.id,e)}l(d)},[])}let op=(0,ew.createContext)(null),om=op.Provider;op.Consumer;let og=()=>(0,ew.useContext)(op),ov=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ox=(0,ew.memo)(i3(function({type:e="source",position:t=_.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:a=!0,isConnectableEnd:i=!0,id:o,onConnect:l,children:s,className:c,onMouseDown:d,onTouchStart:u,...f},h){let p=o||null,m="target"===e,g=iS(),v=og(),{connectOnClick:x,noPanClassName:y,rfId:b}=ik(ov,ix),{connectingFrom:w,connectingTo:j,clickConnecting:k,isPossibleEndHandle:S,connectionInProcess:N,clickConnectionInProcess:C,valid:M}=ik(t=>{let{connectionClickStartHandle:n,connectionMode:r,connection:a}=t,{fromHandle:i,toHandle:o,isValid:l}=a,s=o?.nodeId===v&&o?.id===p&&o?.type===e;return{connectingFrom:i?.nodeId===v&&i?.id===p&&i?.type===e,connectingTo:s,clickConnecting:n?.nodeId===v&&n?.id===p&&n?.type===e,isPossibleEndHandle:r===A.Strict?i?.type!==e:v!==i?.nodeId||p!==i?.id,connectionInProcess:!!i,clickConnectionInProcess:!!n,valid:s&&l}},ix);v||g.getState().onError?.("010","Handle: No node id found. Make sure to only use a Handle inside a custom Node.");let E=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),a={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(((e,t,n={})=>{let r,a;if(!e.source||!e.target)return ao("006","Can't create edge. An edge needs a source and a target."),t;let i=n.getEdgeId||aP;return(a=r=rG(e)?{...e}:{...e,id:i(e)},t.some(e=>e.source===a.source&&e.target===a.target&&(e.sourceHandle===a.sourceHandle||!e.sourceHandle&&!a.sourceHandle)&&(e.targetHandle===a.targetHandle||!e.targetHandle&&!a.targetHandle)))?t:(null===r.sourceHandle&&delete r.sourceHandle,null===r.targetHandle&&delete r.targetHandle,t.concat(r))})(a,e))}n?.(a),l?.(a)},O=e=>{if(!v)return;let t="clientX"in e.nativeEvent;if(a&&(t&&0===e.button||!t)){let t=g.getState();a4(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:m,handleId:p,nodeId:v,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:E,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?d?.(e):u?.(e)};return(0,ey.jsx)("div",{"data-handleid":p,"data-nodeid":v,"data-handlepos":t,"data-id":`${b}-${v}-${p}-${e}`,className:tf(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,c,{source:!m,target:m,connectable:r,connectablestart:a,connectableend:i,clickconnecting:k,connectingfrom:w,connectingto:j,valid:M,connectionindicator:r&&(!N||S)&&(N||C?i:a)}]),onMouseDown:O,onTouchStart:O,onClick:x?t=>{let{onClickConnectStart:r,onClickConnectEnd:i,connectionClickStartHandle:o,connectionMode:l,isValidConnection:s,lib:c,rfId:d,nodeLookup:u,connection:f}=g.getState();if(!v||!o&&!a)return;if(!o){r?.(t.nativeEvent,{nodeId:v,handleId:p,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:v,type:e,id:p}});return}let h=ab(t.target),m=n||s,{connection:x,isValid:y}=a5(t.nativeEvent,{handle:{nodeId:v,id:p,type:e},connectionMode:l,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:m,flowId:d,doc:h,lib:c,nodeLookup:u});y&&x&&E(x);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,i?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:h,...f,children:s})})),oy={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ob={input:function({data:e,isConnectable:t,sourcePosition:n=_.Bottom}){return(0,ey.jsxs)(ey.Fragment,{children:[e?.label,(0,ey.jsx)(ox,{type:"source",position:n,isConnectable:t})]})},default:function({data:e,isConnectable:t,targetPosition:n=_.Top,sourcePosition:r=_.Bottom}){return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ox,{type:"target",position:n,isConnectable:t}),e?.label,(0,ey.jsx)(ox,{type:"source",position:r,isConnectable:t})]})},output:function({data:e,isConnectable:t,targetPosition:n=_.Top}){return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ox,{type:"target",position:n,isConnectable:t}),e?.label]})},group:function(){return null}},ow=e=>{let{width:t,height:n,x:r,y:a}=rZ(e.nodeLookup,{filter:e=>!!e.selected});return{width:ai(t)?t:null,height:ai(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${a}px)`}};function oj({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=iS(),{width:a,height:i,transformString:o,userSelectionActive:l}=ik(ow,ix),s=oh(),c=(0,ew.useRef)(null);(0,ew.useEffect)(()=>{n||c.current?.focus({preventScroll:!0})},[n]);let d=!l&&null!==a&&null!==i;if(of({nodeRef:c,disabled:!d}),!d)return null;let u=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,ey.jsx)("div",{className:tf(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:(0,ey.jsx)("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(oy,e.key)&&(e.preventDefault(),s({direction:oy[e.key],factor:e.shiftKey?4:1}))},style:{width:a,height:i}})})}let ok="u">typeof window?window:void 0,oS=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function oN({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:l,deleteKeyCode:s,selectionKeyCode:c,selectionOnDrag:d,selectionMode:u,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:p,panActivationKeyCode:m,zoomActivationKeyCode:g,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:w,panOnScrollMode:j,zoomOnDoubleClick:k,panOnDrag:S,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:E,preventScrolling:O,onSelectionContextMenu:P,noWheelClassName:A,noPanClassName:I,disableKeyboardA11y:z,onViewportChange:T,isControlledViewport:D}){let{nodesSelectionActive:_,userSelectionActive:R}=ik(oS,ix),L=iY(c,{target:ok}),$=iY(m,{target:ok}),F=$||S,B=$||b,V=d&&!0!==F,H=L||R||V;return!function({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=iS(),{deleteElements:r}=oe(),a=iY(e,{actInsideInputWithModifier:!1}),i=iY(t,{target:on});(0,ew.useEffect)(()=>{if(a){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(ot),edges:e.filter(ot)}),n.setState({nodesSelectionActive:!1})}},[a]),(0,ew.useEffect)(()=>{n.setState({multiSelectionActive:i})},[i])}({deleteKeyCode:s,multiSelectionKeyCode:p}),(0,ey.jsx)(oi,{onPaneContextMenu:i,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:y,panOnScroll:B,panOnScrollSpeed:w,panOnScrollMode:j,zoomOnDoubleClick:k,panOnDrag:!L&&F,defaultViewport:N,translateExtent:C,minZoom:M,maxZoom:E,zoomActivationKeyCode:g,preventScrolling:O,noWheelClassName:A,noPanClassName:I,onViewportChange:T,isControlledViewport:D,paneClickDistance:l,selectionOnDrag:V,children:(0,ey.jsxs)(od,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:F,isSelecting:!!H,selectionMode:u,selectionKeyPressed:L,paneClickDistance:l,selectionOnDrag:V,children:[e,_&&(0,ey.jsx)(oj,{onSelectionContextMenu:P,noPanClassName:I,disableKeyboardA11y:z})]})})}oN.displayName="FlowRenderer";let oC=(0,ew.memo)(oN),oM=e=>e.updateNodeInternals;var oE=(0,ew.memo)(function({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:a,onContextMenu:i,onDoubleClick:o,nodesDraggable:l,elementsSelectable:s,nodesConnectable:c,nodesFocusable:d,resizeObserver:u,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:p,rfId:m,nodeTypes:g,nodeClickDistance:v,onError:x}){let y,{node:b,internals:w,isParent:j}=ik(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},ix),k=b.type||"default",S=g?.[k]||ob[k];void 0===S&&(x?.("003",(y=k,`Node type "${y}" not found. Using fallback type "default".`)),k="default",S=g?.default||ob.default);let N=!!(b.draggable||l&&void 0===b.draggable),C=!!(b.selectable||s&&void 0===b.selectable),M=!!(b.connectable||c&&void 0===b.connectable),E=!!(b.focusable||d&&void 0===b.focusable),O=iS(),P=am(b),A=function({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let a=iS(),i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=(0,ew.useRef)(e.sourcePosition),s=(0,ew.useRef)(e.targetPosition),c=(0,ew.useRef)(t),d=n&&!!e.internals.handleBounds;return(0,ew.useEffect)(()=>{!i.current||e.hidden||d&&o.current===i.current||(o.current&&r?.unobserve(o.current),r?.observe(i.current),o.current=i.current)},[d,e.hidden]),(0,ew.useEffect)(()=>()=>{o.current&&(r?.unobserve(o.current),o.current=null)},[]),(0,ew.useEffect)(()=>{if(i.current){let n=c.current!==t,r=l.current!==e.sourcePosition,o=s.current!==e.targetPosition;(n||r||o)&&(c.current=t,l.current=e.sourcePosition,s.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}({node:b,nodeType:k,hasDimensions:P,resizeObserver:u}),I=of({nodeRef:A,disabled:b.hidden||!N,noDragClassName:f,handleSelector:b.dragHandle,nodeId:e,isSelectable:C,nodeClickDistance:v}),z=oh();if(b.hidden)return null;let T=ap(b),D=void 0===b.internals.handleBounds?{width:b.width??b.initialWidth??b.style?.width,height:b.height??b.initialHeight??b.style?.height}:{width:b.width??b.style?.width,height:b.height??b.style?.height},_=C||N||t||n||r||a,R=n?e=>n(e,{...w.userNode}):void 0,L=r?e=>r(e,{...w.userNode}):void 0,$=a?e=>a(e,{...w.userNode}):void 0,F=i?e=>i(e,{...w.userNode}):void 0,B=o?e=>o(e,{...w.userNode}):void 0;return(0,ey.jsx)("div",{className:tf(["react-flow__node",`react-flow__node-${k}`,{[h]:N},b.className,{selected:b.selected,selectable:C,parent:j,draggable:N,dragging:I}]),ref:A,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:_?"all":"none",visibility:P?"visible":"hidden",...b.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:L,onMouseLeave:$,onContextMenu:F,onClick:n=>{let{selectNodesOnDrag:r,nodeDragThreshold:a}=O.getState();C&&(!r||!N||a>0)&&ou({id:e,store:O,nodeRef:A}),t&&t(n,{...w.userNode})},onDoubleClick:B,onKeyDown:E?t=>{if(!aj(t.nativeEvent)&&!p){if(rH.includes(t.key)&&C)ou({id:e,store:O,unselect:"Escape"===t.key,nodeRef:A});else if(N&&b.selected&&Object.prototype.hasOwnProperty.call(oy,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e["node.a11yDescription.ariaLiveMessage"]({direction:t.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),z({direction:oy[t.key],factor:t.shiftKey?4:1})}}}:void 0,tabIndex:E?0:void 0,onFocus:E?()=>{if(p||!A.current?.matches(":focus-visible"))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:a,setCenter:i}=O.getState();!a||rJ(new Map([[e,b]]),{x:0,y:0,width:n,height:r},t,!0).length>0||i(b.position.x+T.width/2,b.position.y+T.height/2,{zoom:t[2]})}:void 0,role:b.ariaRole??(E?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${iM}-${m}`,"aria-label":b.ariaLabel,...b.domAttributes,children:(0,ey.jsx)(om,{value:e,children:(0,ey.jsx)(S,{id:e,data:b.data,type:k,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:b.selected??!1,selectable:C,draggable:N,deletable:b.deletable??!0,isConnectable:M,sourcePosition:b.sourcePosition,targetPosition:b.targetPosition,dragging:I,dragHandle:b.dragHandle,zIndex:w.z,parentId:b.parentId,...T})})})});let oO=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function oP(e){var t;let{nodesDraggable:n,nodesConnectable:r,nodesFocusable:a,elementsSelectable:i,onError:o}=ik(oO,ix),l=(t=e.onlyRenderVisibleElements,ik((0,ew.useCallback)(e=>t?rJ(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(e=>e.id):Array.from(e.nodeLookup.keys()),[t]),ix)),s=function(){let e=ik(oM),[t]=(0,ew.useState)(()=>"u"<typeof ResizeObserver?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,ew.useEffect)(()=>()=>{t?.disconnect()},[t]),t}();return(0,ey.jsx)("div",{className:"react-flow__nodes",style:or,children:l.map(t=>(0,ey.jsx)(oE,{id:t,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:n,nodesConnectable:r,nodesFocusable:a,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:o},t))})}oP.displayName="NodeRenderer";let oA=(0,ew.memo)(oP),oI={[D.Arrow]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,ey.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},[D.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,ey.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})}},oz=({id:e,type:t,color:n,width:r=12.5,height:a=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{let s,c=(s=iS(),(0,ew.useMemo)(()=>{let e;return Object.prototype.hasOwnProperty.call(oI,t)?oI[t]:(s.getState().onError?.("009",(e=t,`Marker type "${e}" doesn't exist.`)),null)},[t]));return c?(0,ey.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:(0,ey.jsx)(c,{color:n,strokeWidth:o})}):null},oT=({defaultColor:e,rfId:t})=>{let n=ik(e=>e.edges),r=ik(e=>e.defaultEdgeOptions),a=(0,ew.useMemo)(()=>(function(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:a}){let i=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||a].forEach(r=>{if(r&&"object"==typeof r){let a=aF(r,t);i.has(a)||(e.push({id:a,color:r.color||n,...r}),i.add(a))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))})(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return a.length?(0,ey.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,ey.jsx)("defs",{children:a.map(e=>(0,ey.jsx)(oz,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};oT.displayName="MarkerDefinitions";var oD=(0,ew.memo)(oT);function o_({x:e,y:t,label:n,labelStyle:r,labelShowBg:a=!0,labelBgStyle:i,labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:s,className:c,...d}){let[u,f]=(0,ew.useState)({x:1,y:0,width:0,height:0}),h=tf(["react-flow__edge-textwrapper",c]),p=(0,ew.useRef)(null);return((0,ew.useEffect)(()=>{if(p.current){let e=p.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n)?(0,ey.jsxs)("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...d,children:[a&&(0,ey.jsx)("rect",{width:u.width+2*o[0],x:-o[0],y:-o[1],height:u.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),(0,ey.jsx)("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:p,style:r,children:n}),s]}):null}o_.displayName="EdgeText";let oR=(0,ew.memo)(o_);function oL({path:e,labelX:t,labelY:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:s,interactionWidth:c=20,...d}){return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("path",{...d,d:e,fill:"none",className:tf(["react-flow__edge-path",d.className])}),c?(0,ey.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,r&&ai(t)&&ai(n)?(0,ey.jsx)(oR,{x:t,y:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:s}):null]})}function o$({pos:e,x1:t,y1:n,x2:r,y2:a}){return e===_.Left||e===_.Right?[.5*(t+r),n]:[t,.5*(n+a)]}function oF({sourceX:e,sourceY:t,sourcePosition:n=_.Bottom,targetX:r,targetY:a,targetPosition:i=_.Top}){let[o,l]=o$({pos:n,x1:e,y1:t,x2:r,y2:a}),[s,c]=o$({pos:i,x1:r,y1:a,x2:e,y2:t}),[d,u,f,h]=aN({sourceX:e,sourceY:t,targetX:r,targetY:a,sourceControlX:o,sourceControlY:l,targetControlX:s,targetControlY:c});return[`M${e},${t} C${o},${l} ${s},${c} ${r},${a}`,d,u,f,h]}function oB(e){return(0,ew.memo)(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:o,targetPosition:l,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:g,interactionWidth:v})=>{let[x,y,b]=oF({sourceX:n,sourceY:r,sourcePosition:o,targetX:a,targetY:i,targetPosition:l}),w=e.isInternal?void 0:t;return(0,ey.jsx)(oL,{id:w,path:x,labelX:y,labelY:b,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:g,interactionWidth:v})})}let oV=oB({isInternal:!1}),oH=oB({isInternal:!0});function oU(e){return(0,ew.memo)(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:i,label:o,labelStyle:l,labelShowBg:s,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,sourcePosition:h=_.Bottom,targetPosition:p=_.Top,markerEnd:m,markerStart:g,pathOptions:v,interactionWidth:x})=>{let[y,b,w]=aD({sourceX:n,sourceY:r,sourcePosition:h,targetX:a,targetY:i,targetPosition:p,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),j=e.isInternal?void 0:t;return(0,ey.jsx)(oL,{id:j,path:y,labelX:b,labelY:w,label:o,labelStyle:l,labelShowBg:s,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:m,markerStart:g,interactionWidth:x})})}oV.displayName="SimpleBezierEdge",oH.displayName="SimpleBezierEdgeInternal";let oW=oU({isInternal:!1}),oq=oU({isInternal:!0});function oK(e){return(0,ew.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,ey.jsx)(oW,{...n,id:r,pathOptions:(0,ew.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}oW.displayName="SmoothStepEdge",oq.displayName="SmoothStepEdgeInternal";let oG=oK({isInternal:!1}),oX=oK({isInternal:!0});function oY(e){return(0,ew.memo)(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:i,label:o,labelStyle:l,labelShowBg:s,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:p,interactionWidth:m})=>{let[g,v,x]=aA({sourceX:n,sourceY:r,targetX:a,targetY:i}),y=e.isInternal?void 0:t;return(0,ey.jsx)(oL,{id:y,path:g,labelX:v,labelY:x,label:o,labelStyle:l,labelShowBg:s,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:p,interactionWidth:m})})}oG.displayName="StepEdge",oX.displayName="StepEdgeInternal";let oZ=oY({isInternal:!1}),oJ=oY({isInternal:!0});function oQ(e){return(0,ew.memo)(({id:t,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:o=_.Bottom,targetPosition:l=_.Top,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:g,pathOptions:v,interactionWidth:x})=>{let[y,b,w]=aE({sourceX:n,sourceY:r,sourcePosition:o,targetX:a,targetY:i,targetPosition:l,curvature:v?.curvature}),j=e.isInternal?void 0:t;return(0,ey.jsx)(oL,{id:j,path:y,labelX:b,labelY:w,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:g,interactionWidth:x})})}oZ.displayName="StraightEdge",oJ.displayName="StraightEdgeInternal";let o0=oQ({isInternal:!1}),o1=oQ({isInternal:!0});o0.displayName="BezierEdge",o1.displayName="BezierEdgeInternal";let o2={default:o1,straight:oJ,step:oX,smoothstep:oq,simplebezier:oH},o5={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},o4="react-flow__edgeupdater";function o3({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:a,onMouseEnter:i,onMouseOut:o,type:l}){return(0,ey.jsx)("circle",{onMouseDown:a,onMouseEnter:i,onMouseOut:o,className:tf([o4,`${o4}-${l}`]),cx:e===_.Left?t-r:e===_.Right?t+r:t,cy:e===_.Top?n-r:e===_.Bottom?n+r:n,r:r,stroke:"transparent",fill:"transparent"})}function o6({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:a,targetX:i,targetY:o,sourcePosition:l,targetPosition:s,onReconnect:c,onReconnectStart:d,onReconnectEnd:u,setReconnecting:f,setUpdateHover:h}){let p=iS(),m=(e,t)=>{if(0!==e.button)return;let{autoPanOnConnect:r,domNode:a,connectionMode:i,connectionRadius:o,lib:l,onConnectStart:s,cancelConnection:h,nodeLookup:m,rfId:g,panBy:v,updateConnection:x}=p.getState(),y="target"===t.type;a4(e.nativeEvent,{autoPanOnConnect:r,connectionMode:i,connectionRadius:o,domNode:a,handleId:t.id,nodeId:t.nodeId,nodeLookup:m,isTarget:y,edgeUpdaterType:t.type,lib:l,flowId:g,cancelConnection:h,panBy:v,isValidConnection:(...e)=>p.getState().isValidConnection?.(...e)??!0,onConnect:e=>c?.(n,e),onConnectStart:(r,a)=>{f(!0),d?.(e,n,t.type),s?.(r,a)},onConnectEnd:(...e)=>p.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),u?.(e,n,t.type,r)},updateConnection:x,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=()=>h(!0),v=()=>h(!1);return(0,ey.jsxs)(ey.Fragment,{children:[(!0===e||"source"===e)&&(0,ey.jsx)(o3,{position:l,centerX:r,centerY:a,radius:t,onMouseDown:e=>m(e,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),onMouseEnter:g,onMouseOut:v,type:"source"}),(!0===e||"target"===e)&&(0,ey.jsx)(o3,{position:s,centerX:i,centerY:o,radius:t,onMouseDown:e=>m(e,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),onMouseEnter:g,onMouseOut:v,type:"target"})]})}var o8=(0,ew.memo)(function({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:a,onDoubleClick:i,onContextMenu:o,onMouseEnter:l,onMouseMove:s,onMouseLeave:c,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,rfId:p,edgeTypes:m,noPanClassName:g,onError:v,disableKeyboardA11y:x}){let y,b=ik(t=>t.edgeLookup.get(e)),w=ik(e=>e.defaultEdgeOptions),j=(b=w?{...w,...b}:b).type||"default",k=m?.[j]||o2[j];void 0===k&&(v?.("011",(y=j,`Edge type "${y}" not found. Using fallback type "default".`)),j="default",k=m?.default||o2.default);let S=!!(b.focusable||t&&void 0===b.focusable),N=void 0!==u&&(b.reconnectable||n&&void 0===b.reconnectable),C=!!(b.selectable||r&&void 0===b.selectable),M=(0,ew.useRef)(null),[E,O]=(0,ew.useState)(!1),[P,I]=(0,ew.useState)(!1),z=iS(),{zIndex:T,sourceX:D,sourceY:R,targetX:L,targetY:$,sourcePosition:F,targetPosition:B}=ik((0,ew.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return{zIndex:b.zIndex,...o5};let a=function(e){let{sourceNode:t,targetNode:n}=e;if(!a_(t)||!a_(n))return null;let r=t.internals.handleBounds||aR(t.handles),a=n.internals.handleBounds||aR(n.handles),i=a$(r?.source??[],e.sourceHandle),o=a$(e.connectionMode===A.Strict?a?.target??[]:(a?.target??[]).concat(a?.source??[]),e.targetHandle);if(!i||!o)return e.onError?.("008",((e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${"source"===e?n:r}", edge id: ${t}.`)(!i?"source":"target",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let l=i?.position||_.Bottom,s=o?.position||_.Top,c=aL(t,i,l),d=aL(n,o,s);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:s}}({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:v});return{zIndex:function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:a=!1,zIndexMode:i="basic"}){if("manual"===i)return r;let o=Math.max(e.parentId||a&&e.selected?e.internals.z:0,t.parentId||a&&t.selected?t.internals.z:0);return(a&&n?r+1e3:r)+o}({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...a||o5}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),ix),V=(0,ew.useMemo)(()=>b.markerStart?`url('#${aF(b.markerStart,p)}')`:void 0,[b.markerStart,p]),H=(0,ew.useMemo)(()=>b.markerEnd?`url('#${aF(b.markerEnd,p)}')`:void 0,[b.markerEnd,p]);if(b.hidden||null===D||null===R||null===L||null===$)return null;let U=i?e=>{i(e,{...b})}:void 0,W=o?e=>{o(e,{...b})}:void 0,q=l?e=>{l(e,{...b})}:void 0,K=s?e=>{s(e,{...b})}:void 0,G=c?e=>{c(e,{...b})}:void 0;return(0,ey.jsx)("svg",{style:{zIndex:T},children:(0,ey.jsxs)("g",{className:tf(["react-flow__edge",`react-flow__edge-${j}`,b.className,g,{selected:b.selected,animated:b.animated,inactive:!C&&!a,updating:E,selectable:C}]),onClick:t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:i}=z.getState();C&&(z.setState({nodesSelectionActive:!1}),b.selected&&i?(r({nodes:[],edges:[b]}),M.current?.blur()):n([e])),a&&a(t,b)},onDoubleClick:U,onContextMenu:W,onMouseEnter:q,onMouseMove:K,onMouseLeave:G,onKeyDown:S?t=>{if(!x&&rH.includes(t.key)&&C){let{unselectNodesAndEdges:n,addSelectedEdges:r}=z.getState();"Escape"===t.key?(M.current?.blur(),n({edges:[b]})):r([e])}}:void 0,tabIndex:S?0:void 0,role:b.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":null===b.ariaLabel?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":S?`${iE}-${p}`:void 0,ref:M,...b.domAttributes,children:[!P&&(0,ey.jsx)(k,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:C,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:D,sourceY:R,targetX:L,targetY:$,sourcePosition:F,targetPosition:B,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:V,markerEnd:H,pathOptions:"pathOptions"in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),N&&(0,ey.jsx)(o6,{edge:b,isReconnectable:N,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,sourceX:D,sourceY:R,targetX:L,targetY:$,sourcePosition:F,targetPosition:B,setUpdateHover:O,setReconnecting:I})]})})});let o7=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function o9({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:a,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:s,onEdgeMouseLeave:c,onEdgeClick:d,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,disableKeyboardA11y:m}){let{edgesFocusable:g,edgesReconnectable:v,elementsSelectable:x,onError:y}=ik(o7,ix),b=ik((0,ew.useCallback)(e=>{if(!t)return e.edges.map(e=>e.id);let n=[];if(e.width&&e.height)for(let t of e.edges){let r=e.nodeLookup.get(t.source),a=e.nodeLookup.get(t.target);r&&a&&function({sourceNode:e,targetNode:t,width:n,height:r,transform:a}){let i=r8(at(e),at(t));return i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1),ar({x:-a[0]/a[2],y:-a[1]/a[2],width:n/a[2],height:r/a[2]},r9(i))>0}({sourceNode:r,targetNode:a,width:e.width,height:e.height,transform:e.transform})&&n.push(t.id)}return n},[t]),ix);return(0,ey.jsxs)("div",{className:"react-flow__edges",children:[(0,ey.jsx)(oD,{defaultColor:e,rfId:n}),b.map(e=>(0,ey.jsx)(o8,{id:e,edgesFocusable:g,edgesReconnectable:v,elementsSelectable:x,noPanClassName:a,onReconnect:i,onContextMenu:o,onMouseEnter:l,onMouseMove:s,onMouseLeave:c,onClick:d,reconnectRadius:u,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:m},e))]})}o9.displayName="EdgeRenderer";let le=(0,ew.memo)(o9),lt=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function ln({children:e}){let t=ik(lt);return(0,ey.jsx)("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}let lr=e=>e.panZoom?.syncViewport;function la(e){return e.connection.inProgress?{...e.connection,to:as(e.connection.to,e.transform)}:{...e.connection}}let li=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lo({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:a,width:i,height:o,isValid:l,inProgress:s}=ik(li,ix);return i&&a&&s?(0,ey.jsx)("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:(0,ey.jsx)("g",{className:tf(["react-flow__connection",rK(l)]),children:(0,ey.jsx)(ll,{style:t,type:n,CustomComponent:r,isValid:l})})}):null}let ll=({style:e,type:t=T.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:a,from:i,fromNode:o,fromHandle:l,fromPosition:s,to:c,toNode:d,toHandle:u,toPosition:f,pointer:h}=ik(la,ix);if(!a)return;if(n)return(0,ey.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:l,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:s,toPosition:f,connectionStatus:rK(r),toNode:d,toHandle:u,pointer:h});let p="",m={sourceX:i.x,sourceY:i.y,sourcePosition:s,targetX:c.x,targetY:c.y,targetPosition:f};switch(t){case T.Bezier:[p]=aE(m);break;case T.SimpleBezier:[p]=oF(m);break;case T.Step:[p]=aD({...m,borderRadius:0});break;case T.SmoothStep:[p]=aD(m);break;default:[p]=aA(m)}return(0,ey.jsx)("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};ll.displayName="ConnectionLine";let ls={};function lc(e=ls){(0,ew.useRef)(e),iS(),(0,ew.useEffect)(()=>{},[e])}function ld({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:a,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:s,onNodeMouseLeave:c,onNodeContextMenu:d,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:h,connectionLineType:p,connectionLineStyle:m,connectionLineComponent:g,connectionLineContainerStyle:v,selectionKeyCode:x,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:w,panActivationKeyCode:j,zoomActivationKeyCode:k,deleteKeyCode:S,onlyRenderVisibleElements:N,elementsSelectable:C,defaultViewport:M,translateExtent:E,minZoom:O,maxZoom:P,preventScrolling:A,defaultMarkerColor:I,zoomOnScroll:z,zoomOnPinch:T,panOnScroll:D,panOnScrollSpeed:_,panOnScrollMode:R,zoomOnDoubleClick:L,panOnDrag:$,onPaneClick:F,onPaneMouseEnter:B,onPaneMouseMove:V,onPaneMouseLeave:H,onPaneScroll:U,onPaneContextMenu:W,paneClickDistance:q,nodeClickDistance:K,onEdgeContextMenu:G,onEdgeMouseEnter:X,onEdgeMouseMove:Y,onEdgeMouseLeave:Z,reconnectRadius:J,onReconnect:Q,onReconnectStart:ee,onReconnectEnd:et,noDragClassName:en,noWheelClassName:er,noPanClassName:ea,disableKeyboardA11y:ei,nodeExtent:eo,rfId:el,viewport:es,onViewportChange:ec}){let ed,eu,ef,eh;return lc(e),lc(t),iS(),(0,ew.useRef)(!1),(0,ew.useEffect)(()=>{},[]),ed=oe(),eu=(0,ew.useRef)(!1),(0,ew.useEffect)(()=>{!eu.current&&ed.viewportInitialized&&n&&(setTimeout(()=>n(ed),1),eu.current=!0)},[n,ed.viewportInitialized]),ef=ik(lr),eh=iS(),(0,ew.useEffect)(()=>{es&&(ef?.(es),eh.setState({transform:[es.x,es.y,es.zoom]}))},[es,ef]),(0,ey.jsx)(oC,{onPaneClick:F,onPaneMouseEnter:B,onPaneMouseMove:V,onPaneMouseLeave:H,onPaneContextMenu:W,onPaneScroll:U,paneClickDistance:q,deleteKeyCode:S,selectionKeyCode:x,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:w,panActivationKeyCode:j,zoomActivationKeyCode:k,elementsSelectable:C,zoomOnScroll:z,zoomOnPinch:T,zoomOnDoubleClick:L,panOnScroll:D,panOnScrollSpeed:_,panOnScrollMode:R,panOnDrag:$,defaultViewport:M,translateExtent:E,minZoom:O,maxZoom:P,onSelectionContextMenu:u,preventScrolling:A,noDragClassName:en,noWheelClassName:er,noPanClassName:ea,disableKeyboardA11y:ei,onViewportChange:ec,isControlledViewport:!!es,children:(0,ey.jsxs)(ln,{children:[(0,ey.jsx)(le,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:o,onReconnect:Q,onReconnectStart:ee,onReconnectEnd:et,onlyRenderVisibleElements:N,onEdgeContextMenu:G,onEdgeMouseEnter:X,onEdgeMouseMove:Y,onEdgeMouseLeave:Z,reconnectRadius:J,defaultMarkerColor:I,noPanClassName:ea,disableKeyboardA11y:ei,rfId:el}),(0,ey.jsx)(lo,{style:m,type:p,component:g,containerStyle:v}),(0,ey.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,ey.jsx)(oA,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:s,onNodeMouseLeave:c,onNodeContextMenu:d,nodeClickDistance:K,onlyRenderVisibleElements:N,noPanClassName:ea,noDragClassName:en,disableKeyboardA11y:ei,nodeExtent:eo,rfId:el}),(0,ey.jsx)("div",{className:"react-flow__viewport-portal"})]})})}ld.displayName="GraphView";let lu=(0,ew.memo)(ld),lf=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:o,fitViewOptions:l,minZoom:s=.5,maxZoom:c=2,nodeOrigin:d,nodeExtent:u,zIndexMode:f="basic"}={})=>{let h=new Map,p=new Map,m=new Map,g=new Map,v=r??t??[],x=n??e??[],y=d??[0,0],b=u??rV;aZ(m,g,v);let{nodesInitialized:w}=aW(x,h,p,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),j=[0,0,1];if(o&&a&&i){let{x:e,y:t,zoom:n}=au(rZ(h,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),a,i,s,c,l?.padding??.1);j=[e,t,n]}return{rfId:"1",width:a??0,height:i??0,transform:j,nodes:x,nodesInitialized:w,nodeLookup:h,parentLookup:p,edges:v,edgeLookup:g,connectionLookup:m,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==n,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:s,maxZoom:c,translateExtent:rV,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:A.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:l,fitViewResolver:null,connection:{...rW},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ao,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:rU,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}};function lh({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:a,initialHeight:i,initialMinZoom:o,initialMaxZoom:l,initialFitViewOptions:s,fitView:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f,children:h}){let[p]=(0,ew.useState)(()=>(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:o,fitViewOptions:l,minZoom:s,maxZoom:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f})=>{let h,p;return h=(h,p)=>{async function m(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:a,height:i,minZoom:o,maxZoom:l}=p();t&&(await rQ({nodes:e,width:a,height:i,panZoom:t,minZoom:o,maxZoom:l},n),r?.resolve(!0),h({fitViewResolver:null}))}return{...lf({nodes:e,edges:t,width:a,height:i,fitView:o,fitViewOptions:l,minZoom:s,maxZoom:c,nodeOrigin:d,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:a,fitViewQueued:i,zIndexMode:o,nodesSelectionActive:l}=p(),{nodesInitialized:s,hasSelectedNodes:c}=aW(e,t,n,{nodeOrigin:r,nodeExtent:u,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:o}),d=l&&c;i&&s?(m(),h({nodes:e,nodesInitialized:s,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):h({nodes:e,nodesInitialized:s,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=p();aZ(t,n,e),h({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=p();t(e),h({hasDefaultNodes:!0})}if(t){let{setEdges:e}=p();e(t),h({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:a,nodeOrigin:i,nodeExtent:o,debug:l,fitViewQueued:s,zIndexMode:c}=p(),{changes:d,updatedInternals:u}=function(e,t,n,r,a,i,o){let l=r?.querySelector(".xyflow__viewport"),s=!1;if(!l)return{changes:[],updatedInternals:s};let c=[],d=window.getComputedStyle(l),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),s=!0;continue}let l=ay(r.nodeElement),d=e.measured.width!==l.width||e.measured.height!==l.height;if(l.width&&l.height&&(d||!e.internals.handleBounds||r.force)){let h=r.nodeElement.getBoundingClientRect(),p=ah(e.extent)?e.extent:i,{positionAbsolute:m}=e.internals;e.parentId&&"parent"===e.extent?m=r4(m,l,t.get(e.parentId)):p&&(m=r5(m,p,l));let g={...e,measured:l,internals:{...e.internals,positionAbsolute:m,handleBounds:{source:aS("source",r.nodeElement,h,u,e.id),target:aS("target",r.nodeElement,h,u,e.id)}}};t.set(e.id,g),e.parentId&&aq(g,t,n,{nodeOrigin:a,zIndexMode:o}),s=!0,d&&(c.push({id:e.id,type:"dimensions",dimensions:l}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:ae(g,a)}))}}if(f.length>0){let e=aG(f,t,n,a);c.push(...e)}return{changes:c,updatedInternals:s}}(e,n,r,a,i,o,c);u&&(!function(e,t,n){let r=aH(aB,n);for(let n of e.values())if(n.parentId)aq(n,e,t,r);else{let e=r5(rY(n,r.nodeOrigin),ah(n.extent)?n.extent:r.nodeExtent,ap(n));n.internals.positionAbsolute=e}}(n,r,{nodeOrigin:i,nodeExtent:o,zIndexMode:c}),s?(m(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),d?.length>0&&(l&&console.log("React Flow: trigger node changes",d),t?.(d)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:a,triggerNodeChanges:i,connection:o,updateConnection:l,onNodesChangeMiddlewareMap:s}=p();for(let[i,s]of e){let e=a.get(i),c=!!(e?.expandParent&&e?.parentId&&s?.position),d={id:i,type:"position",position:c?{x:Math.max(0,s.position.x),y:Math.max(0,s.position.y)}:s.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=aL(e,o.fromHandle,_.Left,!0);l({...o,from:t})}c&&e.parentId&&n.push({id:i,parentId:e.parentId,rect:{...s.internals.positionAbsolute,width:s.measured.width??0,height:s.measured.height??0}}),r.push(d)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=p(),i=aG(n,a,e,t);r.push(...i)}for(let e of s.values())r=e(r);i(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:a,debug:i}=p();e?.length&&(a&&n(iQ(e,r)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:a,debug:i}=p();e?.length&&(a&&n(iQ(e,r)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:a,triggerEdgeChanges:i}=p();t?a(e.map(e=>i0(e,!0))):(a(i1(r,new Set([...e]),!0)),i(i1(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:a,triggerEdgeChanges:i}=p();t?i(e.map(e=>i0(e,!0))):(i(i1(n,new Set([...e]))),a(i1(r,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:a,triggerNodeChanges:i,triggerEdgeChanges:o}=p(),l=[];for(let t of e||r){if(!t.selected)continue;let e=a.get(t.id);e&&(e.selected=!1),l.push(i0(t.id,!1))}let s=[];for(let e of t||n)e.selected&&s.push(i0(e.id,!1));i(l),o(s)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=p();t?.setScaleExtent([e,n]),h({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=p();t?.setScaleExtent([n,e]),h({maxZoom:e})},setTranslateExtent:e=>{p().panZoom?.setTranslateExtent(e),h({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:a}=p();if(!a)return;let i=t.reduce((e,t)=>t.selected?[...e,i0(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,i0(t.id,!1)]:e,[]);n(i),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:a,elevateNodesOnSelect:i,nodeExtent:o,zIndexMode:l}=p();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(aW(t,n,r,{nodeOrigin:a,nodeExtent:e,elevateNodesOnSelect:i,checkEquality:!1,zIndexMode:l}),h({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:a,translateExtent:i}=p();return aX({delta:e,panZoom:a,transform:t,translateExtent:i,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:a,maxZoom:i,panZoom:o}=p();if(!o)return Promise.resolve(!1);let l=void 0!==n?.zoom?n.zoom:i;return await o.setViewport({x:r/2-e*l,y:a/2-t*l,zoom:l},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...rW}})},updateConnection:e=>{h({connection:e})},reset:()=>h({...lf()})}},p=Object.is,h?iv(h,p):iv})({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:c,minZoom:o,maxZoom:l,fitViewOptions:s,nodeOrigin:d,nodeExtent:u,zIndexMode:f}));return(0,ey.jsx)(iw,{value:p,children:(0,ey.jsx)(i7,{children:h})})}function lp({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:a,width:i,height:o,fitView:l,fitViewOptions:s,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h}){return(0,ew.useContext)(ib)?(0,ey.jsx)(ey.Fragment,{children:e}):(0,ey.jsx)(lh,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:a,initialWidth:i,initialHeight:o,fitView:l,initialFitViewOptions:s,initialMinZoom:c,initialMaxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h,children:e})}let lm={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var lg=i3(function({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:a,nodeTypes:i,edgeTypes:o,onNodeClick:l,onEdgeClick:s,onInit:c,onMove:d,onMoveStart:u,onMoveEnd:f,onConnect:h,onConnectStart:p,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:v,onNodeMouseEnter:x,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:w,onNodeDoubleClick:j,onNodeDragStart:k,onNodeDrag:S,onNodeDragStop:N,onNodesDelete:C,onEdgesDelete:M,onDelete:E,onSelectionChange:O,onSelectionDragStart:P,onSelectionDrag:A,onSelectionDragStop:D,onSelectionContextMenu:_,onSelectionStart:R,onSelectionEnd:L,onBeforeDelete:$,connectionMode:F,connectionLineType:B=T.Bezier,connectionLineStyle:V,connectionLineComponent:H,connectionLineContainerStyle:U,deleteKeyCode:W="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:K=!1,selectionMode:G=z.Full,panActivationKeyCode:X="Space",multiSelectionKeyCode:Y=af()?"Meta":"Control",zoomActivationKeyCode:Z=af()?"Meta":"Control",snapToGrid:J,snapGrid:Q,onlyRenderVisibleElements:ee=!1,selectNodesOnDrag:et,nodesDraggable:en,autoPanOnNodeFocus:er,nodesConnectable:ea,nodesFocusable:ei,nodeOrigin:eo=iV,edgesFocusable:el,edgesReconnectable:es,elementsSelectable:ec=!0,defaultViewport:ed=iH,minZoom:eu=.5,maxZoom:ef=2,translateExtent:eh=rV,preventScrolling:ep=!0,nodeExtent:em,defaultMarkerColor:eg="#b1b1b7",zoomOnScroll:ev=!0,zoomOnPinch:ex=!0,panOnScroll:eb=!1,panOnScrollSpeed:ej=.5,panOnScrollMode:ek=I.Free,zoomOnDoubleClick:eS=!0,panOnDrag:eN=!0,onPaneClick:eC,onPaneMouseEnter:eM,onPaneMouseMove:eE,onPaneMouseLeave:eO,onPaneScroll:eP,onPaneContextMenu:eA,paneClickDistance:eI=1,nodeClickDistance:ez=0,children:eT,onReconnect:eD,onReconnectStart:e_,onReconnectEnd:eR,onEdgeContextMenu:eL,onEdgeDoubleClick:e$,onEdgeMouseEnter:eF,onEdgeMouseMove:eB,onEdgeMouseLeave:eV,reconnectRadius:eH=10,onNodesChange:eU,onEdgesChange:eW,noDragClassName:eq="nodrag",noWheelClassName:eK="nowheel",noPanClassName:eG="nopan",fitView:eX,fitViewOptions:eY,connectOnClick:eZ,attributionPosition:eJ,proOptions:eQ,defaultEdgeOptions:e0,elevateNodesOnSelect:e1=!0,elevateEdgesOnSelect:e2=!1,disableKeyboardA11y:e5=!1,autoPanOnConnect:e4,autoPanOnNodeDrag:e3,autoPanSpeed:e6,connectionRadius:e8,isValidConnection:e7,onError:e9,style:te,id:tt,nodeDragThreshold:tn,connectionDragThreshold:tr,viewport:ta,onViewportChange:ti,width:to,height:tl,colorMode:ts="light",debug:tc,onScroll:td,ariaLabelConfig:tu,zIndexMode:th="basic",...tp},tm){let tg=tt||"1",tv=function(e){let[t,n]=(0,ew.useState)("system"===e?null:e);return(0,ew.useEffect)(()=>{if("system"!==e)return void n(e);let t=iG(),r=()=>n(t?.matches?"dark":"light");return r(),t?.addEventListener("change",r),()=>{t?.removeEventListener("change",r)}},[e]),null!==t?t:iG()?.matches?"dark":"light"}(ts),tx=(0,ew.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),td?.(e)},[td]);return(0,ey.jsx)("div",{"data-testid":"rf__wrapper",...tp,onScroll:tx,style:{...te,...lm},ref:tm,className:tf(["react-flow",a,tv]),id:tt,role:"application",children:(0,ey.jsxs)(lp,{nodes:e,edges:t,width:to,height:tl,fitView:eX,fitViewOptions:eY,minZoom:eu,maxZoom:ef,nodeOrigin:eo,nodeExtent:em,zIndexMode:th,children:[(0,ey.jsx)(iK,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:p,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:v,nodesDraggable:en,autoPanOnNodeFocus:er,nodesConnectable:ea,nodesFocusable:ei,edgesFocusable:el,edgesReconnectable:es,elementsSelectable:ec,elevateNodesOnSelect:e1,elevateEdgesOnSelect:e2,minZoom:eu,maxZoom:ef,nodeExtent:em,onNodesChange:eU,onEdgesChange:eW,snapToGrid:J,snapGrid:Q,connectionMode:F,translateExtent:eh,connectOnClick:eZ,defaultEdgeOptions:e0,fitView:eX,fitViewOptions:eY,onNodesDelete:C,onEdgesDelete:M,onDelete:E,onNodeDragStart:k,onNodeDrag:S,onNodeDragStop:N,onSelectionDrag:A,onSelectionDragStart:P,onSelectionDragStop:D,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:eG,nodeOrigin:eo,rfId:tg,autoPanOnConnect:e4,autoPanOnNodeDrag:e3,autoPanSpeed:e6,onError:e9,connectionRadius:e8,isValidConnection:e7,selectNodesOnDrag:et,nodeDragThreshold:tn,connectionDragThreshold:tr,onBeforeDelete:$,debug:tc,ariaLabelConfig:tu,zIndexMode:th}),(0,ey.jsx)(lu,{onInit:c,onNodeClick:l,onEdgeClick:s,onNodeMouseEnter:x,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:w,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:o,connectionLineType:B,connectionLineStyle:V,connectionLineComponent:H,connectionLineContainerStyle:U,selectionKeyCode:q,selectionOnDrag:K,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:Y,panActivationKeyCode:X,zoomActivationKeyCode:Z,onlyRenderVisibleElements:ee,defaultViewport:ed,translateExtent:eh,minZoom:eu,maxZoom:ef,preventScrolling:ep,zoomOnScroll:ev,zoomOnPinch:ex,zoomOnDoubleClick:eS,panOnScroll:eb,panOnScrollSpeed:ej,panOnScrollMode:ek,panOnDrag:eN,onPaneClick:eC,onPaneMouseEnter:eM,onPaneMouseMove:eE,onPaneMouseLeave:eO,onPaneScroll:eP,onPaneContextMenu:eA,paneClickDistance:eI,nodeClickDistance:ez,onSelectionContextMenu:_,onSelectionStart:R,onSelectionEnd:L,onReconnect:eD,onReconnectStart:e_,onReconnectEnd:eR,onEdgeContextMenu:eL,onEdgeDoubleClick:e$,onEdgeMouseEnter:eF,onEdgeMouseMove:eB,onEdgeMouseLeave:eV,reconnectRadius:eH,defaultMarkerColor:eg,noDragClassName:eq,noWheelClassName:eK,noPanClassName:eG,rfId:tg,disableKeyboardA11y:e5,nodeExtent:em,viewport:ta,onViewportChange:ti}),(0,ey.jsx)(iF,{onSelectionChange:O}),eT,(0,ey.jsx)(iT,{proOptions:eQ,position:eJ}),(0,ey.jsx)(iI,{rfId:tg,disableKeyboardA11y:e5})]})})});let lv=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function lx({children:e}){let t=ik(lv);return t?(0,iy.createPortal)(e,t):null}function ly({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,ey.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:tf(["react-flow__background-pattern",n,r])})}function lb({radius:e,className:t}){return(0,ey.jsx)("circle",{cx:e,cy:e,r:e,className:tf(["react-flow__background-pattern","dots",t])})}(y=L||(L={})).Lines="lines",y.Dots="dots",y.Cross="cross";let lw={[L.Dots]:1,[L.Lines]:1,[L.Cross]:6},lj=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function lk({id:e,variant:t=L.Dots,gap:n=20,size:r,lineWidth:a=1,offset:i=0,color:o,bgColor:l,style:s,className:c,patternClassName:d}){let u=(0,ew.useRef)(null),{transform:f,patternId:h}=ik(lj,ix),p=r||lw[t],m=t===L.Dots,g=t===L.Cross,v=Array.isArray(n)?n:[n,n],x=[v[0]*f[2]||1,v[1]*f[2]||1],y=p*f[2],b=Array.isArray(i)?i:[i,i],w=g?[y,y]:x,j=[b[0]*f[2]||1+w[0]/2,b[1]*f[2]||1+w[1]/2],k=`${h}${e||""}`;return(0,ey.jsxs)("svg",{className:tf(["react-flow__background",c]),style:{...s,...or,"--xy-background-color-props":l,"--xy-background-pattern-color-props":o},ref:u,"data-testid":"rf__background",children:[(0,ey.jsx)("pattern",{id:k,x:f[0]%x[0],y:f[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:m?(0,ey.jsx)(lb,{radius:y/2,className:d}):(0,ey.jsx)(ly,{dimensions:w,lineWidth:a,variant:t,className:d})}),(0,ey.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}lk.displayName="Background";let lS=(0,ew.memo)(lk);function lN(){return(0,ey.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,ey.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function lC(){return(0,ey.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,ey.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function lM(){return(0,ey.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,ey.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function lE(){return(0,ey.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,ey.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function lO(){return(0,ey.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,ey.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function lP({children:e,className:t,...n}){return(0,ey.jsx)("button",{type:"button",className:tf(["react-flow__controls-button",t]),...n,children:e})}let lA=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function lI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:a,onZoomIn:i,onZoomOut:o,onFitView:l,onInteractiveChange:s,className:c,children:d,position:u="bottom-left",orientation:f="vertical","aria-label":h}){let p=iS(),{isInteractive:m,minZoomReached:g,maxZoomReached:v,ariaLabelConfig:x}=ik(lA,ix),{zoomIn:y,zoomOut:b,fitView:w}=oe();return(0,ey.jsxs)(iz,{className:tf(["react-flow__controls","horizontal"===f?"horizontal":"vertical",c]),position:u,style:e,"data-testid":"rf__controls","aria-label":h??x["controls.ariaLabel"],children:[t&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(lP,{onClick:()=>{y(),i?.()},className:"react-flow__controls-zoomin",title:x["controls.zoomIn.ariaLabel"],"aria-label":x["controls.zoomIn.ariaLabel"],disabled:v,children:(0,ey.jsx)(lN,{})}),(0,ey.jsx)(lP,{onClick:()=>{b(),o?.()},className:"react-flow__controls-zoomout",title:x["controls.zoomOut.ariaLabel"],"aria-label":x["controls.zoomOut.ariaLabel"],disabled:g,children:(0,ey.jsx)(lC,{})})]}),n&&(0,ey.jsx)(lP,{className:"react-flow__controls-fitview",onClick:()=>{w(a),l?.()},title:x["controls.fitView.ariaLabel"],"aria-label":x["controls.fitView.ariaLabel"],children:(0,ey.jsx)(lM,{})}),r&&(0,ey.jsx)(lP,{className:"react-flow__controls-interactive",onClick:()=>{p.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),s?.(!m)},title:x["controls.interactive.ariaLabel"],"aria-label":x["controls.interactive.ariaLabel"],children:m?(0,ey.jsx)(lO,{}):(0,ey.jsx)(lE,{})}),d]})}lI.displayName="Controls",(0,ew.memo)(lI);let lz=(0,ew.memo)(function({id:e,x:t,y:n,width:r,height:a,style:i,color:o,strokeColor:l,strokeWidth:s,className:c,borderRadius:d,shapeRendering:u,selected:f,onClick:h}){let{background:p,backgroundColor:m}=i||{};return(0,ey.jsx)("rect",{className:tf(["react-flow__minimap-node",{selected:f},c]),x:t,y:n,rx:d,ry:d,width:r,height:a,style:{fill:o||p||m,stroke:l,strokeWidth:s},shapeRendering:u,onClick:h?t=>h(t,e):void 0})}),lT=e=>e.nodes.map(e=>e.id),lD=e=>e instanceof Function?e:()=>e,l_=(0,ew.memo)(function({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:a,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:l,onClick:s}){let{node:c,x:d,y:u,width:f,height:h}=ik(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:a,y:i}=n.internals.positionAbsolute,{width:o,height:l}=ap(r);return{node:r,x:a,y:i,width:o,height:l}},ix);return c&&!c.hidden&&am(c)?(0,ey.jsx)(l,{x:d,y:u,width:f,height:h,style:c.style,selected:!!c.selected,className:r(c),color:t(c),borderRadius:a,strokeColor:n(c),strokeWidth:i,shapeRendering:o,onClick:s,id:c.id}):null});var lR=(0,ew.memo)(function({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:a,nodeComponent:i=lz,onClick:o}){let l=ik(lT,ix),s=lD(t),c=lD(e),d=lD(n),u="u"<typeof window||window.chrome?"crispEdges":"geometricPrecision";return(0,ey.jsx)(ey.Fragment,{children:l.map(e=>(0,ey.jsx)(l_,{id:e,nodeColorFunc:s,nodeStrokeColorFunc:c,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:a,NodeComponent:i,onClick:o,shapeRendering:u},e))})});let lL=e=>!e.hidden,l$=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?an(rZ(e.nodeLookup,{filter:lL}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}};function lF({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:a="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:l,bgColor:s,maskColor:c,maskStrokeColor:d,maskStrokeWidth:u,position:f="bottom-right",onClick:h,onNodeClick:p,pannable:m=!1,zoomable:g=!1,ariaLabel:v,inversePan:x,zoomStep:y=1,offsetScale:b=5}){let w=iS(),j=(0,ew.useRef)(null),{boundingRect:k,viewBB:S,rfId:N,panZoom:C,translateExtent:M,flowWidth:E,flowHeight:O,ariaLabelConfig:P}=ik(l$,ix),A=e?.width??200,I=e?.height??150,z=Math.max(k.width/A,k.height/I),T=z*A,D=z*I,_=b*z,R=k.x-(T-k.width)/2-_,L=k.y-(D-k.height)/2-_,$=T+2*_,F=D+2*_,B=`react-flow__minimap-desc-${N}`,V=(0,ew.useRef)(0),H=(0,ew.useRef)();V.current=z,(0,ew.useEffect)(()=>{if(j.current&&C)return H.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let a=t4(e);return{update:function({translateExtent:e,width:i,height:o,zoomStep:l=1,pannable:s=!0,zoomable:c=!0,inversePan:d=!1}){let u=[0,0],f=rF().on("start",e=>{("mousedown"===e.sourceEvent.type||"touchstart"===e.sourceEvent.type)&&(u=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on("zoom",s?a=>{let l=n();if("mousemove"!==a.sourceEvent.type&&"touchmove"!==a.sourceEvent.type||!t)return;let s=[a.sourceEvent.clientX??a.sourceEvent.touches[0].clientX,a.sourceEvent.clientY??a.sourceEvent.touches[0].clientY],c=[s[0]-u[0],s[1]-u[1]];u=s;let f=r()*Math.max(l[2],Math.log(l[2]))*(d?-1:1),h={x:l[0]-c[0]*f,y:l[1]-c[1]*f};t.setViewportConstrained({x:h.x,y:h.y,zoom:l[2]},[[0,0],[i,o]],e)}:null).on("zoom.wheel",c?e=>{if("wheel"!==e.sourceEvent.type||!t)return;let r=n(),a=e.sourceEvent.ctrlKey&&af()?10:1,i=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*l,o=r[2]*Math.pow(2,i*a);t.scaleTo(o)}:null);a.call(f,{})},destroy:function(){a.on("zoom",null)},pointer:t3}}({domNode:j.current,panZoom:C,getTransform:()=>w.getState().transform,getViewScale:()=>V.current}),()=>{H.current?.destroy()}},[C]),(0,ew.useEffect)(()=>{H.current?.update({translateExtent:M,width:E,height:O,inversePan:x,pannable:m,zoomStep:y,zoomable:g})},[m,g,x,y,M,E,O]);let U=h?e=>{let[t,n]=H.current?.pointer(e)||[0,0];h(e,{x:t,y:n})}:void 0,W=p?(0,ew.useCallback)((e,t)=>{p(e,w.getState().nodeLookup.get(t).internals.userNode)},[]):void 0,q=v??P["minimap.ariaLabel"];return(0,ey.jsx)(iz,{position:f,style:{...e,"--xy-minimap-background-color-props":"string"==typeof s?s:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof c?c:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof u?u*z:void 0,"--xy-minimap-node-background-color-props":"string"==typeof r?r:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof n?n:void 0,"--xy-minimap-node-stroke-width-props":"number"==typeof o?o:void 0},className:tf(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,ey.jsxs)("svg",{width:A,height:I,viewBox:`${R} ${L} ${$} ${F}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":B,ref:j,onClick:U,children:[q&&(0,ey.jsx)("title",{id:B,children:q}),(0,ey.jsx)(lR,{onClick:W,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:a,nodeStrokeWidth:o,nodeComponent:l}),(0,ey.jsx)("path",{className:"react-flow__minimap-mask",d:`M${R-_},${L-_}h${$+2*_}v${F+2*_}h${-$-2*_}z
2
- M${S.x},${S.y}h${S.width}v${S.height}h${-S.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}lF.displayName="MiniMap",(0,ew.memo)(lF);let lB={[R.Line]:"right",[R.Handle]:"bottom-right"},lV=(0,ew.memo)(function({nodeId:e,position:t,variant:n=R.Handle,className:r,style:a,children:i,color:o,minWidth:l=10,minHeight:s=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:p,onResizeStart:m,onResize:g,onResizeEnd:v}){let x,y=og(),b="string"==typeof e?e:y,w=iS(),j=(0,ew.useRef)(null),k=n===R.Handle,S=ik((0,ew.useCallback)((x=k&&h,e=>x?`${Math.max(1/e.transform[2],1)}`:void 0),[k,h]),ix),N=(0,ew.useRef)(null),C=t??lB[n];(0,ew.useEffect)(()=>{if(j.current&&b)return N.current||(N.current=function({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:a}){let i=t4(e),o={controlDirection:ir("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:l,keepAspectRatio:s,resizeDirection:c,onResizeStart:d,onResize:u,onResizeEnd:f,shouldResize:h}){let p,m,g,v,x={...il},y={...is};o={boundaries:l,resizeDirection:c,keepAspectRatio:s,controlDirection:ir(e)};let b=null,w=[],j=!1,k=ns().on("start",e=>{let{nodeLookup:r,transform:a,snapGrid:i,snapToGrid:o,nodeOrigin:l,paneDomNode:s}=n();if(!(p=r.get(t)))return;b=s?.getBoundingClientRect()??null;let{xSnapped:c,ySnapped:u}=ax(e.sourceEvent,{transform:a,snapGrid:i,snapToGrid:o,containerBounds:b});if(y={...x={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},pointerX:c,pointerY:u,aspectRatio:x.width/x.height},m=void 0,p.parentId&&("parent"===p.extent||p.expandParent)){var f;g=(m=r.get(p.parentId))&&"parent"===p.extent?[[0,0],[(f=m).measured.width,f.measured.height]]:void 0}for(let[e,n]of(w=[],v=void 0,r))if(n.parentId===t&&(w.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let r=t.position.x+e.position.x,a=t.position.y+e.position.y,i=e.measured.width??0,o=e.measured.height??0,l=n[0]*i,s=n[1]*o;return[[r-l,a-s],[r+i-l,a+o-s]]}(n,p,n.origin??l);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}d?.(e,{...x})}).on("drag",e=>{let{transform:t,snapGrid:a,snapToGrid:i,nodeOrigin:l}=n(),s=ax(e.sourceEvent,{transform:t,snapGrid:a,snapToGrid:i,containerBounds:b}),c=[];if(!p)return;let{x:d,y:f,width:k,height:S}=x,N={},C=p.origin??l,{width:M,height:E,x:O,y:P}=function(e,t,n,r,a,i,o,l){var s,c,d,u;let{affectsX:f,affectsY:h}=t,{isHorizontal:p,isVertical:m}=t,g=p&&m,{xSnapped:v,ySnapped:x}=n,{minWidth:y,maxWidth:b,minHeight:w,maxHeight:j}=r,{x:k,y:S,width:N,height:C,aspectRatio:M}=e,E=Math.floor(p?v-e.pointerX:0),O=Math.floor(m?x-e.pointerY:0),P=N+(f?-E:E),A=C+(h?-O:O),I=-i[0]*N,z=-i[1]*C,T=io(P,y,b),D=io(A,w,j);if(o){let e=0,t=0;f&&E<0?e=ia(k+E+I,o[0][0]):!f&&E>0&&(e=ii(k+P+I,o[1][0])),h&&O<0?t=ia(S+O+z,o[0][1]):!h&&O>0&&(t=ii(S+A+z,o[1][1])),T=Math.max(T,e),D=Math.max(D,t)}if(l){let e=0,t=0;f&&E>0?e=ii(k+E,l[0][0]):!f&&E<0&&(e=ia(k+P,l[1][0])),h&&O>0?t=ii(S+O,l[0][1]):!h&&O<0&&(t=ia(S+A,l[1][1])),T=Math.max(T,e),D=Math.max(D,t)}if(a){if(p){(T=Math.max(T,io(P/M,w,j)*M),o)&&(T=Math.max(T,(f||h)&&(!f||h||!g)?ia(S+z+(f?E:-E)/M,o[0][1])*M:ii(S+z+P/M,o[1][1])*M));l&&(T=Math.max(T,(f||h)&&(!f||h||!g)?ii(S+(f?E:-E)/M,l[0][1])*M:ia(S+P/M,l[1][1])*M))}if(m){(D=Math.max(D,io(A*M,y,b)/M),o)&&(D=Math.max(D,(f||h)&&(!h||f||!g)?ia(k+(h?O:-O)*M+I,o[0][0])/M:ii(k+A*M+I,o[1][0])/M));l&&(D=Math.max(D,(f||h)&&(!h||f||!g)?ii(k+(h?O:-O)*M,l[0][0])/M:ia(k+A*M,l[1][0])/M))}}O+=O<0?D:-D,E+=E<0?T:-T,a&&(g?P>A*M?O=((s=f,c=h,s?!c:c)?-E:E)/M:E=((d=f,u=h,d?!u:u)?-O:O)*M:p?(O=E/M,h=f):(E=O*M,f=h));let _=f?k+E:k,R=h?S+O:S;return{width:N+(f?-E:E),height:C+(h?-O:O),x:i[0]*E*(f?-1:1)+_,y:i[1]*O*(h?-1:1)+R}}(y,o.controlDirection,s,o.boundaries,o.keepAspectRatio,C,g,v),A=M!==k,I=E!==S,z=O!==d&&A,T=P!==f&&I;if(!z&&!T&&!A&&!I)return;if((z||T||1===C[0]||1===C[1])&&(N.x=z?O:x.x,N.y=T?P:x.y,x.x=N.x,x.y=N.y,w.length>0)){let e=O-d,t=P-f;for(let n of w)n.position={x:n.position.x-e+C[0]*(M-k),y:n.position.y-t+C[1]*(E-S)},c.push(n)}if((A||I)&&(N.width=A&&(!o.resizeDirection||"horizontal"===o.resizeDirection)?M:x.width,N.height=I&&(!o.resizeDirection||"vertical"===o.resizeDirection)?E:x.height,x.width=N.width,x.height=N.height),m&&p.expandParent){let e=C[0]*(N.width??0);N.x&&N.x<e&&(x.x=e,y.x=y.x-(N.x-e));let t=C[1]*(N.height??0);N.y&&N.y<t&&(x.y=t,y.y=y.y-(N.y-t))}let D=function({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:a,affectsY:i}){let o=e-t,l=n-r,s=[o>0?1:o<0?-1:0,l>0?1:l<0?-1:0];return o&&a&&(s[0]=-1*s[0]),l&&i&&(s[1]=-1*s[1]),s}({width:x.width,prevWidth:k,height:x.height,prevHeight:S,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),_={...x,direction:D};!1!==h?.(e,_)&&(j=!0,u?.(e,_),r(N,c))}).on("end",e=>{j&&(f?.(e,{...x}),a?.({...x}),j=!1)});i.call(k)},destroy:function(){i.on(".drag",null)}}}({domNode:j.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:a,domNode:i}=w.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:a,paneDomNode:i}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:a,nodeOrigin:i}=w.getState(),o=[],l={x:e.x,y:e.y},s=r.get(b);if(s&&s.expandParent&&s.parentId){let t=s.origin??i,n=e.width??s.measured.width??0,c=e.height??s.measured.height??0,d=aG([{id:s.id,parentId:s.parentId,rect:{width:n,height:c,...ag({x:e.x??s.position.x,y:e.y??s.position.y},{width:n,height:c},s.parentId,r,t)}}],r,a,i);o.push(...d),l.x=e.x?Math.max(t[0]*n,e.x):void 0,l.y=e.y?Math.max(t[1]*c,e.y):void 0}if(void 0!==l.x&&void 0!==l.y){let e={id:b,type:"position",position:{...l}};o.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:b,type:"dimensions",resizing:!0,setAttributes:!f||("horizontal"===f?"width":"height"),dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:"position"};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{w.getState().triggerNodeChanges([{id:b,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),N.current.update({controlPosition:C,boundaries:{minWidth:l,minHeight:s,maxWidth:c,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:m,onResize:g,onResizeEnd:v,shouldResize:p}),()=>{N.current?.destroy()}},[C,l,s,c,d,u,m,g,v,p]);let M=C.split("-");return(0,ey.jsx)("div",{className:tf(["react-flow__resize-control","nodrag",...M,n,r]),ref:j,style:{...a,scale:S,...o&&{[k?"backgroundColor":"borderColor"]:o}},children:i})}),lH=(0,ek.default)("cable",[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]]),lU=(0,ek.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),lW=(0,ek.default)("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),lq=(0,ek.default)("hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),lK=(0,ek.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),lG=(0,ek.default)("magnet",[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]]),lX=(0,ek.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),lY=(0,ek.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),lZ=(0,ek.default)("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]),lJ=(0,ek.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),lQ=(0,ek.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),l0=(0,ek.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var l1=e.i(93739),l2=e.i(94237);let l5=(0,l2.cva)("vtl-surface-popover z-50 flex w-fit items-center gap-1 rounded-[var(--surface-popover-radius)] border p-1",{variants:{placement:{"bottom-center":"fixed bottom-5 left-1/2 -translate-x-1/2","top-center":"fixed top-5 left-1/2 -translate-x-1/2","bottom-left":"fixed bottom-5 left-5","bottom-right":"fixed right-5 bottom-5",inline:"relative"},size:{default:"min-h-11",sm:"min-h-10 rounded-lg"}},defaultVariants:{placement:"bottom-center",size:"default"}});function l4({className:e,placement:t,size:n,...r}){return(0,ey.jsx)("div",{role:"toolbar","data-slot":"floating-action-bar","data-placement":t,"data-size":n,className:(0,eI.cn)(l5({placement:t,size:n}),e),...r})}function l3({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"floating-action-bar-group",className:(0,eI.cn)("flex items-center gap-1",e),...t})}function l6({className:e,variant:t="ghost",size:n="icon-sm",...r}){return(0,ey.jsx)(eA.Button,{"data-slot":"floating-action-bar-button",variant:t,size:n,className:(0,eI.cn)("rounded-lg",e),...r})}let l8={actions:"Canvas actions",add:"Add node",select:"Mouse",connect:"Connect",cut:"Cut",drag:"Drag",modeTools:"Mode",resetZoom:"Reset zoom",viewportTools:"Viewport tools",lockViewport:"Lock viewport",visualSnap:"Visual snap",nodeSnap:"Node snap",snapTools:"Snap tools",nodeActions:"Node actions",resizeNode:"Resize node",copyNode:"Copy node",cutNode:"Cut node"},l7={width:192,height:112};function l9(e,t){return Math.round(e/t)*t}function se(e,t,n){return Math.min(n,Math.max(t,e))}function st(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=Number.parseFloat(e);if(Number.isFinite(t))return t}return t}function sn(e){let t=e.measured;return{width:st(e.width??t?.width??e.style?.width,l7.width),height:st(e.height??t?.height??e.style?.height,l7.height)}}function sr({center:e,size:t=l7,snapGrid:n}){return{x:l9(e.x-t.width/2,n[0]),y:l9(e.y-t.height/2,n[1])}}let sa=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],si=[{id:"top",position:_.Top,className:"left-1/2 top-0 -translate-x-1/2 -translate-y-1/2"},{id:"right",position:_.Right,className:"right-0 top-1/2 -translate-y-1/2 translate-x-1/2"},{id:"bottom",position:_.Bottom,className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2"},{id:"left",position:_.Left,className:"left-0 top-1/2 -translate-x-1/2 -translate-y-1/2"}];function so(e,t){let n=e.width??e.measured?.width??l7.width,r=e.height??e.measured?.height??l7.height,a=t.width??t.measured?.width??l7.width,i=t.height??t.measured?.height??l7.height,o={x:e.position.x+n/2,y:e.position.y+r/2},l={x:t.position.x+a/2,y:t.position.y+i/2},s=l.x-o.x,c=l.y-o.y;return Math.abs(s)>=Math.abs(c)?s>=0?{sourceHandle:"source-right",targetHandle:"target-left"}:{sourceHandle:"source-left",targetHandle:"target-right"}:c>=0?{sourceHandle:"source-bottom",targetHandle:"target-top"}:{sourceHandle:"source-top",targetHandle:"target-bottom"}}function sl(e){return e===_.Top?{x:0,y:-1}:e===_.Bottom?{x:0,y:1}:e===_.Left?{x:-1,y:0}:{x:1,y:0}}function ss(e,t){return Math.max(48,Math.min(180,.46*Math.hypot(t.x-e.x,t.y-e.y)))}function sc({point:e,position:t}){return t===_.Top||t===_.Bottom?`M ${e.x-14} ${e.y} L ${e.x+14} ${e.y}`:`M ${e.x} ${e.y-14} L ${e.x} ${e.y+14}`}function sd(e){let t=sn(e);return{x:e.position.x,y:e.position.y,width:t.width,height:t.height,right:e.position.x+t.width,bottom:e.position.y+t.height}}function su(e,t,n,r){let a=Math.max(e,n),i=Math.min(t,r);return a<=i?{distance:0,midpoint:(a+i)/2}:t<n?{distance:n-t,midpoint:(t+n)/2}:{distance:e-r,midpoint:(r+e)/2}}function sf(e,t,n){let r=ew.useRef(null),a=ew.useRef(e),i=ew.useRef(t),[o,l]=ew.useState(e),s=ew.useMemo(()=>n?{height:n.height,measured:n.measured,position:n.position,width:n.width}:void 0,[n]);return ew.useEffect(()=>{let n=a.current,o=i.current,c=o&&o!==t?220:110,d=performance.now();a.current=e,i.current=t,r.current&&window.cancelAnimationFrame(r.current);let u=a=>{let i=Math.min(1,(a-d)/c);l(function({from:e,to:t,fromPosition:n,toPosition:r,progress:a,node:i}){var o;let l,s;if(!i||!n||!r||n===r)return{x:e.x+(t.x-e.x)*a,y:e.y+(t.y-e.y)*a};let c=i.width??i.measured?.width??l7.width,d=i.height??i.measured?.height??l7.height,u={x:i.position.x,y:i.position.y,width:c,height:d},f=sh(e,u),h=sh(t,u),p=2*c+2*d,m=h-f;return Math.abs(m)>p/2&&(m+=m>0?-p:p),(s=((f+m*a)%(l=2*(o=u).width+2*o.height)+l)%l)<=o.width?{x:o.x+s,y:o.y}:s<=o.width+o.height?{x:o.x+o.width,y:o.y+s-o.width}:s<=2*o.width+o.height?{x:o.x+o.width-(s-o.width-o.height),y:o.y+o.height}:{x:o.x,y:o.y+o.height-(s-2*o.width-o.height)}}({from:n,to:e,fromPosition:o,toPosition:t,progress:1-Math.pow(1-i,3),node:s})),i<1&&(r.current=window.requestAnimationFrame(u))};return r.current=window.requestAnimationFrame(u),()=>{r.current&&window.cancelAnimationFrame(r.current)}},[s,e,e.x,e.y,t]),o}function sh(e,t){let n=t.x+t.width,r=t.y+t.height;return 1>=Math.abs(e.y-t.y)?e.x-t.x:1>=Math.abs(e.x-n)?t.width+e.y-t.y:1>=Math.abs(e.y-r)?t.width+t.height+n-e.x:2*t.width+t.height+r-e.y}function sp({route:e,viewportZoom:t}){let n=e.sourcePosition===_.Left||e.sourcePosition===_.Right;return(0,ey.jsx)(lx,{children:(0,ey.jsx)("div",{"data-slot":"node-canvas-joined-terminal",className:"node-canvas-joined-terminal nodrag nopan",style:{position:"absolute",transform:`translate(${e.terminalPoint.x}px, ${e.terminalPoint.y}px) scale(${1/t}) translate(-50%, -50%)`,transformOrigin:"0 0"},children:(0,ey.jsx)("span",{className:"node-canvas-joined-terminal-line","data-orientation":n?"vertical":"horizontal"})})})}function sm({className:e,viewportClassName:t,background:n,fitView:r=!1,snapGrid:a=[16,16],snapToGrid:i=!0,minZoom:o=.15,maxZoom:l=2.5,proOptions:s={hideAttribution:!0},nodes:c=[],edges:d=[],actionBar:u=!0,actionBarOpen:f,defaultActionBarOpen:h=!1,mode:p,defaultMode:m="select",visualSnap:g,defaultVisualSnap:v=!1,onVisualSnapChange:x,nodeSnap:y,defaultNodeSnap:b=!1,onNodeSnapChange:w,viewportLocked:j,defaultViewportLocked:k=!1,onViewportLockedChange:S,selectedNodeId:N,defaultSelectedNodeId:C,resizingNodeId:M,defaultResizingNodeId:E,labels:O,onActionBarOpenChange:P,onModeChange:A,onSelectedNodeChange:I,onResizingNodeChange:z,onCanvasAction:T,onNodeCanvasNodeAction:D,onNodeCanvasConnect:_,onNodeCanvasEdgeAction:R,nodesDraggable:L,panOnDrag:$,panOnScroll:F,zoomOnScroll:B,zoomOnPinch:V,onNodesChange:H,onNodeClick:U,onPaneClick:W,onEdgesChange:q,defaultViewport:K,children:G,...X}){let Y=ew.useRef(null),Z=ew.useRef(null),J=ew.useRef({}),Q=ew.useRef(0),{getViewport:ee,getZoom:et,screenToFlowPosition:en,setViewport:er}=oe(),ea=function(){let[e,t]=ew.useState("light");return ew.useEffect(()=>{let e=document.documentElement,n=()=>{t(e.classList.contains("dark")?"dark":"light")},r=new MutationObserver(n);return n(),r.observe(e,{attributeFilter:["class"],attributes:!0}),()=>r.disconnect()},[]),e}(),[ei,eo]=ew.useState(1),[el,es]=ew.useState(K??{x:0,y:0,zoom:1}),[ec,ed]=ew.useState({width:0,height:0}),[eu,ef]=ew.useState(h),[eh,ep]=ew.useState(m),[em,eg]=ew.useState(v),[ev,ex]=ew.useState(b),[eb,ej]=ew.useState(k),[ek,eS]=ew.useState(C),[eN,eC]=ew.useState(E),[eM,eE]=ew.useState(!1),eO={...l8,...O},eP=p??eh,eA=g??em,ez=y??ev,eT=j??eb,eD=N??ek,e_=M??eN,eR="drag"===eP,eL=!eT&&("select"===eP||"drag"===eP||"connect"===eP),e$=ew.useCallback(e=>{void 0===N&&eS(e),I?.(e)},[I,N]),eF=ew.useCallback(e=>{void 0===M&&eC(e),z?.(e)},[z,M]),eB=ew.useCallback((e,t)=>{Z.current=e,t.preventDefault(),t.stopPropagation()},[]),eV=ew.useCallback(e=>{e$(e),eF(void 0)},[eF,e$]),eH=ew.useMemo(()=>c.map(e=>({...e,data:{...e.data??{},mode:eP,resizing:e.id===e_,onConnectPointerDown:eB,onSelectNode:eV},selected:eD?e.id===eD:e.selected})),[eP,e_,eD,eB,eV,c]),eU=ew.useMemo(()=>d.map(e=>{let t=e.data,n=c.find(t=>t.id===e.source),r=c.find(t=>t.id===e.target),a="connection"===e.type&&t?.autoHandles!==!1&&n&&r?so(n,r):{sourceHandle:e.sourceHandle,targetHandle:e.targetHandle};return{...e,...a,data:{...e.data??{},cutActive:eM,mode:eP,viewportZoom:ei,onAddAnchor:(e,t,n)=>R?.("add-anchor",e,{anchor:t,anchorIndex:n}),onMoveAnchor:(e,t,n)=>R?.("move-anchor",e,{anchor:n,anchorIndex:t}),onDeleteAnchor:(e,t)=>R?.("delete-anchor",e,{anchorIndex:t}),onCutEdge:e=>R?.("cut-edge",e,{})}}}),[eP,eM,d,c,R,ei]);ew.useEffect(()=>{if("connect"!==eP){Z.current=null;return}let e=e=>{let t=Z.current;if(!t)return;Z.current=null;let n=document.elementsFromPoint(e.clientX,e.clientY).find(e=>e.classList.contains("react-flow__node")),r=n?.getAttribute("data-id");if(!r||r===t)return;let a=c.find(e=>e.id===t),i=c.find(e=>e.id===r);a&&i&&_?.({source:t,target:r,...so(a,i)})};return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[eP,c,_]),ew.useEffect(()=>{if("cut"!==eP)return void eE(!1);let e=()=>eE(!1);return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[eP]),ew.useEffect(()=>{eo(et()),es(ee())},[ee,et]),ew.useEffect(()=>{let e=Y.current;if(!e)return;let t=()=>{ed({width:e.clientWidth,height:e.clientHeight})},n=new ResizeObserver(t);return t(),n.observe(e),()=>n.disconnect()},[]),ew.useEffect(()=>{eA||(J.current={})},[eA]);let eW=ew.useCallback((e,t={})=>{let n=Y.current?.getBoundingClientRect();if(!n||0===c.length)return;let r=t.threshold??42,a=Math.max(r+1,64),i=[],o=[];function l(e,n){let i=J.current[e];if(i){let o=n.find(e=>e.nodeId===i.nodeId&&e.edge===i.edge);if(o){if(i.released){if(o.distance<=r)return;J.current[e]=void 0;return}if(o.distance<=1)return t.preserveEscapeDistance||(J.current[e]={nodeId:i.nodeId,edge:i.edge}),o;let n=(i.escapeDistance??0)+o.distance;return o.distance<=a&&n<a?(J.current[e]={...i,escapeDistance:n},o):void(J.current[e]={nodeId:i.nodeId,edge:i.edge,released:!0})}J.current[e]=void 0}let o=n.filter(e=>e.distance<=r).sort((e,t)=>e.distance-t.distance)[0];return o&&(J.current[e]={nodeId:o.nodeId,edge:o.edge}),o}for(let t of c){let r=sn(t),a=t.position.x*e.zoom+e.x,l=(t.position.x+r.width)*e.zoom+e.x,s=t.position.y*e.zoom+e.y,c=(t.position.y+r.height)*e.zoom+e.y;i.push({nodeId:t.id,edge:"left",delta:-a,distance:Math.abs(a)}),i.push({nodeId:t.id,edge:"right",delta:n.width-l,distance:Math.abs(n.width-l)}),o.push({nodeId:t.id,edge:"top",delta:-s,distance:Math.abs(s)}),o.push({nodeId:t.id,edge:"bottom",delta:n.height-c,distance:Math.abs(n.height-c)})}let s=l("x",i),d=l("y",o),u=s?.delta??0,f=d?.delta??0;.5>Math.abs(u)&&.5>Math.abs(f)||er({x:e.x+u,y:e.y+f,zoom:e.zoom},{duration:t.duration??0})},[c,er]);return!function({onStart:e,onChange:t,onEnd:n}){let r=iS();(0,ew.useEffect)(()=>{r.setState({onViewportChangeStart:e})},[e]),(0,ew.useEffect)(()=>{r.setState({onViewportChange:t})},[t]),(0,ew.useEffect)(()=>{r.setState({onViewportChangeEnd:n})},[n])}({onChange:e=>{eo(e.zoom),es(e),eA&&Date.now()>=Q.current&&eW(e,{preserveEscapeDistance:!0,threshold:42})},onEnd:e=>{eo(e.zoom),es(e),eA&&Date.now()>=Q.current&&eW(e,{duration:140})}}),(0,ey.jsxs)("div",{ref:Y,"data-slot":"node-canvas","data-mode":eP,style:{"--node-canvas-zoom":String(ei)},className:(0,eI.cn)("node-canvas vtl-surface-panel relative h-[620px] min-h-[360px] w-full overflow-hidden rounded-[var(--surface-panel-radius)] border",e),onPointerDown:e=>{"cut"===eP&&0===e.button&&eE(!0)},children:[(0,ey.jsxs)(lg,{colorMode:X.colorMode??ea,fitView:r,minZoom:o,maxZoom:l,nodes:eH,edges:eU,nodesDraggable:L??eR,panOnDrag:$??eL,panOnScroll:!eT&&(F??!1),proOptions:s,snapGrid:a,snapToGrid:i,zoomOnScroll:!eT&&(B??!0),zoomOnPinch:!eT&&V,zoomOnDoubleClick:!1,defaultViewport:K,className:(0,eI.cn)("node-canvas__viewport",t),...X,onNodesChange:function(e){let t=eA?ee():void 0,n=eA?Y.current?.getBoundingClientRect():void 0,r=e.filter(e=>"select"!==e.type).map(e=>{if(e_||"position"!==e.type||!e.position||!ez&&!eA)return e;let r=e.position;return ez&&(r=function({nodeId:e,position:t,nodes:n,zoom:r,threshold:a=32}){let i=n.find(t=>t.id===e);if(!i)return t;let o=sn(i),l=a/Math.max(r,.1),s=t.x,c=t.y,d=l+1,u=l+1;for(let r of n){if(r.id===e)continue;let n=sn(r),a=r.position.x,i=r.position.x+n.width,f=r.position.y,h=r.position.y+n.height,p=t.x,m=t.x+o.width,g=t.y,v=t.y+o.height;for(let e of[a-p,i-m,i-p,a-m]){let n=Math.abs(e);n<d&&n<=l&&(d=n,s=t.x+e)}for(let e of[f-g,h-v,h-g,f-v]){let n=Math.abs(e);n<u&&n<=l&&(u=n,c=t.y+e)}}return{x:s,y:c}}({nodeId:e.id,position:r,nodes:c,zoom:ei})),eA&&t&&n&&(r=function({nodeId:e,position:t,nodes:n,viewport:r,viewportRect:a,threshold:i=42}){let o=n.find(t=>t.id===e);if(!o)return t;let l=sn(o),s=t.x*r.zoom+r.x,c=(t.x+l.width)*r.zoom+r.x,d=t.y*r.zoom+r.y,u=(t.y+l.height)*r.zoom+r.y,f=t.x,h=t.y,p=i+1,m=i+1;for(let e of[-s,a.width-c]){let n=Math.abs(e);n<p&&n<=i&&(p=n,f=t.x+e/r.zoom)}for(let e of[-d,a.height-u]){let n=Math.abs(e);n<m&&n<=i&&(m=n,h=t.y+e/r.zoom)}return{x:f,y:h}}({nodeId:e.id,position:r,nodes:c,viewport:t,viewportRect:n})),{...e,position:r}});H?.(r)},onEdgesChange:q,onNodeClick:(e,t)=>{U?.(e,t),"drag"===eP&&(e$(t.id),eF(void 0))},onPaneClick:e=>{if(W?.(e),e_){e$(e_),eF(void 0);return}e$(void 0)},children:[!1!==n?(0,ey.jsx)(lS,{color:"var(--node-canvas-dot)",gap:16,size:1.35,...n}):null,G]}),eD?(0,ey.jsx)(sv,{labels:eO,node:c.find(e=>e.id===eD),rootSize:ec,viewport:el,onAction:function(e){if(!eD)return;if("resize"===e){eF(eD),e$(void 0);return}let t=Y.current?.getBoundingClientRect(),n=en({x:(t?.left??0)+(t?.width??0)/2,y:(t?.top??0)+(t?.height??0)/2}),r=sr({center:n,snapGrid:a});D?.(e,eD,{flowPosition:n,snappedPosition:r})}}):null,u?(0,ey.jsx)(sx,{open:f??eu,mode:eP,visualSnap:eA,nodeSnap:ez,viewportLocked:eT,labels:eO,onOpenChange:function(e){void 0===f&&ef(e),P?.(e)},onModeChange:function(e){void 0===p&&ep(e),A?.(e)},onAction:function(e){let t=Y.current?.getBoundingClientRect(),n=en({x:(t?.left??0)+(t?.width??0)/2,y:(t?.top??0)+(t?.height??0)/2}),r=sr({center:n,snapGrid:a});T?.(e,{flowPosition:n,snappedPosition:r})},onResetZoom:function(){let e=K?.zoom??1,t=ee(),n=Y.current?.getBoundingClientRect();if(J.current={},Q.current=Date.now()+320,!n){er({...t,zoom:e},{duration:220}),eo(e);return}let r={x:n.width/2,y:n.height/2},a={x:(r.x-t.x)/t.zoom,y:(r.y-t.y)/t.zoom};er({x:r.x-a.x*e,y:r.y-a.y*e,zoom:e},{duration:220}),eo(e)},onViewportLockedChange:function(e){void 0===j&&ej(e),S?.(e)},onVisualSnapChange:function(e){void 0===g&&eg(e),x?.(e)},onNodeSnapChange:function(e){void 0===y&&ex(e),w?.(e)}}):null]})}function sg({labels:e,onAction:t}){return(0,ey.jsx)(l4,{"data-slot":"node-canvas-selected-toolbar",placement:"inline",size:"sm","aria-label":e.nodeActions,className:"vtl-surface-popover rounded-[var(--surface-popover-radius)] p-1",children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":e.resizeNode,onClick:()=>t("resize"),children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":e.copyNode,onClick:()=>t("copy"),children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":e.cutNode,onClick:()=>t("cut"),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function sv({labels:e,node:t,rootSize:n,viewport:r,onAction:a}){if(!t||n.width<=0||n.height<=0)return null;let i=sn(t),o=t.position.x*r.zoom+r.x,l=t.position.y*r.zoom+r.y,s=i.width*r.zoom,c=i.height*r.zoom,d=70,u=n.width-8-62,f=u>=d?se(o+s/2,d,u):n.width/2,h=n.height-8-42,p=l+c+10,m=l-42-10,g=p<=h,v=m>=8,x=h<8?Math.max(0,(n.height-42)/2):g?p:v?Math.min(m,h):se(m,8,h);return(0,ey.jsx)("div",{"data-slot":"node-canvas-selected-toolbar-overlay",className:"pointer-events-none absolute z-30 flex justify-center",style:{left:f-62,top:x,width:124},children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(sg,{labels:e,onAction:a})})})}function sx({open:e,mode:t,visualSnap:n,nodeSnap:r,viewportLocked:a,labels:i,onOpenChange:o,onModeChange:l,onAction:s,onResetZoom:c,onViewportLockedChange:d,onVisualSnapChange:u,onNodeSnapChange:f}){let[h,p]=ew.useState(),m="border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",g=[{key:"select",mode:"select",label:i.select,icon:(0,ey.jsx)(lZ,{className:"size-4"})},{key:"drag",mode:"drag",action:"drag",label:i.drag,icon:(0,ey.jsx)(lq,{className:"size-4"})},{key:"connect",mode:"connect",action:"connect",label:i.connect,icon:(0,ey.jsx)(lH,{className:"size-4"})},{key:"cut",mode:"cut",action:"cut",label:i.cut,icon:(0,ey.jsx)(l0,{className:"size-4"})}],v=g.find(e=>e.mode===t)??g[0],x=Number(n)+Number(r),y=[{key:"add",type:"action",label:i.add,icon:(0,ey.jsx)(lJ,{className:"size-4"})},{key:"mode",type:"group",label:`${i.modeTools}: ${v.label}`,icon:v.icon},{key:"viewport",type:"group",pressed:a,label:i.viewportTools,icon:a?(0,ey.jsx)(lK,{className:"size-4"}):(0,ey.jsx)(lQ,{className:"size-4"})},{key:"snap",type:"group",pressed:x>0,count:x,label:i.snapTools,icon:(0,ey.jsx)(lG,{className:"size-4"})}];return ew.useEffect(()=>{e||p(void 0)},[e]),(0,ey.jsx)("div",{"data-slot":"node-canvas-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[y.map((o,v)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute inset-0 transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(v+1)*42}px)`:void 0},children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":o.label,"aria-expanded":"group"===o.type?h===o.key:void 0,"aria-pressed":"group"===o.type&&!!o.pressed||void 0,onClick:()=>{"action"===o.type?s(o.key):p(e=>e===o.key?void 0:o.key)},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[border-color,background-color,color,box-shadow] duration-150","group"===o.type&&o.pressed&&m),children:[o.icon,"snap"===o.key&&o.count>0?(0,ey.jsx)("span",{className:"absolute -top-1 -right-1 grid size-4 place-items-center rounded-full border bg-background text-[10px] leading-none text-foreground shadow-sm",children:o.count}):null]}),"mode"===o.key?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","mode"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:g.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":e.label,"aria-pressed":t===e.mode,onClick:()=>{l(e.mode),e.action&&e.mode!==t&&s(e.action)},className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",t===e.mode&&m),children:e.icon},e.key))}):null,"viewport"===o.key?(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","viewport"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.resetZoom,onClick:c,className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lQ,{className:"size-4"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.lockViewport,"aria-pressed":a,onClick:()=>d(!a),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",a&&m),children:(0,ey.jsx)(lK,{className:"size-4"})})]}):null,"snap"===o.key?(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","snap"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.visualSnap,"aria-pressed":n,onClick:()=>u(!n),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",n&&m),children:(0,ey.jsx)(lW,{className:"size-4"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.nodeSnap,"aria-pressed":r,onClick:()=>f(!r),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",r&&m),children:(0,ey.jsx)(lG,{className:"size-4"})})]}):null]},o.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.actions,"aria-expanded":e,onClick:()=>{o(!e),e&&p(void 0)},className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function sy({provider:e=!0,...t}){return e?(0,ey.jsx)(lh,{children:(0,ey.jsx)(sm,{...t})}):(0,ey.jsx)(sm,{...t})}function sb(){let[e,t]=ew.useState(void 0);return ew.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),n=()=>{t(window.innerWidth<768)};return e.addEventListener("change",n),t(window.innerWidth<768),()=>e.removeEventListener("change",n)},[]),!!e}async function sw(){let e=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});return e.ok?e.json():{machines:[]}}async function sj(e,t,n){let{timeoutMs:r=8e3,signal:a,...i}=n??{},o=new AbortController,l=r>0?setTimeout(()=>o.abort(),r):void 0;a&&a.addEventListener("abort",()=>o.abort(),{once:!0});try{let n=await fetch(eD(`/v1/remote/${e}${t}`),{...i,cache:"no-store",signal:o.signal});if(!n.ok)throw Error(`Remote API error: ${n.status}`);return n.json()}finally{l&&clearTimeout(l)}}class sk extends Error{openedBy;constructor(e){super("conversation is open on another machine"),this.name="ConversationOpenElsewhereError",this.openedBy=e}}let sS={subagents:[],mainModels:[],folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:["local"],permissionMode:"acceptEdits"},sN="local";function sC(e){return!e||e===sN}function sM(e,t){return sC(e)?`/api/local/agent/conversations${t}`:`/v1/remote/${e}/agent/conversations${t}`}async function sE(e){return(await s1(e,"")).conversations.map(t=>s0(t,e))}async function sO(){let e={[sN]:"本机"},t=[],n=[];try{n=await sE(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await sE(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{conversations:o,machineNames:e,unreachable:t}}async function sP(e){let t=await s1(e,"/recent",void 0,{allowNotFound:!0});return t?sQ(t,e):void 0}async function sA(e,t){return sQ(await s1(t,`/${encodeURIComponent(e)}?eventsLimit=200`),t)}async function sI(e,t,n){try{let r=new URLSearchParams;void 0!==t.end&&r.set("end",String(t.end)),void 0!==t.limit&&r.set("limit",String(t.limit));let a=r.toString()?`?${r}`:"",i=await fetch(eD(sM(n,`/${encodeURIComponent(e)}/events${a}`)),{cache:"no-store"});if(!i.ok)return{events:[],start:0,total:0};let o=await i.json().catch(()=>({}));return{events:o.events??[],start:o.start??0,total:o.total??0}}catch{return{events:[],start:0,total:0}}}async function sz(e,t){try{let n=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/subagent-tree`)),{cache:"no-store"});if(!n.ok)return[];return(await n.json().catch(()=>({}))).subagents??[]}catch{return[]}}async function sT(e,t){try{let n=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/background-tasks`)),{cache:"no-store"});if(!n.ok)return[];return(await n.json().catch(()=>({}))).tasks??[]}catch{return[]}}async function sD(){if(void 0!==t)return t;try{let{machines:e}=await sw();t=(e??[]).find(e=>e.isLocal)?.name??""}catch{t=""}return t}async function s_(e,t,n){let r=()=>"u">typeof performance?performance.now():Date.now(),a=r(),i=n?.displayName??await sD(),o=r(),l=new URLSearchParams;n?.force&&l.set("force","1"),l.set("eventsLimit",String(200));let s=`?${l}`,c=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/open${s}`)),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:i})}),d=r(),u=await c.json().catch(()=>({})),f=r();if(409===c.status)throw new sk(u?.openedBy);if(!c.ok){let e=u?.error;throw Error("string"==typeof e?e:"open failed")}let h=sQ(u,t),p=r(),m=Array.isArray(u?.events)?u.events.length:0;return console.debug(`[open] id=${e} machineName=${Math.round(o-a)}ms fetch=${Math.round(d-o)}ms readBody=${Math.round(f-d)}ms map=${Math.round(p-f)}ms events=${m}`),h}async function sR(e,n,r){try{await fetch(eD(sM(n,`/${encodeURIComponent(e)}/open/heartbeat`)),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:r??t??""})})}catch{}}async function sL(e,t){try{await fetch(eD(sM(t,`/${encodeURIComponent(e)}/open/release`)),{method:"POST",cache:"no-store",keepalive:!0})}catch{}}async function s$(e){let t=e.ownerMachineId;return sQ(await s1(t,"",{method:"POST",body:JSON.stringify(e)}),t)}async function sF(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),n)}async function sB(e,t){await s1(t,`/${encodeURIComponent(e)}`,{method:"DELETE"})}async function sV(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/panes`,{method:"PUT",body:JSON.stringify(t)}),n)}async function sH(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/chat-runs`,{method:"POST",body:JSON.stringify(t)}),n)}async function sU(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/chat-runs/retry`,{method:"POST",body:JSON.stringify(t)}),n)}async function sW(e,t,n){let r=await s1(n,`/${encodeURIComponent(e)}/rollback`,{method:"POST",body:JSON.stringify({eventId:t})});return{detail:sQ(r.detail,n),prompt:r.prompt??"",revertedFiles:r.revertedFiles??0,deletedFiles:r.deletedFiles??0,skippedRemote:r.skippedRemote,archivedSubagents:r.archivedSubagents??0}}async function sq(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/fork`,{method:"POST",body:JSON.stringify({eventId:t??""})}),n)}async function sK(e,t,n){let r=new URLSearchParams(t);return s1(n,`/${encodeURIComponent(e)}/files/history?${r}`)}async function sG(e,t,n){let r=new URLSearchParams(t);return s1(n,`/${encodeURIComponent(e)}/files/version?${r}`)}async function sX(e,t,n,r,a){return s1(a,`/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({decision:n,feedback:r})})}async function sY(e,t){return s1(t,`/${encodeURIComponent(e)}/chat-runs/stop`,{method:"POST"},{allowNotFound:!0})}async function sZ(e,t,n){return s1(n,`/${encodeURIComponent(e)}/chat-runs/nudge`,{method:"POST",body:JSON.stringify({message:t})})}async function sJ(e,t,n,r){return await s1(r,`/${encodeURIComponent(e)}/compress`,{method:"POST",body:JSON.stringify({mode:t,agentSummary:n})})}function sQ(e,t){return{conversation:s0(e.conversation,t),events:e.events??[],panes:e.panes??{layoutMode:"quad",agentPosition:"left",panes:[]},eventsTotal:e.eventsTotal,eventsStart:e.eventsStart}}function s0(e,t){let n=e.runtimeSeconds??0,r={...sS,...e.settings},a=sC(t)?e.ownerMachineId??"local":t;return{id:e.id,title:e.title||"新 Agent 对话",agent:e.agent||"Local Agent",status:e.status??"idle",running:e.running??"working"===e.status,goal:e.goal||"",progress:e.progress??0,taskProgress:e.taskProgress?.length?e.taskProgress:[e.progress??0,0,0],runtime:function(e){if(e<=0)return"0m";let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${Math.max(1,n)}m`}(n),runtimeSeconds:n,tokens:e.tokens??0,contextTokens:e.contextTokens??0,lastOpened:function(e){let t=Date.parse(e);if(!Number.isFinite(t))return"刚刚";let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return"刚刚";let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let a=Math.floor(r/60);if(a<24)return`${a} 小时前`;let i=Math.floor(a/24);return 1===i?"昨天":i<7?`${i} 天前`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}(e.lastOpenedAt??e.updatedAt??e.createdAt),roadmap:e.roadmap?.length?e.roadmap:[{title:"配置会话环境",state:"done"},{title:"等待首条消息",state:"queued"}],settings:r,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt,lastSeq:e.lastSeq??0,ownerMachineId:a,runUsage:e.runUsage,rounds:e.rounds??[],openedBy:e.openedBy,forkOriginId:e.forkOriginId,forkPointSeq:e.forkPointSeq}}async function s1(e,t,n,r){let a=await fetch(eD(sM(e,t)),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"agent conversation api failed");return i}let s2=(0,ek.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),s5=(0,ek.default)("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]),s4=(0,ek.default)("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),s3=(0,ek.default)("panel-right-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]),s6=(0,ek.default)("rectangle-horizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]),s8=(0,ek.default)("shredder",[["path",{d:"M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1eob4r"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 22v-5",key:"sfixh4"}],["path",{d:"M14 19v-2",key:"pdve8j"}],["path",{d:"M18 20v-3",key:"uox2gk"}],["path",{d:"M2 13h20",key:"5evz65"}],["path",{d:"M6 20v-3",key:"c6pdcb"}]]);function s7(e,t=[]){let n=[],r=()=>{let t=n.map(e=>ew.createContext(e));return function(n){let r=n?.[e]||t;return ew.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let a=ew.createContext(r),i=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,l=n?.[e]?.[i]||a,s=ew.useMemo(()=>o,Object.values(o));return(0,ey.jsx)(l.Provider,{value:s,children:r})};return o.displayName=t+"Provider",[o,function(n,o){let l=o?.[e]?.[i]||a,s=ew.useContext(l);if(s)return s;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let a=n(e)[`__scope${r}`];return{...t,...a}},{});return ew.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}var s9=e.i(22353);function ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}"u">typeof window&&window.document&&window.document.createElement;var ct=globalThis?.document?ew.useLayoutEffect:()=>{},cn=ew[" useId ".trim().toString()]||(()=>void 0),cr=0;function ca(e){let[t,n]=ew.useState(cn());return ct(()=>{e||n(e=>e??String(cr++))},[e]),e||(t?`radix-${t}`:"")}ew[" useEffectEvent ".trim().toString()],ew[" useInsertionEffect ".trim().toString()];var ci=ew[" useInsertionEffect ".trim().toString()]||ct;function co({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,i,o]=function({defaultProp:e,onChange:t}){let[n,r]=ew.useState(e),a=ew.useRef(n),i=ew.useRef(t);return ci(()=>{i.current=t},[t]),ew.useEffect(()=>{a.current!==n&&(i.current?.(n),a.current=n)},[n,a]),[n,r,i]}({defaultProp:t,onChange:n}),l=void 0!==e,s=l?e:a;{let t=ew.useRef(void 0!==e);ew.useEffect(()=>{let e=t.current;if(e!==l){let t=l?"controlled":"uncontrolled";console.warn(`${r} is changing from ${e?"controlled":"uncontrolled"} to ${t}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=l},[l,r])}return[s,ew.useCallback(t=>{if(l){let n="function"==typeof t?t(e):t;n!==e&&o.current?.(n)}else i(t)},[l,e,i,o])]}function cl(e){var t;let n,r=(t=e,(n=ew.forwardRef((e,t)=>{let{children:n,...r}=e;if(ew.isValidElement(n)){var a;let e,i,o=(a=n,(i=(e=Object.getOwnPropertyDescriptor(a.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.ref:(i=(e=Object.getOwnPropertyDescriptor(a,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.props.ref:a.props.ref||a.ref),l=function(e,t){let n={...t};for(let r in t){let a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...e)=>{let t=i(...e);return a(...e),t}:a&&(n[r]=a):"style"===r?n[r]={...a,...i}:"className"===r&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==ew.Fragment&&(l.ref=t?(0,s9.composeRefs)(t,o):o),ew.cloneElement(n,l)}return ew.Children.count(n)>1?ew.Children.only(null):null})).displayName=`${t}.SlotClone`,n),a=ew.forwardRef((e,t)=>{let{children:n,...a}=e,i=ew.Children.toArray(n),o=i.find(cc);if(o){let e=o.props.children,n=i.map(t=>t!==o?t:ew.Children.count(e)>1?ew.Children.only(null):ew.isValidElement(e)?e.props.children:null);return(0,ey.jsx)(r,{...a,ref:t,children:ew.isValidElement(e)?ew.cloneElement(e,void 0,n):null})}return(0,ey.jsx)(r,{...a,ref:t,children:n})});return a.displayName=`${e}.Slot`,a}Symbol("RADIX:SYNC_STATE");var cs=Symbol("radix.slottable");function cc(e){return ew.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===cs}var cd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=cl(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function cu(e,t){e&&iy.flushSync(()=>e.dispatchEvent(t))}function cf(e){let t=ew.useRef(e);return ew.useEffect(()=>{t.current=e}),ew.useMemo(()=>(...e)=>t.current?.(...e),[])}var ch="dismissableLayer.update",cp=ew.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cm=ew.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...s}=e,c=ew.useContext(cp),[d,u]=ew.useState(null),f=d?.ownerDocument??globalThis?.document,[,h]=ew.useState({}),p=(0,s9.useComposedRefs)(t,e=>u(e)),m=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),x=d?m.indexOf(d):-1,y=c.layersWithOutsidePointerEventsDisabled.size>0,b=x>=v,w=function(e,t=globalThis?.document){let n=cf(e),r=ew.useRef(!1),a=ew.useRef(()=>{});return ew.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){cv("dismissableLayer.pointerDownOutside",n,i,{discrete:!0})},i={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=r,t.addEventListener("click",a.current,{once:!0})):r()}else t.removeEventListener("click",a.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{let t=e.target,n=[...c.branches].some(e=>e.contains(t));b&&!n&&(a?.(e),o?.(e),e.defaultPrevented||l?.())},f),j=function(e,t=globalThis?.document){let n=cf(e),r=ew.useRef(!1);return ew.useEffect(()=>{let e=e=>{e.target&&!r.current&&cv("dismissableLayer.focusOutside",n,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{let t=e.target;![...c.branches].some(e=>e.contains(t))&&(i?.(e),o?.(e),e.defaultPrevented||l?.())},f);return!function(e,t=globalThis?.document){let n=cf(e);ew.useEffect(()=>{let e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{x===c.layers.size-1&&(r?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),ew.useEffect(()=>{if(d)return n&&(0===c.layersWithOutsidePointerEventsDisabled.size&&($=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),cg(),()=>{n&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=$)}},[d,f,n,c]),ew.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),cg())},[d,c]),ew.useEffect(()=>{let e=()=>h({});return document.addEventListener(ch,e),()=>document.removeEventListener(ch,e)},[]),(0,ey.jsx)(cd.div,{...s,ref:p,style:{pointerEvents:y?b?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,j.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,w.onPointerDownCapture)})});function cg(){let e=new CustomEvent(ch);document.dispatchEvent(e)}function cv(e,t,n,{discrete:r}){let a=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?cu(a,i):a.dispatchEvent(i)}cm.displayName="DismissableLayer",ew.forwardRef((e,t)=>{let n=ew.useContext(cp),r=ew.useRef(null),a=(0,s9.useComposedRefs)(t,r);return ew.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,ey.jsx)(cd.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var cx="focusScope.autoFocusOnMount",cy="focusScope.autoFocusOnUnmount",cb={bubbles:!1,cancelable:!0},cw=ew.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,s]=ew.useState(null),c=cf(a),d=cf(i),u=ew.useRef(null),f=(0,s9.useComposedRefs)(t,e=>s(e)),h=ew.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;ew.useEffect(()=>{if(r){let e=function(e){if(h.paused||!l)return;let t=e.target;l.contains(t)?u.current=t:cS(u.current,{select:!0})},t=function(e){if(h.paused||!l)return;let t=e.relatedTarget;null!==t&&(l.contains(t)||cS(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&cS(l)});return l&&n.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[r,l,h.paused]),ew.useEffect(()=>{if(l){cN.add(h);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(cx,cb);l.addEventListener(cx,c),l.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(cS(r,{select:t}),document.activeElement!==n)return}(cj(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&cS(l))}return()=>{l.removeEventListener(cx,c),setTimeout(()=>{let t=new CustomEvent(cy,cb);l.addEventListener(cy,d),l.dispatchEvent(t),t.defaultPrevented||cS(e??document.body,{select:!0}),l.removeEventListener(cy,d),cN.remove(h)},0)}}},[l,c,d,h]);let p=ew.useCallback(e=>{if(!n&&!r||h.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){var i;let t,r=e.currentTarget,[o,l]=[ck(t=cj(i=r),i),ck(t.reverse(),i)];o&&l?e.shiftKey||a!==l?e.shiftKey&&a===o&&(e.preventDefault(),n&&cS(l,{select:!0})):(e.preventDefault(),n&&cS(o,{select:!0})):a===r&&e.preventDefault()}},[n,r,h.paused]);return(0,ey.jsx)(cd.div,{tabIndex:-1,...o,ref:f,onKeyDown:p})});function cj(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ck(e,t){for(let n of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function cS(e,{select:t=!1}={}){if(e&&e.focus){var n;let r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}cw.displayName="FocusScope";var cN=(d=[],{add(e){let t=d[0];e!==t&&t?.pause(),(d=cC(d,e)).unshift(e)},remove(e){d=cC(d,e),d[0]?.resume()}});function cC(e,t){let n=[...e],r=n.indexOf(t);return -1!==r&&n.splice(r,1),n}var cM=ew.forwardRef((e,t)=>{let{container:n,...r}=e,[a,i]=ew.useState(!1);ct(()=>i(!0),[]);let o=n||a&&globalThis?.document?.body;return o?iy.default.createPortal((0,ey.jsx)(cd.div,{...r,ref:t}),o):null});cM.displayName="Portal";var cE=e=>{var t;let n,r,{present:a,children:i}=e,o=function(e){var t,n;let[r,a]=ew.useState(),i=ew.useRef(null),o=ew.useRef(e),l=ew.useRef("none"),[s,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},ew.useReducer((e,t)=>n[e][t]??e,t));return ew.useEffect(()=>{let e=cO(i.current);l.current="mounted"===s?e:"none"},[s]),ct(()=>{let t=i.current,n=o.current;if(n!==e){let r=l.current,a=cO(t);e?c("MOUNT"):"none"===a||t?.display==="none"?c("UNMOUNT"):n&&r!==a?c("ANIMATION_OUT"):c("UNMOUNT"),o.current=e}},[e,c]),ct(()=>{if(r){let e,t=r.ownerDocument.defaultView??window,n=n=>{let a=cO(i.current).includes(CSS.escape(n.animationName));if(n.target===r&&a&&(c("ANIMATION_END"),!o.current)){let n=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=n)})}},a=e=>{e.target===r&&(l.current=cO(i.current))};return r.addEventListener("animationstart",a),r.addEventListener("animationcancel",n),r.addEventListener("animationend",n),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",a),r.removeEventListener("animationcancel",n),r.removeEventListener("animationend",n)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ew.useCallback(e=>{i.current=e?getComputedStyle(e):null,a(e)},[])}}(a),l="function"==typeof i?i({present:o.isPresent}):ew.Children.only(i),s=(0,s9.useComposedRefs)(o.ref,(t=l,(r=(n=Object.getOwnPropertyDescriptor(t.props,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.ref:(r=(n=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.props.ref:t.props.ref||t.ref));return"function"==typeof i||o.isPresent?ew.cloneElement(l,{ref:s}):null};function cO(e){return e?.animationName||"none"}cE.displayName="Presence";var cP=0;function cA(){ew.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cI()),document.body.insertAdjacentElement("beforeend",e[1]??cI()),cP++,()=>{1===cP&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cP--}},[])}function cI(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var cz=function(){return(cz=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function cT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)0>t.indexOf(r[a])&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}var cD=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),c_="width-before-scroll-bar";function cR(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var cL="u">typeof window?ew.useLayoutEffect:ew.useEffect,c$=new WeakMap,cF=(void 0===b&&(b={}),(void 0===w&&(w=function(e){return e}),j=[],k=!1,S={read:function(){if(k)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return j.length?j[j.length-1]:null},useMedium:function(e){var t=w(e,k);return j.push(t),function(){j=j.filter(function(e){return e!==t})}},assignSyncMedium:function(e){for(k=!0;j.length;){var t=j;j=[],t.forEach(e)}j={push:function(t){return e(t)},filter:function(){return j}}},assignMedium:function(e){k=!0;var t=[];if(j.length){var n=j;j=[],n.forEach(e),t=j}var r=function(){var n=t;t=[],n.forEach(e)},a=function(){return Promise.resolve().then(r)};a(),j={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),j}}}}).options=cz({async:!0,ssr:!1},b),S),cB=function(){},cV=ew.forwardRef(function(e,t){var n,r,a,i,o=ew.useRef(null),l=ew.useState({onScrollCapture:cB,onWheelCapture:cB,onTouchMoveCapture:cB}),s=l[0],c=l[1],d=e.forwardProps,u=e.children,f=e.className,h=e.removeScrollBar,p=e.enabled,m=e.shards,g=e.sideCar,v=e.noRelative,x=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,j=e.gapMode,k=cT(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=(n=[o,t],r=function(e){return n.forEach(function(t){return cR(t,e)})},(a=(0,ew.useState)(function(){return{value:null,callback:r,facade:{get current(){return a.value},set current(value){var e=a.value;e!==value&&(a.value=value,a.callback(value,e))}}}})[0]).callback=r,i=a.facade,cL(function(){var e=c$.get(i);if(e){var t=new Set(e),r=new Set(n),a=i.current;t.forEach(function(e){r.has(e)||cR(e,null)}),r.forEach(function(e){t.has(e)||cR(e,a)})}c$.set(i,n)},[n]),i),N=cz(cz({},k),s);return ew.createElement(ew.Fragment,null,p&&ew.createElement(g,{sideCar:cF,removeScrollBar:h,shards:m,noRelative:v,noIsolation:x,inert:y,setCallbacks:c,allowPinchZoom:!!b,lockRef:o,gapMode:j}),d?ew.cloneElement(ew.Children.only(u),cz(cz({},N),{ref:S})):ew.createElement(void 0===w?"div":w,cz({},N,{className:f,ref:S}),u))});cV.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},cV.classNames={fullWidth:c_,zeroRight:cD};var cH=function(e){var t=e.sideCar,n=cT(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error("Sidecar medium not found");return ew.createElement(r,cz({},n))};cH.isSideCarExport=!0;var cU=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=F||("u">typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var r,a;(r=t).styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n)),a=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(a)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cW=function(){var e=cU();return function(t,n){ew.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cq=function(){var e=cW();return function(t){return e(t.styles,t.dynamic),null}},cK={left:0,top:0,right:0,gap:0},cG=function(e){return parseInt(e||"",10)||0},cX=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],a=t["padding"===e?"paddingRight":"marginRight"];return[cG(n),cG(r),cG(a)]},cY=function(e){if(void 0===e&&(e="margin"),"u"<typeof window)return cK;var t=cX(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},cZ=cq(),cJ="data-scroll-locked",cQ=function(e,t,n,r){var a=e.left,i=e.top,o=e.right,l=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(l,"px ").concat(r,";\n }\n body[").concat(cJ,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(a,"px;\n padding-top: ").concat(i,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(cD," {\n right: ").concat(l,"px ").concat(r,";\n }\n \n .").concat(c_," {\n margin-right: ").concat(l,"px ").concat(r,";\n }\n \n .").concat(cD," .").concat(cD," {\n right: 0 ").concat(r,";\n }\n \n .").concat(c_," .").concat(c_," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(cJ,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},c0=function(){var e=parseInt(document.body.getAttribute(cJ)||"0",10);return isFinite(e)?e:0},c1=function(){ew.useEffect(function(){return document.body.setAttribute(cJ,(c0()+1).toString()),function(){var e=c0()-1;e<=0?document.body.removeAttribute(cJ):document.body.setAttribute(cJ,e.toString())}},[])},c2=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=void 0===r?"margin":r;c1();var i=ew.useMemo(function(){return cY(a)},[a]);return ew.createElement(cZ,{styles:cQ(i,!t,a,n?"":"!important")})},c5=!1;if("u">typeof window)try{var c4=Object.defineProperty({},"passive",{get:function(){return c5=!0,!0}});window.addEventListener("test",c4,c4),window.removeEventListener("test",c4,c4)}catch(e){c5=!1}var c3=!!c5&&{passive:!1},c6=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},c8=function(e,t){var n=t.ownerDocument,r=t;do{if("u">typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),c7(e,r)){var a=c9(e,r);if(a[1]>a[2])return!0}r=r.parentNode}while(r&&r!==n.body)return!1},c7=function(e,t){return"v"===e?c6(t,"overflowY"):c6(t,"overflowX")},c9=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},de=function(e,t,n,r,a){var i,o=(i=window.getComputedStyle(t).direction,"h"===e&&"rtl"===i?-1:1),l=o*r,s=n.target,c=t.contains(s),d=!1,u=l>0,f=0,h=0;do{if(!s)break;var p=c9(e,s),m=p[0],g=p[1]-p[2]-o*m;(m||g)&&c7(e,s)&&(f+=g,h+=m);var v=s.parentNode;s=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&s!==document.body||c&&(t.contains(s)||t===s))return u&&(a&&1>Math.abs(f)||!a&&l>f)?d=!0:!u&&(a&&1>Math.abs(h)||!a&&-l>h)&&(d=!0),d},dt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},dn=function(e){return[e.deltaX,e.deltaY]},dr=function(e){return e&&"current"in e?e.current:e},da=0,di=[];let dl=(N=function(e){var t=ew.useRef([]),n=ew.useRef([0,0]),r=ew.useRef(),a=ew.useState(da++)[0],i=ew.useState(cq)[0],o=ew.useRef(e);ew.useEffect(function(){o.current=e},[e]),ew.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var t=(function(e,t,n){if(n||2==arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(dr),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=ew.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var a,i=dt(e),l=n.current,s="deltaX"in e?e.deltaX:l[0]-i[0],c="deltaY"in e?e.deltaY:l[1]-i[1],d=e.target,u=Math.abs(s)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var f=window.getSelection(),h=f&&f.anchorNode;if(h&&(h===d||h.contains(d)))return!1;var p=c8(u,d);if(!p)return!0;if(p?a=u:(a="v"===u?"h":"v",p=c8(u,d)),!p)return!1;if(!r.current&&"changedTouches"in e&&(s||c)&&(r.current=a),!a)return!0;var m=r.current||a;return de(m,t,e,"h"===m?s:c,!0)},[]),s=ew.useCallback(function(e){if(di.length&&di[di.length-1]===i){var n="deltaY"in e?dn(e):dt(e),r=t.current.filter(function(t){var r;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(r=t.delta,r[0]===n[0]&&r[1]===n[1])})[0];if(r&&r.should){e.cancelable&&e.preventDefault();return}if(!r){var a=(o.current.shards||[]).map(dr).filter(Boolean).filter(function(t){return t.contains(e.target)});(a.length>0?l(e,a[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),c=ew.useCallback(function(e,n,r,a){var i={name:e,delta:n,target:r,should:a,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(r)};t.current.push(i),setTimeout(function(){t.current=t.current.filter(function(e){return e!==i})},1)},[]),d=ew.useCallback(function(e){n.current=dt(e),r.current=void 0},[]),u=ew.useCallback(function(t){c(t.type,dn(t),t.target,l(t,e.lockRef.current))},[]),f=ew.useCallback(function(t){c(t.type,dt(t),t.target,l(t,e.lockRef.current))},[]);ew.useEffect(function(){return di.push(i),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",s,c3),document.addEventListener("touchmove",s,c3),document.addEventListener("touchstart",d,c3),function(){di=di.filter(function(e){return e!==i}),document.removeEventListener("wheel",s,c3),document.removeEventListener("touchmove",s,c3),document.removeEventListener("touchstart",d,c3)}},[]);var h=e.removeScrollBar,p=e.inert;return ew.createElement(ew.Fragment,null,p?ew.createElement(i,{styles:"\n .block-interactivity-".concat(a," {pointer-events: none;}\n .allow-interactivity-").concat(a," {pointer-events: all;}\n")}):null,h?ew.createElement(c2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},cF.useMedium(N),cH);var ds=ew.forwardRef(function(e,t){return ew.createElement(cV,cz({},e,{ref:t,sideCar:dl}))});ds.classNames=cV.classNames;var dc=new WeakMap,dd=new WeakMap,du={},df=0,dh=function(e){return e&&(e.host||dh(e.parentNode))},dp=function(e,t,n,r){var a=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=dh(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});du[n]||(du[n]=new WeakMap);var i=du[n],o=[],l=new Set,s=new Set(a),c=function(e){!e||l.has(e)||(l.add(e),c(e.parentNode))};a.forEach(c);var d=function(e){!e||s.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))d(e);else try{var t=e.getAttribute(r),a=null!==t&&"false"!==t,s=(dc.get(e)||0)+1,c=(i.get(e)||0)+1;dc.set(e,s),i.set(e,c),o.push(e),1===s&&a&&dd.set(e,!0),1===c&&e.setAttribute(n,"true"),a||e.setAttribute(r,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),l.clear(),df++,function(){o.forEach(function(e){var t=dc.get(e)-1,a=i.get(e)-1;dc.set(e,t),i.set(e,a),t||(dd.has(e)||e.removeAttribute(r),dd.delete(e)),a||e.removeAttribute(n)}),--df||(dc=new WeakMap,dc=new WeakMap,dd=new WeakMap,du={})}},dm=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),a=t||("u"<typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),dp(r,a,n,"aria-hidden")):function(){return null}},dg="Dialog",[dv,dx]=s7(dg),[dy,db]=dv(dg),dw=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=ew.useRef(null),s=ew.useRef(null),[c,d]=co({prop:r,defaultProp:a??!1,onChange:i,caller:dg});return(0,ey.jsx)(dy,{scope:t,triggerRef:l,contentRef:s,contentId:ca(),titleId:ca(),descriptionId:ca(),open:c,onOpenChange:d,onOpenToggle:ew.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};dw.displayName=dg;var dj="DialogTrigger",dk=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dj,n),i=(0,s9.useComposedRefs)(t,a.triggerRef);return(0,ey.jsx)(cd.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":dH(a.open),...r,ref:i,onClick:ce(e.onClick,a.onOpenToggle)})});dk.displayName=dj;var dS="DialogPortal",[dN,dC]=dv(dS,{forceMount:void 0}),dM=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,i=db(dS,t);return(0,ey.jsx)(dN,{scope:t,forceMount:n,children:ew.Children.map(r,e=>(0,ey.jsx)(cE,{present:n||i.open,children:(0,ey.jsx)(cM,{asChild:!0,container:a,children:e})}))})};dM.displayName=dS;var dE="DialogOverlay",dO=ew.forwardRef((e,t)=>{let n=dC(dE,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=db(dE,e.__scopeDialog);return i.modal?(0,ey.jsx)(cE,{present:r||i.open,children:(0,ey.jsx)(dA,{...a,ref:t})}):null});dO.displayName=dE;var dP=cl("DialogOverlay.RemoveScroll"),dA=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dE,n);return(0,ey.jsx)(ds,{as:dP,allowPinchZoom:!0,shards:[a.contentRef],children:(0,ey.jsx)(cd.div,{"data-state":dH(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),dI="DialogContent",dz=ew.forwardRef((e,t)=>{let n=dC(dI,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=db(dI,e.__scopeDialog);return(0,ey.jsx)(cE,{present:r||i.open,children:i.modal?(0,ey.jsx)(dT,{...a,ref:t}):(0,ey.jsx)(dD,{...a,ref:t})})});dz.displayName=dI;var dT=ew.forwardRef((e,t)=>{let n=db(dI,e.__scopeDialog),r=ew.useRef(null),a=(0,s9.useComposedRefs)(t,n.contentRef,r);return ew.useEffect(()=>{let e=r.current;if(e)return dm(e)},[]),(0,ey.jsx)(d_,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,e=>e.preventDefault())})}),dD=ew.forwardRef((e,t)=>{let n=db(dI,e.__scopeDialog),r=ew.useRef(!1),a=ew.useRef(!1);return(0,ey.jsx)(d_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(a.current=!0));let i=t.target;n.triggerRef.current?.contains(i)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&a.current&&t.preventDefault()}})}),d_=ew.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=db(dI,n),s=ew.useRef(null),c=(0,s9.useComposedRefs)(t,s);return cA(),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(cw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:(0,ey.jsx)(cm,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":dH(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(dK,{titleId:l.titleId}),(0,ey.jsx)(dG,{contentRef:s,descriptionId:l.descriptionId})]})]})}),dR="DialogTitle",dL=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dR,n);return(0,ey.jsx)(cd.h2,{id:a.titleId,...r,ref:t})});dL.displayName=dR;var d$="DialogDescription",dF=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(d$,n);return(0,ey.jsx)(cd.p,{id:a.descriptionId,...r,ref:t})});dF.displayName=d$;var dB="DialogClose",dV=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dB,n);return(0,ey.jsx)(cd.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>a.onOpenChange(!1))})});function dH(e){return e?"open":"closed"}dV.displayName=dB;var dU="DialogTitleWarning",[dW,dq]=(C={contentName:dI,titleName:dR,docsSlug:"dialog"},l=ew.createContext(C),(s=e=>{let{children:t,...n}=e,r=ew.useMemo(()=>n,Object.values(n));return(0,ey.jsx)(l.Provider,{value:r,children:t})}).displayName=dU+"Provider",[s,function(e){let t=ew.useContext(l);if(t)return t;if(void 0!==C)return C;throw Error(`\`${e}\` must be used within \`${dU}\``)}]),dK=({titleId:e})=>{let t=dq(dU),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2
+ M${S.x},${S.y}h${S.width}v${S.height}h${-S.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}lF.displayName="MiniMap",(0,ew.memo)(lF);let lB={[R.Line]:"right",[R.Handle]:"bottom-right"},lV=(0,ew.memo)(function({nodeId:e,position:t,variant:n=R.Handle,className:r,style:a,children:i,color:o,minWidth:l=10,minHeight:s=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:p,onResizeStart:m,onResize:g,onResizeEnd:v}){let x,y=og(),b="string"==typeof e?e:y,w=iS(),j=(0,ew.useRef)(null),k=n===R.Handle,S=ik((0,ew.useCallback)((x=k&&h,e=>x?`${Math.max(1/e.transform[2],1)}`:void 0),[k,h]),ix),N=(0,ew.useRef)(null),C=t??lB[n];(0,ew.useEffect)(()=>{if(j.current&&b)return N.current||(N.current=function({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:a}){let i=t4(e),o={controlDirection:ir("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:l,keepAspectRatio:s,resizeDirection:c,onResizeStart:d,onResize:u,onResizeEnd:f,shouldResize:h}){let p,m,g,v,x={...il},y={...is};o={boundaries:l,resizeDirection:c,keepAspectRatio:s,controlDirection:ir(e)};let b=null,w=[],j=!1,k=ns().on("start",e=>{let{nodeLookup:r,transform:a,snapGrid:i,snapToGrid:o,nodeOrigin:l,paneDomNode:s}=n();if(!(p=r.get(t)))return;b=s?.getBoundingClientRect()??null;let{xSnapped:c,ySnapped:u}=ax(e.sourceEvent,{transform:a,snapGrid:i,snapToGrid:o,containerBounds:b});if(y={...x={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},pointerX:c,pointerY:u,aspectRatio:x.width/x.height},m=void 0,p.parentId&&("parent"===p.extent||p.expandParent)){var f;g=(m=r.get(p.parentId))&&"parent"===p.extent?[[0,0],[(f=m).measured.width,f.measured.height]]:void 0}for(let[e,n]of(w=[],v=void 0,r))if(n.parentId===t&&(w.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let r=t.position.x+e.position.x,a=t.position.y+e.position.y,i=e.measured.width??0,o=e.measured.height??0,l=n[0]*i,s=n[1]*o;return[[r-l,a-s],[r+i-l,a+o-s]]}(n,p,n.origin??l);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}d?.(e,{...x})}).on("drag",e=>{let{transform:t,snapGrid:a,snapToGrid:i,nodeOrigin:l}=n(),s=ax(e.sourceEvent,{transform:t,snapGrid:a,snapToGrid:i,containerBounds:b}),c=[];if(!p)return;let{x:d,y:f,width:k,height:S}=x,N={},C=p.origin??l,{width:M,height:E,x:O,y:P}=function(e,t,n,r,a,i,o,l){var s,c,d,u;let{affectsX:f,affectsY:h}=t,{isHorizontal:p,isVertical:m}=t,g=p&&m,{xSnapped:v,ySnapped:x}=n,{minWidth:y,maxWidth:b,minHeight:w,maxHeight:j}=r,{x:k,y:S,width:N,height:C,aspectRatio:M}=e,E=Math.floor(p?v-e.pointerX:0),O=Math.floor(m?x-e.pointerY:0),P=N+(f?-E:E),A=C+(h?-O:O),I=-i[0]*N,z=-i[1]*C,T=io(P,y,b),D=io(A,w,j);if(o){let e=0,t=0;f&&E<0?e=ia(k+E+I,o[0][0]):!f&&E>0&&(e=ii(k+P+I,o[1][0])),h&&O<0?t=ia(S+O+z,o[0][1]):!h&&O>0&&(t=ii(S+A+z,o[1][1])),T=Math.max(T,e),D=Math.max(D,t)}if(l){let e=0,t=0;f&&E>0?e=ii(k+E,l[0][0]):!f&&E<0&&(e=ia(k+P,l[1][0])),h&&O>0?t=ii(S+O,l[0][1]):!h&&O<0&&(t=ia(S+A,l[1][1])),T=Math.max(T,e),D=Math.max(D,t)}if(a){if(p){(T=Math.max(T,io(P/M,w,j)*M),o)&&(T=Math.max(T,(f||h)&&(!f||h||!g)?ia(S+z+(f?E:-E)/M,o[0][1])*M:ii(S+z+P/M,o[1][1])*M));l&&(T=Math.max(T,(f||h)&&(!f||h||!g)?ii(S+(f?E:-E)/M,l[0][1])*M:ia(S+P/M,l[1][1])*M))}if(m){(D=Math.max(D,io(A*M,y,b)/M),o)&&(D=Math.max(D,(f||h)&&(!h||f||!g)?ia(k+(h?O:-O)*M+I,o[0][0])/M:ii(k+A*M+I,o[1][0])/M));l&&(D=Math.max(D,(f||h)&&(!h||f||!g)?ii(k+(h?O:-O)*M,l[0][0])/M:ia(k+A*M,l[1][0])/M))}}O+=O<0?D:-D,E+=E<0?T:-T,a&&(g?P>A*M?O=((s=f,c=h,s?!c:c)?-E:E)/M:E=((d=f,u=h,d?!u:u)?-O:O)*M:p?(O=E/M,h=f):(E=O*M,f=h));let _=f?k+E:k,R=h?S+O:S;return{width:N+(f?-E:E),height:C+(h?-O:O),x:i[0]*E*(f?-1:1)+_,y:i[1]*O*(h?-1:1)+R}}(y,o.controlDirection,s,o.boundaries,o.keepAspectRatio,C,g,v),A=M!==k,I=E!==S,z=O!==d&&A,T=P!==f&&I;if(!z&&!T&&!A&&!I)return;if((z||T||1===C[0]||1===C[1])&&(N.x=z?O:x.x,N.y=T?P:x.y,x.x=N.x,x.y=N.y,w.length>0)){let e=O-d,t=P-f;for(let n of w)n.position={x:n.position.x-e+C[0]*(M-k),y:n.position.y-t+C[1]*(E-S)},c.push(n)}if((A||I)&&(N.width=A&&(!o.resizeDirection||"horizontal"===o.resizeDirection)?M:x.width,N.height=I&&(!o.resizeDirection||"vertical"===o.resizeDirection)?E:x.height,x.width=N.width,x.height=N.height),m&&p.expandParent){let e=C[0]*(N.width??0);N.x&&N.x<e&&(x.x=e,y.x=y.x-(N.x-e));let t=C[1]*(N.height??0);N.y&&N.y<t&&(x.y=t,y.y=y.y-(N.y-t))}let D=function({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:a,affectsY:i}){let o=e-t,l=n-r,s=[o>0?1:o<0?-1:0,l>0?1:l<0?-1:0];return o&&a&&(s[0]=-1*s[0]),l&&i&&(s[1]=-1*s[1]),s}({width:x.width,prevWidth:k,height:x.height,prevHeight:S,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),_={...x,direction:D};!1!==h?.(e,_)&&(j=!0,u?.(e,_),r(N,c))}).on("end",e=>{j&&(f?.(e,{...x}),a?.({...x}),j=!1)});i.call(k)},destroy:function(){i.on(".drag",null)}}}({domNode:j.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:a,domNode:i}=w.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:a,paneDomNode:i}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:a,nodeOrigin:i}=w.getState(),o=[],l={x:e.x,y:e.y},s=r.get(b);if(s&&s.expandParent&&s.parentId){let t=s.origin??i,n=e.width??s.measured.width??0,c=e.height??s.measured.height??0,d=aG([{id:s.id,parentId:s.parentId,rect:{width:n,height:c,...ag({x:e.x??s.position.x,y:e.y??s.position.y},{width:n,height:c},s.parentId,r,t)}}],r,a,i);o.push(...d),l.x=e.x?Math.max(t[0]*n,e.x):void 0,l.y=e.y?Math.max(t[1]*c,e.y):void 0}if(void 0!==l.x&&void 0!==l.y){let e={id:b,type:"position",position:{...l}};o.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:b,type:"dimensions",resizing:!0,setAttributes:!f||("horizontal"===f?"width":"height"),dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:"position"};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{w.getState().triggerNodeChanges([{id:b,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),N.current.update({controlPosition:C,boundaries:{minWidth:l,minHeight:s,maxWidth:c,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:m,onResize:g,onResizeEnd:v,shouldResize:p}),()=>{N.current?.destroy()}},[C,l,s,c,d,u,m,g,v,p]);let M=C.split("-");return(0,ey.jsx)("div",{className:tf(["react-flow__resize-control","nodrag",...M,n,r]),ref:j,style:{...a,scale:S,...o&&{[k?"backgroundColor":"borderColor"]:o}},children:i})}),lH=(0,ek.default)("cable",[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]]),lU=(0,ek.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),lW=(0,ek.default)("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),lq=(0,ek.default)("hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),lK=(0,ek.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),lG=(0,ek.default)("magnet",[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]]),lX=(0,ek.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),lY=(0,ek.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),lZ=(0,ek.default)("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]),lJ=(0,ek.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),lQ=(0,ek.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),l0=(0,ek.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var l1=e.i(93739),l2=e.i(94237);let l5=(0,l2.cva)("vtl-surface-popover z-50 flex w-fit items-center gap-1 rounded-[var(--surface-popover-radius)] border p-1",{variants:{placement:{"bottom-center":"fixed bottom-5 left-1/2 -translate-x-1/2","top-center":"fixed top-5 left-1/2 -translate-x-1/2","bottom-left":"fixed bottom-5 left-5","bottom-right":"fixed right-5 bottom-5",inline:"relative"},size:{default:"min-h-11",sm:"min-h-10 rounded-lg"}},defaultVariants:{placement:"bottom-center",size:"default"}});function l4({className:e,placement:t,size:n,...r}){return(0,ey.jsx)("div",{role:"toolbar","data-slot":"floating-action-bar","data-placement":t,"data-size":n,className:(0,eI.cn)(l5({placement:t,size:n}),e),...r})}function l3({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"floating-action-bar-group",className:(0,eI.cn)("flex items-center gap-1",e),...t})}function l6({className:e,variant:t="ghost",size:n="icon-sm",...r}){return(0,ey.jsx)(eA.Button,{"data-slot":"floating-action-bar-button",variant:t,size:n,className:(0,eI.cn)("rounded-lg",e),...r})}let l8={actions:"Canvas actions",add:"Add node",select:"Mouse",connect:"Connect",cut:"Cut",drag:"Drag",modeTools:"Mode",resetZoom:"Reset zoom",viewportTools:"Viewport tools",lockViewport:"Lock viewport",visualSnap:"Visual snap",nodeSnap:"Node snap",snapTools:"Snap tools",nodeActions:"Node actions",resizeNode:"Resize node",copyNode:"Copy node",cutNode:"Cut node"},l7={width:192,height:112};function l9(e,t){return Math.round(e/t)*t}function se(e,t,n){return Math.min(n,Math.max(t,e))}function st(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=Number.parseFloat(e);if(Number.isFinite(t))return t}return t}function sn(e){let t=e.measured;return{width:st(e.width??t?.width??e.style?.width,l7.width),height:st(e.height??t?.height??e.style?.height,l7.height)}}function sr({center:e,size:t=l7,snapGrid:n}){return{x:l9(e.x-t.width/2,n[0]),y:l9(e.y-t.height/2,n[1])}}let sa=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],si=[{id:"top",position:_.Top,className:"left-1/2 top-0 -translate-x-1/2 -translate-y-1/2"},{id:"right",position:_.Right,className:"right-0 top-1/2 -translate-y-1/2 translate-x-1/2"},{id:"bottom",position:_.Bottom,className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2"},{id:"left",position:_.Left,className:"left-0 top-1/2 -translate-x-1/2 -translate-y-1/2"}];function so(e,t){let n=e.width??e.measured?.width??l7.width,r=e.height??e.measured?.height??l7.height,a=t.width??t.measured?.width??l7.width,i=t.height??t.measured?.height??l7.height,o={x:e.position.x+n/2,y:e.position.y+r/2},l={x:t.position.x+a/2,y:t.position.y+i/2},s=l.x-o.x,c=l.y-o.y;return Math.abs(s)>=Math.abs(c)?s>=0?{sourceHandle:"source-right",targetHandle:"target-left"}:{sourceHandle:"source-left",targetHandle:"target-right"}:c>=0?{sourceHandle:"source-bottom",targetHandle:"target-top"}:{sourceHandle:"source-top",targetHandle:"target-bottom"}}function sl(e){return e===_.Top?{x:0,y:-1}:e===_.Bottom?{x:0,y:1}:e===_.Left?{x:-1,y:0}:{x:1,y:0}}function ss(e,t){return Math.max(48,Math.min(180,.46*Math.hypot(t.x-e.x,t.y-e.y)))}function sc({point:e,position:t}){return t===_.Top||t===_.Bottom?`M ${e.x-14} ${e.y} L ${e.x+14} ${e.y}`:`M ${e.x} ${e.y-14} L ${e.x} ${e.y+14}`}function sd(e){let t=sn(e);return{x:e.position.x,y:e.position.y,width:t.width,height:t.height,right:e.position.x+t.width,bottom:e.position.y+t.height}}function su(e,t,n,r){let a=Math.max(e,n),i=Math.min(t,r);return a<=i?{distance:0,midpoint:(a+i)/2}:t<n?{distance:n-t,midpoint:(t+n)/2}:{distance:e-r,midpoint:(r+e)/2}}function sf(e,t,n){let r=ew.useRef(null),a=ew.useRef(e),i=ew.useRef(t),[o,l]=ew.useState(e),s=ew.useMemo(()=>n?{height:n.height,measured:n.measured,position:n.position,width:n.width}:void 0,[n]);return ew.useEffect(()=>{let n=a.current,o=i.current,c=o&&o!==t?220:110,d=performance.now();a.current=e,i.current=t,r.current&&window.cancelAnimationFrame(r.current);let u=a=>{let i=Math.min(1,(a-d)/c);l(function({from:e,to:t,fromPosition:n,toPosition:r,progress:a,node:i}){var o;let l,s;if(!i||!n||!r||n===r)return{x:e.x+(t.x-e.x)*a,y:e.y+(t.y-e.y)*a};let c=i.width??i.measured?.width??l7.width,d=i.height??i.measured?.height??l7.height,u={x:i.position.x,y:i.position.y,width:c,height:d},f=sh(e,u),h=sh(t,u),p=2*c+2*d,m=h-f;return Math.abs(m)>p/2&&(m+=m>0?-p:p),(s=((f+m*a)%(l=2*(o=u).width+2*o.height)+l)%l)<=o.width?{x:o.x+s,y:o.y}:s<=o.width+o.height?{x:o.x+o.width,y:o.y+s-o.width}:s<=2*o.width+o.height?{x:o.x+o.width-(s-o.width-o.height),y:o.y+o.height}:{x:o.x,y:o.y+o.height-(s-2*o.width-o.height)}}({from:n,to:e,fromPosition:o,toPosition:t,progress:1-Math.pow(1-i,3),node:s})),i<1&&(r.current=window.requestAnimationFrame(u))};return r.current=window.requestAnimationFrame(u),()=>{r.current&&window.cancelAnimationFrame(r.current)}},[s,e,e.x,e.y,t]),o}function sh(e,t){let n=t.x+t.width,r=t.y+t.height;return 1>=Math.abs(e.y-t.y)?e.x-t.x:1>=Math.abs(e.x-n)?t.width+e.y-t.y:1>=Math.abs(e.y-r)?t.width+t.height+n-e.x:2*t.width+t.height+r-e.y}function sp({route:e,viewportZoom:t}){let n=e.sourcePosition===_.Left||e.sourcePosition===_.Right;return(0,ey.jsx)(lx,{children:(0,ey.jsx)("div",{"data-slot":"node-canvas-joined-terminal",className:"node-canvas-joined-terminal nodrag nopan",style:{position:"absolute",transform:`translate(${e.terminalPoint.x}px, ${e.terminalPoint.y}px) scale(${1/t}) translate(-50%, -50%)`,transformOrigin:"0 0"},children:(0,ey.jsx)("span",{className:"node-canvas-joined-terminal-line","data-orientation":n?"vertical":"horizontal"})})})}function sm({className:e,viewportClassName:t,background:n,fitView:r=!1,snapGrid:a=[16,16],snapToGrid:i=!0,minZoom:o=.15,maxZoom:l=2.5,proOptions:s={hideAttribution:!0},nodes:c=[],edges:d=[],actionBar:u=!0,actionBarOpen:f,defaultActionBarOpen:h=!1,mode:p,defaultMode:m="select",visualSnap:g,defaultVisualSnap:v=!1,onVisualSnapChange:x,nodeSnap:y,defaultNodeSnap:b=!1,onNodeSnapChange:w,viewportLocked:j,defaultViewportLocked:k=!1,onViewportLockedChange:S,selectedNodeId:N,defaultSelectedNodeId:C,resizingNodeId:M,defaultResizingNodeId:E,labels:O,onActionBarOpenChange:P,onModeChange:A,onSelectedNodeChange:I,onResizingNodeChange:z,onCanvasAction:T,onNodeCanvasNodeAction:D,onNodeCanvasConnect:_,onNodeCanvasEdgeAction:R,nodesDraggable:L,panOnDrag:$,panOnScroll:F,zoomOnScroll:B,zoomOnPinch:V,onNodesChange:H,onNodeClick:U,onPaneClick:W,onEdgesChange:q,defaultViewport:K,children:G,...X}){let Y=ew.useRef(null),Z=ew.useRef(null),J=ew.useRef({}),Q=ew.useRef(0),{getViewport:ee,getZoom:et,screenToFlowPosition:en,setViewport:er}=oe(),ea=function(){let[e,t]=ew.useState("light");return ew.useEffect(()=>{let e=document.documentElement,n=()=>{t(e.classList.contains("dark")?"dark":"light")},r=new MutationObserver(n);return n(),r.observe(e,{attributeFilter:["class"],attributes:!0}),()=>r.disconnect()},[]),e}(),[ei,eo]=ew.useState(1),[el,es]=ew.useState(K??{x:0,y:0,zoom:1}),[ec,ed]=ew.useState({width:0,height:0}),[eu,ef]=ew.useState(h),[eh,ep]=ew.useState(m),[em,eg]=ew.useState(v),[ev,ex]=ew.useState(b),[eb,ej]=ew.useState(k),[ek,eS]=ew.useState(C),[eN,eC]=ew.useState(E),[eM,eE]=ew.useState(!1),eO={...l8,...O},eP=p??eh,eA=g??em,ez=y??ev,eT=j??eb,eD=N??ek,e_=M??eN,eR="drag"===eP,eL=!eT&&("select"===eP||"drag"===eP||"connect"===eP),e$=ew.useCallback(e=>{void 0===N&&eS(e),I?.(e)},[I,N]),eF=ew.useCallback(e=>{void 0===M&&eC(e),z?.(e)},[z,M]),eB=ew.useCallback((e,t)=>{Z.current=e,t.preventDefault(),t.stopPropagation()},[]),eV=ew.useCallback(e=>{e$(e),eF(void 0)},[eF,e$]),eH=ew.useMemo(()=>c.map(e=>({...e,data:{...e.data??{},mode:eP,resizing:e.id===e_,onConnectPointerDown:eB,onSelectNode:eV},selected:eD?e.id===eD:e.selected})),[eP,e_,eD,eB,eV,c]),eU=ew.useMemo(()=>d.map(e=>{let t=e.data,n=c.find(t=>t.id===e.source),r=c.find(t=>t.id===e.target),a="connection"===e.type&&t?.autoHandles!==!1&&n&&r?so(n,r):{sourceHandle:e.sourceHandle,targetHandle:e.targetHandle};return{...e,...a,data:{...e.data??{},cutActive:eM,mode:eP,viewportZoom:ei,onAddAnchor:(e,t,n)=>R?.("add-anchor",e,{anchor:t,anchorIndex:n}),onMoveAnchor:(e,t,n)=>R?.("move-anchor",e,{anchor:n,anchorIndex:t}),onDeleteAnchor:(e,t)=>R?.("delete-anchor",e,{anchorIndex:t}),onCutEdge:e=>R?.("cut-edge",e,{})}}}),[eP,eM,d,c,R,ei]);ew.useEffect(()=>{if("connect"!==eP){Z.current=null;return}let e=e=>{let t=Z.current;if(!t)return;Z.current=null;let n=document.elementsFromPoint(e.clientX,e.clientY).find(e=>e.classList.contains("react-flow__node")),r=n?.getAttribute("data-id");if(!r||r===t)return;let a=c.find(e=>e.id===t),i=c.find(e=>e.id===r);a&&i&&_?.({source:t,target:r,...so(a,i)})};return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[eP,c,_]),ew.useEffect(()=>{if("cut"!==eP)return void eE(!1);let e=()=>eE(!1);return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[eP]),ew.useEffect(()=>{eo(et()),es(ee())},[ee,et]),ew.useEffect(()=>{let e=Y.current;if(!e)return;let t=()=>{ed({width:e.clientWidth,height:e.clientHeight})},n=new ResizeObserver(t);return t(),n.observe(e),()=>n.disconnect()},[]),ew.useEffect(()=>{eA||(J.current={})},[eA]);let eW=ew.useCallback((e,t={})=>{let n=Y.current?.getBoundingClientRect();if(!n||0===c.length)return;let r=t.threshold??42,a=Math.max(r+1,64),i=[],o=[];function l(e,n){let i=J.current[e];if(i){let o=n.find(e=>e.nodeId===i.nodeId&&e.edge===i.edge);if(o){if(i.released){if(o.distance<=r)return;J.current[e]=void 0;return}if(o.distance<=1)return t.preserveEscapeDistance||(J.current[e]={nodeId:i.nodeId,edge:i.edge}),o;let n=(i.escapeDistance??0)+o.distance;return o.distance<=a&&n<a?(J.current[e]={...i,escapeDistance:n},o):void(J.current[e]={nodeId:i.nodeId,edge:i.edge,released:!0})}J.current[e]=void 0}let o=n.filter(e=>e.distance<=r).sort((e,t)=>e.distance-t.distance)[0];return o&&(J.current[e]={nodeId:o.nodeId,edge:o.edge}),o}for(let t of c){let r=sn(t),a=t.position.x*e.zoom+e.x,l=(t.position.x+r.width)*e.zoom+e.x,s=t.position.y*e.zoom+e.y,c=(t.position.y+r.height)*e.zoom+e.y;i.push({nodeId:t.id,edge:"left",delta:-a,distance:Math.abs(a)}),i.push({nodeId:t.id,edge:"right",delta:n.width-l,distance:Math.abs(n.width-l)}),o.push({nodeId:t.id,edge:"top",delta:-s,distance:Math.abs(s)}),o.push({nodeId:t.id,edge:"bottom",delta:n.height-c,distance:Math.abs(n.height-c)})}let s=l("x",i),d=l("y",o),u=s?.delta??0,f=d?.delta??0;.5>Math.abs(u)&&.5>Math.abs(f)||er({x:e.x+u,y:e.y+f,zoom:e.zoom},{duration:t.duration??0})},[c,er]);return!function({onStart:e,onChange:t,onEnd:n}){let r=iS();(0,ew.useEffect)(()=>{r.setState({onViewportChangeStart:e})},[e]),(0,ew.useEffect)(()=>{r.setState({onViewportChange:t})},[t]),(0,ew.useEffect)(()=>{r.setState({onViewportChangeEnd:n})},[n])}({onChange:e=>{eo(e.zoom),es(e),eA&&Date.now()>=Q.current&&eW(e,{preserveEscapeDistance:!0,threshold:42})},onEnd:e=>{eo(e.zoom),es(e),eA&&Date.now()>=Q.current&&eW(e,{duration:140})}}),(0,ey.jsxs)("div",{ref:Y,"data-slot":"node-canvas","data-mode":eP,style:{"--node-canvas-zoom":String(ei)},className:(0,eI.cn)("node-canvas vtl-surface-panel relative h-[620px] min-h-[360px] w-full overflow-hidden rounded-[var(--surface-panel-radius)] border",e),onPointerDown:e=>{"cut"===eP&&0===e.button&&eE(!0)},children:[(0,ey.jsxs)(lg,{colorMode:X.colorMode??ea,fitView:r,minZoom:o,maxZoom:l,nodes:eH,edges:eU,nodesDraggable:L??eR,panOnDrag:$??eL,panOnScroll:!eT&&(F??!1),proOptions:s,snapGrid:a,snapToGrid:i,zoomOnScroll:!eT&&(B??!0),zoomOnPinch:!eT&&V,zoomOnDoubleClick:!1,defaultViewport:K,className:(0,eI.cn)("node-canvas__viewport",t),...X,onNodesChange:function(e){let t=eA?ee():void 0,n=eA?Y.current?.getBoundingClientRect():void 0,r=e.filter(e=>"select"!==e.type).map(e=>{if(e_||"position"!==e.type||!e.position||!ez&&!eA)return e;let r=e.position;return ez&&(r=function({nodeId:e,position:t,nodes:n,zoom:r,threshold:a=32}){let i=n.find(t=>t.id===e);if(!i)return t;let o=sn(i),l=a/Math.max(r,.1),s=t.x,c=t.y,d=l+1,u=l+1;for(let r of n){if(r.id===e)continue;let n=sn(r),a=r.position.x,i=r.position.x+n.width,f=r.position.y,h=r.position.y+n.height,p=t.x,m=t.x+o.width,g=t.y,v=t.y+o.height;for(let e of[a-p,i-m,i-p,a-m]){let n=Math.abs(e);n<d&&n<=l&&(d=n,s=t.x+e)}for(let e of[f-g,h-v,h-g,f-v]){let n=Math.abs(e);n<u&&n<=l&&(u=n,c=t.y+e)}}return{x:s,y:c}}({nodeId:e.id,position:r,nodes:c,zoom:ei})),eA&&t&&n&&(r=function({nodeId:e,position:t,nodes:n,viewport:r,viewportRect:a,threshold:i=42}){let o=n.find(t=>t.id===e);if(!o)return t;let l=sn(o),s=t.x*r.zoom+r.x,c=(t.x+l.width)*r.zoom+r.x,d=t.y*r.zoom+r.y,u=(t.y+l.height)*r.zoom+r.y,f=t.x,h=t.y,p=i+1,m=i+1;for(let e of[-s,a.width-c]){let n=Math.abs(e);n<p&&n<=i&&(p=n,f=t.x+e/r.zoom)}for(let e of[-d,a.height-u]){let n=Math.abs(e);n<m&&n<=i&&(m=n,h=t.y+e/r.zoom)}return{x:f,y:h}}({nodeId:e.id,position:r,nodes:c,viewport:t,viewportRect:n})),{...e,position:r}});H?.(r)},onEdgesChange:q,onNodeClick:(e,t)=>{U?.(e,t),"drag"===eP&&(e$(t.id),eF(void 0))},onPaneClick:e=>{if(W?.(e),e_){e$(e_),eF(void 0);return}e$(void 0)},children:[!1!==n?(0,ey.jsx)(lS,{color:"var(--node-canvas-dot)",gap:16,size:1.35,...n}):null,G]}),eD?(0,ey.jsx)(sv,{labels:eO,node:c.find(e=>e.id===eD),rootSize:ec,viewport:el,onAction:function(e){if(!eD)return;if("resize"===e){eF(eD),e$(void 0);return}let t=Y.current?.getBoundingClientRect(),n=en({x:(t?.left??0)+(t?.width??0)/2,y:(t?.top??0)+(t?.height??0)/2}),r=sr({center:n,snapGrid:a});D?.(e,eD,{flowPosition:n,snappedPosition:r})}}):null,u?(0,ey.jsx)(sx,{open:f??eu,mode:eP,visualSnap:eA,nodeSnap:ez,viewportLocked:eT,labels:eO,onOpenChange:function(e){void 0===f&&ef(e),P?.(e)},onModeChange:function(e){void 0===p&&ep(e),A?.(e)},onAction:function(e){let t=Y.current?.getBoundingClientRect(),n=en({x:(t?.left??0)+(t?.width??0)/2,y:(t?.top??0)+(t?.height??0)/2}),r=sr({center:n,snapGrid:a});T?.(e,{flowPosition:n,snappedPosition:r})},onResetZoom:function(){let e=K?.zoom??1,t=ee(),n=Y.current?.getBoundingClientRect();if(J.current={},Q.current=Date.now()+320,!n){er({...t,zoom:e},{duration:220}),eo(e);return}let r={x:n.width/2,y:n.height/2},a={x:(r.x-t.x)/t.zoom,y:(r.y-t.y)/t.zoom};er({x:r.x-a.x*e,y:r.y-a.y*e,zoom:e},{duration:220}),eo(e)},onViewportLockedChange:function(e){void 0===j&&ej(e),S?.(e)},onVisualSnapChange:function(e){void 0===g&&eg(e),x?.(e)},onNodeSnapChange:function(e){void 0===y&&ex(e),w?.(e)}}):null]})}function sg({labels:e,onAction:t}){return(0,ey.jsx)(l4,{"data-slot":"node-canvas-selected-toolbar",placement:"inline",size:"sm","aria-label":e.nodeActions,className:"vtl-surface-popover rounded-[var(--surface-popover-radius)] p-1",children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":e.resizeNode,onClick:()=>t("resize"),children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":e.copyNode,onClick:()=>t("copy"),children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":e.cutNode,onClick:()=>t("cut"),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function sv({labels:e,node:t,rootSize:n,viewport:r,onAction:a}){if(!t||n.width<=0||n.height<=0)return null;let i=sn(t),o=t.position.x*r.zoom+r.x,l=t.position.y*r.zoom+r.y,s=i.width*r.zoom,c=i.height*r.zoom,d=70,u=n.width-8-62,f=u>=d?se(o+s/2,d,u):n.width/2,h=n.height-8-42,p=l+c+10,m=l-42-10,g=p<=h,v=m>=8,x=h<8?Math.max(0,(n.height-42)/2):g?p:v?Math.min(m,h):se(m,8,h);return(0,ey.jsx)("div",{"data-slot":"node-canvas-selected-toolbar-overlay",className:"pointer-events-none absolute z-30 flex justify-center",style:{left:f-62,top:x,width:124},children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(sg,{labels:e,onAction:a})})})}function sx({open:e,mode:t,visualSnap:n,nodeSnap:r,viewportLocked:a,labels:i,onOpenChange:o,onModeChange:l,onAction:s,onResetZoom:c,onViewportLockedChange:d,onVisualSnapChange:u,onNodeSnapChange:f}){let[h,p]=ew.useState(),m="border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",g=[{key:"select",mode:"select",label:i.select,icon:(0,ey.jsx)(lZ,{className:"size-4"})},{key:"drag",mode:"drag",action:"drag",label:i.drag,icon:(0,ey.jsx)(lq,{className:"size-4"})},{key:"connect",mode:"connect",action:"connect",label:i.connect,icon:(0,ey.jsx)(lH,{className:"size-4"})},{key:"cut",mode:"cut",action:"cut",label:i.cut,icon:(0,ey.jsx)(l0,{className:"size-4"})}],v=g.find(e=>e.mode===t)??g[0],x=Number(n)+Number(r),y=[{key:"add",type:"action",label:i.add,icon:(0,ey.jsx)(lJ,{className:"size-4"})},{key:"mode",type:"group",label:`${i.modeTools}: ${v.label}`,icon:v.icon},{key:"viewport",type:"group",pressed:a,label:i.viewportTools,icon:a?(0,ey.jsx)(lK,{className:"size-4"}):(0,ey.jsx)(lQ,{className:"size-4"})},{key:"snap",type:"group",pressed:x>0,count:x,label:i.snapTools,icon:(0,ey.jsx)(lG,{className:"size-4"})}];return ew.useEffect(()=>{e||p(void 0)},[e]),(0,ey.jsx)("div",{"data-slot":"node-canvas-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[y.map((o,v)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute inset-0 transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(v+1)*42}px)`:void 0},children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":o.label,"aria-expanded":"group"===o.type?h===o.key:void 0,"aria-pressed":"group"===o.type&&!!o.pressed||void 0,onClick:()=>{"action"===o.type?s(o.key):p(e=>e===o.key?void 0:o.key)},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[border-color,background-color,color,box-shadow] duration-150","group"===o.type&&o.pressed&&m),children:[o.icon,"snap"===o.key&&o.count>0?(0,ey.jsx)("span",{className:"absolute -top-1 -right-1 grid size-4 place-items-center rounded-full border bg-background text-[10px] leading-none text-foreground shadow-sm",children:o.count}):null]}),"mode"===o.key?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","mode"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:g.map(e=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":e.label,"aria-pressed":t===e.mode,onClick:()=>{l(e.mode),e.action&&e.mode!==t&&s(e.action)},className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",t===e.mode&&m),children:e.icon},e.key))}):null,"viewport"===o.key?(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","viewport"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.resetZoom,onClick:c,className:"rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lQ,{className:"size-4"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.lockViewport,"aria-pressed":a,onClick:()=>d(!a),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",a&&m),children:(0,ey.jsx)(lK,{className:"size-4"})})]}):null,"snap"===o.key?(0,ey.jsxs)("div",{className:(0,eI.cn)("absolute top-0 right-10 flex h-8 flex-row-reverse items-center gap-2 transition-[opacity,transform] duration-150 ease-out","snap"===h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.visualSnap,"aria-pressed":n,onClick:()=>u(!n),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",n&&m),children:(0,ey.jsx)(lW,{className:"size-4"})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.nodeSnap,"aria-pressed":r,onClick:()=>f(!r),className:(0,eI.cn)("rounded-full bg-background/95 shadow-md backdrop-blur transition-colors",r&&m),children:(0,ey.jsx)(lG,{className:"size-4"})})]}):null]},o.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i.actions,"aria-expanded":e,onClick:()=>{o(!e),e&&p(void 0)},className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function sy({provider:e=!0,...t}){return e?(0,ey.jsx)(lh,{children:(0,ey.jsx)(sm,{...t})}):(0,ey.jsx)(sm,{...t})}function sb(){let[e,t]=ew.useState(void 0);return ew.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),n=()=>{t(window.innerWidth<768)};return e.addEventListener("change",n),t(window.innerWidth<768),()=>e.removeEventListener("change",n)},[]),!!e}async function sw(){let e=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});return e.ok?e.json():{machines:[]}}async function sj(e,t,n){let{timeoutMs:r=8e3,signal:a,...i}=n??{},o=new AbortController,l=r>0?setTimeout(()=>o.abort(),r):void 0;a&&a.addEventListener("abort",()=>o.abort(),{once:!0});try{let n=await fetch(eD(`/v1/remote/${e}${t}`),{...i,cache:"no-store",signal:o.signal});if(!n.ok)throw Error(`Remote API error: ${n.status}`);return n.json()}finally{l&&clearTimeout(l)}}class sk extends Error{openedBy;constructor(e){super("conversation is open on another machine"),this.name="ConversationOpenElsewhereError",this.openedBy=e}}let sS={subagents:[],mainModels:[],folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:["local"],permissionMode:"acceptEdits"},sN="local";function sC(e){return!e||e===sN}function sM(e,t){return sC(e)?`/api/local/agent/conversations${t}`:`/v1/remote/${e}/agent/conversations${t}`}async function sE(e){return(await s1(e,"")).conversations.map(t=>s0(t,e))}async function sO(){let e={[sN]:"本机"},t=[],n=[];try{n=await sE(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await sE(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{conversations:o,machineNames:e,unreachable:t}}async function sP(e){let t=await s1(e,"/recent",void 0,{allowNotFound:!0});return t?sQ(t,e):void 0}async function sA(e,t){return sQ(await s1(t,`/${encodeURIComponent(e)}?eventsLimit=200`),t)}async function sI(e,t,n){try{let r=new URLSearchParams;void 0!==t.end&&r.set("end",String(t.end)),void 0!==t.limit&&r.set("limit",String(t.limit)),t.fromEventId&&r.set("fromEventId",t.fromEventId);let a=r.toString()?`?${r}`:"",i=await fetch(eD(sM(n,`/${encodeURIComponent(e)}/events${a}`)),{cache:"no-store"});if(!i.ok)return{events:[],start:0,total:0};let o=await i.json().catch(()=>({}));return{events:o.events??[],start:o.start??0,total:o.total??0}}catch{return{events:[],start:0,total:0}}}async function sz(e,t){try{let n=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/subagent-tree`)),{cache:"no-store"});if(!n.ok)return[];return(await n.json().catch(()=>({}))).subagents??[]}catch{return[]}}async function sT(e,t){try{let n=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/background-tasks`)),{cache:"no-store"});if(!n.ok)return[];return(await n.json().catch(()=>({}))).tasks??[]}catch{return[]}}async function sD(){if(void 0!==t)return t;try{let{machines:e}=await sw();t=(e??[]).find(e=>e.isLocal)?.name??""}catch{t=""}return t}async function s_(e,t,n){let r=()=>"u">typeof performance?performance.now():Date.now(),a=r(),i=n?.displayName??await sD(),o=r(),l=new URLSearchParams;n?.force&&l.set("force","1"),l.set("eventsLimit",String(200));let s=`?${l}`,c=await fetch(eD(sM(t,`/${encodeURIComponent(e)}/open${s}`)),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:i})}),d=r(),u=await c.json().catch(()=>({})),f=r();if(409===c.status)throw new sk(u?.openedBy);if(!c.ok){let e=u?.error;throw Error("string"==typeof e?e:"open failed")}let h=sQ(u,t),p=r(),m=Array.isArray(u?.events)?u.events.length:0;return console.debug(`[open] id=${e} machineName=${Math.round(o-a)}ms fetch=${Math.round(d-o)}ms readBody=${Math.round(f-d)}ms map=${Math.round(p-f)}ms events=${m}`),h}async function sR(e,n,r){try{await fetch(eD(sM(n,`/${encodeURIComponent(e)}/open/heartbeat`)),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:r??t??""})})}catch{}}async function sL(e,t){try{await fetch(eD(sM(t,`/${encodeURIComponent(e)}/open/release`)),{method:"POST",cache:"no-store",keepalive:!0})}catch{}}async function s$(e){let t=e.ownerMachineId;return sQ(await s1(t,"",{method:"POST",body:JSON.stringify(e)}),t)}async function sF(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),n)}async function sB(e,t){await s1(t,`/${encodeURIComponent(e)}`,{method:"DELETE"})}async function sV(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/panes`,{method:"PUT",body:JSON.stringify(t)}),n)}async function sH(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/chat-runs`,{method:"POST",body:JSON.stringify(t)}),n)}async function sU(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/chat-runs/retry`,{method:"POST",body:JSON.stringify(t)}),n)}async function sW(e,t,n){let r=await s1(n,`/${encodeURIComponent(e)}/rollback`,{method:"POST",body:JSON.stringify({eventId:t})});return{detail:sQ(r.detail,n),prompt:r.prompt??"",revertedFiles:r.revertedFiles??0,deletedFiles:r.deletedFiles??0,skippedRemote:r.skippedRemote,archivedSubagents:r.archivedSubagents??0}}async function sq(e,t,n){return sQ(await s1(n,`/${encodeURIComponent(e)}/fork`,{method:"POST",body:JSON.stringify({eventId:t??""})}),n)}async function sK(e,t,n){let r=new URLSearchParams(t);return s1(n,`/${encodeURIComponent(e)}/files/history?${r}`)}async function sG(e,t,n){let r=new URLSearchParams(t);return s1(n,`/${encodeURIComponent(e)}/files/version?${r}`)}async function sX(e,t,n,r,a){return s1(a,`/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify({decision:n,feedback:r})})}async function sY(e,t){return s1(t,`/${encodeURIComponent(e)}/chat-runs/stop`,{method:"POST"},{allowNotFound:!0})}async function sZ(e,t,n){return s1(n,`/${encodeURIComponent(e)}/chat-runs/nudge`,{method:"POST",body:JSON.stringify({message:t})})}async function sJ(e,t,n,r){return await s1(r,`/${encodeURIComponent(e)}/compress`,{method:"POST",body:JSON.stringify({mode:t,agentSummary:n})})}function sQ(e,t){return{conversation:s0(e.conversation,t),events:e.events??[],panes:e.panes??{layoutMode:"quad",agentPosition:"left",panes:[]},eventsTotal:e.eventsTotal,eventsStart:e.eventsStart}}function s0(e,t){let n=e.runtimeSeconds??0,r={...sS,...e.settings},a=sC(t)?e.ownerMachineId??"local":t;return{id:e.id,title:e.title||"新 Agent 对话",agent:e.agent||"Local Agent",status:e.status??"idle",running:e.running??"working"===e.status,goal:e.goal||"",progress:e.progress??0,taskProgress:e.taskProgress?.length?e.taskProgress:[e.progress??0,0,0],runtime:function(e){if(e<=0)return"0m";let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${Math.max(1,n)}m`}(n),runtimeSeconds:n,tokens:e.tokens??0,contextTokens:e.contextTokens??0,lastOpened:function(e){let t=Date.parse(e);if(!Number.isFinite(t))return"刚刚";let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return"刚刚";let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let a=Math.floor(r/60);if(a<24)return`${a} 小时前`;let i=Math.floor(a/24);return 1===i?"昨天":i<7?`${i} 天前`:new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)}(e.lastOpenedAt??e.updatedAt??e.createdAt),roadmap:e.roadmap?.length?e.roadmap:[{title:"配置会话环境",state:"done"},{title:"等待首条消息",state:"queued"}],settings:r,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt,lastSeq:e.lastSeq??0,ownerMachineId:a,runUsage:e.runUsage,rounds:e.rounds??[],openedBy:e.openedBy,forkOriginId:e.forkOriginId,forkPointSeq:e.forkPointSeq}}async function s1(e,t,n,r){let a=await fetch(eD(sM(e,t)),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"agent conversation api failed");return i}let s2=(0,ek.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),s5=(0,ek.default)("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]),s4=(0,ek.default)("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),s3=(0,ek.default)("panel-right-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]),s6=(0,ek.default)("rectangle-horizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]),s8=(0,ek.default)("shredder",[["path",{d:"M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1eob4r"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 22v-5",key:"sfixh4"}],["path",{d:"M14 19v-2",key:"pdve8j"}],["path",{d:"M18 20v-3",key:"uox2gk"}],["path",{d:"M2 13h20",key:"5evz65"}],["path",{d:"M6 20v-3",key:"c6pdcb"}]]);function s7(e,t=[]){let n=[],r=()=>{let t=n.map(e=>ew.createContext(e));return function(n){let r=n?.[e]||t;return ew.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){let a=ew.createContext(r),i=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,l=n?.[e]?.[i]||a,s=ew.useMemo(()=>o,Object.values(o));return(0,ey.jsx)(l.Provider,{value:s,children:r})};return o.displayName=t+"Provider",[o,function(n,o){let l=o?.[e]?.[i]||a,s=ew.useContext(l);if(s)return s;if(void 0!==r)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let a=n(e)[`__scope${r}`];return{...t,...a}},{});return ew.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}(r,...t)]}var s9=e.i(22353);function ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}"u">typeof window&&window.document&&window.document.createElement;var ct=globalThis?.document?ew.useLayoutEffect:()=>{},cn=ew[" useId ".trim().toString()]||(()=>void 0),cr=0;function ca(e){let[t,n]=ew.useState(cn());return ct(()=>{e||n(e=>e??String(cr++))},[e]),e||(t?`radix-${t}`:"")}ew[" useEffectEvent ".trim().toString()],ew[" useInsertionEffect ".trim().toString()];var ci=ew[" useInsertionEffect ".trim().toString()]||ct;function co({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[a,i,o]=function({defaultProp:e,onChange:t}){let[n,r]=ew.useState(e),a=ew.useRef(n),i=ew.useRef(t);return ci(()=>{i.current=t},[t]),ew.useEffect(()=>{a.current!==n&&(i.current?.(n),a.current=n)},[n,a]),[n,r,i]}({defaultProp:t,onChange:n}),l=void 0!==e,s=l?e:a;{let t=ew.useRef(void 0!==e);ew.useEffect(()=>{let e=t.current;if(e!==l){let t=l?"controlled":"uncontrolled";console.warn(`${r} is changing from ${e?"controlled":"uncontrolled"} to ${t}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=l},[l,r])}return[s,ew.useCallback(t=>{if(l){let n="function"==typeof t?t(e):t;n!==e&&o.current?.(n)}else i(t)},[l,e,i,o])]}function cl(e){var t;let n,r=(t=e,(n=ew.forwardRef((e,t)=>{let{children:n,...r}=e;if(ew.isValidElement(n)){var a;let e,i,o=(a=n,(i=(e=Object.getOwnPropertyDescriptor(a.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.ref:(i=(e=Object.getOwnPropertyDescriptor(a,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.props.ref:a.props.ref||a.ref),l=function(e,t){let n={...t};for(let r in t){let a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...e)=>{let t=i(...e);return a(...e),t}:a&&(n[r]=a):"style"===r?n[r]={...a,...i}:"className"===r&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==ew.Fragment&&(l.ref=t?(0,s9.composeRefs)(t,o):o),ew.cloneElement(n,l)}return ew.Children.count(n)>1?ew.Children.only(null):null})).displayName=`${t}.SlotClone`,n),a=ew.forwardRef((e,t)=>{let{children:n,...a}=e,i=ew.Children.toArray(n),o=i.find(cc);if(o){let e=o.props.children,n=i.map(t=>t!==o?t:ew.Children.count(e)>1?ew.Children.only(null):ew.isValidElement(e)?e.props.children:null);return(0,ey.jsx)(r,{...a,ref:t,children:ew.isValidElement(e)?ew.cloneElement(e,void 0,n):null})}return(0,ey.jsx)(r,{...a,ref:t,children:n})});return a.displayName=`${e}.Slot`,a}Symbol("RADIX:SYNC_STATE");var cs=Symbol("radix.slottable");function cc(e){return ew.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===cs}var cd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=cl(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function cu(e,t){e&&iy.flushSync(()=>e.dispatchEvent(t))}function cf(e){let t=ew.useRef(e);return ew.useEffect(()=>{t.current=e}),ew.useMemo(()=>(...e)=>t.current?.(...e),[])}var ch="dismissableLayer.update",cp=ew.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cm=ew.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...s}=e,c=ew.useContext(cp),[d,u]=ew.useState(null),f=d?.ownerDocument??globalThis?.document,[,h]=ew.useState({}),p=(0,s9.useComposedRefs)(t,e=>u(e)),m=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),x=d?m.indexOf(d):-1,y=c.layersWithOutsidePointerEventsDisabled.size>0,b=x>=v,w=function(e,t=globalThis?.document){let n=cf(e),r=ew.useRef(!1),a=ew.useRef(()=>{});return ew.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){cv("dismissableLayer.pointerDownOutside",n,i,{discrete:!0})},i={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=r,t.addEventListener("click",a.current,{once:!0})):r()}else t.removeEventListener("click",a.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{let t=e.target,n=[...c.branches].some(e=>e.contains(t));b&&!n&&(a?.(e),o?.(e),e.defaultPrevented||l?.())},f),j=function(e,t=globalThis?.document){let n=cf(e),r=ew.useRef(!1);return ew.useEffect(()=>{let e=e=>{e.target&&!r.current&&cv("dismissableLayer.focusOutside",n,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{let t=e.target;![...c.branches].some(e=>e.contains(t))&&(i?.(e),o?.(e),e.defaultPrevented||l?.())},f);return!function(e,t=globalThis?.document){let n=cf(e);ew.useEffect(()=>{let e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{x===c.layers.size-1&&(r?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),ew.useEffect(()=>{if(d)return n&&(0===c.layersWithOutsidePointerEventsDisabled.size&&($=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),cg(),()=>{n&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=$)}},[d,f,n,c]),ew.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),cg())},[d,c]),ew.useEffect(()=>{let e=()=>h({});return document.addEventListener(ch,e),()=>document.removeEventListener(ch,e)},[]),(0,ey.jsx)(cd.div,{...s,ref:p,style:{pointerEvents:y?b?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,j.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,w.onPointerDownCapture)})});function cg(){let e=new CustomEvent(ch);document.dispatchEvent(e)}function cv(e,t,n,{discrete:r}){let a=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?cu(a,i):a.dispatchEvent(i)}cm.displayName="DismissableLayer",ew.forwardRef((e,t)=>{let n=ew.useContext(cp),r=ew.useRef(null),a=(0,s9.useComposedRefs)(t,r);return ew.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,ey.jsx)(cd.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var cx="focusScope.autoFocusOnMount",cy="focusScope.autoFocusOnUnmount",cb={bubbles:!1,cancelable:!0},cw=ew.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,s]=ew.useState(null),c=cf(a),d=cf(i),u=ew.useRef(null),f=(0,s9.useComposedRefs)(t,e=>s(e)),h=ew.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;ew.useEffect(()=>{if(r){let e=function(e){if(h.paused||!l)return;let t=e.target;l.contains(t)?u.current=t:cS(u.current,{select:!0})},t=function(e){if(h.paused||!l)return;let t=e.relatedTarget;null!==t&&(l.contains(t)||cS(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&cS(l)});return l&&n.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[r,l,h.paused]),ew.useEffect(()=>{if(l){cN.add(h);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(cx,cb);l.addEventListener(cx,c),l.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(cS(r,{select:t}),document.activeElement!==n)return}(cj(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&cS(l))}return()=>{l.removeEventListener(cx,c),setTimeout(()=>{let t=new CustomEvent(cy,cb);l.addEventListener(cy,d),l.dispatchEvent(t),t.defaultPrevented||cS(e??document.body,{select:!0}),l.removeEventListener(cy,d),cN.remove(h)},0)}}},[l,c,d,h]);let p=ew.useCallback(e=>{if(!n&&!r||h.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){var i;let t,r=e.currentTarget,[o,l]=[ck(t=cj(i=r),i),ck(t.reverse(),i)];o&&l?e.shiftKey||a!==l?e.shiftKey&&a===o&&(e.preventDefault(),n&&cS(l,{select:!0})):(e.preventDefault(),n&&cS(o,{select:!0})):a===r&&e.preventDefault()}},[n,r,h.paused]);return(0,ey.jsx)(cd.div,{tabIndex:-1,...o,ref:f,onKeyDown:p})});function cj(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ck(e,t){for(let n of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function cS(e,{select:t=!1}={}){if(e&&e.focus){var n;let r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}cw.displayName="FocusScope";var cN=(d=[],{add(e){let t=d[0];e!==t&&t?.pause(),(d=cC(d,e)).unshift(e)},remove(e){d=cC(d,e),d[0]?.resume()}});function cC(e,t){let n=[...e],r=n.indexOf(t);return -1!==r&&n.splice(r,1),n}var cM=ew.forwardRef((e,t)=>{let{container:n,...r}=e,[a,i]=ew.useState(!1);ct(()=>i(!0),[]);let o=n||a&&globalThis?.document?.body;return o?iy.default.createPortal((0,ey.jsx)(cd.div,{...r,ref:t}),o):null});cM.displayName="Portal";var cE=e=>{var t;let n,r,{present:a,children:i}=e,o=function(e){var t,n;let[r,a]=ew.useState(),i=ew.useRef(null),o=ew.useRef(e),l=ew.useRef("none"),[s,c]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},ew.useReducer((e,t)=>n[e][t]??e,t));return ew.useEffect(()=>{let e=cO(i.current);l.current="mounted"===s?e:"none"},[s]),ct(()=>{let t=i.current,n=o.current;if(n!==e){let r=l.current,a=cO(t);e?c("MOUNT"):"none"===a||t?.display==="none"?c("UNMOUNT"):n&&r!==a?c("ANIMATION_OUT"):c("UNMOUNT"),o.current=e}},[e,c]),ct(()=>{if(r){let e,t=r.ownerDocument.defaultView??window,n=n=>{let a=cO(i.current).includes(CSS.escape(n.animationName));if(n.target===r&&a&&(c("ANIMATION_END"),!o.current)){let n=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=n)})}},a=e=>{e.target===r&&(l.current=cO(i.current))};return r.addEventListener("animationstart",a),r.addEventListener("animationcancel",n),r.addEventListener("animationend",n),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",a),r.removeEventListener("animationcancel",n),r.removeEventListener("animationend",n)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ew.useCallback(e=>{i.current=e?getComputedStyle(e):null,a(e)},[])}}(a),l="function"==typeof i?i({present:o.isPresent}):ew.Children.only(i),s=(0,s9.useComposedRefs)(o.ref,(t=l,(r=(n=Object.getOwnPropertyDescriptor(t.props,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.ref:(r=(n=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in n&&n.isReactWarning)?t.props.ref:t.props.ref||t.ref));return"function"==typeof i||o.isPresent?ew.cloneElement(l,{ref:s}):null};function cO(e){return e?.animationName||"none"}cE.displayName="Presence";var cP=0;function cA(){ew.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??cI()),document.body.insertAdjacentElement("beforeend",e[1]??cI()),cP++,()=>{1===cP&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cP--}},[])}function cI(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var cz=function(){return(cz=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function cT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)0>t.indexOf(r[a])&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}var cD=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),c_="width-before-scroll-bar";function cR(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var cL="u">typeof window?ew.useLayoutEffect:ew.useEffect,c$=new WeakMap,cF=(void 0===b&&(b={}),(void 0===w&&(w=function(e){return e}),j=[],k=!1,S={read:function(){if(k)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return j.length?j[j.length-1]:null},useMedium:function(e){var t=w(e,k);return j.push(t),function(){j=j.filter(function(e){return e!==t})}},assignSyncMedium:function(e){for(k=!0;j.length;){var t=j;j=[],t.forEach(e)}j={push:function(t){return e(t)},filter:function(){return j}}},assignMedium:function(e){k=!0;var t=[];if(j.length){var n=j;j=[],n.forEach(e),t=j}var r=function(){var n=t;t=[],n.forEach(e)},a=function(){return Promise.resolve().then(r)};a(),j={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),j}}}}).options=cz({async:!0,ssr:!1},b),S),cB=function(){},cV=ew.forwardRef(function(e,t){var n,r,a,i,o=ew.useRef(null),l=ew.useState({onScrollCapture:cB,onWheelCapture:cB,onTouchMoveCapture:cB}),s=l[0],c=l[1],d=e.forwardProps,u=e.children,f=e.className,h=e.removeScrollBar,p=e.enabled,m=e.shards,g=e.sideCar,v=e.noRelative,x=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,j=e.gapMode,k=cT(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=(n=[o,t],r=function(e){return n.forEach(function(t){return cR(t,e)})},(a=(0,ew.useState)(function(){return{value:null,callback:r,facade:{get current(){return a.value},set current(value){var e=a.value;e!==value&&(a.value=value,a.callback(value,e))}}}})[0]).callback=r,i=a.facade,cL(function(){var e=c$.get(i);if(e){var t=new Set(e),r=new Set(n),a=i.current;t.forEach(function(e){r.has(e)||cR(e,null)}),r.forEach(function(e){t.has(e)||cR(e,a)})}c$.set(i,n)},[n]),i),N=cz(cz({},k),s);return ew.createElement(ew.Fragment,null,p&&ew.createElement(g,{sideCar:cF,removeScrollBar:h,shards:m,noRelative:v,noIsolation:x,inert:y,setCallbacks:c,allowPinchZoom:!!b,lockRef:o,gapMode:j}),d?ew.cloneElement(ew.Children.only(u),cz(cz({},N),{ref:S})):ew.createElement(void 0===w?"div":w,cz({},N,{className:f,ref:S}),u))});cV.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},cV.classNames={fullWidth:c_,zeroRight:cD};var cH=function(e){var t=e.sideCar,n=cT(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error("Sidecar medium not found");return ew.createElement(r,cz({},n))};cH.isSideCarExport=!0;var cU=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=F||("u">typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var r,a;(r=t).styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n)),a=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(a)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cW=function(){var e=cU();return function(t,n){ew.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cq=function(){var e=cW();return function(t){return e(t.styles,t.dynamic),null}},cK={left:0,top:0,right:0,gap:0},cG=function(e){return parseInt(e||"",10)||0},cX=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],a=t["padding"===e?"paddingRight":"marginRight"];return[cG(n),cG(r),cG(a)]},cY=function(e){if(void 0===e&&(e="margin"),"u"<typeof window)return cK;var t=cX(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},cZ=cq(),cJ="data-scroll-locked",cQ=function(e,t,n,r){var a=e.left,i=e.top,o=e.right,l=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(l,"px ").concat(r,";\n }\n body[").concat(cJ,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(a,"px;\n padding-top: ").concat(i,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(cD," {\n right: ").concat(l,"px ").concat(r,";\n }\n \n .").concat(c_," {\n margin-right: ").concat(l,"px ").concat(r,";\n }\n \n .").concat(cD," .").concat(cD," {\n right: 0 ").concat(r,";\n }\n \n .").concat(c_," .").concat(c_," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(cJ,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},c0=function(){var e=parseInt(document.body.getAttribute(cJ)||"0",10);return isFinite(e)?e:0},c1=function(){ew.useEffect(function(){return document.body.setAttribute(cJ,(c0()+1).toString()),function(){var e=c0()-1;e<=0?document.body.removeAttribute(cJ):document.body.setAttribute(cJ,e.toString())}},[])},c2=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=void 0===r?"margin":r;c1();var i=ew.useMemo(function(){return cY(a)},[a]);return ew.createElement(cZ,{styles:cQ(i,!t,a,n?"":"!important")})},c5=!1;if("u">typeof window)try{var c4=Object.defineProperty({},"passive",{get:function(){return c5=!0,!0}});window.addEventListener("test",c4,c4),window.removeEventListener("test",c4,c4)}catch(e){c5=!1}var c3=!!c5&&{passive:!1},c6=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},c8=function(e,t){var n=t.ownerDocument,r=t;do{if("u">typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),c7(e,r)){var a=c9(e,r);if(a[1]>a[2])return!0}r=r.parentNode}while(r&&r!==n.body)return!1},c7=function(e,t){return"v"===e?c6(t,"overflowY"):c6(t,"overflowX")},c9=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},de=function(e,t,n,r,a){var i,o=(i=window.getComputedStyle(t).direction,"h"===e&&"rtl"===i?-1:1),l=o*r,s=n.target,c=t.contains(s),d=!1,u=l>0,f=0,h=0;do{if(!s)break;var p=c9(e,s),m=p[0],g=p[1]-p[2]-o*m;(m||g)&&c7(e,s)&&(f+=g,h+=m);var v=s.parentNode;s=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&s!==document.body||c&&(t.contains(s)||t===s))return u&&(a&&1>Math.abs(f)||!a&&l>f)?d=!0:!u&&(a&&1>Math.abs(h)||!a&&-l>h)&&(d=!0),d},dt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},dn=function(e){return[e.deltaX,e.deltaY]},dr=function(e){return e&&"current"in e?e.current:e},da=0,di=[];let dl=(N=function(e){var t=ew.useRef([]),n=ew.useRef([0,0]),r=ew.useRef(),a=ew.useState(da++)[0],i=ew.useState(cq)[0],o=ew.useRef(e);ew.useEffect(function(){o.current=e},[e]),ew.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var t=(function(e,t,n){if(n||2==arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(dr),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=ew.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var a,i=dt(e),l=n.current,s="deltaX"in e?e.deltaX:l[0]-i[0],c="deltaY"in e?e.deltaY:l[1]-i[1],d=e.target,u=Math.abs(s)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var f=window.getSelection(),h=f&&f.anchorNode;if(h&&(h===d||h.contains(d)))return!1;var p=c8(u,d);if(!p)return!0;if(p?a=u:(a="v"===u?"h":"v",p=c8(u,d)),!p)return!1;if(!r.current&&"changedTouches"in e&&(s||c)&&(r.current=a),!a)return!0;var m=r.current||a;return de(m,t,e,"h"===m?s:c,!0)},[]),s=ew.useCallback(function(e){if(di.length&&di[di.length-1]===i){var n="deltaY"in e?dn(e):dt(e),r=t.current.filter(function(t){var r;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(r=t.delta,r[0]===n[0]&&r[1]===n[1])})[0];if(r&&r.should){e.cancelable&&e.preventDefault();return}if(!r){var a=(o.current.shards||[]).map(dr).filter(Boolean).filter(function(t){return t.contains(e.target)});(a.length>0?l(e,a[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),c=ew.useCallback(function(e,n,r,a){var i={name:e,delta:n,target:r,should:a,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(r)};t.current.push(i),setTimeout(function(){t.current=t.current.filter(function(e){return e!==i})},1)},[]),d=ew.useCallback(function(e){n.current=dt(e),r.current=void 0},[]),u=ew.useCallback(function(t){c(t.type,dn(t),t.target,l(t,e.lockRef.current))},[]),f=ew.useCallback(function(t){c(t.type,dt(t),t.target,l(t,e.lockRef.current))},[]);ew.useEffect(function(){return di.push(i),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",s,c3),document.addEventListener("touchmove",s,c3),document.addEventListener("touchstart",d,c3),function(){di=di.filter(function(e){return e!==i}),document.removeEventListener("wheel",s,c3),document.removeEventListener("touchmove",s,c3),document.removeEventListener("touchstart",d,c3)}},[]);var h=e.removeScrollBar,p=e.inert;return ew.createElement(ew.Fragment,null,p?ew.createElement(i,{styles:"\n .block-interactivity-".concat(a," {pointer-events: none;}\n .allow-interactivity-").concat(a," {pointer-events: all;}\n")}):null,h?ew.createElement(c2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},cF.useMedium(N),cH);var ds=ew.forwardRef(function(e,t){return ew.createElement(cV,cz({},e,{ref:t,sideCar:dl}))});ds.classNames=cV.classNames;var dc=new WeakMap,dd=new WeakMap,du={},df=0,dh=function(e){return e&&(e.host||dh(e.parentNode))},dp=function(e,t,n,r){var a=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=dh(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});du[n]||(du[n]=new WeakMap);var i=du[n],o=[],l=new Set,s=new Set(a),c=function(e){!e||l.has(e)||(l.add(e),c(e.parentNode))};a.forEach(c);var d=function(e){!e||s.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))d(e);else try{var t=e.getAttribute(r),a=null!==t&&"false"!==t,s=(dc.get(e)||0)+1,c=(i.get(e)||0)+1;dc.set(e,s),i.set(e,c),o.push(e),1===s&&a&&dd.set(e,!0),1===c&&e.setAttribute(n,"true"),a||e.setAttribute(r,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),l.clear(),df++,function(){o.forEach(function(e){var t=dc.get(e)-1,a=i.get(e)-1;dc.set(e,t),i.set(e,a),t||(dd.has(e)||e.removeAttribute(r),dd.delete(e)),a||e.removeAttribute(n)}),--df||(dc=new WeakMap,dc=new WeakMap,dd=new WeakMap,du={})}},dm=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),a=t||("u"<typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return a?(r.push.apply(r,Array.from(a.querySelectorAll("[aria-live], script"))),dp(r,a,n,"aria-hidden")):function(){return null}},dg="Dialog",[dv,dx]=s7(dg),[dy,db]=dv(dg),dw=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=ew.useRef(null),s=ew.useRef(null),[c,d]=co({prop:r,defaultProp:a??!1,onChange:i,caller:dg});return(0,ey.jsx)(dy,{scope:t,triggerRef:l,contentRef:s,contentId:ca(),titleId:ca(),descriptionId:ca(),open:c,onOpenChange:d,onOpenToggle:ew.useCallback(()=>d(e=>!e),[d]),modal:o,children:n})};dw.displayName=dg;var dj="DialogTrigger",dk=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dj,n),i=(0,s9.useComposedRefs)(t,a.triggerRef);return(0,ey.jsx)(cd.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":dH(a.open),...r,ref:i,onClick:ce(e.onClick,a.onOpenToggle)})});dk.displayName=dj;var dS="DialogPortal",[dN,dC]=dv(dS,{forceMount:void 0}),dM=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:a}=e,i=db(dS,t);return(0,ey.jsx)(dN,{scope:t,forceMount:n,children:ew.Children.map(r,e=>(0,ey.jsx)(cE,{present:n||i.open,children:(0,ey.jsx)(cM,{asChild:!0,container:a,children:e})}))})};dM.displayName=dS;var dE="DialogOverlay",dO=ew.forwardRef((e,t)=>{let n=dC(dE,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=db(dE,e.__scopeDialog);return i.modal?(0,ey.jsx)(cE,{present:r||i.open,children:(0,ey.jsx)(dA,{...a,ref:t})}):null});dO.displayName=dE;var dP=cl("DialogOverlay.RemoveScroll"),dA=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dE,n);return(0,ey.jsx)(ds,{as:dP,allowPinchZoom:!0,shards:[a.contentRef],children:(0,ey.jsx)(cd.div,{"data-state":dH(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),dI="DialogContent",dz=ew.forwardRef((e,t)=>{let n=dC(dI,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=db(dI,e.__scopeDialog);return(0,ey.jsx)(cE,{present:r||i.open,children:i.modal?(0,ey.jsx)(dT,{...a,ref:t}):(0,ey.jsx)(dD,{...a,ref:t})})});dz.displayName=dI;var dT=ew.forwardRef((e,t)=>{let n=db(dI,e.__scopeDialog),r=ew.useRef(null),a=(0,s9.useComposedRefs)(t,n.contentRef,r);return ew.useEffect(()=>{let e=r.current;if(e)return dm(e)},[]),(0,ey.jsx)(d_,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,e=>e.preventDefault())})}),dD=ew.forwardRef((e,t)=>{let n=db(dI,e.__scopeDialog),r=ew.useRef(!1),a=ew.useRef(!1);return(0,ey.jsx)(d_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(a.current=!0));let i=t.target;n.triggerRef.current?.contains(i)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&a.current&&t.preventDefault()}})}),d_=ew.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=db(dI,n),s=ew.useRef(null),c=(0,s9.useComposedRefs)(t,s);return cA(),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(cw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:(0,ey.jsx)(cm,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":dH(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(dK,{titleId:l.titleId}),(0,ey.jsx)(dG,{contentRef:s,descriptionId:l.descriptionId})]})]})}),dR="DialogTitle",dL=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dR,n);return(0,ey.jsx)(cd.h2,{id:a.titleId,...r,ref:t})});dL.displayName=dR;var d$="DialogDescription",dF=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(d$,n);return(0,ey.jsx)(cd.p,{id:a.descriptionId,...r,ref:t})});dF.displayName=d$;var dB="DialogClose",dV=ew.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,a=db(dB,n);return(0,ey.jsx)(cd.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>a.onOpenChange(!1))})});function dH(e){return e?"open":"closed"}dV.displayName=dB;var dU="DialogTitleWarning",[dW,dq]=(C={contentName:dI,titleName:dR,docsSlug:"dialog"},l=ew.createContext(C),(s=e=>{let{children:t,...n}=e,r=ew.useMemo(()=>n,Object.values(n));return(0,ey.jsx)(l.Provider,{value:r,children:t})}).displayName=dU+"Provider",[s,function(e){let t=ew.useContext(l);if(t)return t;if(void 0!==C)return C;throw Error(`\`${e}\` must be used within \`${dU}\``)}]),dK=({titleId:e})=>{let t=dq(dU),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
3
3
 
4
4
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
5
5
 
@@ -49,4 +49,4 @@ ${e.detail}`:e.title;async function l(){try{await navigator.clipboard.writeText(
49
49
  border-radius: 9999px;
50
50
  background-clip: content-box;
51
51
  }
52
- </style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,ey.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,eI.cn)("size-full border-0 bg-background",n)})}function KX({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,ey.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,ey.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,ey.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,ey.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function KY({file:e,labels:t,onApprove:n}){return(0,ey.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,ey.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,ey.jsx)(KI,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,ey.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[KV(e.size)&&(0,ey.jsx)(F3,{variant:"outline",children:KV(e.size)}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function KZ({labels:e}){return(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function KJ({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=KF(e),o=e.src?e.src:t&&"svg"===KF(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,ey.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,eI.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,ey.jsx)(KG,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,ey.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,eI.cn)("size-full overflow-auto bg-background",a),children:(0,ey.jsx)(KK,{value:t})}):"svg"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,eI.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,ey.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,ey.jsx)(KZ,{labels:n})}function KQ({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:h,onHistory:p}){let m=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,ey.jsx)(HF,{className:"size-4"}):(0,ey.jsx)(uv,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,ey.jsx)(Kz,{className:"size-4"}):(0,ey.jsx)(eS,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:h,disabled:a||!i,icon:(0,ey.jsx)(KR,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:p,icon:(0,ey.jsx)(KT,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===m.length?null:(0,ey.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[m.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function K0({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:h=2097152,showHeader:p=!0,wrapLines:m=!1,renderPreview:g,onHistory:v,labels:x,className:y,editorClassName:b,previewClassName:w,headerClassName:j,...k}){var S;let N,C,M=ew.useMemo(()=>({...KL,...x}),[x]),[E,O]=ew.useState(n??e.content??""),[P,A]=ew.useState(i),[I,z]=ew.useState(s),[T,D]=ew.useState(!1),[_,R]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(S=l??I,(N=KH(e)).includes(S)?S:N[0]),U=KF(e),W=KH(e).length>1,q=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(KF(e)),K=!!u&&q&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=KF(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>h&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=KV(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),R(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&O(n??e.content??""),D(!1),R(!1)},[n,e,t]),ew.useEffect(()=>{if(_)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||R(!1)}},[_]),(0,ey.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",p?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",y),...k,children:[p&&(0,ey.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,ey.jsx)(KD,{className:"size-3.5"}):"video"===U?(0,ey.jsx)(K_,{className:"size-3.5"}):"binary"===U?(0,ey.jsx)(KI,{className:"size-3.5"}):(0,ey.jsx)(xW,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,ey.jsx)(F3,{variant:"outline",children:Z}),q&&"code"===H&&(G?(0,ey.jsxs)(F3,{variant:"secondary",children:[(0,ey.jsx)(lK,{className:"size-3"}),M.review]}):(0,ey.jsxs)(F3,{variant:"outline",children:[(0,ey.jsx)(Kz,{className:"size-3"}),M.edit]}))]})]}),(0,ey.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,ey.jsx)(KY,{file:e,labels:M,onApprove:()=>D(!0)}):"preview"===H?(0,ey.jsx)(KJ,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,ey.jsx)(KX,{file:e,value:B,labels:M}):(0,ey.jsx)(Kq,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&O(e),r?.(e)},wrapLines:m,className:b})}),(0,ey.jsx)(KQ,{open:_,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:W,canSwitchMode:q&&"code"===H,canSave:K,canOpenHistory:!!(v&&e.path),onOpenChange:R,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&z(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&A(e),o?.(e)},onSave:J,onHistory:()=>{R(!1),v?.(e)}})]})}function K1(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function K2(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function K5(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function K4({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:h=!0,detachable:p=!1,externalDropTypes:m=[],createLabel:g="New tab",moreLabel:v="More tab actions",closeLabel:x="Close tab",scrollLeftLabel:y="Scroll tabs left",scrollRightLabel:b="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:S=!0,className:N,tabListClassName:C,contentClassName:M}){let[E,O]=ew.useState(t),P=ew.useRef(null),A=ew.useRef(null),[I,z]=ew.useState(),[T,D]=ew.useState(void 0),_=ew.useRef(void 0),[R,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,W]=ew.useState(!1),[q,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&O(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{_.current=e,D(e)},[]),ea=ew.useCallback(()=>{let e=A.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=A.current;if(!e){W(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;W(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=A.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=A.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=A.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[R]);let es=ew.useCallback(e=>{let t=A.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(K5(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(K5(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===m.length)return!1;let t=Array.from(e.dataTransfer.types);return m.some(e=>t.includes(e))}function eu(e){let t=A.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=_.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=_.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(p&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=K1(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){z(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}z(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,ey.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),eh=T?.dragging&&R?R:Y,ep=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,em=T?.dragging&&ep&&$?(0,iy.createPortal)((0,ey.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[ep.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:ep.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:ep.title}),ep.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,ey.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",N),children:[(0,ey.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,ey.jsx)(pL,{})}),(0,ey.jsxs)("div",{ref:A,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,eI.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&q?"both":U?"left":q?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[eh.map((e,t)=>{let r=e.id===et?.id,i=eh[t+1],o=T?.dragging&&I===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==I;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!h||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();z(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":I===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,eI.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",h&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsx)("button",{type:"button",role:"tab","aria-label":K2(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,ey.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,ey.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(K2(e.title)?`${x}: ${K2(e.title)}`:x),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=K1(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,eI.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,ey.jsx)(fc.XIcon,{className:"size-3.5"})})]}),s&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,ey.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,ey.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,ey.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,ey.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[q&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("right"),children:(0,ey.jsx)(p$,{})}),u.length>0?(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,ey.jsx)(lJ,{})})}),(0,ey.jsx)(bL,{align:"end",className:"w-52",children:u.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(bH,{children:e.shortcut})]})]},t))})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,ey.jsx)(lJ,{})}),f.length>0&&(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v,children:(0,ey.jsx)(lY,{})})}),(0,ey.jsx)(bL,{align:"end",className:"w-52",children:f.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(bH,{children:e.shortcut})]})]},t))})]})]})]}),em,S&&(0,ey.jsx)("div",{"data-slot":"multi-tab-content",className:(0,eI.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,ey.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let K3=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),K6=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),K8=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),K7=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function K9({icon:e,label:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,ey.jsx)("span",{children:t})]})}function Ge({online:e}){return(0,ey.jsx)("span",{"aria-hidden":!0,className:(0,eI.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function Gt({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vs();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sA(e,t),sz(e,t).catch(()=>[]),sT(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",h=(n?.conversation.settings?.hosts??[]).filter(Boolean),p=n?.conversation.runUsage,m=n?.conversation.status==="working",g=(p?.cachedInputTokens??0)+(p?.cacheCreationInputTokens??0),{additions:v,deletions:x}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),y=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a);return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,ey.jsx)(K9,{icon:(0,ey.jsx)(up,{}),label:"环境信息"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,ey.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,ey.jsx)(Ge,{online:d(f)}),(0,ey.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(K7,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===h.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):h.map(e=>(0,ey.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(Ge,{online:d(e)}),(0,ey.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(K6,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,ey.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",v]}),(0,ey.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",x]}),(0,ey.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(um,{}),label:"子智能体"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===y.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):y.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,ey.jsx)(K8,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(fc.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(pR,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(uj,{}),label:"后台任务"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,ey.jsx)(K8,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(hb,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,ey.jsx)(fc.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(pR,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,ey.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(K3,{}),label:m?"本轮消耗":"消耗额度"}),(0,ey.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:p?.inputTokens},{label:"输出",value:p?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,ey.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,ey.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,ey.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:p?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}let Gn="application/vnd.vantaloom.canvas-node",Gr="application/vnd.vantaloom.canvas-tab",Ga="application/vnd.vantaloom.dashboard-widget",Gi="application/vnd.vantaloom.workspace-card",Go=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Gl=Array.from(new Set(Go.flatMap(e=>e.tags))).sort(),Gs=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Gc=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Gd({className:e,...t}){return(0,ey.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,eI.cn)("mx-auto flex w-full justify-center",e),...t})}function Gu({className:e,...t}){return(0,ey.jsx)("ul",{"data-slot":"pagination-content",className:(0,eI.cn)("flex flex-row items-center gap-1",e),...t})}function Gf({...e}){return(0,ey.jsx)("li",{"data-slot":"pagination-item",...e})}function Gh({className:e,isActive:t,size:n="icon",...r}){return(0,ey.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,eI.cn)((0,eA.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Gp({className:e,previousLabel:t="Previous",...n}){return(0,ey.jsxs)(Gh,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,ey.jsx)(pL,{}),(0,ey.jsx)("span",{className:"hidden sm:block",children:t})]})}function Gm({className:e,nextLabel:t="Next",...n}){return(0,ey.jsxs)(Gh,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,ey.jsx)("span",{className:"hidden sm:block",children:t}),(0,ey.jsx)(p$,{})]})}function Gg({className:e,moreLabel:t="More pages",...n}){return(0,ey.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,eI.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,ey.jsx)(lY,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:t})]})}function Gv({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Gx(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,ey.jsx)(Gw,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,ey.jsx)(Gw,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,ey.jsx)(Gj,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Go.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),h=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,ey.jsx)(Gv,{title:"防火墙策略"}),(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"新增策略"]})]}),(0,ey.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,ey.jsxs)("span",{className:"relative",children:[(0,ey.jsx)(vc,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,ey.jsx)(ez,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,ey.jsxs)(gb,{value:n,onValueChange:r,children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:"全部标签"})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"all",children:"全部标签"}),Gl.map(e=>(0,ey.jsx)(vr,{value:e,children:e},e))]})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,ey.jsxs)(pT,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,ey.jsx)(pD,{value:"allow",children:"允许"}),(0,ey.jsx)(pD,{value:"drop",children:"丢弃"}),(0,ey.jsx)(pD,{value:"deny",children:"拒绝"}),(0,ey.jsx)(pD,{value:"clear",children:"全部"})]})]})]}),(0,ey.jsx)(UG,{rows:h,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"min-h-0 flex-1 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}}),(0,ey.jsx)(Gy,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Gy({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,ey.jsx)(Gd,{className:"mt-3 shrink-0",children:(0,ey.jsxs)(Gu,{className:"gap-1 sm:gap-2",children:[(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gp,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,eI.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gg,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,ey.jsxs)(ey.Fragment,{children:[i<t-1?(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gg,{moreLabel:"更多页"})}):null,(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gm,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,eI.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Gb({items:e,variant:t}){return(0,ey.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,ey.jsx)(F3,{variant:t,children:e},e))})}function Gw({zone:e}){return(0,ey.jsx)(F3,{variant:"Trust"===e?"secondary":"outline",children:e})}function Gj({action:e}){return(0,ey.jsx)(F3,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Gk({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,ey.jsx)("table",{"data-slot":"table",className:(0,eI.cn)("w-full caption-bottom text-sm",e),...t})})}function GS({className:e,...t}){return(0,ey.jsx)("thead",{"data-slot":"table-header",className:(0,eI.cn)("[&_tr]:border-b",e),...t})}function GN({className:e,...t}){return(0,ey.jsx)("tbody",{"data-slot":"table-body",className:(0,eI.cn)("[&_tr:last-child]:border-0",e),...t})}function GC({className:e,...t}){return(0,ey.jsx)("tr",{"data-slot":"table-row",className:(0,eI.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function GM({className:e,...t}){return(0,ey.jsx)("th",{"data-slot":"table-head",className:(0,eI.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function GE({className:e,...t}){return(0,ey.jsx)("td",{"data-slot":"table-cell",className:(0,eI.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function GO({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function GP({title:e,headers:t,rows:n}){return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsx)(GO,{title:e}),(0,ey.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,ey.jsxs)(Gk,{children:[(0,ey.jsx)(GS,{children:(0,ey.jsx)(GC,{children:t.map(e=>(0,ey.jsx)(GM,{children:e},e))})}),(0,ey.jsx)(GN,{children:n.map(e=>(0,ey.jsx)(GC,{children:e.map((e,t)=>(0,ey.jsx)(GE,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function GA(){return(0,ey.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,ey.jsx)(GO,{title:"策略申请"}),(0,ey.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,ey.jsx)(ez,{placeholder:"策略名称"}),(0,ey.jsx)(ez,{placeholder:"负责人"}),(0,ey.jsx)(ez,{placeholder:"源 CIDR"}),(0,ey.jsx)(ez,{placeholder:"目标 CIDR"})]}),(0,ey.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"提交申请"]})})]})}function GI(){return(0,ey.jsxs)(pr,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,ey.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsxs)(pf,{className:"h-8 w-max min-w-full",children:[(0,ey.jsx)(ph,{value:"policies",children:"防火墙策略"}),(0,ey.jsx)(ph,{value:"ip-addresses",children:"IP 地址"}),(0,ey.jsx)(ph,{value:"renewals",children:"续期"}),(0,ey.jsx)(ph,{value:"policy-request",children:"策略申请"}),(0,ey.jsx)(ph,{value:"user-settings",children:"用户设置"})]})}),(0,ey.jsx)(pp,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(Gx,{})}),(0,ey.jsx)(pp,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Gs})}),(0,ey.jsx)(pp,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"续期",headers:["策略","续期时间","负责人"],rows:Gc})}),(0,ey.jsx)(pp,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GA,{})}),(0,ey.jsx)(pp,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function Gz(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function GT(e,t){let n=t.machineId||"local";return Gz((await uF(n,e.path)).items)}function GD({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await u$();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:Gz(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,ey.jsx)(Hc,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:GT,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function G_({open:e,onOpenChange:t,onSelectFile:n}){return(0,ey.jsx)(dw,{open:e,onOpenChange:t,children:(0,ey.jsxs)(fu,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fh,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fp,{className:"sr-only",children:"选择本机可访问文件。"}),(0,ey.jsx)(GD,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function GR(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let GL=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function G$({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,ey.jsx)(jb,{className:"size-4"}):(0,ey.jsx)(GL,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,ey.jsx)(lJ,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,ey.jsx)("div",{className:(0,eI.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let GF=[];function GB(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function GV(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?GV(n.children,t):void 0;if(e)return e}}function GH(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function GU(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function GW(e){return e.map(e=>({...e,children:e.children?GW(e.children):void 0}))}let Gq=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),GK=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),GG=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),GX={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function GY({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:h,onItemDuplicate:p,onItemsRemove:m,onItemsReorder:g,onExternalDrop:v,onMouseEnter:x,onMouseLeave:y,...b}){let w={...GX,...i},[j,k]=ew.useState(n),[S,N]=ew.useState(),[C,M]=ew.useState(),[E,O]=ew.useState(n),[P,A]=ew.useState(),[I,z]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,D]=ew.useState(!1),[_,R]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==S,W=Math.min(o,10),q=U?e:e.slice(0,W),K=E?C:void 0,G=44*q.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){O(!1),z({canScrollDown:!1,canScrollUp:!1});return}O(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),z({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{O(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==S||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=q.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(q[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,q,U]),(0,ey.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":_,"data-expansion-direction":r,className:(0,eI.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){x?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0));return}!U||S||ee(e,12)||(M(void 0),A(void 0),Q(!1),D(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onMouseLeave:function(e){y?.(e),S||(M(void 0),A(void 0),D(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,R(!0),D(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(R(!1),A(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",R(!0),U?A(et(e)):A(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,R(!1),A(void 0),v?.({insertIndex:n,items:e,nativeEvent:t})},...b,children:[(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,eI.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,ey.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,ey.jsx)(GG,{className:"size-3.5"})}),(0,ey.jsx)("span",{children:a??w.title}),(0,ey.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,eI.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&_?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,ey.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,ey.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,ey.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,ey.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,eI.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;z({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&S&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!S||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===S),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==S),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),A(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,ey.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,q.map((t,n)=>(0,ey.jsx)(GZ,{item:t,index:n,count:q.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||p?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&S&&S!==t.id){let t=e.currentTarget.getBoundingClientRect();A(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{N(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(N(void 0),A(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);m?.(n,{item:t.item,index:a,items:n})}h?.(t)}},t.id))]})}),Y&&I.canScrollUp?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&I.canScrollDown?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function GZ({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let h=Math.min(t,9),p="down-left"===o?-(4.5*h):[-4,2,-1,4][h]??0,m=r?a?n+20:n-t:n+t;return(0,ey.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,eI.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*h,zIndex:m,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*h}px, 0, 0) rotate(${p}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,ey.jsx)(GG,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,ey.jsx)("p",{className:(0,eI.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,ey.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,ey.jsx)(fm,{className:"size-3.5"})})]})})}function GJ({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:G0(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,ey.jsx)(eO,{className:"size-4"}):"failed"===r.status?(0,ey.jsx)(GK,{className:"size-4"}):"running"===r.status?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,ey.jsx)(lU,{className:"size-4"}):(0,ey.jsx)(Gq,{className:"size-4"}),expandedHeight:132,content:(0,ey.jsx)(GQ,{transfer:e})}});return(0,ey.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,ey.jsx)(GY,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function GQ({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,ey.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate",children:G0(e.target.path)}),(0,ey.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"truncate",children:[G1(e.progress.bytesDone)," /"," ",G1(e.progress.bytesTotal)]}),(0,ey.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,ey.jsx)("div",{className:"truncate text-muted-foreground",children:G0(e.progress.currentPath)}):null]})]})}function G0(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function G1(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let G2=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function G5({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onMoveItems:p}){return(0,ey.jsxs)("section",{className:(0,eI.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,ey.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,ey.jsx)(fc.XIcon,{})}),(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,ey.jsx)(G2,{})})]}),(0,ey.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,ey.jsx)("div",{className:"w-14"})]}),(0,ey.jsx)(wT,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>p({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,ey.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function G4({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=GR(),[l,s]=ew.useState([]),[c,d]=ew.useState(GF),[u,f]=ew.useState(GF[0]?.id),[h,p]=ew.useState([]),[m,g]=ew.useState(!1),[v,x]=ew.useState(!1),[y,b]=ew.useState(),w=ew.useRef(GF.length),j=ew.useRef(!1),k=ew.useRef(new Set),S=ew.useCallback(async(e,t,n)=>{let r=await uF(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:GH(e.path,a.path)?{...e,children:GW(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=GU(e,n),a=GU(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return GW(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return GW(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>GH(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),N=ew.useCallback(async()=>{let e=G8((await uK()).transfers);return p(e),e},[]),C=ew.useCallback(e=>{p(t=>G8([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{uq({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)S(e.machineId,e.rootId,e.path)},[S,c]);function O(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,h=Math.max(0,(a-c)/2),p=Math.max(0,(s-u)/2),m={id:n,title:e?.title??GB(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??h+12*w.current,y:e?.y??p+12*w.current,w:c,h:u};d(e=>[...e,m]),f(n),S(m.machineId,m.rootId,m.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await u$();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:GB(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),S(e.machineId,e.rootId,e.path)}})().catch(()=>{}),N().catch(()=>{}),()=>{e=!1}},[S,N]),ew.useEffect(()=>{if(!h.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await N().catch(()=>h)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,N,h]);let A=sb(),I=c.find(e=>e.id===u);function z(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;O(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:GB(r?.name??a,n)})),S(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{uH({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{uU({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{uW({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=GV(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}}}return A?(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,ey.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,ey.jsx)("button",{type:"button",className:(0,eI.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:I?(0,ey.jsx)(G3,{windowLayout:I,roots:l,...z(I)}):(0,ey.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,ey.jsx)(GJ,{transfers:h}),(0,ey.jsx)(G$,{open:m,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(G6,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]}):(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,ey.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,ey.jsx)(G5,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>O(n.id,()=>e),...z(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;O(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:GB(r?.name??a,t)})),S(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{uH({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{uU({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{uW({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=GV(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}},n.id))}),(0,ey.jsx)(GJ,{transfers:h}),(0,ey.jsx)(G$,{open:m,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(G6,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]})}function G3({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,ey.jsx)(wT,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function G6({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,ey.jsx)(dQ,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"确认移动"}),(0,ey.jsx)(uu,{children:e?`将 ${1===(r=a).length?r[0]?G7(r[0]):"0 项":`${r.length} 项`} 移动到 ${G7(e.target)}`:""})]}),e?(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,ey.jsx)("span",{className:"truncate",children:G7(e)},`${e.machineId}:${e.path}`)),i>0?(0,ey.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,ey.jsx)("span",{className:"truncate",children:G7(e.target)})]})]}):null,(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function G8(e){return e.slice(0,10)}function G7(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function G9({className:e}){return(0,ey.jsx)(G4,{className:(0,eI.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var Xe=ew;function Xt(){return(Xt=Object.assign.bind()).apply(null,arguments)}var Xn=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,jN.clsx)("recharts-dot",a);return kn(t)&&kn(n)&&kn(r)?ew.createElement("circle",Xt({},IM(e),I7(e),{className:i,cx:t,cy:n,r:r})):null},Xr=["points"];function Xa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xa(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xo(){return(Xo=Object.assign.bind()).apply(null,arguments)}function Xl(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,jN.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,Xr);return ew.createElement(Xn,Xo({},l,{className:a}))}function Xs(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=C_.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=zY(n),u=null==n?null:(0,ew.isValidElement)(n)?IO(n.props):"object"!=typeof n||Array.isArray(n)?null:IO(n),f=t.map((e,r)=>{var l,s,c=Xi(Xi(Xi({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Xl,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),h={};return l&&null!=s&&(h.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(RO,{zIndex:c},ew.createElement(II,Xo({className:r},h),f))}function Xc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Xd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xc(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Xu=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Xd(Xd(Xd({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),IE(i)),I7(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(Xn,s),ew.createElement(II,{className:"recharts-active-dot",clipPath:l},t)};function Xf(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=C_.activeDot}=e,l=kZ(_X),s=kZ(_4);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(RO,{zIndex:o},ew.createElement(Xu,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Xh(e,t){var n,r,a=kZ(t=>PS(t,e)),i=kZ(e=>PM(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:Pj.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:PN.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Xp(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=kZ(FH),{needClipX:i,needClipY:o,needClip:l}=Xh(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Xm(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Xg(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Xv=(e,t,n)=>A7(e,"xAxis",Xm(e,t),n),Xx=(e,t,n)=>A8(e,"xAxis",Xm(e,t),n),Xy=(e,t,n)=>A7(e,"yAxis",Xg(e,t),n),Xb=(e,t,n)=>A8(e,"yAxis",Xg(e,t),n),Xw=jH([Cl,Xv,Xy,Xx,Xb],(e,t,n,r,a)=>ky(e,"xAxis")?kE(t,r,!1):kE(n,a,!1)),Xj=jH([PT,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Xk=e=>ky(Cl(e),"xAxis")?"yAxis":"xAxis",XS=jH([Xj,(e,t,n)=>P3(e,Xk(e),"yAxis"===Xk(e)?Xg(e,t):Xm(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=C2(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),XN=jH([Cl,Xv,Xy,Xx,Xb,XS,jG,Xw,Xj,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:h}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:p}=s;if(null!=(d=p&&p.length>0?p:null==u?void 0:u.slice(f,h+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:h,bandSize:p}=e,m=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(kn(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),v="horizontal"===o,x=!1,y=d.map((e,t)=>{if(m)d=i[u+t];else{var r,o,l,d,y,b=kx(e,a);Array.isArray(b)?(d=b,x=!0):d=[g,b]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||m&&!n&&null==kx(e,a);return v?{x:kS({axis:s,ticks:f,bandSize:p,entry:e,index:t}),y:j?null:null!=(y=c.scale.map(w))?y:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:kS({axis:c,ticks:h,bandSize:p,entry:e,index:t}),value:d,payload:e}});return t=m||x?y.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):v?c.scale.map(g):s.scale.map(g),{points:y,baseLine:null!=t?t:0,isRange:x}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function XC(e){var t=IE(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var XM=["id"],XE=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function XO(){return(XO=Object.assign.bind()).apply(null,arguments)}function XP(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function XA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XI(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?XA(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):XA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xz(e,t){return e&&"none"!==e?e:t}var XT=Xe.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kf,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kP(o,t),hide:l,type:c,color:Xz(r,i),unit:s,graphicalItemId:d}};return Xe.createElement(D1,{tooltipEntrySettings:u})});function XD(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=IM(r);return Xe.createElement(Xs,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function X_(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return XI(XI({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return Xe.createElement(RQ,{value:t?a:void 0},n)}function XR(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=XP(i,XM),h=IM(f),p=IO(f);return Xe.createElement(Xe.Fragment,null,(null==t?void 0:t.length)>1&&Xe.createElement(II,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},Xe.createElement(zs,XO({},p,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&Xe.createElement(zs,XO({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&Xe.createElement(zs,XO({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),Xe.createElement(XD,{points:t,props:f,clipPathId:a}))}function XL(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!kp(l)||!kp(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(kn(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),kn(d))?Xe.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function X$(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!kp(l)||!kp(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(kn(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),kn(d))?Xe.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function XF(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?Xe.createElement(XL,{alpha:t,points:r,baseLine:a,strokeWidth:i}):Xe.createElement(X$,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function XB(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:h}=r,p=Td((0,Xe.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),m=Cs(),[g,v]=(0,Xe.useState)(!1),x=(0,Xe.useCallback)(()=>{"function"==typeof h&&h(),v(!1)},[h]),y=(0,Xe.useCallback)(()=>{"function"==typeof f&&f(),v(!0)},[f]);if(null==m)return null;var b=a.current,w=i.current;return Xe.createElement(X_,{showLabels:!g,points:o},r.children,Xe.createElement(Tc,{animationId:p,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:x,onAnimationStart:y,key:p},e=>{if(b){var c,d=b.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(b[r]){var a=b[r];return XI(XI({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return t});if(kn(l))c=ks(w,l,e);else c=null==l||ke(l)?ks(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return XI(XI({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),Xe.createElement(XR,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),Xe.createElement(II,null,s&&Xe.createElement("defs",null,Xe.createElement("clipPath",{id:"animationClipPath-".concat(n)},Xe.createElement(XF,{alpha:e,points:o,baseLine:l,layout:m,strokeWidth:r.strokeWidth}))),Xe.createElement(II,{clipPath:"url(#animationClipPath-".concat(n,")")},Xe.createElement(XR,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),Xe.createElement(R5,{label:r.label}))}function XV(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,Xe.useRef)(null),i=(0,Xe.useRef)();return Xe.createElement(XB,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class XH extends Xe.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:h}=this.props;if(e)return null;var p=(0,jN.clsx)("recharts-area",r),{r:m,strokeWidth:g}=XC(t),v=zY(t),x=2*m+g,y=o?"url(#clipPath-".concat(v?"":"dots-").concat(u,")"):void 0;return Xe.createElement(RO,{zIndex:h},Xe.createElement(II,{className:p},o&&Xe.createElement("defs",null,Xe.createElement(Xp,{clipPathId:u,xAxisId:l,yAxisId:s}),!v&&Xe.createElement("clipPath",{id:"clipPath-dots-".concat(u)},Xe.createElement("rect",{x:i-x/2,y:a-x/2,width:c+x,height:d+x}))),Xe.createElement(XV,{needClip:o,clipPathId:u,props:this.props})),Xe.createElement(Xf,{points:n,mainColor:Xz(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}),this.props.isRange&&Array.isArray(f)&&Xe.createElement(Xf,{points:f,mainColor:Xz(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}))}}var XU={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:C_.area};function XW(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:h,xAxisId:p,yAxisId:m}=e,g=XP(e,XE),v=kZ(Cl),x=kZ(CM),{needClip:y}=Xh(p,m),b=Nq(),{points:w,isRange:j,baseLine:k}=null!=(t=kZ(t=>XN(t,e.id,b)))?t:{},S=kZ(FH);if("horizontal"!==v&&"vertical"!==v||null==S||"AreaChart"!==x&&"ComposedChart"!==x)return null;var{height:N,width:C,x:M,y:E}=S;return w&&w.length?Xe.createElement(XH,XO({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:N,hide:d,layout:v,isAnimationActive:u,isRange:j,legendType:f,needClip:y,points:w,stroke:h,width:C,left:M,top:E,xAxisId:p,yAxisId:m})):null}var Xq=Xe.memo(function(e){var t=zE(e,XU),n=Nq();return Xe.createElement(Ro,{id:t.id,type:"area"},e=>Xe.createElement(Xe.Fragment,null,Xe.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:Xz(r,a),value:kP(n,t),payload:e}]})(t)}),Xe.createElement(XT,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),Xe.createElement(Rm,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:kk(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),Xe.createElement(XW,XO({},t,{id:e}))))},Fl);function XK(){return(XK=Object.assign.bind()).apply(null,arguments)}function XG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}Xq.displayName="Area";var XX=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?XG(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):XG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},$3),XY=(0,ew.forwardRef)(function(e,t){var n,r=zE(e.categoricalChartProps,XX),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(Fa,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(Fi,{chartData:s.data}),ew.createElement(Fs,{layout:r.layout,margin:r.margin}),ew.createElement(Fd,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(Fc,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(FK,XK({},r,{ref:t})))}),XZ=["axis"],XJ=(0,ew.forwardRef)((e,t)=>ew.createElement(XY,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:XZ,tooltipPayloadSearcher:Lh,categoricalChartProps:e,ref:t})),XQ=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function X0(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function X1(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function X2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X5(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X2(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X2(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function X4(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(kn(c)||zc.isSsr)return null!=(r=X0(i,(kn(c)?c:0)+1))?r:[];var h="top"===s||"bottom"===s?"width":"height",p=u&&"width"===h?zg(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},m=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===h?(a=zg(i,{fontSize:t,letterSpacing:n}),XQ({width:a.width+p.width,height:a.height+p.height},f)):zg(i,{fontSize:t,letterSpacing:n})[h]},g=i[0],v=i[1],x=i.length>=2&&null!=g&&null!=v?j9(v.coordinate-g.coordinate):1,y=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,x,h);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:X0(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),h=i.coordinate,p=0===c||X1(e,h,f,u,s);p||(c=0,u=l,d+=1),p&&(u=h+e*(f()/2+a),c+=d)}())return i.v;return[]}(x,y,m,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,h=d;h<i&&(0===(c=function(){var t,i=r[h];if(null==i)return 0;var o=h,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,p=h===d||X1(e,c,s,u,l);if(!p)return f=!1,1;p&&(u=c+e*(s()/2+a))}())||1!==c);h+=s);if(f){for(var p=[],m=d;m<i;m+=s){var g=r[m];null!=g&&p.push(g)}return p}}return[]}(x,y,m,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=X5(X5({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&X1(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=X5(X5({},d),{},{isShow:!0}))}}for(var h=i?l-1:l,p=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=X5(X5({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=X5(X5({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&X1(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=X5(X5({},l),{},{isShow:!0}))},m=0;m<h;m++)if(p(m))continue;return o}(x,y,m,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=X5(X5({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=X5(X5({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&X1(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=X5(X5({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(x,y,m,i,l)).filter(e=>e.isShow)}var X3=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function X6(){return(X6=Object.assign.bind()).apply(null,arguments)}function X8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X7(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X8(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X8(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var X9={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:C_.axis};function Ye(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=X7(X7(X7({},s),IM(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=X7(X7({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=X7(X7({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",X6({},c,{className:(0,jN.clsx)("recharts-cartesian-axis-line",(0,jS.default)(l,"className"))}))}function Yt(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,jN.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,X7(X7({},r),{},{className:i}));else if("function"==typeof n)t=n(X7(X7({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,jN.clsx)(o,R4(n))),t=ew.createElement(zV,X6({},r,{className:o}),a)}return t}function Yn(e){var{ticks:t,axisType:n,axisId:r}=e,a=kK();return(0,ew.useEffect)(()=>null==r||null==n?kf:(a(Fe({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Ft({axisId:r,axisType:n}))}),[a,t,r,n]),null}var Yr=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:h,width:p,height:m,tickSize:g,tickMargin:v,fontSize:x,letterSpacing:y,getTicksConfig:b,events:w,axisType:j,axisId:k}=e,S=X4(X7(X7({},b),{},{ticks:n}),x,y),N=IM(b),C=IE(r),M=zD(N.textAnchor)?N.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),O={};"object"==typeof a&&(O=a);var P=X7(X7({},N),{},{fill:"none"},O),A=S.map(e=>X7({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,h,p,m=l?-1:1,g=e.tickSize||o,v=kn(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,p=(u=(f=n+!l*a)-m*g)-m*s,h=v;break;case"left":u=f=e.coordinate,h=(c=(d=t+!l*r)-m*g)-m*s,p=v;break;case"right":u=f=e.coordinate,h=(c=(d=t+l*r)+m*g)+m*s,p=v;break;default:c=d=e.coordinate,p=(u=(f=n+l*a)+m*g)+m*s,h=v}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:h,y:p}}}(e,f,h,p,m,d,g,u,v))),I=A.map(e=>{var{entry:t,line:n}=e;return ew.createElement(II,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",X6({},P,n,{className:(0,jN.clsx)("recharts-cartesian-axis-tick-line",(0,jS.default)(a,"className"))})))}),z=A.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=X7(X7(X7(X7({verticalAnchor:E},N),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:S.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:N.angle)?n:0}),h=X7(X7({},f),C);return ew.createElement(II,X6({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},I9(w,d,t)),r&&ew.createElement(Yt,{option:r,tickProps:h,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(Yn,{ticks:S,axisId:k,axisType:j}),z.length>0&&ew.createElement(RO,{zIndex:C_.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},z)),I.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},I))}),Ya=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,X3),[u,f]=(0,ew.useState)(""),[h,p]=(0,ew.useState)(""),m=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:m.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");m.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==h)&&(f(a),p(i))}}},[u,h]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(RO,{zIndex:e.zIndex},ew.createElement(II,{className:(0,jN.clsx)("recharts-cartesian-axis",i)},ew.createElement(Ye,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:IM(e)}),ew.createElement(Yr,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(R$,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement(Rq,{label:e.label,labelRef:e.labelRef}),e.children)))}),Yi=ew.forwardRef((e,t)=>{var n=zE(e,X9);return ew.createElement(Ya,X6({},n,{ref:t}))});Yi.displayName="CartesianAxis";var Yo=["x1","y1","x2","y2","key"],Yl=["offset"],Ys=["xAxisId","yAxisId"],Yc=["xAxisId","yAxisId"];function Yd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yd(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yf(){return(Yf=Object.assign.bind()).apply(null,arguments)}function Yh(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Yp=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Ym(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=IM(Yh(n,Yo)))?a:{},{offset:u}=d,f=Yh(d,Yl);r=ew.createElement("line",Yf({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Yg(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Yh(e,Ys),s=a.map((e,a)=>{var i=Yu(Yu({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Ym,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Yv(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Yh(e,Yc),s=a.map((e,a)=>{var i=Yu(Yu({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Ym,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Yx(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Yy(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Yb=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return kb(X4(Yu(Yu(Yu({},X9),n),{},{ticks:kw(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Yw=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return kb(X4(Yu(Yu(Yu({},X9),n),{},{ticks:kw(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Yj={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:C_.grid};function Yk(e){var t=kZ(kA),n=kZ(kI),r=Co(),a=Yu(Yu({},zE(e,Yj)),{},{x:kn(e.x)?e.x:r.left,y:kn(e.y)?e.y:r.top,width:kn(e.width)?e.width:r.width,height:kn(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:h}=a,p=Nq(),m=kZ(e=>A3(e,"xAxis",i,p)),g=kZ(e=>A3(e,"yAxis",o,p));if(!km(c)||!km(d)||!kn(l)||!kn(s))return null;var v=a.verticalCoordinatesGenerator||Yb,x=a.horizontalCoordinatesGenerator||Yw,{horizontalPoints:y,verticalPoints:b}=a;if((!y||!y.length)&&"function"==typeof x){var w=f&&f.length,j=x({yAxis:g?Yu(Yu({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);NY(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(y=j)}if((!b||!b.length)&&"function"==typeof v){var k=h&&h.length,S=v({xAxis:m?Yu(Yu({},m),{},{ticks:k?h:m.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);NY(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(b=S)}return ew.createElement(RO,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Yp,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Yx,Yf({},a,{horizontalPoints:y})),ew.createElement(Yy,Yf({},a,{verticalPoints:b})),ew.createElement(Yg,Yf({},a,{offset:r,horizontalPoints:y,xAxis:m,yAxis:g})),ew.createElement(Yv,Yf({},a,{offset:r,verticalPoints:b,xAxis:m,yAxis:g}))))}Yk.displayName="CartesianGrid";var YS=["domain","range"],YN=["domain","range"];function YC(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YM(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function YE(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=YC(e,YS),{domain:i,range:o}=t,l=YC(t,YN);return!!YM(n,i)&&!!YM(r,o)&&Fl(a,l)}var YO=["type"],YP=["dangerouslySetInnerHTML","ticks","scale"],YA=["id","scale"];function YI(){return(YI=Object.assign.bind()).apply(null,arguments)}function Yz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yz(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YD(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Y_(e){var t=kK(),n=(0,ew.useRef)(null),r=Cs(),{type:a}=e,i=YD(e,YO),o=CF(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return YT(YT({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(L8(l)):n.current!==l&&t(L7({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(L9(n.current)),n.current=null)},[t]),null}var YR=e=>{var{xAxisId:t,className:n}=e,r=kZ(kH),a=Nq(),i="xAxis",o=kZ(e=>A6(e,i,t,a)),l=kZ(e=>AY(e,t)),s=kZ(e=>AQ(e,t)),c=kZ(e=>Pk(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,h=YD(e,YP),{id:p,scale:m}=c,g=YD(c,YA);return ew.createElement(Yi,YI({},h,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,jN.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},YL={allowDataOverflow:Pj.allowDataOverflow,allowDecimals:Pj.allowDecimals,allowDuplicatedCategory:Pj.allowDuplicatedCategory,angle:Pj.angle,axisLine:X9.axisLine,height:Pj.height,hide:!1,includeHidden:Pj.includeHidden,interval:Pj.interval,label:!1,minTickGap:Pj.minTickGap,mirror:Pj.mirror,orientation:Pj.orientation,padding:Pj.padding,reversed:Pj.reversed,scale:Pj.scale,tick:Pj.tick,tickCount:Pj.tickCount,tickLine:X9.tickLine,tickSize:X9.tickSize,type:Pj.type,niceTicks:Pj.niceTicks,xAxisId:0},Y$=ew.memo(e=>{var t=zE(e,YL);return ew.createElement(ew.Fragment,null,ew.createElement(Y_,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(YR,t))},YE);Y$.displayName="XAxis";var YF=["type"],YB=["dangerouslySetInnerHTML","ticks","scale"],YV=["id","scale"];function YH(){return(YH=Object.assign.bind()).apply(null,arguments)}function YU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YU(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yq(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YK(e){var t=kK(),n=(0,ew.useRef)(null),r=Cs(),{type:a}=e,i=Yq(e,YF),o=CF(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return YW(YW({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($e(l)):n.current!==l&&t($t({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($n(n.current)),n.current=null)},[t]),null}function YG(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=kZ(kH),s=Nq(),c=kK(),d="yAxis",u=kZ(e=>A1(e,t)),f=kZ(e=>A0(e,t)),h=kZ(e=>A6(e,d,t,s)),p=kZ(e=>PC(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||RV(a)||(0,ew.isValidElement)(a))&&null!=p){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c($o({id:t,width:n}))}}},[h,u,c,a,t,r,p]),null==u||null==f||null==p)return null;var{dangerouslySetInnerHTML:m,ticks:g,scale:v}=e,x=Yq(e,YB),{id:y,scale:b}=p,w=Yq(p,YV);return ew.createElement(Yi,YH({},x,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,jN.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:h,axisType:d,axisId:t}))}var YX={allowDataOverflow:PN.allowDataOverflow,allowDecimals:PN.allowDecimals,allowDuplicatedCategory:PN.allowDuplicatedCategory,angle:PN.angle,axisLine:X9.axisLine,hide:!1,includeHidden:PN.includeHidden,interval:PN.interval,label:!1,minTickGap:PN.minTickGap,mirror:PN.mirror,orientation:PN.orientation,padding:PN.padding,reversed:PN.reversed,scale:PN.scale,tick:PN.tick,tickCount:PN.tickCount,tickLine:X9.tickLine,tickSize:X9.tickSize,type:PN.type,niceTicks:PN.niceTicks,width:PN.width,yAxisId:0},YY=ew.memo(e=>{var t=zE(e,YX);return ew.createElement(ew.Fragment,null,ew.createElement(YK,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(YG,t))},YE);function YZ({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,ey.jsx)(pr,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(pf,{className:"h-8",children:e.map(e=>(0,ey.jsx)(ph,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,ey.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,ey.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,eI.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,ey.jsx)(Y5,{data:e.data,color:e.color}),(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,ey.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,ey.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,ey.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,ey.jsx)(YJ,{metric:d}):null]})]})]})}function YJ({metric:e}){return"cpu"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:4})]}):"memory"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y1,{segments:e.composition}),(0,ey.jsx)(Y2,{details:e.details,columns:3})]}):"disk"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(YQ,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:4})]}):"network"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:2})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,ey.jsx)(YQ,{panel:e},e.id))}),(0,ey.jsx)(Y2,{details:e.details,columns:3})]})}function YQ({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,ey.jsxs)("div",{className:(0,eI.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,ey.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,ey.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,ey.jsx)(Y4,{data:e.data,color:e.color,className:(0,eI.cn)("w-full",n)})]})}function Y0(){return(0,ey.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{children:"60 秒"}),(0,ey.jsx)("span",{children:"0"})]})}function Y1({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,ey.jsxs)("div",{className:"mt-5",children:[(0,ey.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,ey.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,ey.jsx)("div",{className:(0,eI.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function Y2({details:e,columns:t}){return e?.length?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function Y5({data:e,color:t}){return(0,ey.jsx)(Y4,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function Y4({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,ey.jsx)(BZ,{config:o,className:(0,eI.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,ey.jsxs)(XJ,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,ey.jsx)(Yk,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,ey.jsx)(Y$,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,ey.jsx)(YY,{hide:!0,domain:[0,100]}),a?null:(0,ey.jsx)(BA,{cursor:!1,content:(0,ey.jsx)(BQ,{hideLabel:!0,indicator:"line"})}),(0,ey.jsx)(Xq,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}YY.displayName="YAxis";let Y3=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Y6=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),Y8={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function Y7({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],h=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Za(a))?t:e(a,n,r)}(a,n),i=Za(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Zo(Math.min(100,e.cpu)),memoryMb:Zo(e.memoryMb),diskMbps:Zo(e.diskMbps),networkMbps:Zo(e.networkMbps)}))}(f.processes)].sort((e,t)=>Zi(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Zr(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Zi(e,t,o,s)))t.push(Zr(e,1))}return t},[f,d,s,o]),p=ew.useMemo(()=>h.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[h]);function m(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,ey.jsx)(pr,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(pf,{className:"h-8",children:e.map(e=>(0,ey.jsx)(ph,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,ey.jsxs)("button",{type:"button",onClick:()=>m("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,ey.jsx)(Y9,{active:"name"===o,direction:s})]}),(0,ey.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,ey.jsxs)("button",{type:"button",onClick:()=>m(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,ey.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,ey.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[Y8[e],(0,ey.jsx)(Y9,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,ey.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:h.map(e=>{var t;return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,ey.jsx)(Ze,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,ey.jsx)(Zt,{platform:f.platform,status:e.status}),(0,ey.jsx)(Zn,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,ey.jsx)(Zn,{value:e.memoryMb,max:Zl(p,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Zs(t/1024)} GB`:`${Zs(t)} MB`}),(0,ey.jsx)(Zn,{value:e.diskMbps,max:Math.max(1,Zl(p,"diskMbps")),label:`${Zs(e.diskMbps)} MB/秒`}),(0,ey.jsx)(Zn,{value:e.networkMbps,max:Math.max(1,Zl(p,"networkMbps")),label:`${Zs(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function Y9({active:e,direction:t,className:n}){return e?(0,ey.jsx)("asc"===t?jv:jg,{className:(0,eI.cn)("ml-1 size-3",n)}):null}function Ze({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?g8:p$;return(0,ey.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,ey.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Zt({platform:e,status:t}){return t?.length?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,ey.jsx)(Y6,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,ey.jsx)(lQ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,ey.jsx)(Y3,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,ey.jsx)("div",{className:"px-3"})}function Zn({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,ey.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,ey.jsx)("span",{className:(0,eI.cn)("leading-9",a&&"text-destructive"),children:n})})}function Zr(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Za(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Zi(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Zo(e){return Math.round(10*e)/10}function Zl(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Zs(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Zc({className:e}){let t=Zu("/api/local/machines/processes"),n=Zf("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(Y7,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Zd({className:e}){let t=Zu("/api/local/machines/performance"),n=Zf("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(YZ,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Zu(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch(eD(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function Zf(e){let{machines:t}=vs(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sj(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let Zh=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Zp=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),Zm={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},Zg=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function Zv(e,t,n){return e.getPropertyValue(t).trim()||n}function Zx(e,t=!1){let n=getComputedStyle(e),r=Zv(n,"--foreground","#18181b"),a=Zv(n,"--terminal-background",Zv(n,"--background","#ffffff")),i="transparent"===a?Zv(n,"--background","#ffffff"):a,o=Zv(n,"--muted-foreground","#71717a"),l=Zv(n,"--border","#e4e4e7"),s=Zv(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:Zv(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:Zv(n,"--terminal-red","#bf616a"),green:Zv(n,"--terminal-green","#5e8c61"),yellow:Zv(n,"--terminal-yellow","#b06f3c"),blue:Zv(n,"--terminal-blue","#5e81ac"),magenta:Zv(n,"--terminal-magenta","#b48ead"),cyan:Zv(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:Zv(n,"--terminal-bright-red","#d06f79"),brightGreen:Zv(n,"--terminal-bright-green","#6b9a70"),brightYellow:Zv(n,"--terminal-bright-yellow","#c2824b"),brightBlue:Zv(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:Zv(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:Zv(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function Zy(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function Zb({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:h,...p}){let m=ew.useMemo(()=>({loading:Zm.loading,...u}),[u]),g=ew.useRef(null),v=ew.useRef(null),x=ew.useRef(void 0),y=ew.useRef(s),b=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),S=ew.useRef(l),N=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,O]=ew.useState(!1);return ew.useEffect(()=>{y.current=s,b.current=c,w.current=d,j.current=a,k.current=i,S.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:h},{SearchAddon:p},{WebLinksAddon:m}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=Zv(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:Zx(g.current),...j.current,allowTransparency:!0}),E=new h,P=new p,A=new m;function I(){try{E.fit(),b.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(A),C.open(g.current),v.current=C,x.current=E,O(!0),requestAnimationFrame(I),(n=new ResizeObserver(I)).observe(g.current),a.push(C.onData(e=>{k.current||(S.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),y.current?.(e))})),Zy(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:A,fit:I,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(N.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=Zx(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=v.current,t=g.current;e&&t&&(e.options.theme=Zx(t,N.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();v.current?.dispose(),v.current=null,x.current=void 0,N.current=!1,M.current=!1,O(!1)}},[o,t]),ew.useEffect(()=>{let e=v.current;if(e&&C.current!==r)for(let t of(C.current=r,Zy(n)))e.write(t)},[n,r]),(0,ey.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,eI.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...p,children:[(0,ey.jsx)("div",{ref:g,className:(0,eI.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",h)}),!E&&(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:m.loading})]})}function Zw({status:e="idle"}){return"running"===e?(0,ey.jsx)(Zh,{className:"size-3.5 text-foreground"}):"success"===e?(0,ey.jsx)(eO,{className:"size-3.5 text-foreground"}):"error"===e?(0,ey.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(bh,{className:"size-3.5 text-muted-foreground"})}function Zj({session:e}){return e.aiControlled?(0,ey.jsx)(Zp,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(Zw,{status:e.status})}function Zk({sessions:e,defaultSessions:t=Zg,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:h=!1,localEcho:p=!1,terminalOptions:m,labels:g,className:v,tabListClassName:x,terminalClassName:y,...b}){let w=ew.useMemo(()=>({...Zm,...g,status:{...Zm.status,...g?.status}}),[g]),[j,k]=ew.useState(t),S=e??j,N=S[0],[C,M]=ew.useState(r??N?.id),E=n??(S.some(e=>e.id===C)?C:N?.id),O=S.find(e=>e.id===E)??N;function P(t){void 0===e&&k(t),i?.(t)}function A(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,ey.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...b,children:[u&&(0,ey.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,eI.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",x),children:[(0,ey.jsx)(uj,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsxs)("div",{className:(0,eI.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>A(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(Zj,{session:e}),(0,ey.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,ey.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,ey.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=S.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&A(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,ey.jsx)(fc.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${S.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...S,e]),A(e)},className:"size-7 shrink-0",children:(0,ey.jsx)(lJ,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsx)(ZS,{session:e,selected:t,terminalOptions:m,readOnly:h,localEcho:p,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:y},e.id)})})]})}function ZS({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,ey.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,ey.jsx)(Zb,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function ZN({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,h]=ew.useState(),[p,m]=ew.useState(!1),[g,v]=ew.useState(!1),x=ew.useRef(new Map),y=ew.useRef(new Map),b=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),S=ew.useRef(new Map),N=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),O=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",A=t?.trim()||void 0,I=A??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{O.current=r},[r]);let z=a.find(e=>e.id===d)??a[0],T=z?.shells?.find(e=>e.id===f)??z?.shells?.[0],D=ew.useMemo(()=>o.map(e=>e.id),[o]),_=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),R=D.join("\0"),L=_.join("\0"),$=ew.useCallback((e,t)=>{let n=y.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=y.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,y.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!y.current.get(e))return void b.current.set(e,`${b.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(x.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return eD(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},x.current.set(e,t)},[H]),W=ew.useCallback(async()=>{if(z&&!p){M.current=!1,m(!0);try{let e=await fa({machineId:z.id,scopeId:A,shell:T?.id,cwd:z.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{m(!1)}}},[p,U,z,T,A]);function q(e){let t=S.current.get(e);return t||(t={buffer:"",inFlight:!1},S.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return v(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fn(),fr(A)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),h(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&v(!0)}}(),()=>{e=!1}},[P,A,I]),ew.useEffect(()=>{g&&O.current?.({sessionIds:D,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:_})},[s,_,L,g,d,f,D,R]),ew.useEffect(()=>{let e=new Set(D);for(let e of o)U(e.id);for(let[t,n]of x.current)e.has(t)||(n.close(),x.current.delete(t))},[U,D,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,W())},[W,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of x.current.values())e.close();for(let e of S.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);S.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,ey.jsxs)(gb,{value:z?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);h(t?.shells?.[0]?.id)},children:[(0,ey.jsxs)(g9,{size:"sm",className:"max-w-44",children:[(0,ey.jsx)(xJ,{className:"size-3.5"}),(0,ey.jsx)(gS,{placeholder:"机器"})]}),(0,ey.jsx)(vn,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsxs)(gb,{value:T?.id,onValueChange:h,children:[(0,ey.jsx)(g9,{size:"sm",className:"max-w-44",children:(0,ey.jsx)(gS,{placeholder:"Shell"})}),(0,ey.jsx)(vn,{align:"start",children:z?.shells?.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!z||p,onClick:()=>void W(),className:"ml-auto",children:(0,ey.jsx)(lJ,{className:"size-4"})})]}),(0,ey.jsx)(Zk,{sessions:o.map(ZC),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return x.current.get(e)?.close(),x.current.delete(e),y.current.delete(e),b.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=S.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),S.current.delete(e),N.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),fi(e).catch(()=>{}))},onSessionData:function(e,t){let n=q(e);n.buffer+=t,function e(t){let n=q(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=S.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&S.current.delete(t);return}n.inFlight=!0,fo(t,r).catch(()=>{}).finally(()=>{let n=S.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&S.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;N.current.get(e)!==n&&(N.current.set(e,n),fl(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){y.current.set(e,t);let n=b.current.get(e);n&&(b.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function ZC(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function ZM(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=u_("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HS,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(K0,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,ey.jsx)(HY,{className:`${n} border-0`,defaultUrl:e.defaultUrl??u_("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=u_("diff-tab-viewer");return(0,ey.jsx)(U3,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=u_("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HS,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(UG,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:ZE(e)},source:void 0!==e.defaultValue?{type:ZE(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,ey.jsx)(ZN,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function ZE(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function ZO(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,ey.jsx)(K4,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:uD(n.kind),content:ZM(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[Gr],createLabel:"打开文件",emptyContent:(0,ey.jsx)(HS,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,ey.jsx)(Hj,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,ey.jsx)(GD,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,ey.jsx)(Zc,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,ey.jsx)(Zd,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,ey.jsx)("div",{className:`${n} bg-card`,children:(0,ey.jsx)(GI,{})});case"machine-file-management":return(0,ey.jsx)(G9,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,ey.jsx)(V1,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,ey.jsx)(Gt,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return ZM(t.tab??u_(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function ZP({kind:e,...t}){return ZO(e,t)}let ZA="application/vnd.vantaloom.agent-pane-shredder",ZI="application/vnd.vantaloom.agent-pane-cutter";function Zz(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let ZT=[{id:"quad",label:"四分",slots:4,icon:(0,ey.jsx)(xZ,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,ey.jsx)(HF,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,ey.jsx)(HT,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,ey.jsx)(s2,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,ey.jsx)(s4,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,ey.jsx)(HF,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,ey.jsx)(H$,{})},{id:"single",label:"整窗口",slots:1,icon:(0,ey.jsx)(HL,{})}];function ZD(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function Z_(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function ZR(e,t){return[e[t[0]]??50,e[t[1]]??50]}function ZL({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,ey.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=ZD(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(a,e),onLayoutChanged:e=>n?.("outer",ZR(e,a)),children:[(0,ey.jsx)(hg,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=ZD(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(a,e),onLayoutChanged:e=>n?.("outer",ZR(e,a)),children:[(0,ey.jsx)(hg,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=ZD(t,"outer",[58,42]),a=ZD(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("left",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=ZD(t,"outer",[42,58]),a=ZD(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("right",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=ZD(t,"outer",[58,42]),a=ZD(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("top",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=ZD(t,"outer",[42,58]),a=ZD(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("bottom",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=ZD(t,"outer"),i=ZD(t,"left"),o=ZD(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(l,a),onLayoutChanged:e=>n?.("outer",ZR(e,l)),children:[(0,ey.jsx)(hg,{id:l[0],defaultSize:a[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(s,i),onLayoutChanged:e=>n?.("left",ZR(e,s)),children:[(0,ey.jsx)(hg,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:l[1],defaultSize:a[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(c,o),onLayoutChanged:e=>n?.("right",ZR(e,c)),children:[(0,ey.jsx)(hg,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function Z$({conversationId:e,index:t,content:n,clipboardItems:r,clipboardDraggingId:a,onAdd:i,onPanelDrop:o,onContentChange:l,onClear:s,onCut:c,workspaceFolders:d,onRequestFileTab:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p}){let[m,g]=ew.useState();return(0,ey.jsx)("div",{"data-agent-pane":t,className:(0,eI.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",n?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",n?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===m&&"ring-2 ring-foreground/60 ring-inset","shredder"===m&&"ring-2 ring-destructive/70 ring-inset","cutter"===m&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(ZI)){e.preventDefault(),e.dataTransfer.dropEffect="move",g("cutter");return}if(t.includes(ZA)){e.preventDefault(),e.dataTransfer.dropEffect="move",g("shredder");return}t.includes(jp)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",g("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(ZI)){e.preventDefault(),e.stopPropagation(),g(void 0),c(t);return}if(Array.from(e.dataTransfer.types).includes(ZA)){e.preventDefault(),e.stopPropagation(),g(void 0),s(t);return}let n=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=r.find(e=>e.id===t),a=n?n.payloads?.[jp]:void 0;if(n&&a)return{item:n,content:a.content};let i=e.dataTransfer.getData(jp);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);n&&(e.preventDefault(),e.stopPropagation(),g(void 0),o(t,n.item,n.content))},children:n?(0,ey.jsx)("div",{className:(0,eI.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===n.kind&&"vtl-agent-pane-conversation-content",a&&"pointer-events-none"),children:jh(n)?ZO(n.kind,{tab:n.tab,conversationId:e,terminalScopeId:e?`agent:${e}:pane:${n.id}`:void 0,terminalState:n.terminal,onTerminalStateChange:e=>{Zz(n.terminal,e)||l(t,{...n,terminal:e})},workspaceFolders:d,nodeId:n.id,tabs:n.tabs,activeTabId:n.activeTabId,onRequestFileTab:({insertIndex:e})=>u?.(t,e),onOpenWorkspaceFile:f,onTabsChange:(e,r)=>{l(t,{...n,tabs:r,activeTabId:r.some(e=>e.id===n.activeTabId)?n.activeTabId:r[0]?.id})},onTabChange:(e,r)=>{"multi-tab-system"===n.kind?l(t,{...n,tabs:(n.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):l(t,{...n,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>h?.(t,n,r),onOpenFileHistory:(e,n)=>p?.(t,n),onActiveTabChange:(e,r)=>{l(t,{...n,activeTabId:r})}}):(0,ey.jsx)(V1,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:n.events},n.id)},n.id):(0,ey.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:i,"data-tour":"pane-add",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加"]})})})}function ZF({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xn,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索组件..."}),(0,ey.jsxs)(xa,{children:[(0,ey.jsx)(xi,{children:"没有匹配组件。"}),(0,ey.jsx)(xo,{heading:"可放入窗口",children:jd.map(e=>(0,ey.jsxs)(xl,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,ey.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsx)(xs,{children:"添加"})]},e.id))})]})]})})}function ZB({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return jh(e)?ZO(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{Zz(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,ey.jsx)(V1,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let ZV=[{kind:"status-monitor",label:"状态监控",icon:(0,ey.jsx)(up,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,ey.jsx)(HR,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,ey.jsx)(HD,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,ey.jsx)(uj,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,ey.jsx)(H_,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,ey.jsx)(xK,{})}];function ZH(e,t,n){return Math.min(n,Math.max(t,e))}function ZU({onAddCard:e,align:t="end"}){return(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加窗口",(0,ey.jsx)(g8,{className:"size-3.5 text-muted-foreground"})]})}),(0,ey.jsx)(bL,{align:t,sideOffset:6,className:"min-w-40",children:ZV.map(t=>(0,ey.jsxs)(b$,{onSelect:()=>e(t.kind),children:[t.icon,(0,ey.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function ZW({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p,onRequestFileTab:m}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),v=new Map(g.map(e=>[e.content.id,e])),x=g.map(e=>e.content.id).join("|"),y="left"===r,b=ew.useRef(0);0===b.current&&a.length>0&&(b.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${b.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[S,N]=ew.useState(null),[C,M]=ew.useState(null),[E,O]=ew.useState(null),P=ew.useRef(null),A=ew.useRef(null),I=ew.useRef(null),z=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[x,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!S)return;let e=e=>{A.current?function(e,t){let n=P.current,r=A.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){I.current=null,O(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),h=f===d?"top":f===u?"bottom":f===s?"left":"right";I.current={id:i,edge:h};let p=n.getBoundingClientRect();O(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-p.left,top:o.top-p.top,width:o.width,height:o.height},h))}(e.clientX,e.clientY):z.current&&function(e,t){let n=z.current;if(!n)return;if("width"===n.kind){let t=ZH(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=ZH(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=A.current;if(e){var t,n;let r=I.current;A.current=null,I.current=null,M(null),O(null),N(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(y?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}z.current&&(z.current=null,N(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[S]);let D=a.map((e,t)=>({column:e,realIndex:t}));y&&D.reverse();let _=(0,ey.jsx)("div",{className:(0,eI.cn)("flex shrink-0 px-3 py-2",y?"justify-end":"justify-start"),children:(0,ey.jsx)(ZU,{onAddCard:s,align:y?"end":"start"})});return 0===g.length?null:(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[_,(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,ey.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[D.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&v.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=v.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,ey.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,eI.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,ey.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current=t,I.current=null,M(t),O(null),N("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,ey.jsx)(fm,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,ey.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,ey.jsx)(fc.XIcon,{})})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,ey.jsx)(ZB,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p,onRequestFileTab:m})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),z.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},N("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),z.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},N("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;z.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:y?-1:1},N("resize")})(n.key,e),style:y?{left:-6}:{right:-6},className:(0,eI.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",y?"-translate-x-1/2":"translate-x-1/2"),children:(0,ey.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),S?(0,ey.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===S?"grabbing":z.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let Zq="vtl:workspace-layout-mode",ZK="vtl:workspace-agent-side",ZG="vtl:workspace-layout-changed",ZX={mode:"pane",agentSide:"left"};function ZY(){let e=ZX.mode,t=ZX.agentSide;try{let n=window.localStorage.getItem(Zq);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(ZK);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function ZZ(e){try{e.mode&&window.localStorage.setItem(Zq,e.mode),e.agentSide&&window.localStorage.setItem(ZK,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(ZG))}function ZJ({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);if(ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sA(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]),!o)return null;let c=l?.conversation.status??"working",d="working"===c||!!l?.conversation.running;return(0,ey.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,ey.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,ey.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=VB(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(p$,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,ey.jsx)(o,{className:(0,eI.cn)("size-3",r.color)}),(0,ey.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:d?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===c?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,ey.jsx)(hb,{className:"size-3"}),"已暂停"]}):(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})})]}),(0,ey.jsx)("div",{className:"relative min-h-0 flex-1",children:l?(0,ey.jsx)(VN,{events:l.events,bottomInset:16,contentClassName:"max-w-[42.5rem]",onOpenSubagent:e=>i(e),labels:{recall:"召回",branch:"分支",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"}}):(0,ey.jsxs)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"mr-2 size-4 animate-spin"}),"正在打开子代理对话…"]})})]})}let ZQ=[],Z0="vantaloom:file-system-changed";function Z1(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function Z2(e){var t;let n=(t=e?.layoutMode,ZT.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:Z5(e.outer),left:Z5(e.left),right:Z5(e.right),top:Z5(e.top),bottom:Z5(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,ZT.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:Z3(i.title)??"Subagent",subagentId:Z3(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!ju(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>uT(e?.kind)):void 0,s=ju(e.kind);return{id:a,kind:e.kind,title:Z3(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:Z3(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:Z3(r.activeSessionId),selectedMachineId:Z3(r.selectedMachineId),selectedShellId:Z3(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function Z5(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function Z4(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function Z3(e){return"string"==typeof e&&e.trim()?e:void 0}function Z6(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function Z8(e){return e.reduce((e,t)=>Math.max(e,Z6(t)),0)}function Z7({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let h=sb(),p=ew.useRef(null),m=ew.useRef(void 0),g=Z2(e?.panes),[v,x]=ew.useState(g.layoutMode),[y,b]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(ZX);return ew.useEffect(()=>{t(ZY());let e=()=>t(ZY());return window.addEventListener(ZG,e),window.addEventListener("storage",e),()=>{window.removeEventListener(ZG,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,S]=ew.useState(!1),[N,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,O]=ew.useState(g.layoutSizes),[P,A]=ew.useState(()=>g.panes),[I,z]=ew.useState(()=>g.cardColumns),[T,D]=ew.useState(()=>g.cardHeights),[_,R]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[W,q]=ew.useState(new Set),[K,G]=ew.useState(void 0),[X,Y]=ew.useState(()=>HP(e?.conversation.id)),Z=ew.useCallback(t=>{Y(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(HO(e));window.localStorage.setItem(HO(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[J,Q]=ew.useState(()=>HI(e?.conversation.id)),[ee,et]=ew.useState([]),[en,er]=ew.useState(void 0),[ea,ei]=ew.useState(!1),[eo,el]=ew.useState(!1),[es,ec]=ew.useState(""),[ed,eu]=ew.useState(e?.conversation.status==="working"),[ef,eh]=ew.useState(e?.conversation.status??"idle"),[ep,em]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[eg,ev]=ew.useState([]),[ex,eb]=ew.useState(e?.conversation.tokens??0),[ej,ek]=ew.useState(e?.conversation.runUsage),[eS,eN]=ew.useState(e?.conversation.contextTokens??0),[eC,eM]=ew.useState(!1),eE=ew.useRef(ef),[eO,eP]=ew.useState(),[ez,eT]=ew.useState(),[eR,eL]=ew.useState(),e$=ew.useRef(Z8(g.panes)),eF=ew.useRef(0),eB=ew.useRef(""),eV=ZT.find(e=>e.id===v)?.slots??4,eH=e?.conversation.settings.folders??ZQ,{models:eU}=vI(),eW=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];return t.length?eU.filter(e=>t.includes(e.value)).map(e=>({id:e.value,label:e.label})):[]},[eU,e?.conversation.settings.mainModels]),eq=w1(e?.conversation.settings.engine),eK=ew.useMemo(()=>{if(eq){let t,n=e?.conversation.settings.ccModel;return[{id:n&&""!==n?n:"__cc_model__",label:(t=n&&""!==n?n:wQ,w0.find(e=>e.value===t)?.label??n??""),disabled:!0}]}return eW},[eq,e?.conversation.settings.ccModel,eW]),eG=!eq&&0===eW.length,[eX,eY]=ew.useState(!1),eZ=ed||"working"===ef||eX,eJ=ew.useCallback(async t=>{if(!e||eC)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(eq){if(eZ)return void await sZ(n,"请执行 /compact 压缩上下文。",r);eu(!0),eh("working");try{let e=await sH(n,{message:"/compact",modelRef:"",mode:"agent"},r);eh(e.conversation.status)}catch(e){eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"压缩请求失败")}return}if(eZ)return void await sZ(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eM(!0);try{await sJ(n,t,void 0,r);let e=await sA(n,r);e&&(R(e.events),$(e.eventsStart??0),B(e.eventsTotal??e.events.length),eb(e.conversation.tokens??0),ek(e.conversation.runUsage),eN(e.conversation.contextTokens??0))}catch{}finally{eM(!1)}},[e,eC,eZ,eq]),eQ=ew.useMemo(()=>{if(!e)return;let t=eU.find(e=>e.value===es),n=t?.contextLength||200,r=ej?.inputTokens??0,a=ej?.outputTokens??0,i=r>0?r:eS;return{used:i>0?i+a:ex,total:1e3*n,toolCalls:i>0?i:ex,userMessages:a,other:void 0,onCompressPrecise:()=>eJ("precise"),onCompressExtreme:()=>eJ("extreme"),compressing:eC}},[e,eU,es,ex,ej,eS,eJ,eC]),e0=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of _){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,_]),e1=ew.useCallback(e=>{let t=e.anchorEventId??_.find(t=>t.id.startsWith(`${e.runId}-`))?.id??_.find(t=>t.id===e.runId)?.id;t&&p.current?.scrollToEvent(t)},[_]),e2=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(Hz(e));window.localStorage.setItem(Hz(e),t)}catch{}}(e?.conversation.id,t),!t)return void G(void 0);let r=_.findIndex(e=>e.id===t);if(r>=0)for(let e of e0){let t=e.anchorEventId??e.runId,a=_.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=e0.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),G(n)},[e?.conversation.id,_,e0]),e5=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await u2(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),e4=ew.useCallback(async e=>{if(!e||!jh(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(e5));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await e5(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[e5]),e3=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>e4(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&A(n)},[P,e4]);ew.useEffect(()=>{i?.(void 0!==eO||void 0!==ez||void 0!==eR)},[ez,eR,i,eO]);let e6=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(e6.current!==t){e6.current=t,R(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}R(e=>Z1(e,n))},[e?.conversation.id,e?.events]);let e8=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await sI(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&R(e=>(function(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]})(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);function e7(e){if(!e.length)return;let t=e.map(jm);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function e9(e,t,n){if(!e||!jh(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function te(e,t){return e&&jh(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tt(e){A(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function tn(e){e$.current+=1;let t=jf(e,`${e}-${e$.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;e_().then(n=>{tt(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tt(t)}ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===_.length||m.current===t)return;m.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(Hz(e))??void 0}catch{return}}(t),r=_[_.length-1]?.id;if(!n||n===r||!_.some(e=>e.id===n))return;let a=window.setTimeout(()=>{p.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,_.length]),ew.useEffect(()=>{Y(HP(e?.conversation.id)),Q(HI(e?.conversation.id)),et([]),er(void 0),q(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eu(e?.conversation.status==="working"),eh(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{eb(e?.conversation.tokens??0),ek(e?.conversation.runUsage),eN(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{ej?.inputTokens&&eN(ej.inputTokens)},[ej?.inputTokens]),ew.useEffect(()=>{em(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]),ew.useEffect(()=>{let e=eW[0]?.id??"";ec(t=>eW.some(e=>e.id===t)?t:e)},[eW]),ew.useEffect(()=>{let t=Z2(e?.panes);x(t.layoutMode),b(t.agentPosition),O(t.layoutSizes),A(t.panes),z(t.cardColumns),D(t.cardHeights),e$.current=Z8(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{R(t=>Z1(t,e.events)),eh(e.conversation.status),eb(e.conversation.tokens??0),ek(e.conversation.runUsage)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sA(n,r);if(a)return;i(e),eu("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(600),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource(eD(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=sQ(JSON.parse(e.data));i(t),eu("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{e3()},3e3);return()=>window.clearInterval(t)},[e?.conversation.id,e3]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sR(t,n);let a=window.setInterval(()=>{r||sR(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sL(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=_.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==eB.current&&(eB.current=e,window.dispatchEvent(new CustomEvent(Z0)),e3())},[_,e3]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;sV(t,(n={columns:I,heights:T},r=[],P.forEach((e,t)=>{if(e){if(jh(e))return void r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}});r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}})}}),{layoutMode:v,agentPosition:y,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[y,I,T,e?.conversation.id,v,E,P]);let tr=ew.useCallback(e=>{A(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&jh(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}e$.current+=1;let r=jf("browser-tab-viewer",`browser-tab-viewer-${e$.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),ta=ew.useRef(!1);function ti(e,t){A(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);e$.current+=1;let a={id:`${e}-${e$.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function to(e,t,n){try{let r=await u0(e);if(j)return void ti("file-tab-viewer",r);A(e=>e.map((e,a)=>a===t?e9(e,r,n):e))}catch{hI.error("文件预览打开失败")}}function tl(e){if(j)return void to(e,-1);let t=P.slice(0,eV).findIndex(e=>e?.kind==="multi-tab-system");t<0?hI.warning("请先放入一个多标签页组件"):to(e,t)}function ts(e){let t=e.path?.trim()||e.name.trim();("diff"===e.kind||"diff"===e.meta)&&e.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return ti("diff-tab-viewer",n);let r=P.slice(0,eV).findIndex(e=>e?.kind==="multi-tab-system");r<0?hI.warning("请先放入一个多标签页组件"):A(e=>e.map((e,t)=>t===r?e9(e,n):e))}(e):!t||e.meta?.toLowerCase().startsWith("depth")||tl({machineId:e.machineId??"local",path:t})}async function tc(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hI.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uV({machineId:a,path:r,content:n}),o={...await u1(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};A(t=>t.map((t,n)=>n===e?te(t,o):t)),window.dispatchEvent(new CustomEvent(Z0)),hI.success("文件已保存")}catch(e){throw hI.error("文件保存失败"),e}}async function tf(t){let n=e?.conversation.id,r=eR?.tab.file?.path,a=eR?.tab.file?.machineId??"local";if(eR&&n&&r)try{let i=await sG(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await u1(i,{id:eR.tab.id,title:`${i.name} @ ${Je(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:eR.tab.defaultView,defaultMode:"review"});A(e=>e.map((e,t)=>t===eR.paneIndex?te(e,o):e)),eL(void 0)}catch{hI.error("历史版本打开失败")}}function th(e,t,n){let i=P[e];e$.current=Math.max(e$.current,Z6(n)),A(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=jm(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function tp(e,t){A(n=>n.map((n,r)=>r===e?t:n))}function tm(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function tg(e){var t=P[e];if(t&&jh(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])fi(e).catch(()=>{});A(t=>t.map((t,n)=>n===e?void 0:t))}function tv(e){let t=P[e];t&&e7([t]),A(t=>t.map((t,n)=>n===e?void 0:t))}async function tx(t,n="chat",r=[]){let a=e?.conversation.id,i=eq?"":es||eW[0]?.id||"";if(!a||(t.trim()&&Q(function(e,t){let n=t.trim();if(!n)return HI(e);let r=n.slice(0,1e5),a=HI(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(HA(e),JSON.stringify(i))}catch{}return i}(a,t)),ed||"working"===ef))return;if(!eq&&!i)return void hI.error("请先在代理模型配置里选择模型");q(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!=="");eu(!0),eh("working");try{let r=await sH(a,{message:t,modelRef:i,mode:n,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);eh(r.conversation.status)}catch(e){eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"对话请求失败")}}async function ty(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=eq?"":r||es||eW[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!eq&&!a)return void hI.error("请先在代理模型配置里选择模型");eu(!0),eh("working"),R(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await sU(n,{modelRef:a,mode:i,retryEventId:t.id},e?.conversation.ownerMachineId);eh(r.conversation.status)}catch(e){R(e=>e.map(e=>e.id===t.id?t:e)),eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"对话重试失败")}}}function tb(e){eZ?hI.error("对话正在运行,请先停止后再回退"):er(e)}async function tw(){let t=e?.conversation.id;if(!en||!t)return void er(void 0);ei(!0);try{let n=await sW(t,en.id,e?.conversation.ownerMachineId);R(n.detail.events),$(0),B(n.detail.events.length),eh(n.detail.conversation.status),eu(!1),Z(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),hI.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&hI.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){hI.error(e instanceof Error?e.message:"回退失败")}finally{ei(!1),er(void 0)}}async function tj(t){let n=e?.conversation.id;if(n&&!eo){el(!0);try{let r=await sq(n,t.id,e?.conversation.ownerMachineId);o?.(r),hI.success("已创建分支对话")}catch(e){hI.error(e instanceof Error?e.message:"创建分支失败")}finally{el(!1)}}}async function tk(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sF(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){hI.error(e instanceof Error?e.message:"设置更新失败")}}async function tS(t,n){let r=e?.conversation.id;if(r)try{await sX(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){hI.error(e instanceof Error?e.message:"审批操作失败")}}async function tN(){let t=e?.conversation.id;if(t){eY(!0);try{await sY(t,e?.conversation.ownerMachineId)}catch{}}}function tC(){tx("继续","agent")}async function tM(t){let n=e?.conversation.id;if(!n)return;let r=eg.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){ev(e=>e.filter(e=>e.id!==t));try{await sZ(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t||n&&"local"!==n)return;ta.current=!1;let r=!1,a=async()=>{if(!r&&!ta.current)try{let e=(await e_())[0];if(r||ta.current||!e)return;ta.current=!0,tr(e)}catch{}};a();let i=window.setInterval(a,3e3);return()=>{r=!0,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,tr]),ew.useEffect(()=>{"idle"===ef&&eX&&eY(!1)},[ef,eX]),ew.useEffect(()=>{let e=eE.current;if(eE.current=ef,"working"===e&&"idle"===ef&&eg.length>0){let e=eg[0];if(e){ev(eg.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&tx(t.trim(),"agent")}}},[ef]);let tE=Array.from({length:eV},(r,a)=>(0,ey.jsx)(Z$,{conversationId:e?.conversation.id,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>eP(a),onPanelDrop:th,onContentChange:tp,onClear:tg,onCut:tv,workspaceFolders:eH,onRequestFileTab:(e,t)=>eT({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tl,onSaveFileTab:tc,onOpenFileHistory:(e,t)=>eL({paneIndex:e,tab:t})},a)),tO=P.slice(0,eV).some(e=>e?.kind==="subagent-conversation-panel"),tP=E.shell?.agent??42,tA=E.shell?.panes??58,tI=w.agentSide,tz="control-room"===w.mode||k,tT=(0,ey.jsxs)(pT,{type:"single",value:tz?"hidden":tI,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(S(!1),b(e),ZZ({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(S(!0),ZZ({mode:"control-room"}))},children:[(0,ey.jsx)(pD,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s2,{})}),(0,ey.jsx)(pD,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s6,{})}),(0,ey.jsx)(pD,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s4,{})})]}),tD=(0,ey.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,ey.jsx)(V5,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,ey.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(V4,{rounds:e0,onJumpToRound:e1,activeRunId:K})})}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,ey.jsx)(V1,{ref:p,events:e?_:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e8:void 0,models:e?eK:void 0,modelId:eq?eK[0]?.id:es,permissionModeId:ep,onPermissionModeChange:t=>{em(t),e?.conversation.id&&tk({permissionMode:t})},running:eZ,disabled:!!e&&eG,onModelChange:ec,onSubmit:e?e=>{tx(e.value,"agent",e.attachments??[])}:void 0,onStop:tN,onOpenFile:ts,onOpenSubagent:function(e){e.id&&c?.([tm(e)])},onRetry:ty,onApprovalDecision:tS,onContinue:tC,onRecallUserMessage:tb,onBranchAssistantMessage:tj,onActiveEventChange:e2,composerValue:X,onComposerValueChange:Z,promptHistory:J,attachments:ee,onAttachmentsChange:et,queuedMessages:eg,onQueuedMessagesChange:ev,onNudge:tM,contextUsage:eQ})}),s.length>0&&e?(0,ey.jsx)(ZJ,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,tm(e)])}}):null]}),t_=(0,ey.jsx)(hg,{id:"agent",defaultSize:tP,minSize:28,children:tD},"agent-conversation"),tR=(0,ey.jsx)(hg,{id:"panes",defaultSize:tA,minSize:32,children:(0,ey.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":tO?"true":void 0,children:[(0,ey.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)(pr,{value:v,onValueChange:e=>{let t,n;return t=ZT.find(t=>t.id===e)?.slots??4,void((n=P.slice(t).filter(e=>!!e)).length&&e7(n),A(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),x(e))},children:(0,ey.jsx)(pf,{children:ZT.map(e=>(0,ey.jsx)(ph,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))})}),tT,(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(ZI,"cut")},children:(0,ey.jsx)(l0,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(ZA,"clear")},children:(0,ey.jsx)(s8,{})})]})}),(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:(0,ey.jsx)(ZL,{mode:v,sizes:E,onSizeGroupChange:function(e,t){let n=Z4(t);O(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:tE},`${e?.conversation.id??"empty"}-${v}`)})]})},"agent-panes"),tL=(0,ey.jsx)(ZW,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:tI,columns:I,heights:T,onColumnsChange:z,onHeightsChange:D,onAddCard:tn,onContentChange:tp,onClear:tg,workspaceFolders:eH,onOpenWorkspaceFile:tl,onSaveFileTab:tc,onOpenFileHistory:(e,t)=>eL({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>eT({paneIndex:e,insertIndex:t})}),t$=(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===tI?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,ey.jsx)("button",{type:"button",onClick:M,"aria-label":N?"展开工作区":"收起工作区",title:N?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===tI?N?(0,ey.jsx)(s3,{}):(0,ey.jsx)(s5,{}):N?(0,ey.jsx)(tu,{}):(0,ey.jsx)(td,{})})}),tF=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZF,{open:void 0!==eO,onOpenChange:e=>{e||eP(void 0)},onAdd:function(e){if(void 0===eO)return;e$.current+=1;let t=jf(e,`${e}-${e$.current}`),n=P[eO];n&&e7([n]),A(e=>e.map((e,n)=>n===eO?t:e)),eP(void 0)}}),(0,ey.jsx)(Hk,{open:void 0!==ez,folders:eH,onOpenChange:e=>{e||eT(void 0)},onSelectFile:e=>{ez&&to(e,ez.paneIndex,ez.insertIndex),eT(void 0)}}),(0,ey.jsx)(Z9,{open:void 0!==eR,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:eR?.tab,onOpenChange:e=>{e||eL(void 0)},onSelectVersion:e=>{tf(e)}}),(0,ey.jsx)(dQ,{open:void 0!==en,onOpenChange:e=>{e||ea||er(void 0)},children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"回退对话到此处?"}),(0,ey.jsx)(uu,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{disabled:ea,children:"取消"}),(0,ey.jsx)(uf,{variant:"destructive",disabled:ea,onClick:e=>{e.preventDefault(),tw()},children:ea?"回退中…":"确认回退"})]})]})})]});return e?h?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(js,{view:u,onPaneCountChange:f,conversationPanel:(0,ey.jsx)(V1,{flowContentClassName:"pl-10",events:e?_:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e8:void 0,models:e?eK:void 0,modelId:eq?eK[0]?.id:es,permissionModeId:ep,onPermissionModeChange:t=>{em(t),e?.conversation.id&&tk({permissionMode:t})},running:eZ,disabled:!!e&&eG,onModelChange:ec,onSubmit:e?e=>{tx(e.value,"agent",e.attachments??[])}:void 0,onStop:tN,onOpenFile:ts,onOpenSubagent:function(e){var t;let n=P.slice(0,eV),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void hI.warning("请释放一个窗口再选中浏览");eF.current+=1;let o={id:t=`subagent-${e.id}-${eF.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};A(e=>e.map((e,t)=>t===i?o:e))},onRetry:ty,onApprovalDecision:tS,onContinue:tC,onRecallUserMessage:tb,onBranchAssistantMessage:tj,onActiveEventChange:e2,composerValue:X,onComposerValueChange:Z,promptHistory:J,attachments:ee,onAttachmentsChange:et,queuedMessages:eg,onQueuedMessagesChange:ev,onNudge:tM,contextUsage:eQ}),paneElements:tE,panes:P,activeSlotCount:eV,onOpenPalette:eP,timeline:(0,ey.jsx)(V4,{rounds:e0,onJumpToRound:e1,activeRunId:K})}),tF,(0,ey.jsx)(hL,{position:"top-center"})]}):(0,ey.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[tz?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hm,{direction:"horizontal",children:tR})}),(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,ey.jsx)(hm,{direction:"horizontal",children:t_}),(0,ey.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:tT})]}),(0,ey.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,ey.jsx)(HE,{conversationTitle:e.conversation.title,rootEvents:_,rootOwnerMachineId:e.conversation.ownerMachineId,running:eZ,subagentTree:d,baselineSubagentIds:W,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tD}),(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-2 z-20","left"===tI?"right-3":"left-3"),children:(0,ey.jsx)(ZU,{onAddCard:tn,align:"left"===tI?"end":"start"})})]}):j?(0,ey.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===tI?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tD}),(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tL})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tL}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tD})]})}):N?(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hm,{direction:"horizontal",children:tR})}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tD}),t$]}):(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:{agent:tP,panes:tA},onLayoutChanged:e=>{let t=e.agent??tP,n=e.panes??tA;!function(e){let t=Z4(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===y?{agent:n,panes:r}:{agent:r,panes:n};O(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===tI?[t,n]:[n,t])},children:["left"===tI?t_:tR,(0,ey.jsx)(hv,{withHandle:!0}),"left"===tI?tR:t_]},`${e?.conversation.id??"empty"}-${tI}`),t$]}),tF,(0,ey.jsx)(hL,{position:"top-right"})]}):(0,ey.jsx)(jr,{onCreated:e=>o?.(e),onCancel:l})}function Z9({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),sK(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,ey.jsx)(dw,{open:e,onOpenChange:a,children:(0,ey.jsxs)(fu,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fh,{className:"sr-only",children:"历史版本"}),(0,ey.jsx)(fp,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,ey.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,ey.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,ey.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,ey.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,ey.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsxs)("span",{className:"block truncate text-sm font-medium",children:[Je(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,ey.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function Je(e){return e.replace(/^mut-/,"").slice(0,16)}let Jt=(0,l2.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function Jn({className:e,variant:t,...n}){return(0,ey.jsx)("div",{role:"alert","data-slot":"alert",className:(0,eI.cn)(Jt({variant:t}),e),...n})}function Jr({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-title",className:(0,eI.cn)("mb-1 leading-none font-medium",e),...t})}function Ja({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-description",className:(0,eI.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}function Ji({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState({}),[i,o]=ew.useState(!0),[l,s]=ew.useState(null),[c,d]=ew.useState(""),u=ew.useCallback(async()=>{let t=(await w2(e)).folders??[];n(t),a(Object.fromEntries(t.map(e=>[e.path,e.vantaloom])))},[e]);async function f(t){if(!l){s(t),d("");try{await w5(t,r[t]??"",e),await u()}catch(e){d(e instanceof Error?e.message:"保存失败")}finally{s(null)}}}return(ew.useEffect(()=>{(async()=>{o(!0);try{await u()}catch(e){d(e instanceof Error?e.message:"加载失败")}finally{o(!1)}})()},[u]),i)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取该对话的项目文档"}):(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"这里管理本对话工作区文件夹里的系统提示词。会自动读取各文件夹的 agent.md / claude.md 等文档;你可以选一份作为模板,或自行编写,保存后写入该文件夹的 vantaloom.md,并作为带标记的系统提示词长期注入本对话上下文。 若未设置且未检测到任何文档,则使用全局“兜底系统提示词”。"})]}),c?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"错误"}),(0,ey.jsx)(Ja,{children:c})]}):null,0===t.length?(0,ey.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"本对话还没有工作区文件夹。先在“工作区文件夹”里添加一个本机文件夹,这里就会列出它的文档。"}):t.map(e=>{let t=e.docs??[];return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-md border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(e.path),disabled:l===e.path,children:[(0,ey.jsx)(KR,{className:"size-4"}),l===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>a(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,ey.jsx)(bq,{value:r[e.path]??"",onChange:t=>a(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该项目的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)})]})}let Jo=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"system-prompt",label:"系统提示词"},{id:"hosts",label:"可访问主机"}];function Jl({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onClose:l,onEnterConversation:s}){let[c,d]=ew.useState("models"),u=w1(e.settings.engine);return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:l,className:"shrink-0",children:(0,ey.jsx)(fc.XIcon,{className:"size-5"})}),(0,ey.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>s?.(e),children:[(0,ey.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,ey.jsx)("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-2 vtl-scrollbar-hidden",children:Jo.filter(e=>"system-prompt"!==e.id||!u).map(e=>(0,ey.jsx)("button",{type:"button",onClick:()=>d(e.id),className:(0,eI.cn)("shrink-0 rounded-lg px-3 py-1.5 text-[13px] transition-colors",c===e.id?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:e.label},e.id))}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:(0,ey.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:["models"===c?(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),u?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,ey.jsxs)(gb,{value:""===n?wQ:n,onValueChange:e=>i?.(e===wQ?"":e),children:[(0,ey.jsx)(g9,{id:"conversation-cc-model",className:"w-full",children:(0,ey.jsx)(gS,{placeholder:"选择 Claude Code 模型"})}),(0,ey.jsx)(vn,{children:w0.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,ey.jsx)(vz,{conversation:e,mainModels:t,onMainModelsChange:a})]}):null,"tools"===c?(0,ey.jsx)(wU,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}):null,"commands"===c?(0,ey.jsx)(wW,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}):null,"folders"===c?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)(wq,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:u?e.slice(-1):e})}),u?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,"system-prompt"!==c||u?null:(0,ey.jsx)(Ji,{conversationId:e.id}),"hosts"===c?(0,ey.jsx)(wJ,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:u,hint:u?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0}):null]})})]})}function Js({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState([]),[c,d]=ew.useState(""),[u,f]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function h(e){if(!i)return;let n=e.session??u,r=e.mainModels??l,a=e.ccModel??c,s={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0};try{let e=await sF(i.id,{settings:s},t);o(e.conversation)}catch{}}function p(){o(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sA(e,t);if(!r)return;let a=n.conversation;o(a),s(a.settings.mainModels),d(a.settings.ccModel??""),f({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?(0,ey.jsx)(Jl,{conversation:i,mainModels:l,ccModel:c,sessionSettings:u,onMainModelsChange:e=>{s(e),h({mainModels:e})},onCcModelChange:e=>{d(e),h({ccModel:e})},onSessionSettingsChange:e=>{f(e),h({session:e})},onClose:p,onEnterConversation:e=>{p(),a?.(e.id,t)}}):null}let Jc="local";async function Jd(e){return((await Jx(e,"")).canvases??[]).map(t=>Jv(t,e))}async function Ju(e,t){return Jg(await Jx(t,`/${encodeURIComponent(e)}`),t)}async function Jf(e,t){return Jg(await Jx(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(uR),edges:e.edges.map(uL)})}),t)}async function Jh(e,t,n){return Jg(await Jx(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(uR),edges:t.edges.map(uL),nodeIds:t.nodeIds})}),n)}async function Jp(e,t){return Jg(await Jx(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}async function Jm(){let e={[Jc]:"本机"},t=[],n=[];try{n=await Jd(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await Jd(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{canvases:o,machineNames:e,unreachable:t}}function Jg(e,t){return{canvas:Jv(e.canvas,t),nodes:e.nodes??[],edges:e.edges??[]}}function Jv(e,t){let n=t&&t!==Jc?t:e.ownerMachineId??"local";return{id:e.id,title:e.title||"新画布",ownerMachineId:n,nodeCount:e.nodeCount??0,running:e.running??!1,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt}}async function Jx(e,t,n,r){let a=await fetch(eD(!e||e===Jc?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let Jy=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Jb=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),Jw=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Jj=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),Jk=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),JS=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),JN={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function JC(e,t,n){return Math.min(Math.max(e,t),n)}function JM({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...JN,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),h=ew.useRef(0),p=ew.useRef(void 0),[m,g]=ew.useState(0),v=t??e.find(e=>"current"===e.status)?.id,x=ew.useCallback(()=>{void 0!==p.current&&(cancelAnimationFrame(p.current),p.current=void 0)},[]),y=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;x();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=JC(e,0,a),l=performance.now();h.current=o;let s=e=>{let r=JC((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){p.current=requestAnimationFrame(s);return}n.scrollTop=o,p.current=void 0};p.current=requestAnimationFrame(s)},[x]),b=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===p.current?t.scrollTop:h.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=JC(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);y(c)},[y]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-m,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,h.current=a})},[m,e,v,r]),ew.useEffect(()=>x,[x]),(0,ey.jsx)("div",{"data-slot":"roadmap",className:(0,eI.cn)("min-w-0 text-foreground",a),...s,children:(0,ey.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:b,className:(0,eI.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,ey.jsxs)("div",{ref:u,className:(0,eI.cn)("relative",l&&"min-h-full"),children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===v?"current":e.status??"queued";return(0,ey.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,eI.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,ey.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,eI.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{"data-slot":"roadmap-title",className:(0,eI.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,ey.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,ey.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),m>0?(0,ey.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:m}}):null]})})})}let JE="/themes/jelly/bg1.png",JO="/themes/jelly/bg2.png",JP="/themes/jelly/bg3.png",JA="/themes/jelly/bg4.png";function JI({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function Jz({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let JT={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},JD={search:"搜索控制台...",dashboard:"仪表盘",canvas:"画布",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近画布",canvasNew:"新建画布",canvasAll:"浏览所有画布",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};JT.local,JT.direct,JT.online,JT.p2p,JT.online,JT.direct,JT.sleeping,JT.cpu,JT.memory,JT.activeRuns;function J_(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function JR({children:e}){return(0,ey.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,ey.jsx)(wb,{className:"min-h-0 flex-1",children:e})})}function JL(e){return Math.max(0,...e.map(e=>e.y+e.h))}function J$(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function JF(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function JB(e,t,n,r,a){for(let i=0;i<JL(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!J$(l,e))return l}return{id:t,kind:n,x:0,y:JL(e)+2,w:r,h:a}}function JV(e){return{...e.defaultConfig}}function JH(e){return e.payloads?.[Gi]}function JU({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,ey.jsx)(xn,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索可添加卡片..."}),(0,ey.jsxs)(xa,{className:"max-h-[420px]",children:[(0,ey.jsx)(xi,{children:"没有找到可添加的卡片。"}),(0,ey.jsx)(xo,{heading:a,children:t.map(e=>(0,ey.jsxs)(xl,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,ey.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xs,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function JW({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,ey.jsx)(lJ,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,ey.jsx)(lq,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,ey.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let Jq=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function JK({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:h,children:p}){let[m,g]=ew.useState(!1),v=r??n,x=e.x*(n+12),y=e.y*(v+12),b=e.w*n+(e.w-1)*12,w=e.h*v+(e.h-1)*12;return(0,ey.jsxs)("div",{"data-editable-card":e.id,className:(0,eI.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",m&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:x,top:y,width:b,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=JF({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});J$(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,ey.jsx)("div",{className:(0,eI.cn)("size-full",a&&"pointer-events-none"),children:p}),i&&a&&!o?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,ey.jsx)(JG,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,ey.jsx)(JX,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:h}):null]})}function JG({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,ey.jsx)(l4,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":"调整大小",onClick:r,children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(Jq,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"复制",onClick:n,children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function JX({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,ey.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,ey.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,eI.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),J$(d=JF(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function JY({className:e,...t}){return(0,ey.jsx)(dO,{"data-slot":"sheet-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function JZ({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,ey.jsxs)(dM,{children:[(0,ey.jsx)(JY,{}),(0,ey.jsxs)(dz,{"data-slot":"sheet-content","data-side":n,className:(0,eI.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,ey.jsxs)(dV,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,ey.jsx)(fc.XIcon,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function JJ({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"sheet-header",className:(0,eI.cn)("grid gap-1.5 p-4 text-left",e),...t})}function JQ({className:e,...t}){return(0,ey.jsx)(dL,{"data-slot":"sheet-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function J0({className:e,...t}){return(0,ey.jsx)(dF,{"data-slot":"sheet-description",className:(0,eI.cn)("text-sm text-muted-foreground",e),...t})}function J1({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,ey.jsx)(dw,{open:e,onOpenChange:i,children:(0,ey.jsx)(JZ,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,ey.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,ey.jsx)(J2,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,ey.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,ey.jsxs)(JJ,{className:"border-b",children:[(0,ey.jsx)(JQ,{children:"卡片设置"}),(0,ey.jsxs)(J0,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,ey.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,ey.jsx)(ez,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,ey.jsx)(ez,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,ey.jsx)(ez,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,ey.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,ey.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,ey.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,ey.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["类型:",n.id]}),(0,ey.jsxs)("span",{children:["来源:",r.dataSource]}),(0,ey.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function J2({width:e,height:t,className:n,children:r}){let[a,i]=GR(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,ey.jsx)("div",{ref:a,className:(0,eI.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,ey.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function J5({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[h,p]=ew.useState(!1),[m,g]=ew.useState(!1),[v,x]=ew.useState(()=>n),[y,b]=ew.useState({}),[w,j]=ew.useState(),[k,S]=ew.useState(),[N,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[O,P]=GR(),A=P.width>0?(d=P.width)<480?2:d<768?4:12:12,I=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<J_(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:J_(r),w:n,h:a})}return r}(v,A),z=P.width>0?(P.width-12*(A-1))/A:96,T=A<12?72:z,D=Math.max(a,JL(I)+2),_=D*T+(D-1)*12,R=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=R.get(e.kind);return y[e.id]??(t?JV(t):void 0)}function $(e){x(t=>{let n=JF(e);return J$(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=R.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=JB(v,n,e,t.defaultSize.w,t.defaultSize.h);x(e=>[...e,r]),b(e=>({...e,[n]:JV(t)})),j(n),S(void 0),p(!1)}function B(e,t){let n=v.find(t=>t.id===e),r=n?R.get(n.kind):void 0;n&&r&&b(n=>({...n,[e]:{...n[e]??JV(r),...t}}))}ew.useEffect(()=>{c?.(h||!!N)},[h,c,N]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{m||(j(void 0),S(void 0))},[m]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),S(void 0))}},[k]);let V=A<12,H=N?v.find(e=>e.id===N):void 0,U=H?R.get(H.kind):void 0,W=H?L(H):void 0;if(V){let n=[...I].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(v.map(e=>[e.id,e.w]));return(0,ey.jsxs)(JR,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("mx-auto max-w-7xl p-3",i),children:(0,ey.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=R.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,ey.jsx)(JW,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),p(!0)},onDragModeChange:g}),(0,ey.jsx)(JU,{open:h,definitions:t,groupTitle:l,onOpenChange:p,onAdd:F}),(0,ey.jsx)(J1,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,ey.jsxs)(JR,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",m&&"select-none",i),style:{minHeight:_+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(Gi)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&JH(n);if(!n||!a||!R.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=O.current,o=i?.getBoundingClientRect();!function(e,t){let n=JH(e);if(!n||!R.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=JF({id:r,kind:n.kind,x:t?.x??0,y:t?.y??JL(v),w:n.w,h:n.h}),i=t&&!J$(a,v)?a:JB(v,r,n.kind,n.w,n.h);x(e=>[...e,i]),b(e=>({...e,[r]:{...n.config}})),j(r),S(void 0)}(n,{x:o&&z>0?Math.round((e.clientX-o.left-24)/(z+12)):0,y:o&&z>0?Math.round((e.clientY-o.top-24)/(z+12)):JL(v)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),m||S(void 0))},children:(0,ey.jsx)("div",{className:"relative",style:{height:_},children:I.map(t=>{let n=R.get(t.kind);if(!n)return null;let r=L(t);return r?(0,ey.jsx)(JK,{layout:t,layouts:I,cellSize:z,cellHeight:T,dragMode:m,selected:w===t.id,resizing:k===t.id,onSelect:()=>{m&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=v.find(e=>e.id===t),r=n?R.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[Gi]:JSON.stringify(a)},payloads:{[Gi]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),x(e=>e.filter(e=>e.id!==t)),b(e=>{let n={...e};return delete n[t],n}),j(void 0),S(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=v.find(t=>t.id===e),n=t?R.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=JB(v,r,t.kind,t.w,t.h);x(e=>[...e,a]),b(t=>({...t,[r]:t[e]??JV(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),S(t.id)},onResizeEnd:()=>{j(t.id),S(void 0)},children:n.render(r)},t.id):null})})}),(0,ey.jsx)(JW,{open:u,dragMode:m,label:o,onOpenChange:f,onAdd:()=>{f(!1),p(!0)},onDragModeChange:g}),(0,ey.jsx)(JU,{open:h,definitions:t,groupTitle:l,onOpenChange:p,onAdd:F}),(0,ey.jsx)(J1,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function J4({parts:e}){return(0,ey.jsx)(ey.Fragment,{children:e.map((e,t)=>(0,ey.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function J3({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,ey.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,ey.jsx)(J4,{parts:c})}),(0,ey.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,ey.jsx)(J4,{parts:c})})]})}function J6(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function J8({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)(J3,{value:J6(t),minSize:n,maxSize:r,className:a})]})}function J7(e){return Math.max(0,Math.min(100,Math.round(e)))}function J9({className:e,value:t=0,...n}){let r=J7(t);return(0,ey.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,eI.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,ey.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function Qe({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=J7(t),o=2*Math.PI*39;return(0,ey.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,eI.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,ey.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,ey.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,ey.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let Qt=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Qn({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,ey.jsx)(Qr,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,ey.jsx)(JM,{items:a,scrollCurrentIntoView:!1,className:(0,eI.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,eI.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function Qr({canvas:e,onClick:t,mode:n}){return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(J9,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,eI.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Qa,{icon:(0,ey.jsx)(Vl,{}),value:`${e.snapshots}`}),(0,ey.jsx)(Qa,{icon:(0,ey.jsx)(Qt,{}),value:e.runtime}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function Qa({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}let Qi=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),Qo=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var Ql=ew;function Qs(){return(Qs=Object.assign.bind()).apply(null,arguments)}function Qc(e){return ew.createElement(T6,Qs({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var Qd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(kn(e))return e;var a=kn(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},Qu=["children"],Qf=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function Qh(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,Qu);return ew.createElement(Qf.Provider,{value:n},t)}var Qp=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return ko(r,t,0)};function Qm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qg(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qm(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Qv=jH([PT,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),Qx=jH([Qv],e=>null==e?void 0:e.maxBarSize),Qy=jH([Cl,PT,Xm,Xg,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),Qb=jH([Qy,e=>e.rootProps.barSize,(e,t)=>{var n=Cl(e),r=Xm(e,t),a=Xg(e,t);if(null!=r&&null!=a)return"horizontal"===n?A2(e,"xAxis",r):A2(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(C4),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:Qp(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:Qp(t,n,e.barSize)}))]}),Qw=(e,t,n)=>{var r,a,i=Cl(e),o=Xm(e,t),l=Xg(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=A7(e,"xAxis",o,n),a=A8(e,"xAxis",o,n)):(r=A7(e,"yAxis",l,n),a=A8(e,"yAxis",l,n)),kE(r,a)},Qj=jH([Qb,Ck,e=>e.rootProps.barGap,CS,(e,t,n)=>{var r,a,i,o,l=Qv(e,t);if(null==l)return 0;var s=Xm(e,t),c=Xg(e,t);if(null==s||null==c)return 0;var d=Cl(e),u=Ck(e),{maxBarSize:f}=l;return"horizontal"===d?(i=A7(e,"xAxis",s,n),o=A8(e,"xAxis",s,n)):(i=A7(e,"yAxis",c,n),o=A8(e,"yAxis",c,n)),null!=(r=null!=(a=kE(i,o,!0))?a:null==f?u:f)?r:0},Qw,Qx],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=ko(e,n,0,!0),c=[];if(kp(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var h={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h.offset+h.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return h=r.position,a},c)}else{var p=ko(t,n,0,!0);n-2*p-(l-1)*s<=0&&(s=0);var m=(n-2*p-(l-1)*s)/l;m>1&&(m>>=0);var g=kp(a)?Math.min(m,a):m;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+s)*n+(m-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>Qg(Qg({},e),{},{position:Qg(Qg({},e.position),{},{offset:e.position.offset-a/2})}))),l}),Qk=jH([Qj,Qv],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),QS=jH([(e,t,n)=>{var r=Cl(e),a=Xm(e,t),i=Xg(e,t);if(null!=a&&null!=i)return"horizontal"===r?P3(e,"yAxis",i,n):P3(e,"xAxis",a,n)},Qv],(e,t)=>{var n=C2(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),QN=jH([kB,kH,(e,t,n)=>{var r=Xm(e,t);if(null!=r)return A7(e,"xAxis",r,n)},(e,t,n)=>{var r=Xg(e,t);if(null!=r)return A7(e,"yAxis",r,n)},(e,t,n)=>{var r=Xm(e,t);if(null!=r)return A8(e,"xAxis",r,n)},(e,t,n)=>{var r=Xg(e,t);if(null!=r)return A8(e,"yAxis",r,n)},Qk,Cl,jG,Qw,QS,Qv,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var h,{chartData:p,dataStartIndex:m,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:v}=u;if(null!=(h=null!=v&&v.length>0?v:null==p?void 0:p.slice(m,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:h,cells:p,parentViewBox:m,dataStartIndex:g}=e,v="horizontal"===t?s:l,x=u?v.scale.domain():null,y=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:v}),b=v.scale.map(y);return f.map((e,f)=>{if(u){var v=u[f+g];if(null==v)return null;j=((e,t)=>{if(!t||2!==t.length||!kn(t[0])||!kn(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!kn(e[0])||e[0]<n)&&(a[0]=n),(!kn(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(v,x)}else Array.isArray(j=kx(e,n))||(j=[y,j]);var w=Qd(r,0)(j[1],f);if("horizontal"===t){var j,k,S,N,C,M,E,O=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==O||null==P)return null;k=kN({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),S=null!=(E=null!=P?P:O)?E:void 0,N=i.size;var A=O-P;if(C=ke(A)?0:A,M={x:k,y:h.top,width:N,height:h.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var I=j9(C||w)*(Math.abs(w)-Math.abs(C));S-=I,C+=I}}else{var z=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==z||null==T)return null;if(k=z,S=kN({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),N=T-z,C=i.size,M={x:h.left,y:S,width:h.width,height:C},Math.abs(w)>0&&Math.abs(N)<Math.abs(w)){var D=j9(N||w)*(Math.abs(w)-Math.abs(N));N+=D}}return null!=k&&null!=S&&null!=N&&null!=C&&(a||0!==N&&0!==C)?QV(QV({},e),{},{stackedBarStart:b,x:k,y:S,width:N,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+N/2,y:S+C/2},parentViewBox:m,originalDataIndex:f},p&&p[f]&&p[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:h,offset:e,cells:f,dataStartIndex:m})}}),QC=(e,t)=>t,QM=(e,t,n)=>n,QE=jH([QC,PT,QM],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),QO=jH([QE],e=>e.map(e=>e.id)),QP=jH([e=>e,QC,QM],(e,t,n)=>{var r=QO(e,t,n),a=[];return r.forEach(t=>{var r=QN(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),QA=["index"];function QI(){return(QI=Object.assign.bind()).apply(null,arguments)}var Qz=(0,ew.createContext)(void 0),QT=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),QD=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,QA),r=(e=>{var t=(0,ew.useContext)(Qz);if(null!=t){var{stackId:n}=t;return"url(#".concat(QT(n,e),")")}})(t);return ew.createElement(II,QI({className:"recharts-bar-stack-layer",clipPath:r},n))},Q_=["onMouseEnter","onMouseLeave","onClick"],QR=["value","background","tooltipPosition"],QL=["id"],Q$=["onMouseEnter","onClick","onMouseLeave"];function QF(){return(QF=Object.assign.bind()).apply(null,arguments)}function QB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QV(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QB(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QH(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var QU=Ql.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:kf,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:kP(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return Ql.createElement(D1,{tooltipEntrySettings:d})});function QW(e){var t,n=kZ(_X),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=QH(o,Q_),u=DJ(l,a,o.id),f=DQ(s),h=D0(c,a,o.id);if(!i||null==r)return null;var p=IE(i);return Ql.createElement(RO,{zIndex:(t=C_.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&kp(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=QH(e,QR);if(!o)return null;var c=u(e,t),m=f(e,t),g=h(e,t),v=QV(QV(QV(QV(QV({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),p),I9(d,e,t)),{},{onMouseEnter:c,onMouseLeave:m,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return Ql.createElement(Qc,QF({key:"background-bar-".concat(t)},v))}))}function Qq(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return QV(QV({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return Ql.createElement(RQ,{value:t?a:void 0},n)}function QK(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=kZ(_X),c=kZ(_Z),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,Ql.useState)(!1),[h,p]=(0,Ql.useState)(!1);(0,Ql.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{p(!0)})):p(!1),()=>{cancelAnimationFrame(e)}},[d]);var m=(0,Ql.useCallback)(()=>{d||f(!1)},[d]),g=d&&h,v=d||u;t=d?!0===r?n:r:n;var x=Ql.createElement(Qc,QF({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:m}));return v?Ql.createElement(RO,{zIndex:C_.activeBar},Ql.createElement(QD,{index:i.originalDataIndex},x)):x}function QG(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return Ql.createElement(Qc,QF({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function QX(e){var t,{data:n,props:r}=e,a=null!=(t=IM(r))?t:{},{id:i}=a,o=QH(a,QL),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,h=QH(r,Q$),p=DJ(d,s,i),m=DQ(f),g=D0(u,s,i);return n?Ql.createElement(Ql.Fragment,null,n.map((e,t)=>Ql.createElement(QD,QF({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},I9(h,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:g(e,t)}),c?Ql.createElement(QK,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):Ql.createElement(QG,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function QY(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=Td(t,"recharts-bar-"),[h,p]=(0,Ql.useState)(!1),m=(0,Ql.useCallback)(()=>{"function"==typeof c&&c(),p(!1)},[c]),g=(0,Ql.useCallback)(()=>{"function"==typeof d&&d(),p(!0)},[d]);return Ql.createElement(Qq,{showLabels:!h,rects:r},Ql.createElement(Tc,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:m,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return QV(QV({},t),{},{x:ks(r.x,t.x,e),y:ks(r.y,t.y,e),width:ks(r.width,t.width,e),height:ks(r.height,t.height,e)});if("horizontal"===a){var i=ks(0,t.height,e),o=ks(t.stackedBarStart,t.y,e);return QV(QV({},t),{},{y:o,height:i})}var l=ks(0,t.width,e),s=ks(t.stackedBarStart,t.x,e);return QV(QV({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:Ql.createElement(II,null,Ql.createElement(QX,{props:t,data:i}))}),Ql.createElement(R5,{label:t.label}),t.children)}function QZ(e){var t=(0,Ql.useRef)(null);return Ql.createElement(QY,{previousRectanglesRef:t,props:e})}var QJ=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:kx(e,t)}};class QQ extends Ql.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,jN.clsx)("recharts-bar",r);return Ql.createElement(II,{className:c,id:s},o&&Ql.createElement("defs",null,Ql.createElement(Xp,{clipPathId:s,xAxisId:a,yAxisId:i})),Ql.createElement(II,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},Ql.createElement(QW,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),Ql.createElement(QZ,this.props)))}}var Q0={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:C_.bar};function Q1(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Xh(n,r),h=kZ(Cl),p=Nq(),m=zX(e.children,zH),g=kZ(t=>QN(t,e.id,p,m));if("vertical"!==h&&"horizontal"!==h)return null;var v=null==g?void 0:g[0];return t=null==v||null==v.height||null==v.width?0:"vertical"===h?v.height/2:v.width/2,Ql.createElement(Qh,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:QJ,errorBarOffset:t},Ql.createElement(QQ,QF({},e,{layout:h,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}Ql.memo(function(e){var t,n,r=zE(e,Q0),a=(t=r.stackId,null!=(n=(0,ew.useContext)(Qz))?n.stackId:null!=t?kk(t):void 0),i=Nq();return Ql.createElement(Ro,{id:r.id,type:"bar"},e=>Ql.createElement(Ql.Fragment,null,Ql.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kP(n,t),payload:e}]})(r)}),Ql.createElement(QU,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),Ql.createElement(Rm,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),Ql.createElement(RO,{zIndex:r.zIndex},Ql.createElement(Q1,QF({},r,{id:e})))))},Fl).displayName="Bar";let Q2=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function Q5({className:e,orientation:t="horizontal",...n}){return(0,ey.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,eI.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}function Q4({label:e,description:t,value:n}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,ey.jsx)(J3,{value:J6(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var Q3=ew,Q6=(e,t,n,r)=>A7(e,"xAxis",t,r),Q8=(e,t,n,r)=>A8(e,"xAxis",t,r),Q7=(e,t,n,r)=>A7(e,"yAxis",n,r),Q9=(e,t,n,r)=>A8(e,"yAxis",n,r),eee=jH([Cl,Q6,Q7,Q8,Q9],(e,t,n,r,a)=>ky(e,"xAxis")?kE(t,r,!1):kE(n,a,!1));function eet(e){return"line"===e.type}var een=jH([PT,(e,t,n,r,a)=>a],(e,t)=>e.filter(eet).find(e=>e.id===t)),eer=jH([Cl,Q6,Q7,Q8,Q9,een,eee,jK],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:h}=i;if(null!=(s=null!=h&&h.length>0?h:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=kx(e,o);if("horizontal"===t){var d=kS({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),h=kS({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==h?null:{x:f,y:h,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),eea=["id"],eei=["type","layout","connectNulls","needClip","shape"],eeo=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function eel(){return(eel=Object.assign.bind()).apply(null,arguments)}function ees(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eec(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ees(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ees(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eed(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eeu=Q3.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kf,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kP(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return Q3.createElement(D1,{tooltipEntrySettings:u})}),eef=(e,t)=>"".concat(t,"px ").concat(e,"px");function eeh(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=IM(eed(r,eea));return Q3.createElement(Xs,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function eep(e){var{showLabels:t,children:n,points:r}=e,a=(0,Q3.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return eec(eec({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return Q3.createElement(RQ,{value:t?a:void 0},n)}function eem(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=eec(eec({},IO(eed(i,eei))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return Q3.createElement(Q3.Fragment,null,(null==r?void 0:r.length)>1&&Q3.createElement(T6,eel({shapeType:"curve",option:d},u,{pathRef:n})),Q3.createElement(eeh,{points:r,clipPathId:t,props:i}))}function eeg(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:h,height:p,onAnimationEnd:m,onAnimationStart:g}=n,v=a.current,x=Td(o,"recharts-line-"),y=(0,Q3.useRef)(x),[b,w]=(0,Q3.useState)(!1),j=(0,Q3.useCallback)(()=>{"function"==typeof m&&m(),w(!1)},[m]),k=(0,Q3.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),S=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),N=(0,Q3.useRef)(0);y.current!==x&&(N.current=i.current,y.current=x);var C=N.current;return Q3.createElement(eep,{points:o,showLabels:!b},n.children,Q3.createElement(Tc,{animationId:x,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:x},e=>{var c,d=Math.min(ks(C,S+C,e),S);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return eef(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,S,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):eef(S,d):null==l?void 0:String(l),e>0&&S>0&&(a.current=o,i.current=Math.max(i.current,d)),v){var u=v.length/o.length,m=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(v[r]){var a=v[r];return eec(eec({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return f?eec(eec({},t),{},{x:ks(2*h,t.x,e),y:ks(p/2,t.y,e)}):eec(eec({},t),{},{x:t.x,y:t.y})});return a.current=m,Q3.createElement(eem,{props:n,points:m,clipPathId:t,pathRef:r,strokeDasharray:c})}return Q3.createElement(eem,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),Q3.createElement(R5,{label:n.label}))}function eev(e){var{clipPathId:t,props:n}=e,r=(0,Q3.useRef)(null),a=(0,Q3.useRef)(0),i=(0,Q3.useRef)(null);return Q3.createElement(eeg,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var eex=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:kx(e.payload,t)}};class eey extends Q3.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var h=(0,jN.clsx)("recharts-line",r),{r:p,strokeWidth:m}=XC(t),g=zY(t),v=2*p+m,x=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return Q3.createElement(RO,{zIndex:f},Q3.createElement(II,{className:h},u&&Q3.createElement("defs",null,Q3.createElement(Xp,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&Q3.createElement("clipPath",{id:"clipPath-dots-".concat(d)},Q3.createElement("rect",{x:l-v/2,y:o-v/2,width:s+v,height:c+v}))),Q3.createElement(Qh,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:eex,errorBarOffset:0},Q3.createElement(eev,{props:this.props,clipPathId:d}))),Q3.createElement(Xf,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}}var eeb={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:C_.line,type:"linear"};function eew(e){var t=zE(e,eeb),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:h,yAxisId:p,id:m}=t,g=eed(t,eeo),{needClip:v}=Xh(h,p),x=kZ(FH),y=kZ(Cl),b=Nq(),w=kZ(e=>eer(e,h,p,b,m));if("horizontal"!==y&&"vertical"!==y||null==w||null==x)return null;var{height:j,width:k,x:S,y:N}=x;return Q3.createElement(eey,eel({},g,{id:m,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:h,yAxisId:p,points:w,layout:y,height:j,width:k,left:S,top:N,needClip:v}))}var eej=Q3.memo(function(e){var t=zE(e,eeb),n=Nq();return Q3.createElement(Ro,{id:t.id,type:"line"},e=>Q3.createElement(Q3.Fragment,null,Q3.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kP(n,t),payload:e}]})(t)}),Q3.createElement(eeu,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),Q3.createElement(Rm,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),Q3.createElement(eew,eel({},t,{id:e}))))},Fl);eej.displayName="Line";var eek=["axis"],eeS=(0,ew.forwardRef)((e,t)=>ew.createElement(XY,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eek,tooltipPayloadSearcher:Lh,categoricalChartProps:e,ref:t}));let eeN={online:"bg-foreground",warning:"bg-muted-foreground",offline:"bg-destructive"},eeC={direct:"stroke-foreground",p2p:"stroke-foreground",relay:"stroke-muted-foreground",down:"stroke-destructive"},eeM={topologyNode:function({data:e}){return(0,ey.jsxs)("div",{className:"vtl-surface-card min-w-36 rounded-[var(--surface-card-radius)] border px-3 py-2",children:[(0,ey.jsx)(ox,{type:"target",position:_.Top,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:_.Bottom,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"target",position:_.Left,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:_.Right,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("size-2.5 shrink-0 rounded-full",eeN[e.state])}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:e.label})]}),e.meta?(0,ey.jsx)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:e.meta}):null]})}},eeE={topologyEdge:function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:a,sourcePosition:i,targetPosition:o,data:l}){let[s]=aE({sourcePosition:i,sourceX:t,sourceY:n,targetPosition:o,targetX:r,targetY:a}),{x:c,y:d}=function(e){if("u"<typeof document)return{x:0,y:0};let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",e);let n=t.getTotalLength(),r=t.getPointAtLength(n/2);return{x:r.x,y:r.y}}(s),u=l?.kind??"direct";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(oL,{id:e,path:s,className:(0,eI.cn)("fill-none",eeC[u],"p2p"===u&&"stroke-dasharray-[8_6]","relay"===u&&"stroke-dasharray-[12_8]"),style:{strokeWidth:"down"===u?3:2.4,strokeLinecap:"round",strokeLinejoin:"round"}}),(l?.label||l?.meta)&&(0,ey.jsx)("foreignObject",{x:c-48,y:d-20,width:96,height:40,className:"overflow-visible",requiredExtensions:"http://www.w3.org/1999/xhtml",children:(0,ey.jsxs)("div",{className:"pointer-events-none grid h-10 w-24 content-center rounded-md border bg-background/95 px-2 py-1 text-center shadow-sm",children:[l.label?(0,ey.jsx)("div",{className:"truncate text-xs font-medium leading-4",children:l.label}):null,l.meta?(0,ey.jsx)("div",{className:"truncate ui-text-kbd text-muted-foreground",children:l.meta}):null]})})]})}};function eeO({nodes:e,links:t,className:n,...r}){let a=ew.useMemo(()=>e.map(e=>({id:e.id,data:{label:e.label,meta:e.meta,state:e.state??"online"},position:{x:e.x/100*1e3,y:e.y/100*560},type:"topologyNode"})),[e]),i=ew.useMemo(()=>t.map(e=>({id:e.id,data:{kind:e.kind??"direct",label:e.label,meta:e.meta},source:e.from,target:e.to,type:"topologyEdge"})),[t]);return(0,ey.jsx)("div",{"data-slot":"topology-map",className:(0,eI.cn)("h-full min-h-0 overflow-hidden rounded-xl bg-muted/25",n),...r,children:(0,ey.jsx)(lh,{children:(0,ey.jsx)(lg,{nodes:a,edges:i,nodeTypes:eeM,edgeTypes:eeE,fitView:!0,fitViewOptions:{maxZoom:1.15,minZoom:.45,padding:.22},minZoom:.35,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},className:"topology-flow text-foreground",children:(0,ey.jsx)(lS,{gap:28,size:1,color:"var(--border)",className:"opacity-80"})})})})}function eeP({nodes:e,links:t}){return(0,ey.jsx)(eeO,{nodes:e,links:t})}function eeA({title:e,count:t}){return(0,ey.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,ey.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function eeI({items:e}){return(0,ey.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function eez({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,ey.jsx)("span",{className:"truncate",children:n}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,ey.jsx)(JM,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eeT({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,ey.jsx)(eeD,{item:e})}}),[e]);return(0,ey.jsx)(JM,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function eeD({item:e}){return(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(J9,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(J9,{value:e.load,className:"h-1.5"}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function ee_({workers:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(eeR,{worker:e,divided:t>0},e.id))})}function eeR({worker:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,ey.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,ey.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ey.jsx)(eeL,{label:"CPU",value:e.cpu}),(0,ey.jsx)(eeL,{label:"MEM",value:e.memory})]})]})}function eeL({label:e,value:t}){return(0,ey.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,ey.jsx)(Qe,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function ee$({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,ey.jsx)(JM,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eeF({machines:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(eeB,{machine:e,divided:t>0},e.id))})}function eeB({machine:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eeH,{status:e.status}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,ey.jsx)(eeV,{icon:(0,ey.jsx)(ux,{}),label:"CPU",value:e.cpu}),(0,ey.jsx)(eeV,{icon:(0,ey.jsx)(Qi,{}),label:"MEM",value:e.memory}),(0,ey.jsx)(eeV,{icon:(0,ey.jsx)(uy,{}),label:"DISK",value:e.disk}),(0,ey.jsx)(eeV,{icon:(0,ey.jsx)(Qo,{}),label:"NET",value:e.network})]})]})}function eeV({icon:e,label:t,value:n}){return(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,ey.jsxs)("span",{children:[n,"%"]})]}),(0,ey.jsx)(J9,{value:n,className:"h-1.5"})]})}function eeH({status:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function eeU({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,ey.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,ey.jsx)(JM,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function eeW({config:e,data:t}){return(0,ey.jsx)(BZ,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,ey.jsxs)(XJ,{data:t,margin:{left:8,right:8},children:[(0,ey.jsx)(Yk,{vertical:!1}),(0,ey.jsx)(Y$,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,ey.jsx)(BA,{content:(0,ey.jsx)(BQ,{indicator:"line"})}),(0,ey.jsx)(Xq,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,ey.jsx)(Xq,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,ey.jsx)(Xq,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function eeq({services:e}){let[t,n]=GR(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,ey.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,ey.jsx)(eeK,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function eeK({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,ey.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,ey.jsx)("span",{className:(0,eI.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let eeG=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function eeX(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}eeG.push(eeX("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),eeX("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),eeX("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),eeX("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),eeX("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let eeY=eeG.filter(e=>"idle"!==e.status),eeZ=eeG.filter(e=>"idle"===e.status);function eeJ(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function eeQ(e,t){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:JI({image:t,opacity:.88,blur:"0px"}),children:e})}let ee0=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*eeZ.length)+1)}];function ee1({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sb(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,ey.jsx)(dw,{open:e,onOpenChange:o,children:(0,ey.jsxs)(fu,{hideClose:!0,className:(0,eI.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,ey.jsx)(fh,{className:"sr-only",children:t}),(0,ey.jsxs)(fp,{className:"sr-only",children:[r?(0,ey.jsxs)(ey.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,ey.jsxs)("div",{className:"flex h-full flex-col",children:[(0,ey.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,ey.jsx)(fc.XIcon,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,ey.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,ey.jsx)("span",{children:e.label}),e.badge?(0,ey.jsx)(F3,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,ey.jsx)(wb,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,ey.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,ey.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,ey.jsx)(wb,{className:"h-full",children:(0,ey.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,ey.jsxs)(eA.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,eI.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,ey.jsx)(F3,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,ey.jsx)(wb,{className:"min-h-0 bg-background",children:(0,ey.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function ee2({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeJ("活跃画布","画布列表"),render:e=>eeQ((0,ey.jsx)(Q4,{label:e.title,description:"当前正在编辑的画布数量",value:String(eeY.length)}),JE)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,ey.jsx)(Vl,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeJ("运行节点","画布节点"),render:e=>eeQ((0,ey.jsx)(Q4,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),JO)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,ey.jsx)(jw,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeJ("未保存","画布保存状态"),render:e=>eeQ((0,ey.jsx)(Q4,{label:e.title,description:"等待写入的画布变更",value:"4"}),JP)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,ey.jsx)(KT,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeJ("快照","画布快照"),render:e=>eeQ((0,ey.jsx)(Q4,{label:e.title,description:"可回退的历史存档",value:"46"}),JA)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eeJ("正在使用的画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(eeA,{title:t.title,count:eeY.length}),(0,ey.jsx)(Qn,{canvases:eeY,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,ey.jsx)(pF,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*eeZ.length)+1)},defaultConfig:eeJ("最近画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col",children:[(0,ey.jsx)(eeA,{title:t.title,count:eeZ.length}),(0,ey.jsx)(Qn,{canvases:eeZ,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(J5,{boardId:"canvas-library",definitions:i,initialLayouts:ee0,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,ey.jsx)(ee4,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function ee5({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}function ee4({canvas:e,onOpenChange:t}){return e?(0,ey.jsx)(ee1,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,ey.jsx)(Vs,{}),content:(0,ey.jsx)(ee3,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,ey.jsx)(Jy,{}),badge:e.settings.nodeTemplates.length,content:(0,ey.jsx)(ee8,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,ey.jsx)(JS,{}),content:(0,ey.jsx)(ee8,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,ey.jsx)(pF,{}),content:(0,ey.jsx)(ee8,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,ey.jsx)(Jk,{}),content:(0,ey.jsx)(ee8,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,ey.jsx)(KR,{}),content:(0,ey.jsx)(ee8,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,ey.jsx)(KT,{}),content:(0,ey.jsx)(ee8,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,ey.jsx)(Jw,{}),content:(0,ey.jsx)(ee8,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,ey.jsx)(Jj,{}),content:(0,ey.jsx)(ee8,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function ee3({canvas:e}){return(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("div",{className:"max-w-2xl",children:[(0,ey.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,ey.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,ey.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,ey.jsx)(ee6,{label:"Nodes",value:`${e.nodes}`}),(0,ey.jsx)(ee6,{label:"Agent",value:`${e.agents}`}),(0,ey.jsx)(ee6,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,ey.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,ey.jsx)(ee5,{icon:(0,ey.jsx)(Vl,{}),value:e.runtime})]}),(0,ey.jsx)(JM,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function ee6({label:e,value:t}){return(0,ey.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function ee8({title:e,items:t,empty:n="暂无内容"}){return(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,ey.jsx)(Jb,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,ey.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function ee7({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xn,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索节点..."}),(0,ey.jsxs)(xa,{children:[(0,ey.jsx)(xi,{children:"没有匹配节点。"}),(0,ey.jsx)(xo,{heading:"可用节点",children:uA.map(e=>(0,ey.jsxs)(xl,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,ey.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xs,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function ee9({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:h,handleCanvasAction:p,handleCanvasDragOver:m,handleCanvasDrop:g,handleNodeCanvasConnect:v,handleNodeCanvasEdgeAction:x,handleNodeCanvasNodeAction:y,filePickerDialog:b,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[h,p]=ew.useState(),m=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return uT(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),b=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,uA.find(e=>e.id===n)?.size??uC({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:uO(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:uM(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),w=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await u5(e):await u0(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||b(l,u??{x:496,y:336})}catch{hI.error("文件预览打开失败")}},[b,t,r,u]),j=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);w(e,n?{nodeId:n.id}:void 0)},[t,w]),k=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hI.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uV({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};x(e,o),hI.success("文件已保存")}catch(e){throw hI.error("文件保存失败"),e}},[x]),S=ew.useCallback((e,t,n)=>{b(t,m(n.clientX,n.clientY))},[b,m]),N=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[Gr]:void 0;if(a)return a;let i=e.dataTransfer.getData(Gr);if(i)try{return JSON.parse(i)}catch{return}},[n]),C=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),M=ew.useCallback((e,t,n)=>{let r=N(n);r&&C(e,t,r)},[N,C]),E=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),O=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),P=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onTabDetach:s,onExternalTabDrop:c}){return ew.useMemo(()=>e.map(e=>{let d=e.data??{},u=(e.data??{}).kind;return u?{...e,data:{...d,content:(0,ey.jsx)(ZP,{kind:u,nodeId:e.id,tab:d.tab,tabs:d.tabs,activeTabId:d.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:d.terminal,onTerminalStateChange:t=>l(e.id,t),onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:s,onExternalTabDrop:c})}}:e}),[e,n,c,a,r,o,i,s,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:v,onRequestFileTab:p,onOpenWorkspaceFile:j,onTabChange:x,onSaveFileTab:k,onTerminalStateChange:y,onTabDetach:S,onExternalTabDrop:M}),A=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:uT(e.id)&&(r.tab=u_(e.id,`${t}-tab`)),{id:t,type:"blank",position:uO(n,e.size),data:r,width:e.size.width,height:e.size.height,style:uM(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),I=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=m(e.clientX,e.clientY),s=N(e),c=s?E(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=O(c.id,e.clientX,n.length);C(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[Gn]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:uO(n,r),style:e.style??uM(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,E,N,m,O,C,r,i]),z=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[Gn,Gr].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),T=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),_=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),R=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&uT(n.kind))return n;let r=t.kind;if(uT(r))return u_(r,e.id)}(e=uR(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[Gn]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[Gn]:u.id},s&&(c[Gr]=s,d[Gr]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?uD(l.kind):(0,ey.jsx)(ug,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:A,filePickerDialog:(0,ey.jsx)(G_,{open:void 0!==h,onOpenChange:e=>{e||p(void 0)},onSelectFile:e=>{p(void 0),w(e,h)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:T,handleCanvasDragOver:z,handleCanvasDrop:I,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:_,handleNodeCanvasNodeAction:R,renderedCanvasNodes:P}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,ey.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:m,onDrop:g,children:[(0,ey.jsx)(sy,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:uS,edgeTypes:uN,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:p,onNodeCanvasConnect:v,onNodeCanvasEdgeAction:x,onNodeCanvasNodeAction:y}),(0,ey.jsx)(ee7,{open:u,onOpenChange:h,onAdd:f}),b,(0,ey.jsx)(hL,{position:"top-right"})]})}vl.length;let ete={delete:"Delete",empty:"Drop here",title:"Trash"};function ett({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...ete,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,ey.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,eI.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,ey.jsx)(x2,{className:"size-4"}),(0,ey.jsx)("span",{children:s.empty})]}),t.length>0?(0,ey.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,ey.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,ey.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,ey.jsx)(fc.XIcon,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,ey.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,ey.jsx)(x2,{className:"size-5"})})})}function etn({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,iy.createPortal)((0,ey.jsxs)("div",{className:(0,eI.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,ey.jsx)(ett,{active:!e&&void 0!==a,items:e?[]:n,className:(0,eI.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,ey.jsx)("div",{className:(0,eI.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,ey.jsx)(GY,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[Ga],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[Gi],a&&i&&(i[Ga]={...a,config:{...a.config}}),l&&i&&(i[Gi]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let etr=(0,ek.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),eta=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),eti=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),eto=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),etl=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),ets=(0,ek.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),etc=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),etd=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),etu=(0,ek.default)("users-round",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]),etf=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);var eth="Collapsible",[etp,etm]=s7(eth),[etg,etv]=etp(eth),etx=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=co({prop:r,defaultProp:a??!1,onChange:o,caller:eth});return(0,ey.jsx)(etg,{scope:n,disabled:i,contentId:ca(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,ey.jsx)(cd.div,{"data-state":etS(s),"data-disabled":i?"":void 0,...l,ref:t})})});etx.displayName=eth;var ety="CollapsibleTrigger",etb=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=etv(ety,n);return(0,ey.jsx)(cd.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":etS(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:ce(e.onClick,a.onOpenToggle)})});etb.displayName=ety;var etw="CollapsibleContent",etj=ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=etv(etw,e.__scopeCollapsible);return(0,ey.jsx)(cE,{present:n||a.open,children:({present:e})=>(0,ey.jsx)(etk,{...r,ref:t,present:e})})});etj.displayName=etw;var etk=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=etv(etw,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,s9.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,h=ew.useRef(0),p=h.current,m=o.open||l,g=ew.useRef(m),v=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),ct(()=>{let e=c.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,h.current=t.width,g.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),s(r)}},[o.open,r]),(0,ey.jsx)(cd.div,{"data-state":etS(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!m,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":p?`${p}px`:void 0,...e.style},children:m&&a})});function etS(e){return e?"open":"closed"}var etN=e.i(91e3);let etC={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-model-routes":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-system-prompt":"settings","preferences-layout":"settings","network-topology":"settings","check-update":"settings",account:"settings"};function etM({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeCanvasId:a,onItemSelect:i,onOpenConversation:o,onOpenCanvas:l,onOpenConversationSettings:s,onOpenCanvasSettings:c,onConversationDeleted:d,onAccountSettings:u,subagentTree:f,activeSubagentPath:h,onOpenSubagent:p,hideCanvas:m,className:g}){let v=etC[n]??(m?"agent":"canvas");m&&"canvas"===v&&(v="agent");let[x,y]=ew.useState(v);ew.useEffect(()=>{y(v)},[v]);let b=m?e.filter(e=>"canvas"!==e.id):e,w=t.find(e=>e.id===x);return(0,ey.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,eI.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",g),children:[(0,ey.jsx)("nav",{className:"mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:b.map(e=>{let t=e.id===x;return(0,ey.jsxs)("button",{type:"button",onClick:()=>y(e.id),className:(0,eI.cn)("flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"border border-border/50 bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"truncate",children:e.label})]},e.id)})}),"canvas"===x?(0,ey.jsx)(etE,{activeCanvasId:a,onItemSelect:i,onOpenCanvas:l,onOpenCanvasSettings:c}):"agent"===x?(0,ey.jsx)(etI,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:s,onConversationDeleted:d,subagentTree:f,activeSubagentPath:h,onOpenSubagent:p}):(0,ey.jsx)(et$,{content:w,activeWorkspace:n,onItemSelect:i}),(0,ey.jsx)(etK,{onItemSelect:i,onAccountSettings:u})]})}function etE({activeCanvasId:e,onItemSelect:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let{recents:a,loading:i}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0);return ew.useEffect(()=>{let e=!0;async function n(){try{let{canvases:n}=await Jm();if(!e)return;let r=[...n].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r)}catch{}finally{e&&r(!1)}}n();let a=setInterval(()=>void n(),1e4);return()=>{e=!1,clearInterval(a)}},[]),{recents:e,loading:n}}(),o=a.filter(e=>!0===e.running),l=a.filter(e=>!0!==e.running),s=i&&0===a.length;return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,ey.jsx)(etU,{icon:etc,label:JD.canvasNew,onClick:()=>t({item:{id:"new-canvas"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[o.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(t=>(0,ey.jsx)(etO,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]}):null,(0,ey.jsx)("div",{className:"mb-2 flex items-center justify-between px-3",children:(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"})}),(0,ey.jsx)("div",{className:"space-y-0.5",children:s?(0,ey.jsx)(etW,{}):0===l.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:"暂无画布"}):l.map(t=>(0,ey.jsx)(etO,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]})]})}function etO({canvas:e,active:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let a=!0===e.running;return(0,ey.jsx)(etL,{title:a?`${e.title} \xb7 运行中`:e.title,label:e.title,active:t,running:a,onOpen:()=>n(e.id,e.ownerMachineId),onOpenSettings:r?()=>r(e.id,e.ownerMachineId):void 0})}let etP="__all__",etA={status:"all",location:etP,sort:"recent"};function etI({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let{recents:s,refresh:c,loading:d,machineNames:u}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState({}),o=ew.useRef(!0),l=ew.useCallback(async()=>{try{let{conversations:e,machineNames:n}=await sO();if(!o.current)return;let r=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r),i(n)}catch{}finally{o.current&&r(!1)}},[]);return ew.useEffect(()=>{o.current=!0,l();let e=setInterval(()=>void l(),1e4);return()=>{o.current=!1,clearInterval(e)}},[l]),{recents:e,refresh:()=>void l(),loading:n,machineNames:a}}(),[f,h]=ew.useState(etA),p=ew.useMemo(()=>{let e=new Set;for(let t of s)e.add(t.ownerMachineId||sN);return Array.from(e)},[s]),m=ew.useCallback(e=>sC(e)?"本机":u[e]??e,[u]),g=ew.useMemo(()=>{let e=s.filter(e=>{let t=!0===e.running;return("running"!==f.status||!!t)&&("idle"!==f.status||!t)&&(f.location===etP||(e.ownerMachineId||sN)===f.location)});return"name"===f.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[s,f]),v=g.filter(e=>!0===e.running),x=g.filter(e=>!0!==e.running),y=f.status!==etA.status||f.location!==etA.location||f.sort!==etA.sort,b=d&&0===s.length,w=ew.useCallback(async e=>{try{await sB(e.id,e.ownerMachineId)}catch{}a?.(e.id),c()},[a,c]),j=ew.useCallback(async e=>{try{let t=await sq(e.id,void 0,e.ownerMachineId);await c(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[c,n]),k=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),S=o?.[o.length-1]?.id,N=t=>{let a=new Map(t.map(e=>[e.id,e])),o=new Map,s=[];for(let e of t){let t=e.forkOriginId;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=(t,a)=>{let s=t.id!==e||(i?.length??0)===0?null:(0,ey.jsx)(etz,{nodes:i??[],depth:0,ancestors:[],activeIds:k,activeLeafId:S,onOpen:l});return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(etR,{conversation:t,depth:a,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:w,onFork:j}),s?(0,ey.jsx)("div",{style:a>0?{marginLeft:14*a}:void 0,children:s}):null,(o.get(t.id)??[]).map(e=>c(e,a+1))]},t.id)};return s.map(e=>c(e,0))};return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5","data-tour":"new-conversation",children:(0,ey.jsx)(etU,{icon:tc,label:JD.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[v.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:N(v)})]}):null,(0,ey.jsxs)("div",{className:"mb-2 flex items-center justify-between px-3",children:[(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,ey.jsx)(etD,{filter:f,onChange:h,active:y,locations:p,locationLabel:m})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:b?(0,ey.jsx)(etW,{}):0===x.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:y?"没有符合筛选条件的对话":"暂无对话"}):N(x)})]})]})}function etz({nodes:e,depth:t,ancestors:n,activeIds:r,activeLeafId:a,onOpen:i}){let o=e.filter(e=>(function e(t,n){return!!(t.running||n.has(t.id))||(t.children??[]).some(t=>e(t,n))})(e,r));return 0===o.length?null:(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(e=>{let o=VB(e.subagentType),l=o.Icon,s=[...n,{id:e.id,ownerMachineId:e.ownerMachineId,name:e.subagentName,subagentType:e.subagentType}],c=e.id===a;return(0,ey.jsxs)("div",{children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*t},onClick:()=>i?.(s),title:e.subagentName||o.label,children:[(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,ey.jsx)(l,{className:(0,eI.cn)("size-3.5 shrink-0",o.color)}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||`${o.label}子代理`}),e.running?(0,ey.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,ey.jsx)(etz,{nodes:e.children??[],depth:t+1,ancestors:s,activeIds:r,activeLeafId:a,onOpen:i})]},e.id)})})}let etT={all:"全部",running:"运行中",idle:"空闲"};function etD({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=e.location===etP?"全部":a(e.location);return(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,eI.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,ey.jsx)(JS,{className:"size-4"}),n?(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]})}),(0,ey.jsxs)(bL,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,ey.jsx)(bB,{children:"筛选与排序"}),(0,ey.jsxs)(bR,{children:[(0,ey.jsxs)(bU,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"状态"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:etT[e.status]})]}),(0,ey.jsx)(bW,{children:(0,ey.jsxs)(bA,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,ey.jsx)(bF,{value:"all",children:"全部"}),(0,ey.jsx)(bF,{value:"running",children:"运行中"}),(0,ey.jsx)(bF,{value:"idle",children:"空闲"})]})})]}),(0,ey.jsxs)(bR,{children:[(0,ey.jsxs)(bU,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,ey.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:i})]}),(0,ey.jsx)(bW,{className:"max-h-72 overflow-y-auto",children:(0,ey.jsxs)(bA,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,ey.jsx)(bF,{value:etP,children:"全部"}),r.map(e=>(0,ey.jsx)(bF,{value:e,children:(0,ey.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,ey.jsx)(bV,{}),(0,ey.jsx)(bB,{children:"排序"}),(0,ey.jsxs)(bA,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,ey.jsx)(bF,{value:"recent",children:"最近活动"}),(0,ey.jsx)(bF,{value:"name",children:"名称"})]}),n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bV,{}),(0,ey.jsx)(b$,{onSelect:()=>t(etA),children:(0,ey.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function et_({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,ey.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,eI.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}function etR({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o}){let l=!0===e.running,s=e.settings?.engine??"vantaloom",c="vantaloom"!==s?(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,ey.jsx)(et_,{engine:s}),(0,ey.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,ey.jsx)(etL,{title:l?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:c,active:t,running:l,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,deleteLabel:"删除会话"})}function etL({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,deleteLabel:d="删除"}){let[u,f]=ew.useState(!1),h=!!(l||s||c),p=i>0,m=(0,ey.jsxs)(ey.Fragment,{children:[l?(0,ey.jsxs)(bm,{onSelect:()=>l(),children:[(0,ey.jsx)(Jq,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bm,{onSelect:()=>c(),children:[(0,ey.jsx)(Vl,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bm,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(x2,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]}),g=(0,ey.jsxs)("div",{className:(0,eI.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors",r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:p?{marginLeft:14*i}:void 0,children:[(0,ey.jsxs)("button",{type:"button",title:e,onClick:o,className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[p?(0,ey.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500","aria-label":"运行中"}):(0,ey.jsx)(etq,{active:r}),n??(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),h?(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,ey.jsx)(lY,{className:"size-4"})})}),(0,ey.jsxs)(bL,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,ey.jsxs)(b$,{onSelect:()=>l(),children:[(0,ey.jsx)(Jq,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(b$,{onSelect:()=>c(),children:[(0,ey.jsx)(Vl,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(b$,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(x2,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]})]}):null]});return(0,ey.jsxs)(ey.Fragment,{children:[h?(0,ey.jsxs)(ba,{children:[(0,ey.jsx)(bo,{asChild:!0,children:g}),(0,ey.jsx)(bp,{className:"min-w-44",children:m})]}):g,s?(0,ey.jsx)(dQ,{open:u,onOpenChange:f,children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:d}),(0,ey.jsxs)(uu,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})}function et$({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,ey.jsx)(wb,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,ey.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,ey.jsx)(etV,{activeWorkspace:t,onItemSelect:n},e.id):(0,ey.jsx)(etF,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function etF({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,ey.jsx)(etq,{active:!0})]})}let etB=[{id:"model",title:"模型设置",icon:(0,ey.jsx)(ux,{}),items:[{id:"preferences-model-routes",label:"模型路由",icon:(0,ey.jsx)(p_,{})},{id:"preferences-agent-config",label:"代理配置",icon:(0,ey.jsx)(um,{})},{id:"preferences-subagent-config",label:"子代理配置",icon:(0,ey.jsx)(etu,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,ey.jsx)(ux,{})}]},{id:"prefs",title:"偏好设置",icon:(0,ey.jsx)(Jq,{}),items:[{id:"preferences-system-prompt",label:"系统提示词",icon:(0,ey.jsx)(ets,{})},{id:"preferences-layout",label:"布局排版",icon:(0,ey.jsx)(eti,{})}]},{id:"system",title:"系统设置",icon:(0,ey.jsx)(K7,{}),items:[{id:"network-topology",label:"组网关系",icon:(0,ey.jsx)(Jw,{})},{id:"check-update",label:"检查更新",icon:(0,ey.jsx)(x1,{})},{id:"account",label:"Hub 账户",icon:(0,ey.jsx)(eC,{})},{id:"balance-usage",label:"余额用量",icon:(0,ey.jsx)(etf,{})},{id:"feedback",label:"问题反馈",icon:(0,ey.jsx)(jl,{})}]}];function etV({activeWorkspace:e,onItemSelect:t}){return(0,ey.jsx)(ey.Fragment,{children:etB.map(n=>(0,ey.jsx)(etH,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t},n.id))})}function etH({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0);return(0,ey.jsxs)(etx,{open:o,onOpenChange:l,children:[(0,ey.jsx)(etb,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,ey.jsx)(g8,{className:(0,eI.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,ey.jsx)(etj,{className:"mt-0.5 space-y-0.5",children:n.map(e=>{let t=e.id===r;return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",t?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),t&&(0,ey.jsx)(etq,{active:!0})]},e.id)})})]})}function etU({icon:e,label:t,onClick:n}){return(0,ey.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function etW(){return(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"}),(0,ey.jsx)("span",{children:"加载中…"})]})}function etq({active:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function etK({onItemSelect:e,onAccountSettings:t}){let{user:n}=tl(),r=n?.name??JT.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,ey.jsx)("div",{className:"mt-auto pt-3",children:(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,ey.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,ey.jsx)(p$,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,ey.jsxs)(bL,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,ey.jsx)(bB,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,ey.jsxs)(b$,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,ey.jsx)(Jq,{}),(0,ey.jsx)("span",{className:"flex-1",children:"设置"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,ey.jsxs)(b$,{disabled:!0,children:[(0,ey.jsx)(eta,{}),(0,ey.jsx)("span",{className:"flex-1",children:"语言"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,ey.jsxs)(b$,{disabled:!0,children:[(0,ey.jsx)(etr,{}),(0,ey.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,ey.jsx)(KT,{}),(0,ey.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,ey.jsx)(etX,{}),n&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bV,{}),(0,ey.jsx)(etY,{})]})]})]})})}let etG=["light","dark","jelly"];function etX(){let{resolvedTheme:e,setTheme:t}=(0,hw.useTheme)(),[n,r]=ew.useState(etN.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(etN.appearanceThemeStorageKey)??etN.defaultAppearanceTheme;r(e),(0,etN.applyAppearanceTheme)({theme:e})},[]);let a=n===etN.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=etG[(etG.indexOf(a)+1)%etG.length]??"light";function o(e){r(e),window.localStorage.setItem(etN.appearanceThemeStorageKey,e),(0,etN.applyAppearanceTheme)({theme:e})}let l="dark"===a?etl:etd;return(0,ey.jsxs)(b$,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(etN.jellyAppearanceTheme);return}o(etN.defaultAppearanceTheme),t(i)}()},children:[(0,ey.jsx)(l,{}),(0,ey.jsx)("span",{className:"flex-1",children:JT.theme}),(0,ey.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function etY(){let{logout:e}=tl();return(0,ey.jsxs)(b$,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,ey.jsx)(eto,{}),(0,ey.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let etZ=ew.default.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),etJ=()=>{let e=ew.default.useContext(etZ);if(!e)throw Error("useDrawerContext must be used within a Drawer.Root");return e};function etQ(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function et0(){return et1(/^iPhone/)||et1(/^iPad/)||et1(/^Mac/)&&navigator.maxTouchPoints>1}function et1(e){return"u">typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if(!e||"u"<typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");let et2="u">typeof window?ew.useLayoutEffect:ew.useEffect;function et5(...e){return(...t)=>{for(let n of e)"function"==typeof n&&n(...t)}}let et4="u">typeof document&&window.visualViewport;function et3(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function et6(e){for(et3(e)&&(e=e.parentElement);e&&!et3(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}let et8=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),et7=0;function et9(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ene(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=et6(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=r-n)}e=t.parentElement}}function ent(e){return e instanceof HTMLInputElement&&!et8.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function enn(...e){return ew.useCallback(function(...e){return t=>e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}(...e),e)}let enr=new WeakMap;function ena(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):(r[t]=e.style[t],e.style[t]=n)}),n||enr.set(e,r)}let eni=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function eno(e,t){if(!e)return null;let n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform,a=r.match(/^matrix3d\((.+)\)$/);return a?parseFloat(a[1].split(", ")[eni(t)?13:12]):(a=r.match(/^matrix\((.+)\)$/))?parseFloat(a[1].split(", ")[eni(t)?5:4]):null}function enl(e,t){if(!e)return()=>{};let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}let ens=[.32,.72,0,1],enc="vaul-dragging";function end(e){let t=ew.default.useRef(e);return ew.default.useEffect(()=>{t.current=e}),ew.default.useMemo(()=>(...e)=>null==t.current?void 0:t.current.call(t,...e),[])}function enu({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,a]=function({defaultProp:e,onChange:t}){let n=ew.default.useState(e),[r]=n,a=ew.default.useRef(r),i=end(t);return ew.default.useEffect(()=>{a.current!==r&&(i(r),a.current=r)},[r,a,i]),n}({defaultProp:t,onChange:n}),i=void 0!==e,o=i?e:r,l=end(n);return[o,ew.default.useCallback(t=>{if(i){let n="function"==typeof t?t(e):t;n!==e&&l(n)}else a(t)},[i,e,a,l])]}let enf=()=>()=>{},enh=null,enp=ew.default.forwardRef(function({...e},t){let{overlayRef:n,snapPoints:r,onRelease:a,shouldFade:i,isOpen:o,modal:l,shouldAnimate:s}=etJ(),c=enn(t,n),d=r&&r.length>0;if(!l)return null;let u=ew.default.useCallback(e=>a(e),[a]);return ew.default.createElement(dO,{onMouseUp:u,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&d?"true":"false","data-vaul-snap-points-overlay":o&&i?"true":"false","data-vaul-animate":(null==s?void 0:s.current)?"true":"false",...e})});enp.displayName="Drawer.Overlay";let enm=ew.default.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},a){let{drawerRef:i,onPress:o,onRelease:l,onDrag:s,keyboardIsOpen:c,snapPointsOffset:d,activeSnapPointIndex:u,modal:f,isOpen:h,direction:p,snapPoints:m,container:g,handleOnly:v,shouldAnimate:x,autoFocus:y}=etJ(),[b,w]=ew.default.useState(!1),j=enn(a,i),k=ew.default.useRef(null),S=ew.default.useRef(null),N=ew.default.useRef(!1),C=m&&m.length>0;function M(e){k.current=null,N.current=!1,l(e)}return!function(){let{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:a}=etJ(),i=ew.default.useRef(null),o=(0,ew.useMemo)(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}ew.default.useEffect(()=>{if(t&&n){i.current&&clearTimeout(i.current);let t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;!function(...e){}(r&&!a?enl(document.body,{background:"black"}):enf,enl(t,{transformOrigin:eni(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${ens.join(",")})`}));let n=enl(t,{borderRadius:"8px",overflow:"hidden",...eni(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),i.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},500)}}},[t,n,o])}(),ew.default.useEffect(()=>{C&&window.requestAnimationFrame(()=>{w(!0)})},[]),ew.default.createElement(dz,{"data-vaul-drawer-direction":p,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":h&&C?"true":"false","data-vaul-custom-container":g?"true":"false","data-vaul-animate":(null==x?void 0:x.current)?"true":"false",...r,ref:j,style:d&&d.length>0?{"--snap-point-height":`${d[null!=u?u:0]}px`,...t}:t,onPointerDown:e=>{v||(null==r.onPointerDown||r.onPointerDown.call(r,e),k.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==n||n(e),y||e.preventDefault()},onPointerDownOutside:t=>{(null==e||e(t),!f||t.defaultPrevented)?t.preventDefault():c.current&&(c.current=!1)},onFocusOutside:e=>{if(!f)return void e.preventDefault()},onPointerMove:e=>{if(S.current=e,v||(null==r.onPointerMove||r.onPointerMove.call(r,e),!k.current))return;let t=e.pageY-k.current.y,n=e.pageX-k.current.x,a="touch"===e.pointerType?10:2;((e,t,n=0)=>{if(N.current)return!0;let r=Math.abs(e.y),a=Math.abs(e.x),i=a>r,o=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*o<0)&&a>=0&&a<=n)return i}else if(!(e.y*o<0)&&r>=0&&r<=n)return!i;return N.current=!0,!0})({x:n,y:t},p,a)?s(e):(Math.abs(n)>a||Math.abs(t)>a)&&(k.current=null)},onPointerUp:e=>{null==r.onPointerUp||r.onPointerUp.call(r,e),k.current=null,N.current=!1,l(e)},onPointerOut:e=>{null==r.onPointerOut||r.onPointerOut.call(r,e),M(S.current)},onContextMenu:e=>{null==r.onContextMenu||r.onContextMenu.call(r,e),S.current&&M(S.current)}})});enm.displayName="Drawer.Content",ew.default.forwardRef(function({preventCycle:e=!1,children:t,...n},r){let{closeDrawer:a,isDragging:i,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:s,dismissible:c,handleOnly:d,isOpen:u,onPress:f,onDrag:h}=etJ(),p=ew.default.useRef(null),m=ew.default.useRef(!1);function g(){p.current&&window.clearTimeout(p.current),m.current=!1}return ew.default.createElement("div",{onClick:function(){m.current?g():window.setTimeout(()=>{!function(){if(i||e||m.current)return g();if(g(),!o||0===o.length){c||a();return}if(l===o[o.length-1]&&c)return a();let t=o.findIndex(e=>e===l);-1===t||s(o[t+1])}()},120)},onPointerCancel:g,onPointerDown:e=>{d&&f(e),p.current=window.setTimeout(()=>{m.current=!0},250)},onPointerMove:e=>{d&&h(e)},ref:r,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},ew.default.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))}).displayName="Drawer.Handle";let eng=function({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:a,snapPoints:i,shouldScaleBackground:l=!1,setBackgroundColorOnScale:s=!0,closeThreshold:c=.25,scrollLockTimeout:d=100,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:h=i&&i.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:x,nested:y,noBodyStyles:b=!1,direction:w="bottom",defaultOpen:j=!1,disablePreventScroll:k=!0,snapToSequentialPoint:S=!1,preventScrollRestoration:N=!1,repositionInputs:C=!0,onAnimationEnd:M,container:E,autoFocus:O=!1}){var P,A;let[I=!1,z]=enu({defaultProp:j,prop:e,onChange:e=>{null==t||t(e),e||y||ed(),setTimeout(()=>{null==M||M(e)},500),e&&!v&&"u">typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[T,D]=ew.default.useState(!1),[_,R]=ew.default.useState(!1),[L,$]=ew.default.useState(!1),F=ew.default.useRef(null),B=ew.default.useRef(null),V=ew.default.useRef(null),H=ew.default.useRef(null),U=ew.default.useRef(null),W=ew.default.useRef(!1),q=ew.default.useRef(null),K=ew.default.useRef(0),G=ew.default.useRef(!1),X=ew.default.useRef(!j),Y=ew.default.useRef(0),Z=ew.default.useRef(null),J=ew.default.useRef((null==(P=Z.current)?void 0:P.getBoundingClientRect().height)||0),Q=ew.default.useRef((null==(A=Z.current)?void 0:A.getBoundingClientRect().width)||0),ee=ew.default.useRef(0),et=ew.default.useCallback(e=>{i&&e===eo.length-1&&(B.current=new Date)},[]),{activeSnapPoint:en,activeSnapPointIndex:er,setActiveSnapPoint:ea,onRelease:ei,snapPointsOffset:eo,onDrag:el,shouldFade:es,getPercentageDragged:ec}=function({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:a,fadeFromIndex:i,onSnapPointChange:o,direction:l="bottom",container:s,snapToSequentialPoint:c}){let[d,u]=enu({prop:e,defaultProp:null==n?void 0:n[0],onChange:t}),[f,h]=ew.default.useState("u">typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);ew.default.useEffect(()=>{function e(){h({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let p=ew.default.useMemo(()=>d===(null==n?void 0:n[n.length-1])||null,[n,d]),m=ew.default.useMemo(()=>{var e;return null!=(e=null==n?void 0:n.findIndex(e=>e===d))?e:null},[n,d]),g=n&&n.length>0&&(i||0===i)&&!Number.isNaN(i)&&n[i]===d||!n,v=ew.default.useMemo(()=>{var e;let t=s?{width:s.getBoundingClientRect().width,height:s.getBoundingClientRect().height}:"u">typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};return null!=(e=null==n?void 0:n.map(e=>{let n="string"==typeof e,r=0;if(n&&(r=parseInt(e,10)),eni(l)){let a=n?r:f?e*t.height:0;return f?"bottom"===l?t.height-a:-t.height+a:a}let a=n?r:f?e*t.width:0;return f?"right"===l?t.width-a:-t.width+a:a}))?e:[]},[n,f,s]),x=ew.default.useMemo(()=>null!==m?null==v?void 0:v[m]:null,[v,m]),y=ew.default.useCallback(e=>{var t;let s=null!=(t=null==v?void 0:v.findIndex(t=>t===e))?t:null;o(s),ena(r.current,{transition:`transform 0.5s cubic-bezier(${ens.join(",")})`,transform:eni(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),v&&s!==v.length-1&&void 0!==i&&s!==i&&s<i?ena(a.current,{transition:`opacity 0.5s cubic-bezier(${ens.join(",")})`,opacity:"0"}):ena(a.current,{transition:`opacity 0.5s cubic-bezier(${ens.join(",")})`,opacity:"1"}),u(null==n?void 0:n[Math.max(s,0)])},[r.current,n,v,i,a,u]);return ew.default.useEffect(()=>{if(d||e){var t;let r=null!=(t=null==n?void 0:n.findIndex(t=>t===e||t===d))?t:-1;v&&-1!==r&&"number"==typeof v[r]&&y(v[r])}},[d,e,n,v,y]),{isLastSnapPoint:p,activeSnapPoint:d,shouldFade:g,getPercentageDragged:function(e,t){if(!n||"number"!=typeof m||!v||void 0===i)return null;let r=m===i-1;if(m>=i&&t)return 0;if(r&&!t)return 1;if(!g&&!r)return null;let a=r?m+1:m-1,o=e/Math.abs(r?v[a]-v[a-1]:v[a+1]-v[a]);return r?1-o:o},setActiveSnapPoint:u,activeSnapPointIndex:m,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:o}){if(void 0===i)return;let s="bottom"===l||"right"===l?(null!=x?x:0)-e:(null!=x?x:0)+e,d=m===i-1,u=0===m,f=e>0;if(d&&ena(a.current,{transition:`opacity 0.5s cubic-bezier(${ens.join(",")})`}),!c&&r>2&&!f)return void(o?t():y(v[0]));if(!c&&r>2&&f&&v&&n)return void y(v[n.length-1]);let h=null==v?void 0:v.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-s)<Math.abs(e-s)?t:e),g=eni(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*g){let e=f?1:-1;return e>0&&p&&n?void y(v[n.length-1]):void(u&&e<0&&o&&t(),null===m||y(v[m+e]))}y(h)},onDrag:function({draggedDistance:e}){if(null===x)return;let t="bottom"===l||"right"===l?x-e:x+e;("bottom"===l||"right"===l)&&t<v[v.length-1]||("top"===l||"left"===l)&&t>v[v.length-1]||ena(r.current,{transform:eni(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:v}}({snapPoints:i,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Z,fadeFromIndex:h,overlayRef:F,onSnapPointChange:et,direction:w,container:E,snapToSequentialPoint:S});!function(e={}){let{isDisabled:t}=e;et2(()=>{if(!t){var e,n,r;let t,a,i,l,s,c,d;return 1==++et7&&et0()&&(i=0,l=window.pageXOffset,s=window.pageYOffset,c=et5((e=document.documentElement,n="paddingRight",r=`${window.innerWidth-document.documentElement.clientWidth}px`,t=e.style[n],e.style[n]=r,()=>{e.style[n]=t})),window.scrollTo(0,0),d=et5(et9(document,"touchstart",e=>{((a=et6(e.target))!==document.documentElement||a!==document.body)&&(i=e.changedTouches[0].pageY)},{passive:!1,capture:!0}),et9(document,"touchmove",e=>{if(!a||a===document.documentElement||a===document.body)return void e.preventDefault();let t=e.changedTouches[0].pageY,n=a.scrollTop,r=a.scrollHeight-a.clientHeight;0!==r&&((n<=0&&t>i||n>=r&&t<i)&&e.preventDefault(),i=t)},{passive:!1,capture:!0}),et9(document,"touchend",e=>{let t=e.target;ent(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},{passive:!1,capture:!0}),et9(document,"focus",e=>{let t=e.target;ent(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",et4&&(et4.height<window.innerHeight?requestAnimationFrame(()=>{ene(t)}):et4.addEventListener("resize",()=>ene(t),{once:!0}))}))},!0),et9(window,"scroll",()=>{window.scrollTo(0,0)})),o=()=>{c(),d(),window.scrollTo(l,s)}),()=>{0==--et7&&(null==o||o())}}},[t])}({isDisabled:!I||_||!v||L||!T||!C||!k});let{restorePositionSetting:ed}=function({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:a,noBodyStyles:i}){let[o,l]=ew.default.useState(()=>"u">typeof window?window.location.href:""),s=ew.default.useRef(0),c=ew.default.useCallback(()=>{if(etQ()&&null===enh&&e&&!i){enh={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};let{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-s.current}px`,left:`${-e}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let e=t-window.innerHeight;e&&s.current>=t&&(document.body.style.top=`${-(s.current+e)}px`)}),300)}},[e]),d=ew.default.useCallback(()=>{if(etQ()&&null!==enh&&!i){let e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,enh),window.requestAnimationFrame(()=>{a&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),enh=null}},[o]);return ew.default.useEffect(()=>{function e(){s.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),ew.default.useEffect(()=>{if(t)return()=>{"u"<typeof document||document.querySelector("[data-vaul-drawer]")||d()}},[t,d]),ew.default.useEffect(()=>{!n&&r&&(e?(window.matchMedia("(display-mode: standalone)").matches||c(),t||window.setTimeout(()=>{d()},500)):d())},[e,r,o,t,n,c,d]),{restorePositionSetting:d}}({isOpen:I,modal:v,nested:null!=y&&y,hasBeenOpened:T,preventScrollRestoration:N,noBodyStyles:b});function eu(){return(window.innerWidth-26)/window.innerWidth}function ef(e,t){var n;let r=e,a=null==(n=window.getSelection())?void 0:n.toString(),i=Z.current?eno(Z.current,w):null,o=new Date;if("SELECT"===r.tagName||r.hasAttribute("data-vaul-no-drag")||r.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(B.current&&o.getTime()-B.current.getTime()<500)return!1;if(null!==i&&("bottom"===w?i>0:i<0))return!0;if(a&&a.length>0)return!1;if(U.current&&o.getTime()-U.current.getTime()<d&&0===i||t)return U.current=o,!1;for(;r;){if(r.scrollHeight>r.clientHeight){if(0!==r.scrollTop)return U.current=new Date,!1;if("dialog"===r.getAttribute("role"))break}r=r.parentNode}return!0}function eh(e){_&&Z.current&&(Z.current.classList.remove(enc),W.current=!1,R(!1),H.current=new Date),null==x||x(),e||z(!1),setTimeout(()=>{i&&ea(i[0])},500)}function ep(){if(!Z.current)return;let e=document.querySelector("[data-vaul-drawer-wrapper]"),t=eno(Z.current,w);ena(Z.current,{transform:"translate3d(0, 0, 0)",transition:`transform 0.5s cubic-bezier(${ens.join(",")})`}),ena(F.current,{transition:`opacity 0.5s cubic-bezier(${ens.join(",")})`,opacity:"1"}),l&&t&&t>0&&I&&ena(e,{borderRadius:"8px",overflow:"hidden",...eni(w)?{transform:`scale(${eu()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${eu()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${ens.join(",")})`},!0)}return ew.default.useEffect(()=>{window.requestAnimationFrame(()=>{X.current=!0})},[]),ew.default.useEffect(()=>{var e;function t(){if(Z.current&&C&&(ent(document.activeElement)||G.current)){var e;let t=(null==(e=window.visualViewport)?void 0:e.height)||0,n=window.innerHeight,r=n-t,a=Z.current.getBoundingClientRect().height||0;ee.current||(ee.current=a);let o=Z.current.getBoundingClientRect().top;if(Math.abs(Y.current-r)>60&&(G.current=!G.current),i&&i.length>0&&eo&&er&&(r+=eo[er]||0),Y.current=r,a>t||G.current){let e=Z.current.getBoundingClientRect().height,i=e;e>t&&(i=t-(a>.8*n?o:26)),g?Z.current.style.height=`${e-Math.max(r,0)}px`:Z.current.style.height=`${Math.max(i,t-o)}px`}else{let e;e=navigator.userAgent,"u">typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))||(Z.current.style.height=`${ee.current}px`)}i&&i.length>0&&!G.current?Z.current.style.bottom="0px":Z.current.style.bottom=`${Math.max(r,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[er,i,eo]),ew.default.useEffect(()=>(I&&(ena(document.documentElement,{scrollBehavior:"auto"}),B.current=new Date),()=>{!function(e,t){if(!e||!(e instanceof HTMLElement))return;let n=enr.get(e);n&&(e.style[t]=n[t])}(document.documentElement,"scrollBehavior")}),[I]),ew.default.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),ew.default.createElement(dw,{defaultOpen:j,onOpenChange:e=>{(u||e)&&(e?D(!0):eh(!0),z(e))},open:I},ew.default.createElement(etZ.Provider,{value:{activeSnapPoint:en,snapPoints:i,setActiveSnapPoint:ea,drawerRef:Z,overlayRef:F,onOpenChange:t,onPress:function(e){var t,n;!u&&!i||(!Z.current||Z.current.contains(e.target))&&(J.current=(null==(t=Z.current)?void 0:t.getBoundingClientRect().height)||0,Q.current=(null==(n=Z.current)?void 0:n.getBoundingClientRect().width)||0,R(!0),V.current=new Date,et0()&&window.addEventListener("touchend",()=>W.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),K.current=eni(w)?e.pageY:e.pageX)},onRelease:function(e){var t,n;if(!_||!Z.current)return;Z.current.classList.remove(enc),W.current=!1,R(!1),H.current=new Date;let r=eno(Z.current,w);if(!e||!ef(e.target,!1)||!r||Number.isNaN(r)||null===V.current)return;let o=H.current.getTime()-V.current.getTime(),l=K.current-(eni(w)?e.pageY:e.pageX),s=Math.abs(l)/o;if(s>.05&&($(!0),setTimeout(()=>{$(!1)},200)),i){ei({draggedDistance:l*("bottom"===w||"right"===w?1:-1),closeDrawer:eh,velocity:s,dismissible:u}),null==a||a(e,!0);return}if("bottom"===w||"right"===w?l>0:l<0){ep(),null==a||a(e,!0);return}if(s>.4){eh(),null==a||a(e,!1);return}let d=Math.min(null!=(t=Z.current.getBoundingClientRect().height)?t:0,window.innerHeight),f=Math.min(null!=(n=Z.current.getBoundingClientRect().width)?n:0,window.innerWidth);if(Math.abs(r)>=("left"===w||"right"===w?f:d)*c){eh(),null==a||a(e,!1);return}null==a||a(e,!0),ep()},onDrag:function(e){if(Z.current&&_){let t="bottom"===w||"right"===w?1:-1,n=(K.current-(eni(w)?e.pageY:e.pageX))*t,a=n>0,o=i&&!u&&!a;if(o&&0===er)return;let s=Math.abs(n),c=document.querySelector("[data-vaul-drawer-wrapper]"),d=s/("bottom"===w||"top"===w?J.current:Q.current),f=ec(s,a);if(null!==f&&(d=f),o&&d>=1||!W.current&&!ef(e.target,a))return;if(Z.current.classList.add(enc),W.current=!0,ena(Z.current,{transition:"none"}),ena(F.current,{transition:"none"}),i&&el({draggedDistance:n}),a&&!i){let e=Math.min(-(8*(Math.log(n+1)-2)*1),0)*t;ena(Z.current,{transform:eni(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`});return}let p=1-d;if((es||h&&er===h-1)&&(null==r||r(e,d),ena(F.current,{opacity:`${p}`,transition:"none"},!0)),c&&F.current&&l){let e=Math.min(eu()+d*(1-eu()),1),t=8-8*d,n=Math.max(0,14-14*d);ena(c,{borderRadius:`${t}px`,transform:eni(w)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:"none"},!0)}if(!i){let e=s*t;ena(Z.current,{transform:eni(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:X,handleOnly:f,isOpen:I,isDragging:_,shouldFade:es,closeDrawer:eh,onNestedDrag:function(e,t){if(t<0)return;let n=(window.innerWidth-16)/window.innerWidth,r=n+t*(1-n),a=-16+16*t;ena(Z.current,{transform:eni(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){let t=e?(window.innerWidth-16)/window.innerWidth:1,n=e?-16:0;q.current&&window.clearTimeout(q.current),ena(Z.current,{transition:`transform 0.5s cubic-bezier(${ens.join(",")})`,transform:eni(w)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&Z.current&&(q.current=setTimeout(()=>{let e=eno(Z.current,w);ena(Z.current,{transition:"none",transform:eni(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){let n=eni(w)?window.innerHeight:window.innerWidth,r=t?(n-16)/n:1,a=t?-16:0;t&&ena(Z.current,{transition:`transform 0.5s cubic-bezier(${ens.join(",")})`,transform:eni(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`})},keyboardIsOpen:G,modal:v,snapPointsOffset:eo,activeSnapPointIndex:er,direction:w,shouldScaleBackground:l,setBackgroundColorOnScale:s,noBodyStyles:b,container:E,autoFocus:O}},n))},env=function(e){let t=etJ(),{container:n=t.container,...r}=e;return ew.default.createElement(dM,{container:n,...r})};function enx({className:e,...t}){return(0,ey.jsx)(enp,{"data-slot":"drawer-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function eny({className:e,children:t,...n}){return(0,ey.jsxs)(env,{"data-slot":"drawer-portal",children:[(0,ey.jsx)(enx,{}),(0,ey.jsxs)(enm,{"data-slot":"drawer-content",className:(0,eI.cn)("vtl-surface-modal group/drawer-content fixed z-50 flex h-auto flex-col border outline-none","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-t-0","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-b-0","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-r-0 data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-l-0 data-[vaul-drawer-direction=left]:sm:max-w-sm",e),...n,children:[(0,ey.jsx)("div",{className:"mx-auto mt-3 hidden h-1.5 w-16 shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),t]})]})}function enb({className:e,...t}){return(0,ey.jsx)(dL,{"data-slot":"drawer-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function enw({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:a,onOpenConversation:i,onOpenConversationSettings:o,onConversationDeleted:l,onAccountSettings:s,subagentTree:c,activeSubagentPath:d,onOpenSubagent:u,title:f,trailing:h}){let[p,m]=ew.useState(!1),g=ew.useCallback(()=>m(!1),[]),v=ew.useCallback(e=>{g(),a(e)},[g,a]),x=ew.useCallback((e,t)=>{g(),i(e,t)},[g,i]),y=ew.useCallback(e=>{g(),u?.(e)},[g,u]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(enj,{onMenuClick:()=>m(!0),title:f,trailing:h}),(0,ey.jsx)(eng,{open:p,onOpenChange:m,direction:"left",children:(0,ey.jsxs)(eny,{className:"w-[85vw] max-w-xs",children:[(0,ey.jsx)(enb,{className:"sr-only",children:"导航"}),(0,ey.jsx)(etM,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:v,onOpenConversation:x,onOpenCanvas:()=>{},onOpenConversationSettings:(e,t)=>{g(),o?.(e,t)},onConversationDeleted:l,onAccountSettings:()=>{g(),s?.()},subagentTree:c,activeSubagentPath:d,onOpenSubagent:y,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})})]})}function enj({onMenuClick:e,title:t,trailing:n,className:r}){return(0,ey.jsxs)("header",{className:(0,eI.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,ey.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,ey.jsx)(s2,{})}),t?(0,ey.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,ey.jsx)("div",{className:"min-w-0 flex-1"}),(0,ey.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let enk=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),enS=[{id:"canvas",label:JD.canvas,icon:(0,ey.jsx)(ug,{})},{id:"agent",label:"智能体",icon:(0,ey.jsx)(um,{})},{id:"settings",label:JD.settings,icon:(0,ey.jsx)(Jq,{})}],enN=[{id:"canvas",title:JD.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:JD.canvas,items:[{id:"open-recent-canvas",label:JD.canvasRecent,icon:(0,ey.jsx)(ug,{})},{id:"new-canvas",label:JD.canvasNew,icon:(0,ey.jsx)(lJ,{})},{id:"all-canvases",label:JD.canvasAll,icon:(0,ey.jsx)(uy,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:JD.conversationRecent,icon:(0,ey.jsx)(enk,{})},{id:"new-agent-conversation",label:JD.conversationNew,icon:(0,ey.jsx)(um,{})}]}]},{id:"settings",title:JD.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,ey.jsx)(Jq,{})}]}]}],enC=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),enM=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),enE=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),enO=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function enP(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=tl(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[h,p]=ew.useState(""),[m,g]=ew.useState(!1),[v,x]=ew.useState(null);async function y(){o(!0);try{await eJ("online");let e=eW();d(e),await a()}catch{}finally{o(!1)}}async function b(){let e=h.trim();if(!e)return void x("名称不能为空");g(!0),x(null);try{let t=await e0(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){x(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsx)("div",{className:"flex items-center justify-between gap-3","data-tour":"hub-account",children:(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"Vantaloom Hub 账户"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"管理你的 Hub 连接和设备绑定"})]})}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,ey.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,ey.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,ey.jsxs)(F3,{variant:"outline",className:"shrink-0",children:[(0,ey.jsx)(jb,{className:"mr-1 size-3"}),"已验证"]})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:y,disabled:i,children:[i?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(x1,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(ez,{value:h,onChange:e=>p(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&b(),"Escape"===e.key&&f(!1)}}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void b(),disabled:m,"aria-label":"保存名称",children:m?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(pR,{})}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:m,"aria-label":"取消",children:(0,ey.jsx)(fc.XIcon,{})})]}):(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,ey.jsx)("button",{type:"button",onClick:function(){p(c?.name??""),x(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,ey.jsx)(V6,{className:"size-3.5"})})]}),(0,ey.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,ey.jsxs)(F3,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,ey.jsx)(enE,{className:"size-3"}):(0,ey.jsx)(enO,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),v?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:v}):null,(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,ey.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,ey.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,ey.jsx)(enO,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsxs)("div",{children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,ey.jsx)(enA,{}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,ey.jsxs)(dQ,{children:[(0,ey.jsx)(d0,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,ey.jsx)(enM,{}),"解除绑定"]})}),(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"确认解除设备绑定?"}),(0,ey.jsx)(uu,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,ey.jsx)(eto,{}),"退出登录"]})]})]})]})})}):null}function enA(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await e1(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(enC,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(ez,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,ey.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsx)(eA.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}var enI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,l1.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),enz=ew.forwardRef((e,t)=>(0,ey.jsx)(enI.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function enT({className:e,...t}){return(0,ey.jsx)(enz,{"data-slot":"label",className:(0,eI.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}enz.displayName="Label";var enD=["PageUp","PageDown"],en_=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],enR={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},enL="Slider",[en$,enF,enB]=h$(enL),[enV,enH]=s7(enL,[enB]),[enU,enW]=enV(enL),enq=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:h=!1,form:p,...m}=e,g=ew.useRef(new Set),v=ew.useRef(0),x="horizontal"===o,[y=[],b]=co({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[v.current]?.focus(),u(e)}}),w=ew.useRef(y);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=pV(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);b((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{v.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,ey.jsx)(enU,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:v,thumbs:g.current,values:y,orientation:o,form:p,children:(0,ey.jsx)(en$.Provider,{scope:e.__scopeSlider,children:(0,ey.jsx)(en$.Slot,{scope:e.__scopeSlider,children:(0,ey.jsx)(x?enX:enY,{"aria-disabled":l,"data-disabled":l?"":void 0,...m,ref:t,onPointerDown:ce(m.onPointerDown,()=>{l||(w.current=y)}),min:r,max:a,inverted:h,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(y,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=enD.includes(e.key)||e.shiftKey&&en_.includes(e.key),r=v.current;j(y[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});enq.displayName=enL;var[enK,enG]=enV(enL,{startEdge:"left",endEdge:"right",size:"width",direction:1}),enX=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),h=(0,s9.useComposedRefs)(t,e=>f(e)),p=ew.useRef(void 0),m=hU(a),g="ltr"===m,v=g&&!i||!g&&i;function x(e){let t=p.current||u.getBoundingClientRect(),a=en8([0,t.width],v?[n,r]:[r,n]);return p.current=t,a(e-t.left)}return(0,ey.jsx)(enK,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,ey.jsx)(enZ,{dir:m,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);o?.(t)},onSlideMove:e=>{let t=x(e.clientX);l?.(t)},onSlideEnd:()=>{p.current=void 0,s?.()},onStepKeyDown:e=>{let t=enR[v?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),enY=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,s9.useComposedRefs)(t,d),f=ew.useRef(void 0),h=!a;function p(e){let t=f.current||d.current.getBoundingClientRect(),a=en8([0,t.height],h?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,ey.jsx)(enK,{scope:e.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:(0,ey.jsx)(enZ,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=p(e.clientY);i?.(t)},onSlideMove:e=>{let t=p(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=enR[h?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),enZ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=enW(enL,n);return(0,ey.jsx)(cd.span,{...c,ref:t,onKeyDown:ce(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):enD.concat(en_).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:ce(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:ce(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:ce(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),enJ="SliderTrack",enQ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=enW(enJ,n);return(0,ey.jsx)(cd.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});enQ.displayName=enJ;var en0="SliderRange",en1=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=enW(en0,n),i=enG(en0,n),o=ew.useRef(null),l=(0,s9.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>en6(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,ey.jsx)(cd.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});en1.displayName=en0;var en2="SliderThumb",en5=ew.forwardRef((e,t)=>{let n=enF(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,s9.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,ey.jsx)(en4,{...e,ref:i,index:o})}),en4=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,h=enW(en2,c),p=enG(en2,c),[m,g]=ew.useState(null),v=(0,s9.useComposedRefs)(t,e=>g(e)),x=!m||h.form||!!m.closest("form"),y=mY(m),b=h.values[d],w=void 0===b?0:en6(b,h.min,h.max),j=(n=d,(r=h.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=y?.[p.size],S=k?(a=k,i=w,o=p.direction,s=en8([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(m)return h.thumbs.add(m),()=>{h.thumbs.delete(m)}},[m,h.thumbs]),(0,ey.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[p.startEdge]:`calc(${w}% + ${S}px)`},children:[(0,ey.jsx)(en$.ItemSlot,{scope:e.__scopeSlider,children:(0,ey.jsx)(cd.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":h.min,"aria-valuenow":b,"aria-valuemax":h.max,"aria-orientation":h.orientation,"data-orientation":h.orientation,"data-disabled":h.disabled?"":void 0,tabIndex:h.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:ce(e.onFocus,()=>{h.valueIndexToChangeRef.current=d})})}),x&&(0,ey.jsx)(en3,{name:u??(h.name?h.name+(h.values.length>1?"[]":""):void 0),form:h.form,value:b},d)]})});en5.displayName=en2;var en3=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,s9.useComposedRefs)(a,r),o=gi(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,ey.jsx)(cd.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function en6(e,t,n){return pV(100/(n-t)*(e-t),[0,100])}function en8(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function en7(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function en9({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>en7(n)??en7(t)??[r,a],[t,a,r,n]);return(0,ey.jsxs)(enq,{"data-slot":"slider",defaultValue:en7(t),value:en7(n),min:r,max:a,className:(0,eI.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,ey.jsx)(enQ,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,ey.jsx)(en1,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,ey.jsx)(en5,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}en3.displayName="RadioBubbleInput";let ere=[1e4,3e4,12e4,3e5,6e5];function ert(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??20,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[]}}}function ern(e){return(e&&e.length?e:ere).map(e=>Math.round(e/1e3)).join(", ")}function err(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,h]=ew.useState("");function p(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0)}async function m(){if(e&&!o){l(!0),c("");try{let n=await w3({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});t(ert(n)),h(ern(n.behavior?.retryDelaysMs)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([w4(),vC()]);t(ert(e)),h(ern(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"代理配置"})}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void m(),disabled:o,children:[(0,ey.jsx)(KR,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"错误"}),(0,ey.jsx)(Ja,{children:s})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"自动压缩阈值"}),(0,ey.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,ey.jsx)(en9,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>p("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"压缩模型"}),(0,ey.jsx)(era,{models:n,value:e.compression.modelRef,onValueChange:e=>p("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"对话标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,ey.jsx)(xR,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>p("summary",{enableTitleSummary:e})})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"轮次标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,ey.jsx)(xR,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>p("summary",{enableRoundSummary:e})})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(era,{models:n,value:e.summary.modelRef,onValueChange:e=>p("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"最大工具调用次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>p("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次。默认 20。"})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"自动重试次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>p("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,ey.jsx)(ez,{value:f,onChange:e=>{let t=e.currentTarget.value;h(t),p("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"审批模型"}),(0,ey.jsx)(era,{models:n,value:e.approval.modelRef,onValueChange:e=>p("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"审批提示词"}),(0,ey.jsx)(bq,{value:e.approval.prompt,onChange:e=>p("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})]}):(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"读取失败"}),(0,ey.jsx)(Ja,{children:s||"无法加载代理配置"})]})}function era({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.label},e.id))]})]})}let eri=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var ero="Accordion",erl=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[ers,erc,erd]=h$(ero),[eru,erf]=s7(ero,[erd,etm]),erh=etm(),erp=ew.default.forwardRef((e,t)=>{let{type:n,...r}=e;return(0,ey.jsx)(ers.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,ey.jsx)(erb,{...r,ref:t}):(0,ey.jsx)(ery,{...r,ref:t})})});erp.displayName=ero;var[erm,erg]=eru(ero),[erv,erx]=eru(ero,{collapsible:!1}),ery=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,s]=co({prop:n,defaultProp:r??"",onChange:a,caller:ero});return(0,ey.jsx)(erm,{scope:e.__scopeAccordion,value:ew.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:s,onItemClose:ew.default.useCallback(()=>i&&s(""),[i,s]),children:(0,ey.jsx)(erv,{scope:e.__scopeAccordion,collapsible:i,children:(0,ey.jsx)(erk,{...o,ref:t})})})}),erb=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,l]=co({prop:n,defaultProp:r??[],onChange:a,caller:ero}),s=ew.default.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=ew.default.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return(0,ey.jsx)(erm,{scope:e.__scopeAccordion,value:o,onItemOpen:s,onItemClose:c,children:(0,ey.jsx)(erv,{scope:e.__scopeAccordion,collapsible:!0,children:(0,ey.jsx)(erk,{...i,ref:t})})})}),[erw,erj]=eru(ero),erk=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:r,dir:a,orientation:i="vertical",...o}=e,l=ew.default.useRef(null),s=(0,s9.useComposedRefs)(l,t),c=erc(n),d="ltr"===hU(a),u=ce(e.onKeyDown,e=>{if(!erl.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),a=n.length;if(-1===r)return;e.preventDefault();let o=r,l=a-1,s=()=>{(o=r+1)>l&&(o=0)},u=()=>{(o=r-1)<0&&(o=l)};switch(e.key){case"Home":o=0;break;case"End":o=l;break;case"ArrowRight":"horizontal"===i&&(d?s():u());break;case"ArrowDown":"vertical"===i&&s();break;case"ArrowLeft":"horizontal"===i&&(d?u():s());break;case"ArrowUp":"vertical"===i&&u()}let f=o%a;n[f].ref.current?.focus()});return(0,ey.jsx)(erw,{scope:n,disabled:r,direction:a,orientation:i,children:(0,ey.jsx)(ers.Slot,{scope:n,children:(0,ey.jsx)(cd.div,{...o,"data-orientation":i,ref:s,onKeyDown:r?void 0:u})})})}),erS="AccordionItem",[erN,erC]=eru(erS),erM=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:r,...a}=e,i=erj(erS,n),o=erg(erS,n),l=erh(n),s=ca(),c=r&&o.value.includes(r)||!1,d=i.disabled||e.disabled;return(0,ey.jsx)(erN,{scope:n,open:c,disabled:d,triggerId:s,children:(0,ey.jsx)(etx,{"data-orientation":i.orientation,"data-state":erT(c),...l,...a,ref:t,disabled:d,open:c,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})});erM.displayName=erS;var erE="AccordionHeader",erO=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erj(ero,n),i=erC(erE,n);return(0,ey.jsx)(cd.h3,{"data-orientation":a.orientation,"data-state":erT(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});erO.displayName=erE;var erP="AccordionTrigger",erA=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erj(ero,n),i=erC(erP,n),o=erx(erP,n),l=erh(n);return(0,ey.jsx)(ers.ItemSlot,{scope:n,children:(0,ey.jsx)(etb,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...r,ref:t})})});erA.displayName=erP;var erI="AccordionContent",erz=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erj(ero,n),i=erC(erI,n),o=erh(n);return(0,ey.jsx)(etj,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function erT(e){return e?"open":"closed"}function erD({...e}){return(0,ey.jsx)(erp,{"data-slot":"accordion",...e})}function er_({className:e,...t}){return(0,ey.jsx)(erM,{"data-slot":"accordion-item",className:(0,eI.cn)("border-b last:border-b-0",e),...t})}function erR({className:e,children:t,...n}){return(0,ey.jsx)(erO,{className:"flex",children:(0,ey.jsxs)(erA,{"data-slot":"accordion-trigger",className:(0,eI.cn)("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,(0,ey.jsx)(g8,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"})]})})}function erL({className:e,children:t,...n}){return(0,ey.jsx)(erz,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-out data-[state=open]:animate-in",...n,children:(0,ey.jsx)("div",{className:(0,eI.cn)("pb-4 pt-0 text-muted-foreground",e),children:t})})}erz.displayName=erI;let er$={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"};function erF(e){return{...e.claudeCode??{}}}function erB(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function erV(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,h]=ew.useState(""),[p,m]=ew.useState(!1);async function g(){if(!d){u(!0),h("");try{let e=(await w8()).engines??[];r(e),t(t=>t?erB(t,e):t)}catch(e){h(e instanceof Error?e.message:"适配器安装失败")}finally{u(!1)}}}function v(e){t(t=>t?{...t,...e}:t),m(!0)}ew.useEffect(()=>{!async function(){try{let[e,n,a]=await Promise.all([w4(),w6(),vC()]),o=n.engines??[];t(erB(erF(e),o)),r(o),i(a.models)}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]);let x=e?.adapterArgs?.[0]??"";async function y(){if(e&&!s){c(!0),h("");try{let n=await w3({claudeCode:e});t(erF(n)),m(!1)}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}return o?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"CC 引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"配置 Claude Code / reclaude 引擎。展开下方分组按需修改,留空项将自动发现。"})]}),p&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void y(),disabled:s,children:[(0,ey.jsx)(KR,{className:"size-4"}),s?"保存中":"保存"]})]}),f?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"错误"}),(0,ey.jsx)(Ja,{children:f})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void g(),disabled:d,children:[d?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):(0,ey.jsx)(xB,{className:"size-4"}),d?"安装中…":"下载/安装适配器"]})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 需要 ACP 适配器。运行时不再内置它(以减小体积), 点击上方按钮即可在后台静默下载安装;安装后无需手填路径即可使用。"}),(0,ey.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,ey.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:er$[e.engine]??e.engine}),(0,ey.jsxs)("span",{className:(0,eI.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,ey.jsx)(eO,{}):(0,ey.jsx)(eri,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),(0,ey.jsx)("section",{className:"rounded-lg border bg-card px-4",children:(0,ey.jsxs)(erD,{type:"multiple",className:"w-full",children:[(0,ey.jsxs)(er_,{value:"adapter",children:[(0,ey.jsx)(erR,{children:"适配器"}),(0,ey.jsxs)(erL,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"适配器命令"}),(0,ey.jsx)(ez,{value:e.adapterCommand??"",onChange:e=>v({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动使用 node 运行适配器。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"适配器入口 (…/@zed-industries/claude-code-acp/dist/index.js)"}),(0,ey.jsx)(ez,{value:x,onChange:e=>{let t=e.currentTarget.value;v({adapterArgs:t?[t]:[]})},placeholder:"…/@zed-industries/claude-code-acp/dist/index.js"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装或环境变量 VANTALOOM_CC_ADAPTER)。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"Git Bash 路径"}),(0,ey.jsx)(ez,{value:e.gitBashPath??"",onChange:e=>v({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"reclaude 可执行文件"}),(0,ey.jsx)(ez,{value:e.reclaudeExecutable??"",onChange:e=>v({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"reclaude 可执行文件(或 node shim)路径;自动发现到 reclaude 时会自动填入, 会通过内置 shim 启动。留空则自动发现。"})]})]})]}),(0,ey.jsxs)(er_,{value:"auth",children:[(0,ey.jsx)(erR,{children:"认证"}),(0,ey.jsxs)(erL,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"API Key"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.apiKey??"",onChange:e=>v({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用;留空可使用 claude /login 登录。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"OAuth Token"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.oauthToken??"",onChange:e=>v({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})]}),(0,ey.jsxs)(er_,{value:"summary",children:[(0,ey.jsx)(erR,{children:"摘要模型"}),(0,ey.jsx)(erL,{className:"grid gap-4 text-foreground",children:(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(erH,{models:a,value:e.summaryModelRef??"",onValueChange:e=>v({summaryModelRef:e}),placeholder:"使用默认"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})]})]})})]}):(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"读取失败"}),(0,ey.jsx)(Ja,{children:f||"无法加载引擎配置"})]})}function erH({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.label},e.id))]})]})}let erU=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,ey.jsx)(eti,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,ey.jsx)(HT,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,ey.jsx)(eP,{})}],erW=[{id:"left",label:"Agent 在左",icon:(0,ey.jsx)(s2,{})},{id:"right",label:"Agent 在右",icon:(0,ey.jsx)(s4,{})}];function erq(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");return ew.useEffect(()=>{let e=ZY();t(e.mode),r(e.agentSide)},[]),(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"布局排版"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局与 Agent 对话的位置,设置即时应用到所有会话。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:erU.map(n=>{let r=e===n.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),ZZ({mode:e})},className:(0,eI.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,ey.jsx)("span",{className:(0,eI.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:erW.map(e=>{let t=n===e.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),ZZ({agentSide:t})},className:(0,eI.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]})]})}let erK=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"}];function erG(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!0,editing:!1}}function erX(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vC();t(e.routes.map(erG))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vE({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds});l(t,()=>erG(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vO(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vC();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,error:r.lastError??""}:e):[erG(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"模型路由"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加模型路由"]})]}),a?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"读取失败"}),(0,ey.jsx)(Ja,{children:a})]}):null,n?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,ey.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,ey.jsx)(erY,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{c(t)}},e.id??`draft-${t}`))})]})}function erY({draft:e,onDraftChange:t,onSave:n,onDelete:r}){let a=ew.useRef(e),i=ew.useRef(t),o=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),l=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),s=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;function c(n){t({...e,...n})}if(ew.useEffect(()=>{a.current=e,i.current=t},[e,t]),ew.useEffect(()=>{if(!l)return;let e=window.setTimeout(async()=>{let e=a.current;i.current({...e,loadingModels:!0,error:""});try{let t=await vM({providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey}),n=e.selectedModelIds.filter(e=>t.models.some(t=>t.id===e));i.current({...e,models:t.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(t){i.current({...e,loadingModels:!1,error:t instanceof Error?t.message:"模型拉取失败"})}},650);return()=>window.clearTimeout(e)},[l,o]),!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=erK.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,ey.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,ey.jsx)(lK,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,ey.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n})]}),(0,ey.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),e.builtin?null:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>c({editing:!0}),children:[(0,ey.jsx)(V6,{className:"size-4"}),"编辑"]})]})}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,ey.jsx)(ez,{value:e.providerName,placeholder:"提供商名称",onChange:e=>c({providerName:e.currentTarget.value})}),(0,ey.jsxs)(gb,{value:e.protocol,onValueChange:e=>c({protocol:e}),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:erK.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,ey.jsx)(ez,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",onChange:e=>c({endpointUrl:e.currentTarget.value})}),(0,ey.jsx)(ez,{value:e.apiKey,type:"password",placeholder:e.savedKeyAvailable?"已保存,留空沿用":"API Key",onChange:e=>c({apiKey:e.currentTarget.value})})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,ey.jsx)(p_,{className:"size-4 text-muted-foreground"}),"可用模型"]}),e.loadingModels?(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null]}),e.models.length>0?(0,ey.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.models.map(t=>{let n=e.selectedModelIds.includes(t.id);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-8 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,ey.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,ey.jsx)(vN,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void c({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,ey.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(ez,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void c({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]})]},t.id)})}):(0,ey.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"模型路由错误"}),(0,ey.jsx)(Ja,{className:"break-words",children:e.error})]}):null,(0,ey.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,ey.jsx)(x2,{className:"size-4"}),"删除"]}),(0,ey.jsx)(eA.Button,{type:"button",onClick:n,disabled:!s,children:e.saving?"保存中":"保存"})]})]})}async function erZ(){return erQ("/api/local/subagent-config")}async function erJ(e){return erQ("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function erQ(e,t){let n=await fetch(eD(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function er0(e){return{explore:{...e.explore},workflow:{...e.workflow},operator:{...e.operator},custom:{...e.custom,models:[...e.custom.models??[]]}}}let er1={explore:{title:"探索子代理",icon:(0,ey.jsx)(Vo,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,ey.jsx)(uk,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,ey.jsx)(uj,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function er2(){let[e,t]=ew.useState(null),{models:n,loading:r}=vI(),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1);async function f(){if(e&&!o){l(!0),c("");try{let n=await erJ({explore:e.explore,workflow:e.workflow,operator:e.operator,custom:e.custom});t(er0(n)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await erZ();t(er0(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"子代理配置"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"主 agent 可以派发这些子代理来分担任务。每个子代理拥有独立上下文与受限工具集,完成后只把结果汇报给主 agent。"})]}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:o,children:[(0,ey.jsx)(KR,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"错误"}),(0,ey.jsx)(Ja,{children:s})]}):null,["explore","workflow","operator"].map(a=>(0,ey.jsx)(er5,{tourId:`subagent-${a}`,meta:er1[a],value:e[a],models:n,modelsLoading:r,onChange:e=>{t(t=>t?{...t,[a]:{...t[a],...e}}:t),u(!0)}},a)),(0,ey.jsx)(er4,{value:e.custom,models:n,modelsLoading:r,onChange:function(e){t(t=>t?{...t,custom:{...t.custom,...e}}:t),u(!0)}})]}):(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"读取失败"}),(0,ey.jsx)(Ja,{children:s||"无法加载子代理配置"})]})}function er5({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:e.tint,children:e.icon}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,ey.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"使用模型"}),(0,ey.jsx)(er3,{models:n,value:t.modelRef,onValueChange:e=>a({modelRef:e}),placeholder:r?"读取模型中":"继承上级模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"允许上级指定模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,ey.jsx)(xR,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,ey.jsx)(bq,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function er4({value:e,models:t,modelsLoading:n,onChange:r}){let a=ew.useCallback(e=>t.find(t=>t.value===e)?.label??e,[t]);return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,ey.jsx)(um,{className:"size-4"})}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,ey.jsx)(Q5,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enT,{className:"text-sm",children:"可用模型池"}),(0,ey.jsx)(x_,{variant:"list-combobox",value:e.models,onValueChange:e=>r({models:e}),options:t,placeholder:n?"读取模型中":"选择可供自定义子代理使用的模型",searchPlaceholder:"搜索模型...",emptyText:"没有可用模型",renderItem:a}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function er3({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))]})]})}function er6(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState("");async function d(){if(!a){i(!0),c("");try{await w3({systemPrompt:{userPrompt:e}}),l(!1)}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return(ew.useEffect(()=>{(async()=>{try{let e=await w4();t(e.systemPrompt?.userPrompt??"")}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}})()},[]),n)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取系统提示词配置"}):(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"兜底系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅对 vantaloom 引擎对话生效。当某个对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也没有在该对话的“系统提示词”里单独设置时, 才使用这里的内容作为兜底。各对话独立的系统提示词请到对话设置 → 系统提示词中配置。"})]}),o?(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void d(),disabled:a,children:[(0,ey.jsx)(KR,{className:"size-4"}),a?"保存中":"保存"]}):null]}),s?(0,ey.jsxs)(Jn,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Jr,{children:"错误"}),(0,ey.jsx)(Ja,{children:s})]}):null,(0,ey.jsx)(bq,{value:e,onChange:e=>{t(e.currentTarget.value),l(!0)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"})]})}function er8({section:e}={}){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"agent-config"===e?(0,ey.jsx)(err,{}):"subagent-config"===e?(0,ey.jsx)(er2,{}):"cc-engine-config"===e?(0,ey.jsx)(erV,{}):"system-prompt"===e?(0,ey.jsx)(er6,{}):"layout"===e?(0,ey.jsx)(erq,{}):(0,ey.jsx)(erX,{})})})}let er7=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function er9(e,t){if(e.isLocal)return eD(t);let n=t.replace(/^\/v1(?=\/)/,"");return eD(`/v1/remote/${e.id}${n}`)}async function eae(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function eat(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(er9(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await eae(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(er9(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,ey.jsx)("div",{className:"h-full overflow-auto px-6 py-8","data-tour":"check-update",children:(0,ey.jsxs)("div",{className:"mx-auto flex max-w-3xl flex-col gap-5",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h1",{className:"text-xl font-semibold",children:"检查更新"}),(0,ey.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:()=>void o(),disabled:n,children:[(0,ey.jsx)(x1,{className:(0,eI.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,ey.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,ey.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,ey.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,ey.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,ey.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,ey.jsx)("span",{className:"text-amber-600",children:e.error}):(0,ey.jsxs)(ey.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,ey.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,ey.jsxs)(ey.Fragment,{children:[" · 最新 ",(0,ey.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,ey.jsxs)(ey.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,ey.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,ey.jsxs)(eA.Button,{size:"sm",onClick:()=>void l(e),children:[(0,ey.jsx)(er7,{className:"size-4"})," 立即更新"]}):e.info?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)(eO,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})})}let ean=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),ear=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),eaa=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eai(){let{user:e}=tl(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[h,p]=ew.useState([]),[m,g]=ew.useState(!0),[v,x]=ew.useState(""),[y,b]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e6())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e9().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e8(l,"all"===c?void 0:c).then(e=>{t||p(e.points)}).catch(()=>{t||p([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let S=ew.useMemo(()=>h.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[h]),N=ew.useMemo(()=>h.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[h,l]);async function C(){let e=v.trim();if(e){b(!0),j(null);try{let t=await e7(e);j({kind:"ok",text:`兑换成功,到账 ${e4(t.valueMicro)}`}),x(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{b(!1)}}}return e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"余额与用量"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(etf,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(x1,{}),"刷新"]})]}),i?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,ey.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e4(t?.balanceMicro??0,4)})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ean,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ez,{value:v,onChange:e=>x(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,ey.jsxs)(eA.Button,{className:"shrink-0",onClick:()=>void C(),disabled:y||!v.trim(),children:[y?(0,ey.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ear,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsxs)(gb,{value:c,onValueChange:d,children:[(0,ey.jsx)(g9,{size:"sm",className:"w-44",children:(0,ey.jsx)(gS,{placeholder:"全部模型"})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"all",children:"全部模型"}),u.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,ey.jsxs)(gb,{value:l,onValueChange:s,children:[(0,ey.jsx)(g9,{size:"sm",className:"w-32",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:eaa.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]})]}),(0,ey.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,ey.jsx)(eao,{label:"花费",value:e4(S.costMicro,4)}),(0,ey.jsx)(eao,{label:"请求数",value:S.requests.toLocaleString("zh-CN")}),(0,ey.jsx)(eao,{label:"Tokens",value:S.totalTokens.toLocaleString("zh-CN")})]}),(0,ey.jsx)("div",{className:"h-56 w-full",children:m&&0===h.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===N.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,ey.jsx)(Cn,{width:"100%",height:"100%",children:(0,ey.jsxs)(XJ,{data:N,margin:{top:8,right:8,left:0,bottom:0},children:[(0,ey.jsx)("defs",{children:(0,ey.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ey.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,ey.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,ey.jsx)(Yk,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,ey.jsx)(Y$,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,ey.jsx)(YY,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,ey.jsx)(BA,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,ey.jsx)(Xq,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]})}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(etf,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})})}function eao({label:e,value:t}){return(0,ey.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let eal=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eas=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),eac=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],ead=Object.fromEntries(eac.map(e=>[e.value,e.label])),eau={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function eaf(){let{user:e}=tl(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[h,p]=ew.useState(!1),m=ew.useRef(null),[g,v]=ew.useState([]),[x,y]=ew.useState(!0),[b,w]=ew.useState(null),j=ew.useCallback(async()=>{y(!0);try{let e=await tt();v(e.issues)}catch{v([])}finally{y(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function S(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await te({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await tn(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,ey.jsxs)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:[(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"问题反馈"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,ey.jsx)(ez,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,ey.jsxs)(gb,{value:r,onValueChange:a,children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:eac.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,ey.jsx)(bq,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",h?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>m.current?.click(),children:[(0,ey.jsx)(eal,{}),"添加图片"]}),(0,ey.jsx)("input",{ref:m,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,ey.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,ey.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,ey.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,ey.jsx)(fc.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsxs)(eA.Button,{onClick:()=>void S(),disabled:c||!t.trim(),children:[c?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(eas,{}),"提交反馈"]})})]}),(0,ey.jsxs)("section",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),x?(0,ey.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,ey.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=eau[e.status]??{label:e.status,variant:"secondary"};return(0,ey.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,ey.jsx)(F3,{variant:"outline",children:ead[e.type]??e.type}),(0,ey.jsx)(F3,{variant:t.variant,children:t.label})]})]}),e.content?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,ey.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,ey.jsx)(eap,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,ey.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]})]}),(0,ey.jsx)(dw,{open:null!==b,onOpenChange:e=>{e||w(null)},children:(0,ey.jsx)(fu,{className:"max-w-3xl",children:b?(0,ey.jsx)(eam,{issueId:b.issueId,imageId:b.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(jl,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})})}function eah(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tr(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function eap({issueId:e,imageId:t}){let n=eah(e,t);return n?(0,ey.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,ey.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function eam({issueId:e,imageId:t,className:n}){let r=eah(e,t);return r?(0,ey.jsx)("img",{src:r,alt:"",className:n}):(0,ey.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})})}let eag={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},eav={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function eax(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch(eD(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}function eay(){let e=eax("/api/local/machines/fleet",eag),{nodes:t,links:n}=e.topology;return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,ey.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"组网关系"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器的拓扑关系图(自动生成)。节点为机器,连线表示机器之间的连接方式与实时延迟。"}),(0,ey.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 p-4",children:0===t.length?(0,ey.jsx)("div",{className:"grid h-full place-items-center rounded-lg border border-dashed",children:(0,ey.jsx)("p",{className:"max-w-sm text-center text-sm text-muted-foreground",children:"暂未发现其它机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动绘制组网拓扑。"})}):(0,ey.jsx)("div",{className:"h-full overflow-hidden rounded-lg border bg-card",children:(0,ey.jsx)(eeP,{nodes:t,links:n})})}),(0,ey.jsx)("footer",{className:"shrink-0 border-t px-6 py-2",children:(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[(0,ey.jsx)("span",{children:"连接方式:"}),[{kind:"direct",label:"直连",className:"bg-foreground"},{kind:"p2p",label:"P2P",className:"bg-foreground"},{kind:"relay",label:"中继",className:"bg-muted-foreground"},{kind:"down",label:"断开",className:"bg-destructive"}].map(e=>(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:`h-0.5 w-4 rounded ${e.className}`}),e.label]},e.kind))]})})]})}let eab=["light","dark","jelly"],eaw={light:{label:"Light",icon:etd,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:etl,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,ey.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,ey.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,ey.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,ey.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,ey.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,ey.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function eaj(){let{resolvedTheme:e,setTheme:t}=(0,hw.useTheme)(),[n,r]=ew.useState(etN.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(etN.appearanceThemeStorageKey)??etN.defaultAppearanceTheme;r(e),(0,etN.applyAppearanceTheme)({theme:e})},[]);let a=n===etN.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=eab.indexOf(a),o=eab[(i+1)%eab.length]??"light",{icon:l,label:s,className:c}=eaw[a];function d(e){r(e),window.localStorage.setItem(etN.appearanceThemeStorageKey,e),(0,etN.applyAppearanceTheme)({theme:e})}return(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,eI.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${JT.theme}: ${s}`,title:`${JT.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(etN.jellyAppearanceTheme);return}d(etN.defaultAppearanceTheme),t(o)},children:(0,ey.jsx)(l,{})})}let eak=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);let eaS=(0,ek.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]),eaN=((0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]),(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]])),eaC=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],eaM=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],eaE=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],eaO=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],eaP={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function eaA(e,t,n=42,r){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?JI({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,ey.jsx)(J8,{label:e,value:t,minSize:n})})}function eaI(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let eaz={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},eaT=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("运行中","运行队列"),render:e=>eaA(e.title,"07",44,JE)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,ey.jsx)(up,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("排队","调度器"),render:e=>eaA(e.title,"04",44,JO)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,ey.jsx)(eaN,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("待确认","确认队列"),render:e=>eaA(e.title,"03",44,JP)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("Worker","Agent worker"),render:e=>eaA(e.title,"14",44,JA)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,ey.jsx)(eaS,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eaI("任务队列","运行队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(Jz,{title:e.title}),(0,ey.jsx)(eeT,{items:eaC})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eaI("Agent worker","Worker 状态"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(Jz,{title:e.title}),(0,ey.jsx)(ee_,{workers:eaM})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,ey.jsx)(Qt,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eaI("最近执行","执行日志"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(Jz,{title:e.title}),(0,ey.jsx)(eez,{items:eaO})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,ey.jsx)(Q2,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eaI("待确认","确认队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(Jz,{title:e.title}),(0,ey.jsx)(eeI,{items:eaE})]})}],eaD=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function ea_(e=eaz){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("在线机器","机器心跳"),render:t=>eaA(t.title,String(e.metrics.online),44,JE)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,ey.jsx)(eO,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("健康度","服务遥测"),render:t=>eaA(t.title,`${e.metrics.health}%`,44,JO)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,ey.jsx)(Qo,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("平均延迟","网络遥测"),render:t=>eaA(t.title,e.metrics.latency,44,JP)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,ey.jsx)(Q2,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaI("事件","事件流"),render:t=>eaA(t.title,String(e.metrics.events),44,JA)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eaI("机器健康矩阵","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:JI({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,ey.jsx)(Jz,{title:t.title}),(0,ey.jsx)(eeF,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,ey.jsx)(eak,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eaI("资源趋势","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(Jz,{title:t.title}),(0,ey.jsx)(eeW,{config:eaP,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,ey.jsx)(Jw,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eaI("网络连接","网络遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(Jz,{title:t.title}),(0,ey.jsx)(eeU,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,ey.jsx)(Q2,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eaI("事件流","事件流"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(Jz,{title:t.title}),(0,ey.jsx)(ee$,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eaI("服务健康","服务遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(Jz,{title:t.title}),(0,ey.jsx)(eeq,{services:e.serviceHealth})]})}]}ea_();let eaR=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],eaL={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function ea$({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,ey.jsx)(J5,{boardId:"runtime-operations",definitions:eaT,initialLayouts:eaD,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eaF({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=eax("/api/local/machines/telemetry",eav),a=ew.useMemo(()=>ea_(r),[r]);return(0,ey.jsx)(J5,{boardId:"telemetry",definitions:a,initialLayouts:eaR,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eaB({className:e,title:t="Vantaloom"}){return(0,ey.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,eI.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,ey.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,ey.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,ey.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,ey.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,ey.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,ey.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,ey.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,ey.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function eaV(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function eaH(e){return"u"<typeof document?null:document.querySelector(e)}function eaU(){return null!=eaH('[role="menu"]')}function eaW(){return null!=eaH('[data-tour="init-wizard"]')}function eaq(){let e=eaH('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=eaL){eaI("机器","机器组"),eaI("在线","机器心跳"),eaI("Runtime","Agent runtime"),eaI("Token","机器注册"),eaI("机器组","机器组"),eaI("拓扑图","网络拓扑"),eaI("直连","网络拓扑"),eaI("P2P","网络拓扑"),eaI("Relay","网络拓扑"),eaI("中断","网络拓扑"),eaI("延迟","网络遥测"),eaI("候选路径","网络候选路径")}(),eaI("日志与审计","审计事件"),eaI("筛选","审计筛选"),eaI("拒绝事件","审计事件"),eaI("事件趋势","审计事件");var eaK=e.i(64990);function eaG(){let e=sb(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,h]=ew.useState([]),[p,m]=ew.useState([]),[g,v]=ew.useState("conversation"),[x,y]=ew.useState(0),b=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{h([]),m([]),v("conversation")},[b]),ew.useEffect(()=>{let e;if(!b||"new-agent-conversation"!==a)return void m([]);let t=!1,n=async()=>{let r=await sz(b,w);t||(m(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[b,w,a]);let[j,k]=ew.useState(),[S,N]=ew.useState(!1),[C,M]=ew.useState([]),[E,O]=ew.useState([]),[P,A]=ew.useState({}),[I,z]=ew.useState(),[T,D]=ew.useState(uP),[_,R]=ew.useState([]),[L,$]=ew.useState(),[F,B]=ew.useState(),[V,H]=ew.useState(),U=ew.useRef(!1),W=ew.useCallback(e=>{D(t=>iQ(e,t))},[]),q=ew.useCallback(e=>{R(t=>iQ(e,t))},[]),K=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await s_(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sk){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await s_(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),G=ew.useCallback(async(e,t)=>{h([]),await K(e,t)},[K]),X=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),Y=ew.useCallback(async()=>{let e=await sP();e?await K(e.conversation.id,e.conversation.ownerMachineId):X()},[K,X]),Z=ew.useCallback(async()=>{U.current=!0,D(uP),R([]),i("new-canvas");try{let e=await Jf({title:"新画布",nodes:uP,edges:[]});B(e.canvas.id),H("local")}catch{B(void 0),H(void 0),U.current=!1}},[]),J=ew.useCallback(async(e,t)=>{try{await Jp(e,t);let n=await Ju(e,t);U.current=!0,D(n.nodes),R(n.edges),B(n.canvas.id),H(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]);ew.useEffect(()=>{if(!F)return;if(U.current){U.current=!1;return}let e=window.setTimeout(()=>{Jh(F,{nodes:T,edges:_,nodeIds:T.map(e=>e.id)},V).catch(()=>{})},800);return()=>window.clearTimeout(e)},[T,_,F,V]);let Q=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void Z();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void X();if("open-recent-conversation"===t.id)return void Y();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-model-routes"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-system-prompt"===t.id||"preferences-layout"===t.id||"network-topology"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[Z,e,Y,X]),{start:ee}=(0,eaK.useTour)(),et=ew.useCallback(()=>{var e;ee((e={select:e=>Q({item:{id:e}}),startNewConversation:X,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,ey.jsxs)(ey.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,ey.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,ey.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:eaV(()=>e.goHome()),target:()=>eaH('[role="menu"]')??eaH('[data-tour="account-button"]'),gate:eaU,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,ey.jsxs)(ey.Fragment,{children:["点击左下角的 ",(0,ey.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,ey.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,ey.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:eaV(()=>e.select("preferences-model-routes")),target:()=>eaH('[data-tour="model-route-form"]')??eaH('[data-tour="add-model-route"]'),gate:()=>null!=eaH('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["进入 ",(0,ey.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,ey.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:eaV(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["表单各项:",(0,ey.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,ey.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,ey.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,ey.jsx)("code",{children:"/v1"})," 这一级;",(0,ey.jsx)("b",{children:"API Key"})," 是密钥;",(0,ey.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,ey.jsx)("br",{}),"⚠️ 填完",(0,ey.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:eaV(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,ey.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:eaV(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"对话摘要"}),":开启后用",(0,ey.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:eaV(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,ey.jsx)("b",{children:"审批模型"})," + ",(0,ey.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,ey.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:eaV(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,ey.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,ey.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,ey.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:eaV(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:eaV(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:eaV(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,ey.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:eaV(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,ey.jsxs)(ey.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,ey.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,ey.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,ey.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:eaV(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,ey.jsx)("b",{children:"账户信息"}),"与",(0,ey.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:eaV(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,ey.jsxs)(ey.Fragment,{children:["下方的 ",(0,ey.jsx)("b",{children:"危险操作"})," 区可",(0,ey.jsx)("b",{children:"解除设备绑定"}),"或",(0,ey.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:eaV(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:eaW,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,ey.jsxs)(ey.Fragment,{children:["回到主页,请点 ",(0,ey.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!eaW()||eaq()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,ey.jsxs)(ey.Fragment,{children:["先选在",(0,ey.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,ey.jsx)("b",{children:"运行引擎"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," / ",(0,ey.jsx)("b",{children:"Claude Code"})," / ",(0,ey.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,ey.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaW()||eaq()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,ey.jsxs)(ey.Fragment,{children:["先给对话",(0,ey.jsx)("b",{children:"起个名字"}),",再选 ",(0,ey.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaW()||eaq()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,ey.jsxs)(ey.Fragment,{children:["选择这段对话使用的",(0,ey.jsx)("b",{children:"模型"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,ey.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaW(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,ey.jsxs)(ey.Fragment,{children:["核对无误后,点向导右下角的 ",(0,ey.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,ey.jsxs)(ey.Fragment,{children:["输入框下面一排:",(0,ey.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,ey.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,ey.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,ey.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,ey.jsxs)(ey.Fragment,{children:["输入内容后按 ",(0,ey.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,ey.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,ey.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,ey.jsxs)(ey.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,ey.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,ey.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=eaH('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,ey.jsxs)(ey.Fragment,{children:["在布局标签里点 ",(0,ey.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=eaH('[placeholder="搜索组件..."]')||null!=eaH('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["点",(0,ey.jsx)("b",{children:"上面板"}),"中间的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=eaH('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["在弹出面板里找到 ",(0,ey.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["顶部是",(0,ey.jsx)("b",{children:"多文件标签条"}),":点 ",(0,ey.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,ey.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,ey.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,ey.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=eaH('[placeholder="搜索组件..."]')||null!=eaH('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["现在点",(0,ey.jsx)("b",{children:"下面板"}),"的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=eaH('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,ey.jsxs)(ey.Fragment,{children:["在面板里找到 ",(0,ey.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,ey.jsxs)(ey.Fragment,{children:["终端支持多会话标签:点 ",(0,ey.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,ey.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,ey.jsxs)(ey.Fragment,{children:["顶栏的 ",(0,ey.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,ey.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,ey.jsxs)(ey.Fragment,{children:["点位置切换中间的 ",(0,ey.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,ey.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,ey.jsxs)(ey.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,ey.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[Q,X,ee]),en=ew.useCallback(()=>{i("account")},[]),er=d?.id??s?.conversation.id,ea=!!d&&s?.conversation.id!==d.id;return(0,ey.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground",children:[e?(0,ey.jsx)(enw,{navItems:enS,contents:enN,activeWorkspace:a,activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:p,activeSubagentPath:f,onOpenSubagent:e=>h(e),title:"new-agent-conversation"===a&&s?s.conversation.title?.trim()||"新 Agent 对话":JT.product,trailing:"new-agent-conversation"===a&&s?(0,ey.jsx)(jc,{view:g,onViewChange:v,paneCount:x}):(0,ey.jsx)(eaj,{})}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:(0,eI.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,ey.jsx)(etM,{navItems:enS,contents:enN,activeWorkspace:a,activeConversationId:er,activeCanvasId:F,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenCanvas:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:p,activeSubagentPath:f,onOpenSubagent:e=>h(e)})}),(0,ey.jsx)("div",{className:(0,eI.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,ey.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,ey.jsx)(tu,{className:"size-4"}):(0,ey.jsx)(td,{className:"size-4"})})})]}),(0,ey.jsxs)("section",{className:(0,eI.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,ey.jsx)(ea$,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"telemetry"===a?(0,ey.jsx)(eaF,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"preferences-model-routes"===a?(0,ey.jsx)(er8,{section:"model-routes"}):"preferences-agent-config"===a?(0,ey.jsx)(er8,{section:"agent-config"}):"preferences-subagent-config"===a?(0,ey.jsx)(er8,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,ey.jsx)(er8,{section:"cc-engine-config"}):"preferences-system-prompt"===a?(0,ey.jsx)(er8,{section:"system-prompt"}):"preferences-layout"===a?(0,ey.jsx)(er8,{section:"layout"}):"network-topology"===a?(0,ey.jsx)(eay,{}):"preferences"===a?(0,ey.jsx)(er8,{}):"check-update"===a?(0,ey.jsx)(eat,{}):"balance-usage"===a?(0,ey.jsx)(eai,{}):"feedback"===a?(0,ey.jsx)(eaf,{}):"account"===a?(0,ey.jsx)(enP,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-agent-conversation"===a&&ea?(0,ey.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-6 animate-spin"}),(0,ey.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a?(0,ey.jsx)(Z7,{conversation:s,clipboardItems:C,clipboardDraggingId:I,onClipboardItemsChange:M,onClipboardDraggingChange:z,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:h,subagentTree:p,mobileView:g,onMobilePaneCountChange:y}):e?(0,ey.jsx)(eaY,{activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,ey.jsx)(eaX,{onNewConversation:X,onStartTour:et}):(0,ey.jsx)(ee2,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):(0,ey.jsx)(ee9,{nodes:T,edges:_,selectedNodeId:L,clipboardItems:C,onNodesChange:W,onEdgesChange:q,onNodesSet:D,onEdgesSet:R,onSelectedNodeChange:$,onClipboardItemsChange:M}),j?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,ey.jsx)(Js,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{G(e,t)}})}):null,(0,ey.jsx)(etn,{hidden:!!j||("new-agent-conversation"===a?o:S),items:C,trashItems:E,draggingId:I,onDraggingChange:z,onItemsChange:M,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:P})]})]})}function eaX({onNewConversation:e,onStartTour:t}){return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,ey.jsx)(eaB,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,ey.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,ey.jsxs)(eA.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,ey.jsx)(tc,{className:"size-4"}),"新建对话"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",onClick:t,children:[(0,ey.jsx)(ts,{className:"size-4"}),"使用教程"]})]})]})}function eaY({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,ey.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,ey.jsx)(etI,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function eaZ(){let{ready:e,user:t,logout:n}=tl();return e?t?(0,ey.jsx)(eaG,{}):(0,ey.jsx)(ta,{onComplete:()=>{window.location.reload()}}):(0,ey.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ey.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function eaJ(){return(0,ey.jsx)(to,{children:(0,ey.jsx)(eaZ,{})})}e.s(["default",()=>eaJ],66204)}]);
52
+ </style>`,/<\/head>/i.test(t)?t.replace(/<\/head>/i,`${n}</head>`):`${n}${t}`},[r,t]);return(0,ey.jsx)("iframe",{title:e,sandbox:"allow-scripts",srcDoc:a,className:(0,eI.cn)("size-full border-0 bg-background",n)})}function KX({file:e,value:t,labels:n}){let r=ew.useMemo(()=>{let n=e.bytes??(t?new TextEncoder().encode(t):[]),r=Math.min(n.length,4096),a=[];for(let e=0;e<r;e+=16){let t=Array.from({length:Math.min(16,r-e)},(t,r)=>n[e+r]??0);a.push({offset:e.toString(16).padStart(8,"0"),hex:t.map(e=>e.toString(16).padStart(2,"0")).join(" "),ascii:t.map(e=>e>=32&&e<=126?String.fromCharCode(e):".").join("")})}return a},[e.bytes,t]);return 0===r.length?(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:n.noContent}):(0,ey.jsx)("div",{className:"size-full overflow-auto bg-background p-3 ui-text-code",children:(0,ey.jsx)("div",{className:"grid min-w-max grid-cols-[5.5rem_30rem_1fr] gap-x-4",children:r.map(e=>(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.offset}),(0,ey.jsx)("span",{className:"font-mono text-foreground",children:e.hex}),(0,ey.jsx)("span",{className:"font-mono text-muted-foreground",children:e.ascii})]},e.offset))})})}function KY({file:e,labels:t,onApprove:n}){return(0,ey.jsx)("div",{className:"grid size-full place-items-center bg-muted/20 p-6",children:(0,ey.jsxs)("div",{className:"grid max-w-md justify-items-center gap-3 text-center",children:[(0,ey.jsx)("div",{className:"grid size-10 place-items-center rounded-full border bg-background text-muted-foreground",children:(0,ey.jsx)(KI,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("h3",{className:"ui-text-body font-medium text-foreground",children:t.binaryTitle}),(0,ey.jsx)("p",{className:"ui-text-body text-muted-foreground",children:t.binaryDescription})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[KV(e.size)&&(0,ey.jsx)(F3,{variant:"outline",children:KV(e.size)}),(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"outline",onClick:n,children:t.renderAnyway})]})]})})}function KZ({labels:e}){return(0,ey.jsx)("div",{className:"ui-text-body grid size-full place-items-center p-6 text-center text-muted-foreground",children:e.unsupportedPreview})}function KJ({file:e,value:t,labels:n,renderPreview:r,className:a}){let i=KF(e),o=e.src?e.src:t&&"svg"===KF(e)?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`:void 0,l=r?.(e,t);return void 0!==l?(0,ey.jsx)("div",{"data-slot":"file-tab-custom-preview",className:(0,eI.cn)("size-full",a),children:l}):"html"===i||"richtext"===i?(0,ey.jsx)(KG,{title:e.name,value:e.previewContent??t,className:a}):"markdown"===i?(0,ey.jsx)("div",{"data-slot":"file-tab-markdown-preview",className:(0,eI.cn)("size-full overflow-auto bg-background",a),children:(0,ey.jsx)(KK,{value:t})}):"svg"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-svg-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-lg border bg-background p-4"})}):"image"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-image-preview",className:(0,eI.cn)("grid size-full place-items-center overflow-auto bg-muted/20 p-6",a),children:(0,ey.jsx)("img",{src:o,alt:e.name,className:"max-h-full max-w-full rounded-md"})}):"video"===i&&o?(0,ey.jsx)("div",{"data-slot":"file-tab-video-preview",className:(0,eI.cn)("grid size-full place-items-center bg-muted/20 p-6",a),children:(0,ey.jsx)("video",{src:o,controls:!0,preload:"none",className:"max-h-full max-w-full rounded-md border bg-background"})}):(0,ey.jsx)(KZ,{labels:n})}function KQ({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:h,onHistory:p}){let m=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,ey.jsx)(HF,{className:"size-4"}):(0,ey.jsx)(uv,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,ey.jsx)(Kz,{className:"size-4"}):(0,ey.jsx)(eS,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:h,disabled:a||!i,icon:(0,ey.jsx)(KR,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:p,icon:(0,ey.jsx)(KT,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===m.length?null:(0,ey.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[m.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function K0({file:e,value:t,defaultValue:n,onValueChange:r,mode:a,defaultMode:i="review",onModeChange:o,view:l,defaultView:s="code",onViewChange:c,modified:d=!1,onSave:u,onSaveError:f,largeBinaryThreshold:h=2097152,showHeader:p=!0,wrapLines:m=!1,renderPreview:g,onHistory:v,labels:x,className:y,editorClassName:b,previewClassName:w,headerClassName:j,...k}){var S;let N,C,M=ew.useMemo(()=>({...KL,...x}),[x]),[E,O]=ew.useState(n??e.content??""),[P,A]=ew.useState(i),[I,z]=ew.useState(s),[T,D]=ew.useState(!1),[_,R]=ew.useState(!1),[L,$]=ew.useState(!1),F=ew.useRef(null),B=t??E,V=a??P,H=(S=l??I,(N=KH(e)).includes(S)?S:N[0]),U=KF(e),W=KH(e).length>1,q=!e.readOnly&&["text","code","html","markdown","richtext","svg"].includes(KF(e)),K=!!u&&q&&"code"===H&&(d||L),G="review"===V||!0===e.readOnly,X="binary"===(C=KF(e))||"image"!==C&&"video"!==C&&!!(e.size&&e.size>h&&!e.content),Y=(e.path??e.name).split(/[\\/]+/).filter(Boolean),Z=KV(e.size??B.length);async function J(){if(u&&!L){$(!0);try{await u(B),R(!1)}catch(e){f?.(e)}finally{$(!1)}}}return ew.useEffect(()=>{void 0===t&&O(n??e.content??""),D(!1),R(!1)},[n,e,t]),ew.useEffect(()=>{if(_)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&F.current?.contains(t)||R(!1)}},[_]),(0,ey.jsxs)("div",{ref:F,"data-slot":"file-tab-viewer","data-mode":V,"data-view":H,className:(0,eI.cn)("vtl-surface-panel relative grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",p?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",y),...k,children:[p&&(0,ey.jsxs)("div",{"data-slot":"file-tab-viewer-header",className:(0,eI.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",j),children:[(0,ey.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:"image"===U?(0,ey.jsx)(KD,{className:"size-3.5"}):"video"===U?(0,ey.jsx)(K_,{className:"size-3.5"}):"binary"===U?(0,ey.jsx)(KI,{className:"size-3.5"}):(0,ey.jsx)(xW,{className:"size-3.5"})}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:Y.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[t>0&&(0,ey.jsx)("span",{className:"text-muted-foreground",children:M.pathSeparator}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",t===Y.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,ey.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[Z&&(0,ey.jsx)(F3,{variant:"outline",children:Z}),q&&"code"===H&&(G?(0,ey.jsxs)(F3,{variant:"secondary",children:[(0,ey.jsx)(lK,{className:"size-3"}),M.review]}):(0,ey.jsxs)(F3,{variant:"outline",children:[(0,ey.jsx)(Kz,{className:"size-3"}),M.edit]}))]})]}),(0,ey.jsx)("div",{"data-slot":"file-tab-viewer-body",className:"min-h-0 overflow-hidden",children:X&&!T?(0,ey.jsx)(KY,{file:e,labels:M,onApprove:()=>D(!0)}):"preview"===H?(0,ey.jsx)(KJ,{file:e,value:B,labels:M,renderPreview:g,className:w}):"hex"===H?(0,ey.jsx)(KX,{file:e,value:B,labels:M}):(0,ey.jsx)(Kq,{file:e,value:B,readOnly:G,onValueChange:function(e){void 0===t&&O(e),r?.(e)},wrapLines:m,className:b})}),(0,ey.jsx)(KQ,{open:_,labels:M,currentView:H,currentMode:V,saving:L,modified:d,canSwitchView:W,canSwitchMode:q&&"code"===H,canSave:K,canOpenHistory:!!(v&&e.path),onOpenChange:R,onToggleView:function(){var e;e="code"===H?"preview":"code",void 0===l&&z(e),c?.(e)},onToggleMode:function(){var e;e="review"===V?"edit":"review",void 0===a&&A(e),o?.(e)},onSave:J,onHistory:()=>{R(!1),v?.(e)}})]})}function K1(e,t){return e[Math.max(0,t-1)]?.id??e[0]?.id}function K2(e){return"string"==typeof e||"number"==typeof e?String(e):void 0}function K5(e,t,n){let r=[...e],a=r[t],i=r[n];return a&&i&&(r[t]=i,r[n]=a),r}function K4({tabs:e,defaultTabs:t=[],activeTabId:n,defaultActiveTabId:r,onActiveTabChange:a,onTabsChange:i,onCreateTab:o,onCloseTab:l,onTabReorder:s,onTabDetach:c,onExternalTabDrop:d,createActions:u=[],tabActions:f=[],reorderable:h=!0,detachable:p=!1,externalDropTypes:m=[],createLabel:g="New tab",moreLabel:v="More tab actions",closeLabel:x="Close tab",scrollLeftLabel:y="Scroll tabs left",scrollRightLabel:b="Scroll tabs right",tabListLabel:w="Open tabs",emptyContent:j,renderContent:k,showContent:S=!0,className:N,tabListClassName:C,contentClassName:M}){let[E,O]=ew.useState(t),P=ew.useRef(null),A=ew.useRef(null),[I,z]=ew.useState(),[T,D]=ew.useState(void 0),_=ew.useRef(void 0),[R,L]=ew.useState(void 0),[$,F]=ew.useState(!1),B=ew.useRef(void 0),V=ew.useRef(void 0),H=ew.useRef(!1),[U,W]=ew.useState(!1),[q,K]=ew.useState(!1),[G,X]=ew.useState(),Y=e??E,Z=Y.find(e=>!e.disabled),[J,Q]=ew.useState(r??Z?.id),ee=n??J,et=Y.find(e=>e.id===ee&&!e.disabled)??Z;ew.useEffect(()=>{!et&&Z&&void 0===n&&Q(Z.id)},[et,n,Z]);let en=ew.useCallback(t=>{void 0===e&&O(t),i?.(t)},[i,e]),er=ew.useCallback(e=>{_.current=e,D(e)},[]),ea=ew.useCallback(()=>{let e=A.current,t=new Map;if(!e)return t;for(let n of e.querySelectorAll("[data-tab-id]")){let e=n.getBoundingClientRect(),r=n.dataset.tabId;r&&t.set(r,{left:e.left,top:e.top})}return t},[]),ei=ew.useCallback((e,t=!0)=>{t&&(V.current=ea()),B.current=e,L(e)},[ea]),eo=ew.useCallback(()=>{let e=A.current;if(!e){W(!1),K(!1);return}let t=e.scrollWidth-e.clientWidth;W(e.scrollLeft>1),K(e.scrollLeft<t-1)},[]);function el(e){let t=A.current;if(!t)return;let n=Math.max(.7*t.clientWidth,160);t.scrollLeft+="left"===e?-n:n,window.requestAnimationFrame(eo)}ew.useEffect(()=>{F(!0)},[]),ew.useEffect(()=>{eo();let e=A.current;if(!e)return;let t=new ResizeObserver(eo);return t.observe(e),window.addEventListener("resize",eo),()=>{t.disconnect(),window.removeEventListener("resize",eo)}},[Y.length,eo]),ew.useLayoutEffect(()=>{let e=V.current,t=A.current;if(e&&t)for(let n of(V.current=void 0,t.querySelectorAll("[data-tab-id]"))){let t=n.dataset.tabId;if(!t)continue;let r=e.get(t);if(!r)continue;let a=n.getBoundingClientRect(),i=r.left-a.left,o=r.top-a.top;1>Math.abs(i)&&1>Math.abs(o)||n.animate([{transform:`translate(${i}px, ${o}px)`},{transform:"translate(0, 0)"}],{duration:150,easing:"cubic-bezier(0.2, 0, 0, 1)"})}},[R]);let es=ew.useCallback(e=>{let t=A.current;if(t)return Array.from(t.querySelectorAll("[data-tab-id]")).find(t=>t.dataset.tabId===e)},[]),ec=ew.useCallback((e,t)=>{let n=B.current??Y,r=n.findIndex(t=>t.id===e.tabId);if(-1===r)return;let a=t-e.offsetX,i=a+e.width,o=t>=e.currentX,l=n[r+1],s=n[r-1];if(o&&l&&!l.disabled){let e=es(l.id),t=e?.getBoundingClientRect();t&&i>=t.left+.7*t.width&&ei(K5(n,r,r+1));return}if(!o&&s&&!s.disabled){let e=es(s.id),t=e?.getBoundingClientRect();t&&a<=t.right-.7*t.width&&ei(K5(n,r,r-1))}},[es,Y,ei]);function ed(e){if(!d||0===m.length)return!1;let t=Array.from(e.dataTransfer.types);return m.some(e=>t.includes(e))}function eu(e){let t=A.current;if(!t)return{index:Y.length,left:0};let n=t.getBoundingClientRect(),r=Array.from(t.querySelectorAll("[data-tab-id]"));if(0===r.length)return{index:0,left:t.scrollLeft+8};for(let[a,i]of r.entries()){let r=i.getBoundingClientRect();if(e.clientX<r.left+r.width/2)return{index:a,left:r.left-n.left+t.scrollLeft}}let a=r[r.length-1].getBoundingClientRect();return{index:r.length,left:a.right-n.left+t.scrollLeft}}ew.useEffect(()=>{if(T)return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t,{once:!0}),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)};function e(e){let t=_.current;if(!t)return;let n=e.clientX-t.startX,r=e.clientY-t.startY,a=t.dragging||Math.abs(n)>4||Math.abs(r)>4;a&&(e.preventDefault(),ec(t,e.clientX)),er({...t,currentX:e.clientX,currentY:e.clientY,dragging:a})}function t(e){let t=_.current;if(t?.dragging){e.preventDefault(),H.current=!0;let r=Y.find(e=>e.id===t.tabId),i=P.current?.getBoundingClientRect(),o=!!i&&(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom);if(p&&c&&r&&o&&function(e,t){if(e.pinned)return!1;let r=Y.findIndex(t=>t.id===e.id);if(c?.(e,{tabs:Y,clientX:t.clientX,clientY:t.clientY,nativeEvent:t})===!1)return!1;let i=Y.filter(t=>t.id!==e.id);if(en(i),e.id===ee){let e=K1(i,r);void 0===n&&Q(e),e&&a?.(e)}return!0}(r,e)){z(void 0),er(void 0),ei(void 0,!1);return}let l=B.current;l&&!(l.length===Y.length&&l.every((e,t)=>e.id===Y[t]?.id))&&(en(l),s?.(l))}z(void 0),er(void 0),ei(void 0,!1)}});let ef=et&&(k?.(et)??et.content??(0,ey.jsx)("div",{className:"grid min-h-44 place-items-center bg-muted/30 p-6 text-center text-muted-foreground",children:et.title})),eh=T?.dragging&&R?R:Y,ep=T?.dragging?Y.find(e=>e.id===T.tabId):void 0,em=T?.dragging&&ep&&$?(0,iy.createPortal)((0,ey.jsxs)("div",{"data-slot":"multi-tab-drag-preview","aria-hidden":"true",className:"pointer-events-none fixed z-[100] flex h-9 min-w-0 items-center gap-1 rounded-t-lg border border-border bg-background px-2.5 text-foreground shadow-lg",style:{left:T.currentX-T.offsetX,top:T.top,width:T.width},children:[ep.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:ep.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:ep.title}),ep.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),document.body):null;return(0,ey.jsxs)("div",{ref:P,"data-slot":"multi-tab-system",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--surface-panel-radius)] border",N),children:[(0,ey.jsxs)("div",{className:"relative flex min-w-0 shrink-0 items-end gap-1 border-b bg-muted/35 px-1.5 pt-1.5",children:[U&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":y,onClick:()=>el("left"),className:"mb-1 shrink-0",children:(0,ey.jsx)(pL,{})}),(0,ey.jsxs)("div",{ref:A,role:"tablist","aria-label":w,"data-slot":"multi-tab-list",className:(0,eI.cn)("relative flex min-w-0 flex-1 items-end overflow-x-auto [scrollbar-width:none] data-[overflow=both]:[mask-image:linear-gradient(90deg,transparent,black_24px,black_calc(100%-24px),transparent)] data-[overflow=left]:[mask-image:linear-gradient(90deg,transparent,black_24px)] data-[overflow=right]:[mask-image:linear-gradient(90deg,black_calc(100%-24px),transparent)] [&::-webkit-scrollbar]:hidden",C),"data-overflow":U&&q?"both":U?"left":q?"right":void 0,onScroll:eo,onDragOver:function(e){ed(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",X(eu(e)))},onDragLeave:function(e){if(!ed(e))return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||X(void 0)},onDrop:function(e){if(!ed(e))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=eu(e);X(void 0),d?.({tabs:Y,insertIndex:t.index,nativeEvent:e})},children:[eh.map((e,t)=>{let r=e.id===et?.id,i=eh[t+1],o=T?.dragging&&I===e.id,s=!r&&!o&&void 0!==i&&i.id!==et?.id&&i.id!==I;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsxs)("div",{onPointerDown:t=>(function(e,t){if(!h||e.disabled||0!==t.button)return;let n=t.currentTarget.getBoundingClientRect();z(e.id),ei(Y,!1),er({tabId:e.id,startX:t.clientX,startY:t.clientY,offsetX:t.clientX-n.left,top:n.top,width:n.width,currentX:t.clientX,currentY:t.clientY,dragging:!1})})(e,t),"data-slot":"multi-tab","data-tab-id":e.id,"data-state":r?"active":"inactive","data-dragging":I===e.id?"true":void 0,"data-modified":e.modified?"true":void 0,className:(0,eI.cn)("group/tab relative flex h-9 min-w-0 max-w-52 shrink-0 items-center gap-1 rounded-t-lg border border-b-0 px-2.5 transition-[border-color,background-color,color,box-shadow,outline-color] duration-150 ease-out",h&&!e.disabled&&"cursor-grab active:cursor-grabbing",r?"border-border bg-background text-foreground shadow-[0_-1px_0_var(--background)_inset]":"border-transparent bg-transparent text-muted-foreground hover:bg-background/70 hover:text-foreground",o&&"border-dashed border-border bg-muted/45 text-transparent shadow-none outline outline-1 outline-ring/30 [&_*]:opacity-0",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsx)("button",{type:"button",role:"tab","aria-label":K2(e.title),"aria-selected":r,disabled:e.disabled,onClick:t=>{var r;let i;if(H.current){H.current=!1,t.preventDefault();return}r=e.id,(i=Y.find(e=>e.id===r))&&!i.disabled&&(void 0===n&&Q(r),a?.(r))},className:"absolute inset-0 rounded-t-lg outline-none focus-visible:ring-2 focus-visible:ring-ring/50"}),(0,ey.jsxs)("div",{"aria-hidden":"true",className:"pointer-events-none relative z-10 flex min-w-0 flex-1 items-center gap-1.5",children:[e.icon&&(0,ey.jsx)("span",{className:"grid size-4 shrink-0 place-items-center text-muted-foreground [&_svg]:size-3.5",children:e.icon}),(0,ey.jsx)("span",{className:"truncate ui-text-control font-medium",children:e.title}),e.meta&&(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.meta}),e.modified&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-foreground/70"})]}),!e.pinned&&(0,ey.jsx)("button",{type:"button",draggable:!1,onPointerDown:e=>e.stopPropagation(),"aria-label":e.closeLabel??(K2(e.title)?`${x}: ${K2(e.title)}`:x),onClick:()=>(function(e){if(e.pinned)return;let t=Y.findIndex(t=>t.id===e.id),r=Y.filter(t=>t.id!==e.id);if(en(r),l?.(e),e.id===ee){let e=K1(r,t);void 0===n&&Q(e),e&&a?.(e)}})(e),className:(0,eI.cn)("relative z-20 grid size-5 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none group-hover/tab:opacity-100",r&&"opacity-100"),children:(0,ey.jsx)(fc.XIcon,{className:"size-3.5"})})]}),s&&(0,ey.jsx)("span",{"aria-hidden":"true",className:"mb-2 h-4 w-px shrink-0 bg-border/80"})]},e.id)}),G?(0,ey.jsxs)("span",{"data-slot":"multi-tab-external-insert","aria-hidden":"true",className:"pointer-events-none absolute top-2 bottom-1 z-30 flex w-0 -translate-x-1/2 items-center justify-center",style:{left:G.left},children:[(0,ey.jsx)("span",{className:"h-full w-px rounded-full bg-foreground/80"}),(0,ey.jsx)("span",{className:"absolute top-0 size-1.5 rounded-full bg-foreground"})]}):null]}),(0,ey.jsxs)("div",{className:"mb-1 flex shrink-0 items-center gap-1",children:[q&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":b,onClick:()=>el("right"),children:(0,ey.jsx)(p$,{})}),u.length>0?(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,children:(0,ey.jsx)(lJ,{})})}),(0,ey.jsx)(bL,{align:"end",className:"w-52",children:u.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(bH,{children:e.shortcut})]})]},t))})]}):(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":g,onClick:function(){let e=o?.();e&&(en([...Y,e]),e.disabled||(void 0===n&&Q(e.id),a?.(e.id)))},children:(0,ey.jsx)(lJ,{})}),f.length>0&&(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v,children:(0,ey.jsx)(lY,{})})}),(0,ey.jsx)(bL,{align:"end",className:"w-52",children:f.map((e,t)=>(0,ey.jsxs)(ew.Fragment,{children:[e.separatorBefore&&(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{disabled:e.disabled,onSelect:e.onSelect,children:[e.icon,e.label,e.shortcut&&(0,ey.jsx)(bH,{children:e.shortcut})]})]},t))})]})]})]}),em,S&&(0,ey.jsx)("div",{"data-slot":"multi-tab-content",className:(0,eI.cn)("min-h-0 overflow-hidden",M),children:ef??j??(0,ey.jsx)("div",{"aria-hidden":"true",className:"min-h-44 rounded-lg border border-dashed bg-muted/30"})})]})}let K3=(0,ek.default)("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),K6=(0,ek.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),K8=(0,ek.default)("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),K7=(0,ek.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function K9({icon:e,label:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 pt-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70 [&_svg]:size-3.5",children:[e,(0,ey.jsx)("span",{children:t})]})}function Ge({online:e}){return(0,ey.jsx)("span",{"aria-hidden":!0,className:(0,eI.cn)("inline-block size-2 shrink-0 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/40")})}function Gt({conversationId:e,ownerMachineId:t}){let[n,r]=ew.useState(null),[a,i]=ew.useState([]),[o,l]=ew.useState([]),{machines:s}=vs();ew.useEffect(()=>{if(!e)return;let n=!0,a=async()=>{try{let[a,o,s]=await Promise.all([sA(e,t),sz(e,t).catch(()=>[]),sT(e,t).catch(()=>[])]);if(!n)return;r(a),i(o),l(s)}catch{}};a();let o=window.setInterval(a,1200);return()=>{n=!1,window.clearInterval(o)}},[e,t]);let c=ew.useMemo(()=>new Map(s.map(e=>[e.id,e])),[s]),d=e=>"local"===e||c.get(e)?.status==="online",u=e=>"local"===e?c.get("local")?.name??"本地":c.get(e)?.name??e,f=t??n?.conversation.ownerMachineId??"local",h=(n?.conversation.settings?.hosts??[]).filter(Boolean),p=n?.conversation.runUsage,m=n?.conversation.status==="working",g=(p?.cachedInputTokens??0)+(p?.cacheCreationInputTokens??0),{additions:v,deletions:x}=function(e){let t=-1;for(let n=e.length-1;n>=0;n-=1)if(e[n]?.kind==="user"){t=n;break}let n=0,r=0;for(let a=Math.max(0,t);a<e.length;a+=1){let t=e[a],i=t?.additions??t?.meta?.additions,o=t?.deletions??t?.meta?.deletions;"number"==typeof i&&(n+=i),"number"==typeof o&&(r+=o)}return{additions:n,deletions:r}}(n?.events??[]),y=function e(t,n=0,r=[]){for(let a of t)r.push({node:a,depth:n}),a.children&&a.children.length>0&&e(a.children,n+1,r);return r}(a);return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col overflow-auto rounded-[inherit] bg-background text-sm",children:[(0,ey.jsx)(K9,{icon:(0,ey.jsx)(up,{}),label:"环境信息"}),(0,ey.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 pb-2 text-[13px]",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2 text-foreground/90",children:[(0,ey.jsx)(eP,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"运行于"}),(0,ey.jsx)(Ge,{online:d(f)}),(0,ey.jsx)("span",{className:"truncate font-medium",children:u(f)})]}),(0,ey.jsxs)("div",{className:"flex items-start gap-2",children:[(0,ey.jsx)(K7,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:"可访问"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-wrap gap-x-3 gap-y-1",children:0===h.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"—"}):h.map(e=>(0,ey.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(Ge,{online:d(e)}),(0,ey.jsx)("span",{className:"truncate",children:u(e)})]},e))})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(K6,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"text-muted-foreground",children:"本轮变更"}),(0,ey.jsxs)("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:["+",v]}),(0,ey.jsxs)("span",{className:"font-medium text-rose-600 dark:text-rose-400",children:["-",x]}),(0,ey.jsx)("span",{className:"text-muted-foreground/60",children:"行"})]})]}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(um,{}),label:"子智能体"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===y.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮未释放子智能体"}):y.map(({node:e,depth:t})=>{let n="failed"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",style:{paddingLeft:12*t},children:[e.running?(0,ey.jsx)(K8,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(fc.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(pR,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||e.title||e.subagentType||"子智能体"}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(uj,{}),label:"后台任务"}),(0,ey.jsx)("div",{className:"flex max-h-44 flex-col gap-1 overflow-y-auto px-3 pb-2 text-[13px]",children:0===o.length?(0,ey.jsx)("span",{className:"text-muted-foreground/70",children:"本轮无后台任务"}):o.map(e=>{let t="failed"===e.status||"timeout"===e.status,n="unknown"===e.status;return(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[e.running?(0,ey.jsx)(K8,{className:"size-3.5 shrink-0 animate-spin text-amber-500"}):n?(0,ey.jsx)(hb,{className:"size-3.5 shrink-0 text-amber-500"}):t?(0,ey.jsx)(fc.XIcon,{className:"size-3.5 shrink-0 text-rose-500"}):(0,ey.jsx)(pR,{className:"size-3.5 shrink-0 text-emerald-500"}),(0,ey.jsx)("span",{className:"truncate font-mono text-[12px]",title:e.command,children:e.command||"(命令)"}),e.orphaned?(0,ey.jsx)("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"该后台进程脱离了本轮但仍在运行",children:"脱离"}):null,(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-muted-foreground/70",children:e.running?"运行中":n?"状态未知":t?"timeout"===e.status?"超时":"失败":"已完成"})]},e.id)})}),(0,ey.jsx)("div",{className:"mx-3 border-t border-border/60"}),(0,ey.jsx)(K9,{icon:(0,ey.jsx)(K3,{}),label:m?"本轮消耗":"消耗额度"}),(0,ey.jsx)("div",{className:"grid grid-cols-3 gap-2 px-3 pb-3",children:[{label:"输入",value:p?.inputTokens},{label:"输出",value:p?.outputTokens},{label:"缓存",value:g}].map(e=>{let t;return(0,ey.jsxs)("div",{className:"rounded-lg border border-border/60 bg-muted/30 px-2 py-1.5",children:[(0,ey.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e.label}),(0,ey.jsx)("div",{className:"font-mono text-sm font-medium tabular-nums",children:p?(t=e.value??0)>=1e6?`${(t/1e6).toFixed(2)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t):"—"})]},e.label)})})]})}let Gn="application/vnd.vantaloom.canvas-node",Gr="application/vnd.vantaloom.canvas-tab",Ga="application/vnd.vantaloom.dashboard-widget",Gi="application/vnd.vantaloom.workspace-card",Go=[{policyNumber:3,name:"Allow HTTP Traffic",sourceZone:"Trust",sourceIPs:["192.168.1.0/24","10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["192.168.2.0/24"],tags:["Web Access","Internal"],action:"allow",description:"Permits HTTP traffic from internal network"},{policyNumber:5,name:"Block Suspicious IPs",sourceZone:"Untrust",sourceIPs:["203.0.113.0/24","198.51.100.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Security"],action:"deny",description:"Blocks known malicious IP ranges"},{policyNumber:9,name:"SSH Access Control",sourceZone:"Trust",sourceIPs:["172.16.0.0/12"],destinationZone:"Trust",destinationIPs:["10.50.0.0/16"],tags:["Admin Access","VPN"],action:"allow",description:"Restricted SSH access for admin network"},{policyNumber:12,name:"Database Port Protection",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["10.100.0.0/24"],tags:["Blocking","Database"],action:"deny",description:"Blocks external access to database ports"},{policyNumber:15,name:"API Gateway Access",sourceZone:"Trust",sourceIPs:["192.168.100.0/24","192.168.101.0/24"],destinationZone:"Trust",destinationIPs:["10.200.0.5"],tags:["API","VDI Env"],action:"allow",description:"Allows traffic to API gateway from specific subnets"},{policyNumber:18,name:"Drop Legacy SMB",sourceZone:"Trust",sourceIPs:["Any"],destinationZone:"Trust",destinationIPs:["10.20.0.0/16"],tags:["Legacy","Internal"],action:"drop",description:"Drops SMBv1 probes across workstation networks"},{policyNumber:22,name:"Agent Runtime Mesh",sourceZone:"Trust",sourceIPs:["10.10.4.0/24"],destinationZone:"Trust",destinationIPs:["10.10.8.0/24","10.10.12.0/24"],tags:["Agent","Runtime"],action:"allow",description:"Allows managed agent runtime channels between worker pools"},{policyNumber:27,name:"Block Public Admin Ports",sourceZone:"Untrust",sourceIPs:["0.0.0.0/0"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Blocking","Admin Access"],action:"deny",description:"Denies public access to SSH, RDP, and database admin ports"},{policyNumber:31,name:"Build Cache Access",sourceZone:"Trust",sourceIPs:["10.30.0.0/16"],destinationZone:"Trust",destinationIPs:["10.60.12.20"],tags:["Build","Internal"],action:"allow",description:"Allows build workers to reach shared cache storage"},{policyNumber:36,name:"Relay Egress",sourceZone:"Trust",sourceIPs:["10.40.0.0/16"],destinationZone:"Untrust",destinationIPs:["198.18.0.0/15"],tags:["Relay","Agent"],action:"allow",description:"Permits relay service egress to managed edge addresses"},{policyNumber:41,name:"Quarantine Subnet",sourceZone:"Quarantine",sourceIPs:["10.250.0.0/24"],destinationZone:"Trust",destinationIPs:["Any"],tags:["Security","Blocking"],action:"deny",description:"Blocks quarantined hosts from internal services"},{policyNumber:48,name:"Observability Intake",sourceZone:"Trust",sourceIPs:["10.0.0.0/8"],destinationZone:"Trust",destinationIPs:["10.80.4.10"],tags:["Telemetry","Internal"],action:"allow",description:"Allows metrics and logs to the observability intake"}],Gl=Array.from(new Set(Go.flatMap(e=>e.tags))).sort(),Gs=[["10.10.4.0/24","Agent workers","Trust","18"],["10.20.0.0/16","Workstations","Trust","41"],["10.250.0.0/24","Quarantine","Quarantine","03"],["198.18.0.0/15","Relay edge","Untrust","12"]],Gc=[["Database Port Protection","2026-06-12","Security"],["Relay Egress","2026-06-28","Network"],["Build Cache Access","2026-07-04","Build"],["Observability Intake","2026-07-18","Ops"]];function Gd({className:e,...t}){return(0,ey.jsx)("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:(0,eI.cn)("mx-auto flex w-full justify-center",e),...t})}function Gu({className:e,...t}){return(0,ey.jsx)("ul",{"data-slot":"pagination-content",className:(0,eI.cn)("flex flex-row items-center gap-1",e),...t})}function Gf({...e}){return(0,ey.jsx)("li",{"data-slot":"pagination-item",...e})}function Gh({className:e,isActive:t,size:n="icon",...r}){return(0,ey.jsx)("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:(0,eI.cn)((0,eA.buttonVariants)({variant:t?"outline":"ghost",size:n}),e),...r})}function Gp({className:e,previousLabel:t="Previous",...n}){return(0,ey.jsxs)(Gh,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pl-2",e),...n,children:[(0,ey.jsx)(pL,{}),(0,ey.jsx)("span",{className:"hidden sm:block",children:t})]})}function Gm({className:e,nextLabel:t="Next",...n}){return(0,ey.jsxs)(Gh,{"aria-label":t,size:"default",className:(0,eI.cn)("gap-1 px-2.5 sm:pr-2",e),...n,children:[(0,ey.jsx)("span",{className:"hidden sm:block",children:t}),(0,ey.jsx)(p$,{})]})}function Gg({className:e,moreLabel:t="More pages",...n}){return(0,ey.jsxs)("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:(0,eI.cn)("flex size-8 items-center justify-center",e),...n,children:[(0,ey.jsx)(lY,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:t})]})}function Gv({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function Gx(){let[e,t]=ew.useState(""),[n,r]=ew.useState("all"),[a,i]=ew.useState({allow:!1,drop:!1,deny:!1}),[o,l]=ew.useState(1),s=ew.useMemo(()=>["allow","drop","deny"].filter(e=>a[e]),[a]),c=ew.useMemo(()=>[{id:"policyNumber",header:"策略 #",accessorKey:"policyNumber",align:"right",width:84},{id:"name",header:"名称",accessorKey:"name",width:180,className:"font-medium"},{id:"sourceZone",header:"源区域",accessorKey:"sourceZone",width:112,cell:({row:e})=>(0,ey.jsx)(Gw,{zone:e.sourceZone})},{id:"sourceIPs",header:"源 IP",accessorKey:"sourceIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.sourceIPs,variant:"outline"}),copyValue:({row:e})=>e.sourceIPs.join(", ")},{id:"destinationZone",header:"目标区域",accessorKey:"destinationZone",width:112,cell:({row:e})=>(0,ey.jsx)(Gw,{zone:e.destinationZone})},{id:"destinationIPs",header:"目标 IP",accessorKey:"destinationIPs",width:250,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.destinationIPs,variant:"outline"}),copyValue:({row:e})=>e.destinationIPs.join(", ")},{id:"tags",header:"标签",accessorKey:"tags",width:220,cell:({row:e})=>(0,ey.jsx)(Gb,{items:e.tags,variant:"secondary"}),copyValue:({row:e})=>e.tags.join(", ")},{id:"action",header:"动作",accessorKey:"action",width:96,cell:({row:e})=>(0,ey.jsx)(Gj,{action:e.action})}],[]),d=ew.useMemo(()=>{let t=e.trim().toLowerCase();return Go.filter(e=>{let r=0===t.length||e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.sourceIPs.some(e=>e.toLowerCase().includes(t))||e.destinationIPs.some(e=>e.toLowerCase().includes(t)),i="all"===n||e.tags.includes(n),o=!(a.allow||a.drop||a.deny)||a.allow&&"allow"===e.action||a.drop&&"drop"===e.action||a.deny&&"deny"===e.action;return r&&i&&o})},[a,e,n]),u=Math.max(1,Math.ceil(d.length/8)),f=Math.min(o,u),h=d.slice((f-1)*8,8*f);return ew.useEffect(()=>{l(1)},[a,e,n]),(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsxs)("div",{className:"mb-3 flex shrink-0 items-center justify-between gap-3",children:[(0,ey.jsx)(Gv,{title:"防火墙策略"}),(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"新增策略"]})]}),(0,ey.jsxs)("div",{className:"mb-3 grid shrink-0 grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(12rem,1fr)_10rem_auto]",children:[(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"搜索"}),(0,ey.jsxs)("span",{className:"relative",children:[(0,ey.jsx)(vc,{className:"pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"}),(0,ey.jsx)(ez,{value:e,onChange:e=>t(e.target.value),placeholder:"搜索策略...",className:"pl-8"})]})]}),(0,ey.jsxs)("label",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"标签"}),(0,ey.jsxs)(gb,{value:n,onValueChange:r,children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:"全部标签"})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"all",children:"全部标签"}),Gl.map(e=>(0,ey.jsx)(vr,{value:e,children:e},e))]})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:"动作"}),(0,ey.jsxs)(pT,{type:"multiple",variant:"outline",value:s,onValueChange:function(e){e.includes("clear")?(t(""),r("all"),i({allow:!1,drop:!1,deny:!1}),l(1)):i({allow:e.includes("allow"),drop:e.includes("drop"),deny:e.includes("deny")})},children:[(0,ey.jsx)(pD,{value:"allow",children:"允许"}),(0,ey.jsx)(pD,{value:"drop",children:"丢弃"}),(0,ey.jsx)(pD,{value:"deny",children:"拒绝"}),(0,ey.jsx)(pD,{value:"clear",children:"全部"})]})]})]}),(0,ey.jsx)(UG,{rows:h,columns:c,rowId:"policyNumber",showHeader:!1,showToolbar:!1,rowHeight:40,className:"min-h-0 flex-1 rounded-lg shadow-none",labels:{noRows:"没有匹配的策略。",selectAllRows:"选择当前页策略",selectRow:e=>`选择第 ${e+1} 条策略`,resizeColumn:"调整列宽",sortAsc:"升序",sortDesc:"降序",sortClear:"取消排序",copyCell:"复制单元格",copied:"已复制"}}),(0,ey.jsx)(Gy,{page:f,totalPages:u,onPageChange:function(e){l(Math.min(u,Math.max(1,e)))}})]})}function Gy({page:e,totalPages:t,onPageChange:n}){let r=ew.useMemo(()=>t<=3?Array.from({length:t},(e,t)=>t+1):e<=2?[1,2,3]:e>=t-1?[t-2,t-1,t]:[e-1,e,e+1],[e,t]),a=r[0]??1,i=r[r.length-1]??t;function o(e,t){e.preventDefault(),n(t)}return(0,ey.jsx)(Gd,{className:"mt-3 shrink-0",children:(0,ey.jsxs)(Gu,{className:"gap-1 sm:gap-2",children:[(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gp,{href:"#",previousLabel:"上一页","aria-disabled":1===e,className:(0,eI.cn)(1===e&&"pointer-events-none opacity-40"),onClick:t=>o(t,e-1)})}),a>1?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",onClick:e=>o(e,1),children:"1"})}),a>2?(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gg,{moreLabel:"更多页"})}):null]}):null,r.map(t=>(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",isActive:e===t,onClick:e=>o(e,t),children:t})},t)),i<t?(0,ey.jsxs)(ey.Fragment,{children:[i<t-1?(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gg,{moreLabel:"更多页"})}):null,(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gh,{href:"#",size:"icon",onClick:e=>o(e,t),children:t})})]}):null,(0,ey.jsx)(Gf,{children:(0,ey.jsx)(Gm,{href:"#",nextLabel:"下一页","aria-disabled":e===t,className:(0,eI.cn)(e===t&&"pointer-events-none opacity-40"),onClick:t=>o(t,e+1)})})]})})}function Gb({items:e,variant:t}){return(0,ey.jsx)("div",{className:"flex min-w-48 flex-wrap gap-1",children:e.map(e=>(0,ey.jsx)(F3,{variant:t,children:e},e))})}function Gw({zone:e}){return(0,ey.jsx)(F3,{variant:"Trust"===e?"secondary":"outline",children:e})}function Gj({action:e}){return(0,ey.jsx)(F3,{variant:"allow"===e?"default":"destructive",children:{allow:"允许",drop:"丢弃",deny:"拒绝"}[e]})}function Gk({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,ey.jsx)("table",{"data-slot":"table",className:(0,eI.cn)("w-full caption-bottom text-sm",e),...t})})}function GS({className:e,...t}){return(0,ey.jsx)("thead",{"data-slot":"table-header",className:(0,eI.cn)("[&_tr]:border-b",e),...t})}function GN({className:e,...t}){return(0,ey.jsx)("tbody",{"data-slot":"table-body",className:(0,eI.cn)("[&_tr:last-child]:border-0",e),...t})}function GC({className:e,...t}){return(0,ey.jsx)("tr",{"data-slot":"table-row",className:(0,eI.cn)("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function GM({className:e,...t}){return(0,ey.jsx)("th",{"data-slot":"table-head",className:(0,eI.cn)("h-9 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function GE({className:e,...t}){return(0,ey.jsx)("td",{"data-slot":"table-cell",className:(0,eI.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5",e),...t})}function GO({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}function GP({title:e,headers:t,rows:n}){return(0,ey.jsxs)("div",{className:"flex h-full min-h-0 flex-col p-3",children:[(0,ey.jsx)(GO,{title:e}),(0,ey.jsx)("div",{className:"mt-3 min-h-0 flex-1 overflow-auto",children:(0,ey.jsxs)(Gk,{children:[(0,ey.jsx)(GS,{children:(0,ey.jsx)(GC,{children:t.map(e=>(0,ey.jsx)(GM,{children:e},e))})}),(0,ey.jsx)(GN,{children:n.map(e=>(0,ey.jsx)(GC,{children:e.map((e,t)=>(0,ey.jsx)(GE,{className:0===t?"font-medium":"text-muted-foreground",children:e},`${e}-${t}`))},e.join("-")))})]})})]})}function GA(){return(0,ey.jsxs)("div",{className:"grid h-full min-h-0 content-start gap-3 p-3",children:[(0,ey.jsx)(GO,{title:"策略申请"}),(0,ey.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,ey.jsx)(ez,{placeholder:"策略名称"}),(0,ey.jsx)(ez,{placeholder:"负责人"}),(0,ey.jsx)(ez,{placeholder:"源 CIDR"}),(0,ey.jsx)(ez,{placeholder:"目标 CIDR"})]}),(0,ey.jsx)("textarea",{placeholder:"用途",className:"min-h-32 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"}),(0,ey.jsx)("div",{children:(0,ey.jsxs)(eA.Button,{size:"sm",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"提交申请"]})})]})}function GI(){return(0,ey.jsxs)(pr,{defaultValue:"policies",className:"vtl-firewall-workspace flex h-full min-h-0 flex-col",children:[(0,ey.jsx)("div",{className:"shrink-0 overflow-x-auto px-3 pt-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsxs)(pf,{className:"h-8 w-max min-w-full",children:[(0,ey.jsx)(ph,{value:"policies",children:"防火墙策略"}),(0,ey.jsx)(ph,{value:"ip-addresses",children:"IP 地址"}),(0,ey.jsx)(ph,{value:"renewals",children:"续期"}),(0,ey.jsx)(ph,{value:"policy-request",children:"策略申请"}),(0,ey.jsx)(ph,{value:"user-settings",children:"用户设置"})]})}),(0,ey.jsx)(pp,{value:"policies",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(Gx,{})}),(0,ey.jsx)(pp,{value:"ip-addresses",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"IP 地址",headers:["地址","名称","区域","策略"],rows:Gs})}),(0,ey.jsx)(pp,{value:"renewals",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"续期",headers:["策略","续期时间","负责人"],rows:Gc})}),(0,ey.jsx)(pp,{value:"policy-request",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GA,{})}),(0,ey.jsx)(pp,{value:"user-settings",className:"mt-3 min-h-0 flex-1 border-t",children:(0,ey.jsx)(GP,{title:"用户设置",headers:["设置","值"],rows:[["默认区域","Trust"],["审核提醒","14 天"],["申请审批","安全负责人"],["策略导出","已开启"]]})})]})}function Gz(e){return e.map(e=>{var t;return{id:e.id,name:e.name,path:e.path,kind:"folder"===(t=e.kind)?"folder":"image"===t?"image":"archive"===t?"archive":"text"===t?"text":"code"===t?"code":"executable"===t?"config":"unknown",hasChildren:"folder"===e.kind,readonly:e.readonly,disabled:e.disabled}})}async function GT(e,t){let n=t.machineId||"local";return Gz((await uF(n,e.path)).items)}function GD({className:e,onOpenFile:t}){let[n,r]=ew.useState([]),[a,i]=ew.useState(!1),[o,l]=ew.useState(0),s=ew.useCallback(async()=>{i(!0);try{let e=await u$();r(e.roots.map(e=>({id:e.id,machineId:e.machineId,name:e.name,path:e.path,platform:e.platform,children:Gz(e.children)}))),l(e=>e+1)}catch{r([]),l(e=>e+1)}finally{i(!1)}},[]);return ew.useEffect(()=>{s()},[s]),ew.useEffect(()=>{function e(){s()}return window.addEventListener("vantaloom:file-system-changed",e),()=>window.removeEventListener("vantaloom:file-system-changed",e)},[s]),(0,ey.jsx)(Hc,{className:e,compact:!0,openFilesOnSingleClick:!1,allowCreateFile:!1,allowCreateFolder:!1,allowRename:!1,allowDelete:!1,allowDragAndDrop:!1,allowBoxSelect:!1,defaultRoots:n,defaultExpandedIds:n.map(e=>e.id),loadingIds:a?n.map(e=>e.id):[],labels:{title:"Explorer",refresh:"刷新",collapseAll:"折叠",empty:"没有文件",noResults:"没有匹配文件",loading:"读取中..."},onLoadChildren:GT,onOpenNode:(e,n)=>{"folder"!==e.kind&&t?.({machineId:n.machineId||"local",path:e.path})},onRefresh:()=>{s()}},o)}function G_({open:e,onOpenChange:t,onSelectFile:n}){return(0,ey.jsx)(dw,{open:e,onOpenChange:t,children:(0,ey.jsxs)(fu,{className:"h-[min(42rem,calc(100svh-2rem))] max-w-2xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fh,{className:"sr-only",children:"选择文件"}),(0,ey.jsx)(fp,{className:"sr-only",children:"选择本机可访问文件。"}),(0,ey.jsx)(GD,{className:"size-full max-w-none rounded-none border-0",onOpenFile:e=>{n(e),t(!1)}})]})})}function GR(){let e=ew.useRef(null),[t,n]=ew.useState({width:0,height:0});return ew.useLayoutEffect(()=>{let t=e.current;if(!t)return;function r(){let e=t.getBoundingClientRect();n({width:e.width,height:e.height})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}let GL=(0,ek.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);function G$({open:e,placement:t="viewport",movePermissionGranted:n,onOpenChange:r,onAdd:a,onMovePermissionGrantedChange:i}){let o=[{key:"move-permission",label:n?"取消放行权限":"放行权限",icon:n?(0,ey.jsx)(jb,{className:"size-4"}):(0,ey.jsx)(GL,{className:"size-4"}),pressed:n,onClick:()=>i(!n)},{key:"add",label:"新建文件窗口",icon:(0,ey.jsx)(lJ,{className:"size-4"}),pressed:void 0,onClick:a}];return(0,ey.jsx)("div",{className:(0,eI.cn)("right-5 z-50","viewport"===t?"fixed bottom-5 max-md:bottom-20":"absolute bottom-5"),children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,title:t.label,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.pressed&&"border-foreground bg-foreground text-background hover:bg-foreground/90 hover:text-background"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":"文件窗口操作","aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let GF=[];function GB(e,t){return`${e} / ${t.replace(/\\/g," / ").replace(/\//g," / ")}`}function GV(e,t){for(let n of e){if(n.id===t)return n;let e=n.children?GV(n.children,t):void 0;if(e)return e}}function GH(e,t){return e.replace(/\\/g,"/").toLowerCase()===t.replace(/\\/g,"/").toLowerCase()}function GU(e,t){let n=e.replace(/\\/g,"/").replace(/\/+/g,"/");return"windows"===t?n.toLowerCase():n}function GW(e){return e.map(e=>({...e,children:e.children?GW(e.children):void 0}))}let Gq=(0,ek.default)("move-right",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]),GK=(0,ek.default)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),GG=(0,ek.default)("clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]),GX={title:"Clipboard",empty:"No clips",dragHandle:"Drag clip"};function GY({items:e,expanded:t,defaultExpanded:n=!1,expansionDirection:r="down-left",title:a,labels:i,maxCollapsedItems:o=10,maxExpandedHeight:l=360,acceptExternalDrops:s=!1,removeOnExternalDrop:c=!1,className:d,onExpandedChange:u,onItemDragStart:f,onItemDragEnd:h,onItemDuplicate:p,onItemsRemove:m,onItemsReorder:g,onExternalDrop:v,onMouseEnter:x,onMouseLeave:y,...b}){let w={...GX,...i},[j,k]=ew.useState(n),[S,N]=ew.useState(),[C,M]=ew.useState(),[E,O]=ew.useState(n),[P,A]=ew.useState(),[I,z]=ew.useState({canScrollDown:!1,canScrollUp:!1}),[T,D]=ew.useState(!1),[_,R]=ew.useState(!1),L=ew.useRef(0),$=ew.useRef(void 0),F=ew.useRef(!1),B=ew.useRef(null),V=ew.useRef(null),H=void 0!==t,U=(H?t:j)||void 0!==S,W=Math.min(o,10),q=U?e:e.slice(0,W),K=E?C:void 0,G=44*q.length+18,X=Math.min(G,l),Y=U&&G>X,Z=0===e.length?"h-24":U?`${X}px`:"h-28",J=U&&Y?14:0;ew.useEffect(()=>{if(!U){O(!1),z({canScrollDown:!1,canScrollUp:!1});return}O(!1),window.requestAnimationFrame(()=>{V.current&&(V.current.scrollTop=0)}),z({canScrollUp:!1,canScrollDown:G>X});let e=window.setTimeout(()=>{O(!0)},260);return()=>window.clearTimeout(e)},[G,X,U]),ew.useEffect(()=>()=>{void 0!==$.current&&window.clearTimeout($.current)},[]);let Q=ew.useCallback(e=>{H||k(e),u?.(e)},[H,u]);function ee(e,t=0){let n=e.currentTarget.getBoundingClientRect();return e.clientX>=n.left-t&&e.clientX<=n.right+t&&e.clientY>=n.top-t&&e.clientY<=n.bottom+t}function et(e){if(!U||!V.current)return 0;let t=Array.from(V.current.querySelectorAll('[data-slot="clipboard-stack-card"]'));if(0===t.length)return 0;for(let[n,r]of t.entries()){let t=r.getBoundingClientRect();if(e.clientY<t.top+t.height/2)return n}return t.length}function en(e){return void 0!==S||Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.clip-id")}return ew.useEffect(()=>{if(0===e.length||U)return;let t=window.requestAnimationFrame(()=>{B.current?.matches(":hover")&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))});return()=>window.cancelAnimationFrame(t)},[e.length,Q,U]),ew.useEffect(()=>{if(!U||!Y||!K||!V.current)return;let e=q.findIndex(e=>e.id===K);if(e<0)return;let t=V.current,n=44*e-8,r=44*e+(q[e]?.expandedHeight??220)+12,a=t.scrollTop,i=a+t.clientHeight;n<a?t.scrollTo({top:Math.max(0,n),behavior:"smooth"}):r>i&&t.scrollTo({top:r-t.clientHeight,behavior:"smooth"})},[K,Y,q,U]),(0,ey.jsxs)("div",{ref:B,"data-slot":"clipboard-stack","data-expanded":U,"data-closing":T,"data-external-dragging":_,"data-expansion-direction":r,className:(0,eI.cn)("group/clipboard relative w-80 max-w-full overflow-visible py-2",d),onMouseEnter:function(e){x?.(e),ee(e)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0))},onMouseMove:function(e){if(!U){ee(e,12)&&(void 0!==$.current&&(window.clearTimeout($.current),$.current=void 0),D(!1),Q(!0));return}!U||S||ee(e,12)||(M(void 0),A(void 0),Q(!1),D(!0),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onMouseLeave:function(e){y?.(e),S||(M(void 0),A(void 0),D(!0),Q(!1),void 0!==$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{D(!1),$.current=void 0},320))},onDragEnter:function(e){!s||en(e)||(L.current+=1,R(!0),D(!1))},onDragLeave:function(e){!s||en(e)||(L.current=Math.max(0,L.current-1),0===L.current&&(R(!1),A(void 0)))},onDragOver:function(e){!s||en(e)||(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="copy",R(!0),U?A(et(e)):A(0))},onDrop:function(t){if(!s||en(t))return;t.preventDefault(),t.stopPropagation();let n=P??et(t);L.current=0,R(!1),A(void 0),v?.({insertIndex:n,items:e,nativeEvent:t})},...b,children:[(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-header",className:(0,eI.cn)("mb-2 flex h-8 items-center gap-2 px-1 text-sm font-medium text-foreground transition-[opacity,transform] duration-200","down-left"===r&&"justify-end",U?"opacity-100":"translate-y-1 opacity-0"),children:[(0,ey.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:(0,ey.jsx)(GG,{className:"size-3.5"})}),(0,ey.jsx)("span",{children:a??w.title}),(0,ey.jsx)("span",{className:"ml-auto tabular-nums text-muted-foreground",children:e.length})]}),(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-list",className:(0,eI.cn)("relative transition-[height] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]"),style:{height:Z},children:[e.length>0&&"down-left"===r?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-pivot","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute top-3 right-[34px] z-50 size-2.5 rounded-full bg-foreground shadow-sm transition-[opacity,transform] duration-200 dark:bg-background",U?"scale-75 opacity-0":"opacity-100")}):null,s&&_?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-external-ghost","aria-hidden":"true",className:(0,eI.cn)("pointer-events-none absolute right-0 z-[70] h-14 w-[88%] rounded-xl border bg-background shadow-md shadow-black/10","clipboard-stack-external-ghost"),children:[(0,ey.jsx)("span",{className:"absolute top-3 right-[34px] size-2 rounded-full bg-foreground dark:bg-background"}),(0,ey.jsx)("span",{className:"absolute top-4 left-3 h-2 w-24 rounded-full bg-foreground/18"}),(0,ey.jsx)("span",{className:"absolute top-8 left-3 h-1.5 w-14 rounded-full bg-foreground/10"})]}):null,0===e.length?(0,ey.jsx)("div",{className:"flex h-24 items-center justify-center rounded-xl border border-dashed bg-muted/35 text-sm text-muted-foreground",children:w.empty}):(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-frame",className:"relative h-full",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-scroll",ref:V,className:(0,eI.cn)("relative h-full overflow-x-visible",U&&Y?"clipboard-stack-scrollbar-hidden overflow-y-auto pt-2 pr-1 pb-3":"overflow-visible"),onScroll:e=>{let t=e.currentTarget;z({canScrollUp:t.scrollTop>1,canScrollDown:t.scrollTop+t.clientHeight<t.scrollHeight-1})},onDragOver:function(e){U&&S&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move")},onDrop:function(t){if(!U||!S||void 0===P)return;t.preventDefault(),t.stopPropagation(),F.current=!0;let n=e.findIndex(e=>e.id===S),r=e[n];if(n<0||!r)return;let a=e.filter(e=>e.id!==S),i=Math.max(0,Math.min(P>n?P-1:P,a.length));a.splice(i,0,r),A(void 0),M(void 0),i!==n&&g?.(a,{item:r,fromIndex:n,toIndex:i,items:a})},children:(0,ey.jsxs)("div",{"data-slot":"clipboard-stack-scroll-content",className:"relative",style:{width:U&&Y?`calc(100% - ${J}px)`:void 0,marginLeft:U&&Y?`${J}px`:void 0,height:U&&Y?G+28:U?G:"100%"},children:[void 0!==P?(0,ey.jsxs)("span",{"data-slot":"clipboard-stack-insert-line","aria-hidden":"true",className:"pointer-events-none absolute right-0 left-0 z-[80] flex items-center",style:{top:44*P-2},children:[(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"}),(0,ey.jsx)("span",{className:"mx-1 size-1.5 rounded-full bg-foreground"}),(0,ey.jsx)("span",{className:"h-px flex-1 bg-foreground/70"})]}):null,q.map((t,n)=>(0,ey.jsx)(GZ,{item:t,index:n,count:q.length,expanded:U,active:U&&t.id===K,top:U?44*n:void 0,expansionDirection:r,labels:w,onHover:()=>M(t.id),onDuplicate:()=>{let n=e.findIndex(e=>e.id===t.id);n<0||p?.(e,{item:t,index:n,items:e})},onDragOver:e=>{if(U&&S&&S!==t.id){let t=e.currentTarget.getBoundingClientRect();A(e.clientY<t.top+t.height/2?n:n+1)}},onDragStart:e=>{N(e.item.id),M(void 0),F.current=!1,f?.(e)},onDragEnd:t=>{let n=t.nativeEvent.dataTransfer.dropEffect,r=t.item.id,a=e.findIndex(e=>e.id===r),i=c&&!F.current&&"none"!==n&&a>=0;if(N(void 0),A(void 0),M(void 0),F.current?F.current=!1:Q(!1),i){let n=e.filter(e=>e.id!==r);m?.(n,{item:t.item,index:a,items:n})}h?.(t)}},t.id))]})}),Y&&I.canScrollUp?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-top","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-8 bg-gradient-to-b from-background to-transparent"}):null,Y&&I.canScrollDown?(0,ey.jsx)("span",{"data-slot":"clipboard-stack-scroll-mask-bottom","aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 z-[90] h-8 bg-gradient-to-t from-background to-transparent"}):null]})]})]})}function GZ({item:e,index:t,count:n,expanded:r,active:a,top:i,expansionDirection:o,labels:l,onHover:s,onDuplicate:c,onDragOver:d,onDragStart:u,onDragEnd:f}){let h=Math.min(t,9),p="down-left"===o?-(4.5*h):[-4,2,-1,4][h]??0,m=r?a?n+20:n-t:n+t;return(0,ey.jsx)("article",{"data-slot":"clipboard-stack-card",draggable:!e.disabled,"aria-disabled":e.disabled,className:(0,eI.cn)("absolute right-0 min-h-16 w-full cursor-grab select-none rounded-xl border bg-background p-2.5 text-foreground shadow-sm shadow-black/5 outline-none transition-[top,transform,opacity,box-shadow,border-color] duration-300 ease-[cubic-bezier(.2,.8,.2,1)] active:cursor-grabbing","hover:border-foreground/35 hover:shadow-md hover:shadow-black/10 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40",r&&"min-h-0 overflow-hidden py-2 transition-[top,transform,max-height,opacity,box-shadow,border-color] duration-300",r&&!a&&"max-h-11",e.disabled&&"cursor-not-allowed opacity-50"),style:{top:r?i??44*t:"down-left"===o?0:9*h,zIndex:m,maxHeight:r&&a?e.expandedHeight??220:void 0,transformOrigin:"down-left"===o?"calc(100% - 34px) 14px":"100% 0",transform:r?a?"translate3d(-10px, -6px, 0) rotate(0deg)":"translate3d(0, 0, 0) rotate(0deg)":`translate3d(${"down-left"===o?0:4*h}px, 0, 0) rotate(${p}deg)`},tabIndex:e.disabled?-1:0,onMouseDown:function(t){1!==t.button||e.disabled||t.preventDefault()},onMouseEnter:s,onFocus:s,onAuxClick:function(t){1!==t.button||e.disabled||(t.preventDefault(),c?.())},onDragOver:d,onDragStart:function(t){for(let[n,r]of(t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setData("text/plain",e.title),t.dataTransfer.setData("application/vnd.vantaloom.clip-id",e.id),Object.entries(e.dragData??{})))t.dataTransfer.setData(n,r);u?.({item:e,nativeEvent:t})},onDragEnd:function(t){f?.({item:e,nativeEvent:t})},children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,ey.jsx)("div",{"data-slot":"clipboard-stack-card-media",className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:e.icon??(0,ey.jsx)(GG,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-muted-foreground",children:e.meta}):null]}),e.description?(0,ey.jsx)("p",{className:(0,eI.cn)("mt-0.5 text-xs leading-5 text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-40 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.description}):null,e.content?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-2 text-xs text-muted-foreground transition-[max-height,opacity,transform] duration-200",a?"max-h-80 translate-y-0 opacity-100":"max-h-0 -translate-y-1 overflow-hidden opacity-0"),children:e.content}):null]}),(0,ey.jsx)("span",{"aria-label":l.dragHandle,className:"mt-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground",children:(0,ey.jsx)(fm,{className:"size-3.5"})})]})})}function GJ({transfers:e}){let t=e.slice(0,10);if(0===t.length)return null;let n=t.map(e=>{var t,n,r;let a,i,o;return{id:e.id,title:(a="copy"===(t=e).mode?"复制":"移动",i=t.sources.length,o=t.sources[0],`${a} ${i>1?`${i} 项`:G0(o?.path??"")}`),description:(n=e).message?n.message:`${n.sources[0]?.machineId??"local"} -> ${n.target.machineId}`,meta:function(e){switch(e.status){case"completed":return"完成";case"failed":return"失败";case"queued":return"排队";default:return`${Math.round(e.progress?.percent??0)}%`}}(e),icon:"completed"===(r=e).status?(0,ey.jsx)(eO,{className:"size-4"}):"failed"===r.status?(0,ey.jsx)(GK,{className:"size-4"}):"running"===r.status?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):"copy"===r.mode?(0,ey.jsx)(lU,{className:"size-4"}):(0,ey.jsx)(Gq,{className:"size-4"}),expandedHeight:132,content:(0,ey.jsx)(GQ,{transfer:e})}});return(0,ey.jsx)("div",{className:"pointer-events-auto fixed top-4 right-4 z-50 w-80 max-w-[calc(100vw-2rem)] max-md:left-4 max-md:right-auto max-md:w-auto max-md:max-w-[16rem]",children:(0,ey.jsx)(GY,{items:n,title:"传输",labels:{empty:"暂无传输",dragHandle:"传输任务"},expansionDirection:"down-left",maxExpandedHeight:420})})}function GQ({transfer:e}){let t=Math.max(0,Math.min(100,e.progress?.percent??0));return(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-border",children:(0,ey.jsx)("div",{className:"h-full rounded-full bg-foreground transition-[width] duration-300",style:{width:`${t}%`}})}),(0,ey.jsxs)("div",{className:"grid gap-1 tabular-nums",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate",children:G0(e.target.path)}),(0,ey.jsxs)("span",{children:[Math.round(t),"%"]})]}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-2 text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"truncate",children:[G1(e.progress.bytesDone)," /"," ",G1(e.progress.bytesTotal)]}),(0,ey.jsxs)("span",{children:[e.progress.entriesDone,"/",e.progress.entriesTotal]})]}),e.progress.currentPath?(0,ey.jsx)("div",{className:"truncate text-muted-foreground",children:G0(e.progress.currentPath)}):null]})]})}function G0(e){return e.split(/[\\/]+/).filter(Boolean).at(-1)??e}function G1(e){if(!e)return"0 B";let t=["B","KB","MB","GB","TB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||0===r?Math.round(n):n.toFixed(1)} ${t[r]}`}let G2=(0,ek.default)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function G5({windowLayout:e,roots:t,active:n,zIndex:r,boardSize:a,onActivate:i,onClose:o,onMinimize:l,onWindowChange:s,onNavigate:c,onRootsChange:d,onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onMoveItems:p}){return(0,ey.jsxs)("section",{className:(0,eI.cn)("absolute overflow-hidden rounded-xl border bg-card shadow-lg transition-[box-shadow,border-color] duration-150","vtl-file-manager-window",n&&"border-foreground shadow-xl"),style:{left:e.x,top:e.y,width:e.w,height:e.h,zIndex:r},onPointerDown:i,children:[(0,ey.jsxs)("div",{className:"grid h-9 cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 border-b bg-muted/35 px-2 active:cursor-grabbing",onPointerDown:function(t){t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function a(t){let a=Math.max(0,e.x+t.clientX-n),i=Math.max(0,e.y+t.clientY-r);s({...e,x:a,y:i})}window.addEventListener("pointermove",a),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",e)})},children:[(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"关闭窗口",onPointerDown:e=>e.stopPropagation(),onClick:o,children:(0,ey.jsx)(fc.XIcon,{})}),(0,ey.jsx)(eA.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"缩小到剪切板",onPointerDown:e=>e.stopPropagation(),onClick:l,children:(0,ey.jsx)(G2,{})})]}),(0,ey.jsx)("div",{className:"truncate text-center ui-text-control",children:e.title}),(0,ey.jsx)("div",{className:"w-14"})]}),(0,ey.jsx)(wT,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,draggableItems:!0,onNavigate:c,onRootsChange:e=>d(e),onCreateFolder:u,onRenameItem:f,onDeleteItems:h,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>p({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"vtl-file-window-explorer min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0",style:{height:"calc(100% - 2.25rem)",minHeight:0}}),(0,ey.jsx)("button",{type:"button","aria-label":"调整窗口大小",className:"absolute right-0 bottom-0 size-5 cursor-nwse-resize rounded-tl-md border-t border-l bg-background/80",onPointerDown:function(t){t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture(t.pointerId),i();let n=t.clientX,r=t.clientY;function o(t){let i=Math.max(420,Math.min(Math.max(420,a.width-e.x),e.w+t.clientX-n)),o=Math.max(320,e.h+t.clientY-r);s({...e,w:i,h:o})}window.addEventListener("pointermove",o),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",e)})}})]})}function G4({clipboardItems:e=[],onClipboardItemsChange:t,className:n,minBoardHeight:r=520,actionsPlacement:a="container"}){let[i,o]=GR(),[l,s]=ew.useState([]),[c,d]=ew.useState(GF),[u,f]=ew.useState(GF[0]?.id),[h,p]=ew.useState([]),[m,g]=ew.useState(!1),[v,x]=ew.useState(!1),[y,b]=ew.useState(),w=ew.useRef(GF.length),j=ew.useRef(!1),k=ew.useRef(new Set),S=ew.useCallback(async(e,t,n)=>{let r=await uF(e,n);s(n=>{var a;return a={...r,root:{...r.root,id:t,machineId:e}},n.map(e=>e.id!==a.root.id?e:GH(e.path,a.path)?{...e,children:GW(a.items)}:{...e,children:function(e,t,n,r,a){let i=function(e,t,n){let r=GU(e,n),a=GU(t,n);if(r===a)return[];let i=r.endsWith("/")?r:`${r}/`;return a.startsWith(i)?a.slice(i.length).split("/").filter(Boolean):[]}(t,n,r);if(0===i.length)return GW(a);let o="windows"===r?"\\":"/";return function e(t,n,r){let l=i[r];if(!l)return GW(a);let s=n===o?`${o}${l}`:`${n.replace(/[\\/]+$/,"")}${o}${l}`,c=t.findIndex(e=>GH(e.path,s)),d=t[c],u={...d??{id:`synthetic-${s}`,name:l,kind:"folder",path:s,children:[]},kind:"folder",children:e(d?.children??[],s,r+1)};if(c<0)return[...t,u];let f=[...t];return f[c]=u,f}(e,t,0)}(e.children,e.path,a.path,e.platform,a.items)})})},[]),N=ew.useCallback(async()=>{let e=G8((await uK()).transfers);return p(e),e},[]),C=ew.useCallback(e=>{p(t=>G8([e,...t.filter(t=>t.id!==e.id)]))},[]),M=ew.useCallback(e=>{uq({mode:"move",sources:e.sources.map(e=>({machineId:e.machineId,path:e.path})),target:{machineId:e.target.machineId,path:e.target.path}}).then(C).catch(()=>{})},[C]),E=ew.useCallback(()=>{for(let e of c)S(e.machineId,e.rootId,e.path)},[S,c]);function O(e,t){d(n=>n.map(n=>n.id===e?t(n):n))}function P(e){let t=l[0];if(!t&&!e?.rootId)return;w.current+=1;let n=`files-window-${w.current}`,r=i.current?.getBoundingClientRect(),a=r?.width??o.width,s=r?.height??o.height,c=e?.w??680,u=e?.h??460,h=Math.max(0,(a-c)/2),p=Math.max(0,(s-u)/2),m={id:n,title:e?.title??GB(t?.name??"local",t?.path??""),machineId:e?.machineId??t?.machineId??"local",rootId:e?.rootId??t?.id??"local",path:e?.path??t?.path??"",x:e?.x??h+12*w.current,y:e?.y??p+12*w.current,w:c,h:u};d(e=>[...e,m]),f(n),S(m.machineId,m.rootId,m.path)}ew.useEffect(()=>{let e=!0;return(async function(){let t=await u$();if(e&&(s(t.roots),!j.current&&t.roots[0])){j.current=!0;let e=function(e,t=0){return{id:`files-${e.id.replace(/[^a-z0-9_-]/gi,"-")}-${t}`,title:GB(e.name,e.path),machineId:e.machineId,rootId:e.id,path:e.path,x:28+24*t,y:28+24*t,w:720,h:480}}(t.roots[0]);d([e]),f(e.id),S(e.machineId,e.rootId,e.path)}})().catch(()=>{}),N().catch(()=>{}),()=>{e=!1}},[S,N]),ew.useEffect(()=>{if(!h.some(e=>"pending"===e.status||"running"===e.status||"queued"===e.status))return;let e=window.setInterval(async()=>{let e=(await N().catch(()=>h)).filter(e=>"completed"===e.status&&!k.current.has(e.id));if(e.length>0){for(let t of e)k.current.add(t.id);E()}},1e3);return()=>window.clearInterval(e)},[E,N,h]);let A=sb(),I=c.find(e=>e.id===u);function z(e){return{onNavigate:({rootId:t,path:n})=>{let r=l.find(e=>e.id===t),a=r?.machineId??e.machineId;O(e.id,e=>({...e,machineId:a,rootId:t,path:n,title:GB(r?.name??a,n)})),S(a,t,n)},onRootsChange:s,onCreateFolder:(t,n)=>{uH({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onRenameItem:(t,n)=>{uU({machineId:e.machineId,path:t.path,name:n}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onDeleteItems:t=>{uW({machineId:e.machineId,paths:t.map(e=>e.path)}).then(()=>S(e.machineId,e.rootId,e.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=GV(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}}}return A?(0,ey.jsxs)("div",{className:(0,eI.cn)("flex h-full min-h-0 w-full flex-col",n),children:[c.length>1?(0,ey.jsx)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:c.map(e=>(0,ey.jsx)("button",{type:"button",className:(0,eI.cn)("shrink-0 rounded-md px-2.5 py-1 text-xs transition-colors",e.id===u?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"),onClick:()=>f(e.id),children:e.title},e.id))}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:I?(0,ey.jsx)(G3,{windowLayout:I,roots:l,...z(I)}):(0,ey.jsx)("div",{className:"grid h-full place-items-center text-sm text-muted-foreground",children:"暂无打开的文件窗口"})}),(0,ey.jsx)(GJ,{transfers:h}),(0,ey.jsx)(G$,{open:m,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(G6,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]}):(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative h-full min-h-0 w-full overflow-hidden rounded-[inherit]",n),onDragOver:e=>{Array.from(e.dataTransfer.types).includes("application/vnd.vantaloom.file-window")&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.file-window");if(t)try{let n=JSON.parse(t),r=i.current?.getBoundingClientRect();e.preventDefault(),e.stopPropagation(),P({...n,x:r?e.clientX-r.left-160:n.x,y:r?e.clientY-r.top-24:n.y})}catch{return}},children:[(0,ey.jsx)("div",{className:"relative h-full min-h-0",style:{minHeight:Math.max(r,o.height-48)},children:c.map((n,r)=>(0,ey.jsx)(G5,{windowLayout:n,roots:l,active:u===n.id,zIndex:20+r+20*(u===n.id),boardSize:o,onActivate:()=>f(n.id),onClose:()=>d(e=>e.filter(e=>e.id!==n.id)),onMinimize:()=>{t?.([{id:`clip-${n.id}`,title:n.title,description:"文件管理窗口",meta:`${Math.round(n.w)}x${Math.round(n.h)}`,payloads:{"application/vnd.vantaloom.file-window":{...n}},dragData:{"application/vnd.vantaloom.clip-kind":"file-window","application/vnd.vantaloom.file-window":JSON.stringify(n)}},...e.filter(e=>e.id!==`clip-${n.id}`)]),d(e=>e.filter(e=>e.id!==n.id))},onWindowChange:e=>O(n.id,()=>e),...z(n),onNavigate:({rootId:e,path:t})=>{let r=l.find(t=>t.id===e),a=r?.machineId??n.machineId;O(n.id,n=>({...n,machineId:a,rootId:e,path:t,title:GB(r?.name??a,t)})),S(a,e,t)},onRootsChange:s,onCreateFolder:(e,t)=>{uH({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onRenameItem:(e,t)=>{uU({machineId:n.machineId,path:e.path,name:t}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onDeleteItems:e=>{uW({machineId:n.machineId,paths:e.map(e=>e.path)}).then(()=>S(n.machineId,n.rootId,n.path)).catch(()=>{})},onMoveItems:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>{let a=l.find(t=>t.id===e);if(!a)return;let i=t.flatMap(e=>{let t=GV(a.children,e);return t?[{machineId:a.machineId,path:t.path,name:t.name}]:[]});if(0===i.length)return;let o={sources:i,target:{machineId:n.machineId,path:r.path,name:r.name}};v?M(o):b(o)}},n.id))}),(0,ey.jsx)(GJ,{transfers:h}),(0,ey.jsx)(G$,{open:m,placement:a,movePermissionGranted:v,onOpenChange:g,onMovePermissionGrantedChange:x,onAdd:()=>{g(!1),P()}}),(0,ey.jsx)(G6,{move:y,onCancel:()=>b(void 0),onConfirm:e=>{b(void 0),M(e)}})]})}function G3({windowLayout:e,roots:t,onNavigate:n,onRootsChange:r,onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onMoveItems:l}){return(0,ey.jsx)(wT,{roots:t,variant:"full",currentRootId:e.rootId,currentPath:e.path,onNavigate:n,onRootsChange:e=>r(e),onCreateFolder:a,onRenameItem:i,onDeleteItems:o,onItemDrop:({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r})=>l({sourceRootId:e,sourceItemIds:t,targetRoot:n,target:r}),labels:{title:"文件管理",search:"搜索文件",newFolder:"新建",upload:"上传",refresh:"刷新",sort:"排序",view:"视图"},className:"h-full min-h-0 rounded-none border-0 shadow-none",contentClassName:"min-h-0"})}function G6({move:e,onCancel:t,onConfirm:n}){var r;let a=e?.sources??[],i=Math.max(0,a.length-4);return(0,ey.jsx)(dQ,{open:void 0!==e,onOpenChange:e=>{e||t()},children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"确认移动"}),(0,ey.jsx)(uu,{children:e?`将 ${1===(r=a).length?r[0]?G7(r[0]):"0 项":`${r.length} 项`} 移动到 ${G7(e.target)}`:""})]}),e?(0,ey.jsxs)("div",{className:"grid gap-2 rounded-lg border bg-muted/20 p-3 ui-text-body",children:[(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"移动内容"}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[a.slice(0,4).map(e=>(0,ey.jsx)("span",{className:"truncate",children:G7(e)},`${e.machineId}:${e.path}`)),i>0?(0,ey.jsxs)("span",{className:"text-muted-foreground",children:["另有 ",i," 项"]}):null]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)("span",{className:"text-muted-foreground ui-text-kbd",children:"目标位置"}),(0,ey.jsx)("span",{className:"truncate",children:G7(e.target)})]})]}):null,(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{onClick:()=>{e&&n(e)},children:"确认移动"})]})]})})}function G8(e){return e.slice(0,10)}function G7(e){let t=e.path.replace(/\\/g,"/");return`${e.machineId} / ${e.name||t}`}function G9({className:e}){return(0,ey.jsx)(G4,{className:(0,eI.cn)("h-full min-h-0 w-full rounded-[inherit] border-0 shadow-none",e),minBoardHeight:360,actionsPlacement:"container"})}var Xe=ew;function Xt(){return(Xt=Object.assign.bind()).apply(null,arguments)}var Xn=e=>{var{cx:t,cy:n,r,className:a}=e,i=(0,jN.clsx)("recharts-dot",a);return kn(t)&&kn(n)&&kn(r)?ew.createElement("circle",Xt({},IM(e),I7(e),{className:i,cx:t,cy:n,r:r})):null},Xr=["points"];function Xa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xa(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xo(){return(Xo=Object.assign.bind()).apply(null,arguments)}function Xl(e){var{option:t,dotProps:n,className:r}=e;if((0,ew.isValidElement)(t))return(0,ew.cloneElement)(t,n);if("function"==typeof t)return t(n);var a=(0,jN.clsx)(r,"boolean"!=typeof t?t.className:""),i=null!=n?n:{},{points:o}=i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(i,Xr);return ew.createElement(Xn,Xo({},l,{className:a}))}function Xs(e){var{points:t,dot:n,className:r,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:s,zIndex:c=C_.scatter}=e;if(null==t||!n&&1!==t.length)return null;var d=zY(n),u=null==n?null:(0,ew.isValidElement)(n)?IO(n.props):"object"!=typeof n||Array.isArray(n)?null:IO(n),f=t.map((e,r)=>{var l,s,c=Xi(Xi(Xi({r:3},o),u),{},{index:r,cx:null!=(l=e.x)?l:void 0,cy:null!=(s=e.y)?s:void 0,dataKey:i,value:e.value,payload:e.payload,points:t});return ew.createElement(Xl,{key:"dot-".concat(r),option:n,dotProps:c,className:a})}),h={};return l&&null!=s&&(h.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(s,")")),ew.createElement(RO,{zIndex:c},ew.createElement(II,Xo({className:r},h),f))}function Xc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Xd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xc(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Xu=e=>{var t,{point:n,childIndex:r,mainColor:a,activeDot:i,dataKey:o,clipPath:l}=e;if(!1===i||null==n.x||null==n.y)return null;var s=Xd(Xd(Xd({},{index:r,dataKey:o,cx:n.x,cy:n.y,r:4,fill:null!=a?a:"none",strokeWidth:2,stroke:"#fff",payload:n.payload,value:n.value}),IE(i)),I7(i));return t=(0,ew.isValidElement)(i)?(0,ew.cloneElement)(i,s):"function"==typeof i?i(s):ew.createElement(Xn,s),ew.createElement(II,{className:"recharts-active-dot",clipPath:l},t)};function Xf(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:a,clipPath:i,zIndex:o=C_.activeDot}=e,l=kZ(_X),s=kZ(_4);if(null==t||null==s)return null;var c=t.find(e=>s.includes(e.payload));return null==c?null:ew.createElement(RO,{zIndex:o},ew.createElement(Xu,{point:c,childIndex:Number(l),mainColor:n,dataKey:a,activeDot:r,clipPath:i}))}function Xh(e,t){var n,r,a=kZ(t=>PS(t,e)),i=kZ(e=>PM(e,t)),o=null!=(n=null==a?void 0:a.allowDataOverflow)?n:Pj.allowDataOverflow,l=null!=(r=null==i?void 0:i.allowDataOverflow)?r:PN.allowDataOverflow;return{needClip:o||l,needClipX:o,needClipY:l}}function Xp(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,a=kZ(FH),{needClipX:i,needClipY:o,needClip:l}=Xh(t,n);if(!l||!a)return null;var{x:s,y:c,width:d,height:u}=a;return ew.createElement("clipPath",{id:"clipPath-".concat(r)},ew.createElement("rect",{x:i?s:s-d/2,y:o?c:c-u/2,width:i?d:2*d,height:o?u:2*u}))}function Xm(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.xAxisId)?n:0}function Xg(e,t){var n,r;return null!=(n=null==(r=e.graphicalItems.cartesianItems.find(e=>e.id===t))?void 0:r.yAxisId)?n:0}var Xv=(e,t,n)=>A7(e,"xAxis",Xm(e,t),n),Xx=(e,t,n)=>A8(e,"xAxis",Xm(e,t),n),Xy=(e,t,n)=>A7(e,"yAxis",Xg(e,t),n),Xb=(e,t,n)=>A8(e,"yAxis",Xg(e,t),n),Xw=jH([Cl,Xv,Xy,Xx,Xb],(e,t,n,r,a)=>ky(e,"xAxis")?kE(t,r,!1):kE(n,a,!1)),Xj=jH([PT,(e,t)=>t],(e,t)=>e.filter(e=>"area"===e.type).find(e=>e.id===t)),Xk=e=>ky(Cl(e),"xAxis")?"yAxis":"xAxis",XS=jH([Xj,(e,t,n)=>P3(e,Xk(e),"yAxis"===Xk(e)?Xg(e,t):Xm(e,t),n)],(e,t)=>{if(null!=e&&null!=t){var n,{stackId:r}=e,a=C2(e);if(null!=r&&null!=a){var i=null==(n=t[r])?void 0:n.stackedData,o=null==i?void 0:i.find(e=>e.key===a);if(null!=o)return o.map(e=>[e[0],e[1]])}}}),XN=jH([Cl,Xv,Xy,Xx,Xb,XS,jG,Xw,Xj,e=>e.rootProps.baseValue],(e,t,n,r,a,i,o,l,s,c)=>{var d,{chartData:u,dataStartIndex:f,dataEndIndex:h}=o;if(null!=s&&("horizontal"===e||"vertical"===e)&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=l){var{data:p}=s;if(null!=(d=p&&p.length>0?p:null==u?void 0:u.slice(f,h+1)))return function(e){var t,{areaSettings:{connectNulls:n,baseValue:r,dataKey:a},stackedData:i,layout:o,chartBaseValue:l,xAxis:s,yAxis:c,displayedData:d,dataStartIndex:u,xAxisTicks:f,yAxisTicks:h,bandSize:p}=e,m=i&&i.length,g=((e,t,n,r,a)=>{var i=null!=n?n:t;if(kn(i))return i;var o="horizontal"===e?a:r,l=o.scale.domain();if("number"===o.type){var s=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return"dataMin"===i?c:"dataMax"===i||s<0?s:Math.max(Math.min(l[0],l[1]),0)}return"dataMin"===i?l[0]:"dataMax"===i?l[1]:l[0]})(o,l,r,s,c),v="horizontal"===o,x=!1,y=d.map((e,t)=>{if(m)d=i[u+t];else{var r,o,l,d,y,b=kx(e,a);Array.isArray(b)?(d=b,x=!0):d=[g,b]}var w=null!=(r=null==(o=d)?void 0:o[1])?r:null,j=null==w||m&&!n&&null==kx(e,a);return v?{x:kS({axis:s,ticks:f,bandSize:p,entry:e,index:t}),y:j?null:null!=(y=c.scale.map(w))?y:null,value:d,payload:e}:{x:j?null:null!=(l=s.scale.map(w))?l:null,y:kS({axis:c,ticks:h,bandSize:p,entry:e,index:t}),value:d,payload:e}});return t=m||x?y.map(e=>{var t,n,r=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:null!=r&&null!=e.y&&null!=(n=c.scale.map(r))?n:null,payload:e.payload}:{x:null!=r&&null!=(t=s.scale.map(r))?t:null,y:e.y,payload:e.payload}}):v?c.scale.map(g):s.scale.map(g),{points:y,baseLine:null!=t?t:0,isRange:x}}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataStartIndex:f,areaSettings:s,stackedData:i,displayedData:d,chartBaseValue:c,bandSize:l})}});function XC(e){var t=IE(e);if(null!=t){var{r:n,strokeWidth:r}=t,a=Number(n),i=Number(r);return(Number.isNaN(a)||a<0)&&(a=3),(Number.isNaN(i)||i<0)&&(i=2),{r:a,strokeWidth:i}}return{r:3,strokeWidth:2}}var XM=["id"],XE=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function XO(){return(XO=Object.assign.bind()).apply(null,arguments)}function XP(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function XA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XI(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?XA(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):XA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xz(e,t){return e&&"none"!==e?e:t}var XT=Xe.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kf,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kP(o,t),hide:l,type:c,color:Xz(r,i),unit:s,graphicalItemId:d}};return Xe.createElement(D1,{tooltipEntrySettings:u})});function XD(e){var{clipPathId:t,points:n,props:r}=e,{needClip:a,dot:i,dataKey:o}=r,l=IM(r);return Xe.createElement(Xs,{points:n,dot:i,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:a,clipPathId:t})}function X_(e){var{showLabels:t,children:n,points:r}=e,a=r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return XI(XI({},r),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:r,fill:void 0})});return Xe.createElement(RQ,{value:t?a:void 0},n)}function XR(e){var{points:t,baseLine:n,needClip:r,clipPathId:a,props:i}=e,{layout:o,type:l,stroke:s,connectNulls:c,isRange:d}=i,{id:u}=i,f=XP(i,XM),h=IM(f),p=IO(f);return Xe.createElement(Xe.Fragment,null,(null==t?void 0:t.length)>1&&Xe.createElement(II,{clipPath:r?"url(#clipPath-".concat(a,")"):void 0},Xe.createElement(zs,XO({},p,{id:u,points:t,connectNulls:c,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),"none"!==s&&Xe.createElement(zs,XO({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:t})),"none"!==s&&d&&Array.isArray(n)&&Xe.createElement(zs,XO({},h,{className:"recharts-area-curve",layout:o,type:l,connectNulls:c,fill:"none",points:n}))),Xe.createElement(XD,{points:t,props:f,clipPathId:a}))}function XL(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.y,s=null==(n=i[i.length-1])?void 0:n.y;if(!kp(l)||!kp(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.x||0));return(kn(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.x||0),d)),kn(d))?Xe.createElement("rect",{x:0,y:l<s?l:l-c,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(c)}):null}function X$(e){var t,n,{alpha:r,baseLine:a,points:i,strokeWidth:o}=e,l=null==(t=i[0])?void 0:t.x,s=null==(n=i[i.length-1])?void 0:n.x;if(!kp(l)||!kp(s))return null;var c=r*Math.abs(l-s),d=Math.max(...i.map(e=>e.y||0));return(kn(a)?d=Math.max(a,d):a&&Array.isArray(a)&&a.length&&(d=Math.max(...a.map(e=>e.y||0),d)),kn(d))?Xe.createElement("rect",{x:l<s?l:l-c,y:0,width:c,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function XF(e){var{alpha:t,layout:n,points:r,baseLine:a,strokeWidth:i}=e;return"vertical"===n?Xe.createElement(XL,{alpha:t,points:r,baseLine:a,strokeWidth:i}):Xe.createElement(X$,{alpha:t,points:r,baseLine:a,strokeWidth:i})}function XB(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i}=e,{points:o,baseLine:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,onAnimationStart:f,onAnimationEnd:h}=r,p=Td((0,Xe.useMemo)(()=>({points:o,baseLine:l}),[o,l]),"recharts-area-"),m=Cs(),[g,v]=(0,Xe.useState)(!1),x=(0,Xe.useCallback)(()=>{"function"==typeof h&&h(),v(!1)},[h]),y=(0,Xe.useCallback)(()=>{"function"==typeof f&&f(),v(!0)},[f]);if(null==m)return null;var b=a.current,w=i.current;return Xe.createElement(X_,{showLabels:!g,points:o},r.children,Xe.createElement(Tc,{animationId:p,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:x,onAnimationStart:y,key:p},e=>{if(b){var c,d=b.length/o.length,u=1===e?o:o.map((t,n)=>{var r=Math.floor(n*d);if(b[r]){var a=b[r];return XI(XI({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return t});if(kn(l))c=ks(w,l,e);else c=null==l||ke(l)?ks(w,0,e):l.map((t,n)=>{var r=Math.floor(n*d);if(Array.isArray(w)&&w[r]){var a=w[r];return XI(XI({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return t});return e>0&&(a.current=u,i.current=c),Xe.createElement(XR,{points:u,baseLine:c,needClip:t,clipPathId:n,props:r})}return e>0&&(a.current=o,i.current=l),Xe.createElement(II,null,s&&Xe.createElement("defs",null,Xe.createElement("clipPath",{id:"animationClipPath-".concat(n)},Xe.createElement(XF,{alpha:e,points:o,baseLine:l,layout:m,strokeWidth:r.strokeWidth}))),Xe.createElement(II,{clipPath:"url(#animationClipPath-".concat(n,")")},Xe.createElement(XR,{points:o,baseLine:l,needClip:t,clipPathId:n,props:r})))}),Xe.createElement(R5,{label:r.label}))}function XV(e){var{needClip:t,clipPathId:n,props:r}=e,a=(0,Xe.useRef)(null),i=(0,Xe.useRef)();return Xe.createElement(XB,{needClip:t,clipPathId:n,props:r,previousPointsRef:a,previousBaselineRef:i})}class XH extends Xe.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:a,left:i,needClip:o,xAxisId:l,yAxisId:s,width:c,height:d,id:u,baseLine:f,zIndex:h}=this.props;if(e)return null;var p=(0,jN.clsx)("recharts-area",r),{r:m,strokeWidth:g}=XC(t),v=zY(t),x=2*m+g,y=o?"url(#clipPath-".concat(v?"":"dots-").concat(u,")"):void 0;return Xe.createElement(RO,{zIndex:h},Xe.createElement(II,{className:p},o&&Xe.createElement("defs",null,Xe.createElement(Xp,{clipPathId:u,xAxisId:l,yAxisId:s}),!v&&Xe.createElement("clipPath",{id:"clipPath-dots-".concat(u)},Xe.createElement("rect",{x:i-x/2,y:a-x/2,width:c+x,height:d+x}))),Xe.createElement(XV,{needClip:o,clipPathId:u,props:this.props})),Xe.createElement(Xf,{points:n,mainColor:Xz(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}),this.props.isRange&&Array.isArray(f)&&Xe.createElement(Xf,{points:f,mainColor:Xz(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:y}))}}var XU={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:C_.area};function XW(e){var t,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,connectNulls:o,dot:l,fill:s,fillOpacity:c,hide:d,isAnimationActive:u,legendType:f,stroke:h,xAxisId:p,yAxisId:m}=e,g=XP(e,XE),v=kZ(Cl),x=kZ(CM),{needClip:y}=Xh(p,m),b=Nq(),{points:w,isRange:j,baseLine:k}=null!=(t=kZ(t=>XN(t,e.id,b)))?t:{},S=kZ(FH);if("horizontal"!==v&&"vertical"!==v||null==S||"AreaChart"!==x&&"ComposedChart"!==x)return null;var{height:N,width:C,x:M,y:E}=S;return w&&w.length?Xe.createElement(XH,XO({},g,{activeDot:n,animationBegin:r,animationDuration:a,animationEasing:i,baseLine:k,connectNulls:o,dot:l,fill:s,fillOpacity:c,height:N,hide:d,layout:v,isAnimationActive:u,isRange:j,legendType:f,needClip:y,points:w,stroke:h,width:C,left:M,top:E,xAxisId:p,yAxisId:m})):null}var Xq=Xe.memo(function(e){var t=zE(e,XU),n=Nq();return Xe.createElement(Ro,{id:t.id,type:"area"},e=>Xe.createElement(Xe.Fragment,null,Xe.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,fill:a,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:Xz(r,a),value:kP(n,t),payload:e}]})(t)}),Xe.createElement(XT,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),Xe.createElement(Rm,{type:"area",id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:kk(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),Xe.createElement(XW,XO({},t,{id:e}))))},Fl);function XK(){return(XK=Object.assign.bind()).apply(null,arguments)}function XG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}Xq.displayName="Area";var XX=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?XG(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):XG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},$3),XY=(0,ew.forwardRef)(function(e,t){var n,r=zE(e.categoricalChartProps,XX),{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:s}=e;return ew.createElement(Fa,{preloadedState:{options:{chartName:a,defaultTooltipEventType:i,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0}},reduxStoreName:null!=(n=s.id)?n:a},ew.createElement(Fi,{chartData:s.data}),ew.createElement(Fs,{layout:r.layout,margin:r.margin}),ew.createElement(Fd,{throttleDelay:r.throttleDelay,throttledEvents:r.throttledEvents}),ew.createElement(Fc,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),ew.createElement(FK,XK({},r,{ref:t})))}),XZ=["axis"],XJ=(0,ew.forwardRef)((e,t)=>ew.createElement(XY,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:XZ,tooltipPayloadSearcher:Lh,categoricalChartProps:e,ref:t})),XQ=function(e){var{width:t,height:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(r%180+180)%180*Math.PI/180,i=Math.atan(n/t);return Math.abs(a>i&&a<Math.PI-i?n/Math.sin(a):t/Math.cos(a))};function X0(e,t){if(t<1)return[];if(1===t)return e;for(var n=[],r=0;r<e.length;r+=t){var a=e[r];void 0!==a&&n.push(a)}return n}function X1(e,t,n,r,a){if(e*t<e*r||e*t>e*a)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-a)<=0}function X2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X5(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X2(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X2(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function X4(e,t,n){var r,{tick:a,ticks:i,viewBox:o,minTickGap:l,orientation:s,interval:c,tickFormatter:d,unit:u,angle:f}=e;if(!i||!i.length||!a)return[];if(kn(c)||zc.isSsr)return null!=(r=X0(i,(kn(c)?c:0)+1))?r:[];var h="top"===s||"bottom"===s?"width":"height",p=u&&"width"===h?zg(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},m=(e,r)=>{var a,i="function"==typeof d?d(e.value,r):e.value;return"width"===h?(a=zg(i,{fontSize:t,letterSpacing:n}),XQ({width:a.width+p.width,height:a.height+p.height},f)):zg(i,{fontSize:t,letterSpacing:n})[h]},g=i[0],v=i[1],x=i.length>=2&&null!=g&&null!=v?j9(v.coordinate-g.coordinate):1,y=function(e,t,n){var r="width"===n,{x:a,y:i,width:o,height:l}=e;return 1===t?{start:r?a:i,end:r?a+o:i+l}:{start:r?a+o:i+l,end:r?a:i}}(o,x,h);return"equidistantPreserveStart"===c?function(e,t,n,r,a){for(var i,o=(r||[]).slice(),{start:l,end:s}=t,c=0,d=1,u=l;d<=o.length;)if(i=function(){var t,i=null==r?void 0:r[c];if(void 0===i)return{v:X0(r,d)};var o=c,f=()=>(void 0===t&&(t=n(i,o)),t),h=i.coordinate,p=0===c||X1(e,h,f,u,s);p||(c=0,u=l,d+=1),p&&(u=h+e*(f()/2+a),c+=d)}())return i.v;return[]}(x,y,m,i,l):"equidistantPreserveEnd"===c?function(e,t,n,r,a){var i=(r||[]).slice().length;if(0===i)return[];for(var{start:o,end:l}=t,s=1;s<=i;s++){for(var c,d=(i-1)%s,u=o,f=!0,h=d;h<i&&(0===(c=function(){var t,i=r[h];if(null==i)return 0;var o=h,s=()=>(void 0===t&&(t=n(i,o)),t),c=i.coordinate,p=h===d||X1(e,c,s,u,l);if(!p)return f=!1,1;p&&(u=c+e*(s()/2+a))}())||1!==c);h+=s);if(f){for(var p=[],m=d;m<i;m+=s){var g=r[m];null!=g&&p.push(g)}return p}}return[]}(x,y,m,i,l):("preserveStart"===c||"preserveStartEnd"===c?function(e,t,n,r,a,i){var o=(r||[]).slice(),l=o.length,{start:s,end:c}=t;if(i){var d=r[l-1];if(null!=d){var u=n(d,l-1),f=e*(d.coordinate+e*u/2-c);o[l-1]=d=X5(X5({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate}),null!=d.tickCoord&&X1(e,d.tickCoord,()=>u,s,c)&&(c=d.tickCoord-e*(u/2+a),o[l-1]=X5(X5({},d),{},{isShow:!0}))}}for(var h=i?l-1:l,p=function(t){var r,i=o[t];if(null==i)return 1;var l=i,d=()=>(void 0===r&&(r=n(i,t)),r);if(0===t){var u=e*(l.coordinate-e*d()/2-s);o[t]=l=X5(X5({},l),{},{tickCoord:u<0?l.coordinate-u*e:l.coordinate})}else o[t]=l=X5(X5({},l),{},{tickCoord:l.coordinate});null!=l.tickCoord&&X1(e,l.tickCoord,d,s,c)&&(s=l.tickCoord+e*(d()/2+a),o[t]=X5(X5({},l),{},{isShow:!0}))},m=0;m<h;m++)if(p(m))continue;return o}(x,y,m,i,l,"preserveStartEnd"===c):function(e,t,n,r,a){for(var i=(r||[]).slice(),o=i.length,{start:l}=t,{end:s}=t,c=function(t){var r,c=i[t];if(null==c)return 1;var d=c,u=()=>(void 0===r&&(r=n(c,t)),r);if(t===o-1){var f=e*(d.coordinate+e*u()/2-s);i[t]=d=X5(X5({},d),{},{tickCoord:f>0?d.coordinate-f*e:d.coordinate})}else i[t]=d=X5(X5({},d),{},{tickCoord:d.coordinate});null!=d.tickCoord&&X1(e,d.tickCoord,u,l,s)&&(s=d.tickCoord-e*(u()/2+a),i[t]=X5(X5({},d),{},{isShow:!0}))},d=o-1;d>=0;d--)if(c(d))continue;return i}(x,y,m,i,l)).filter(e=>e.isShow)}var X3=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function X6(){return(X6=Object.assign.bind()).apply(null,arguments)}function X8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X7(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X8(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X8(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var X9={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:C_.axis};function Ye(e){var{x:t,y:n,width:r,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:s}=e;if(!l)return null;var c=X7(X7(X7({},s),IM(l)),{},{fill:"none"});if("top"===i||"bottom"===i){var d=+("top"===i&&!o||"bottom"===i&&o);c=X7(X7({},c),{},{x1:t,y1:n+d*a,x2:t+r,y2:n+d*a})}else{var u=+("left"===i&&!o||"right"===i&&o);c=X7(X7({},c),{},{x1:t+u*r,y1:n,x2:t+u*r,y2:n+a})}return ew.createElement("line",X6({},c,{className:(0,jN.clsx)("recharts-cartesian-axis-line",(0,jS.default)(l,"className"))}))}function Yt(e){var t,{option:n,tickProps:r,value:a}=e,i=(0,jN.clsx)(r.className,"recharts-cartesian-axis-tick-value");if(ew.isValidElement(n))t=ew.cloneElement(n,X7(X7({},r),{},{className:i}));else if("function"==typeof n)t=n(X7(X7({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";"boolean"!=typeof n&&(o=(0,jN.clsx)(o,R4(n))),t=ew.createElement(zV,X6({},r,{className:o}),a)}return t}function Yn(e){var{ticks:t,axisType:n,axisId:r}=e,a=kK();return(0,ew.useEffect)(()=>null==r||null==n?kf:(a(Fe({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{a(Ft({axisId:r,axisType:n}))}),[a,t,r,n]),null}var Yr=(0,ew.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:s,tickTextProps:c,orientation:d,mirror:u,x:f,y:h,width:p,height:m,tickSize:g,tickMargin:v,fontSize:x,letterSpacing:y,getTicksConfig:b,events:w,axisType:j,axisId:k}=e,S=X4(X7(X7({},b),{},{ticks:n}),x,y),N=IM(b),C=IE(r),M=zD(N.textAnchor)?N.textAnchor:function(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}(d,u),E=function(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}(d,u),O={};"object"==typeof a&&(O=a);var P=X7(X7({},N),{},{fill:"none"},O),A=S.map(e=>X7({entry:e},function(e,t,n,r,a,i,o,l,s){var c,d,u,f,h,p,m=l?-1:1,g=e.tickSize||o,v=kn(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":c=d=e.coordinate,p=(u=(f=n+!l*a)-m*g)-m*s,h=v;break;case"left":u=f=e.coordinate,h=(c=(d=t+!l*r)-m*g)-m*s,p=v;break;case"right":u=f=e.coordinate,h=(c=(d=t+l*r)+m*g)+m*s,p=v;break;default:c=d=e.coordinate,p=(u=(f=n+l*a)+m*g)+m*s,h=v}return{line:{x1:c,y1:u,x2:d,y2:f},tick:{x:h,y:p}}}(e,f,h,p,m,d,g,u,v))),I=A.map(e=>{var{entry:t,line:n}=e;return ew.createElement(II,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(t.value,"-").concat(t.coordinate,"-").concat(t.tickCoord)},a&&ew.createElement("line",X6({},P,n,{className:(0,jN.clsx)("recharts-cartesian-axis-tick-line",(0,jS.default)(a,"className"))})))}),z=A.map((e,t)=>{var n,a,{entry:d,tick:u}=e,f=X7(X7(X7(X7({verticalAnchor:E},N),{},{textAnchor:M,stroke:"none",fill:i},u),{},{index:t,payload:d,visibleTicksCount:S.length,tickFormatter:o,padding:s},c),{},{angle:null!=(n=null!=(a=null==c?void 0:c.angle)?a:N.angle)?n:0}),h=X7(X7({},f),C);return ew.createElement(II,X6({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(d.value,"-").concat(d.coordinate,"-").concat(d.tickCoord)},I9(w,d,t)),r&&ew.createElement(Yt,{option:r,tickProps:h,value:"".concat("function"==typeof o?o(d.value,t):d.value).concat(l||"")}))});return ew.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(j,"-ticks")},ew.createElement(Yn,{ticks:S,axisId:k,axisType:j}),z.length>0&&ew.createElement(RO,{zIndex:C_.label},ew.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(j,"-tick-labels"),ref:t},z)),I.length>0&&ew.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(j,"-tick-lines")},I))}),Ya=(0,ew.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:a,className:i,hide:o,ticks:l,axisType:s,axisId:c}=e,d=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,X3),[u,f]=(0,ew.useState)(""),[h,p]=(0,ew.useState)(""),m=(0,ew.useRef)(null);(0,ew.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>{var t;return(e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var l=n?n.getBoundingClientRect().width:0;return Math.round(o+(a+i)+l+(n?r:0))}return 0})({ticks:m.current,label:null==(t=e.labelRef)?void 0:t.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var g=(0,ew.useCallback)(e=>{if(e){var t=e.getElementsByClassName("recharts-cartesian-axis-tick-value");m.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),a=r.fontSize,i=r.letterSpacing;(a!==u||i!==h)&&(f(a),p(i))}}},[u,h]);return o||null!=r&&r<=0||null!=a&&a<=0?null:ew.createElement(RO,{zIndex:e.zIndex},ew.createElement(II,{className:(0,jN.clsx)("recharts-cartesian-axis",i)},ew.createElement(Ye,{x:e.x,y:e.y,width:r,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:IM(e)}),ew.createElement(Yr,{ref:g,axisType:s,events:d,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:c}),ew.createElement(R$,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},ew.createElement(Rq,{label:e.label,labelRef:e.labelRef}),e.children)))}),Yi=ew.forwardRef((e,t)=>{var n=zE(e,X9);return ew.createElement(Ya,X6({},n,{ref:t}))});Yi.displayName="CartesianAxis";var Yo=["x1","y1","x2","y2","key"],Yl=["offset"],Ys=["xAxisId","yAxisId"],Yc=["xAxisId","yAxisId"];function Yd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yd(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yf(){return(Yf=Object.assign.bind()).apply(null,arguments)}function Yh(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var Yp=e=>{var{fill:t}=e;if(!t||"none"===t)return null;var{fillOpacity:n,x:r,y:a,width:i,height:o,ry:l}=e;return ew.createElement("rect",{x:r,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Ym(e){var{option:t,lineItemProps:n}=e;if(ew.isValidElement(t))r=ew.cloneElement(t,n);else if("function"==typeof t)r=t(n);else{var r,a,{x1:i,y1:o,x2:l,y2:s,key:c}=n,d=null!=(a=IM(Yh(n,Yo)))?a:{},{offset:u}=d,f=Yh(d,Yl);r=ew.createElement("line",Yf({},f,{x1:i,y1:o,x2:l,y2:s,fill:"none",key:c}))}return r}function Yg(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Yh(e,Ys),s=a.map((e,a)=>{var i=Yu(Yu({},l),{},{x1:t,y1:e,x2:t+n,y2:e,key:"line-".concat(a),index:a});return ew.createElement(Ym,{key:"line-".concat(a),option:r,lineItemProps:i})});return ew.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Yv(e){var{y:t,height:n,vertical:r=!0,verticalPoints:a}=e;if(!r||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=Yh(e,Yc),s=a.map((e,a)=>{var i=Yu(Yu({},l),{},{x1:e,y1:t,x2:e,y2:t+n,key:"line-".concat(a),index:a});return ew.createElement(Ym,{option:r,lineItemProps:i,key:"line-".concat(a)})});return ew.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Yx(e){var{horizontalFill:t,fillOpacity:n,x:r,y:a,width:i,height:o,horizontalPoints:l,horizontal:s=!0}=e;if(!s||!t||!t.length||null==l)return null;var c=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,l)=>{var s=c[l+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=l%t.length;return ew.createElement("rect",{key:"react-".concat(l),y:e,x:r,height:d,width:i,stroke:"none",fill:t[u],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Yy(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:a,y:i,width:o,height:l,verticalPoints:s}=e;if(!t||!n||!n.length)return null;var c=s.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==c[0]&&c.unshift(0);var d=c.map((e,t)=>{var s=c[t+1],d=null==s?a+o-e:s-e;if(d<=0)return null;var u=t%n.length;return ew.createElement("rect",{key:"react-".concat(t),x:e,y:i,width:d,height:l,stroke:"none",fill:n[u],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ew.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Yb=(e,t)=>{var{xAxis:n,width:r,height:a,offset:i}=e;return kb(X4(Yu(Yu(Yu({},X9),n),{},{ticks:kw(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.left,i.left+i.width,t)},Yw=(e,t)=>{var{yAxis:n,width:r,height:a,offset:i}=e;return kb(X4(Yu(Yu(Yu({},X9),n),{},{ticks:kw(n,!0),viewBox:{x:0,y:0,width:r,height:a}})),i.top,i.top+i.height,t)},Yj={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:C_.grid};function Yk(e){var t=kZ(kA),n=kZ(kI),r=Co(),a=Yu(Yu({},zE(e,Yj)),{},{x:kn(e.x)?e.x:r.left,y:kn(e.y)?e.y:r.top,width:kn(e.width)?e.width:r.width,height:kn(e.height)?e.height:r.height}),{xAxisId:i,yAxisId:o,x:l,y:s,width:c,height:d,syncWithTicks:u,horizontalValues:f,verticalValues:h}=a,p=Nq(),m=kZ(e=>A3(e,"xAxis",i,p)),g=kZ(e=>A3(e,"yAxis",o,p));if(!km(c)||!km(d)||!kn(l)||!kn(s))return null;var v=a.verticalCoordinatesGenerator||Yb,x=a.horizontalCoordinatesGenerator||Yw,{horizontalPoints:y,verticalPoints:b}=a;if((!y||!y.length)&&"function"==typeof x){var w=f&&f.length,j=x({yAxis:g?Yu(Yu({},g),{},{ticks:w?f:g.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!w||u);NY(Array.isArray(j),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(y=j)}if((!b||!b.length)&&"function"==typeof v){var k=h&&h.length,S=v({xAxis:m?Yu(Yu({},m),{},{ticks:k?h:m.ticks}):void 0,width:null!=t?t:c,height:null!=n?n:d,offset:r},!!k||u);NY(Array.isArray(S),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof S,"]")),Array.isArray(S)&&(b=S)}return ew.createElement(RO,{zIndex:a.zIndex},ew.createElement("g",{className:"recharts-cartesian-grid"},ew.createElement(Yp,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),ew.createElement(Yx,Yf({},a,{horizontalPoints:y})),ew.createElement(Yy,Yf({},a,{verticalPoints:b})),ew.createElement(Yg,Yf({},a,{offset:r,horizontalPoints:y,xAxis:m,yAxis:g})),ew.createElement(Yv,Yf({},a,{offset:r,verticalPoints:b,xAxis:m,yAxis:g}))))}Yk.displayName="CartesianGrid";var YS=["domain","range"],YN=["domain","range"];function YC(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YM(e,t){return e===t||!!(Array.isArray(e)&&2===e.length&&Array.isArray(t))&&2===t.length&&e[0]===t[0]&&e[1]===t[1]}function YE(e,t){if(e===t)return!0;var{domain:n,range:r}=e,a=YC(e,YS),{domain:i,range:o}=t,l=YC(t,YN);return!!YM(n,i)&&!!YM(r,o)&&Fl(a,l)}var YO=["type"],YP=["dangerouslySetInnerHTML","ticks","scale"],YA=["id","scale"];function YI(){return(YI=Object.assign.bind()).apply(null,arguments)}function Yz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yz(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YD(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Y_(e){var t=kK(),n=(0,ew.useRef)(null),r=Cs(),{type:a}=e,i=YD(e,YO),o=CF(r,"xAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return YT(YT({},i),{},{type:o})},[i,o]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t(L8(l)):n.current!==l&&t(L7({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t(L9(n.current)),n.current=null)},[t]),null}var YR=e=>{var{xAxisId:t,className:n}=e,r=kZ(kH),a=Nq(),i="xAxis",o=kZ(e=>A6(e,i,t,a)),l=kZ(e=>AY(e,t)),s=kZ(e=>AQ(e,t)),c=kZ(e=>Pk(e,t));if(null==l||null==s||null==c)return null;var{dangerouslySetInnerHTML:d,ticks:u,scale:f}=e,h=YD(e,YP),{id:p,scale:m}=c,g=YD(c,YA);return ew.createElement(Yi,YI({},h,g,{x:s.x,y:s.y,width:l.width,height:l.height,className:(0,jN.clsx)("recharts-".concat(i," ").concat(i),n),viewBox:r,ticks:o,axisType:i,axisId:t}))},YL={allowDataOverflow:Pj.allowDataOverflow,allowDecimals:Pj.allowDecimals,allowDuplicatedCategory:Pj.allowDuplicatedCategory,angle:Pj.angle,axisLine:X9.axisLine,height:Pj.height,hide:!1,includeHidden:Pj.includeHidden,interval:Pj.interval,label:!1,minTickGap:Pj.minTickGap,mirror:Pj.mirror,orientation:Pj.orientation,padding:Pj.padding,reversed:Pj.reversed,scale:Pj.scale,tick:Pj.tick,tickCount:Pj.tickCount,tickLine:X9.tickLine,tickSize:X9.tickSize,type:Pj.type,niceTicks:Pj.niceTicks,xAxisId:0},Y$=ew.memo(e=>{var t=zE(e,YL);return ew.createElement(ew.Fragment,null,ew.createElement(Y_,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),ew.createElement(YR,t))},YE);Y$.displayName="XAxis";var YF=["type"],YB=["dangerouslySetInnerHTML","ticks","scale"],YV=["id","scale"];function YH(){return(YH=Object.assign.bind()).apply(null,arguments)}function YU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YW(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YU(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yq(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function YK(e){var t=kK(),n=(0,ew.useRef)(null),r=Cs(),{type:a}=e,i=Yq(e,YF),o=CF(r,"yAxis",a),l=(0,ew.useMemo)(()=>{if(null!=o)return YW(YW({},i),{},{type:o})},[o,i]);return(0,ew.useLayoutEffect)(()=>{null!=l&&(null===n.current?t($e(l)):n.current!==l&&t($t({prev:n.current,next:l})),n.current=l)},[l,t]),(0,ew.useLayoutEffect)(()=>()=>{n.current&&(t($n(n.current)),n.current=null)},[t]),null}function YG(e){var{yAxisId:t,className:n,width:r,label:a}=e,i=(0,ew.useRef)(null),o=(0,ew.useRef)(null),l=kZ(kH),s=Nq(),c=kK(),d="yAxis",u=kZ(e=>A1(e,t)),f=kZ(e=>A0(e,t)),h=kZ(e=>A6(e,d,t,s)),p=kZ(e=>PC(e,t));if((0,ew.useLayoutEffect)(()=>{if(!("auto"!==r||!u||RV(a)||(0,ew.isValidElement)(a))&&null!=p){var e=i.current;if(e){var n=e.getCalculatedWidth();Math.round(u.width)!==Math.round(n)&&c($o({id:t,width:n}))}}},[h,u,c,a,t,r,p]),null==u||null==f||null==p)return null;var{dangerouslySetInnerHTML:m,ticks:g,scale:v}=e,x=Yq(e,YB),{id:y,scale:b}=p,w=Yq(p,YV);return ew.createElement(Yi,YH({},x,w,{ref:i,labelRef:o,x:f.x,y:f.y,tickTextProps:"auto"===r?{width:void 0}:{width:r},width:u.width,height:u.height,className:(0,jN.clsx)("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:h,axisType:d,axisId:t}))}var YX={allowDataOverflow:PN.allowDataOverflow,allowDecimals:PN.allowDecimals,allowDuplicatedCategory:PN.allowDuplicatedCategory,angle:PN.angle,axisLine:X9.axisLine,hide:!1,includeHidden:PN.includeHidden,interval:PN.interval,label:!1,minTickGap:PN.minTickGap,mirror:PN.mirror,orientation:PN.orientation,padding:PN.padding,reversed:PN.reversed,scale:PN.scale,tick:PN.tick,tickCount:PN.tickCount,tickLine:X9.tickLine,tickSize:X9.tickSize,type:PN.type,niceTicks:PN.niceTicks,width:PN.width,yAxisId:0},YY=ew.memo(e=>{var t=zE(e,YX);return ew.createElement(ew.Fragment,null,ew.createElement(YK,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),ew.createElement(YG,t))},YE);function YZ({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),o=e.find(e=>e.id===a)??e[0],[l,s]=ew.useState({});if(!o)return null;let c=l[o.id]??o.selectedMetricId??o.metrics[0]?.id,d=o.metrics.find(e=>e.id===c)??o.metrics[0];return(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-performance-monitor",n),...r,children:[(0,ey.jsx)(pr,{value:o.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(pf,{className:"h-8",children:e.map(e=>(0,ey.jsx)(ph,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid min-h-0 flex-1 grid-cols-[14rem_minmax(0,1fr)] border-t",children:[(0,ey.jsx)("div",{className:"min-h-0 overflow-auto border-r p-2",children:o.metrics.map(e=>(0,ey.jsxs)("button",{type:"button",onClick:()=>s(t=>({...t,[o.id]:e.id})),className:(0,eI.cn)("grid w-full grid-cols-[3.75rem_minmax(0,1fr)] gap-3 px-2 py-2 text-left transition-colors",e.id===c&&"bg-muted"),children:[(0,ey.jsx)(Y5,{data:e.data,color:e.color}),(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsx)("span",{className:"block truncate text-base leading-tight",children:e.label}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.value}),e.detail?(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.detail}):null]})]},e.id))}),(0,ey.jsxs)("div",{className:"min-h-0 overflow-auto p-5",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-start gap-5",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h2",{className:"text-4xl leading-none font-semibold tracking-normal",children:d?.title}),d?.subtitle?(0,ey.jsx)("p",{className:"mt-1 text-base text-muted-foreground",children:d.subtitle}):null]}),(0,ey.jsx)("div",{className:"text-right text-sm text-muted-foreground",children:d?.detail})]}),d?(0,ey.jsx)(YJ,{metric:d}):null]})]})]})}function YJ({metric:e}){return"cpu"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"cpu",title:"% 利用率",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:4})]}):"memory"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"memory",title:"内存使用量",value:e.detail,data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y1,{segments:e.composition}),(0,ey.jsx)(Y2,{details:e.details,columns:3})]}):"disk"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"disk-active",title:"活动时间",value:"100%",data:e.data,span:"full"},size:"large"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(YQ,{panel:{id:"disk-rate",title:"磁盘传输速率",value:"500 KB/秒",data:e.panels?.[0]?.data??e.data,span:"full"},size:"short"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:4})]}):"network"===e.kind?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(YQ,{panel:{id:"network",title:"吞吐量",value:"100 Kbps",data:e.data,span:"full",color:"danger"},size:"tall"}),(0,ey.jsx)(Y0,{}),(0,ey.jsx)(Y2,{details:e.details,columns:2})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:(e.panels??[]).map(e=>(0,ey.jsx)(YQ,{panel:e},e.id))}),(0,ey.jsx)(Y2,{details:e.details,columns:3})]})}function YQ({panel:e,size:t="normal"}){let n={short:"h-[4rem]",normal:"full"===e.span?"h-20":"h-24",large:"h-[17.5rem]",tall:"h-[21.5rem]"}[t];return(0,ey.jsxs)("div",{className:(0,eI.cn)("mt-5","full"===e.span&&"col-span-2"),children:[(0,ey.jsxs)("div",{className:"mb-1 flex items-center justify-between text-sm",children:[(0,ey.jsx)("span",{className:"text-muted-foreground",children:e.title}),e.value?(0,ey.jsx)("span",{className:"text-muted-foreground tabular-nums",children:e.value}):null]}),(0,ey.jsx)(Y4,{data:e.data,color:e.color,className:(0,eI.cn)("w-full",n)})]})}function Y0(){return(0,ey.jsxs)("div",{className:"mt-1 flex justify-between text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{children:"60 秒"}),(0,ey.jsx)("span",{children:"0"})]})}function Y1({segments:e}){let t=e&&e.length>0?e:[{label:"used",value:64},{label:"available",value:36}];return(0,ey.jsxs)("div",{className:"mt-5",children:[(0,ey.jsx)("div",{className:"mb-1 text-sm text-muted-foreground",children:"内存组合"}),(0,ey.jsx)("div",{className:"flex h-[3.25rem] w-full overflow-hidden border border-primary/75 bg-background",children:t.map((e,n)=>(0,ey.jsx)("div",{className:(0,eI.cn)("h-full border-r border-primary/75 last:border-r-0",0===n?"bg-primary/20":n===t.length-1?"bg-background":"bg-primary/8"),style:{width:`${Math.max(0,e.value)}%`}},`${e.label}-${n}`))})]})}function Y2({details:e,columns:t}){return e?.length?(0,ey.jsx)("div",{className:(0,eI.cn)("mt-5 grid gap-x-10 gap-y-4",2===t&&"grid-cols-2",3===t&&"grid-cols-3",4===t&&"grid-cols-4"),children:e.map(([e,t])=>(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("div",{className:"truncate text-2xl leading-tight tabular-nums",children:t})]},e))}):null}function Y5({data:e,color:t}){return(0,ey.jsx)(Y4,{data:e,color:t,className:"h-10 w-full",strokeWidth:1.4,compact:!0})}function Y4({data:e,color:t="default",className:n,strokeWidth:r=1.6,compact:a=!1}){let i=ew.useMemo(()=>(e.length>1?e:[0,0]).map((e,t)=>({index:t,value:Math.max(0,Math.min(100,e))})),[e]),o=ew.useMemo(()=>({value:{label:"Value",color:"danger"===t?"var(--destructive)":"var(--foreground)"}}),[t]);return(0,ey.jsx)(BZ,{config:o,className:(0,eI.cn)("aspect-auto border bg-background text-muted-foreground",n),initialDimension:{width:a?96:640,height:a?40:220},children:(0,ey.jsxs)(XJ,{data:i,margin:{top:a?2:6,right:0,bottom:0,left:0},children:[a?null:(0,ey.jsx)(Yk,{strokeDasharray:"0",stroke:"var(--border)",strokeOpacity:.7}),(0,ey.jsx)(Y$,{dataKey:"index",hide:!0,domain:["dataMin","dataMax"]}),(0,ey.jsx)(YY,{hide:!0,domain:[0,100]}),a?null:(0,ey.jsx)(BA,{cursor:!1,content:(0,ey.jsx)(BQ,{hideLabel:!0,indicator:"line"})}),(0,ey.jsx)(Xq,{dataKey:"value",type:"monotone",fill:"var(--color-value)",fillOpacity:"danger"===t?.16:.12,stroke:"var(--color-value)",strokeWidth:r,isAnimationActive:!1,dot:!1,activeDot:!1})]})})}YY.displayName="YAxis";let Y3=(0,ek.default)("badge-alert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Y6=(0,ek.default)("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),Y8={name:"名称",cpu:"CPU",memoryMb:"内存",diskMbps:"磁盘",networkMbps:"网络"};function Y7({machines:e,defaultMachineId:t,className:n,...r}){let[a,i]=ew.useState(t??e[0]?.id),[o,l]=ew.useState("cpu"),[s,c]=ew.useState("desc"),[d,u]=ew.useState({}),f=e.find(e=>e.id===a)??e[0],h=ew.useMemo(()=>{if(!f)return[];let e=[...function(e){let t=new Map,n=new Map;for(let t of e)void 0!==t.pid&&n.set(t.pid,t);for(let a of e){var r;let e=function e(t,n,r=new Set){void 0!==t.pid&&r.add(t.pid);let a=void 0!==t.parentPid?n.get(t.parentPid):void 0;return!a||void 0===a.pid||r.has(a.pid)||["bash","containerd","dockerd","explorer","init","kernel_task","launchd","services","sh","smss","svchost","system","systemd","wininit","winlogon","zsh"].includes(Za(a))?t:e(a,n,r)}(a,n),i=Za(e),o=t.get(i)??{kind:"group",id:i,name:(r=e,r.appName?.trim()||r.name.trim().replace(/\.(exe|com)$/i,"")||r.id),children:[],status:[],cpu:0,memoryMb:0,diskMbps:0,networkMbps:0};o.children.push(a),o.cpu+=a.cpu,o.memoryMb+=a.memoryMb,o.diskMbps+=a.diskMbps,o.networkMbps+=a.networkMbps,o.status=function(e,t){let n=new Set(e??[]);for(let e of t??[])n.add(e);return Array.from(n)}(o.status,a.status),t.set(i,o)}return Array.from(t.values()).map(e=>({...e,cpu:Zo(Math.min(100,e.cpu)),memoryMb:Zo(e.memoryMb),diskMbps:Zo(e.diskMbps),networkMbps:Zo(e.networkMbps)}))}(f.processes)].sort((e,t)=>Zi(e,t,o,s)),t=[];for(let n of e){if(n.children.length<=1){let e=n.children[0];e&&t.push(Zr(e,0));continue}if(t.push(n),d[n.id])for(let e of[...n.children].sort((e,t)=>Zi(e,t,o,s)))t.push(Zr(e,1))}return t},[f,d,s,o]),p=ew.useMemo(()=>h.map(e=>({memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps})),[h]);function m(e){e===o?c(e=>"asc"===e?"desc":"asc"):(l(e),c("name"===e?"asc":"desc"))}return f?(0,ey.jsxs)("div",{className:(0,eI.cn)("vtl-surface-card flex h-full min-h-0 flex-col rounded-[var(--surface-card-radius)] border","vtl-process-monitor",n),...r,children:[(0,ey.jsx)(pr,{value:f.id,onValueChange:i,className:"shrink-0 px-3 pt-3",children:(0,ey.jsx)(pf,{className:"h-8",children:e.map(e=>(0,ey.jsx)(ph,{value:e.id,children:e.name},e.id))})}),(0,ey.jsxs)("div",{className:"mt-3 grid h-14 shrink-0 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] border-y text-sm",children:[(0,ey.jsxs)("button",{type:"button",onClick:()=>m("name"),className:"flex items-end px-3 pb-2 text-left text-muted-foreground",children:["名称",(0,ey.jsx)(Y9,{active:"name"===o,direction:s})]}),(0,ey.jsx)("div",{className:"flex items-end px-3 pb-2 text-muted-foreground",children:"状态"}),["cpu","memoryMb","diskMbps","networkMbps"].map(e=>{var t,n;return(0,ey.jsxs)("button",{type:"button",onClick:()=>m(e),className:"grid content-end border-l px-3 pb-2 text-right",children:[(0,ey.jsx)("span",{className:"text-lg leading-none text-foreground",children:(t=f.totals,"cpu"===(n=e)?`${Math.round(t.cpu)}%`:"memoryMb"===n?`${Math.round(t.memory)}%`:"diskMbps"===n?`${Math.round(t.disk)}%`:"networkMbps"===n?`${Math.round(t.network)}%`:"")}),(0,ey.jsxs)("span",{className:"mt-1 text-xs text-muted-foreground",children:[Y8[e],(0,ey.jsx)(Y9,{active:o===e,direction:s,className:"ml-1 inline-flex"})]})]},e)})]}),(0,ey.jsx)("div",{className:"vtl-scrollbar-hidden min-h-0 flex-1 overflow-auto",children:h.map(e=>{var t;return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-9 grid-cols-[minmax(12rem,1fr)_6.25rem_repeat(4,minmax(5rem,7rem))] items-center text-sm","group"===e.kind&&"bg-muted/35"),children:[(0,ey.jsx)(Ze,{row:e,expanded:"group"===e.kind&&!!d[e.id],onToggle:()=>{"group"===e.kind&&u(t=>({...t,[e.id]:!t[e.id]}))}}),(0,ey.jsx)(Zt,{platform:f.platform,status:e.status}),(0,ey.jsx)(Zn,{value:e.cpu,max:100,label:`${e.cpu.toFixed(1)}%`}),(0,ey.jsx)(Zn,{value:e.memoryMb,max:Zl(p,"memoryMb"),label:(t=e.memoryMb)>=1024?`${Zs(t/1024)} GB`:`${Zs(t)} MB`}),(0,ey.jsx)(Zn,{value:e.diskMbps,max:Math.max(1,Zl(p,"diskMbps")),label:`${Zs(e.diskMbps)} MB/秒`}),(0,ey.jsx)(Zn,{value:e.networkMbps,max:Math.max(1,Zl(p,"networkMbps")),label:`${Zs(e.networkMbps)} Mbps`})]},`${e.kind}-${e.id}`)})})]}):null}function Y9({active:e,direction:t,className:n}){return e?(0,ey.jsx)("asc"===t?jv:jg,{className:(0,eI.cn)("ml-1 size-3",n)}):null}function Ze({row:e,expanded:t,onToggle:n}){if("group"===e.kind){let r=t?g8:p$;return(0,ey.jsxs)("button",{type:"button","aria-expanded":t,onClick:n,className:"flex h-full min-w-0 items-center gap-2 px-3 text-left outline-none transition-colors hover:bg-muted/55 focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"size-2 rounded-sm bg-foreground/65"}),(0,ey.jsxs)("span",{className:"min-w-0 truncate font-medium",children:[e.name," (",e.children.length,")"]})]})}return(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-3",style:{paddingLeft:e.depth>0?34:void 0},children:[e.depth>0?(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/70"}):(0,ey.jsx)("span",{className:"size-1.5 rounded-full bg-foreground/65"}),(0,ey.jsx)("span",{className:(0,eI.cn)("truncate",0===e.depth&&"font-medium"),children:e.name}),e.process.pid?(0,ey.jsx)("span",{className:"shrink-0 ui-text-kbd text-muted-foreground",children:e.process.pid}):null]})}function Zt({platform:e,status:t}){return t?.length?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 px-3 text-muted-foreground",children:[t.includes("suspended")?(0,ey.jsx)(Y6,{"aria-label":"linux"===e?"挂起进程":"挂起",className:"size-4"}):null,t.includes("auto-restart")?(0,ey.jsx)(lQ,{"aria-label":"linux"===e?"自动重启进程":"自动重启",className:"size-4"}):null,t.includes("running")?(0,ey.jsx)(Y3,{"aria-label":"运行",className:"size-4 text-primary"}):null]}):(0,ey.jsx)("div",{className:"px-3"})}function Zn({value:e,max:t,label:n}){let r=Math.min(1,Math.max(0,e/Math.max(1,t))),a=r>.78,i=a?`color-mix(in oklch, var(--destructive) ${Math.round(18+42*r)}%, var(--background))`:`color-mix(in oklch, var(--foreground) ${Math.round(5+20*r)}%, var(--background))`;return(0,ey.jsx)("div",{className:"vtl-process-heat-cell h-full border-l px-3 text-right tabular-nums","data-hot":a?"":void 0,style:{background:i},children:(0,ey.jsx)("span",{className:(0,eI.cn)("leading-9",a&&"text-destructive"),children:n})})}function Zr(e,t){return{kind:"process",id:e.id,process:e,depth:t,name:e.appName&&0===t?e.appName:e.name,status:e.status,cpu:e.cpu,memoryMb:e.memoryMb,diskMbps:e.diskMbps,networkMbps:e.networkMbps}}function Za(e){return e.appId?.trim().toLowerCase()||e.appName?.trim().toLowerCase()||e.name.trim().toLowerCase().replace(/\.(exe|com)$/i,"")||e.id}function Zi(e,t,n,r){let a="asc"===r?1:-1;return"name"===n?e.name.localeCompare(t.name)*a:(e[n]-t[n])*a}function Zo(e){return Math.round(10*e)/10}function Zl(e,t){return e.reduce((e,n)=>Math.max(e,n[t]),0)}function Zs(e){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:+(e<10)}).format(e)}function Zc({className:e}){let t=Zu("/api/local/machines/processes"),n=Zf("/machines/processes"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(Y7,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Zd({className:e}){let t=Zu("/api/local/machines/performance"),n=Zf("/machines/performance"),r=ew.useMemo(()=>[...t,...n],[t,n]);return(0,ey.jsx)(YZ,{machines:r,className:(0,eI.cn)("h-full min-h-0 w-full",e)})}function Zu(e){let[t,n]=ew.useState([]);return ew.useEffect(()=>{let t=!0,r=!1;async function a(){if(!r){r=!0;try{let r=await fetch(eD(e),{cache:"no-store"});if(!r.ok)return;let a=await r.json();t&&n(a.machines)}catch{t&&n([])}finally{r=!1}}}a();let i=window.setInterval(a,2e3);return()=>{t=!1,window.clearInterval(i)}},[e]),t}function Zf(e){let{machines:t}=vs(),[n,r]=ew.useState([]),a=ew.useMemo(()=>t.filter(e=>!e.isLocal&&"online"===e.status).map(e=>e.id),[t]);return ew.useEffect(()=>{if(0===a.length)return void r([]);let t=!0,n=!1;async function i(){if(!n){n=!0;try{let n=await Promise.all(a.map(async t=>{try{return(await sj(t,e)).machines??[]}catch{return[]}}));t&&r(n.flat())}finally{n=!1}}}i();let o=window.setInterval(i,5e3);return()=>{t=!1,window.clearInterval(o)}},[a,e]),n}let Zh=(0,ek.default)("circle-play",[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Zp=(0,ek.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),Zm={loading:"Starting terminal...",newTerminal:"New terminal",closeTerminal:e=>`Close ${e}`,terminalList:"Terminal sessions",status:{idle:"Idle",running:"Running",success:"Succeeded",error:"Failed"}},Zg=[{id:"powershell",title:"PowerShell",shell:"PowerShell",cwd:"D:\\Projects\\Vantaloom-ui",status:"idle",initialOutput:"PowerShell 7.6.1\r\nPS D:\\Projects\\Vantaloom-ui> "}];function Zv(e,t,n){return e.getPropertyValue(t).trim()||n}function Zx(e,t=!1){let n=getComputedStyle(e),r=Zv(n,"--foreground","#18181b"),a=Zv(n,"--terminal-background",Zv(n,"--background","#ffffff")),i="transparent"===a?Zv(n,"--background","#ffffff"):a,o=Zv(n,"--muted-foreground","#71717a"),l=Zv(n,"--border","#e4e4e7"),s=Zv(n,"--selection","#18181b");return{background:a,foreground:r,cursor:t?"transparent":r,cursorAccent:t?"transparent":i,selectionBackground:`color-mix(in oklch, ${s} 18%, transparent)`,selectionForeground:Zv(n,"--selection-foreground","#ffffff"),scrollbarSliderBackground:`color-mix(in oklch, ${l} 78%, transparent)`,scrollbarSliderHoverBackground:l,black:r,red:Zv(n,"--terminal-red","#bf616a"),green:Zv(n,"--terminal-green","#5e8c61"),yellow:Zv(n,"--terminal-yellow","#b06f3c"),blue:Zv(n,"--terminal-blue","#5e81ac"),magenta:Zv(n,"--terminal-magenta","#b48ead"),cyan:Zv(n,"--terminal-cyan","#4c8da8"),white:a,brightBlack:o,brightRed:Zv(n,"--terminal-bright-red","#d06f79"),brightGreen:Zv(n,"--terminal-bright-green","#6b9a70"),brightYellow:Zv(n,"--terminal-bright-yellow","#c2824b"),brightBlue:Zv(n,"--terminal-bright-blue","#6f91ba"),brightMagenta:Zv(n,"--terminal-bright-magenta","#c19ac0"),brightCyan:Zv(n,"--terminal-bright-cyan","#5aa0b8"),brightWhite:r}}function Zy(e){return void 0===e?[]:Array.isArray(e)?e:[e]}function Zb({initialOutput:t,data:n,dataKey:r,options:a,readOnly:i=!1,autoFocus:o=!1,localEcho:l=!1,onData:s,onResize:c,onReady:d,labels:u,className:f,terminalClassName:h,...p}){let m=ew.useMemo(()=>({loading:Zm.loading,...u}),[u]),g=ew.useRef(null),v=ew.useRef(null),x=ew.useRef(void 0),y=ew.useRef(s),b=ew.useRef(c),w=ew.useRef(d),j=ew.useRef(a),k=ew.useRef(i),S=ew.useRef(l),N=ew.useRef(!1),C=ew.useRef(void 0),M=ew.useRef(!1),[E,O]=ew.useState(!1);return ew.useEffect(()=>{y.current=s,b.current=c,w.current=d,j.current=a,k.current=i,S.current=l},[l,s,d,c,a,i]),ew.useEffect(()=>{let n,r=!1,a=[];!async function(){var i;let l,s,c,d,u;if(!g.current||M.current)return;M.current=!0;let[{Terminal:f},{FitAddon:h},{SearchAddon:p},{WebLinksAddon:m}]=await Promise.all([e.A(93626),e.A(16118),e.A(24306),e.A(46866)]);if(r||!g.current)return;let C=new f({convertEol:!1,cursorBlink:!0,cursorStyle:"block",drawBoldTextInBrightColors:!1,fontFamily:(l=getComputedStyle(i=g.current),u=(c=Zv(l,"--font-family-mono",s='"Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", "Liberation Mono", monospace'),d=getComputedStyle(i),c.replace(/var\((--[a-zA-Z0-9-_]+)(?:,[^)]+)?\)/g,(e,t)=>d.getPropertyValue(t).trim()||"")).trim(),`"Cascadia Mono", "Cascadia Code", Consolas, ${u||s}`),fontSize:13,letterSpacing:0,lineHeight:1.25,macOptionIsMeta:!0,minimumContrastRatio:4.5,scrollback:5e3,theme:Zx(g.current),...j.current,allowTransparency:!0}),E=new h,P=new p,A=new m;function I(){try{E.fit(),b.current?.({cols:C.cols,rows:C.rows})}catch{}}for(let e of(C.loadAddon(E),C.loadAddon(P),C.loadAddon(A),C.open(g.current),v.current=C,x.current=E,O(!0),requestAnimationFrame(I),(n=new ResizeObserver(I)).observe(g.current),a.push(C.onData(e=>{k.current||(S.current&&("\r"===e?C.write("\r\n"):""===e?C.write("\b \b"):C.write(e)),y.current?.(e))})),Zy(t)))C.write(e);w.current?.({terminal:C,fitAddon:E,searchAddon:P,webLinksAddon:A,fit:I,focus:()=>C.focus(),clear:()=>C.clear(),setCursorSuppressed:function(e){let t=g.current;t&&(N.current=e,t.toggleAttribute("data-vtl-terminal-cursor-suppressed",e),C.options.theme=Zx(t,e))},write:(e,t)=>C.write(e,t),writeln:e=>C.writeln(e)}),o&&C.focus()}();let i=new MutationObserver(()=>{let e=v.current,t=g.current;e&&t&&(e.options.theme=Zx(t,N.current))});return i.observe(document.documentElement,{attributeFilter:["class","style"],attributes:!0}),()=>{for(let e of(r=!0,i.disconnect(),n?.disconnect(),a))e.dispose();v.current?.dispose(),v.current=null,x.current=void 0,N.current=!1,M.current=!1,O(!1)}},[o,t]),ew.useEffect(()=>{let e=v.current;if(e&&C.current!==r)for(let t of(C.current=r,Zy(n)))e.write(t)},[n,r]),(0,ey.jsxs)("div",{"data-slot":"terminal-tab-surface",className:(0,eI.cn)("relative size-full min-h-0 overflow-hidden bg-background text-foreground",f),...p,children:[(0,ey.jsx)("div",{ref:g,className:(0,eI.cn)("vtl-terminal-xterm size-full overflow-hidden p-1.5 font-mono","[&_.xterm]:h-full [&_.xterm]:p-0 [&_.xterm-viewport]:!bg-transparent","[&_.xterm-screen]:!bg-transparent [&_.xterm-helper-textarea]:!outline-none","[&[data-vtl-terminal-cursor-suppressed]_.xterm-cursor]:!opacity-0","[&_.xterm-viewport::-webkit-scrollbar]:w-2.5 [&_.xterm-viewport::-webkit-scrollbar-track]:bg-transparent","[&_.xterm-viewport::-webkit-scrollbar-thumb]:rounded-full [&_.xterm-viewport::-webkit-scrollbar-thumb]:border-[3px]","[&_.xterm-viewport::-webkit-scrollbar-thumb]:border-transparent [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-border [&_.xterm-viewport::-webkit-scrollbar-thumb]:bg-clip-content",h)}),!E&&(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center text-muted-foreground ui-text-code",children:m.loading})]})}function Zw({status:e="idle"}){return"running"===e?(0,ey.jsx)(Zh,{className:"size-3.5 text-foreground"}):"success"===e?(0,ey.jsx)(eO,{className:"size-3.5 text-foreground"}):"error"===e?(0,ey.jsx)(eE,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(bh,{className:"size-3.5 text-muted-foreground"})}function Zj({session:e}){return e.aiControlled?(0,ey.jsx)(Zp,{className:"size-3.5 text-destructive"}):(0,ey.jsx)(Zw,{status:e.status})}function Zk({sessions:e,defaultSessions:t=Zg,activeSessionId:n,defaultActiveSessionId:r,onActiveSessionChange:a,onSessionsChange:i,onCreateSession:o,onCloseSession:l,onSessionData:s,onSessionResize:c,onSessionReady:d,showTabs:u=!0,allowCreateSession:f=!0,readOnly:h=!1,localEcho:p=!1,terminalOptions:m,labels:g,className:v,tabListClassName:x,terminalClassName:y,...b}){let w=ew.useMemo(()=>({...Zm,...g,status:{...Zm.status,...g?.status}}),[g]),[j,k]=ew.useState(t),S=e??j,N=S[0],[C,M]=ew.useState(r??N?.id),E=n??(S.some(e=>e.id===C)?C:N?.id),O=S.find(e=>e.id===E)??N;function P(t){void 0===e&&k(t),i?.(t)}function A(e){e.disabled||(void 0===n&&M(e.id),a?.(e.id,e))}return(0,ey.jsxs)("div",{"data-slot":"terminal-tab-group",className:(0,eI.cn)("vtl-surface-panel grid min-h-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",u?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",v),...b,children:[u&&(0,ey.jsxs)("div",{"data-slot":"terminal-tab-list",role:"tablist","aria-label":w.terminalList,className:(0,eI.cn)("flex min-w-0 items-center gap-1 border-b bg-muted/35 px-2 py-1.5",x),children:[(0,ey.jsx)(uj,{className:"ml-1 size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsxs)("div",{className:(0,eI.cn)("group flex h-7 min-w-0 shrink-0 items-center rounded-md border border-transparent ui-text-control","transition-colors hover:bg-background/80",t?"bg-background text-foreground shadow-xs":"text-muted-foreground",e.disabled&&"pointer-events-none opacity-50"),children:[(0,ey.jsxs)("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":`terminal-panel-${e.id}`,disabled:e.disabled,onClick:()=>A(e),className:"flex h-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/20",children:[(0,ey.jsx)(Zj,{session:e}),(0,ey.jsx)("span",{className:"max-w-36 truncate",children:e.title}),e.shell&&(0,ey.jsx)("span",{className:"hidden text-muted-foreground ui-text-kbd sm:inline",children:e.shell})]}),e.closable&&(0,ey.jsx)("button",{type:"button","aria-label":w.closeTerminal(e.title),onClick:t=>{t.stopPropagation();l?.(e.id,e);let n=S.filter(t=>t.id!==e.id);if(P(n),e.id===E){let e=n.at(-1);e&&A(e)}},className:"mr-1 grid size-4 place-items-center rounded-sm text-muted-foreground opacity-0 outline-none transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/20 group-hover:opacity-100",children:(0,ey.jsx)(fc.XIcon,{className:"size-3"})})]},e.id)})}),f&&(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":w.newTerminal,onClick:function(){let e=o?.()??{id:`terminal-${Date.now()}`,title:`Terminal ${S.length+1}`,status:"idle",initialOutput:"",closable:!0};P([...S,e]),A(e)},className:"size-7 shrink-0",children:(0,ey.jsx)(lJ,{className:"size-3.5"})})]}),(0,ey.jsx)("div",{"data-slot":"terminal-tab-panels",className:"relative min-h-0 overflow-hidden",children:S.map(e=>{let t=e.id===O?.id;return(0,ey.jsx)(ZS,{session:e,selected:t,terminalOptions:m,readOnly:h,localEcho:p,onSessionData:s,onSessionResize:c,onSessionReady:d,labels:w,terminalClassName:y},e.id)})})]})}function ZS({session:e,selected:t,terminalOptions:n,readOnly:r,localEcho:a,onSessionData:i,onSessionResize:o,onSessionReady:l,labels:s,terminalClassName:c}){let d=ew.useRef(null),u=ew.useRef(t);return ew.useEffect(()=>{if(t&&!u.current&&d.current){let e=d.current;requestAnimationFrame(()=>{e&&(e.fit(),e.terminal.refresh(0,e.terminal.rows-1),e.terminal.focus())})}u.current=t},[t]),(0,ey.jsx)("div",{id:`terminal-panel-${e.id}`,role:"tabpanel","aria-hidden":!t,"data-active":t,className:"absolute inset-0 min-h-0",style:{display:t?"block":"none"},children:(0,ey.jsx)(Zb,{initialOutput:e.initialOutput,options:{...n,...e.options},readOnly:r||e.disabled,localEcho:a,autoFocus:t,onData:t=>i?.(e.id,t),onResize:t=>o?.(e.id,t),onReady:t=>{d.current=t,l?.(e.id,t)},labels:s,terminalClassName:c})})}function ZN({className:e,scopeId:t,state:n,onStateChange:r}){let[a,i]=ew.useState([]),[o,l]=ew.useState([]),[s,c]=ew.useState(),[d,u]=ew.useState("local"),[f,h]=ew.useState(),[p,m]=ew.useState(!1),[g,v]=ew.useState(!1),x=ew.useRef(new Map),y=ew.useRef(new Map),b=ew.useRef(new Map),w=ew.useRef(new Map),j=ew.useRef(new Map),k=ew.useRef(new Map),S=ew.useRef(new Map),N=ew.useRef(new Map),C=ew.useRef(!1),M=ew.useRef(n?.autoStart===!1),E=ew.useRef(n),O=ew.useRef(r),P=Array.isArray(n?.sessionIds)?n.sessionIds.join("\0"):"__all__",A=t?.trim()||void 0,I=A??"__unscoped__";ew.useEffect(()=>{E.current=n},[n]),ew.useEffect(()=>{O.current=r},[r]);let z=a.find(e=>e.id===d)??a[0],T=z?.shells?.find(e=>e.id===f)??z?.shells?.[0],D=ew.useMemo(()=>o.map(e=>e.id),[o]),_=ew.useMemo(()=>o.filter(e=>e.aiControlled).map(e=>e.id),[o]),R=D.join("\0"),L=_.join("\0"),$=ew.useCallback((e,t)=>{let n=y.current.get(e);if(t){let t=j.current.get(e);void 0!==t&&(window.clearTimeout(t),j.current.delete(e))}n?.setCursorSuppressed(t)},[]),F=ew.useCallback(e=>{let t=j.current.get(e);void 0!==t&&window.clearTimeout(t);let n=window.setTimeout(()=>{j.current.delete(e),$(e,!1)},90);j.current.set(e,n)},[$]),B=ew.useCallback(e=>{let t=w.current.get(e),n=y.current.get(e);if(!t||!n||t.writing)return;if(!t.buffer){w.current.delete(e),F(e);return}void 0!==t.drainTimer&&(window.clearTimeout(t.drainTimer),t.drainTimer=void 0);let r=t.buffer.slice(0,65536);t.buffer=t.buffer.slice(r.length),t.writing=!0,$(e,!0);try{n.write(r,()=>{(t.writing=!1,y.current.has(e))?t.buffer?t.drainTimer=window.setTimeout(()=>B(e),0):(w.current.delete(e),F(e)):w.current.delete(e)})}catch{t.writing=!1,w.current.delete(e),F(e)}},[F,$]),V=ew.useCallback((e,t)=>{if(!t)return;if(!y.current.get(e))return void b.current.set(e,`${b.current.get(e)??""}${t}`);let n=w.current.get(e);(n||(n={buffer:"",writing:!1},w.current.set(e,n)),n.buffer+=t,$(e,!0),n.buffer.length>=65536)?B(e):n.writing||void 0!==n.drainTimer||(n.drainTimer=window.setTimeout(()=>B(e),8))},[B,$]),H=ew.useCallback((e,t)=>{(k.current.set(e,t.sequence),"output"===t.type&&t.data)?V(e,t.data):"status"===t.type&&t.status&&l(n=>n.map(n=>n.id===e?{...n,status:t.status??n.status,updatedAt:t.createdAt}:n))},[V]),U=ew.useCallback(e=>{if(x.current.has(e))return;let t=new EventSource(function(e,t=0){let n=new URLSearchParams;t>0&&n.set("after",String(t));let r=n.toString();return eD(`/api/local/terminals/sessions/${encodeURIComponent(e)}/events${r?`?${r}`:""}`)}(e,k.current.get(e)??0));t.onmessage=t=>{try{H(e,JSON.parse(t.data))}catch{return}},x.current.set(e,t)},[H]),W=ew.useCallback(async()=>{if(z&&!p){M.current=!1,m(!0);try{let e=await fa({machineId:z.id,scopeId:A,shell:T?.id,cwd:z.defaultCwd,cols:100,rows:30});l(t=>t.some(t=>t.id===e.id)?t:[...t,e]),c(e.id),U(e.id)}catch{return}finally{m(!1)}}},[p,U,z,T,A]);function q(e){let t=S.current.get(e);return t||(t={buffer:"",inFlight:!1},S.current.set(e,t)),t}return ew.useEffect(()=>{let e=!0;return v(!1),async function(){try{let t=E.current,n=t?.sessionIds,r=Array.isArray(n)?new Set(n):void 0,[a,o]=await Promise.all([fn(),fr(A)]);if(!e)return;let s=r?o.sessions.filter(e=>r.has(e.id)):o.sessions;C.current=!1,M.current=t?.autoStart===!1,i(a.machines),l(s),c(e=>{let n=t?.activeSessionId??e;return n&&s.some(e=>e.id===n)?n:s[0]?.id});let d=a.machines[0];if(d){let e=a.machines.find(e=>e.id===t?.selectedMachineId)??d;u(e.id),h(n=>t?.selectedShellId&&e.shells?.some(e=>e.id===t.selectedShellId)?t.selectedShellId:n&&e.shells?.some(e=>e.id===n)?n:e.shells?.[0]?.id)}}finally{e&&v(!0)}}(),()=>{e=!1}},[P,A,I]),ew.useEffect(()=>{g&&O.current?.({sessionIds:D,activeSessionId:s,selectedMachineId:d,selectedShellId:f,autoStart:!M.current,aiControlledSessionIds:_})},[s,_,L,g,d,f,D,R]),ew.useEffect(()=>{let e=new Set(D);for(let e of o)U(e.id);for(let[t,n]of x.current)e.has(t)||(n.close(),x.current.delete(t))},[U,D,o]),ew.useEffect(()=>{!g||C.current||M.current||o.length>0||0===a.length||(C.current=!0,W())},[W,g,a.length,o.length]),ew.useEffect(()=>()=>{for(let e of x.current.values())e.close();for(let e of S.current.values())void 0!==e.timer&&window.clearTimeout(e.timer);for(let e of w.current.values())void 0!==e.drainTimer&&window.clearTimeout(e.drainTimer);for(let[e,t]of j.current)window.clearTimeout(t),$(e,!1);S.current.clear(),w.current.clear(),j.current.clear()},[$]),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid h-full min-h-0 w-full grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit] border bg-card",e),children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 border-b bg-muted/35 px-2 py-1.5",children:[(0,ey.jsxs)(gb,{value:z?.id,onValueChange:e=>{u(e);let t=a.find(t=>t.id===e);h(t?.shells?.[0]?.id)},children:[(0,ey.jsxs)(g9,{size:"sm",className:"max-w-44",children:[(0,ey.jsx)(xJ,{className:"size-3.5"}),(0,ey.jsx)(gS,{placeholder:"机器"})]}),(0,ey.jsx)(vn,{align:"start",children:a.filter(e=>"online"===e.status).map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsxs)(gb,{value:T?.id,onValueChange:h,children:[(0,ey.jsx)(g9,{size:"sm",className:"max-w-44",children:(0,ey.jsx)(gS,{placeholder:"Shell"})}),(0,ey.jsx)(vn,{align:"start",children:z?.shells?.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.name},e.id))})]}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"新建终端",disabled:!z||p,onClick:()=>void W(),className:"ml-auto",children:(0,ey.jsx)(lJ,{className:"size-4"})})]}),(0,ey.jsx)(Zk,{sessions:o.map(ZC),activeSessionId:s,allowCreateSession:!1,localEcho:!1,labels:{loading:"启动终端...",terminalList:"终端会话",closeTerminal:e=>`关闭 ${e}`},onActiveSessionChange:e=>c(e),onCloseSession:e=>{let t,n,r;return x.current.get(e)?.close(),x.current.delete(e),y.current.delete(e),b.current.delete(e),t=w.current.get(e),t?.drainTimer!==void 0&&window.clearTimeout(t.drainTimer),w.current.delete(e),k.current.delete(e),void 0!==(n=j.current.get(e))&&(window.clearTimeout(n),j.current.delete(e)),r=S.current.get(e),void(r?.timer!==void 0&&window.clearTimeout(r.timer),S.current.delete(e),N.current.delete(e),l(t=>{let n=t.filter(t=>t.id!==e);return 0===n.length&&(M.current=!0),c(t=>t&&t!==e&&n.some(e=>e.id===t)?t:n[0]?.id),n}),fi(e).catch(()=>{}))},onSessionData:function(e,t){let n=q(e);n.buffer+=t,function e(t){let n=q(t);n.inFlight||void 0!==n.timer||(n.timer=window.setTimeout(()=>{n.timer=void 0,function(t){let n=S.current.get(t);if(!n||n.inFlight)return;let r=n.buffer;if(n.buffer="",!r){void 0===n.timer&&S.current.delete(t);return}n.inFlight=!0,fo(t,r).catch(()=>{}).finally(()=>{let n=S.current.get(t);n&&(n.inFlight=!1,n.buffer?e(t):void 0===n.timer&&S.current.delete(t))})}(t)},6))}(e)},onSessionResize:function(e,t){let n=`${t.cols}x${t.rows}`;N.current.get(e)!==n&&(N.current.set(e,n),fl(e,t).then(e=>{l(t=>t.map(t=>t.id===e.id?{...t,...e}:t))}).catch(()=>{}))},onSessionReady:function(e,t){y.current.set(e,t);let n=b.current.get(e);n&&(b.current.delete(e),V(e,n))},className:"min-h-0 rounded-none border-0"})]})}function ZC(e){return{id:e.id,title:e.title,shell:e.ordinal?`T${e.ordinal}`:"",cwd:e.cwd,status:function(e){switch(e){case"running":return"running";case"exited":case"closed":return"success";case"failed":return"error";default:return"idle"}}(e.status),closable:!0,initialOutput:"",aiControlled:e.aiControlled,controller:e.controller}}function ZM(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e.kind){case"file-tab-viewer":{let r=u_("file-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HS,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(K0,{className:`${n} border-0`,file:a??r.file,value:e.defaultValue??r.defaultValue??"",defaultValue:e.defaultValue??r.defaultValue,view:e.defaultView,mode:e.defaultMode,modified:e.modified,onValueChange:n=>t.onTabChange?.({...e,defaultValue:n,modified:!0}),onViewChange:n=>t.onTabChange?.({...e,defaultView:n}),onModeChange:n=>t.onTabChange?.({...e,defaultMode:n}),onSave:t.onSaveFileTab?n=>t.onSaveFileTab?.(e,n):void 0,onHistory:()=>t.onOpenFileHistory?.(e),labels:{review:"审阅",edit:"编辑",view:"视图",code:"代码",preview:"预览",hex:"十六进制",actions:"文件菜单",save:"保存",saving:"保存中",history:"历史版本"}})}case"browser-tab-viewer":return(0,ey.jsx)(HY,{className:`${n} border-0`,defaultUrl:e.defaultUrl??u_("browser-tab-viewer").defaultUrl});case"diff-tab-viewer":{let t=u_("diff-tab-viewer");return(0,ey.jsx)(U3,{className:`${n} border-0`,file:e.file??t.file,diff:e.diff??t.diff??""})}case"data-table-tab-viewer":{let r=u_("data-table-tab-viewer"),a=e.file;if(!a&&t.onRequestFileTab)return(0,ey.jsx)(HS,{className:n,onChooseFile:t.onRequestFileTab});return(0,ey.jsx)(UG,{className:`${n} border-0`,file:{name:a?.name??r.file?.name??"data",path:a?.path??r.file?.path,type:ZE(e)},source:void 0!==e.defaultValue?{type:ZE(e),content:e.defaultValue}:void 0,data:e.tableData??r.tableData??[]})}case"terminal-tab-group":return(0,ey.jsx)(ZN,{className:`${n} border-0`,scopeId:t.terminalScopeId,state:e.terminal??t.terminalState,onStateChange:t.onTerminalStateChange})}}function ZE(e){return`${e.file?.mimeType??""} ${e.file?.path??e.file?.name??""}`.toLowerCase().includes("json")?"json":"csv"}function ZO(e,t={}){let n="h-full min-h-0 w-full overflow-hidden rounded-[inherit]";switch(e){case"multi-tab-system":{let e=t.nodeId,r=void 0!==t.tabs?t.tabs:[];return(0,ey.jsx)(K4,{className:n,contentClassName:"min-h-0",tabs:r.map(n=>({id:n.id,title:n.title,meta:n.meta,modified:n.modified,icon:uD(n.kind),content:ZM(n,{terminalScopeId:e?`${t.terminalScopeId??`canvas:node:${e}`}:tab:${n.id}`:t.terminalScopeId,terminalState:n.terminal,onTerminalStateChange:r=>e?t.onTabChange?.(e,{...n,terminal:r}):void 0,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length}),onTabChange:n=>{e&&t.onTabChange?.(e,n)},onSaveFileTab:(n,r)=>e?t.onSaveFileTab?.(e,n,r):void 0,onOpenFileHistory:n=>e?t.onOpenFileHistory?.(e,n):void 0})})),activeTabId:t.activeTabId,detachable:!0,externalDropTypes:[Gr],createLabel:"打开文件",emptyContent:(0,ey.jsx)(HS,{onChooseFile:()=>t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})}),onCreateTab:()=>{t.onRequestFileTab?.({nodeId:e,insertIndex:r.length})},onActiveTabChange:n=>{e&&t.onActiveTabChange?.(e,n)},onTabsChange:n=>{if(!e)return;let a=n.map(e=>r.find(t=>t.id===e.id)).filter(e=>!!e);t.onTabsChange?.(e,a)},onTabDetach:(n,a)=>{if(!e)return!1;let i=r.find(e=>e.id===n.id);return!!i&&t.onTabDetach?.(e,i,{clientX:a.clientX,clientY:a.clientY})},onExternalTabDrop:({insertIndex:n,nativeEvent:r})=>{e&&t.onExternalTabDrop?.(e,n,r)}})}case"file-tree-panel":if(t.workspaceFolders)return(0,ey.jsx)(Hj,{folders:t.workspaceFolders,className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});return(0,ey.jsx)(GD,{className:`${n} max-w-none`,onOpenFile:t.onOpenWorkspaceFile});case"process-management":return(0,ey.jsx)(Zc,{className:`${n} rounded-[inherit] border-0`});case"machine-performance":return(0,ey.jsx)(Zd,{className:`${n} rounded-[inherit] border-0`});case"firewall-policy-workspace":return(0,ey.jsx)("div",{className:`${n} bg-card`,children:(0,ey.jsx)(GI,{})});case"machine-file-management":return(0,ey.jsx)(G9,{className:`${n} bg-card`});case"agent-conversation-panel":return(0,ey.jsx)(V1,{className:`${n} vtl-canvas-agent-conversation-node`,composerClassName:"max-w-[42rem]"});case"status-monitor":return(0,ey.jsx)(Gt,{conversationId:t.conversationId,ownerMachineId:t.ownerMachineId});case"file-tab-viewer":case"browser-tab-viewer":case"diff-tab-viewer":case"data-table-tab-viewer":case"terminal-tab-group":return ZM(t.tab??u_(e,`${e}-tab`),{terminalState:t.terminalState,terminalScopeId:t.terminalScopeId,onTerminalStateChange:t.onTerminalStateChange,onRequestFileTab:()=>t.onRequestFileTab?.({nodeId:t.nodeId}),onTabChange:e=>{t.nodeId&&t.onTabChange?.(t.nodeId,e)},onSaveFileTab:(e,n)=>t.nodeId?t.onSaveFileTab?.(t.nodeId,e,n):void 0,onOpenFileHistory:e=>t.nodeId?t.onOpenFileHistory?.(t.nodeId,e):void 0})}}function ZP({kind:e,...t}){return ZO(e,t)}let ZA="application/vnd.vantaloom.agent-pane-shredder",ZI="application/vnd.vantaloom.agent-pane-cutter";function Zz(e,t){return(e?.activeSessionId??"")===(t.activeSessionId??"")&&(e?.selectedMachineId??"")===(t.selectedMachineId??"")&&(e?.selectedShellId??"")===(t.selectedShellId??"")&&(e?.autoStart??!0)===(t.autoStart??!0)&&(e?.sessionIds??[]).join("\0")===t.sessionIds.join("\0")&&(e?.aiControlledSessionIds??[]).join("\0")===(t.aiControlledSessionIds??[]).join("\0")}let ZT=[{id:"quad",label:"四分",slots:4,icon:(0,ey.jsx)(xZ,{})},{id:"vertical-split",label:"上下二分",slots:2,icon:(0,ey.jsx)(HF,{})},{id:"horizontal-split",label:"左右二分",slots:2,icon:(0,ey.jsx)(HT,{})},{id:"left-two-right-one",label:"左二右一",slots:3,icon:(0,ey.jsx)(s2,{})},{id:"left-one-right-two",label:"左一右二",slots:3,icon:(0,ey.jsx)(s4,{})},{id:"top-two-bottom-one",label:"上二下一",slots:3,icon:(0,ey.jsx)(HF,{})},{id:"top-one-bottom-two",label:"上一下二",slots:3,icon:(0,ey.jsx)(H$,{})},{id:"single",label:"整窗口",slots:1,icon:(0,ey.jsx)(HL,{})}];function ZD(e,t,n=[50,50]){let r=e?.[t],a=r?.[0],i=r?.[1];return["number"==typeof a&&a>0?a:n[0],"number"==typeof i&&i>0?i:n[1]]}function Z_(e,t){return{[e[0]]:t[0],[e[1]]:t[1]}}function ZR(e,t){return[e[t[0]]??50,e[t[1]]??50]}function ZL({mode:e,sizes:t,onSizeGroupChange:n,children:r}){if("single"===e)return(0,ey.jsx)("div",{className:"size-full min-h-0",children:r[0]});if("horizontal-split"===e){let e=ZD(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(a,e),onLayoutChanged:e=>n?.("outer",ZR(e,a)),children:[(0,ey.jsx)(hg,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("vertical-split"===e){let e=ZD(t,"outer"),a=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(a,e),onLayoutChanged:e=>n?.("outer",ZR(e,a)),children:[(0,ey.jsx)(hg,{id:a[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:a[1],defaultSize:e[1],minSize:24,children:r[1]})]})}if("left-two-right-one"===e){let e=ZD(t,"outer",[58,42]),a=ZD(t,"left"),i=["left","right"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("left",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:20,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:20,children:r[1]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("left-one-right-two"===e){let e=ZD(t,"outer",[42,58]),a=ZD(t,"right"),i=["left","right"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("right",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:20,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:20,children:r[2]})]})})]})}if("top-two-bottom-one"===e){let e=ZD(t,"outer",[58,42]),a=ZD(t,"top"),i=["top","bottom"],o=["pane-0","pane-1"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("top",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:24,children:r[1]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:r[2]})]})}if("top-one-bottom-two"===e){let e=ZD(t,"outer",[42,58]),a=ZD(t,"bottom"),i=["top","bottom"],o=["pane-1","pane-2"];return(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(i,e),onLayoutChanged:e=>n?.("outer",ZR(e,i)),children:[(0,ey.jsx)(hg,{id:i[0],defaultSize:e[0],minSize:24,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:i[1],defaultSize:e[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(o,a),onLayoutChanged:e=>n?.("bottom",ZR(e,o)),children:[(0,ey.jsx)(hg,{id:o[0],defaultSize:a[0],minSize:24,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:o[1],defaultSize:a[1],minSize:24,children:r[2]})]})})]})}let a=ZD(t,"outer"),i=ZD(t,"left"),o=ZD(t,"right"),l=["left","right"],s=["pane-0","pane-2"],c=["pane-1","pane-3"];return(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:Z_(l,a),onLayoutChanged:e=>n?.("outer",ZR(e,l)),children:[(0,ey.jsx)(hg,{id:l[0],defaultSize:a[0],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(s,i),onLayoutChanged:e=>n?.("left",ZR(e,s)),children:[(0,ey.jsx)(hg,{id:s[0],defaultSize:i[0],minSize:20,children:r[0]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:s[1],defaultSize:i[1],minSize:20,children:r[2]})]})}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:l[1],defaultSize:a[1],minSize:24,children:(0,ey.jsxs)(hm,{direction:"vertical",defaultLayout:Z_(c,o),onLayoutChanged:e=>n?.("right",ZR(e,c)),children:[(0,ey.jsx)(hg,{id:c[0],defaultSize:o[0],minSize:20,children:r[1]}),(0,ey.jsx)(hv,{withHandle:!0}),(0,ey.jsx)(hg,{id:c[1],defaultSize:o[1],minSize:20,children:r[3]})]})})]})}function Z$({conversationId:e,index:t,content:n,clipboardItems:r,clipboardDraggingId:a,onAdd:i,onPanelDrop:o,onContentChange:l,onClear:s,onCut:c,workspaceFolders:d,onRequestFileTab:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p}){let[m,g]=ew.useState();return(0,ey.jsx)("div",{"data-agent-pane":t,className:(0,eI.cn)("relative size-full min-h-0 min-w-0 overflow-hidden",n?.kind!=="subagent-conversation-panel"&&"bg-background","vtl-agent-workspace-pane",n?.kind==="subagent-conversation-panel"&&"vtl-agent-workspace-conversation-pane bg-transparent","panel"===m&&"ring-2 ring-foreground/60 ring-inset","shredder"===m&&"ring-2 ring-destructive/70 ring-inset","cutter"===m&&"ring-2 ring-amber-500/70 ring-inset"),onDragOver:e=>{let t=Array.from(e.dataTransfer.types);if(t.includes(ZI)){e.preventDefault(),e.dataTransfer.dropEffect="move",g("cutter");return}if(t.includes(ZA)){e.preventDefault(),e.dataTransfer.dropEffect="move",g("shredder");return}t.includes(jp)&&(e.preventDefault(),e.dataTransfer.dropEffect="move",g("panel"))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||g(void 0)},onDrop:e=>{if(Array.from(e.dataTransfer.types).includes(ZI)){e.preventDefault(),e.stopPropagation(),g(void 0),c(t);return}if(Array.from(e.dataTransfer.types).includes(ZA)){e.preventDefault(),e.stopPropagation(),g(void 0),s(t);return}let n=function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),n=r.find(e=>e.id===t),a=n?n.payloads?.[jp]:void 0;if(n&&a)return{item:n,content:a.content};let i=e.dataTransfer.getData(jp);if(i)try{let e=JSON.parse(i);return n&&e.content?{item:n,content:e.content}:void 0}catch{return}}(e);n&&(e.preventDefault(),e.stopPropagation(),g(void 0),o(t,n.item,n.content))},children:n?(0,ey.jsx)("div",{className:(0,eI.cn)("size-full min-h-0 min-w-0 overflow-hidden rounded-none","vtl-agent-pane-content","subagent-conversation-panel"===n.kind&&"vtl-agent-pane-conversation-content",a&&"pointer-events-none"),children:jh(n)?ZO(n.kind,{tab:n.tab,conversationId:e,terminalScopeId:e?`agent:${e}:pane:${n.id}`:void 0,terminalState:n.terminal,onTerminalStateChange:e=>{Zz(n.terminal,e)||l(t,{...n,terminal:e})},workspaceFolders:d,nodeId:n.id,tabs:n.tabs,activeTabId:n.activeTabId,onRequestFileTab:({insertIndex:e})=>u?.(t,e),onOpenWorkspaceFile:f,onTabsChange:(e,r)=>{l(t,{...n,tabs:r,activeTabId:r.some(e=>e.id===n.activeTabId)?n.activeTabId:r[0]?.id})},onTabChange:(e,r)=>{"multi-tab-system"===n.kind?l(t,{...n,tabs:(n.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):l(t,{...n,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>h?.(t,n,r),onOpenFileHistory:(e,n)=>p?.(t,n),onActiveTabChange:(e,r)=>{l(t,{...n,activeTabId:r})}}):(0,ey.jsx)(V1,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:n.events},n.id)},n.id):(0,ey.jsx)("div",{className:"vtl-agent-pane-empty grid size-full place-items-center p-4",children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full bg-background/90",onClick:i,"data-tour":"pane-add",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加"]})})})}function ZF({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xn,{open:e,onOpenChange:t,title:"添加工作区组件",description:"选择一个组件填入当前窗口。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索组件..."}),(0,ey.jsxs)(xa,{children:[(0,ey.jsx)(xi,{children:"没有匹配组件。"}),(0,ey.jsx)(xo,{heading:"可放入窗口",children:jd.map(e=>(0,ey.jsxs)(xl,{"data-tour":`pane-template-${e.id}`,value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e.id),children:[(0,ey.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsx)(xs,{children:"添加"})]},e.id))})]})]})})}function ZB({content:e,index:t,conversationId:n,ownerMachineId:r,workspaceFolders:a,onContentChange:i,onOpenWorkspaceFile:o,onSaveFileTab:l,onOpenFileHistory:s,onRequestFileTab:c}){return jh(e)?ZO(e.kind,{tab:e.tab,conversationId:n,ownerMachineId:r,terminalScopeId:n?`agent:${n}:pane:${e.id}`:void 0,terminalState:e.terminal,onTerminalStateChange:n=>{Zz(e.terminal,n)||i(t,{...e,terminal:n})},workspaceFolders:a,nodeId:e.id,tabs:e.tabs,activeTabId:e.activeTabId,onRequestFileTab:({insertIndex:e})=>c?.(t,e),onOpenWorkspaceFile:o,onTabsChange:(n,r)=>{i(t,{...e,tabs:r,activeTabId:r.some(t=>t.id===e.activeTabId)?e.activeTabId:r[0]?.id})},onTabChange:(n,r)=>{"multi-tab-system"===e.kind?i(t,{...e,tabs:(e.tabs??[]).map(e=>e.id===r.id?r:e),activeTabId:r.id}):i(t,{...e,title:r.title,tab:r})},onSaveFileTab:(e,n,r)=>l?.(t,n,r),onOpenFileHistory:(e,n)=>s?.(t,n),onActiveTabChange:(n,r)=>{i(t,{...e,activeTabId:r})}}):(0,ey.jsx)(V1,{className:"size-full min-h-0",composerClassName:"max-w-[42.5rem]",initialEvents:e.events},e.id)}let ZV=[{kind:"status-monitor",label:"状态监控",icon:(0,ey.jsx)(up,{})},{kind:"browser-tab-viewer",label:"预览窗口",icon:(0,ey.jsx)(HR,{})},{kind:"diff-tab-viewer",label:"Diff 栏",icon:(0,ey.jsx)(HD,{})},{kind:"terminal-tab-group",label:"终端窗口",icon:(0,ey.jsx)(uj,{})},{kind:"file-tree-panel",label:"文件树",icon:(0,ey.jsx)(H_,{})},{kind:"file-tab-viewer",label:"文件窗口",icon:(0,ey.jsx)(xK,{})}];function ZH(e,t,n){return Math.min(n,Math.max(t,e))}function ZU({onAddCard:e,align:t="end"}){return(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加窗口",(0,ey.jsx)(g8,{className:"size-3.5 text-muted-foreground"})]})}),(0,ey.jsx)(bL,{align:t,sideOffset:6,className:"min-w-40",children:ZV.map(t=>(0,ey.jsxs)(b$,{onSelect:()=>e(t.kind),children:[t.icon,(0,ey.jsx)("span",{className:"flex-1",children:t.label})]},t.kind))})]})}function ZW({conversationId:e,ownerMachineId:t,panes:n,agentSide:r,columns:a,heights:i,onColumnsChange:o,onHeightsChange:l,onAddCard:s,onContentChange:c,onClear:d,workspaceFolders:u,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p,onRequestFileTab:m}){let g=n.map((e,t)=>({content:e,index:t})).filter(e=>!!e.content),v=new Map(g.map(e=>[e.content.id,e])),x=g.map(e=>e.content.id).join("|"),y="left"===r,b=ew.useRef(0);0===b.current&&a.length>0&&(b.current=a.reduce((e,t)=>{let n=/^col-(\d+)/.exec(t.key);return n?Math.max(e,Number(n[1])):e},0));let w=ew.useCallback(()=>`col-${b.current+=1}`,[]),j=e=>o("function"==typeof e?e(a):e),k=e=>l("function"==typeof e?e(i):e),[S,N]=ew.useState(null),[C,M]=ew.useState(null),[E,O]=ew.useState(null),P=ew.useRef(null),A=ew.useRef(null),I=ew.useRef(null),z=ew.useRef(null);ew.useEffect(()=>{let e={};j(t=>{let n=new Set(g.map(e=>e.content.id)),r=t.map(e=>({...e,cardIds:e.cardIds.filter(e=>n.has(e))})).filter(e=>e.cardIds.length>0),a=new Set(r.flatMap(e=>e.cardIds)),o=g.map(e=>e.content.id).filter(e=>!a.has(e));if(o.length>0){r=r.map(e=>({...e,cardIds:[...e.cardIds]}));let t=P.current?.clientHeight??0,n=t=>t.cardIds.reduce((t,n,r)=>t+(e[n]??i[n]??320)+12*(r>0),0);for(let a of o){let i=!1;if(t>0)for(let o of r){let r=12*(o.cardIds.length>0),l=t-n(o)-r;if(l>=320){o.cardIds.push(a),i=!0;break}if(l>=140){o.cardIds.push(a),e[a]=Math.floor(l),i=!0;break}}i||(0===r.length||t>0?r.push({key:w(),width:360,cardIds:[a]}):r[0].cardIds.push(a))}}return!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],a=t[n];if(!r||!a||r.key!==a.key||r.width!==a.width||r.cardIds.length!==a.cardIds.length)return!1;for(let e=0;e<r.cardIds.length;e+=1)if(r.cardIds[e]!==a.cardIds[e])return!1}return!0}(t,r)?r:t}),Object.keys(e).length>0&&k(t=>({...t,...e}))},[x,w]);let T=e=>i[e]??320;ew.useEffect(()=>{if(!S)return;let e=e=>{A.current?function(e,t){let n=P.current,r=A.current;if(!n||!r)return;let a=Array.from(n.querySelectorAll("[data-card-id]")),i=null,o=null,l=1/0;for(let n of a){let a=n.dataset.cardId;if(!a||a===r)continue;let s=n.getBoundingClientRect(),c=Math.max(s.left-e,0,e-s.right),d=Math.max(s.top-t,0,t-s.bottom),u=c*c+d*d;u<l&&(l=u,i=a,o=s)}if(!i||!o){I.current=null,O(null);return}let s=e-o.left,c=o.right-e,d=t-o.top,u=o.bottom-t,f=Math.min(s,c,d,u),h=f===d?"top":f===u?"bottom":f===s?"left":"right";I.current={id:i,edge:h};let p=n.getBoundingClientRect();O(function(e,t){switch(t){case"top":return{left:e.left,top:e.top-6-2,width:e.width,height:4};case"bottom":return{left:e.left,top:e.top+e.height+6-2,width:e.width,height:4};case"left":return{left:e.left-6-2,top:e.top,width:4,height:e.height};case"right":return{left:e.left+e.width+6-2,top:e.top,width:4,height:e.height}}}({left:o.left-p.left,top:o.top-p.top,width:o.width,height:o.height},h))}(e.clientX,e.clientY):z.current&&function(e,t){let n=z.current;if(!n)return;if("width"===n.kind){let t=ZH(n.startWidth+(e-n.startX)*n.factor,240,760);j(e=>e.map(e=>e.key===n.columnKey?{...e,width:t}:e));return}if("growHeight"===n.kind){let e=Math.max(140,n.h0+(t-n.startY));k(t=>({...t,[n.cardId]:e}));return}let r=n.hA+n.hB,a=ZH(n.hA+(t-n.startY),140,r-140);k(e=>({...e,[n.aboveId]:a,[n.belowId]:r-a}))}(e.clientX,e.clientY)},t=()=>(function(){let e=A.current;if(e){var t,n;let r=I.current;A.current=null,I.current=null,M(null),O(null),N(null),r&&(t=r.id,n=r.edge,e&&e!==t&&j(r=>{let a=r.map(e=>({...e,cardIds:[...e.cardIds]}));for(let t of a){let n=t.cardIds.indexOf(e);n>=0&&t.cardIds.splice(n,1)}let i=-1,o=-1;a.forEach((e,n)=>{let r=e.cardIds.indexOf(t);r>=0&&(i=n,o=r)});let l=a[i];if(!l)return r;if("top"===n||"bottom"===n)l.cardIds.splice("top"===n?o:o+1,0,e);else{let t=(y?"right"===n:"left"===n)?i:i+1;a.splice(t,0,{key:w(),width:a[i]?.width??360,cardIds:[e]})}return a.filter(e=>e.cardIds.length>0)}));return}z.current&&(z.current=null,N(null))})();return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[S]);let D=a.map((e,t)=>({column:e,realIndex:t}));y&&D.reverse();let _=(0,ey.jsx)("div",{className:(0,eI.cn)("flex shrink-0 px-3 py-2",y?"justify-end":"justify-start"),children:(0,ey.jsx)(ZU,{onAddCard:s,align:y?"end":"start"})});return 0===g.length?null:(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col",children:[_,(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3",children:(0,ey.jsxs)("div",{ref:P,className:"relative flex min-h-full items-start gap-3",children:[D.map(({column:n})=>{let r=[],i=0;for(let e=0;e<n.cardIds.length;e+=1)i+=T(n.cardIds[e]),e<n.cardIds.length-1&&(r.push(i+6),i+=12);let o=i,l=n.cardIds[n.cardIds.length-1],s=1===n.cardIds.length&&v.get(n.cardIds[0])?.content.kind==="status-monitor";return(0,ey.jsxs)("div",{className:(0,eI.cn)("relative flex shrink-0 flex-col gap-3",s&&"h-full"),style:{width:n.width},children:[n.cardIds.map(n=>{let r=v.get(n);if(!r)return null;let{content:a,index:i}=r;return(0,ey.jsxs)("div",{"data-card-id":a.id,style:s?void 0:{height:T(a.id)},className:(0,eI.cn)("group/card relative flex w-full flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm",s?"min-h-0 flex-1":"shrink-0",C===a.id?"opacity-40":"opacity-100"),children:[(0,ey.jsxs)("div",{onPointerDown:e=>{var t;return t=a.id,void(0===e.button&&(e.preventDefault(),e.stopPropagation(),A.current=t,I.current=null,M(t),O(null),N("drag")))},className:"flex shrink-0 cursor-grab touch-none select-none items-center justify-between gap-2 border-b border-border/60 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,ey.jsx)(fm,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,ey.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.title})]}),(0,ey.jsx)("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:()=>d(i),"aria-label":"关闭窗口",title:"关闭窗口",className:"grid size-5 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-3.5",children:(0,ey.jsx)(fc.XIcon,{})})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:(0,ey.jsx)(ZB,{content:a,index:i,conversationId:e,ownerMachineId:t,workspaceFolders:u,onContentChange:c,onOpenWorkspaceFile:f,onSaveFileTab:h,onOpenFileHistory:p,onRequestFileTab:m})})]},a.id)}),n.cardIds.slice(0,-1).map((e,t)=>(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:r=>{var a;return a=n.cardIds[t+1],void(0===r.button&&(r.preventDefault(),r.stopPropagation(),z.current={kind:"height",aboveId:e,belowId:a,startY:r.clientY,hA:T(e),hB:T(a)},N("resize")))},style:{top:r[t]??0},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})},`hbar-${e}`)),l&&!s?(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),z.current={kind:"growHeight",cardId:l,startY:e.clientY,h0:T(l)},N("resize"))},style:{top:o+6},className:"group/hbar absolute inset-x-0 z-10 flex h-3 -translate-y-1/2 cursor-ns-resize items-center justify-center",children:(0,ey.jsx)("span",{className:"h-1 w-12 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/hbar:opacity-100"})}):null,(0,ey.jsx)("div",{"aria-hidden":!0,onPointerDown:e=>(function(e,t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation();let n=a.find(t=>t.key===e)?.width??360;z.current={kind:"width",columnKey:e,startX:t.clientX,startWidth:n,factor:y?-1:1},N("resize")})(n.key,e),style:y?{left:-6}:{right:-6},className:(0,eI.cn)("group/wbar absolute inset-y-0 z-10 flex w-3 cursor-ew-resize items-center justify-center",y?"-translate-x-1/2":"translate-x-1/2"),children:(0,ey.jsx)("span",{className:"h-12 w-1 rounded-full bg-muted-foreground/40 opacity-0 transition-opacity group-hover/wbar:opacity-100"})})]},n.key)}),E?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute z-40 rounded-full bg-muted-foreground/70",style:{left:E.left,top:E.top,width:E.width,height:E.height}}):null]})}),S?(0,ey.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 z-50",style:{cursor:"drag"===S?"grabbing":z.current?.kind==="width"?"ew-resize":"ns-resize"}}):null]})}let Zq="vtl:workspace-layout-mode",ZK="vtl:workspace-agent-side",ZG="vtl:workspace-layout-changed",ZX={mode:"pane",agentSide:"left"};function ZY(){let e=ZX.mode,t=ZX.agentSide;try{let n=window.localStorage.getItem(Zq);("pane"===n||"card"===n||"control-room"===n)&&(e=n);let r=window.localStorage.getItem(ZK);("left"===r||"right"===r)&&(t=r)}catch{}return{mode:e,agentSide:t}}function ZZ(e){try{e.mode&&window.localStorage.setItem(Zq,e.mode),e.agentSide&&window.localStorage.setItem(ZK,e.agentSide)}catch{}window.dispatchEvent(new CustomEvent(ZG))}function ZJ({stack:e,rootTitle:t,rootOwnerMachineId:n,onNavigateRoot:r,onNavigateIndex:a,onOpenSubagent:i}){let o=e[e.length-1],[l,s]=ew.useState(null);if(ew.useEffect(()=>{let e;if(!o)return;let t=!1;async function r(){try{let a=await sA(o.id,n);if(t)return;s(a);let i="working"===a.conversation.status||!!a.conversation.running;e=window.setTimeout(r,i?900:5e3)}catch{if(t)return;e=window.setTimeout(r,3e3)}}return s(null),r(),()=>{t=!0,e&&window.clearTimeout(e)}},[o,n]),!o)return null;let c=l?.conversation.status??"working",d="working"===c||!!l?.conversation.running;return(0,ey.jsxs)("div",{className:"absolute inset-0 z-30 flex flex-col bg-background",children:[(0,ey.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,ey.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",onClick:r,children:t||"主对话"}),e.map((t,n)=>{let r=VB(t.subagentType),i=n===e.length-1,o=r.Icon;return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(p$,{className:"size-3 shrink-0 text-muted-foreground/60"}),(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 transition-colors hover:bg-accent/50",i?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>a(n),children:[(0,ey.jsx)(o,{className:(0,eI.cn)("size-3",r.color)}),(0,ey.jsx)("span",{className:"max-w-[10rem] truncate",children:t.name||`${r.label}子代理`})]})]},t.id)}),(0,ey.jsx)("span",{className:"ml-auto shrink-0 pl-2",children:d?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-3 animate-spin"}),"运行中"]}):"paused"===c?(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,ey.jsx)(hb,{className:"size-3"}),"已暂停"]}):(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-500",children:[(0,ey.jsx)(eO,{className:"size-3"}),"完成"]})})]}),(0,ey.jsx)("div",{className:"relative min-h-0 flex-1",children:l?(0,ey.jsx)(VN,{events:l.events,bottomInset:16,contentClassName:"max-w-[42.5rem]",onOpenSubagent:e=>i(e),labels:{recall:"召回",branch:"分支",expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"}}):(0,ey.jsxs)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"mr-2 size-4 animate-spin"}),"正在打开子代理对话…"]})})]})}let ZQ=[],Z0="vantaloom:file-system-changed";function Z1(e,t){let n;if(0===t.length)return e;let r=new Map;for(let t=0;t<e.length;t+=1){let n=e[t]?.id;n&&r.set(n,t)}for(let a of t){let t=a?.id,i=t?r.get(t):void 0;if(void 0!==i){if(e[i]===a)continue;n||(n=e.slice()),n[i]=a}else n||(n=e.slice()),t&&r.set(t,n.length),n.push(a)}return n??e}function Z2(e,t){if(0===e.length)return t;let n=new Set;for(let e of t)e?.id&&n.add(e.id);let r=e.filter(e=>e?.id&&!n.has(e.id));return 0===r.length?t:[...r,...t]}function Z5(e){var t;let n=(t=e?.layoutMode,ZT.some(e=>e.id===t)?t:"quad"),r="right"===e?.agentPosition?"right":"left",a=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return{};let t=e.shell&&"object"==typeof e.shell&&!Array.isArray(e.shell)?e.shell:void 0,n={};for(let e of["agent","panes"]){let r=t?.[e];"number"==typeof r&&Number.isFinite(r)&&r>0&&(n[e]=r)}return{...Object.keys(n).length?{shell:n}:{},outer:Z4(e.outer),left:Z4(e.left),right:Z4(e.right),top:Z4(e.top),bottom:Z4(e.bottom)}}(e?.sizes),i=Array.from({length:Math.max(4,ZT.find(e=>e.id===n)?.slots??4)},()=>void 0);for(let[t,n]of(e?.panes??[]).entries()){let e=Number.isInteger(n.slot)?n.slot:t;e<0||e>=i.length||(i[e]=function(e,t){var n,r;let a=e.paneId||`${e.kind}-${t+1}`,i=!(n=e.props)||"object"!=typeof n||Array.isArray(n)?{}:n;if("subagent-conversation-panel"===e.kind)return{id:a,kind:"subagent-conversation-panel",title:Z6(i.title)??"Subagent",subagentId:Z6(i.subagentId)??a,events:Array.isArray(i.events)?i.events:[]};if(!ju(e.kind))return;let o=i.tab&&"object"==typeof i.tab?i.tab:void 0,l=Array.isArray(i.tabs)?i.tabs.filter(e=>uT(e?.kind)):void 0,s=ju(e.kind);return{id:a,kind:e.kind,title:Z6(i.title)??o?.title??s?.title??"组件",tab:o,tabs:l,activeTabId:Z6(i.activeTabId),terminal:"terminal-tab-group"===e.kind?!(r=i.terminal)||"object"!=typeof r||Array.isArray(r)?{sessionIds:[]}:{sessionIds:Array.isArray(r.sessionIds)?r.sessionIds.filter(e=>"string"==typeof e):[],activeSessionId:Z6(r.activeSessionId),selectedMachineId:Z6(r.selectedMachineId),selectedShellId:Z6(r.selectedShellId),autoStart:"boolean"==typeof r.autoStart?r.autoStart:void 0,aiControlledSessionIds:Array.isArray(r.aiControlledSessionIds)?r.aiControlledSessionIds.filter(e=>"string"==typeof e):void 0}:void 0}}(n,t))}return{layoutMode:n,agentPosition:r,layoutSizes:a,panes:i,cardColumns:Array.isArray(e?.cardLayout?.columns)?e.cardLayout.columns.filter(e=>e&&"string"==typeof e.key&&Array.isArray(e.cardIds)).map(e=>({key:e.key,width:"number"==typeof e.width&&e.width>0?e.width:360,cardIds:e.cardIds.filter(e=>"string"==typeof e)})):[],cardHeights:e?.cardLayout?.heights&&"object"==typeof e.cardLayout.heights?e.cardLayout.heights:{}}}function Z4(e){if(!Array.isArray(e))return;let t=e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0);return t.length?t:void 0}function Z3(e){return e.filter(e=>"number"==typeof e&&Number.isFinite(e)&&e>0)}function Z6(e){return"string"==typeof e&&e.trim()?e:void 0}function Z8(e){let t=e?.id.match(/-(\d+)$/);return t?Number(t[1]):0}function Z7(e){return e.reduce((e,t)=>Math.max(e,Z8(t)),0)}function Z9({conversation:e,clipboardItems:t,clipboardDraggingId:n,onClipboardItemsChange:r,onClipboardDraggingChange:a,onOverlayOpenChange:i,onConversationCreated:o,onCancelDraft:l,subagentStack:s=[],onSubagentStackChange:c,subagentTree:d=[],mobileView:u="conversation",onMobilePaneCountChange:f}){let h=sb(),p=ew.useRef(null),m=ew.useRef(void 0),g=Z5(e?.panes),[v,x]=ew.useState(g.layoutMode),[y,b]=ew.useState(g.agentPosition),w=function(){let[e,t]=ew.useState(ZX);return ew.useEffect(()=>{t(ZY());let e=()=>t(ZY());return window.addEventListener(ZG,e),window.addEventListener("storage",e),()=>{window.removeEventListener(ZG,e),window.removeEventListener("storage",e)}},[]),e}(),j="card"===w.mode,[k,S]=ew.useState(!1),[N,C]=ew.useState(!1);ew.useEffect(()=>{try{C("1"===window.localStorage.getItem("vtl:agent-panes-collapsed"))}catch{}},[]);let M=ew.useCallback(()=>{C(e=>{let t=!e;try{window.localStorage.setItem("vtl:agent-panes-collapsed",t?"1":"0")}catch{}return t})},[]),[E,O]=ew.useState(g.layoutSizes),[P,A]=ew.useState(()=>g.panes),[I,z]=ew.useState(()=>g.cardColumns),[T,D]=ew.useState(()=>g.cardHeights),[_,R]=ew.useState(()=>e?.events??[]),[L,$]=ew.useState(()=>e?.eventsStart??0),[F,B]=ew.useState(()=>e?.eventsTotal??e?.events?.length??0),[V,H]=ew.useState(!1),U=L>0,[W,q]=ew.useState(new Set),[K,G]=ew.useState(void 0),[X,Y]=ew.useState(()=>HP(e?.conversation.id)),Z=ew.useCallback(t=>{Y(t),function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(HO(e));window.localStorage.setItem(HO(e),t.slice(0,1e5))}catch{}}(e?.conversation.id,t)},[e?.conversation.id]),[J,Q]=ew.useState(()=>HI(e?.conversation.id)),[ee,et]=ew.useState([]),[en,er]=ew.useState(void 0),[ea,ei]=ew.useState(!1),[eo,el]=ew.useState(!1),[es,ec]=ew.useState(""),[ed,eu]=ew.useState(e?.conversation.status==="working"),[ef,eh]=ew.useState(e?.conversation.status??"idle"),[ep,em]=ew.useState(e?.conversation.settings?.permissionMode??"acceptEdits"),[eg,ev]=ew.useState([]),[ex,eb]=ew.useState(e?.conversation.tokens??0),[ej,ek]=ew.useState(e?.conversation.runUsage),[eS,eN]=ew.useState(e?.conversation.contextTokens??0),[eC,eM]=ew.useState(!1),eE=ew.useRef(ef),[eO,eP]=ew.useState(),[ez,eT]=ew.useState(),[eR,eL]=ew.useState(),e$=ew.useRef(Z7(g.panes)),eF=ew.useRef(0),eB=ew.useRef(""),eV=ZT.find(e=>e.id===v)?.slots??4,eH=e?.conversation.settings.folders??ZQ,{models:eU}=vI(),eW=ew.useMemo(()=>{let t=e?.conversation.settings.mainModels??[];return t.length?eU.filter(e=>t.includes(e.value)).map(e=>({id:e.value,label:e.label})):[]},[eU,e?.conversation.settings.mainModels]),eq=w1(e?.conversation.settings.engine),eK=ew.useMemo(()=>{if(eq){let t,n=e?.conversation.settings.ccModel;return[{id:n&&""!==n?n:"__cc_model__",label:(t=n&&""!==n?n:wQ,w0.find(e=>e.value===t)?.label??n??""),disabled:!0}]}return eW},[eq,e?.conversation.settings.ccModel,eW]),eG=!eq&&0===eW.length,[eX,eY]=ew.useState(!1),eZ=ed||"working"===ef||eX,eJ=ew.useCallback(async t=>{if(!e||eC)return;let n=e.conversation.id,r=e.conversation.ownerMachineId;if(eq){if(eZ)return void await sZ(n,"请执行 /compact 压缩上下文。",r);eu(!0),eh("working");try{let e=await sH(n,{message:"/compact",modelRef:"",mode:"agent"},r);eh(e.conversation.status)}catch(e){eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"压缩请求失败")}return}if(eZ)return void await sZ(n,"precise"===t?"请在完成当前小任务后进行精确压缩(去除冗余文件读取和旧工具输出)。":"请在完成当前小任务后进行极致压缩(AI摘要),以便继续工作。",r);eM(!0);try{await sJ(n,t,void 0,r);let e=await sA(n,r);e&&(R(e.events),$(e.eventsStart??0),B(e.eventsTotal??e.events.length),eb(e.conversation.tokens??0),ek(e.conversation.runUsage),eN(e.conversation.contextTokens??0))}catch{}finally{eM(!1)}},[e,eC,eZ,eq]),eQ=ew.useMemo(()=>{if(!e)return;let t=eU.find(e=>e.value===es),n=t?.contextLength||200,r=ej?.inputTokens??0,a=ej?.outputTokens??0,i=r>0?r:eS;return{used:i>0?i+a:ex,total:1e3*n,toolCalls:i>0?i:ex,userMessages:a,other:void 0,onCompressPrecise:()=>eJ("precise"),onCompressExtreme:()=>eJ("extreme"),compressing:eC}},[e,eU,es,ex,ej,eS,eJ,eC]),e0=ew.useMemo(()=>{let t=e?.conversation.rounds;if(t?.length)return t;let n=[];for(let e of _){if("user"!==e.kind)continue;let t=n.length,r=(e.title??"").replace(/\s+/g," ").trim(),a=(r?r.slice(0,28):"")||`第 ${t+1} 轮`;n.push({runId:e.id,index:t,anchorEventId:e.id,title:a,summary:a,createdAt:""})}return n},[e?.conversation.rounds,_]),e1=ew.useCallback(async t=>{let n=e?.conversation.id,r=t.anchorEventId??_.find(e=>e.id.startsWith(`${t.runId}-`))?.id??_.find(e=>e.id===t.runId)?.id;if(r){if(_.some(e=>e.id===r))return void p.current?.scrollToEvent(r);if(n&&L>0)try{let t=await sI(n,{fromEventId:r,end:L},e?.conversation.ownerMachineId);t.events.length>0&&(R(e=>Z2(t.events,e)),$(t.start),t.total>0&&B(t.total))}catch{}window.setTimeout(()=>{p.current?.scrollToEvent(r)},60)}},[e?.conversation.id,e?.conversation.ownerMachineId,_,L]),e2=ew.useCallback(t=>{let n;if(t&&function(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(Hz(e));window.localStorage.setItem(Hz(e),t)}catch{}}(e?.conversation.id,t),!t)return void G(void 0);let r=_.findIndex(e=>e.id===t);if(r>=0)for(let e of e0){let t=e.anchorEventId??e.runId,a=_.findIndex(e=>e.id===t);a>=0&&a<=r&&(n=e.runId)}n||(n=e0.find(e=>t===e.runId||t.startsWith(`${e.runId}-`))?.runId),G(n)},[e?.conversation.id,_,e0]),e5=ew.useCallback(async e=>{if("file-tab-viewer"!==e.kind||e.modified||e.file?.readOnly)return e;try{var t,n;let r=await u2(e);return(t=e,n=r,t.defaultValue!==n.defaultValue||t.title!==n.title||t.file?.size!==n.file?.size||t.file?.mimeType!==n.file?.mimeType||t.file?.previewContent!==n.file?.previewContent||t.file?.src!==n.file?.src||t.file?.truncated!==n.file?.truncated)?r:e}catch{return e}},[]),e4=ew.useCallback(async e=>{if(!e||!jh(e))return e;if("multi-tab-system"===e.kind){var t,n;let r=e.tabs??[],a=await Promise.all(r.map(e5));return(t=r,n=a,t.length!==n.length||t.some((e,t)=>e!==n[t]))?{...e,tabs:a}:e}if("file-tab-viewer"===e.kind&&e.tab){let t=await e5(e.tab);return t!==e.tab?{...e,title:t.title,tab:t}:e}return e},[e5]),e3=ew.useCallback(async()=>{var e,t;let n=await Promise.all(P.map(async e=>e4(e)));e=P,t=n,(e.length!==t.length||e.some((e,n)=>e!==t[n]))&&A(n)},[P,e4]);ew.useEffect(()=>{i?.(void 0!==eO||void 0!==ez||void 0!==eR)},[ez,eR,i,eO]);let e6=ew.useRef(void 0);ew.useEffect(()=>{let t=e?.conversation.id,n=e?.events??[];if(e6.current!==t){e6.current=t,R(n),$(e?.eventsStart??0),B(e?.eventsTotal??n.length);return}R(e=>Z1(e,n))},[e?.conversation.id,e?.events]);let e8=ew.useCallback(async()=>{let t=e?.conversation.id;if(t&&!(L<=0)&&!V){H(!0);try{let n=await sI(t,{end:L,limit:200},e?.conversation.ownerMachineId);n.events.length>0&&R(e=>Z2(n.events,e)),$(e=>n.events.length>0?n.start:Math.max(0,e-200)),n.total>0&&B(n.total)}finally{H(!1)}}},[e?.conversation.id,e?.conversation.ownerMachineId,L,V]);function e7(e){if(!e.length)return;let t=e.map(jm);r(e=>[...t,...e.filter(e=>!t.some(t=>t.id===e.id))])}function e9(e,t,n){if(!e||!jh(e))return e;if("multi-tab-system"===e.kind){var r;let a,i;return{...e,tabs:(r=e.tabs??[],a=r.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}return"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e}function te(e,t){return e&&jh(e)?"multi-tab-system"===e.kind?{...e,tabs:(e.tabs??[]).map(e=>e.id===t.id?t:e),activeTabId:t.id}:"file-tab-viewer"===e.kind?{...e,title:t.title,tab:t}:e:e}function tt(e){A(t=>{let n=t.findIndex(e=>void 0===e);return n>=0?t.map((t,r)=>r===n?e:t):[...t,e]})}function tn(e){e$.current+=1;let t=jf(e,`${e}-${e$.current}`);if("browser-tab-viewer"===e&&t.tab){let e=t.tab;e_().then(n=>{tt(n.length>0?{...t,tab:{...e,defaultUrl:n[0]}}:t)});return}tt(t)}ew.useEffect(()=>{let t=e?.conversation.id;if(!t||0===_.length||m.current===t)return;m.current=t;let n=function(e){if(e)try{return window.localStorage.getItem(Hz(e))??void 0}catch{return}}(t),r=_[_.length-1]?.id;if(!n||n===r||!_.some(e=>e.id===n))return;let a=window.setTimeout(()=>{p.current?.scrollToEvent(n)},80);return()=>window.clearTimeout(a)},[e?.conversation.id,_.length]),ew.useEffect(()=>{Y(HP(e?.conversation.id)),Q(HI(e?.conversation.id)),et([]),er(void 0),q(new Set)},[e?.conversation.id]),ew.useEffect(()=>{eu(e?.conversation.status==="working"),eh(e?.conversation.status??"idle")},[e?.conversation.id,e?.conversation.status]),ew.useEffect(()=>{eb(e?.conversation.tokens??0),ek(e?.conversation.runUsage),eN(e?.conversation.contextTokens??0)},[e?.conversation.id,e?.conversation.tokens,e?.conversation.runUsage,e?.conversation.contextTokens]),ew.useEffect(()=>{ej?.inputTokens&&eN(ej.inputTokens)},[ej?.inputTokens]),ew.useEffect(()=>{em(e?.conversation.settings?.permissionMode??"acceptEdits")},[e?.conversation.id,e?.conversation.settings?.permissionMode]),ew.useEffect(()=>{let e=eW[0]?.id??"";ec(t=>eW.some(e=>e.id===t)?t:e)},[eW]),ew.useEffect(()=>{let t=Z5(e?.panes);x(t.layoutMode),b(t.agentPosition),O(t.layoutSizes),A(t.panes),z(t.cardColumns),D(t.cardHeights),e$.current=Z7(t.panes)},[e?.conversation.id,e?.panes]),ew.useEffect(()=>{let t,n=e?.conversation.id,r=e?.conversation.ownerMachineId;if(!n)return;let a=!1,i=e=>{R(t=>Z1(t,e.events)),eh(e.conversation.status),eb(e.conversation.tokens??0),ek(e.conversation.runUsage)},o=e=>{void 0===t&&(t=window.setInterval(async()=>{try{let e=await sA(n,r);if(a)return;i(e),eu("working"===e.conversation.status)}catch{return}},e))};if(r&&"local"!==r)return o(600),()=>{a=!0,void 0!==t&&window.clearInterval(t)};let l=e?.conversation.lastSeq??0,s=new EventSource(eD(`/api/local/agent/conversations/${encodeURIComponent(n)}/events/stream?after=${l}`));return s.addEventListener("detail",e=>{try{let t=sQ(JSON.parse(e.data));i(t),eu("working"===t.conversation.status)}catch{return}}),s.onerror=()=>{s.close(),o(350)},()=>{a=!0,s.close(),void 0!==t&&window.clearInterval(t)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{if(!e?.conversation.id)return;let t=window.setInterval(()=>{e3()},3e3);return()=>window.clearInterval(t)},[e?.conversation.id,e3]),ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t)return;let r=!1;sR(t,n);let a=window.setInterval(()=>{r||sR(t,n)},3e4);return()=>{r=!0,window.clearInterval(a),sL(t,n)}},[e?.conversation.id,e?.conversation.ownerMachineId]),ew.useEffect(()=>{let e=_.filter(e=>"change"===e.kind).map(e=>`${e.id}:${e.status??""}:${e.isStreaming?"1":"0"}`).join("|");e&&e!==eB.current&&(eB.current=e,window.dispatchEvent(new CustomEvent(Z0)),e3())},[_,e3]),ew.useEffect(()=>{let t=e?.conversation.id;if(!t)return;let n=window.setTimeout(()=>{var n;let r;sV(t,(n={columns:I,heights:T},r=[],P.forEach((e,t)=>{if(e){if(jh(e))return void r.push({paneId:e.id,slot:t,kind:e.kind,machineId:e.terminal?.selectedMachineId,resourceId:e.terminal?.activeSessionId,props:{title:e.title,tab:e.tab,tabs:e.tabs,activeTabId:e.activeTabId,terminal:e.terminal}});r.push({paneId:e.id,slot:t,kind:e.kind,props:{title:e.title,subagentId:e.subagentId,events:e.events}})}}),{layoutMode:v,agentPosition:y,sizes:E,cardLayout:n,panes:r}),e?.conversation.ownerMachineId)},300);return()=>window.clearTimeout(n)},[y,I,T,e?.conversation.id,v,E,P]);let tr=ew.useCallback(e=>{A(t=>{let n=t.findIndex(e=>e?.kind==="browser-tab-viewer");if(n>=0){let r=t[n];return r&&jh(r)&&r.tab&&(!r.tab.defaultUrl||r.tab.defaultUrl.startsWith("https://vantaloom.local"))?t.map((t,a)=>a===n&&r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:t):t}e$.current+=1;let r=jf("browser-tab-viewer",`browser-tab-viewer-${e$.current}`),a=void 0!==r.tab?{...r,tab:{...r.tab,defaultUrl:e}}:r,i=t.findIndex(e=>void 0===e);return i>=0?t.map((e,t)=>t===i?a:e):j?[...t,a]:t})},[j]),ta=ew.useRef(!1);function ti(e,t){A(n=>{let r=n.findIndex(t=>t?.kind===e);if(r>=0)return n.map((n,a)=>a===r&&n?{id:n.id,kind:e,title:t.title,tab:t}:n);e$.current+=1;let a={id:`${e}-${e$.current}`,kind:e,title:t.title,tab:t},i=n.findIndex(e=>void 0===e);return i>=0?n.map((e,t)=>t===i?a:e):[...n,a]})}async function to(e,t,n){try{let r=await u0(e);if(j)return void ti("file-tab-viewer",r);A(e=>e.map((e,a)=>a===t?e9(e,r,n):e))}catch{hI.error("文件预览打开失败")}}function tl(e){if(j)return void to(e,-1);let t=P.slice(0,eV).findIndex(e=>e?.kind==="multi-tab-system");t<0?hI.warning("请先放入一个多标签页组件"):to(e,t)}function ts(e){let t=e.path?.trim()||e.name.trim();("diff"===e.kind||"diff"===e.meta)&&e.diff?function(e){let t=e.path?.trim()||e.name.trim(),n={id:function(e,t){let n=0x811c9dc5;for(let e=0;e<t.length;e+=1)n^=t.charCodeAt(e),n=Math.imul(n,0x1000193);return`${e}-${(n>>>0).toString(36)}`}("diff",`${e.mutationId??""}|${e.machineId??"local"}|${t}|${e.diff??""}`),kind:"diff-tab-viewer",title:`Diff ${e.name}`,file:{name:e.name,path:t,machineId:e.machineId??"local",kind:"code"},diff:e.diff};if(j)return ti("diff-tab-viewer",n);let r=P.slice(0,eV).findIndex(e=>e?.kind==="multi-tab-system");r<0?hI.warning("请先放入一个多标签页组件"):A(e=>e.map((e,t)=>t===r?e9(e,n):e))}(e):!t||e.meta?.toLowerCase().startsWith("depth")||tl({machineId:e.machineId??"local",path:t})}async function tc(e,t,n){let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hI.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uV({machineId:a,path:r,content:n}),o={...await u1(i,{id:t.id,title:t.title,defaultView:t.defaultView,defaultMode:t.defaultMode}),modified:!1};A(t=>t.map((t,n)=>n===e?te(t,o):t)),window.dispatchEvent(new CustomEvent(Z0)),hI.success("文件已保存")}catch(e){throw hI.error("文件保存失败"),e}}async function tf(t){let n=e?.conversation.id,r=eR?.tab.file?.path,a=eR?.tab.file?.machineId??"local";if(eR&&n&&r)try{let i=await sG(n,{machineId:a,path:r,mutationId:t.mutationId,state:t.state},e?.conversation.ownerMachineId),o=await u1(i,{id:eR.tab.id,title:`${i.name} @ ${Jt(t.mutationId)} ${"before"===t.state?"before":"after"}`,readOnly:!0,defaultView:eR.tab.defaultView,defaultMode:"review"});A(e=>e.map((e,t)=>t===eR.paneIndex?te(e,o):e)),eL(void 0)}catch{hI.error("历史版本打开失败")}}function th(e,t,n){let i=P[e];e$.current=Math.max(e$.current,Z8(n)),A(t=>t.map((t,r)=>r===e?n:t)),r(e=>{let n=e.filter(e=>e.id!==t.id);if(!i)return n;let r=jm(i);return[r,...n.filter(e=>e.id!==r.id)]}),a?.(void 0)}function tp(e,t){A(n=>n.map((n,r)=>r===e?t:n))}function tm(t){return{id:t.id,ownerMachineId:t.ownerMachineId??e?.conversation.ownerMachineId,name:t.name,subagentType:t.subagentType}}function tg(e){var t=P[e];if(t&&jh(t)&&"terminal-tab-group"===t.kind)for(let e of t.terminal?.sessionIds??[])fi(e).catch(()=>{});A(t=>t.map((t,n)=>n===e?void 0:t))}function tv(e){let t=P[e];t&&e7([t]),A(t=>t.map((t,n)=>n===e?void 0:t))}async function tx(t,n="chat",r=[]){let a=e?.conversation.id,i=eq?"":es||eW[0]?.id||"";if(!a||(t.trim()&&Q(function(e,t){let n=t.trim();if(!n)return HI(e);let r=n.slice(0,1e5),a=HI(e);if(a[a.length-1]===r)return a;let i=[...a,r].slice(-100);if(e&&1)try{window.localStorage.setItem(HA(e),JSON.stringify(i))}catch{}return i}(a,t)),ed||"working"===ef))return;if(!eq&&!i)return void hI.error("请先在代理模型配置里选择模型");q(function e(t,n=new Set){for(let r of t)n.add(r.id),e(r.children??[],n);return n}(d));let o=r.map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?""!==e.data:(e.text??"")!=="");eu(!0),eh("working");try{let r=await sH(a,{message:t,modelRef:i,mode:n,attachments:o.length>0?o:void 0},e?.conversation.ownerMachineId);eh(r.conversation.status)}catch(e){eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"对话请求失败")}}async function ty(t){let n=e?.conversation.id,r="string"==typeof t.modelRef?t.modelRef.trim():"",a=eq?"":r||es||eW[0]?.id||"",i="agent"===t.mode?"agent":"chat";if(n){if(!eq&&!a)return void hI.error("请先在代理模型配置里选择模型");eu(!0),eh("working"),R(e=>e.map(e=>e.id===t.id?{...e,status:"retried"}:e));try{let r=await sU(n,{modelRef:a,mode:i,retryEventId:t.id},e?.conversation.ownerMachineId);eh(r.conversation.status)}catch(e){R(e=>e.map(e=>e.id===t.id?t:e)),eu(!1),eh("idle"),hI.error(e instanceof Error?e.message:"对话重试失败")}}}function tb(e){eZ?hI.error("对话正在运行,请先停止后再回退"):er(e)}async function tw(){let t=e?.conversation.id;if(!en||!t)return void er(void 0);ei(!0);try{let n=await sW(t,en.id,e?.conversation.ownerMachineId);R(n.detail.events),$(0),B(n.detail.events.length),eh(n.detail.conversation.status),eu(!1),Z(n.prompt),c?.([]);let r=[];n.revertedFiles>0&&r.push(`恢复 ${n.revertedFiles} 个文件`),n.deletedFiles>0&&r.push(`删除 ${n.deletedFiles} 个新增文件`),n.archivedSubagents>0&&r.push(`归档 ${n.archivedSubagents} 个子代理`),hI.success(r.length?`已回退:${r.join(",")}`:"已回退到此处"),n.skippedRemote&&n.skippedRemote.length>0&&hI.warning(`${n.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){hI.error(e instanceof Error?e.message:"回退失败")}finally{ei(!1),er(void 0)}}async function tj(t){let n=e?.conversation.id;if(n&&!eo){el(!0);try{let r=await sq(n,t.id,e?.conversation.ownerMachineId);o?.(r),hI.success("已创建分支对话")}catch(e){hI.error(e instanceof Error?e.message:"创建分支失败")}finally{el(!1)}}}async function tk(t){let n=e?.conversation.id;if(n)try{let r=e?.conversation.settings??{};await sF(n,{settings:{...r,...t}},e?.conversation.ownerMachineId)}catch(e){hI.error(e instanceof Error?e.message:"设置更新失败")}}async function tS(t,n){let r=e?.conversation.id;if(r)try{await sX(r,t,n,void 0,e?.conversation.ownerMachineId)}catch(e){hI.error(e instanceof Error?e.message:"审批操作失败")}}async function tN(){let t=e?.conversation.id;if(t){eY(!0);try{await sY(t,e?.conversation.ownerMachineId)}catch{}}}function tC(){tx("继续","agent")}async function tM(t){let n=e?.conversation.id;if(!n)return;let r=eg.find(e=>e.id===t);if(!r)return;let a="string"==typeof r.content?r.content:String(r.content??"");if(a.trim()){ev(e=>e.filter(e=>e.id!==t));try{await sZ(n,a.trim(),e?.conversation.ownerMachineId)}catch{}}}ew.useEffect(()=>{let t=e?.conversation.id,n=e?.conversation.ownerMachineId;if(!t||n&&"local"!==n)return;ta.current=!1;let r=!1,a=async()=>{if(!r&&!ta.current)try{let e=(await e_())[0];if(r||ta.current||!e)return;ta.current=!0,tr(e)}catch{}};a();let i=window.setInterval(a,3e3);return()=>{r=!0,window.clearInterval(i)}},[e?.conversation.id,e?.conversation.ownerMachineId,tr]),ew.useEffect(()=>{"idle"===ef&&eX&&eY(!1)},[ef,eX]),ew.useEffect(()=>{let e=eE.current;if(eE.current=ef,"working"===e&&"idle"===ef&&eg.length>0){let e=eg[0];if(e){ev(eg.slice(1));let t="string"==typeof e.content?e.content:String(e.content??"");t.trim()&&tx(t.trim(),"agent")}}},[ef]);let tE=Array.from({length:eV},(r,a)=>(0,ey.jsx)(Z$,{conversationId:e?.conversation.id,index:a,content:P[a],clipboardItems:t,clipboardDraggingId:n,onAdd:()=>eP(a),onPanelDrop:th,onContentChange:tp,onClear:tg,onCut:tv,workspaceFolders:eH,onRequestFileTab:(e,t)=>eT({paneIndex:e,insertIndex:t}),onOpenWorkspaceFile:tl,onSaveFileTab:tc,onOpenFileHistory:(e,t)=>eL({paneIndex:e,tab:t})},a)),tO=P.slice(0,eV).some(e=>e?.kind==="subagent-conversation-panel"),tP=E.shell?.agent??42,tA=E.shell?.panes??58,tI=w.agentSide,tz="control-room"===w.mode||k,tT=(0,ey.jsxs)(pT,{type:"single",value:tz?"hidden":tI,variant:"outline",size:"sm","data-tour":"control-room-toggle","aria-label":"Agent 面板位置",onValueChange:e=>{"left"===e||"right"===e?(S(!1),b(e),ZZ({mode:j?"card":"pane",agentSide:e})):"hidden"===e&&(S(!0),ZZ({mode:"control-room"}))},children:[(0,ey.jsx)(pD,{value:"left","aria-label":"Agent 在左",title:"Agent 在左",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s2,{})}),(0,ey.jsx)(pD,{value:"hidden","aria-label":"隐藏面板,居中对话",title:"隐藏面板,居中对话",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s6,{})}),(0,ey.jsx)(pD,{value:"right","aria-label":"Agent 在右",title:"Agent 在右",className:"h-7 w-9 px-0 [&_svg]:size-4",children:(0,ey.jsx)(s4,{})})]}),tD=(0,ey.jsxs)("div",{className:"relative flex size-full min-h-0 min-w-0 flex-col",children:[e?(0,ey.jsx)(V5,{ownerMachineId:e.conversation.ownerMachineId,title:e.conversation.title,className:"pr-12"}):null,e?(0,ey.jsx)("div",{className:"pointer-events-none absolute left-1 top-9 z-30 flex justify-start pt-1.5",children:(0,ey.jsx)("div",{className:"pointer-events-auto",children:(0,ey.jsx)(V4,{rounds:e0,onJumpToRound:e1,activeRunId:K})})}):null,(0,ey.jsx)("div",{className:"min-h-0 flex-1 pl-10",children:(0,ey.jsx)(V1,{ref:p,events:e?_:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e8:void 0,models:e?eK:void 0,modelId:eq?eK[0]?.id:es,permissionModeId:ep,onPermissionModeChange:t=>{em(t),e?.conversation.id&&tk({permissionMode:t})},running:eZ,disabled:!!e&&eG,onModelChange:ec,onSubmit:e?e=>{tx(e.value,"agent",e.attachments??[])}:void 0,onStop:tN,onOpenFile:ts,onOpenSubagent:function(e){e.id&&c?.([tm(e)])},onRetry:ty,onApprovalDecision:tS,onContinue:tC,onRecallUserMessage:tb,onBranchAssistantMessage:tj,onActiveEventChange:e2,composerValue:X,onComposerValueChange:Z,promptHistory:J,attachments:ee,onAttachmentsChange:et,queuedMessages:eg,onQueuedMessagesChange:ev,onNudge:tM,contextUsage:eQ})}),s.length>0&&e?(0,ey.jsx)(ZJ,{stack:s,rootTitle:e.conversation.title,rootOwnerMachineId:e.conversation.ownerMachineId,onNavigateRoot:()=>c?.([]),onNavigateIndex:e=>c?.(s.slice(0,e+1)),onOpenSubagent:function(e){e.id&&c?.([...s,tm(e)])}}):null]}),t_=(0,ey.jsx)(hg,{id:"agent",defaultSize:tP,minSize:28,children:tD},"agent-conversation"),tR=(0,ey.jsx)(hg,{id:"panes",defaultSize:tA,minSize:32,children:(0,ey.jsxs)("section",{className:"vtl-agent-workspace-panel flex size-full min-h-0 min-w-0 flex-col bg-transparent","data-has-conversation-pane":tO?"true":void 0,children:[(0,ey.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-3","data-tour":"pane-toolbar",children:(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)(pr,{value:v,onValueChange:e=>{let t,n;return t=ZT.find(t=>t.id===e)?.slots??4,void((n=P.slice(t).filter(e=>!!e)).length&&e7(n),A(Array.from({length:Math.max(4,t)},(e,n)=>n<t?P[n]:void 0)),x(e))},children:(0,ey.jsx)(pf,{children:ZT.map(e=>(0,ey.jsx)(ph,{value:e.id,"aria-label":e.label,title:e.label,className:"h-7 w-10 px-0 [&_svg]:size-4",children:e.icon},e.id))})}),tT,(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"剪切窗口内容",title:"拖拽到窗口以剪切到剪切板",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(ZI,"cut")},children:(0,ey.jsx)(l0,{})}),(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",draggable:!0,"aria-label":"粉碎窗口内容",title:"拖拽到窗口以清空",className:"h-7 w-10 cursor-grab rounded-md text-muted-foreground active:cursor-grabbing [&_svg]:size-4",onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData(ZA,"clear")},children:(0,ey.jsx)(s8,{})})]})}),(0,ey.jsx)("div",{className:"min-h-0 flex-1",children:(0,ey.jsx)(ZL,{mode:v,sizes:E,onSizeGroupChange:function(e,t){let n=Z3(t);O(t=>{var r;return(r=t[e],(r?.length??0)===(n?.length??0)&&(r??[]).every((e,t)=>.01>Math.abs(e-(n?.[t]??0))))?t:{...t,[e]:n}})},children:tE},`${e?.conversation.id??"empty"}-${v}`)})]})},"agent-panes"),tL=(0,ey.jsx)(ZW,{conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,panes:P,agentSide:tI,columns:I,heights:T,onColumnsChange:z,onHeightsChange:D,onAddCard:tn,onContentChange:tp,onClear:tg,workspaceFolders:eH,onOpenWorkspaceFile:tl,onSaveFileTab:tc,onOpenFileHistory:(e,t)=>eL({paneIndex:e,tab:t}),onRequestFileTab:(e,t)=>eT({paneIndex:e,insertIndex:t})}),t$=(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-y-0 z-30 flex w-9 items-center","left"===tI?"right-0 justify-end pr-1":"left-0 justify-start pl-1"),children:(0,ey.jsx)("button",{type:"button",onClick:M,"aria-label":N?"展开工作区":"收起工作区",title:N?"展开工作区":"收起工作区",className:"grid size-7 place-items-center rounded-md border bg-background/85 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/panes:opacity-100 [&_svg]:size-4",children:"left"===tI?N?(0,ey.jsx)(s3,{}):(0,ey.jsx)(s5,{}):N?(0,ey.jsx)(tu,{}):(0,ey.jsx)(td,{})})}),tF=(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(ZF,{open:void 0!==eO,onOpenChange:e=>{e||eP(void 0)},onAdd:function(e){if(void 0===eO)return;e$.current+=1;let t=jf(e,`${e}-${e$.current}`),n=P[eO];n&&e7([n]),A(e=>e.map((e,n)=>n===eO?t:e)),eP(void 0)}}),(0,ey.jsx)(Hk,{open:void 0!==ez,folders:eH,onOpenChange:e=>{e||eT(void 0)},onSelectFile:e=>{ez&&to(e,ez.paneIndex,ez.insertIndex),eT(void 0)}}),(0,ey.jsx)(Je,{open:void 0!==eR,conversationId:e?.conversation.id,ownerMachineId:e?.conversation.ownerMachineId,tab:eR?.tab,onOpenChange:e=>{e||eL(void 0)},onSelectVersion:e=>{tf(e)}}),(0,ey.jsx)(dQ,{open:void 0!==en,onOpenChange:e=>{e||ea||er(void 0)},children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"回退对话到此处?"}),(0,ey.jsx)(uu,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{disabled:ea,children:"取消"}),(0,ey.jsx)(uf,{variant:"destructive",disabled:ea,onClick:e=>{e.preventDefault(),tw()},children:ea?"回退中…":"确认回退"})]})]})})]});return e?h?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(js,{view:u,onPaneCountChange:f,conversationPanel:(0,ey.jsx)(V1,{flowContentClassName:"pl-10",events:e?_:void 0,hasEarlier:e?U:void 0,loadingEarlier:e?V:void 0,onLoadEarlier:e?e8:void 0,models:e?eK:void 0,modelId:eq?eK[0]?.id:es,permissionModeId:ep,onPermissionModeChange:t=>{em(t),e?.conversation.id&&tk({permissionMode:t})},running:eZ,disabled:!!e&&eG,onModelChange:ec,onSubmit:e?e=>{tx(e.value,"agent",e.attachments??[])}:void 0,onStop:tN,onOpenFile:ts,onOpenSubagent:function(e){var t;let n=P.slice(0,eV),r=n.findIndex(e=>!e),a=n.findIndex(e=>e?.kind==="subagent-conversation-panel"),i=r>=0?r:a;if(i<0)return void hI.warning("请释放一个窗口再选中浏览");eF.current+=1;let o={id:t=`subagent-${e.id}-${eF.current}`,kind:"subagent-conversation-panel",title:e.title,subagentId:e.id,events:e.events?.length?e.events:[{id:`${t}-status`,kind:"done",title:e.detail??e.status??e.activity??e.title}]};A(e=>e.map((e,t)=>t===i?o:e))},onRetry:ty,onApprovalDecision:tS,onContinue:tC,onRecallUserMessage:tb,onBranchAssistantMessage:tj,onActiveEventChange:e2,composerValue:X,onComposerValueChange:Z,promptHistory:J,attachments:ee,onAttachmentsChange:et,queuedMessages:eg,onQueuedMessagesChange:ev,onNudge:tM,contextUsage:eQ}),paneElements:tE,panes:P,activeSlotCount:eV,onOpenPalette:eP,timeline:(0,ey.jsx)(V4,{rounds:e0,onJumpToRound:e1,activeRunId:K})}),tF,(0,ey.jsx)(hL,{position:"top-center"})]}):(0,ey.jsxs)("div",{className:"vtl-app-background vtl-agent-conversation-workspace relative h-full min-h-0",children:[tz?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hm,{direction:"horizontal",children:tR})}),(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 basis-[58%] shrink-0 flex-col",children:[(0,ey.jsx)(hm,{direction:"horizontal",children:t_}),(0,ey.jsx)("div",{className:"absolute right-3 top-1.5 z-20",children:tT})]}),(0,ey.jsx)("div",{className:"relative min-h-0 min-w-0 flex-1",children:(0,ey.jsx)(HE,{conversationTitle:e.conversation.title,rootEvents:_,rootOwnerMachineId:e.conversation.ownerMachineId,running:eZ,subagentTree:d,baselineSubagentIds:W,activeSubagentPath:s,onSelectMain:()=>c?.([]),onSelectSubagent:e=>c?.([e])})})]}):j&&!P.some(Boolean)?(0,ey.jsxs)("div",{className:"relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tD}),(0,ey.jsx)("div",{className:(0,eI.cn)("absolute top-2 z-20","left"===tI?"right-3":"left-3"),children:(0,ey.jsx)(ZU,{onAddCard:tn,align:"left"===tI?"end":"start"})})]}):j?(0,ey.jsx)("div",{className:"flex h-full min-h-0 overflow-x-auto",children:"left"===tI?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tD}),(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tL})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"flex h-full min-h-0 shrink-0 flex-col",children:tL}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-[20rem] flex-1 flex-col",children:tD})]})}):N?(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsx)("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-0","aria-hidden":!0,children:(0,ey.jsx)(hm,{direction:"horizontal",children:tR})}),(0,ey.jsx)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col",children:tD}),t$]}):(0,ey.jsxs)("div",{className:"group/panes relative flex h-full min-h-0",children:[(0,ey.jsxs)(hm,{direction:"horizontal",defaultLayout:{agent:tP,panes:tA},onLayoutChanged:e=>{let t=e.agent??tP,n=e.panes??tA;!function(e){let t=Z3(e),n=t[0],r=t[1];if(void 0===n||void 0===r)return;let a="left"===y?{agent:n,panes:r}:{agent:r,panes:n};O(e=>{let t=e.shell?.agent,n=e.shell?.panes;return .01>Math.abs((t??0)-a.agent)&&.01>Math.abs((n??0)-a.panes)?e:{...e,shell:{...e.shell,...a}}})}("left"===tI?[t,n]:[n,t])},children:["left"===tI?t_:tR,(0,ey.jsx)(hv,{withHandle:!0}),"left"===tI?tR:t_]},`${e?.conversation.id??"empty"}-${tI}`),t$]}),tF,(0,ey.jsx)(hL,{position:"top-right"})]}):(0,ey.jsx)(jr,{onCreated:e=>o?.(e),onCancel:l})}function Je({open:e,conversationId:t,ownerMachineId:n,tab:r,onOpenChange:a,onSelectVersion:i}){let[o,l]=ew.useState([]),[s,c]=ew.useState(!1),d=r?.file?.path,u=r?.file?.machineId??"local";return ew.useEffect(()=>{if(!e||!t||!d)return void l([]);let r=!1;return c(!0),sK(t,{machineId:u,path:d},n).then(e=>{r||l(e.versions)}).catch(()=>{r||l([])}).finally(()=>{r||c(!1)}),()=>{r=!0}},[t,n,u,e,d]),(0,ey.jsx)(dw,{open:e,onOpenChange:a,children:(0,ey.jsxs)(fu,{className:"max-w-xl gap-0 overflow-hidden p-0",children:[(0,ey.jsx)(fh,{className:"sr-only",children:"历史版本"}),(0,ey.jsx)(fp,{className:"sr-only",children:"浏览当前文件在此 Agent 会话中的修改历史。"}),(0,ey.jsxs)("div",{className:"border-b px-4 py-3",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:r?.file?.name??r?.title??"文件"}),d?(0,ey.jsxs)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:[u,":",d]}):null]}),(0,ey.jsx)("div",{className:"max-h-[28rem] overflow-auto p-2",children:s?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"正在读取历史版本"}):0===o.length?(0,ey.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"还没有记录到这个文件的修改历史"}):(0,ey.jsx)("div",{className:"grid gap-1",children:o.map(e=>{var t;let n;return(0,ey.jsxs)("button",{type:"button",className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-muted/70",onClick:()=>i(e),children:[(0,ey.jsxs)("span",{className:"min-w-0",children:[(0,ey.jsxs)("span",{className:"block truncate text-sm font-medium",children:[Jt(e.mutationId)," ·"," ","before"===e.state?"修改前":"修改后"]}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:Number.isFinite(n=Date.parse(t=e.createdAt))?new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(n):t})]}),(0,ey.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,ey.jsxs)("b",{className:"font-medium text-emerald-600",children:["+",e.additions??0]}),(0,ey.jsxs)("b",{className:"font-medium text-rose-600",children:["-",e.deletions??0]})]})]},e.id)})})})]})})}function Jt(e){return e.replace(/^mut-/,"").slice(0,16)}let Jn=(0,l2.cva)("vtl-surface-card relative w-full rounded-[var(--surface-card-radius)] border px-4 py-3 text-sm [&>svg]:absolute [&>svg]:top-3.5 [&>svg]:left-4 [&>svg~*]:pl-7",{variants:{variant:{default:"border-border",muted:"border-border bg-muted/40",destructive:"border-destructive/35 bg-destructive/10 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}});function Jr({className:e,variant:t,...n}){return(0,ey.jsx)("div",{role:"alert","data-slot":"alert",className:(0,eI.cn)(Jn({variant:t}),e),...n})}function Ja({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-title",className:(0,eI.cn)("mb-1 leading-none font-medium",e),...t})}function Ji({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"alert-description",className:(0,eI.cn)("text-muted-foreground [&_p]:leading-relaxed",e),...t})}function Jo({conversationId:e}){let[t,n]=ew.useState([]),[r,a]=ew.useState({}),[i,o]=ew.useState(!0),[l,s]=ew.useState(null),[c,d]=ew.useState(""),u=ew.useCallback(async()=>{let t=(await w2(e)).folders??[];n(t),a(Object.fromEntries(t.map(e=>[e.path,e.vantaloom])))},[e]);async function f(t){if(!l){s(t),d("");try{await w5(t,r[t]??"",e),await u()}catch(e){d(e instanceof Error?e.message:"保存失败")}finally{s(null)}}}return(ew.useEffect(()=>{(async()=>{o(!0);try{await u()}catch(e){d(e instanceof Error?e.message:"加载失败")}finally{o(!1)}})()},[u]),i)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取该对话的项目文档"}):(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"这里管理本对话工作区文件夹里的系统提示词。会自动读取各文件夹的 agent.md / claude.md 等文档;你可以选一份作为模板,或自行编写,保存后写入该文件夹的 vantaloom.md,并作为带标记的系统提示词长期注入本对话上下文。 若未设置且未检测到任何文档,则使用全局“兜底系统提示词”。"})]}),c?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"错误"}),(0,ey.jsx)(Ji,{children:c})]}):null,0===t.length?(0,ey.jsx)("p",{className:"rounded-md border border-dashed px-3 py-4 text-xs text-muted-foreground",children:"本对话还没有工作区文件夹。先在“工作区文件夹”里添加一个本机文件夹,这里就会列出它的文档。"}):t.map(e=>{let t=e.docs??[];return(0,ey.jsxs)("div",{className:"grid gap-2 rounded-md border bg-card p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",title:e.path,children:e.path}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(e.path),disabled:l===e.path,children:[(0,ey.jsx)(KR,{className:"size-4"}),l===e.path?"保存中":"保存到 vantaloom.md"]})]}),t.length>0?(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"用作模板:"}),t.map(t=>(0,ey.jsx)(eA.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>a(n=>({...n,[e.path]:t.content})),children:t.name},t.name))]}):(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到 agent.md / claude.md,可直接编写。"}),(0,ey.jsx)(bq,{value:r[e.path]??"",onChange:t=>a(n=>({...n,[e.path]:t.currentTarget.value})),placeholder:"该项目的系统提示词 / 规范,将写入 vantaloom.md",rows:8,className:"resize-y font-mono text-xs"})]},e.path)})]})}let Jl=[{id:"models",label:"模型"},{id:"tools",label:"工具权限"},{id:"commands",label:"禁止命令"},{id:"folders",label:"工作区文件夹"},{id:"system-prompt",label:"系统提示词"},{id:"hosts",label:"可访问主机"}];function Js({conversation:e,mainModels:t,ccModel:n="",sessionSettings:r,onMainModelsChange:a,onCcModelChange:i,onSessionSettingsChange:o,onClose:l,onEnterConversation:s}){let[c,d]=ew.useState("models"),u=w1(e.settings.engine);return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon","aria-label":"关闭设置",onClick:l,className:"shrink-0",children:(0,ey.jsx)(fc.XIcon,{className:"size-5"})}),(0,ey.jsxs)("button",{type:"button",className:"min-w-0 flex-1 rounded-lg px-2 py-1 text-left transition-colors hover:bg-muted/60",title:"返回该对话",onClick:()=>s?.(e),children:[(0,ey.jsxs)("div",{className:"text-[11px] text-muted-foreground",children:[e.agent," · 会话设置"]}),(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:e.title})]})]}),(0,ey.jsx)("nav",{className:"flex shrink-0 gap-1 overflow-x-auto border-b px-3 py-2 vtl-scrollbar-hidden",children:Jl.filter(e=>"system-prompt"!==e.id||!u).map(e=>(0,ey.jsx)("button",{type:"button",onClick:()=>d(e.id),className:(0,eI.cn)("shrink-0 rounded-lg px-3 py-1.5 text-[13px] transition-colors",c===e.id?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:e.label},e.id))}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4 pb-[max(1.25rem,env(safe-area-inset-bottom))]",children:(0,ey.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:["models"===c?(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"grid grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"运行引擎"}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:function(e){switch(e){case"claude-code":return"Claude Code";case"reclaude":return"reclaude";default:return"Vantaloom"}}(e.settings.engine)})]}),u?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("label",{htmlFor:"conversation-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,ey.jsxs)(gb,{value:""===n?wQ:n,onValueChange:e=>i?.(e===wQ?"":e),children:[(0,ey.jsx)(g9,{id:"conversation-cc-model",className:"w-full",children:(0,ey.jsx)(gS,{placeholder:"选择 Claude Code 模型"})}),(0,ey.jsx)(vn,{children:w0.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,ey.jsx)(vz,{conversation:e,mainModels:t,onMainModelsChange:a})]}):null,"tools"===c?(0,ey.jsx)(wU,{value:r.allowedTools,onChange:e=>o({...r,allowedTools:e,deniedTools:[]})}):null,"commands"===c?(0,ey.jsx)(wW,{value:r.blockedCommands,onChange:e=>o({...r,blockedCommands:e})}):null,"folders"===c?(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)(wq,{title:"可访问的工作区文件夹",value:r.folders,onValueChange:e=>o({...r,folders:u?e.slice(-1):e})}),u?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,"system-prompt"!==c||u?null:(0,ey.jsx)(Jo,{conversationId:e.id}),"hosts"===c?(0,ey.jsx)(wJ,{value:r.hosts,onValueChange:e=>o({...r,hosts:e}),disabled:u,hint:u?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0}):null]})})]})}function Jc({conversationId:e,ownerMachineId:t,open:n,onOpenChange:r,onEnterConversation:a}){let[i,o]=ew.useState(),[l,s]=ew.useState([]),[c,d]=ew.useState(""),[u,f]=ew.useState({folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:[]});async function h(e){if(!i)return;let n=e.session??u,r=e.mainModels??l,a=e.ccModel??c,s={subagents:i.settings.subagents??[],mainModels:r,folders:n.folders,blockedCommands:n.blockedCommands,allowedTools:n.allowedTools,deniedTools:n.deniedTools,plugins:n.plugins,hosts:n.hosts,permissionMode:n.permissionMode??i.settings.permissionMode,engine:i.settings.engine,ccModel:i.settings.engine?a:void 0};try{let e=await sF(i.id,{settings:s},t);o(e.conversation)}catch{}}function p(){o(void 0),r(!1)}return(ew.useEffect(()=>{if(!n||!e)return;let r=!0;return async function(){try{let n=await sA(e,t);if(!r)return;let a=n.conversation;o(a),s(a.settings.mainModels),d(a.settings.ccModel??""),f({folders:a.settings.folders,blockedCommands:a.settings.blockedCommands,allowedTools:a.settings.allowedTools,deniedTools:a.settings.deniedTools,plugins:a.settings.plugins,hosts:a.settings.hosts})}catch{}}(),()=>{r=!1}},[e,n,t]),n&&i)?(0,ey.jsx)(Js,{conversation:i,mainModels:l,ccModel:c,sessionSettings:u,onMainModelsChange:e=>{s(e),h({mainModels:e})},onCcModelChange:e=>{d(e),h({ccModel:e})},onSessionSettingsChange:e=>{f(e),h({session:e})},onClose:p,onEnterConversation:e=>{p(),a?.(e.id,t)}}):null}let Jd="local";async function Ju(e){return((await Jy(e,"")).canvases??[]).map(t=>Jx(t,e))}async function Jf(e,t){return Jv(await Jy(t,`/${encodeURIComponent(e)}`),t)}async function Jh(e,t){return Jv(await Jy(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(uR),edges:e.edges.map(uL)})}),t)}async function Jp(e,t,n){return Jv(await Jy(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(uR),edges:t.edges.map(uL),nodeIds:t.nodeIds})}),n)}async function Jm(e,t){return Jv(await Jy(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}async function Jg(){let e={[Jd]:"本机"},t=[],n=[];try{n=await Ju(void 0)}catch{n=[]}let r=[];try{let{machines:e}=await sw();r=(e??[]).filter(e=>!e.isLocal&&"online"===e.status).map(e=>({id:e.id,name:e.name}))}catch{r=[]}let a=await Promise.all(r.map(async n=>{e[n.id]=n.name;try{return await Ju(n.id)}catch{return t.push(n.id),[]}})),i=new Map;for(let e of[...n,...a.flat()]){let t=i.get(e.id);(!t||e.updatedAt>t.updatedAt)&&i.set(e.id,e)}let o=Array.from(i.values());return o.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),{canvases:o,machineNames:e,unreachable:t}}function Jv(e,t){return{canvas:Jx(e.canvas,t),nodes:e.nodes??[],edges:e.edges??[]}}function Jx(e,t){let n=t&&t!==Jd?t:e.ownerMachineId??"local";return{id:e.id,title:e.title||"新画布",ownerMachineId:n,nodeCount:e.nodeCount??0,running:e.running??!1,createdAt:e.createdAt,updatedAt:e.updatedAt,lastOpenedAt:e.lastOpenedAt}}async function Jy(e,t,n,r){let a=await fetch(eD(!e||e===Jd?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let Jb=(0,ek.default)("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Jw=(0,ek.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),Jj=(0,ek.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Jk=(0,ek.default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]),JS=(0,ek.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),JN=(0,ek.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),JC={done:"Done",current:"Current",queued:"Queued",blocked:"Blocked"};function JM(e,t,n){return Math.min(Math.max(e,t),n)}function JE({items:e,currentId:t,labels:n,scrollCurrentIntoView:r=!0,className:a,viewportClassName:i,itemClassName:o,extendLineToViewport:l=!1,...s}){let c={...JC,...n},d=ew.useRef(null),u=ew.useRef(null),f=ew.useRef(null),h=ew.useRef(0),p=ew.useRef(void 0),[m,g]=ew.useState(0),v=t??e.find(e=>"current"===e.status)?.id,x=ew.useCallback(()=>{void 0!==p.current&&(cancelAnimationFrame(p.current),p.current=void 0)},[]),y=ew.useCallback((e,t=340)=>{let n=d.current,r=u.current;if(!n||!r)return;x();let a=Math.max(0,n.scrollHeight-n.clientHeight),i=n.scrollTop,o=JM(e,0,a),l=performance.now();h.current=o;let s=e=>{let r=JM((e-l)/t,0,1);if(n.scrollTop=i+(o-i)*(1-Math.pow(1-r,3)),r<1){p.current=requestAnimationFrame(s);return}n.scrollTop=o,p.current=void 0};p.current=requestAnimationFrame(s)},[x]),b=ew.useCallback(e=>{let t=d.current,n=u.current;if(!t||!n)return;let r=Math.max(0,t.scrollHeight-t.clientHeight);if(r<=0)return;e.preventDefault();let a=void 0===p.current?t.scrollTop:h.current,i=1===e.deltaMode?32*e.deltaY:2===e.deltaMode?e.deltaY*e.currentTarget.clientHeight:e.deltaY,o=Math.sign(i);if(0===o)return;let l=Array.from(n.querySelectorAll("[data-slot='roadmap-item']")).map(e=>e.offsetTop),s=JM(Math.ceil(Math.abs(i)/160),1,3),c=a;for(let e=0;e<s;e+=1)c=function(e,t,n,r){if(0===e.length)return t;if(n>0)return e.find(e=>e>t+1)??r;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0!==r&&r<t-1)return r}return 0}(l,c,o,r);y(c)},[y]);return ew.useLayoutEffect(()=>{if(!r)return;let e=d.current,t=u.current,n=f.current;if(!e||!t||!n)return void g(0);let a=n.offsetTop,i=t.scrollHeight-m,o=Math.max(0,e.clientHeight-(i-a));g(e=>Math.abs(e-o)>.5?o:e),requestAnimationFrame(()=>{e.scrollTop=a,h.current=a})},[m,e,v,r]),ew.useEffect(()=>x,[x]),(0,ey.jsx)("div",{"data-slot":"roadmap",className:(0,eI.cn)("min-w-0 text-foreground",a),...s,children:(0,ey.jsx)("div",{"data-slot":"roadmap-viewport",ref:d,onWheel:b,className:(0,eI.cn)("max-h-72 overflow-y-auto overscroll-contain pr-2",i),children:(0,ey.jsxs)("div",{ref:u,className:(0,eI.cn)("relative",l&&"min-h-full"),children:[(0,ey.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 bottom-0 left-[0.3125rem] w-px bg-border"}),e.map(e=>{let t=e.id===v?"current":e.status??"queued";return(0,ey.jsxs)("div",{ref:"current"===t?f:void 0,"data-slot":"roadmap-item","data-status":t,"aria-label":c[t],className:(0,eI.cn)("relative grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-2 py-2.5",o),children:[(0,ey.jsx)("span",{"aria-hidden":"true","data-slot":"roadmap-marker",className:(0,eI.cn)("relative z-10 mt-1 size-2.5 rounded-full border bg-background","done"===t&&"border-muted-foreground bg-muted-foreground","current"===t&&"border-primary bg-primary","queued"===t&&"border-border","blocked"===t&&"border-destructive bg-destructive")}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{"data-slot":"roadmap-title",className:(0,eI.cn)("text-sm leading-5","queued"===t&&"text-muted-foreground","blocked"===t&&"text-destructive"),children:e.title}),e.description?(0,ey.jsx)("div",{"data-slot":"roadmap-description",className:"mt-0.5 text-xs leading-5 text-muted-foreground",children:e.description}):null]}),e.meta?(0,ey.jsx)("div",{"data-slot":"roadmap-meta",className:"pt-0.5 text-right ui-text-kbd text-muted-foreground",children:e.meta}):null]},e.id)}),m>0?(0,ey.jsx)("div",{"aria-hidden":"true","data-slot":"roadmap-bottom-spacer",style:{height:m}}):null]})})})}let JO="/themes/jelly/bg1.png",JP="/themes/jelly/bg2.png",JA="/themes/jelly/bg3.png",JI="/themes/jelly/bg4.png";function Jz({image:e,position:t="center",opacity:n=.72,blur:r="10px"}){return{"--vtl-jelly-card-image":`url("${e}")`,"--vtl-jelly-card-position":t,"--vtl-jelly-card-opacity":String(n),"--vtl-jelly-card-blur":r}}function JT({title:e}){return(0,ey.jsx)("h2",{className:"h-7 text-sm font-semibold tracking-normal",children:e})}let JD={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题"},J_={search:"搜索控制台...",dashboard:"仪表盘",canvas:"画布",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近画布",canvasNew:"新建画布",canvasAll:"浏览所有画布",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"};JD.local,JD.direct,JD.online,JD.p2p,JD.online,JD.direct,JD.sleeping,JD.cpu,JD.memory,JD.activeRuns;function JR(e){return e.reduce((e,t)=>Math.max(e,t.y+t.h),0)}function JL({children:e}){return(0,ey.jsx)("section",{className:"vtl-app-background flex h-full min-h-0 flex-col pb-14 md:pb-0 text-foreground",children:(0,ey.jsx)(wb,{className:"min-h-0 flex-1",children:e})})}function J$(e){return Math.max(0,...e.map(e=>e.y+e.h))}function JF(e,t,n){return t.some(t=>t.id!==n&&e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}function JB(e){let t=Math.max(2,Math.min(12,e.w)),n=Math.max(1,e.h),r=Math.max(0,Math.min(12-t,e.x)),a=Math.max(0,e.y);return{...e,x:r,y:a,w:t,h:n}}function JV(e,t,n,r,a){for(let i=0;i<J$(e)+8;i+=1)for(let o=0;o<=12-r;o+=1){let l={id:t,kind:n,x:o,y:i,w:r,h:a};if(!JF(l,e))return l}return{id:t,kind:n,x:0,y:J$(e)+2,w:r,h:a}}function JH(e){return{...e.defaultConfig}}function JU(e){return e.payloads?.[Gi]}function JW({open:e,definitions:t,title:n="添加卡片",description:r="搜索并选择要添加到当前页面的卡片。",groupTitle:a="可添加卡片",onOpenChange:i,onAdd:o}){return(0,ey.jsx)(xn,{open:e,onOpenChange:i,title:n,description:r,className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索可添加卡片..."}),(0,ey.jsxs)(xa,{className:"max-h-[420px]",children:[(0,ey.jsx)(xi,{children:"没有找到可添加的卡片。"}),(0,ey.jsx)(xo,{heading:a,children:t.map(e=>(0,ey.jsxs)(xl,{value:`${e.title} ${e.description}`,keywords:[e.id,e.defaultConfig.dataSource,e.defaultConfig.title],onSelect:()=>o(e.id),className:"min-h-14 items-start py-2",children:[(0,ey.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate font-medium",children:e.title}),(0,ey.jsx)("span",{className:"mt-0.5 block truncate ui-text-kbd text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xs,{children:[e.defaultSize.w,"x",e.defaultSize.h]})]},e.id))})]})]})})}function Jq({open:e,dragMode:t,label:n="页面卡片操作",onOpenChange:r,onAdd:a,onDragModeChange:i}){let o=[{key:"add",label:"添加卡片",icon:(0,ey.jsx)(lJ,{className:"size-4"}),onClick:a,pressed:!1},{key:"drag",label:"拖拽排版",icon:(0,ey.jsx)(lq,{className:"size-4"}),onClick:()=>i(!t),pressed:t}];return(0,ey.jsx)("div",{className:"fixed right-5 bottom-5 z-30",children:(0,ey.jsxs)("div",{className:"relative size-8",children:[o.map((t,n)=>(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,"aria-pressed":t.pressed,onClick:t.onClick,className:(0,eI.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",t.pressed&&"border-foreground bg-foreground text-background shadow-lg ring-1 ring-background/50 hover:bg-foreground hover:text-background dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,ey.jsx)(eA.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":n,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,ey.jsx)(lY,{className:(0,eI.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}let JK=(0,ek.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function JG({layout:e,layouts:t,cellSize:n,cellHeight:r,dragMode:a,selected:i,resizing:o,onSelect:l,onMove:s,onCut:c,onCopy:d,onSettingsOpen:u,onResizeStart:f,onResizeEnd:h,children:p}){let[m,g]=ew.useState(!1),v=r??n,x=e.x*(n+12),y=e.y*(v+12),b=e.w*n+(e.w-1)*12,w=e.h*v+(e.h-1)*12;return(0,ey.jsxs)("div",{"data-editable-card":e.id,className:(0,eI.cn)("absolute rounded-lg p-1 transition-[left,top,width,height,box-shadow] duration-200 ease-out",a&&"cursor-grab active:cursor-grabbing",m&&"duration-150",i&&!o&&"z-20 shadow-sm",o&&"z-30 transition-none"),style:{left:x,top:y,width:b,height:w},onPointerDown:function(r){if(!a||o)return;let i=r.target;if(i instanceof HTMLElement&&i.closest("[data-editable-card-action]"))return;r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),l();let c=r.clientX,d=r.clientY;function u(r){let a=JB({...e,x:e.x+Math.round((r.clientX-c)/(n+12)),y:e.y+Math.round((r.clientY-d)/(n+12))});JF(a,t,e.id)||s(a)}g(!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",e),g(!1)})},onClick:()=>{a&&l()},children:[(0,ey.jsx)("div",{className:(0,eI.cn)("size-full",a&&"pointer-events-none"),children:p}),i&&a&&!o?(0,ey.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-1 rounded-lg border-2 border-foreground"}):null,i&&a&&!o?(0,ey.jsx)(JX,{onSettingsOpen:u,onCut:c,onCopy:d,onResizeStart:f}):null,o?(0,ey.jsx)(JY,{layout:e,layouts:t,cellSize:n,onResize:s,onResizeEnd:h}):null]})}function JX({onSettingsOpen:e,onCut:t,onCopy:n,onResizeStart:r}){return(0,ey.jsx)(l4,{"data-editable-card-action":!0,placement:"inline",size:"sm","aria-label":"卡片操作",className:"!absolute top-full left-1/2 z-40 mt-2 -translate-x-1/2 rounded-lg bg-popover/95 p-1 shadow-md",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,ey.jsxs)(l3,{children:[(0,ey.jsx)(l6,{type:"button","aria-label":"调整大小",onClick:r,children:(0,ey.jsx)(lX,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"卡片设置",onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),e()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(JK,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"复制",onClick:n,children:(0,ey.jsx)(lU,{className:"size-4"})}),(0,ey.jsx)(l6,{type:"button","aria-label":"剪切",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),t()},onClick:e=>e.stopPropagation(),children:(0,ey.jsx)(l0,{className:"size-4"})})]})})}function JY({layout:e,layouts:t,cellSize:n,onResize:r,onResizeEnd:a}){return(0,ey.jsx)("div",{"data-editable-card-action":!0,className:"pointer-events-none absolute inset-1 z-40 border-2 border-foreground",children:[{id:"top-left",className:"top-0 left-0 -translate-x-1/2 -translate-y-1/2 cursor-nwse-resize"},{id:"top",className:"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 cursor-ns-resize"},{id:"top-right",className:"top-0 right-0 translate-x-1/2 -translate-y-1/2 cursor-nesw-resize"},{id:"right",className:"top-1/2 right-0 translate-x-1/2 -translate-y-1/2 cursor-ew-resize"},{id:"bottom-right",className:"right-0 bottom-0 translate-x-1/2 translate-y-1/2 cursor-nwse-resize"},{id:"bottom",className:"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2 cursor-ns-resize"},{id:"bottom-left",className:"bottom-0 left-0 -translate-x-1/2 translate-y-1/2 cursor-nesw-resize"},{id:"left",className:"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize"}].map(i=>(0,ey.jsx)("button",{type:"button","aria-label":`调整 ${i.id}`,className:(0,eI.cn)("pointer-events-auto absolute size-2.5 border border-foreground bg-background shadow-sm",i.className),onPointerDown:o=>(function(i,o){i.preventDefault(),i.stopPropagation(),i.currentTarget.setPointerCapture(i.pointerId);let l=i.clientX,s=i.clientY;function c(a){let i=Math.round((a.clientX-l)/(n+12)),c=Math.round((a.clientY-s)/(n+12)),d={...e};o.includes("right")&&(d.w=e.w+i),o.includes("bottom")&&(d.h=e.h+c),o.includes("left")&&(d.x=e.x+i,d.w=e.w-i),o.includes("top")&&(d.y=e.y+c,d.h=e.h-c),JF(d=JB(d),t,e.id)||r(d)}window.addEventListener("pointermove",c),window.addEventListener("pointerup",function e(){window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",e),a()})})(o,i.id)},i.id))})}function JZ({className:e,...t}){return(0,ey.jsx)(dO,{"data-slot":"sheet-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function JJ({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return(0,ey.jsxs)(dM,{children:[(0,ey.jsx)(JZ,{}),(0,ey.jsxs)(dz,{"data-slot":"sheet-content","data-side":n,className:(0,eI.cn)("vtl-surface-modal fixed z-50 flex flex-col gap-4 border transition ease-in-out outline-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-300","right"===n&&"inset-y-0 right-0 h-full w-3/4 border-r-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm","left"===n&&"inset-y-0 left-0 h-full w-3/4 border-l-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm","top"===n&&"inset-x-0 top-0 h-auto border-t-0 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top","bottom"===n&&"inset-x-0 bottom-0 h-auto border-b-0 data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),...a,children:[t,r&&(0,ey.jsxs)(dV,{className:"absolute top-3 right-3 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none",children:[(0,ey.jsx)(fc.XIcon,{className:"size-4"}),(0,ey.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function JQ({className:e,...t}){return(0,ey.jsx)("div",{"data-slot":"sheet-header",className:(0,eI.cn)("grid gap-1.5 p-4 text-left",e),...t})}function J0({className:e,...t}){return(0,ey.jsx)(dL,{"data-slot":"sheet-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function J1({className:e,...t}){return(0,ey.jsx)(dF,{"data-slot":"sheet-description",className:(0,eI.cn)("text-sm text-muted-foreground",e),...t})}function J2({open:e,layout:t,definition:n,config:r,cellSize:a,onOpenChange:i,onConfigChange:o}){let l=t&&a>0?t.w*a+(t.w-1)*12:320,s=t&&a>0?t.h*a+(t.h-1)*12:180;return(0,ey.jsx)(dw,{open:e,onOpenChange:i,children:(0,ey.jsx)(JJ,{side:"right",className:"w-screen gap-0 border-0 bg-transparent p-0 shadow-none sm:max-w-none",children:t&&n&&r?(0,ey.jsxs)("div",{className:"grid h-full min-w-0 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_24rem]",children:[(0,ey.jsx)(J5,{width:l,height:s,className:"hidden lg:grid",children:n.render(r)}),(0,ey.jsxs)("div",{className:"animate-in slide-in-from-right-4 flex h-full w-full flex-col border-y-0 border-r-0 bg-background text-foreground shadow-lg duration-300",children:[(0,ey.jsxs)(JQ,{className:"border-b",children:[(0,ey.jsx)(J0,{children:"卡片设置"}),(0,ey.jsxs)(J1,{children:[n.title," · ",t.w,"x",t.h]})]}),(0,ey.jsxs)("div",{className:"grid flex-1 content-start gap-4 overflow-y-auto p-4",children:[(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"显示标题"}),(0,ey.jsx)(ez,{value:r.title,onChange:e=>o({title:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"数据来源"}),(0,ey.jsx)(ez,{value:r.dataSource,onChange:e=>o({dataSource:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"刷新间隔"}),(0,ey.jsx)(ez,{value:r.refreshRate,onChange:e=>o({refreshRate:e.currentTarget.value})})]}),(0,ey.jsxs)("label",{className:"grid gap-1.5",children:[(0,ey.jsx)("span",{className:"ui-text-control font-medium",children:"备注"}),(0,ey.jsx)("textarea",{value:r.note,rows:4,className:"min-h-24 resize-none rounded-lg border border-input bg-transparent px-2.5 py-2 ui-text-control transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",onChange:e=>o({note:e.currentTarget.value})})]}),(0,ey.jsxs)("div",{className:"rounded-lg border bg-muted/20 p-3",children:[(0,ey.jsx)("div",{className:"ui-text-control font-medium",children:"当前绑定"}),(0,ey.jsxs)("div",{className:"mt-2 grid gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["类型:",n.id]}),(0,ey.jsxs)("span",{children:["来源:",r.dataSource]}),(0,ey.jsxs)("span",{children:["刷新:",r.refreshRate]})]})]})]})]})]}):null})})}function J5({width:e,height:t,className:n,children:r}){let[a,i]=GR(),o=i.width>0&&i.height>0?Math.min(1,(i.width-32)/e,(i.height-32)/t):1;return(0,ey.jsx)("div",{ref:a,className:(0,eI.cn)("min-h-0 min-w-0 place-items-center overflow-hidden p-4",n),children:(0,ey.jsx)("div",{className:"animate-in fade-in-0 zoom-in-95 origin-center rounded-lg duration-300",style:{width:e,height:t,transform:`scale(${Math.max(.1,o)})`},children:r})})}function J4({boardId:e,definitions:t,initialLayouts:n,clipboardItems:r=[],minRows:a=9,className:i,actionLabel:o,paletteGroupTitle:l,onClipboardItemsChange:s,onOverlayOpenChange:c}){var d;let[u,f]=ew.useState(!1),[h,p]=ew.useState(!1),[m,g]=ew.useState(!1),[v,x]=ew.useState(()=>n),[y,b]=ew.useState({}),[w,j]=ew.useState(),[k,S]=ew.useState(),[N,C]=ew.useState(),M=ew.useRef(0),E=ew.useRef(0),[O,P]=GR(),A=P.width>0?(d=P.width)<480?2:d<768?4:12:12,I=function(e,t){if(t>=12)return e;let n=[...e].sort((e,t)=>e.y!==t.y?e.y-t.y:e.x-t.x),r=[];for(let e of n){let n=Math.max(2,Math.min(t,Math.round(e.w*t/12))),a=e.h,i=!1;for(let o=0;o<JR(r)+8&&!i;o+=1)for(let l=0;l<=t-n&&!i;l+=1){let t={...e,x:l,y:o,w:n,h:a};!function(e,t){return t.some(t=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y)}(t,r)&&(r.push(t),i=!0)}i||r.push({...e,x:0,y:JR(r),w:n,h:a})}return r}(v,A),z=P.width>0?(P.width-12*(A-1))/A:96,T=A<12?72:z,D=Math.max(a,J$(I)+2),_=D*T+(D-1)*12,R=ew.useMemo(()=>new Map(t.map(e=>[e.id,e])),[t]);function L(e){let t=R.get(e.kind);return y[e.id]??(t?JH(t):void 0)}function $(e){x(t=>{let n=JB(e);return JF(n,t,n.id)?t:t.map(e=>e.id===n.id?n:e)})}function F(e){let t=R.get(e);if(!t)return;E.current+=1;let n=`${e}-added-${E.current}`,r=JV(v,n,e,t.defaultSize.w,t.defaultSize.h);x(e=>[...e,r]),b(e=>({...e,[n]:JH(t)})),j(n),S(void 0),p(!1)}function B(e,t){let n=v.find(t=>t.id===e),r=n?R.get(n.kind):void 0;n&&r&&b(n=>({...n,[e]:{...n[e]??JH(r),...t}}))}ew.useEffect(()=>{c?.(h||!!N)},[h,c,N]),ew.useEffect(()=>()=>c?.(!1),[c]),ew.useEffect(()=>{m||(j(void 0),S(void 0))},[m]),ew.useEffect(()=>{if(k)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof HTMLElement&&t.closest("[data-editable-card-action]")||(j(k),S(void 0))}},[k]);let V=A<12,H=N?v.find(e=>e.id===N):void 0,U=H?R.get(H.kind):void 0,W=H?L(H):void 0;if(V){let n=[...I].sort((e,t)=>e.y-t.y||e.x-t.x),r=Object.fromEntries(v.map(e=>[e.id,e.w]));return(0,ey.jsxs)(JL,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("mx-auto max-w-7xl p-3",i),children:(0,ey.jsx)("div",{className:"grid grid-cols-2 gap-3",children:n.map(e=>{let t=R.get(e.kind);if(!t)return null;let n=L(e);if(!n)return null;let a=(r[e.id]??e.w)>6;return(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-0 overflow-hidden rounded-lg",a&&"col-span-2"),style:{minHeight:a?200:120},children:t.render(n)},e.id)})})}),(0,ey.jsx)(Jq,{open:u,dragMode:!1,label:o,onOpenChange:f,onAdd:()=>{f(!1),p(!0)},onDragModeChange:g}),(0,ey.jsx)(JW,{open:h,definitions:t,groupTitle:l,onOpenChange:p,onAdd:F}),(0,ey.jsx)(J2,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}return(0,ey.jsxs)(JL,{children:[(0,ey.jsx)("div",{ref:O,"data-editable-card-board":e,className:(0,eI.cn)("relative mx-auto max-w-7xl p-4 lg:p-6",m&&"select-none",i),style:{minHeight:_+48},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(Gi)&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},onDrop:function(e){let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let n=r.find(e=>e.id===t),a=n&&JU(n);if(!n||!a||!R.has(a.kind))return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let i=O.current,o=i?.getBoundingClientRect();!function(e,t){let n=JU(e);if(!n||!R.has(n.kind))return;E.current+=1;let r=`${n.kind}-clip-${E.current}`,a=JB({id:r,kind:n.kind,x:t?.x??0,y:t?.y??J$(v),w:n.w,h:n.h}),i=t&&!JF(a,v)?a:JV(v,r,n.kind,n.w,n.h);x(e=>[...e,i]),b(e=>({...e,[r]:{...n.config}})),j(r),S(void 0)}(n,{x:o&&z>0?Math.round((e.clientX-o.left-24)/(z+12)):0,y:o&&z>0?Math.round((e.clientY-o.top-24)/(z+12)):J$(v)})},onPointerDown:e=>{e.target===e.currentTarget&&(j(void 0),m||S(void 0))},children:(0,ey.jsx)("div",{className:"relative",style:{height:_},children:I.map(t=>{let n=R.get(t.kind);if(!n)return null;let r=L(t);return r?(0,ey.jsx)(JG,{layout:t,layouts:I,cellSize:z,cellHeight:T,dragMode:m,selected:w===t.id,resizing:k===t.id,onSelect:()=>{m&&j(t.id)},onMove:$,onCut:()=>(function(t){let n=v.find(e=>e.id===t),r=n?R.get(n.kind):void 0,a=n?L(n):void 0;if(!n||!r||!a)return;let i=function({boardId:e,layout:t,definition:n,config:r}){let a={boardId:e,kind:t.kind,w:t.w,h:t.h,config:{...r}};return{id:`clip-${e}-${t.id}`,title:r.title||n.title,description:n.description,meta:`${t.w}x${t.h}`,icon:n.icon,dragData:{"application/vnd.vantaloom.clip-kind":"workspace-card","application/vnd.vantaloom.workspace-card-board":e,"application/vnd.vantaloom.workspace-card-kind":t.kind,"application/vnd.vantaloom.workspace-card-width":String(t.w),"application/vnd.vantaloom.workspace-card-height":String(t.h),"application/vnd.vantaloom.workspace-card-config":JSON.stringify(r),[Gi]:JSON.stringify(a)},payloads:{[Gi]:a}}}({boardId:e,layout:n,definition:r,config:a});s?.(e=>[i,...e.filter(e=>e.id!==i.id)]),x(e=>e.filter(e=>e.id!==t)),b(e=>{let n={...e};return delete n[t],n}),j(void 0),S(void 0),C(e=>e===t?void 0:e)})(t.id),onCopy:()=>(function(e){let t=v.find(t=>t.id===e),n=t?R.get(t.kind):void 0;if(!t||!n)return;M.current+=1;let r=`${e}-copy-${M.current}`,a=JV(v,r,t.kind,t.w,t.h);x(e=>[...e,a]),b(t=>({...t,[r]:t[e]??JH(n)})),j(r)})(t.id),onSettingsOpen:()=>C(t.id),onResizeStart:()=>{j(void 0),S(t.id)},onResizeEnd:()=>{j(t.id),S(void 0)},children:n.render(r)},t.id):null})})}),(0,ey.jsx)(Jq,{open:u,dragMode:m,label:o,onOpenChange:f,onAdd:()=>{f(!1),p(!0)},onDragModeChange:g}),(0,ey.jsx)(JW,{open:h,definitions:t,groupTitle:l,onOpenChange:p,onAdd:F}),(0,ey.jsx)(J2,{open:!!(H&&U&&W),layout:H,definition:U,config:W,cellSize:z,onOpenChange:e=>{e||C(void 0)},onConfigChange:e=>{H&&B(H.id,e)}})]})}function J3({parts:e}){return(0,ey.jsx)(ey.Fragment,{children:e.map((e,t)=>(0,ey.jsx)("span",{className:e.small?"text-[0.55em]":void 0,children:e.text},`${e.text}-${t}`))})}function J6({value:e,minSize:t=24,maxSize:n=180,className:r,...a}){let i=ew.useRef(null),o=ew.useRef(null),[l,s]=ew.useState(t),c=function(e){let t=e.trim();if(/^[$¥€]\s*\d/.test(t))return[{text:t.replace(/^[$¥€]\s*/,""),small:!1},{text:t[0]??"",small:!0}];let n=t.match(/^(.+?)\s*\/\s*(.+)$/);if(n)return[{text:n[1]??"",small:!1},{text:"/",small:!0},{text:n[2]??"",small:!1}];let r=t.match(/^(.+?)([%a-zA-Z$¥€]+)$/);return r?[{text:r[1]??t,small:!1},{text:r[2]??"",small:!0}]:[{text:t,small:!1}]}(e);return ew.useLayoutEffect(()=>{let e=i.current,r=o.current;if(!e||!r)return;function a(e,r){let a=e.clientWidth,i=e.clientHeight;if(a<=0||i<=0)return;let o=t,l=n,c=t;for(;o<=l;){let e=Math.floor((o+l)/2);r.style.fontSize=`${e}px`,r.getBoundingClientRect().width<=a&&r.getBoundingClientRect().height<=i?(c=e,o=e+1):l=e-1}s(c)}a(e,r);let l=new ResizeObserver(()=>a(e,r));return l.observe(e),()=>l.disconnect()},[n,t,e]),(0,ey.jsxs)("div",{ref:i,className:(0,eI.cn)("relative min-h-0 min-w-0 overflow-hidden",r),...a,children:[(0,ey.jsx)("span",{ref:o,"aria-hidden":"true",className:"pointer-events-none invisible absolute right-0 bottom-0 flex items-baseline whitespace-nowrap font-semibold leading-none tracking-normal",children:(0,ey.jsx)(J3,{parts:c})}),(0,ey.jsx)("span",{className:"absolute right-0 bottom-0 flex max-w-full items-baseline whitespace-nowrap font-semibold leading-none tracking-normal text-foreground",style:{fontSize:l},children:(0,ey.jsx)(J3,{parts:c})})]})}function J8(e){return/^\d+$/.test(e)&&1===e.length?`0${e}`:/^\d+(?:\.\d+)?%$/.test(e)?`${Number.parseFloat(e).toFixed(1)}%`:e}function J7({label:e,value:t,minSize:n=42,maxSize:r=180,valueClassName:a="absolute right-0 bottom-0 h-2/3 w-full"}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)(J6,{value:J8(t),minSize:n,maxSize:r,className:a})]})}function J9(e){return Math.max(0,Math.min(100,Math.round(e)))}function Qe({className:e,value:t=0,...n}){let r=J9(t);return(0,ey.jsx)("div",{"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r,className:(0,eI.cn)("relative h-1.5 w-full overflow-hidden rounded-full bg-muted",e),...n,children:(0,ey.jsx)("div",{"data-slot":"progress-indicator",className:"h-full rounded-full bg-primary transition-all",style:{width:`${r}%`}})})}function Qt({className:e,value:t=0,label:n,showValue:r=!0,...a}){let i=J9(t),o=2*Math.PI*39;return(0,ey.jsxs)("div",{"data-slot":"progress-ring","aria-label":n?`${n} ${i}%`:`${i}%`,role:"img",className:(0,eI.cn)("relative grid size-24 place-items-center",e),...a,children:[(0,ey.jsxs)("svg",{"aria-hidden":"true","data-slot":"progress-ring-svg",viewBox:"0 0 100 100",className:"absolute inset-0 size-full overflow-visible",children:[(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--muted)",strokeWidth:12}),i>0&&(0,ey.jsx)("circle",{cx:"50",cy:"50",r:39,fill:"none",stroke:"var(--primary)",strokeDasharray:o,strokeDashoffset:o-i/100*o,strokeLinecap:"round",strokeWidth:12,className:"origin-center -rotate-90 transition-all"})]}),(0,ey.jsx)("div",{"data-slot":"progress-ring-center",className:"relative z-10 grid size-16 place-items-center rounded-full bg-card",children:r&&(0,ey.jsxs)("span",{className:"ui-text-control font-medium tabular-nums",children:[i,"%"]})})]})}(0,ek.default)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);let Qn=(0,ek.default)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Qr({canvases:e,mode:t="active",scrollable:n=!1,onSelect:r}){let a=ew.useMemo(()=>e.map(e=>{var n;return{id:e.id,status:"live"===(n=e).status?"current":"review"===n.status?"blocked":"done",title:(0,ey.jsx)(Qa,{canvas:e,mode:t,onClick:()=>r(e)})}}),[e,t,r]);return(0,ey.jsx)(JE,{items:a,scrollCurrentIntoView:!1,className:(0,eI.cn)("mt-2",n&&"min-h-0 flex-1"),viewportClassName:(0,eI.cn)("max-h-none pr-0",n?"h-full overflow-y-auto":"overflow-visible"),itemClassName:"py-2"})}function Qa({canvas:e,onClick:t,mode:n}){return(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("grid w-full items-center gap-4 rounded-lg px-2 py-0 text-left transition-colors hover:bg-muted/50","active"===n?"grid-cols-[minmax(0,1fr)_8rem_1.75rem]":"grid-cols-[minmax(0,1fr)_7rem_7rem_8rem]"),onClick:t,children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:"active"===n?e.purpose:`${e.nodes} nodes`})]}),"active"===n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Qe,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("span",{"aria-label":e.progress>=100?"Canvas complete":"Canvas incomplete",className:(0,eI.cn)("size-2.5 rounded-full",e.progress>=100?"bg-primary":"bg-border")})]}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(Qi,{icon:(0,ey.jsx)(Vl,{}),value:`${e.snapshots}`}),(0,ey.jsx)(Qi,{icon:(0,ey.jsx)(Qn,{}),value:e.runtime}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:e.lastOpened})]})]})}function Qi({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}let Qo=(0,ek.default)("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),Ql=(0,ek.default)("radio-tower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);(0,ek.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);var Qs=ew;function Qc(){return(Qc=Object.assign.bind()).apply(null,arguments)}function Qd(e){return ew.createElement(T6,Qc({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var Qu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(n,r)=>{if(kn(e))return e;var a=kn(n)||null==n;return a?e(n,r):(a||function(e,t){if(!e)throw Error("Invariant failed")}(!1,"minPointSize callback function received a value with type of ".concat(typeof n,". Currently only numbers or null/undefined are supported.")),t)}},Qf=["children"],Qh=(0,ew.createContext)({data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function Qp(e){var{children:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,Qf);return ew.createElement(Qh.Provider,{value:n},t)}var Qm=(e,t,n)=>{var r=null!=n?n:e;if(null!=r)return ko(r,t,0)};function Qg(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qv(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qg(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qg(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Qx=jH([PT,(e,t)=>t],(e,t)=>e.filter(e=>"bar"===e.type).find(e=>e.id===t)),Qy=jH([Qx],e=>null==e?void 0:e.maxBarSize),Qb=jH([Cl,PT,Xm,Xg,(e,t,n)=>n],(e,t,n,r,a)=>t.filter(t=>"horizontal"===e?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===a).filter(e=>!1===e.hide).filter(e=>"bar"===e.type)),Qw=jH([Qb,e=>e.rootProps.barSize,(e,t)=>{var n=Cl(e),r=Xm(e,t),a=Xg(e,t);if(null!=r&&null!=a)return"horizontal"===n?A2(e,"xAxis",r):A2(e,"yAxis",a)}],(e,t,n)=>{var r=e.filter(C4),a=e.filter(e=>null==e.stackId);return[...Object.entries(r.reduce((e,t)=>{var n=e[t.stackId];return null==n&&(n=[]),n.push(t),e[t.stackId]=n,e},{})).map(e=>{var r,[a,i]=e;return{stackId:a,dataKeys:i.map(e=>e.dataKey),barSize:Qm(t,n,null==(r=i[0])?void 0:r.barSize)}}),...a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>null!=e),barSize:Qm(t,n,e.barSize)}))]}),Qj=(e,t,n)=>{var r,a,i=Cl(e),o=Xm(e,t),l=Xg(e,t);if(null!=o&&null!=l)return"horizontal"===i?(r=A7(e,"xAxis",o,n),a=A8(e,"xAxis",o,n)):(r=A7(e,"yAxis",l,n),a=A8(e,"yAxis",l,n)),kE(r,a)},Qk=jH([Qw,Ck,e=>e.rootProps.barGap,CS,(e,t,n)=>{var r,a,i,o,l=Qx(e,t);if(null==l)return 0;var s=Xm(e,t),c=Xg(e,t);if(null==s||null==c)return 0;var d=Cl(e),u=Ck(e),{maxBarSize:f}=l;return"horizontal"===d?(i=A7(e,"xAxis",s,n),o=A8(e,"xAxis",s,n)):(i=A7(e,"yAxis",c,n),o=A8(e,"yAxis",c,n)),null!=(r=null!=(a=kE(i,o,!0))?a:null==f?u:f)?r:0},Qj,Qy],(e,t,n,r,a,i,o)=>{var l=function(e,t,n,r,a){var i,o,l=r.length;if(!(l<1)){var s=ko(e,n,0,!0),c=[];if(kp(null==(i=r[0])?void 0:i.barSize)){var d=!1,u=n/l,f=r.reduce((e,t)=>e+(t.barSize||0),0);(f+=(l-1)*s)>=n&&(f-=(l-1)*s,s=0),f>=n&&u>0&&(d=!0,u*=.9,f=l*u);var h={offset:((n-f)/2|0)-s,size:0};o=r.reduce((e,t)=>{var n,r={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:h.offset+h.size+s,size:d?u:null!=(n=t.barSize)?n:0}},a=[...e,r];return h=r.position,a},c)}else{var p=ko(t,n,0,!0);n-2*p-(l-1)*s<=0&&(s=0);var m=(n-2*p-(l-1)*s)/l;m>1&&(m>>=0);var g=kp(a)?Math.min(m,a):m;o=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+s)*n+(m-g)/2,size:g}}],c)}return o}}(n,r,a!==i?a:i,e,null==o?t:o);return a!==i&&null!=l&&(l=l.map(e=>Qv(Qv({},e),{},{position:Qv(Qv({},e.position),{},{offset:e.position.offset-a/2})}))),l}),QS=jH([Qk,Qx],(e,t)=>{if(null!=e&&null!=t){var n=e.find(e=>e.stackId===t.stackId&&null!=t.dataKey&&e.dataKeys.includes(t.dataKey));if(null!=n)return n.position}}),QN=jH([(e,t,n)=>{var r=Cl(e),a=Xm(e,t),i=Xg(e,t);if(null!=a&&null!=i)return"horizontal"===r?P3(e,"yAxis",i,n):P3(e,"xAxis",a,n)},Qx],(e,t)=>{var n=C2(t);if(!e||null==n||null==t)return;var{stackId:r}=t;if(null!=r){var a=e[r];if(a){var{stackedData:i}=a;if(i)return i.find(e=>e.key===n)}}}),QC=jH([kB,kH,(e,t,n)=>{var r=Xm(e,t);if(null!=r)return A7(e,"xAxis",r,n)},(e,t,n)=>{var r=Xg(e,t);if(null!=r)return A7(e,"yAxis",r,n)},(e,t,n)=>{var r=Xm(e,t);if(null!=r)return A8(e,"xAxis",r,n)},(e,t,n)=>{var r=Xg(e,t);if(null!=r)return A8(e,"yAxis",r,n)},QS,Cl,jG,Qj,QN,Qx,(e,t,n,r)=>r],(e,t,n,r,a,i,o,l,s,c,d,u,f)=>{var h,{chartData:p,dataStartIndex:m,dataEndIndex:g}=s;if(null!=u&&null!=o&&null!=t&&("horizontal"===l||"vertical"===l)&&null!=n&&null!=r&&null!=a&&null!=i&&null!=c){var{data:v}=u;if(null!=(h=null!=v&&v.length>0?v:null==p?void 0:p.slice(m,g+1)))return function(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:a},pos:i,bandSize:o,xAxis:l,yAxis:s,xAxisTicks:c,yAxisTicks:d,stackedData:u,displayedData:f,offset:h,cells:p,parentViewBox:m,dataStartIndex:g}=e,v="horizontal"===t?s:l,x=u?v.scale.domain():null,y=(e=>{var{numericAxis:t}=e,n=t.scale.domain();if("number"===t.type){var r=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);return r<=0&&a>=0?0:a<0?a:r}return n[0]})({numericAxis:v}),b=v.scale.map(y);return f.map((e,f)=>{if(u){var v=u[f+g];if(null==v)return null;j=((e,t)=>{if(!t||2!==t.length||!kn(t[0])||!kn(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),a=[e[0],e[1]];return(!kn(e[0])||e[0]<n)&&(a[0]=n),(!kn(e[1])||e[1]>r)&&(a[1]=r),a[0]>r&&(a[0]=r),a[1]<n&&(a[1]=n),a})(v,x)}else Array.isArray(j=kx(e,n))||(j=[y,j]);var w=Qu(r,0)(j[1],f);if("horizontal"===t){var j,k,S,N,C,M,E,O=s.scale.map(j[0]),P=s.scale.map(j[1]);if(null==O||null==P)return null;k=kN({axis:l,ticks:c,bandSize:o,offset:i.offset,entry:e,index:f}),S=null!=(E=null!=P?P:O)?E:void 0,N=i.size;var A=O-P;if(C=ke(A)?0:A,M={x:k,y:h.top,width:N,height:h.height},Math.abs(w)>0&&Math.abs(C)<Math.abs(w)){var I=j9(C||w)*(Math.abs(w)-Math.abs(C));S-=I,C+=I}}else{var z=l.scale.map(j[0]),T=l.scale.map(j[1]);if(null==z||null==T)return null;if(k=z,S=kN({axis:s,ticks:d,bandSize:o,offset:i.offset,entry:e,index:f}),N=T-z,C=i.size,M={x:h.left,y:S,width:h.width,height:C},Math.abs(w)>0&&Math.abs(N)<Math.abs(w)){var D=j9(N||w)*(Math.abs(w)-Math.abs(N));N+=D}}return null!=k&&null!=S&&null!=N&&null!=C&&(a||0!==N&&0!==C)?QH(QH({},e),{},{stackedBarStart:b,x:k,y:S,width:N,height:C,value:u?j:j[1],payload:e,background:M,tooltipPosition:{x:k+N/2,y:S+C/2},parentViewBox:m,originalDataIndex:f},p&&p[f]&&p[f].props):null}).filter(Boolean)}({layout:l,barSettings:u,pos:o,parentViewBox:t,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,stackedData:d,displayedData:h,offset:e,cells:f,dataStartIndex:m})}}),QM=(e,t)=>t,QE=(e,t,n)=>n,QO=jH([QM,PT,QE],(e,t,n)=>t.filter(e=>"bar"===e.type).filter(t=>t.stackId===e).filter(e=>e.isPanorama===n).filter(e=>!e.hide)),QP=jH([QO],e=>e.map(e=>e.id)),QA=jH([e=>e,QM,QE],(e,t,n)=>{var r=QP(e,t,n),a=[];return r.forEach(t=>{var r=QC(e,t,n,void 0);null==r||r.forEach(e=>{var t=e.originalDataIndex;a[t]=((e,t)=>{if(!e)return t;if(!t)return e;var n=Math.min(e.x,e.x+e.width,t.x,t.x+t.width),r=Math.min(e.y,e.y+e.height,t.y,t.y+t.height);return{x:n,y:r,width:Math.max(e.x,e.x+e.width,t.x,t.x+t.width)-n,height:Math.max(e.y,e.y+e.height,t.y,t.y+t.height)-r}})(a[t],e)})}),a}),QI=["index"];function Qz(){return(Qz=Object.assign.bind()).apply(null,arguments)}var QT=(0,ew.createContext)(void 0),QD=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),Q_=e=>{var{index:t}=e,n=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,QI),r=(e=>{var t=(0,ew.useContext)(QT);if(null!=t){var{stackId:n}=t;return"url(#".concat(QD(n,e),")")}})(t);return ew.createElement(II,Qz({className:"recharts-bar-stack-layer",clipPath:r},n))},QR=["onMouseEnter","onMouseLeave","onClick"],QL=["value","background","tooltipPosition"],Q$=["id"],QF=["onMouseEnter","onClick","onMouseLeave"];function QB(){return(QB=Object.assign.bind()).apply(null,arguments)}function QV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QH(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QV(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function QU(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var QW=Qs.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:a,name:i,hide:o,unit:l,tooltipType:s,id:c}=e,d={dataDefinedOnItem:void 0,getPosition:kf,settings:{stroke:n,strokeWidth:r,fill:a,dataKey:t,nameKey:void 0,name:kP(i,t),hide:o,type:s,color:a,unit:l,graphicalItemId:c}};return Qs.createElement(D1,{tooltipEntrySettings:d})});function Qq(e){var t,n=kZ(_X),{data:r,dataKey:a,background:i,allOtherBarProps:o}=e,{onMouseEnter:l,onMouseLeave:s,onClick:c}=o,d=QU(o,QR),u=DJ(l,a,o.id),f=DQ(s),h=D0(c,a,o.id);if(!i||null==r)return null;var p=IE(i);return Qs.createElement(RO,{zIndex:(t=C_.barBackground,i&&"object"==typeof i&&"zIndex"in i&&"number"==typeof i.zIndex&&kp(i.zIndex)?i.zIndex:t)},r.map((e,t)=>{var{value:r,background:o,tooltipPosition:l}=e,s=QU(e,QL);if(!o)return null;var c=u(e,t),m=f(e,t),g=h(e,t),v=QH(QH(QH(QH(QH({option:i,isActive:String(t)===n},s),{},{fill:"#eee"},o),p),I9(d,e,t)),{},{onMouseEnter:c,onMouseLeave:m,onClick:g,dataKey:a,index:t,className:"recharts-bar-background-rectangle"});return Qs.createElement(Qd,QB({key:"background-bar-".concat(t)},v))}))}function QK(e){var{showLabels:t,children:n,rects:r}=e,a=null==r?void 0:r.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return QH(QH({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return Qs.createElement(RQ,{value:t?a:void 0},n)}function QG(e){var t,{shape:n,activeBar:r,baseProps:a,entry:i,index:o,dataKey:l}=e,s=kZ(_X),c=kZ(_Z),d=r&&String(i.originalDataIndex)===s&&(null==c||l===c),[u,f]=(0,Qs.useState)(!1),[h,p]=(0,Qs.useState)(!1);(0,Qs.useEffect)(()=>{var e;return d?(f(!0),e=requestAnimationFrame(()=>{p(!0)})):p(!1),()=>{cancelAnimationFrame(e)}},[d]);var m=(0,Qs.useCallback)(()=>{d||f(!1)},[d]),g=d&&h,v=d||u;t=d?!0===r?n:r:n;var x=Qs.createElement(Qd,QB({},a,{name:String(a.name)},i,{isActive:g,option:t,index:o,dataKey:l,onTransitionEnd:m}));return v?Qs.createElement(RO,{zIndex:C_.activeBar},Qs.createElement(Q_,{index:i.originalDataIndex},x)):x}function QX(e){var{shape:t,baseProps:n,entry:r,index:a,dataKey:i}=e;return Qs.createElement(Qd,QB({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:a,dataKey:i}))}function QY(e){var t,{data:n,props:r}=e,a=null!=(t=IM(r))?t:{},{id:i}=a,o=QU(a,Q$),{shape:l,dataKey:s,activeBar:c}=r,{onMouseEnter:d,onClick:u,onMouseLeave:f}=r,h=QU(r,QF),p=DJ(d,s,i),m=DQ(f),g=D0(u,s,i);return n?Qs.createElement(Qs.Fragment,null,n.map((e,t)=>Qs.createElement(Q_,QB({index:e.originalDataIndex,key:"rectangle-".concat(null==e?void 0:e.x,"-").concat(null==e?void 0:e.y,"-").concat(null==e?void 0:e.value,"-").concat(t),className:"recharts-bar-rectangle"},I9(h,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:g(e,t)}),c?Qs.createElement(QG,{shape:l,activeBar:c,baseProps:o,entry:e,index:t,dataKey:s}):Qs.createElement(QX,{shape:l,baseProps:o,entry:e,index:t,dataKey:s})))):null}function QZ(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:s,onAnimationEnd:c,onAnimationStart:d}=t,u=n.current,f=Td(t,"recharts-bar-"),[h,p]=(0,Qs.useState)(!1),m=(0,Qs.useCallback)(()=>{"function"==typeof c&&c(),p(!1)},[c]),g=(0,Qs.useCallback)(()=>{"function"==typeof d&&d(),p(!0)},[d]);return Qs.createElement(QK,{showLabels:!h,rects:r},Qs.createElement(Tc,{animationId:f,begin:o,duration:l,isActive:i,easing:s,onAnimationEnd:m,onAnimationStart:g,key:f},e=>{var i=1===e?r:null==r?void 0:r.map((t,n)=>{var r=u&&u[n];if(r)return QH(QH({},t),{},{x:ks(r.x,t.x,e),y:ks(r.y,t.y,e),width:ks(r.width,t.width,e),height:ks(r.height,t.height,e)});if("horizontal"===a){var i=ks(0,t.height,e),o=ks(t.stackedBarStart,t.y,e);return QH(QH({},t),{},{y:o,height:i})}var l=ks(0,t.width,e),s=ks(t.stackedBarStart,t.x,e);return QH(QH({},t),{},{width:l,x:s})});return(e>0&&(n.current=null!=i?i:null),null==i)?null:Qs.createElement(II,null,Qs.createElement(QY,{props:t,data:i}))}),Qs.createElement(R5,{label:t.label}),t.children)}function QJ(e){var t=(0,Qs.useRef)(null);return Qs.createElement(QZ,{previousRectanglesRef:t,props:e})}var QQ=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:kx(e,t)}};class Q0 extends Qs.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:a,yAxisId:i,needClip:o,background:l,id:s}=this.props;if(e||null==t)return null;var c=(0,jN.clsx)("recharts-bar",r);return Qs.createElement(II,{className:c,id:s},o&&Qs.createElement("defs",null,Qs.createElement(Xp,{clipPathId:s,xAxisId:a,yAxisId:i})),Qs.createElement(II,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(s,")"):void 0},Qs.createElement(Qq,{data:t,dataKey:n,background:l,allOtherBarProps:this.props}),Qs.createElement(QJ,this.props)))}}var Q1={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,xAxisId:0,yAxisId:0,zIndex:C_.bar};function Q2(e){var t,{xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u}=e,{needClip:f}=Xh(n,r),h=kZ(Cl),p=Nq(),m=zX(e.children,zH),g=kZ(t=>QC(t,e.id,p,m));if("vertical"!==h&&"horizontal"!==h)return null;var v=null==g?void 0:g[0];return t=null==v||null==v.height||null==v.width?0:"vertical"===h?v.height/2:v.width/2,Qs.createElement(Qp,{xAxisId:n,yAxisId:r,data:g,dataPointFormatter:QQ,errorBarOffset:t},Qs.createElement(Q0,QB({},e,{layout:h,needClip:f,data:g,xAxisId:n,yAxisId:r,hide:a,legendType:i,minPointSize:o,activeBar:l,animationBegin:s,animationDuration:c,animationEasing:d,isAnimationActive:u})))}Qs.memo(function(e){var t,n,r=zE(e,Q1),a=(t=r.stackId,null!=(n=(0,ew.useContext)(QT))?n.stackId:null!=t?kk(t):void 0),i=Nq();return Qs.createElement(Ro,{id:r.id,type:"bar"},e=>Qs.createElement(Qs.Fragment,null,Qs.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,fill:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kP(n,t),payload:e}]})(r)}),Qs.createElement(QW,{dataKey:r.dataKey,stroke:r.stroke,strokeWidth:r.strokeWidth,fill:r.fill,name:r.name,hide:r.hide,unit:r.unit,tooltipType:r.tooltipType,id:e}),Qs.createElement(Rm,{type:"bar",id:e,data:void 0,xAxisId:r.xAxisId,yAxisId:r.yAxisId,zAxisId:0,dataKey:r.dataKey,stackId:a,hide:r.hide,barSize:r.barSize,minPointSize:r.minPointSize,maxBarSize:r.maxBarSize,isPanorama:i,hasCustomShape:null!=r.shape}),Qs.createElement(RO,{zIndex:r.zIndex},Qs.createElement(Q2,QB({},r,{id:e})))))},Fl).displayName="Bar";let Q5=(0,ek.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);function Q4({className:e,orientation:t="horizontal",...n}){return(0,ey.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,eI.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}function Q3({label:e,description:t,value:n}){return(0,ey.jsxs)("div",{className:"relative h-full min-h-0",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("div",{className:"text-xl font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:t})]}),(0,ey.jsx)(J6,{value:J8(n),minSize:48,maxSize:220,className:"absolute right-0 bottom-0 h-2/3 w-full"})]})}(0,ek.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);var Q6=ew,Q8=(e,t,n,r)=>A7(e,"xAxis",t,r),Q7=(e,t,n,r)=>A8(e,"xAxis",t,r),Q9=(e,t,n,r)=>A7(e,"yAxis",n,r),eee=(e,t,n,r)=>A8(e,"yAxis",n,r),eet=jH([Cl,Q8,Q9,Q7,eee],(e,t,n,r,a)=>ky(e,"xAxis")?kE(t,r,!1):kE(n,a,!1));function een(e){return"line"===e.type}var eer=jH([PT,(e,t,n,r,a)=>a],(e,t)=>e.filter(een).find(e=>e.id===t)),eea=jH([Cl,Q8,Q9,Q7,eee,eer,eet,jK],(e,t,n,r,a,i,o,l)=>{var s,{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(null!=i&&null!=t&&null!=n&&null!=r&&null!=a&&0!==r.length&&0!==a.length&&null!=o&&("horizontal"===e||"vertical"===e)){var{dataKey:f,data:h}=i;if(null!=(s=null!=h&&h.length>0?h:null==c?void 0:c.slice(d,u+1)))return function(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:s}=e;return s.map((e,s)=>{var c=kx(e,o);if("horizontal"===t){var d=kS({axis:n,ticks:a,bandSize:l,entry:e,index:s}),u=null==c?null:r.scale.map(c);return{x:d,y:null!=u?u:null,value:c,payload:e}}var f=null==c?null:n.scale.map(c),h=kS({axis:r,ticks:i,bandSize:l,entry:e,index:s});return null==f||null==h?null:{x:f,y:h,value:c,payload:e}}).filter(Boolean)}({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:a,dataKey:f,bandSize:o,displayedData:s})}}),eei=["id"],eeo=["type","layout","connectNulls","needClip","shape"],eel=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function ees(){return(ees=Object.assign.bind()).apply(null,arguments)}function eec(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eed(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?eec(Object(n),!0).forEach(function(t){var r,a,i;r=e,a=t,i=n[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in r?Object.defineProperty(r,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[a]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eec(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eeu(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var eef=Q6.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:a,fill:i,name:o,hide:l,unit:s,tooltipType:c,id:d}=e,u={dataDefinedOnItem:n,getPosition:kf,settings:{stroke:r,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:kP(o,t),hide:l,type:c,color:r,unit:s,graphicalItemId:d}};return Q6.createElement(D1,{tooltipEntrySettings:u})}),eeh=(e,t)=>"".concat(t,"px ").concat(e,"px");function eep(e){var{clipPathId:t,points:n,props:r}=e,{dot:a,dataKey:i,needClip:o}=r,{id:l}=r,s=IM(eeu(r,eei));return Q6.createElement(Xs,{points:n,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:s,needClip:o,clipPathId:t})}function eem(e){var{showLabels:t,children:n,points:r}=e,a=(0,Q6.useMemo)(()=>null==r?void 0:r.map(e=>{var t,n,r={x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:0,lowerWidth:0,upperWidth:0,height:0};return eed(eed({},r),{},{value:e.value,payload:e.payload,viewBox:r,parentViewBox:void 0,fill:void 0})}),[r]);return Q6.createElement(RQ,{value:t?a:void 0},n)}function eeg(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:s,needClip:c,shape:d}=i,u=eed(eed({},IO(eeu(i,eeo))),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(t,")"):void 0,points:r,type:o,layout:l,connectNulls:s,strokeDasharray:null!=a?a:i.strokeDasharray});return Q6.createElement(Q6.Fragment,null,(null==r?void 0:r.length)>1&&Q6.createElement(T6,ees({shapeType:"curve",option:d},u,{pathRef:n})),Q6.createElement(eep,{points:r,clipPathId:t,props:i}))}function eev(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:s,animationBegin:c,animationDuration:d,animationEasing:u,animateNewValues:f,width:h,height:p,onAnimationEnd:m,onAnimationStart:g}=n,v=a.current,x=Td(o,"recharts-line-"),y=(0,Q6.useRef)(x),[b,w]=(0,Q6.useState)(!1),j=(0,Q6.useCallback)(()=>{"function"==typeof m&&m(),w(!1)},[m]),k=(0,Q6.useCallback)(()=>{"function"==typeof g&&g(),w(!0)},[g]),S=function(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch(e){return 0}}(r.current),N=(0,Q6.useRef)(0);y.current!==x&&(N.current=i.current,y.current=x);var C=N.current;return Q6.createElement(eem,{points:o,showLabels:!b},n.children,Q6.createElement(Tc,{animationId:x,begin:c,duration:d,isActive:s,easing:u,onAnimationEnd:j,onAnimationStart:k,key:x},e=>{var c,d=Math.min(ks(C,S+C,e),S);if(c=s?l?((e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return eeh(t,e);for(var a=Math.floor(e/r),i=e%r,o=[],l=0,s=0;l<n.length;s+=null!=(c=n[l])?c:0,++l){var c,d=n[l];if(null!=d&&s+d>i){o=[...n.slice(0,l),i-s];break}}var u=o.length%2==0?[0,t]:[t];return[...function(e,t){for(var n=e.length%2!=0?[...e,0]:e,r=[],a=0;a<t;++a)r.push(...n);return r}(n,a),...o,...u].map(e=>"".concat(e,"px")).join(", ")})(d,S,"".concat(l).split(/[,\s]+/gim).map(e=>parseFloat(e))):eeh(S,d):null==l?void 0:String(l),e>0&&S>0&&(a.current=o,i.current=Math.max(i.current,d)),v){var u=v.length/o.length,m=1===e?o:o.map((t,n)=>{var r=Math.floor(n*u);if(v[r]){var a=v[r];return eed(eed({},t),{},{x:ks(a.x,t.x,e),y:ks(a.y,t.y,e)})}return f?eed(eed({},t),{},{x:ks(2*h,t.x,e),y:ks(p/2,t.y,e)}):eed(eed({},t),{},{x:t.x,y:t.y})});return a.current=m,Q6.createElement(eeg,{props:n,points:m,clipPathId:t,pathRef:r,strokeDasharray:c})}return Q6.createElement(eeg,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:c})}),Q6.createElement(R5,{label:n.label}))}function eex(e){var{clipPathId:t,props:n}=e,r=(0,Q6.useRef)(null),a=(0,Q6.useRef)(0),i=(0,Q6.useRef)(null);return Q6.createElement(eev,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:a,pathRef:i})}var eey=(e,t)=>{var n,r;return{x:null!=(n=e.x)?n:void 0,y:null!=(r=e.y)?r:void 0,value:e.value,errorVal:kx(e.payload,t)}};class eeb extends Q6.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:a,yAxisId:i,top:o,left:l,width:s,height:c,id:d,needClip:u,zIndex:f}=this.props;if(e)return null;var h=(0,jN.clsx)("recharts-line",r),{r:p,strokeWidth:m}=XC(t),g=zY(t),v=2*p+m,x=u?"url(#clipPath-".concat(g?"":"dots-").concat(d,")"):void 0;return Q6.createElement(RO,{zIndex:f},Q6.createElement(II,{className:h},u&&Q6.createElement("defs",null,Q6.createElement(Xp,{clipPathId:d,xAxisId:a,yAxisId:i}),!g&&Q6.createElement("clipPath",{id:"clipPath-dots-".concat(d)},Q6.createElement("rect",{x:l-v/2,y:o-v/2,width:s+v,height:c+v}))),Q6.createElement(Qp,{xAxisId:a,yAxisId:i,data:n,dataPointFormatter:eey,errorBarOffset:0},Q6.createElement(eex,{props:this.props,clipPathId:d}))),Q6.createElement(Xf,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}}var eew={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:C_.line,type:"linear"};function eej(e){var t=zE(e,eew),{activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:s,hide:c,isAnimationActive:d,label:u,legendType:f,xAxisId:h,yAxisId:p,id:m}=t,g=eeu(t,eel),{needClip:v}=Xh(h,p),x=kZ(FH),y=kZ(Cl),b=Nq(),w=kZ(e=>eea(e,h,p,b,m));if("horizontal"!==y&&"vertical"!==y||null==w||null==x)return null;var{height:j,width:k,x:S,y:N}=x;return Q6.createElement(eeb,ees({},g,{id:m,connectNulls:l,dot:s,activeDot:n,animateNewValues:r,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:d,hide:c,label:u,legendType:f,xAxisId:h,yAxisId:p,points:w,layout:y,height:j,width:k,left:S,top:N,needClip:v}))}var eek=Q6.memo(function(e){var t=zE(e,eew),n=Nq();return Q6.createElement(Ro,{id:t.id,type:"line"},e=>Q6.createElement(Q6.Fragment,null,Q6.createElement(Rn,{legendPayload:(e=>{var{dataKey:t,name:n,stroke:r,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:r,value:kP(n,t),payload:e}]})(t)}),Q6.createElement(eef,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),Q6.createElement(Rm,{type:"line",id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),Q6.createElement(eej,ees({},t,{id:e}))))},Fl);eek.displayName="Line";var eeS=["axis"],eeN=(0,ew.forwardRef)((e,t)=>ew.createElement(XY,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:eeS,tooltipPayloadSearcher:Lh,categoricalChartProps:e,ref:t}));let eeC={online:"bg-foreground",warning:"bg-muted-foreground",offline:"bg-destructive"},eeM={direct:"stroke-foreground",p2p:"stroke-foreground",relay:"stroke-muted-foreground",down:"stroke-destructive"},eeE={topologyNode:function({data:e}){return(0,ey.jsxs)("div",{className:"vtl-surface-card min-w-36 rounded-[var(--surface-card-radius)] border px-3 py-2",children:[(0,ey.jsx)(ox,{type:"target",position:_.Top,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:_.Bottom,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"target",position:_.Left,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsx)(ox,{type:"source",position:_.Right,className:"!size-0 !border-0 !bg-transparent"}),(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:(0,eI.cn)("size-2.5 shrink-0 rounded-full",eeC[e.state])}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:e.label})]}),e.meta?(0,ey.jsx)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:e.meta}):null]})}},eeO={topologyEdge:function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:a,sourcePosition:i,targetPosition:o,data:l}){let[s]=aE({sourcePosition:i,sourceX:t,sourceY:n,targetPosition:o,targetX:r,targetY:a}),{x:c,y:d}=function(e){if("u"<typeof document)return{x:0,y:0};let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",e);let n=t.getTotalLength(),r=t.getPointAtLength(n/2);return{x:r.x,y:r.y}}(s),u=l?.kind??"direct";return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(oL,{id:e,path:s,className:(0,eI.cn)("fill-none",eeM[u],"p2p"===u&&"stroke-dasharray-[8_6]","relay"===u&&"stroke-dasharray-[12_8]"),style:{strokeWidth:"down"===u?3:2.4,strokeLinecap:"round",strokeLinejoin:"round"}}),(l?.label||l?.meta)&&(0,ey.jsx)("foreignObject",{x:c-48,y:d-20,width:96,height:40,className:"overflow-visible",requiredExtensions:"http://www.w3.org/1999/xhtml",children:(0,ey.jsxs)("div",{className:"pointer-events-none grid h-10 w-24 content-center rounded-md border bg-background/95 px-2 py-1 text-center shadow-sm",children:[l.label?(0,ey.jsx)("div",{className:"truncate text-xs font-medium leading-4",children:l.label}):null,l.meta?(0,ey.jsx)("div",{className:"truncate ui-text-kbd text-muted-foreground",children:l.meta}):null]})})]})}};function eeP({nodes:e,links:t,className:n,...r}){let a=ew.useMemo(()=>e.map(e=>({id:e.id,data:{label:e.label,meta:e.meta,state:e.state??"online"},position:{x:e.x/100*1e3,y:e.y/100*560},type:"topologyNode"})),[e]),i=ew.useMemo(()=>t.map(e=>({id:e.id,data:{kind:e.kind??"direct",label:e.label,meta:e.meta},source:e.from,target:e.to,type:"topologyEdge"})),[t]);return(0,ey.jsx)("div",{"data-slot":"topology-map",className:(0,eI.cn)("h-full min-h-0 overflow-hidden rounded-xl bg-muted/25",n),...r,children:(0,ey.jsx)(lh,{children:(0,ey.jsx)(lg,{nodes:a,edges:i,nodeTypes:eeE,edgeTypes:eeO,fitView:!0,fitViewOptions:{maxZoom:1.15,minZoom:.45,padding:.22},minZoom:.35,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},className:"topology-flow text-foreground",children:(0,ey.jsx)(lS,{gap:28,size:1,color:"var(--border)",className:"opacity-80"})})})})}function eeA({nodes:e,links:t}){return(0,ey.jsx)(eeP,{nodes:e,links:t})}function eeI({title:e,count:t}){return(0,ey.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between",children:[(0,ey.jsx)("h2",{className:"text-sm font-semibold tracking-normal",children:e}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:t})]})}function eez({items:e}){return(0,ey.jsx)("div",{className:"mt-2 grid",children:e.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("px-2 py-2",t>0&&"border-t"),children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-1 truncate ui-text-kbd text-muted-foreground","warning"===e.tone&&"text-destructive"),children:e.meta})]},e.id))})}function eeT({items:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r])=>({id:`${e}-${n}`,status:"完成"===r?"done":"运行中"===r?"current":"失败"===r?"blocked":"queued",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_8rem_minmax(0,1fr)_4rem] items-center gap-3",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:t}),(0,ey.jsx)("span",{className:"truncate",children:n}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:r})]})})),[e]);return(0,ey.jsx)(JE,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eeD({items:e}){let t=ew.useMemo(()=>e.map(e=>{var t;return{id:e.id,status:"running"===(t=e.state)?"current":"blocked"===t||"failed"===t?"blocked":"queued",title:(0,ey.jsx)(ee_,{item:e})}}),[e]);return(0,ey.jsx)(JE,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function ee_({item:e}){return(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_7.5rem_5rem] items-center gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.machine," · ",e.agent," · ",e.started]})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Qe,{value:e.progress,className:"h-1.5"}),(0,ey.jsx)("div",{className:"ui-text-kbd text-muted-foreground",children:e.runtime})]}),(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsx)(Qe,{value:e.load,className:"h-1.5"}),(0,ey.jsx)("div",{className:"text-right ui-text-kbd text-muted-foreground",children:"load"})]})]})}function eeR({workers:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(eeL,{worker:e,divided:t>0},e.id))})}function eeL({worker:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-24 grid-cols-[minmax(0,1fr)_2.5rem_auto] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-lg font-semibold tracking-normal",children:e.machine}),(0,ey.jsx)("div",{className:"mt-0.5 truncate ui-text-kbd text-muted-foreground",children:e.role})]}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.active,"/",e.capacity]}),(0,ey.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,ey.jsx)(ee$,{label:"CPU",value:e.cpu}),(0,ey.jsx)(ee$,{label:"MEM",value:e.memory})]})]})}function ee$({label:e,value:t}){return(0,ey.jsxs)("div",{className:"grid justify-items-center gap-1",children:[(0,ey.jsx)(Qt,{value:t,label:e,className:"size-16 [&_[data-slot=progress-ring-center]]:size-10 [&_[data-slot=progress-ring-center]]:bg-background [&_[data-slot=progress-ring-center]_span]:text-xs"}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e})]})}function eeF({events:e}){let t=ew.useMemo(()=>e.map(([e,t],n)=>({id:`${e}-${t}`,status:0===n?"current":"done",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[3.25rem_minmax(0,1fr)] items-center gap-2",children:[(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"truncate",children:t})]})})),[e]);return(0,ey.jsx)(JE,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-1.5"})}function eeB({machines:e}){return(0,ey.jsx)("div",{className:"mt-2 grid min-h-0 flex-1 content-start overflow-hidden",children:e.map((e,t)=>(0,ey.jsx)(eeV,{machine:e,divided:t>0},e.id))})}function eeV({machine:e,divided:t}){return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-20 grid-cols-[minmax(0,1fr)_minmax(0,1.45fr)] items-center gap-4 px-2 py-2",t&&"border-t"),children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eeU,{status:e.status}),(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.name})]}),(0,ey.jsxs)("div",{className:"mt-1 truncate ui-text-kbd text-muted-foreground",children:[e.os," · ",e.link," · heartbeat ",e.heartbeat]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 sm:grid-cols-4",children:[(0,ey.jsx)(eeH,{icon:(0,ey.jsx)(ux,{}),label:"CPU",value:e.cpu}),(0,ey.jsx)(eeH,{icon:(0,ey.jsx)(Qo,{}),label:"MEM",value:e.memory}),(0,ey.jsx)(eeH,{icon:(0,ey.jsx)(uy,{}),label:"DISK",value:e.disk}),(0,ey.jsx)(eeH,{icon:(0,ey.jsx)(Ql,{}),label:"NET",value:e.network})]})]})}function eeH({icon:e,label:t,value:n}){return(0,ey.jsxs)("div",{className:"grid gap-1",children:[(0,ey.jsxs)("div",{className:"flex justify-between gap-1 ui-text-kbd text-muted-foreground",children:[(0,ey.jsxs)("span",{className:"flex items-center gap-1 [&_svg]:size-3",children:[e,t]}),(0,ey.jsxs)("span",{children:[n,"%"]})]}),(0,ey.jsx)(Qe,{value:n,className:"h-1.5"})]})}function eeU({status:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-2 rounded-full bg-border","online"===e&&"bg-primary")})}function eeW({links:e}){let t=ew.useMemo(()=>e.map(([e,t,n,r,a])=>({id:`${e}-${t}`,status:"Relay fallback"===n?"blocked":"current",title:(0,ey.jsxs)("div",{className:"grid w-full grid-cols-[minmax(0,1fr)_5rem_4rem_3.5rem] items-center gap-3",children:[(0,ey.jsxs)("span",{className:"truncate",children:[e," / ",t]}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n}),(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:r}),(0,ey.jsx)("span",{className:"text-right ui-text-kbd text-muted-foreground",children:a})]})})),[e]);return(0,ey.jsx)(JE,{items:t,scrollCurrentIntoView:!1,extendLineToViewport:!0,className:"mt-2 min-h-0 flex-1",viewportClassName:"h-full max-h-none overflow-y-auto pr-0",itemClassName:"py-2"})}function eeq({config:e,data:t}){return(0,ey.jsx)(BZ,{config:e,className:"mt-2 min-h-0 flex-1",children:(0,ey.jsxs)(XJ,{data:t,margin:{left:8,right:8},children:[(0,ey.jsx)(Yk,{vertical:!1}),(0,ey.jsx)(Y$,{dataKey:"time",tickLine:!1,axisLine:!1,tickMargin:8}),(0,ey.jsx)(BA,{content:(0,ey.jsx)(BQ,{indicator:"line"})}),(0,ey.jsx)(Xq,{dataKey:"cpu",type:"monotone",fill:"var(--color-cpu)",fillOpacity:.11,stroke:"var(--color-cpu)",strokeWidth:2}),(0,ey.jsx)(Xq,{dataKey:"memory",type:"monotone",fill:"var(--color-memory)",fillOpacity:.1,stroke:"var(--color-memory)",strokeWidth:2}),(0,ey.jsx)(Xq,{dataKey:"network",type:"monotone",fill:"var(--color-network)",fillOpacity:.08,stroke:"var(--color-network)",strokeWidth:2})]})})}function eeK({services:e}){let[t,n]=GR(),r=Math.max(1,Math.floor((Math.max(0,n.width-192-64-32)+5)/12)),a=Math.max(48,n.height>0?Math.floor((n.height-0*Math.max(0,e.length-1))/e.length):48),i=Math.max(28,a-22);return(0,ey.jsx)("div",{ref:t,className:"mt-2 min-h-0 flex-1",children:e.map((e,t)=>(0,ey.jsx)(eeG,{service:e,divided:t>0,rowHeight:a,sampleCount:r,sampleHeight:i},e.id))})}function eeG({service:e,divided:t,rowHeight:n,sampleCount:r,sampleHeight:a}){let i=ew.useMemo(()=>{var t,n;return t=e.samples,n=r,t.length>=n?t.slice(t.length-n):Array.from({length:n},(e,n)=>{let r=n%t.length;return t[r]??0})},[r,e.samples]);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid grid-cols-[12rem_minmax(0,1fr)_4rem] items-center gap-4 px-2",t&&"border-t"),style:{height:n},children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("div",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("div",{className:(0,eI.cn)("mt-0.5 truncate ui-text-kbd text-muted-foreground","告警"===e.state&&"text-destructive"),children:e.state})]}),(0,ey.jsx)("div",{"aria-label":`${e.name} 30 minute stability samples`,className:"flex min-w-0 items-center overflow-hidden",style:{gap:5},children:i.map((t,n)=>{var r;return(0,ey.jsx)("span",{className:(0,eI.cn)("shrink-0 rounded-[2px]",(r=t)<60?"bg-destructive":r<72?"bg-destructive/55":r<84?"bg-primary/35":r<92?"bg-primary/60":"bg-primary"),style:{width:7,height:a},title:`${t}%`},`${e.id}-${n}`)})}),(0,ey.jsxs)("div",{className:"text-right text-sm font-medium tabular-nums",children:[e.samples.at(-1),"%"]})]})}let eeX=[{id:"canvas-vantaloom-base",title:"Vantaloom 基座设计",status:"live",purpose:"承载多标签系统、文件树、终端和 Agent 会话节点。",nodes:18,agents:3,progress:64,health:91,runtime:"3h 12m",tokenUsage:62e4,lastOpened:"刚刚",snapshots:14,unsavedChanges:3,roadmap:[{title:"接入节点模板选择",state:"done"},{title:"处理节点吸附与连线遮挡",state:"done"},{title:"合并多标签页拖拽",state:"running"},{title:"沉淀真实项目模板",state:"queued"}],settings:{nodeTemplates:["多标签页系统","文件管理树","终端标签组","Agent 对话"],defaultLayout:["默认缩放 0.72","节点内容 2x","定位点 24px"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],sharing:["工作组管理员可编辑","成员可审阅","访客不可访问"],autosave:["每 45 秒保存","节点拖拽结束保存","切换工作区保存"],snapshots:["保留最近 30 个","发布前创建检查点"],hosts:["Studio-PC","Linux-runner-02"],plugins:["Browser","Git checkpoint"]}},{id:"canvas-agent-lab",title:"Agent 编排实验",status:"live",purpose:"验证多 Agent 对话、工具窗口和剪切板在画布中的协同。",nodes:11,agents:4,progress:41,health:78,runtime:"1h 36m",tokenUsage:308e3,lastOpened:"8 分钟前",snapshots:9,unsavedChanges:1,roadmap:[{title:"四分工作区布局",state:"done"},{title:"面板替换进剪切板",state:"done"},{title:"会话浏览页",state:"running"},{title:"会话节点化",state:"queued"}],settings:{nodeTemplates:["Agent 对话","数据表标签","浏览器标签"],defaultLayout:["默认双栏","右侧可调整","剪切板常驻"],folders:["D:/Projects/Vantaloom-ui/apps/vantaloom"],sharing:["仅本机管理员可编辑"],autosave:["每 60 秒保存"],snapshots:["保留最近 12 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-release-map",title:"发布路线图",status:"review",purpose:"梳理组件库、主应用和文档的发布前检查。",nodes:9,agents:1,progress:83,health:86,runtime:"42m",tokenUsage:144e3,lastOpened:"今天 15:02",snapshots:7,unsavedChanges:0,roadmap:[{title:"组件清单",state:"done"},{title:"风险列表",state:"done"},{title:"最终检查",state:"running"}],settings:{nodeTemplates:["Diff 标签","数据表标签","文件预览标签"],defaultLayout:["审阅模式默认开启"],folders:["D:/Projects/Vantaloom-ui/docs"],sharing:["工作组可审阅"],autosave:["手动保存"],snapshots:["里程碑保留"],hosts:["Studio-PC"],plugins:[]}},{id:"canvas-browser-matrix",title:"浏览器预览矩阵",status:"idle",purpose:"检查不同 UA、比例和内嵌预览模式的表现。",nodes:6,agents:0,progress:100,health:94,runtime:"28m",tokenUsage:78e3,lastOpened:"昨天 18:44",snapshots:5,unsavedChanges:0,roadmap:[{title:"自适应模式",state:"done"},{title:"长宽比菜单",state:"done"},{title:"导航按钮",state:"done"}],settings:{nodeTemplates:["浏览器标签","多标签页系统"],defaultLayout:["自适应预览"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:["Browser"]}},{id:"canvas-ops-topology",title:"工作组拓扑",status:"idle",purpose:"记录机器、服务和工作组连接关系。",nodes:15,agents:0,progress:100,health:89,runtime:"1h 04m",tokenUsage:92e3,lastOpened:"周四 11:30",snapshots:11,unsavedChanges:0,roadmap:[{title:"机器节点整理",state:"done"},{title:"连接策略标注",state:"done"},{title:"访问权限检查",state:"done"}],settings:{nodeTemplates:["数据表标签","浏览器标签","终端标签组"],defaultLayout:["视口吸附开启","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui/ops"],sharing:["管理员可编辑","成员可查看"],autosave:["每 2 分钟保存"],snapshots:["每日保留"],hosts:["Studio-PC","Linux-runner-02","MacBook-build"],plugins:[]}}];function eeY(e,t,n,r,a,i,o){return{id:e,title:t,status:"idle",purpose:n,nodes:r,agents:0,progress:100,health:90,runtime:a,tokenUsage:i,lastOpened:o,snapshots:Math.max(3,Math.round(r/2)),unsavedChanges:0,roadmap:[{title:"整理节点结构",state:"done"},{title:"检查连接关系",state:"done"},{title:"保存最终快照",state:"done"}],settings:{nodeTemplates:["多标签页系统","文件预览标签"],defaultLayout:["默认缩放 0.72","节点吸附开启"],folders:["D:/Projects/Vantaloom-ui"],sharing:["仅自己"],autosave:["关闭"],snapshots:["保留最近 5 个"],hosts:["Studio-PC"],plugins:[]}}}eeX.push(eeY("canvas-terminal-layout","终端工作台草图","记录终端标签组、日志表和命令区的组合方式。",7,"36m",84e3,"昨天 15:21"),eeY("canvas-file-review","文件审阅流程","沉淀文件树、diff 预览和文件标签之间的拖拽关系。",12,"58m",126e3,"周五 20:10"),eeY("canvas-settings-ia","设置导航结构","整理设置菜单面板的主菜单、子菜单和搜索入口。",8,"24m",61e3,"周五 16:42"),eeY("canvas-auth-access","本机账户接入","记录本机用户、工作组加入和可用机器列表关系。",10,"47m",112e3,"周四 22:05"),eeY("canvas-data-ops","运维数据面板","对齐数据表标签、机器状态卡片和运行记录列表。",14,"1h 18m",172e3,"周三 19:48"));let eeZ=eeX.filter(e=>"idle"!==e.status),eeJ=eeX.filter(e=>"idle"===e.status);function eeQ(e,t,n=""){return{title:e,dataSource:t,refreshRate:"30s",note:n}}function ee0(e,t){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5","vtl-jelly-image-card vtl-jelly-image-card-shadowless"),style:Jz({image:t,opacity:.88,blur:"0px"}),children:e})}let ee1=[{id:"metric-active",kind:"metric-active",x:0,y:0,w:3,h:3},{id:"metric-nodes",kind:"metric-nodes",x:3,y:0,w:3,h:3},{id:"metric-unsaved",kind:"metric-unsaved",x:6,y:0,w:3,h:3},{id:"metric-snapshots",kind:"metric-snapshots",x:9,y:0,w:3,h:3},{id:"active",kind:"active",x:0,y:3,w:12,h:3},{id:"recent",kind:"recent",x:0,y:6,w:12,h:Math.max(3,Math.ceil(.75*eeJ.length)+1)}];function ee2({open:e,title:t,description:n,eyebrow:r,panels:a,defaultPanelId:i="overview",onOpenChange:o}){let l=sb(),[s,c]=ew.useState(i),d=a.find(e=>e.id===s)??a[0];return ew.useEffect(()=>{e&&c(i)},[i,e]),(0,ey.jsx)(dw,{open:e,onOpenChange:o,children:(0,ey.jsxs)(fu,{hideClose:!0,className:(0,eI.cn)("gap-0 overflow-hidden p-0",l?"inset-0 h-svh w-full max-w-none translate-x-0 translate-y-0 rounded-none border-0":"h-[min(44rem,calc(100svh-2rem))] max-w-5xl"),children:[(0,ey.jsx)(fh,{className:"sr-only",children:t}),(0,ey.jsxs)(fp,{className:"sr-only",children:[r?(0,ey.jsxs)(ey.Fragment,{children:[r,". "]}):null,n??t]}),l?(0,ey.jsxs)("div",{className:"flex h-full flex-col",children:[(0,ey.jsxs)("header",{className:"flex shrink-0 items-center gap-3 border-b px-4 py-3",children:[(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"关闭",onClick:()=>o(!1),children:(0,ey.jsx)(fc.XIcon,{className:"size-4"})}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[r?(0,ey.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:r}):null,(0,ey.jsx)("div",{className:"truncate text-sm font-semibold",children:t})]})]}),(0,ey.jsx)("nav",{className:"shrink-0 overflow-x-auto border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:(0,ey.jsx)("div",{className:"flex gap-1.5 px-4 py-2",children:a.map(e=>(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium transition-colors",d?.id===e.id?"bg-foreground text-background":"bg-muted text-muted-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e.icon}):null,(0,ey.jsx)("span",{children:e.label}),e.badge?(0,ey.jsx)(F3,{variant:"outline",className:"h-4 px-1 ui-text-kbd",children:e.badge}):null]},e.id))})}),(0,ey.jsx)(wb,{className:"min-h-0 flex-1",children:(0,ey.jsx)("div",{className:"p-4",children:d?.content})})]}):(0,ey.jsxs)("div",{className:"grid size-full min-h-0 grid-cols-[15rem_minmax(0,1fr)]",children:[(0,ey.jsx)("aside",{"data-slot":"resource-management-dialog-sidebar",className:"min-h-0 border-r bg-muted/20",children:(0,ey.jsx)(wb,{className:"h-full",children:(0,ey.jsx)("div",{className:"space-y-1 p-2",children:a.map(e=>(0,ey.jsxs)(eA.Button,{"data-slot":"resource-management-dialog-nav-item",type:"button",variant:"ghost",className:(0,eI.cn)("h-9 w-full justify-start px-2.5 text-left font-medium",d?.id===e.id?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),onClick:()=>c(e.id),children:[e.icon?(0,ey.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:e.icon}):null,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),e.badge?(0,ey.jsx)(F3,{variant:"outline",className:"h-5 px-1.5 ui-text-kbd",children:e.badge}):null]},e.id))})})}),(0,ey.jsx)(wb,{className:"min-h-0 bg-background",children:(0,ey.jsx)("div",{className:"p-5 pr-9",children:d?.content})})]})]})})}function ee5({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let[r,a]=ew.useState(),i=ew.useMemo(()=>(function({onSelect:e}){return[{id:"metric-active",title:"活跃画布",description:"当前正在编辑的画布数量。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeQ("活跃画布","画布列表"),render:e=>ee0((0,ey.jsx)(Q3,{label:e.title,description:"当前正在编辑的画布数量",value:String(eeZ.length)}),JO)},{id:"metric-nodes",title:"运行节点",description:"所有活跃画布内的节点。",icon:(0,ey.jsx)(Vl,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeQ("运行节点","画布节点"),render:e=>ee0((0,ey.jsx)(Q3,{label:e.title,description:"所有活跃画布内的节点",value:"38"}),JP)},{id:"metric-unsaved",title:"未保存",description:"等待写入的画布变更。",icon:(0,ey.jsx)(jw,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeQ("未保存","画布保存状态"),render:e=>ee0((0,ey.jsx)(Q3,{label:e.title,description:"等待写入的画布变更",value:"4"}),JA)},{id:"metric-snapshots",title:"快照",description:"可回退的历史存档。",icon:(0,ey.jsx)(KT,{className:"size-4"}),defaultSize:{w:3,h:3},defaultConfig:eeQ("快照","画布快照"),render:e=>ee0((0,ey.jsx)(Q3,{label:e.title,description:"可回退的历史存档",value:"46"}),JI)},{id:"active",title:"正在使用的画布",description:"活跃画布 Roadmap。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eeQ("正在使用的画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(eeI,{title:t.title,count:eeZ.length}),(0,ey.jsx)(Qr,{canvases:eeZ,scrollable:!0,onSelect:e})]})},{id:"recent",title:"最近画布",description:"最近打开的画布。",icon:(0,ey.jsx)(pF,{className:"size-4"}),defaultSize:{w:12,h:Math.max(3,Math.ceil(.75*eeJ.length)+1)},defaultConfig:eeQ("最近画布","画布列表"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col",children:[(0,ey.jsx)(eeI,{title:t.title,count:eeJ.length}),(0,ey.jsx)(Qr,{canvases:eeJ,mode:"archive",onSelect:e})]})}]})({onSelect:a}),[]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(J4,{boardId:"canvas-library",definitions:i,initialLayouts:ee1,clipboardItems:e,actionLabel:"画布库页面卡片操作",paletteGroupTitle:"画布库页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n}),(0,ey.jsx)(ee3,{canvas:r,onOpenChange:e=>{e||a(void 0)}})]})}function ee4({icon:e,value:t}){return(0,ey.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"[&_svg]:size-3.5",children:e}),(0,ey.jsx)("span",{className:"tabular-nums",children:t})]})}function ee3({canvas:e,onOpenChange:t}){return e?(0,ey.jsx)(ee2,{open:!!e,onOpenChange:t,title:e.title,eyebrow:"画布管理",description:e.purpose,panels:[{id:"overview",label:"首页",icon:(0,ey.jsx)(Vs,{}),content:(0,ey.jsx)(ee6,{canvas:e})},{id:"templates",label:"节点模板",icon:(0,ey.jsx)(Jb,{}),badge:e.settings.nodeTemplates.length,content:(0,ey.jsx)(ee7,{title:"可用节点模板",items:e.settings.nodeTemplates})},{id:"layout",label:"默认布局",icon:(0,ey.jsx)(JN,{}),content:(0,ey.jsx)(ee7,{title:"默认布局参数",items:e.settings.defaultLayout})},{id:"folders",label:"工作区绑定",icon:(0,ey.jsx)(pF,{}),content:(0,ey.jsx)(ee7,{title:"绑定的工作区文件夹",items:e.settings.folders})},{id:"sharing",label:"共享权限",icon:(0,ey.jsx)(JS,{}),content:(0,ey.jsx)(ee7,{title:"共享与权限",items:e.settings.sharing})},{id:"autosave",label:"自动保存",icon:(0,ey.jsx)(KR,{}),content:(0,ey.jsx)(ee7,{title:"自动保存策略",items:e.settings.autosave})},{id:"snapshots",label:"快照和版本",icon:(0,ey.jsx)(KT,{}),content:(0,ey.jsx)(ee7,{title:"快照和版本策略",items:e.settings.snapshots})},{id:"hosts",label:"可访问主机",icon:(0,ey.jsx)(Jj,{}),content:(0,ey.jsx)(ee7,{title:"可访问主机",items:e.settings.hosts})},{id:"plugins",label:"插件",icon:(0,ey.jsx)(Jk,{}),content:(0,ey.jsx)(ee7,{title:"画布插件",items:e.settings.plugins,empty:"未加载插件"})}]}):null}function ee6({canvas:e}){return(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("button",{type:"button",className:"group relative grid min-h-72 rounded-[2rem] border bg-card p-7 text-left transition-colors hover:bg-muted/35",children:[(0,ey.jsxs)("div",{className:"grid gap-5",children:[(0,ey.jsxs)("div",{className:"max-w-2xl",children:[(0,ey.jsx)("h3",{className:"text-3xl font-semibold tracking-normal",children:e.title}),(0,ey.jsx)("p",{className:"mt-4 text-sm leading-6 text-muted-foreground",children:e.purpose})]}),(0,ey.jsxs)("div",{className:"grid max-w-56 gap-2",children:[(0,ey.jsx)(ee8,{label:"Nodes",value:`${e.nodes}`}),(0,ey.jsx)(ee8,{label:"Agent",value:`${e.agents}`}),(0,ey.jsx)(ee8,{label:"Snapshots",value:`${e.snapshots}`})]})]}),(0,ey.jsx)("span",{className:"absolute right-7 bottom-7 text-sm font-medium text-foreground transition-opacity group-hover:opacity-70",children:"进入"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:"Roadmap"}),(0,ey.jsx)(ee4,{icon:(0,ey.jsx)(Vl,{}),value:e.runtime})]}),(0,ey.jsx)(JE,{items:e.roadmap.map(e=>({id:e.title,title:e.title,status:"running"===e.state?"current":"done"===e.state?"done":"queued"})),viewportClassName:"max-h-64"})]})]})}function ee8({label:e,value:t}){return(0,ey.jsxs)("span",{className:"grid min-w-0 gap-0.5 py-0.5",children:[(0,ey.jsx)("span",{className:"truncate ui-text-kbd text-muted-foreground",children:e}),(0,ey.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold tracking-normal",children:t})]})}function ee7({title:e,items:t,empty:n="暂无内容"}){return(0,ey.jsxs)("div",{className:"grid gap-3",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:e}),(0,ey.jsx)("div",{className:"overflow-hidden rounded-xl border bg-card",children:t.length>0?t.map((e,t)=>(0,ey.jsxs)("div",{className:(0,eI.cn)("flex min-h-10 items-center gap-2 px-3 text-sm",t>0&&"border-t"),children:[(0,ey.jsx)(Jw,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 truncate",children:e})]},e)):(0,ey.jsx)("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:n})})]})}function ee9({open:e,onOpenChange:t,onAdd:n}){return(0,ey.jsx)(xn,{open:e,onOpenChange:t,title:"添加节点",description:"搜索并选择要放入画布的可用节点。",className:"top-1/2 max-w-xl -translate-y-1/2",children:(0,ey.jsxs)(xt,{loop:!0,children:[(0,ey.jsx)(xr,{placeholder:"搜索节点..."}),(0,ey.jsxs)(xa,{children:[(0,ey.jsx)(xi,{children:"没有匹配节点。"}),(0,ey.jsx)(xo,{heading:"可用节点",children:uA.map(e=>(0,ey.jsxs)(xl,{value:`${e.title} ${e.description} ${e.keywords}`,onSelect:()=>n(e),children:[(0,ey.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground",children:e.icon}),(0,ey.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,ey.jsx)("span",{className:"block truncate text-sm font-medium",children:e.title}),(0,ey.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,ey.jsxs)(xs,{children:[e.size.width,"x",e.size.height]})]},e.id))})]})]})})}function ete({nodes:e,edges:t,selectedNodeId:n,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c}){let d=ew.useRef(null),{addPaletteOpen:u,addTemplateNode:f,handleAddPaletteOpenChange:h,handleCanvasAction:p,handleCanvasDragOver:m,handleCanvasDrop:g,handleNodeCanvasConnect:v,handleNodeCanvasEdgeAction:x,handleNodeCanvasNodeAction:y,filePickerDialog:b,renderedCanvasNodes:w}=function({workspaceRef:e,nodes:t,clipboardItems:n,onNodesSet:r,onEdgesSet:a,onSelectedNodeChange:i,onClipboardItemsChange:o}){let l=ew.useRef(0),s=ew.useRef(0),[c,d]=ew.useState(!1),[u,f]=ew.useState(),[h,p]=ew.useState(),m=ew.useCallback((t,n)=>{let r,a,i,o,l,s,c,d;return r=e.current,a=r?.querySelector(".react-flow__viewport"),i=r?.getBoundingClientRect(),l="none"!==(o=a?getComputedStyle(a).transform:"none")?new DOMMatrixReadOnly(o):void 0,s=l?.a&&Number.isFinite(l.a)?l.a:1,c=l?.e??0,d=l?.f??0,{x:(t-(i?.left??0)-c)/s,y:(n-(i?.top??0)-d)/s}},[e]),g=ew.useCallback((e,t)=>{r(n=>n.map(n=>{let r,a;return n.id===e?(a="string"==typeof(r=n.data??{}).activeTabId&&t.some(e=>e.id===r.activeTabId)?r.activeTabId:t[0]?.id,{...n,data:{...r,tabs:t,activeTabId:a}}):n}))},[r]),v=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},activeTabId:t}}:n))},[r]),x=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?function(e,t){let n=e.data??{};if("multi-tab-system"===n.kind){let r=Array.isArray(n.tabs)?n.tabs:[];return{...e,data:{...n,tabs:r.map(e=>e.id===t.id?t:e),activeTabId:t.id}}}return uT(n.kind)?{...e,data:{...n,tab:t}}:e}(n,t):n))},[r]),y=ew.useCallback((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data??{},terminal:t}}:n))},[r]),b=ew.useCallback((e,t)=>{var n;let a=(n=e.kind,uA.find(e=>e.id===n)?.size??uC({width:480,height:320}));s.current+=1;let o=`${e.kind}-detached-${s.current}`;r(n=>[...n,function({tab:e,nodeId:t,center:n,size:r}){return{id:t,type:"blank",position:uO(n,r),data:{contentScale:2,kind:e.kind,tab:{...e,id:`${t}-tab`}},width:r.width,height:r.height,style:uM(r)}}({tab:e,nodeId:o,center:t,size:a})]),i(o)},[r,i]),w=ew.useCallback(async(e,n)=>{try{let a,i=n?.nodeId?t.find(e=>e.id===n.nodeId):void 0,o=i?(i.data??{}).kind:void 0,l="data-table-tab-viewer"===o?await u5(e):await u0(e),s=void 0!==i&&(a=i.data??{},"multi-tab-system"===a.kind||"file-tab-viewer"===a.kind||"data-table-tab-viewer"===a.kind);n?.nodeId&&s&&r(e=>e.map(e=>e.id===n.nodeId?function(e,t,n){let r=e.data??{};if("multi-tab-system"===r.kind){let a,i,o=Array.isArray(r.tabs)?r.tabs:[];return{...e,data:{...r,tabs:(a=o.filter(e=>e.id!==t.id),i=void 0===n?a.length:Math.min(Math.max(n,0),a.length),a.splice(i,0,t),a),activeTabId:t.id}}}return"file-tab-viewer"===r.kind||"data-table-tab-viewer"===r.kind&&"data-table-tab-viewer"===t.kind?{...e,data:{...r,tab:t}}:e}(e,l,n.insertIndex):e)),n?.nodeId&&s||b(l,u??{x:496,y:336})}catch{hI.error("文件预览打开失败")}},[b,t,r,u]),j=ew.useCallback(e=>{let n=t.find(e=>"multi-tab-system"===(e.data??{}).kind);w(e,n?{nodeId:n.id}:void 0)},[t,w]),k=ew.useCallback(async(e,t,n)=>{let r=t.file?.path,a=t.file?.machineId??"local";if(!r)throw hI.error("文件路径不可用"),Error("file path is unavailable");try{let i=await uV({machineId:a,path:r,content:n}),o={...t,title:i.name,modified:!1,defaultValue:"utf-8"===i.encoding?i.content:n,file:{...t.file,name:i.name,path:i.path,machineId:i.machine.id,mimeType:i.mimeType,kind:t.file?.kind,size:i.size,truncated:i.truncated}};x(e,o),hI.success("文件已保存")}catch(e){throw hI.error("文件保存失败"),e}},[x]),S=ew.useCallback((e,t,n)=>{b(t,m(n.clientX,n.clientY))},[b,m]),N=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id"),r=n.find(e=>e.id===t),a=r?r.payloads?.[Gr]:void 0;if(a)return a;let i=e.dataTransfer.getData(Gr);if(i)try{return JSON.parse(i)}catch{return}},[n]),C=ew.useCallback((e,t,n)=>{r(r=>r.map(r=>r.id!==e?r:function(e,t,n){let r=e.data??{},a=Array.isArray(r.tabs)?r.tabs:[],i=new Set(a.map(e=>e.id)),o=n.tab.id,l=2;for(;i.has(o);)o=`${n.tab.id}-${l}`,l+=1;let s=[...a];return s.splice(Math.max(0,Math.min(t,s.length)),0,{...n.tab,id:o}),{...e,data:{...r,tabs:s,activeTabId:o}}}(r,t,n)))},[r]),M=ew.useCallback((e,t,n)=>{let r=N(n);r&&C(e,t,r)},[N,C]),E=ew.useCallback(e=>(function(e,t){for(let n of[...e].reverse()){if("multi-tab-system"!==(n.data??{}).kind)continue;let e=function(e){let t="number"==typeof e.width?e.width:"number"==typeof e.style?.width?e.style.width:"string"==typeof e.style?.width?Number.parseFloat(e.style.width):192,n="number"==typeof e.height?e.height:"number"==typeof e.style?.height?e.style.height:"string"==typeof e.style?.height?Number.parseFloat(e.style.height):112;return{width:Number.isFinite(t)?t:192,height:Number.isFinite(n)?n:112}}(n),r=t.x>=n.position.x&&t.x<=n.position.x+e.width,a=t.y>=n.position.y&&t.y<=n.position.y+e.height;if(r&&a)return n}})(t,e),[t]),O=ew.useCallback((t,n,r)=>(function(e,t,n,r){let a=Array.from(e.current?.querySelectorAll(".react-flow__node")??[]).find(e=>e.getAttribute("data-id")===t),i=a?.querySelector('[data-slot="multi-tab-list"]');if(!i)return r;let o=Array.from(i.querySelectorAll("[data-tab-id]"));for(let[e,t]of o.entries()){let r=t.getBoundingClientRect();if(n<r.left+r.width/2)return e}return o.length})(e,t,n,r),[e]),P=function({nodes:e,onTabsChange:t,onActiveTabChange:n,onRequestFileTab:r,onOpenWorkspaceFile:a,onTabChange:i,onSaveFileTab:o,onTerminalStateChange:l,onTabDetach:s,onExternalTabDrop:c}){return ew.useMemo(()=>e.map(e=>{let d=e.data??{},u=(e.data??{}).kind;return u?{...e,data:{...d,content:(0,ey.jsx)(ZP,{kind:u,nodeId:e.id,tab:d.tab,tabs:d.tabs,activeTabId:d.activeTabId,terminalScopeId:`canvas:node:${e.id}`,terminalState:d.terminal,onTerminalStateChange:t=>l(e.id,t),onRequestFileTab:r,onOpenWorkspaceFile:a,onTabsChange:t,onTabChange:i,onSaveFileTab:o,onActiveTabChange:n,onTabDetach:s,onExternalTabDrop:c})}}:e}),[e,n,c,a,r,o,i,s,l,t])}({nodes:t,onTabsChange:g,onActiveTabChange:v,onRequestFileTab:p,onOpenWorkspaceFile:j,onTabChange:x,onSaveFileTab:k,onTerminalStateChange:y,onTabDetach:S,onExternalTabDrop:M}),A=ew.useCallback(e=>{s.current+=1;let n=`${e.id}-${t.length+s.current}`;r(t=>[...t,function({template:e,nodeId:t,center:n}){let r={contentScale:2,kind:e.id};return"multi-tab-system"===e.id?r.tabs=[]:uT(e.id)&&(r.tab=u_(e.id,`${t}-tab`)),{id:t,type:"blank",position:uO(n,e.size),data:r,width:e.size.width,height:e.size.height,style:uM(e.size)}}({template:e,nodeId:n,center:u??{x:496,y:336}})]),i(void 0),d(!1),f(void 0)},[t.length,r,i,u]),I=ew.useCallback(e=>{let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id");if(!t)return;let a=n.find(e=>e.id===t),o=m(e.clientX,e.clientY),s=N(e),c=s?E(o):void 0;if(s&&c){e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move";let t=c.data??{},n=Array.isArray(t.tabs)?t.tabs:[],r=O(c.id,e.clientX,n.length);C(c.id,r,s),i(void 0);return}let d=a?a.payloads?.[Gn]:void 0;if(!a||!d)return;e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect="move",l.current+=1;let u=`${d.node.id}-drop-${l.current}`;r(e=>[...e,function({source:e,nodeId:t,center:n}){let r={width:e.width??192,height:e.height??112};return{...e,id:t,position:uO(n,r),style:e.style??uM(r),selected:!1,data:{...e.data??{},resizing:!1}}}({source:d.node,nodeId:u,center:o})]),i(u)},[n,E,N,m,O,C,r,i]),z=ew.useCallback(e=>{Array.from(e.dataTransfer.types).some(e=>[Gn,Gr].includes(e))&&(e.preventDefault(),e.dataTransfer.dropEffect="move")},[]),T=ew.useCallback((e,{flowPosition:t})=>{"add"===e&&(f(t),d(!0))},[]),D=ew.useCallback(e=>{a(t=>{if(t.find(t=>t.source===e.source&&t.target===e.target))return t;let n=t.find(t=>t.source===e.target&&t.target===e.source);return n?t.map(e=>e.id===n.id?{...e,data:{...e.data??{},bidirectional:!0}}:e):[...t,{id:`edge-${e.source}-${e.target}-${t.length+1}`,type:"connection",source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,data:{anchors:[]}}]})},[a]),_=ew.useCallback((e,t,n)=>{"cut-edge"===e?a(e=>e.filter(e=>e.id!==t)):a(r=>r.map(r=>{if(r.id!==t)return r;let a=[...r.data?.anchors??[]];return"add-anchor"===e&&n.anchor&&a.splice(n.anchorIndex??a.length,0,n.anchor),"move-anchor"===e&&n.anchor&&void 0!==n.anchorIndex&&(a[n.anchorIndex]=n.anchor),"delete-anchor"===e&&void 0!==n.anchorIndex&&a.splice(n.anchorIndex,1),{...r,data:{...r.data??{},anchors:a}}}))},[a]),R=ew.useCallback((e,n,{snappedPosition:l})=>{if("copy"===e)return void r(e=>{let t=e.find(e=>e.id===n);if(!t)return e;let r=`${t.id}-copy-${e.length+1}`;return i(r),[...e,{...t,id:r,position:l,selected:!1,data:{...t.data??{},resizing:!1}}]});if("cut"===e){let e,l,s,c,d,u=t.find(e=>e.id===n);if(!u)return;let f=(s=(l=function(e){let t=e.data??{},n=t.tab;if(n?.id&&uT(n.kind))return n;let r=t.kind;if(uT(r))return u_(r,e.id)}(e=uR(u)))?{tab:l,sourceNodeId:u.id}:void 0,c={[Gn]:{node:e}},d={"application/vnd.vantaloom.clip-kind":l?"canvas-tab":"canvas-node",[Gn]:u.id},s&&(c[Gr]=s,d[Gr]=JSON.stringify(s)),{id:`clip-${u.id}`,title:l?.title??"画布节点",description:l?"来自画布的独立标签页。":"来自节点画布的空白节点。",meta:`${Math.round(u.width??192)}x${Math.round(u.height??112)}`,icon:l?uD(l.kind):(0,ey.jsx)(ug,{className:"size-4"}),dragData:d,payloads:c});o(e=>[f,...e.filter(e=>e.id!==f.id)]),r(e=>e.filter(e=>e.id!==n)),a(e=>e.filter(e=>e.source!==n&&e.target!==n)),i(void 0)}},[t,o,a,r,i]);return{addPaletteOpen:c,addTemplateNode:A,filePickerDialog:(0,ey.jsx)(G_,{open:void 0!==h,onOpenChange:e=>{e||p(void 0)},onSelectFile:e=>{p(void 0),w(e,h)}}),handleAddPaletteOpenChange:function(e){d(e),e||f(void 0)},handleCanvasAction:T,handleCanvasDragOver:z,handleCanvasDrop:I,handleNodeCanvasConnect:D,handleNodeCanvasEdgeAction:_,handleNodeCanvasNodeAction:R,renderedCanvasNodes:P}}({workspaceRef:d,nodes:e,clipboardItems:r,onNodesChange:a,onEdgesChange:i,onNodesSet:o,onEdgesSet:l,onSelectedNodeChange:s,onClipboardItemsChange:c});return(0,ey.jsxs)("div",{ref:d,className:"vtl-app-background vtl-canvas-workspace relative h-full w-full overflow-hidden",onDragOver:m,onDrop:g,children:[(0,ey.jsx)(sy,{"aria-label":"新建画布",className:"h-full min-h-0 rounded-none border-0",viewportClassName:"h-full",nodes:w,edges:t,nodeTypes:uS,edgeTypes:uN,onNodesChange:a,onEdgesChange:i,selectedNodeId:n,onSelectedNodeChange:s,defaultViewport:{x:0,y:0,zoom:.5},labels:{actions:"画布操作",add:"添加节点",select:"普通鼠标",connect:"连接工具",cut:"剪刀工具",drag:"拖拽工具",modeTools:"模式工具",resetZoom:"重置缩放",viewportTools:"视口工具",lockViewport:"锁定视口",visualSnap:"视觉吸附",nodeSnap:"节点吸附",snapTools:"吸附工具",nodeActions:"节点操作",resizeNode:"调整大小",copyNode:"复制节点",cutNode:"剪切节点"},onCanvasAction:p,onNodeCanvasConnect:v,onNodeCanvasEdgeAction:x,onNodeCanvasNodeAction:y}),(0,ey.jsx)(ee9,{open:u,onOpenChange:h,onAdd:f}),b,(0,ey.jsx)(hL,{position:"top-right"})]})}vl.length;let ett={delete:"Delete",empty:"Drop here",title:"Trash"};function etn({active:e=!1,items:t=[],labels:n,className:r,onDrop:a,onDelete:i,onItemRestore:o,...l}){let s={...ett,...n},[c,d]=ew.useState(!1),u=ew.useRef(0),f=e||c||t.length>0;return ew.useEffect(()=>{e||(u.current=0,d(!1))},[e]),(0,ey.jsx)("div",{"data-slot":"trash-drop-zone","data-visible":f,"data-drag-inside":c,className:(0,eI.cn)("fixed top-4 left-1/2 z-50 -translate-x-1/2 transition-[opacity,transform] duration-300 ease-[cubic-bezier(.2,.8,.2,1)]",f?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-5 opacity-0",r),onDragEnter:function(e){e.preventDefault(),u.current+=1,d(!0)},onDragLeave:function(){u.current=Math.max(0,u.current-1),0===u.current&&d(!1)},onDragOver:function(e){e.preventDefault(),e.dataTransfer.dropEffect="move",d(!0)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),u.current=0,d(!1);let t=e.dataTransfer.getData("application/vnd.vantaloom.clip-id")||e.dataTransfer.getData("text/plain"),n=e.dataTransfer.getData("text/plain")||t||"Dropped item",r=e.dataTransfer.getData("application/vnd.vantaloom.clip-kind");t&&a?.({id:t,title:n,meta:r,nativeEvent:e})},...l,children:(0,ey.jsx)("div",{className:(0,eI.cn)("min-w-12 overflow-hidden rounded-xl border-2 border-background bg-destructive text-destructive-foreground shadow-lg shadow-black/15 transition-[width,min-height,background-color,border-color,padding,box-shadow] duration-300","dark:border-destructive dark:bg-background dark:text-destructive",c||t.length>0?"w-64 border-dashed bg-destructive/12 p-2 text-destructive dark:bg-destructive/8":"flex size-12 items-center justify-center p-0"),children:c||t.length>0?(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-14 items-center justify-center gap-2 rounded-lg border border-dashed border-destructive/55 bg-destructive/8 px-3 text-sm font-medium text-destructive",children:[(0,ey.jsx)(x2,{className:"size-4"}),(0,ey.jsx)("span",{children:s.empty})]}),t.length>0?(0,ey.jsx)("div",{className:"grid max-h-36 gap-1 overflow-y-auto pr-1",children:t.map(e=>(0,ey.jsxs)("div",{className:"flex h-8 items-center gap-2 rounded-md border border-destructive/25 bg-background/80 px-2 text-foreground",children:[(0,ey.jsx)("button",{type:"button","aria-label":`Restore ${e.title}`,className:"flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",onClick:()=>o?.(e),children:(0,ey.jsx)(fc.XIcon,{className:"size-3.5"})}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:e.title}),e.meta?(0,ey.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:e.meta}):null]},e.id))}):null,t.length>0?(0,ey.jsx)("button",{type:"button",className:"h-8 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 dark:border dark:border-destructive dark:bg-background dark:text-destructive dark:hover:bg-destructive/10",onClick:()=>i?.(t),children:s.delete}):null]}):(0,ey.jsx)(x2,{className:"size-5"})})})}function etr({hidden:e,items:t,trashItems:n,trashClipboardItems:r,draggingId:a,onDraggingChange:i,onItemsChange:o,onTrashItemsChange:l,onTrashClipboardItemsChange:s}){let c=ew.useRef(0),[d,u]=ew.useState(!1);return(ew.useEffect(()=>{u(!0)},[]),d)?(0,iy.createPortal)((0,ey.jsxs)("div",{className:(0,eI.cn)("pointer-events-none fixed inset-0 z-40 overflow-visible transition-opacity duration-200",e&&"opacity-0"),children:[(0,ey.jsx)(etn,{active:!e&&void 0!==a,items:e?[]:n,className:(0,eI.cn)(e&&"pointer-events-none"),labels:{delete:"删除",empty:"拖入暂存"},onDrop:({id:e,title:n,meta:r})=>{let a=t.find(t=>t.id===e);a&&(s(t=>({...t,[e]:a})),l(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:n,meta:r,icon:a.icon}]))},onDelete:e=>{let t=new Set(e.map(e=>e.id));l(e=>e.filter(e=>!t.has(e.id))),s(e=>{let n={...e};for(let e of t)delete n[e];return n})},onItemRestore:e=>{let n=r[e.id];n&&o([n,...t.filter(e=>e.id!==n.id)]),l(t=>t.filter(t=>t.id!==e.id)),s(t=>{let n={...t};return delete n[e.id],n})}}),t.length>0?(0,ey.jsx)("div",{className:(0,eI.cn)("pointer-events-auto absolute top-4 right-4 w-80 max-w-[calc(100vw-2rem)] transition-[opacity,transform] duration-200",e&&"pointer-events-none -translate-y-2 opacity-0"),children:(0,ey.jsx)(GY,{items:t,title:"剪切板",labels:{empty:"剪切板为空",dragHandle:"拖拽卡片"},expansionDirection:"down-left",removeOnExternalDrop:!0,maxExpandedHeight:420,onItemDuplicate:(e,{item:n,index:r})=>{let a,i,l,s,d;return c.current+=1,a=n.payloads?.[Ga],i=n.payloads?{...n.payloads}:void 0,l=n.payloads?.[Gi],a&&i&&(i[Ga]={...a,config:{...a.config}}),l&&i&&(i[Gi]={...l,config:l.config?{...l.config}:l.config}),s={...n,id:`${n.id}-copy-${c.current}`,title:`${n.title} copy`,payloads:i,dragData:{...n.dragData,...a?{"application/vnd.vantaloom.dashboard-widget-config":JSON.stringify(a.config)}:{}}},void((d=[...t]).splice(r+1,0,s),o(d))},onItemsRemove:e=>o(e),onItemsReorder:e=>o(e),onItemDragStart:({item:e})=>i(e.id),onItemDragEnd:()=>i(void 0)})}):null]}),document.body):null}let eta=(0,ek.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),eti=(0,ek.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),eto=(0,ek.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),etl=(0,ek.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),ets=(0,ek.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),etc=(0,ek.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),etd=(0,ek.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),etu=(0,ek.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),etf=(0,ek.default)("users-round",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]),eth=(0,ek.default)("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);var etp="Collapsible",[etm,etg]=s7(etp),[etv,etx]=etm(etp),ety=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=co({prop:r,defaultProp:a??!1,onChange:o,caller:etp});return(0,ey.jsx)(etv,{scope:n,disabled:i,contentId:ca(),open:s,onOpenToggle:ew.useCallback(()=>c(e=>!e),[c]),children:(0,ey.jsx)(cd.div,{"data-state":etN(s),"data-disabled":i?"":void 0,...l,ref:t})})});ety.displayName=etp;var etb="CollapsibleTrigger",etw=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=etx(etb,n);return(0,ey.jsx)(cd.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":etN(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:ce(e.onClick,a.onOpenToggle)})});etw.displayName=etb;var etj="CollapsibleContent",etk=ew.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=etx(etj,e.__scopeCollapsible);return(0,ey.jsx)(cE,{present:n||a.open,children:({present:e})=>(0,ey.jsx)(etS,{...r,ref:t,present:e})})});etk.displayName=etj;var etS=ew.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=etx(etj,n),[l,s]=ew.useState(r),c=ew.useRef(null),d=(0,s9.useComposedRefs)(t,c),u=ew.useRef(0),f=u.current,h=ew.useRef(0),p=h.current,m=o.open||l,g=ew.useRef(m),v=ew.useRef(void 0);return ew.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),ct(()=>{let e=c.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,h.current=t.width,g.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),s(r)}},[o.open,r]),(0,ey.jsx)(cd.div,{"data-state":etN(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!m,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":p?`${p}px`:void 0,...e.style},children:m&&a})});function etN(e){return e?"open":"closed"}var etC=e.i(91e3);let etM={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-model-routes":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-system-prompt":"settings","preferences-layout":"settings","network-topology":"settings","check-update":"settings",account:"settings"};function etE({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeCanvasId:a,onItemSelect:i,onOpenConversation:o,onOpenCanvas:l,onOpenConversationSettings:s,onOpenCanvasSettings:c,onConversationDeleted:d,onAccountSettings:u,subagentTree:f,activeSubagentPath:h,onOpenSubagent:p,hideCanvas:m,className:g}){let v=etM[n]??(m?"agent":"canvas");m&&"canvas"===v&&(v="agent");let[x,y]=ew.useState(v);ew.useEffect(()=>{y(v)},[v]);let b=m?e.filter(e=>"canvas"!==e.id):e,w=t.find(e=>e.id===x);return(0,ey.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,eI.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",g),children:[(0,ey.jsx)("nav",{className:"mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:b.map(e=>{let t=e.id===x;return(0,ey.jsxs)("button",{type:"button",onClick:()=>y(e.id),className:(0,eI.cn)("flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"border border-border/50 bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"truncate",children:e.label})]},e.id)})}),"canvas"===x?(0,ey.jsx)(etO,{activeCanvasId:a,onItemSelect:i,onOpenCanvas:l,onOpenCanvasSettings:c}):"agent"===x?(0,ey.jsx)(etz,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:s,onConversationDeleted:d,subagentTree:f,activeSubagentPath:h,onOpenSubagent:p}):(0,ey.jsx)(etF,{content:w,activeWorkspace:n,onItemSelect:i}),(0,ey.jsx)(etG,{onItemSelect:i,onAccountSettings:u})]})}function etO({activeCanvasId:e,onItemSelect:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let{recents:a,loading:i}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0);return ew.useEffect(()=>{let e=!0;async function n(){try{let{canvases:n}=await Jg();if(!e)return;let r=[...n].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r)}catch{}finally{e&&r(!1)}}n();let a=setInterval(()=>void n(),1e4);return()=>{e=!1,clearInterval(a)}},[]),{recents:e,loading:n}}(),o=a.filter(e=>!0===e.running),l=a.filter(e=>!0!==e.running),s=i&&0===a.length;return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,ey.jsx)(etW,{icon:etd,label:J_.canvasNew,onClick:()=>t({item:{id:"new-canvas"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[o.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(t=>(0,ey.jsx)(etP,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]}):null,(0,ey.jsx)("div",{className:"mb-2 flex items-center justify-between px-3",children:(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"})}),(0,ey.jsx)("div",{className:"space-y-0.5",children:s?(0,ey.jsx)(etq,{}):0===l.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:"暂无画布"}):l.map(t=>(0,ey.jsx)(etP,{canvas:t,active:t.id===e,onOpenCanvas:n,onOpenCanvasSettings:r},t.id))})]})]})}function etP({canvas:e,active:t,onOpenCanvas:n,onOpenCanvasSettings:r}){let a=!0===e.running;return(0,ey.jsx)(et$,{title:a?`${e.title} \xb7 运行中`:e.title,label:e.title,active:t,running:a,onOpen:()=>n(e.id,e.ownerMachineId),onOpenSettings:r?()=>r(e.id,e.ownerMachineId):void 0})}let etA="__all__",etI={status:"all",location:etA,sort:"recent"};function etz({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let{recents:s,refresh:c,loading:d,machineNames:u}=function(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState({}),o=ew.useRef(!0),l=ew.useCallback(async()=>{try{let{conversations:e,machineNames:n}=await sO();if(!o.current)return;let r=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(r),i(n)}catch{}finally{o.current&&r(!1)}},[]);return ew.useEffect(()=>{o.current=!0,l();let e=setInterval(()=>void l(),1e4);return()=>{o.current=!1,clearInterval(e)}},[l]),{recents:e,refresh:()=>void l(),loading:n,machineNames:a}}(),[f,h]=ew.useState(etI),p=ew.useMemo(()=>{let e=new Set;for(let t of s)e.add(t.ownerMachineId||sN);return Array.from(e)},[s]),m=ew.useCallback(e=>sC(e)?"本机":u[e]??e,[u]),g=ew.useMemo(()=>{let e=s.filter(e=>{let t=!0===e.running;return("running"!==f.status||!!t)&&("idle"!==f.status||!t)&&(f.location===etA||(e.ownerMachineId||sN)===f.location)});return"name"===f.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[s,f]),v=g.filter(e=>!0===e.running),x=g.filter(e=>!0!==e.running),y=f.status!==etI.status||f.location!==etI.location||f.sort!==etI.sort,b=d&&0===s.length,w=ew.useCallback(async e=>{try{await sB(e.id,e.ownerMachineId)}catch{}a?.(e.id),c()},[a,c]),j=ew.useCallback(async e=>{try{let t=await sq(e.id,void 0,e.ownerMachineId);await c(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[c,n]),k=ew.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),S=o?.[o.length-1]?.id,N=t=>{let a=new Map(t.map(e=>[e.id,e])),o=new Map,s=[];for(let e of t){let t=e.forkOriginId;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=(t,a)=>{let s=t.id!==e||(i?.length??0)===0?null:(0,ey.jsx)(etT,{nodes:i??[],depth:0,ancestors:[],activeIds:k,activeLeafId:S,onOpen:l});return(0,ey.jsxs)(ew.Fragment,{children:[(0,ey.jsx)(etL,{conversation:t,depth:a,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onDelete:w,onFork:j}),s?(0,ey.jsx)("div",{style:a>0?{marginLeft:14*a}:void 0,children:s}):null,(o.get(t.id)??[]).map(e=>c(e,a+1))]},t.id)};return s.map(e=>c(e,0))};return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:"mb-6 space-y-0.5","data-tour":"new-conversation",children:(0,ey.jsx)(etW,{icon:tc,label:J_.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,ey.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[v.length>0?(0,ey.jsxs)("div",{className:"mb-4",children:[(0,ey.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:N(v)})]}):null,(0,ey.jsxs)("div",{className:"mb-2 flex items-center justify-between px-3",children:[(0,ey.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,ey.jsx)(et_,{filter:f,onChange:h,active:y,locations:p,locationLabel:m})]}),(0,ey.jsx)("div",{className:"space-y-0.5",children:b?(0,ey.jsx)(etq,{}):0===x.length?(0,ey.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:y?"没有符合筛选条件的对话":"暂无对话"}):N(x)})]})]})}function etT({nodes:e,depth:t,ancestors:n,activeIds:r,activeLeafId:a,onOpen:i}){let o=e.filter(e=>(function e(t,n){return!!(t.running||n.has(t.id))||(t.children??[]).some(t=>e(t,n))})(e,r));return 0===o.length?null:(0,ey.jsx)("div",{className:"space-y-0.5",children:o.map(e=>{let o=VB(e.subagentType),l=o.Icon,s=[...n,{id:e.id,ownerMachineId:e.ownerMachineId,name:e.subagentName,subagentType:e.subagentType}],c=e.id===a;return(0,ey.jsxs)("div",{children:[(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*t},onClick:()=>i?.(s),title:e.subagentName||o.label,children:[(0,ey.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,ey.jsx)(l,{className:(0,eI.cn)("size-3.5 shrink-0",o.color)}),(0,ey.jsx)("span",{className:"truncate",children:e.subagentName||`${o.label}子代理`}),e.running?(0,ey.jsx)(eM,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,ey.jsx)(etT,{nodes:e.children??[],depth:t+1,ancestors:s,activeIds:r,activeLeafId:a,onOpen:i})]},e.id)})})}let etD={all:"全部",running:"运行中",idle:"空闲"};function et_({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=e.location===etA?"全部":a(e.location);return(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,eI.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,ey.jsx)(JN,{className:"size-4"}),n?(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]})}),(0,ey.jsxs)(bL,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,ey.jsx)(bB,{children:"筛选与排序"}),(0,ey.jsxs)(bR,{children:[(0,ey.jsxs)(bU,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"状态"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:etD[e.status]})]}),(0,ey.jsx)(bW,{children:(0,ey.jsxs)(bA,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,ey.jsx)(bF,{value:"all",children:"全部"}),(0,ey.jsx)(bF,{value:"running",children:"运行中"}),(0,ey.jsx)(bF,{value:"idle",children:"空闲"})]})})]}),(0,ey.jsxs)(bR,{children:[(0,ey.jsxs)(bU,{children:[(0,ey.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,ey.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:i})]}),(0,ey.jsx)(bW,{className:"max-h-72 overflow-y-auto",children:(0,ey.jsxs)(bA,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,ey.jsx)(bF,{value:etA,children:"全部"}),r.map(e=>(0,ey.jsx)(bF,{value:e,children:(0,ey.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,ey.jsx)(bV,{}),(0,ey.jsx)(bB,{children:"排序"}),(0,ey.jsxs)(bA,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,ey.jsx)(bF,{value:"recent",children:"最近活动"}),(0,ey.jsx)(bF,{value:"name",children:"名称"})]}),n?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bV,{}),(0,ey.jsx)(b$,{onSelect:()=>t(etI),children:(0,ey.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function etR({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,ey.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,eI.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,ey.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}function etL({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onDelete:i,onFork:o}){let l=!0===e.running,s=e.settings?.engine??"vantaloom",c="vantaloom"!==s?(0,ey.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,ey.jsx)(etR,{engine:s}),(0,ey.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,ey.jsx)(et$,{title:l?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:c,active:t,running:l,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a?()=>a(e.id,e.ownerMachineId):void 0,onDelete:i?()=>i(e):void 0,onFork:o?()=>o(e):void 0,deleteLabel:"删除会话"})}function et$({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onDelete:s,onFork:c,deleteLabel:d="删除"}){let[u,f]=ew.useState(!1),h=!!(l||s||c),p=i>0,m=(0,ey.jsxs)(ey.Fragment,{children:[l?(0,ey.jsxs)(bm,{onSelect:()=>l(),children:[(0,ey.jsx)(JK,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(bm,{onSelect:()=>c(),children:[(0,ey.jsx)(Vl,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(bm,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(x2,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]}),g=(0,ey.jsxs)("div",{className:(0,eI.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors",r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:p?{marginLeft:14*i}:void 0,children:[(0,ey.jsxs)("button",{type:"button",title:e,onClick:o,className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[p?(0,ey.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,ey.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500","aria-label":"运行中"}):(0,ey.jsx)(etK,{active:r}),n??(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),h?(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,ey.jsx)(lY,{className:"size-4"})})}),(0,ey.jsxs)(bL,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,ey.jsxs)(b$,{onSelect:()=>l(),children:[(0,ey.jsx)(JK,{}),(0,ey.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,c?(0,ey.jsxs)(b$,{onSelect:()=>c(),children:[(0,ey.jsx)(Vl,{}),(0,ey.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,s?(0,ey.jsxs)(b$,{variant:"destructive",onSelect:()=>f(!0),children:[(0,ey.jsx)(x2,{}),(0,ey.jsx)("span",{className:"flex-1",children:d})]}):null]})]}):null]});return(0,ey.jsxs)(ey.Fragment,{children:[h?(0,ey.jsxs)(ba,{children:[(0,ey.jsx)(bo,{asChild:!0,children:g}),(0,ey.jsx)(bp,{className:"min-w-44",children:m})]}):g,s?(0,ey.jsx)(dQ,{open:u,onOpenChange:f,children:(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:d}),(0,ey.jsxs)(uu,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{variant:"destructive",onClick:()=>s(),children:"删除"})]})]})}):null]})}function etF({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,ey.jsx)(wb,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,ey.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,ey.jsx)(etH,{activeWorkspace:t,onItemSelect:n},e.id):(0,ey.jsx)(etB,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function etB({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,ey.jsx)(etK,{active:!0})]})}let etV=[{id:"model",title:"模型设置",icon:(0,ey.jsx)(ux,{}),items:[{id:"preferences-model-routes",label:"模型路由",icon:(0,ey.jsx)(p_,{})},{id:"preferences-agent-config",label:"代理配置",icon:(0,ey.jsx)(um,{})},{id:"preferences-subagent-config",label:"子代理配置",icon:(0,ey.jsx)(etf,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,ey.jsx)(ux,{})}]},{id:"prefs",title:"偏好设置",icon:(0,ey.jsx)(JK,{}),items:[{id:"preferences-system-prompt",label:"系统提示词",icon:(0,ey.jsx)(etc,{})},{id:"preferences-layout",label:"布局排版",icon:(0,ey.jsx)(eto,{})}]},{id:"system",title:"系统设置",icon:(0,ey.jsx)(K7,{}),items:[{id:"network-topology",label:"组网关系",icon:(0,ey.jsx)(Jj,{})},{id:"check-update",label:"检查更新",icon:(0,ey.jsx)(x1,{})},{id:"account",label:"Hub 账户",icon:(0,ey.jsx)(eC,{})},{id:"balance-usage",label:"余额用量",icon:(0,ey.jsx)(eth,{})},{id:"feedback",label:"问题反馈",icon:(0,ey.jsx)(jl,{})}]}];function etH({activeWorkspace:e,onItemSelect:t}){return(0,ey.jsx)(ey.Fragment,{children:etV.map(n=>(0,ey.jsx)(etU,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t},n.id))})}function etU({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=ew.useState(!0);return(0,ey.jsxs)(ety,{open:o,onOpenChange:l,children:[(0,ey.jsx)(etw,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button",className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,ey.jsx)(g8,{className:(0,eI.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,ey.jsx)(etk,{className:"mt-0.5 space-y-0.5",children:n.map(e=>{let t=e.id===r;return(0,ey.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),className:(0,eI.cn)("flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",t?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),t&&(0,ey.jsx)(etK,{active:!0})]},e.id)})})]})}function etW({icon:e,label:t,onClick:n}){return(0,ey.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",children:[(0,ey.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,ey.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function etq(){return(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"}),(0,ey.jsx)("span",{children:"加载中…"})]})}function etK({active:e}){return(0,ey.jsx)("span",{className:(0,eI.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}function etG({onItemSelect:e,onAccountSettings:t}){let{user:n}=tl(),r=n?.name??JD.product,a=(n?.name??"V").slice(0,1).toUpperCase();return(0,ey.jsx)("div",{className:"mt-auto pt-3",children:(0,ey.jsxs)(bk,{children:[(0,ey.jsx)(bN,{asChild:!0,children:(0,ey.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,ey.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,ey.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:a}),(0,ey.jsx)("span",{className:"truncate text-sm text-foreground",children:r})]}),(0,ey.jsx)(p$,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,ey.jsxs)(bL,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[n?.email&&(0,ey.jsx)(bB,{className:"truncate font-normal text-muted-foreground",children:n.email}),(0,ey.jsxs)(b$,{onSelect:()=>e({item:{id:"preferences"}}),children:[(0,ey.jsx)(JK,{}),(0,ey.jsx)("span",{className:"flex-1",children:"设置"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"Ctrl,"})]}),(0,ey.jsxs)(b$,{disabled:!0,children:[(0,ey.jsx)(eti,{}),(0,ey.jsx)("span",{className:"flex-1",children:"语言"}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,ey.jsxs)(b$,{disabled:!0,children:[(0,ey.jsx)(eta,{}),(0,ey.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,ey.jsx)(bV,{}),(0,ey.jsxs)(b$,{onSelect:()=>{t?t():e({item:{id:"account"}})},children:[(0,ey.jsx)(KT,{}),(0,ey.jsx)("span",{className:"flex-1",children:"Hub 账户"})]}),(0,ey.jsx)(etY,{}),n&&(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(bV,{}),(0,ey.jsx)(etZ,{})]})]})]})})}let etX=["light","dark","jelly"];function etY(){let{resolvedTheme:e,setTheme:t}=(0,hw.useTheme)(),[n,r]=ew.useState(etC.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(etC.appearanceThemeStorageKey)??etC.defaultAppearanceTheme;r(e),(0,etC.applyAppearanceTheme)({theme:e})},[]);let a=n===etC.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=etX[(etX.indexOf(a)+1)%etX.length]??"light";function o(e){r(e),window.localStorage.setItem(etC.appearanceThemeStorageKey,e),(0,etC.applyAppearanceTheme)({theme:e})}let l="dark"===a?ets:etu;return(0,ey.jsxs)(b$,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(etC.jellyAppearanceTheme);return}o(etC.defaultAppearanceTheme),t(i)}()},children:[(0,ey.jsx)(l,{}),(0,ey.jsx)("span",{className:"flex-1",children:JD.theme}),(0,ey.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function etZ(){let{logout:e}=tl();return(0,ey.jsxs)(b$,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,ey.jsx)(etl,{}),(0,ey.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let etJ=ew.default.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),etQ=()=>{let e=ew.default.useContext(etJ);if(!e)throw Error("useDrawerContext must be used within a Drawer.Root");return e};function et0(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function et1(){return et2(/^iPhone/)||et2(/^iPad/)||et2(/^Mac/)&&navigator.maxTouchPoints>1}function et2(e){return"u">typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if(!e||"u"<typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");let et5="u">typeof window?ew.useLayoutEffect:ew.useEffect;function et4(...e){return(...t)=>{for(let n of e)"function"==typeof n&&n(...t)}}let et3="u">typeof document&&window.visualViewport;function et6(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function et8(e){for(et6(e)&&(e=e.parentElement);e&&!et6(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}let et7=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),et9=0;function ene(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ent(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=et8(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=r-n)}e=t.parentElement}}function enn(e){return e instanceof HTMLInputElement&&!et7.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function enr(...e){return ew.useCallback(function(...e){return t=>e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}(...e),e)}let ena=new WeakMap;function eni(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([t,n])=>{t.startsWith("--")?e.style.setProperty(t,n):(r[t]=e.style[t],e.style[t]=n)}),n||ena.set(e,r)}let eno=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function enl(e,t){if(!e)return null;let n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform,a=r.match(/^matrix3d\((.+)\)$/);return a?parseFloat(a[1].split(", ")[eno(t)?13:12]):(a=r.match(/^matrix\((.+)\)$/))?parseFloat(a[1].split(", ")[eno(t)?5:4]):null}function ens(e,t){if(!e)return()=>{};let n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}let enc=[.32,.72,0,1],end="vaul-dragging";function enu(e){let t=ew.default.useRef(e);return ew.default.useEffect(()=>{t.current=e}),ew.default.useMemo(()=>(...e)=>null==t.current?void 0:t.current.call(t,...e),[])}function enf({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,a]=function({defaultProp:e,onChange:t}){let n=ew.default.useState(e),[r]=n,a=ew.default.useRef(r),i=enu(t);return ew.default.useEffect(()=>{a.current!==r&&(i(r),a.current=r)},[r,a,i]),n}({defaultProp:t,onChange:n}),i=void 0!==e,o=i?e:r,l=enu(n);return[o,ew.default.useCallback(t=>{if(i){let n="function"==typeof t?t(e):t;n!==e&&l(n)}else a(t)},[i,e,a,l])]}let enh=()=>()=>{},enp=null,enm=ew.default.forwardRef(function({...e},t){let{overlayRef:n,snapPoints:r,onRelease:a,shouldFade:i,isOpen:o,modal:l,shouldAnimate:s}=etQ(),c=enr(t,n),d=r&&r.length>0;if(!l)return null;let u=ew.default.useCallback(e=>a(e),[a]);return ew.default.createElement(dO,{onMouseUp:u,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&d?"true":"false","data-vaul-snap-points-overlay":o&&i?"true":"false","data-vaul-animate":(null==s?void 0:s.current)?"true":"false",...e})});enm.displayName="Drawer.Overlay";let eng=ew.default.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},a){let{drawerRef:i,onPress:o,onRelease:l,onDrag:s,keyboardIsOpen:c,snapPointsOffset:d,activeSnapPointIndex:u,modal:f,isOpen:h,direction:p,snapPoints:m,container:g,handleOnly:v,shouldAnimate:x,autoFocus:y}=etQ(),[b,w]=ew.default.useState(!1),j=enr(a,i),k=ew.default.useRef(null),S=ew.default.useRef(null),N=ew.default.useRef(!1),C=m&&m.length>0;function M(e){k.current=null,N.current=!1,l(e)}return!function(){let{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:a}=etQ(),i=ew.default.useRef(null),o=(0,ew.useMemo)(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}ew.default.useEffect(()=>{if(t&&n){i.current&&clearTimeout(i.current);let t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;!function(...e){}(r&&!a?ens(document.body,{background:"black"}):enh,ens(t,{transformOrigin:eno(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${enc.join(",")})`}));let n=ens(t,{borderRadius:"8px",overflow:"hidden",...eno(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{n(),i.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},500)}}},[t,n,o])}(),ew.default.useEffect(()=>{C&&window.requestAnimationFrame(()=>{w(!0)})},[]),ew.default.createElement(dz,{"data-vaul-drawer-direction":p,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":h&&C?"true":"false","data-vaul-custom-container":g?"true":"false","data-vaul-animate":(null==x?void 0:x.current)?"true":"false",...r,ref:j,style:d&&d.length>0?{"--snap-point-height":`${d[null!=u?u:0]}px`,...t}:t,onPointerDown:e=>{v||(null==r.onPointerDown||r.onPointerDown.call(r,e),k.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==n||n(e),y||e.preventDefault()},onPointerDownOutside:t=>{(null==e||e(t),!f||t.defaultPrevented)?t.preventDefault():c.current&&(c.current=!1)},onFocusOutside:e=>{if(!f)return void e.preventDefault()},onPointerMove:e=>{if(S.current=e,v||(null==r.onPointerMove||r.onPointerMove.call(r,e),!k.current))return;let t=e.pageY-k.current.y,n=e.pageX-k.current.x,a="touch"===e.pointerType?10:2;((e,t,n=0)=>{if(N.current)return!0;let r=Math.abs(e.y),a=Math.abs(e.x),i=a>r,o=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*o<0)&&a>=0&&a<=n)return i}else if(!(e.y*o<0)&&r>=0&&r<=n)return!i;return N.current=!0,!0})({x:n,y:t},p,a)?s(e):(Math.abs(n)>a||Math.abs(t)>a)&&(k.current=null)},onPointerUp:e=>{null==r.onPointerUp||r.onPointerUp.call(r,e),k.current=null,N.current=!1,l(e)},onPointerOut:e=>{null==r.onPointerOut||r.onPointerOut.call(r,e),M(S.current)},onContextMenu:e=>{null==r.onContextMenu||r.onContextMenu.call(r,e),S.current&&M(S.current)}})});eng.displayName="Drawer.Content",ew.default.forwardRef(function({preventCycle:e=!1,children:t,...n},r){let{closeDrawer:a,isDragging:i,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:s,dismissible:c,handleOnly:d,isOpen:u,onPress:f,onDrag:h}=etQ(),p=ew.default.useRef(null),m=ew.default.useRef(!1);function g(){p.current&&window.clearTimeout(p.current),m.current=!1}return ew.default.createElement("div",{onClick:function(){m.current?g():window.setTimeout(()=>{!function(){if(i||e||m.current)return g();if(g(),!o||0===o.length){c||a();return}if(l===o[o.length-1]&&c)return a();let t=o.findIndex(e=>e===l);-1===t||s(o[t+1])}()},120)},onPointerCancel:g,onPointerDown:e=>{d&&f(e),p.current=window.setTimeout(()=>{m.current=!0},250)},onPointerMove:e=>{d&&h(e)},ref:r,"data-vaul-drawer-visible":u?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},ew.default.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))}).displayName="Drawer.Handle";let env=function({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:a,snapPoints:i,shouldScaleBackground:l=!1,setBackgroundColorOnScale:s=!0,closeThreshold:c=.25,scrollLockTimeout:d=100,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:h=i&&i.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:x,nested:y,noBodyStyles:b=!1,direction:w="bottom",defaultOpen:j=!1,disablePreventScroll:k=!0,snapToSequentialPoint:S=!1,preventScrollRestoration:N=!1,repositionInputs:C=!0,onAnimationEnd:M,container:E,autoFocus:O=!1}){var P,A;let[I=!1,z]=enf({defaultProp:j,prop:e,onChange:e=>{null==t||t(e),e||y||ed(),setTimeout(()=>{null==M||M(e)},500),e&&!v&&"u">typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[T,D]=ew.default.useState(!1),[_,R]=ew.default.useState(!1),[L,$]=ew.default.useState(!1),F=ew.default.useRef(null),B=ew.default.useRef(null),V=ew.default.useRef(null),H=ew.default.useRef(null),U=ew.default.useRef(null),W=ew.default.useRef(!1),q=ew.default.useRef(null),K=ew.default.useRef(0),G=ew.default.useRef(!1),X=ew.default.useRef(!j),Y=ew.default.useRef(0),Z=ew.default.useRef(null),J=ew.default.useRef((null==(P=Z.current)?void 0:P.getBoundingClientRect().height)||0),Q=ew.default.useRef((null==(A=Z.current)?void 0:A.getBoundingClientRect().width)||0),ee=ew.default.useRef(0),et=ew.default.useCallback(e=>{i&&e===eo.length-1&&(B.current=new Date)},[]),{activeSnapPoint:en,activeSnapPointIndex:er,setActiveSnapPoint:ea,onRelease:ei,snapPointsOffset:eo,onDrag:el,shouldFade:es,getPercentageDragged:ec}=function({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:a,fadeFromIndex:i,onSnapPointChange:o,direction:l="bottom",container:s,snapToSequentialPoint:c}){let[d,u]=enf({prop:e,defaultProp:null==n?void 0:n[0],onChange:t}),[f,h]=ew.default.useState("u">typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);ew.default.useEffect(()=>{function e(){h({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let p=ew.default.useMemo(()=>d===(null==n?void 0:n[n.length-1])||null,[n,d]),m=ew.default.useMemo(()=>{var e;return null!=(e=null==n?void 0:n.findIndex(e=>e===d))?e:null},[n,d]),g=n&&n.length>0&&(i||0===i)&&!Number.isNaN(i)&&n[i]===d||!n,v=ew.default.useMemo(()=>{var e;let t=s?{width:s.getBoundingClientRect().width,height:s.getBoundingClientRect().height}:"u">typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};return null!=(e=null==n?void 0:n.map(e=>{let n="string"==typeof e,r=0;if(n&&(r=parseInt(e,10)),eno(l)){let a=n?r:f?e*t.height:0;return f?"bottom"===l?t.height-a:-t.height+a:a}let a=n?r:f?e*t.width:0;return f?"right"===l?t.width-a:-t.width+a:a}))?e:[]},[n,f,s]),x=ew.default.useMemo(()=>null!==m?null==v?void 0:v[m]:null,[v,m]),y=ew.default.useCallback(e=>{var t;let s=null!=(t=null==v?void 0:v.findIndex(t=>t===e))?t:null;o(s),eni(r.current,{transition:`transform 0.5s cubic-bezier(${enc.join(",")})`,transform:eno(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),v&&s!==v.length-1&&void 0!==i&&s!==i&&s<i?eni(a.current,{transition:`opacity 0.5s cubic-bezier(${enc.join(",")})`,opacity:"0"}):eni(a.current,{transition:`opacity 0.5s cubic-bezier(${enc.join(",")})`,opacity:"1"}),u(null==n?void 0:n[Math.max(s,0)])},[r.current,n,v,i,a,u]);return ew.default.useEffect(()=>{if(d||e){var t;let r=null!=(t=null==n?void 0:n.findIndex(t=>t===e||t===d))?t:-1;v&&-1!==r&&"number"==typeof v[r]&&y(v[r])}},[d,e,n,v,y]),{isLastSnapPoint:p,activeSnapPoint:d,shouldFade:g,getPercentageDragged:function(e,t){if(!n||"number"!=typeof m||!v||void 0===i)return null;let r=m===i-1;if(m>=i&&t)return 0;if(r&&!t)return 1;if(!g&&!r)return null;let a=r?m+1:m-1,o=e/Math.abs(r?v[a]-v[a-1]:v[a+1]-v[a]);return r?1-o:o},setActiveSnapPoint:u,activeSnapPointIndex:m,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:o}){if(void 0===i)return;let s="bottom"===l||"right"===l?(null!=x?x:0)-e:(null!=x?x:0)+e,d=m===i-1,u=0===m,f=e>0;if(d&&eni(a.current,{transition:`opacity 0.5s cubic-bezier(${enc.join(",")})`}),!c&&r>2&&!f)return void(o?t():y(v[0]));if(!c&&r>2&&f&&v&&n)return void y(v[n.length-1]);let h=null==v?void 0:v.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-s)<Math.abs(e-s)?t:e),g=eno(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*g){let e=f?1:-1;return e>0&&p&&n?void y(v[n.length-1]):void(u&&e<0&&o&&t(),null===m||y(v[m+e]))}y(h)},onDrag:function({draggedDistance:e}){if(null===x)return;let t="bottom"===l||"right"===l?x-e:x+e;("bottom"===l||"right"===l)&&t<v[v.length-1]||("top"===l||"left"===l)&&t>v[v.length-1]||eni(r.current,{transform:eno(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:v}}({snapPoints:i,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Z,fadeFromIndex:h,overlayRef:F,onSnapPointChange:et,direction:w,container:E,snapToSequentialPoint:S});!function(e={}){let{isDisabled:t}=e;et5(()=>{if(!t){var e,n,r;let t,a,i,l,s,c,d;return 1==++et9&&et1()&&(i=0,l=window.pageXOffset,s=window.pageYOffset,c=et4((e=document.documentElement,n="paddingRight",r=`${window.innerWidth-document.documentElement.clientWidth}px`,t=e.style[n],e.style[n]=r,()=>{e.style[n]=t})),window.scrollTo(0,0),d=et4(ene(document,"touchstart",e=>{((a=et8(e.target))!==document.documentElement||a!==document.body)&&(i=e.changedTouches[0].pageY)},{passive:!1,capture:!0}),ene(document,"touchmove",e=>{if(!a||a===document.documentElement||a===document.body)return void e.preventDefault();let t=e.changedTouches[0].pageY,n=a.scrollTop,r=a.scrollHeight-a.clientHeight;0!==r&&((n<=0&&t>i||n>=r&&t<i)&&e.preventDefault(),i=t)},{passive:!1,capture:!0}),ene(document,"touchend",e=>{let t=e.target;enn(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},{passive:!1,capture:!0}),ene(document,"focus",e=>{let t=e.target;enn(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",et3&&(et3.height<window.innerHeight?requestAnimationFrame(()=>{ent(t)}):et3.addEventListener("resize",()=>ent(t),{once:!0}))}))},!0),ene(window,"scroll",()=>{window.scrollTo(0,0)})),o=()=>{c(),d(),window.scrollTo(l,s)}),()=>{0==--et9&&(null==o||o())}}},[t])}({isDisabled:!I||_||!v||L||!T||!C||!k});let{restorePositionSetting:ed}=function({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:a,noBodyStyles:i}){let[o,l]=ew.default.useState(()=>"u">typeof window?window.location.href:""),s=ew.default.useRef(0),c=ew.default.useCallback(()=>{if(et0()&&null===enp&&e&&!i){enp={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};let{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-s.current}px`,left:`${-e}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let e=t-window.innerHeight;e&&s.current>=t&&(document.body.style.top=`${-(s.current+e)}px`)}),300)}},[e]),d=ew.default.useCallback(()=>{if(et0()&&null!==enp&&!i){let e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,enp),window.requestAnimationFrame(()=>{a&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),enp=null}},[o]);return ew.default.useEffect(()=>{function e(){s.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),ew.default.useEffect(()=>{if(t)return()=>{"u"<typeof document||document.querySelector("[data-vaul-drawer]")||d()}},[t,d]),ew.default.useEffect(()=>{!n&&r&&(e?(window.matchMedia("(display-mode: standalone)").matches||c(),t||window.setTimeout(()=>{d()},500)):d())},[e,r,o,t,n,c,d]),{restorePositionSetting:d}}({isOpen:I,modal:v,nested:null!=y&&y,hasBeenOpened:T,preventScrollRestoration:N,noBodyStyles:b});function eu(){return(window.innerWidth-26)/window.innerWidth}function ef(e,t){var n;let r=e,a=null==(n=window.getSelection())?void 0:n.toString(),i=Z.current?enl(Z.current,w):null,o=new Date;if("SELECT"===r.tagName||r.hasAttribute("data-vaul-no-drag")||r.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(B.current&&o.getTime()-B.current.getTime()<500)return!1;if(null!==i&&("bottom"===w?i>0:i<0))return!0;if(a&&a.length>0)return!1;if(U.current&&o.getTime()-U.current.getTime()<d&&0===i||t)return U.current=o,!1;for(;r;){if(r.scrollHeight>r.clientHeight){if(0!==r.scrollTop)return U.current=new Date,!1;if("dialog"===r.getAttribute("role"))break}r=r.parentNode}return!0}function eh(e){_&&Z.current&&(Z.current.classList.remove(end),W.current=!1,R(!1),H.current=new Date),null==x||x(),e||z(!1),setTimeout(()=>{i&&ea(i[0])},500)}function ep(){if(!Z.current)return;let e=document.querySelector("[data-vaul-drawer-wrapper]"),t=enl(Z.current,w);eni(Z.current,{transform:"translate3d(0, 0, 0)",transition:`transform 0.5s cubic-bezier(${enc.join(",")})`}),eni(F.current,{transition:`opacity 0.5s cubic-bezier(${enc.join(",")})`,opacity:"1"}),l&&t&&t>0&&I&&eni(e,{borderRadius:"8px",overflow:"hidden",...eno(w)?{transform:`scale(${eu()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${eu()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:"0.5s",transitionTimingFunction:`cubic-bezier(${enc.join(",")})`},!0)}return ew.default.useEffect(()=>{window.requestAnimationFrame(()=>{X.current=!0})},[]),ew.default.useEffect(()=>{var e;function t(){if(Z.current&&C&&(enn(document.activeElement)||G.current)){var e;let t=(null==(e=window.visualViewport)?void 0:e.height)||0,n=window.innerHeight,r=n-t,a=Z.current.getBoundingClientRect().height||0;ee.current||(ee.current=a);let o=Z.current.getBoundingClientRect().top;if(Math.abs(Y.current-r)>60&&(G.current=!G.current),i&&i.length>0&&eo&&er&&(r+=eo[er]||0),Y.current=r,a>t||G.current){let e=Z.current.getBoundingClientRect().height,i=e;e>t&&(i=t-(a>.8*n?o:26)),g?Z.current.style.height=`${e-Math.max(r,0)}px`:Z.current.style.height=`${Math.max(i,t-o)}px`}else{let e;e=navigator.userAgent,"u">typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))||(Z.current.style.height=`${ee.current}px`)}i&&i.length>0&&!G.current?Z.current.style.bottom="0px":Z.current.style.bottom=`${Math.max(r,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[er,i,eo]),ew.default.useEffect(()=>(I&&(eni(document.documentElement,{scrollBehavior:"auto"}),B.current=new Date),()=>{!function(e,t){if(!e||!(e instanceof HTMLElement))return;let n=ena.get(e);n&&(e.style[t]=n[t])}(document.documentElement,"scrollBehavior")}),[I]),ew.default.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),ew.default.createElement(dw,{defaultOpen:j,onOpenChange:e=>{(u||e)&&(e?D(!0):eh(!0),z(e))},open:I},ew.default.createElement(etJ.Provider,{value:{activeSnapPoint:en,snapPoints:i,setActiveSnapPoint:ea,drawerRef:Z,overlayRef:F,onOpenChange:t,onPress:function(e){var t,n;!u&&!i||(!Z.current||Z.current.contains(e.target))&&(J.current=(null==(t=Z.current)?void 0:t.getBoundingClientRect().height)||0,Q.current=(null==(n=Z.current)?void 0:n.getBoundingClientRect().width)||0,R(!0),V.current=new Date,et1()&&window.addEventListener("touchend",()=>W.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),K.current=eno(w)?e.pageY:e.pageX)},onRelease:function(e){var t,n;if(!_||!Z.current)return;Z.current.classList.remove(end),W.current=!1,R(!1),H.current=new Date;let r=enl(Z.current,w);if(!e||!ef(e.target,!1)||!r||Number.isNaN(r)||null===V.current)return;let o=H.current.getTime()-V.current.getTime(),l=K.current-(eno(w)?e.pageY:e.pageX),s=Math.abs(l)/o;if(s>.05&&($(!0),setTimeout(()=>{$(!1)},200)),i){ei({draggedDistance:l*("bottom"===w||"right"===w?1:-1),closeDrawer:eh,velocity:s,dismissible:u}),null==a||a(e,!0);return}if("bottom"===w||"right"===w?l>0:l<0){ep(),null==a||a(e,!0);return}if(s>.4){eh(),null==a||a(e,!1);return}let d=Math.min(null!=(t=Z.current.getBoundingClientRect().height)?t:0,window.innerHeight),f=Math.min(null!=(n=Z.current.getBoundingClientRect().width)?n:0,window.innerWidth);if(Math.abs(r)>=("left"===w||"right"===w?f:d)*c){eh(),null==a||a(e,!1);return}null==a||a(e,!0),ep()},onDrag:function(e){if(Z.current&&_){let t="bottom"===w||"right"===w?1:-1,n=(K.current-(eno(w)?e.pageY:e.pageX))*t,a=n>0,o=i&&!u&&!a;if(o&&0===er)return;let s=Math.abs(n),c=document.querySelector("[data-vaul-drawer-wrapper]"),d=s/("bottom"===w||"top"===w?J.current:Q.current),f=ec(s,a);if(null!==f&&(d=f),o&&d>=1||!W.current&&!ef(e.target,a))return;if(Z.current.classList.add(end),W.current=!0,eni(Z.current,{transition:"none"}),eni(F.current,{transition:"none"}),i&&el({draggedDistance:n}),a&&!i){let e=Math.min(-(8*(Math.log(n+1)-2)*1),0)*t;eni(Z.current,{transform:eno(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`});return}let p=1-d;if((es||h&&er===h-1)&&(null==r||r(e,d),eni(F.current,{opacity:`${p}`,transition:"none"},!0)),c&&F.current&&l){let e=Math.min(eu()+d*(1-eu()),1),t=8-8*d,n=Math.max(0,14-14*d);eni(c,{borderRadius:`${t}px`,transform:eno(w)?`scale(${e}) translate3d(0, ${n}px, 0)`:`scale(${e}) translate3d(${n}px, 0, 0)`,transition:"none"},!0)}if(!i){let e=s*t;eni(Z.current,{transform:eno(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:X,handleOnly:f,isOpen:I,isDragging:_,shouldFade:es,closeDrawer:eh,onNestedDrag:function(e,t){if(t<0)return;let n=(window.innerWidth-16)/window.innerWidth,r=n+t*(1-n),a=-16+16*t;eni(Z.current,{transform:eno(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){let t=e?(window.innerWidth-16)/window.innerWidth:1,n=e?-16:0;q.current&&window.clearTimeout(q.current),eni(Z.current,{transition:`transform 0.5s cubic-bezier(${enc.join(",")})`,transform:eno(w)?`scale(${t}) translate3d(0, ${n}px, 0)`:`scale(${t}) translate3d(${n}px, 0, 0)`}),!e&&Z.current&&(q.current=setTimeout(()=>{let e=enl(Z.current,w);eni(Z.current,{transition:"none",transform:eno(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){let n=eno(w)?window.innerHeight:window.innerWidth,r=t?(n-16)/n:1,a=t?-16:0;t&&eni(Z.current,{transition:`transform 0.5s cubic-bezier(${enc.join(",")})`,transform:eno(w)?`scale(${r}) translate3d(0, ${a}px, 0)`:`scale(${r}) translate3d(${a}px, 0, 0)`})},keyboardIsOpen:G,modal:v,snapPointsOffset:eo,activeSnapPointIndex:er,direction:w,shouldScaleBackground:l,setBackgroundColorOnScale:s,noBodyStyles:b,container:E,autoFocus:O}},n))},enx=function(e){let t=etQ(),{container:n=t.container,...r}=e;return ew.default.createElement(dM,{container:n,...r})};function eny({className:e,...t}){return(0,ey.jsx)(enm,{"data-slot":"drawer-overlay",className:(0,eI.cn)("vtl-overlay fixed inset-0 z-50 animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function enb({className:e,children:t,...n}){return(0,ey.jsxs)(enx,{"data-slot":"drawer-portal",children:[(0,ey.jsx)(eny,{}),(0,ey.jsxs)(eng,{"data-slot":"drawer-content",className:(0,eI.cn)("vtl-surface-modal group/drawer-content fixed z-50 flex h-auto flex-col border outline-none","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-t-0","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-b-0","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-r-0 data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-l-0 data-[vaul-drawer-direction=left]:sm:max-w-sm",e),...n,children:[(0,ey.jsx)("div",{className:"mx-auto mt-3 hidden h-1.5 w-16 shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),t]})]})}function enw({className:e,...t}){return(0,ey.jsx)(dL,{"data-slot":"drawer-title",className:(0,eI.cn)("text-base leading-none font-semibold text-foreground",e),...t})}function enj({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:a,onOpenConversation:i,onOpenConversationSettings:o,onConversationDeleted:l,onAccountSettings:s,subagentTree:c,activeSubagentPath:d,onOpenSubagent:u,title:f,trailing:h}){let[p,m]=ew.useState(!1),g=ew.useCallback(()=>m(!1),[]),v=ew.useCallback(e=>{g(),a(e)},[g,a]),x=ew.useCallback((e,t)=>{g(),i(e,t)},[g,i]),y=ew.useCallback(e=>{g(),u?.(e)},[g,u]);return(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(enk,{onMenuClick:()=>m(!0),title:f,trailing:h}),(0,ey.jsx)(env,{open:p,onOpenChange:m,direction:"left",children:(0,ey.jsxs)(enb,{className:"w-[85vw] max-w-xs",children:[(0,ey.jsx)(enw,{className:"sr-only",children:"导航"}),(0,ey.jsx)(etE,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,onItemSelect:v,onOpenConversation:x,onOpenCanvas:()=>{},onOpenConversationSettings:(e,t)=>{g(),o?.(e,t)},onConversationDeleted:l,onAccountSettings:()=>{g(),s?.()},subagentTree:c,activeSubagentPath:d,onOpenSubagent:y,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})})]})}function enk({onMenuClick:e,title:t,trailing:n,className:r}){return(0,ey.jsxs)("header",{className:(0,eI.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,ey.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,ey.jsx)(s2,{})}),t?(0,ey.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,ey.jsx)("div",{className:"min-w-0 flex-1"}),(0,ey.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let enS=(0,ek.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),enN=[{id:"canvas",label:J_.canvas,icon:(0,ey.jsx)(ug,{})},{id:"agent",label:"智能体",icon:(0,ey.jsx)(um,{})},{id:"settings",label:J_.settings,icon:(0,ey.jsx)(JK,{})}],enC=[{id:"canvas",title:J_.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:J_.canvas,items:[{id:"open-recent-canvas",label:J_.canvasRecent,icon:(0,ey.jsx)(ug,{})},{id:"new-canvas",label:J_.canvasNew,icon:(0,ey.jsx)(lJ,{})},{id:"all-canvases",label:J_.canvasAll,icon:(0,ey.jsx)(uy,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:J_.conversationRecent,icon:(0,ey.jsx)(enS,{})},{id:"new-agent-conversation",label:J_.conversationNew,icon:(0,ey.jsx)(um,{})}]}]},{id:"settings",title:J_.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,ey.jsx)(JK,{})}]}]}],enM=(0,ek.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),enE=(0,ek.default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),enO=(0,ek.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),enP=(0,ek.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function enA(){let{user:e,machine:t,logout:n,unbind:r,refreshUser:a}=tl(),[i,o]=ew.useState(!1),[l,s]=ew.useState(!1),[c,d]=ew.useState(t),[u,f]=ew.useState(!1),[h,p]=ew.useState(""),[m,g]=ew.useState(!1),[v,x]=ew.useState(null);async function y(){o(!0);try{await eJ("online");let e=eW();d(e),await a()}catch{}finally{o(!1)}}async function b(){let e=h.trim();if(!e)return void x("名称不能为空");g(!0),x(null);try{let t=await e0(e);d(e=>e?{...e,name:t}:e),f(!1)}catch(e){x(e instanceof Error?e.message:"重命名失败")}finally{g(!1)}}async function w(){s(!0);try{await r()}catch{s(!1)}}async function j(){await n()}return ew.useEffect(()=>{d(t)},[t]),e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsx)("div",{className:"flex items-center justify-between gap-3","data-tour":"hub-account",children:(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"Vantaloom Hub 账户"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"管理你的 Hub 连接和设备绑定"})]})}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户信息"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"你的 Vantaloom Hub 账户详情。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,ey.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10",children:(0,ey.jsx)("span",{className:"text-base font-semibold text-primary",children:e.name.charAt(0).toUpperCase()})}),(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,ey.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:e.email})]})]}),(0,ey.jsxs)(F3,{variant:"outline",className:"shrink-0",children:[(0,ey.jsx)(jb,{className:"mr-1 size-3"}),"已验证"]})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"用户 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[e.id.slice(0,8),"..."]})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(e.createdAt).toLocaleDateString("zh-CN")})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"此设备已自动注册到你的 Hub 账户。"})]}),c?(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:y,disabled:i,children:[i?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(x1,{}),i?"刷新中...":"刷新状态"]}):null]}),c?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[u?(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)(ez,{value:h,onChange:e=>p(e.target.value),maxLength:64,autoFocus:!0,placeholder:"机器名称",className:"h-8 text-sm",onKeyDown:e=>{"Enter"===e.key&&b(),"Escape"===e.key&&f(!1)}}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>void b(),disabled:m,"aria-label":"保存名称",children:m?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(pR,{})}),(0,ey.jsx)(eA.Button,{size:"icon-sm",variant:"ghost",className:"size-8 shrink-0",onClick:()=>f(!1),disabled:m,"aria-label":"取消",children:(0,ey.jsx)(fc.XIcon,{})})]}):(0,ey.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,ey.jsx)("p",{className:"truncate text-sm font-medium",children:c.name}),(0,ey.jsx)("button",{type:"button",onClick:function(){p(c?.name??""),x(null),f(!0)},title:"重命名",className:"shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,ey.jsx)(V6,{className:"size-3.5"})})]}),(0,ey.jsxs)("p",{className:"truncate text-xs text-muted-foreground",children:[c.platform," / ",c.arch]})]}),(0,ey.jsxs)(F3,{variant:"online"===c.status?"default":"secondary",className:"shrink-0 gap-1",children:["online"===c.status?(0,ey.jsx)(enO,{className:"size-3"}):(0,ey.jsx)(enP,{className:"size-3"}),"online"===c.status?"在线":"离线"]})]}),v?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:v}):null,(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"设备 ID"}),(0,ey.jsxs)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:[c.id.slice(0,8),"..."]})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接方式"}),(0,ey.jsx)("span",{className:"text-sm",children:c.connectivity||"直连"})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"本机 IP"}),(0,ey.jsx)("code",{className:"rounded bg-muted px-2 py-0.5 font-mono text-xs",children:c.localIp})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"最后心跳"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.lastHeartbeat).toLocaleString("zh-CN")})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"注册时间"}),(0,ey.jsx)("span",{className:"text-sm",children:new Date(c.createdAt).toLocaleString("zh-CN")})]})]}):(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[(0,ey.jsx)(enP,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsxs)("div",{children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"设备未绑定"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"设备注册异常,请尝试重新登录"})]})]})]}),(0,ey.jsx)(enI,{}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"hub-account-danger",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold text-destructive",children:"危险操作"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"以下操作不可逆,请谨慎执行。"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"解除设备绑定"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"将此设备从你的 Hub 账户中移除,并退出登录。设备数据不会受到影响。"})]}),(0,ey.jsxs)(dQ,{children:[(0,ey.jsx)(d0,{asChild:!0,children:(0,ey.jsxs)(eA.Button,{variant:"destructive",size:"sm",className:"shrink-0",children:[(0,ey.jsx)(enE,{}),"解除绑定"]})}),(0,ey.jsxs)(ul,{children:[(0,ey.jsxs)(us,{children:[(0,ey.jsx)(ud,{children:"确认解除设备绑定?"}),(0,ey.jsx)(uu,{children:"此操作将从你的 Hub 账户中移除当前设备,并退出登录。你可以随时重新登录并绑定设备。"})]}),(0,ey.jsxs)(uc,{children:[(0,ey.jsx)(uh,{children:"取消"}),(0,ey.jsx)(uf,{onClick:w,disabled:l,className:"bg-destructive text-white hover:bg-destructive/90",children:l?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"处理中..."]}):"确认解除"})]})]})]})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("p",{className:"text-sm font-medium",children:"退出登录"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"退出当前 Hub 账户但保留设备在云端的注册。下次登录时无需重新绑定。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:j,children:[(0,ey.jsx)(etl,{}),"退出登录"]})]})]})]})})}):null}function enI(){let[e,t]=ew.useState(""),[n,r]=ew.useState(""),[a,i]=ew.useState(""),[o,l]=ew.useState(!1),[s,c]=ew.useState(null);async function d(){if(c(null),n.length<8)return void c({kind:"err",text:"新密码至少 8 位"});if(n!==a)return void c({kind:"err",text:"两次输入的新密码不一致"});l(!0);try{await e1(e,n),c({kind:"ok",text:"密码已更新"}),t(""),r(""),i("")}catch(e){c({kind:"err",text:e instanceof Error?e.message:"修改失败,请重试"})}finally{l(!1)}}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(enM,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"修改密码"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"更改你的 Vantaloom Hub 登录密码。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(ez,{type:"password",placeholder:"当前密码",autoComplete:"current-password",value:e,onChange:e=>t(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"新密码(至少 8 位)",autoComplete:"new-password",value:n,onChange:e=>r(e.target.value)}),(0,ey.jsx)(ez,{type:"password",placeholder:"确认新密码",autoComplete:"new-password",value:a,onChange:e=>i(e.target.value)})]}),s?(0,ey.jsx)("p",{className:"ok"===s.kind?"text-xs text-primary":"text-xs text-destructive",children:s.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsx)(eA.Button,{size:"sm",onClick:d,disabled:o||!e||!n,children:o?(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)(eM,{className:"animate-spin"}),"保存中..."]}):"更新密码"})})]})}var enz=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=(0,l1.createSlot)(`Primitive.${t}`),r=ew.forwardRef((e,r)=>{let{asChild:a,...i}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,ey.jsx)(a?n:t,{...i,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),enT=ew.forwardRef((e,t)=>(0,ey.jsx)(enz.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));function enD({className:e,...t}){return(0,ey.jsx)(enT,{"data-slot":"label",className:(0,eI.cn)("flex w-fit items-center gap-2 text-sm font-medium leading-snug peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]/field:opacity-50",e),...t})}enT.displayName="Label";var en_=["PageUp","PageDown"],enR=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],enL={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},en$="Slider",[enF,enB,enV]=h$(en$),[enH,enU]=s7(en$,[enV]),[enW,enq]=enH(en$),enK=ew.forwardRef((e,t)=>{let{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:s=0,defaultValue:c=[r],value:d,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:h=!1,form:p,...m}=e,g=ew.useRef(new Set),v=ew.useRef(0),x="horizontal"===o,[y=[],b]=co({prop:d,defaultProp:c,onChange:e=>{let t=[...g.current];t[v.current]?.focus(),u(e)}}),w=ew.useRef(y);function j(e,t,{commit:n}={commit:!1}){let o,l=(String(i).split(".")[1]||"").length,c=pV(Math.round((Math.round((e-r)/i)*i+r)*(o=Math.pow(10,l)))/o,[r,a]);b((e=[])=>{let r=function(e=[],t,n){let r=[...e];return r[n]=t,r.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,n)=>e[n+1]-t))>=t;return!0}(r,s*i))return e;{v.current=r.indexOf(c);let t=String(r)!==String(e);return t&&n&&f(r),t?r:e}})}return(0,ey.jsx)(enW,{scope:e.__scopeSlider,name:n,disabled:l,min:r,max:a,valueIndexToChangeRef:v,thumbs:g.current,values:y,orientation:o,form:p,children:(0,ey.jsx)(enF.Provider,{scope:e.__scopeSlider,children:(0,ey.jsx)(enF.Slot,{scope:e.__scopeSlider,children:(0,ey.jsx)(x?enY:enZ,{"aria-disabled":l,"data-disabled":l?"":void 0,...m,ref:t,onPointerDown:ce(m.onPointerDown,()=>{l||(w.current=y)}),min:r,max:a,inverted:h,onSlideStart:l?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let n=e.map(e=>Math.abs(e-t)),r=Math.min(...n);return n.indexOf(r)}(y,e);j(e,t)},onSlideMove:l?void 0:function(e){j(e,v.current)},onSlideEnd:l?void 0:function(){let e=w.current[v.current];y[v.current]!==e&&f(y)},onHomeKeyDown:()=>!l&&j(r,0,{commit:!0}),onEndKeyDown:()=>!l&&j(a,y.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!l){let n=en_.includes(e.key)||e.shiftKey&&enR.includes(e.key),r=v.current;j(y[r]+i*(n?10:1)*t,r,{commit:!0})}}})})})})});enK.displayName=en$;var[enG,enX]=enH(en$,{startEdge:"left",endEdge:"right",size:"width",direction:1}),enY=ew.forwardRef((e,t)=>{let{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:s,onStepKeyDown:c,...d}=e,[u,f]=ew.useState(null),h=(0,s9.useComposedRefs)(t,e=>f(e)),p=ew.useRef(void 0),m=hU(a),g="ltr"===m,v=g&&!i||!g&&i;function x(e){let t=p.current||u.getBoundingClientRect(),a=en7([0,t.width],v?[n,r]:[r,n]);return p.current=t,a(e-t.left)}return(0,ey.jsx)(enG,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:(0,ey.jsx)(enJ,{dir:m,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);o?.(t)},onSlideMove:e=>{let t=x(e.clientX);l?.(t)},onSlideEnd:()=>{p.current=void 0,s?.()},onStepKeyDown:e=>{let t=enL[v?"from-left":"from-right"].includes(e.key);c?.({event:e,direction:t?-1:1})}})})}),enZ=ew.forwardRef((e,t)=>{let{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:s,...c}=e,d=ew.useRef(null),u=(0,s9.useComposedRefs)(t,d),f=ew.useRef(void 0),h=!a;function p(e){let t=f.current||d.current.getBoundingClientRect(),a=en7([0,t.height],h?[r,n]:[n,r]);return f.current=t,a(e-t.top)}return(0,ey.jsx)(enG,{scope:e.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:(0,ey.jsx)(enJ,{"data-orientation":"vertical",...c,ref:u,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=p(e.clientY);i?.(t)},onSlideMove:e=>{let t=p(e.clientY);o?.(t)},onSlideEnd:()=>{f.current=void 0,l?.()},onStepKeyDown:e=>{let t=enL[h?"from-bottom":"from-top"].includes(e.key);s?.({event:e,direction:t?-1:1})}})})}),enJ=ew.forwardRef((e,t)=>{let{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:s,...c}=e,d=enq(en$,n);return(0,ey.jsx)(cd.span,{...c,ref:t,onKeyDown:ce(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):en_.concat(enR).includes(e.key)&&(s(e),e.preventDefault())}),onPointerDown:ce(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():r(e)}),onPointerMove:ce(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:ce(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),i(e))})})}),enQ="SliderTrack",en0=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=enq(enQ,n);return(0,ey.jsx)(cd.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});en0.displayName=enQ;var en1="SliderRange",en2=ew.forwardRef((e,t)=>{let{__scopeSlider:n,...r}=e,a=enq(en1,n),i=enX(en1,n),o=ew.useRef(null),l=(0,s9.useComposedRefs)(t,o),s=a.values.length,c=a.values.map(e=>en8(e,a.min,a.max)),d=s>1?Math.min(...c):0,u=100-Math.max(...c);return(0,ey.jsx)(cd.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:l,style:{...e.style,[i.startEdge]:d+"%",[i.endEdge]:u+"%"}})});en2.displayName=en1;var en5="SliderThumb",en4=ew.forwardRef((e,t)=>{let n=enB(e.__scopeSlider),[r,a]=ew.useState(null),i=(0,s9.useComposedRefs)(t,e=>a(e)),o=ew.useMemo(()=>r?n().findIndex(e=>e.ref.current===r):-1,[n,r]);return(0,ey.jsx)(en3,{...e,ref:i,index:o})}),en3=ew.forwardRef((e,t)=>{var n,r,a,i,o;let l,s,{__scopeSlider:c,index:d,name:u,...f}=e,h=enq(en5,c),p=enX(en5,c),[m,g]=ew.useState(null),v=(0,s9.useComposedRefs)(t,e=>g(e)),x=!m||h.form||!!m.closest("form"),y=mY(m),b=h.values[d],w=void 0===b?0:en8(b,h.min,h.max),j=(n=d,(r=h.values.length)>2?`Value ${n+1} of ${r}`:2===r?["Minimum","Maximum"][n]:void 0),k=y?.[p.size],S=k?(a=k,i=w,o=p.direction,s=en7([0,50],[0,l=a/2]),(l-s(i)*o)*o):0;return ew.useEffect(()=>{if(m)return h.thumbs.add(m),()=>{h.thumbs.delete(m)}},[m,h.thumbs]),(0,ey.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[p.startEdge]:`calc(${w}% + ${S}px)`},children:[(0,ey.jsx)(enF.ItemSlot,{scope:e.__scopeSlider,children:(0,ey.jsx)(cd.span,{role:"slider","aria-label":e["aria-label"]||j,"aria-valuemin":h.min,"aria-valuenow":b,"aria-valuemax":h.max,"aria-orientation":h.orientation,"data-orientation":h.orientation,"data-disabled":h.disabled?"":void 0,tabIndex:h.disabled?void 0:0,...f,ref:v,style:void 0===b?{display:"none"}:e.style,onFocus:ce(e.onFocus,()=>{h.valueIndexToChangeRef.current=d})})}),x&&(0,ey.jsx)(en6,{name:u??(h.name?h.name+(h.values.length>1?"[]":""):void 0),form:h.form,value:b},d)]})});en4.displayName=en5;var en6=ew.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{let a=ew.useRef(null),i=(0,s9.useComposedRefs)(a,r),o=gi(t);return ew.useEffect(()=>{let e=a.current;if(!e)return;let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(o!==t&&n){let r=new Event("input",{bubbles:!0});n.call(e,t),e.dispatchEvent(r)}},[o,t]),(0,ey.jsx)(cd.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});function en8(e,t,n){return pV(100/(n-t)*(e-t),[0,100])}function en7(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function en9(e){return Array.isArray(e)?e:"number"==typeof e?[e]:void 0}function ere({className:e,defaultValue:t,value:n,min:r=0,max:a=100,...i}){let o=ew.useMemo(()=>en9(n)??en9(t)??[r,a],[t,a,r,n]);return(0,ey.jsxs)(enK,{"data-slot":"slider",defaultValue:en9(t),value:en9(n),min:r,max:a,className:(0,eI.cn)("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...i,children:[(0,ey.jsx)(en0,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1",children:(0,ey.jsx)(en2,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),o.map((e,t)=>(0,ey.jsx)(en4,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white shadow-sm transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 hover:ring-ring/50 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden active:ring-3 active:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-primary-foreground"},t))]})}en6.displayName="RadioBubbleInput";let ert=[1e4,3e4,12e4,3e5,6e5];function ern(e){return{compression:{...e.compression},summary:{...e.summary},approval:{...e.approval},behavior:{maxToolCalls:e.behavior?.maxToolCalls??20,retryCount:e.behavior?.retryCount??0,retryDelaysMs:e.behavior?.retryDelaysMs??[]}}}function err(e){return(e&&e.length?e:ert).map(e=>Math.round(e/1e3)).join(", ")}function era(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1),[f,h]=ew.useState("");function p(e,n){t(t=>t?{...t,[e]:{...t[e],...n}}:t),u(!0)}async function m(){if(e&&!o){l(!0),c("");try{let n=await w3({compression:e.compression,summary:e.summary,approval:e.approval,behavior:e.behavior});t(ern(n)),h(err(n.behavior?.retryDelaysMs)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return(ew.useEffect(()=>{!async function(){try{let[e,n]=await Promise.all([w4(),vC()]);t(ern(e)),h(err(e.behavior?.retryDelaysMs)),r(n.models)}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"代理配置"})}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void m(),disabled:o,children:[(0,ey.jsx)(KR,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"错误"}),(0,ey.jsx)(Ji,{children:s})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-compression",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"压缩上下文"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"当对话 token 达到模型上下文窗口的指定百分比时自动压缩。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"自动压缩阈值"}),(0,ey.jsxs)("span",{className:"text-sm tabular-nums text-muted-foreground",children:[e.compression.autoThresholdPercent,"%"]})]}),(0,ey.jsx)(ere,{value:[e.compression.autoThresholdPercent],onValueChange:([e])=>p("compression",{autoThresholdPercent:e}),min:0,max:100,step:5}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"0% 表示禁用自动压缩。建议设为 70%-85%。"})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"压缩模型"}),(0,ey.jsx)(eri,{models:n,value:e.compression.modelRef,onValueChange:e=>p("compression",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于执行上下文压缩的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-summary",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"对话摘要"}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"对话标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"每轮对话结束后自动更新对话标题。"})]}),(0,ey.jsx)(xR,{checked:e.summary.enableTitleSummary,onCheckedChange:e=>p("summary",{enableTitleSummary:e})})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"轮次标题摘要"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"为每轮 agent 操作生成摘要标题。"})]}),(0,ey.jsx)(xR,{checked:e.summary.enableRoundSummary,onCheckedChange:e=>p("summary",{enableRoundSummary:e})})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(eri,{models:n,value:e.summary.modelRef,onValueChange:e=>p("summary",{modelRef:e}),placeholder:"使用主模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用于生成对话摘要的模型。留空则使用当前对话主模型。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自动重试与工具调用上限"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"控制本机(vantaloom)agent 单次运行的工具调用上限,以及请求失败后的自动重试。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"最大工具调用次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.maxToolCalls,onChange:e=>p("behavior",{maxToolCalls:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"单次运行累计调用工具达到该次数后强制暂停(可点击“继续”恢复)。设为 0 表示不限次。默认 20。"})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"自动重试次数"}),(0,ey.jsx)(ez,{type:"number",min:0,value:e.behavior.retryCount,onChange:e=>p("behavior",{retryCount:Math.max(0,Number.parseInt(e.currentTarget.value,10)||0)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型/服务商请求失败时自动重试的次数(仅在尚未产出内容时重试,避免重复输出)。设为 0 表示不重试。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"重试间隔梯度(秒)"}),(0,ey.jsx)(ez,{value:f,onChange:e=>{let t=e.currentTarget.value;h(t),p("behavior",{retryDelaysMs:t.split(/[,,\s]+/).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isFinite(e)&&e>0).map(e=>1e3*e)})},placeholder:"10, 30, 120, 300, 600"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"用逗号分隔每次重试的等待秒数(指数级递增),例如 10, 30, 120, 300, 600。超出列表长度时使用最后一项。留空使用内置默认梯度。"})]})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"agent-config-approval",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"命令审批"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"在 Auto 权限模式下,使用 AI 模型审批 Agent 发起的命令是否可以自动执行。"}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"审批模型"}),(0,ey.jsx)(eri,{models:n,value:e.approval.modelRef,onValueChange:e=>p("approval",{modelRef:e}),placeholder:"未配置(全部放行)"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空表示 Auto 模式下不进行 AI 审批,所有非危险命令自动放行。"})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"审批提示词"}),(0,ey.jsx)(bq,{value:e.approval.prompt,onChange:e=>p("approval",{prompt:e.currentTarget.value}),placeholder:"可选:给审批模型的额外指导,例如允许哪些操作、拒绝哪些操作",rows:4,className:"resize-none text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"与系统提示词一起发送给审批模型,帮助它判断命令是否安全。"})]})]})]}):(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"读取失败"}),(0,ey.jsx)(Ji,{children:s||"无法加载代理配置"})]})}function eri({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.label},e.id))]})]})}let ero=(0,ek.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var erl="Accordion",ers=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[erc,erd,eru]=h$(erl),[erf,erh]=s7(erl,[eru,etg]),erp=etg(),erm=ew.default.forwardRef((e,t)=>{let{type:n,...r}=e;return(0,ey.jsx)(erc.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,ey.jsx)(erw,{...r,ref:t}):(0,ey.jsx)(erb,{...r,ref:t})})});erm.displayName=erl;var[erg,erv]=erf(erl),[erx,ery]=erf(erl,{collapsible:!1}),erb=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},collapsible:i=!1,...o}=e,[l,s]=co({prop:n,defaultProp:r??"",onChange:a,caller:erl});return(0,ey.jsx)(erg,{scope:e.__scopeAccordion,value:ew.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:s,onItemClose:ew.default.useCallback(()=>i&&s(""),[i,s]),children:(0,ey.jsx)(erx,{scope:e.__scopeAccordion,collapsible:i,children:(0,ey.jsx)(erS,{...o,ref:t})})})}),erw=ew.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,l]=co({prop:n,defaultProp:r??[],onChange:a,caller:erl}),s=ew.default.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=ew.default.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return(0,ey.jsx)(erg,{scope:e.__scopeAccordion,value:o,onItemOpen:s,onItemClose:c,children:(0,ey.jsx)(erx,{scope:e.__scopeAccordion,collapsible:!0,children:(0,ey.jsx)(erS,{...i,ref:t})})})}),[erj,erk]=erf(erl),erS=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:r,dir:a,orientation:i="vertical",...o}=e,l=ew.default.useRef(null),s=(0,s9.useComposedRefs)(l,t),c=erd(n),d="ltr"===hU(a),u=ce(e.onKeyDown,e=>{if(!ers.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),a=n.length;if(-1===r)return;e.preventDefault();let o=r,l=a-1,s=()=>{(o=r+1)>l&&(o=0)},u=()=>{(o=r-1)<0&&(o=l)};switch(e.key){case"Home":o=0;break;case"End":o=l;break;case"ArrowRight":"horizontal"===i&&(d?s():u());break;case"ArrowDown":"vertical"===i&&s();break;case"ArrowLeft":"horizontal"===i&&(d?u():s());break;case"ArrowUp":"vertical"===i&&u()}let f=o%a;n[f].ref.current?.focus()});return(0,ey.jsx)(erj,{scope:n,disabled:r,direction:a,orientation:i,children:(0,ey.jsx)(erc.Slot,{scope:n,children:(0,ey.jsx)(cd.div,{...o,"data-orientation":i,ref:s,onKeyDown:r?void 0:u})})})}),erN="AccordionItem",[erC,erM]=erf(erN),erE=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:r,...a}=e,i=erk(erN,n),o=erv(erN,n),l=erp(n),s=ca(),c=r&&o.value.includes(r)||!1,d=i.disabled||e.disabled;return(0,ey.jsx)(erC,{scope:n,open:c,disabled:d,triggerId:s,children:(0,ey.jsx)(ety,{"data-orientation":i.orientation,"data-state":erD(c),...l,...a,ref:t,disabled:d,open:c,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})});erE.displayName=erN;var erO="AccordionHeader",erP=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erk(erl,n),i=erM(erO,n);return(0,ey.jsx)(cd.h3,{"data-orientation":a.orientation,"data-state":erD(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});erP.displayName=erO;var erA="AccordionTrigger",erI=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erk(erl,n),i=erM(erA,n),o=ery(erA,n),l=erp(n);return(0,ey.jsx)(erc.ItemSlot,{scope:n,children:(0,ey.jsx)(etw,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...r,ref:t})})});erI.displayName=erA;var erz="AccordionContent",erT=ew.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...r}=e,a=erk(erl,n),i=erM(erz,n),o=erp(n);return(0,ey.jsx)(etk,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function erD(e){return e?"open":"closed"}function er_({...e}){return(0,ey.jsx)(erm,{"data-slot":"accordion",...e})}function erR({className:e,...t}){return(0,ey.jsx)(erE,{"data-slot":"accordion-item",className:(0,eI.cn)("border-b last:border-b-0",e),...t})}function erL({className:e,children:t,...n}){return(0,ey.jsx)(erP,{className:"flex",children:(0,ey.jsxs)(erI,{"data-slot":"accordion-trigger",className:(0,eI.cn)("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,(0,ey.jsx)(g8,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"})]})})}function er$({className:e,children:t,...n}){return(0,ey.jsx)(erT,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-out data-[state=open]:animate-in",...n,children:(0,ey.jsx)("div",{className:(0,eI.cn)("pb-4 pt-0 text-muted-foreground",e),children:t})})}erT.displayName=erz;let erF={vantaloom:"Vantaloom","claude-code":"Claude Code",reclaude:"reclaude"};function erB(e){return{...e.claudeCode??{}}}function erV(e,t){if(e.reclaudeExecutable)return e;let n=t.find(e=>"reclaude"===e.engine);return n?.available&&n.detail?{...e,reclaudeExecutable:n.detail}:e}function erH(){let[e,t]=ew.useState(null),[n,r]=ew.useState([]),[a,i]=ew.useState([]),[o,l]=ew.useState(!0),[s,c]=ew.useState(!1),[d,u]=ew.useState(!1),[f,h]=ew.useState(""),[p,m]=ew.useState(!1);async function g(){if(!d){u(!0),h("");try{let e=(await w8()).engines??[];r(e),t(t=>t?erV(t,e):t)}catch(e){h(e instanceof Error?e.message:"适配器安装失败")}finally{u(!1)}}}function v(e){t(t=>t?{...t,...e}:t),m(!0)}ew.useEffect(()=>{!async function(){try{let[e,n,a]=await Promise.all([w4(),w6(),vC()]),o=n.engines??[];t(erV(erB(e),o)),r(o),i(a.models)}catch(e){h(e instanceof Error?e.message:"Failed to load config")}finally{l(!1)}}()},[]);let x=e?.adapterArgs?.[0]??"";async function y(){if(e&&!s){c(!0),h("");try{let n=await w3({claudeCode:e});t(erB(n)),m(!1)}catch(e){h(e instanceof Error?e.message:"Save failed")}finally{c(!1)}}}return o?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取引擎配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"CC 引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"配置 Claude Code / reclaude 引擎。展开下方分组按需修改,留空项将自动发现。"})]}),p&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void y(),disabled:s,children:[(0,ey.jsx)(KR,{className:"size-4"}),s?"保存中":"保存"]})]}),f?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"错误"}),(0,ey.jsx)(Ji,{children:f})]}):null,(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"检测到的引擎"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"本机当前可用的 Agent 运行引擎。不可用的引擎会说明原因。"})]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void g(),disabled:d,children:[d?(0,ey.jsx)(eM,{className:"size-4 animate-spin"}):(0,ey.jsx)(xB,{className:"size-4"}),d?"安装中…":"下载/安装适配器"]})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"Claude Code / reclaude 需要 ACP 适配器。运行时不再内置它(以减小体积), 点击上方按钮即可在后台静默下载安装;安装后无需手填路径即可使用。"}),(0,ey.jsx)("div",{className:"grid gap-2",children:0===n.length?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"未检测到引擎信息。"}):n.map(e=>(0,ey.jsxs)("div",{className:"grid gap-1 rounded-md border bg-background p-3",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsx)("span",{className:"text-sm font-medium",children:erF[e.engine]??e.engine}),(0,ey.jsxs)("span",{className:(0,eI.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium [&_svg]:size-3",e.available?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-destructive/10 text-destructive"),children:[e.available?(0,ey.jsx)(eO,{}):(0,ey.jsx)(ero,{}),e.available?"可用":"不可用"]})]}),e.reason?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.reason}):null,e.detail?(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/80",children:e.detail}):null]},e.engine))})]}),(0,ey.jsx)("section",{className:"rounded-lg border bg-card px-4",children:(0,ey.jsxs)(er_,{type:"multiple",className:"w-full",children:[(0,ey.jsxs)(erR,{value:"adapter",children:[(0,ey.jsx)(erL,{children:"适配器"}),(0,ey.jsxs)(er$,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"适配器命令"}),(0,ey.jsx)(ez,{value:e.adapterCommand??"",onChange:e=>v({adapterCommand:e.currentTarget.value}),placeholder:"node"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动使用 node 运行适配器。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"适配器入口 (…/@zed-industries/claude-code-acp/dist/index.js)"}),(0,ey.jsx)(ez,{value:x,onChange:e=>{let t=e.currentTarget.value;v({adapterArgs:t?[t]:[]})},placeholder:"…/@zed-industries/claude-code-acp/dist/index.js"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则自动发现(随运行时安装或环境变量 VANTALOOM_CC_ADAPTER)。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"Git Bash 路径"}),(0,ey.jsx)(ez,{value:e.gitBashPath??"",onChange:e=>v({gitBashPath:e.currentTarget.value}),placeholder:"C:\\\\Program Files\\\\Git\\\\bin\\\\bash.exe"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"Windows 专用,留空自动发现。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"reclaude 可执行文件"}),(0,ey.jsx)(ez,{value:e.reclaudeExecutable??"",onChange:e=>v({reclaudeExecutable:e.currentTarget.value}),placeholder:"reclaude"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"reclaude 可执行文件(或 node shim)路径;自动发现到 reclaude 时会自动填入, 会通过内置 shim 启动。留空则自动发现。"})]})]})]}),(0,ey.jsxs)(erR,{value:"auth",children:[(0,ey.jsx)(erL,{children:"认证"}),(0,ey.jsxs)(er$,{className:"grid gap-4 text-foreground",children:[(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"API Key"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.apiKey??"",onChange:e=>v({apiKey:e.currentTarget.value}),placeholder:"claude-code 引擎用;留空可用 claude /login"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"claude-code 引擎用;留空可使用 claude /login 登录。"})]}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"OAuth Token"}),(0,ey.jsx)(ez,{type:"password",autoComplete:"off",value:e.oauthToken??"",onChange:e=>v({oauthToken:e.currentTarget.value}),placeholder:"留空使用其它认证方式"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"可选的 OAuth Token,作为 API Key 之外的认证方式。"})]})]})]}),(0,ey.jsxs)(erR,{value:"summary",children:[(0,ey.jsx)(erL,{children:"摘要模型"}),(0,ey.jsx)(er$,{className:"grid gap-4 text-foreground",children:(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"摘要模型"}),(0,ey.jsx)(erU,{models:a,value:e.summaryModelRef??"",onValueChange:e=>v({summaryModelRef:e}),placeholder:"使用默认"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"CC 会话标题/摘要用的 Vantaloom 模型路由。"})]})})]})]})})]}):(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"读取失败"}),(0,ey.jsx)(Ji,{children:f||"无法加载引擎配置"})]})}function erU({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.label},e.id))]})]})}let erW=[{id:"card",label:"卡片布局",description:"圆角卡片自由排布,右上角下拉菜单按需添加单窗口。",icon:(0,ey.jsx)(eto,{})},{id:"pane",label:"分屏布局",description:"传统多窗格 + 顶部分屏预设,可拖拽分割线调整。",icon:(0,ey.jsx)(HT,{})},{id:"control-room",label:"导播台视角",description:"隐藏窗格,右侧以监视器墙并排查看主代理与各子代理。",icon:(0,ey.jsx)(eP,{})}],erq=[{id:"left",label:"Agent 在左",icon:(0,ey.jsx)(s2,{})},{id:"right",label:"Agent 在右",icon:(0,ey.jsx)(s4,{})}];function erK(){let[e,t]=ew.useState("pane"),[n,r]=ew.useState("left");return ew.useEffect(()=>{let e=ZY();t(e.mode),r(e.agentSide)},[]),(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"布局排版"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅电脑端生效。切换 Agent 工作区的窗口布局与 Agent 对话的位置,设置即时应用到所有会话。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"布局模式"}),(0,ey.jsx)("div",{className:"grid gap-2 sm:grid-cols-3",children:erW.map(n=>{let r=e===n.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var e;t(e=n.id),ZZ({mode:e})},className:(0,eI.cn)("flex flex-col gap-2 rounded-lg border p-3 text-left transition-colors [&_svg]:size-5",r?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":r,children:[(0,ey.jsx)("span",{className:(0,eI.cn)("grid size-9 place-items-center rounded-md",r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:n.icon}),(0,ey.jsx)("span",{className:"text-sm font-medium text-foreground",children:n.label}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:n.description})]},n.id)})})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"Agent 对话位置"}),(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:erq.map(e=>{let t=n===e.id;return(0,ey.jsxs)("button",{type:"button",onClick:()=>{var t;r(t=e.id),ZZ({agentSide:t})},className:(0,eI.cn)("inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors [&_svg]:size-4",t?"border-primary bg-primary/5 text-foreground":"border-border bg-background text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-pressed":t,children:[e.icon,e.label]},e.id)})})]})]})}let erG=[{value:"openai-v1",label:"OpenAI v1"},{value:"anthropic",label:"Anthropic"},{value:"openai-responses",label:"OpenAI Responses"}];function erX(e){return{id:e.id,providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:"",models:e.models,selectedModelIds:e.selectedModelIds,builtin:e.builtin,loadingModels:!1,saving:!1,error:e.lastError??"",savedKeyAvailable:!0,editing:!1}}function erY(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),[a,i]=ew.useState(""),o=ew.useCallback(async()=>{i("");try{let e=await vC();t(e.routes.map(erX))}catch(e){i(e instanceof Error?e.message:"模型路由读取失败")}finally{r(!1)}},[]);function l(e,n){t(t=>t.map((t,r)=>r===e?n(t):t))}async function s(t){let n=e[t];if(n&&!n.saving){l(t,e=>({...e,saving:!0,error:""}));try{let e=await vE({id:n.id,providerName:n.providerName,protocol:n.protocol,endpointUrl:n.endpointUrl,apiKey:n.apiKey,models:n.models,selectedModelIds:n.selectedModelIds});l(t,()=>erX(e))}catch(e){l(t,t=>({...t,saving:!1,error:e instanceof Error?e.message:"保存失败"}))}}}async function c(n){let r=e[n];if(r&&!r.saving){if(!r.id)return void t(e=>e.filter((e,t)=>t!==n));l(n,e=>({...e,saving:!0,error:""}));try{await vO(r.id),t(e=>e.filter((e,t)=>t!==n))}catch(e){l(n,t=>({...t,saving:!1,error:e instanceof Error?e.message:"删除失败"}))}}}return ew.useEffect(()=>{o()},[o]),ew.useEffect(()=>{let e=!1,n=window.setInterval(()=>{(async()=>{try{let n=await vC();if(e)return;let r=n.routes.find(e=>e.builtin);t(e=>{let t=e.some(e=>e.builtin);return r?t?e.map(e=>e.builtin?{...e,providerName:r.providerName,models:r.models,selectedModelIds:r.selectedModelIds,error:r.lastError??""}:e):[erX(r),...e]:t?e.filter(e=>!e.builtin):e})}catch{}})()},3e4);return()=>{e=!0,window.clearInterval(n)}},[]),(0,ey.jsxs)("div",{className:"grid gap-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsx)("div",{className:"min-w-0",children:(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"模型路由"})}),(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:function(){t(e=>[{providerName:"",protocol:"openai-v1",endpointUrl:"",apiKey:"",models:[],selectedModelIds:[],loadingModels:!1,saving:!1,error:"",editing:!0},...e])},"data-tour":"add-model-route",children:[(0,ey.jsx)(lJ,{className:"size-4"}),"添加模型路由"]})]}),a?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"读取失败"}),(0,ey.jsx)(Ji,{children:a})]}):null,n?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取模型路由"}):0===e.length?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"还没有模型路由。"}):(0,ey.jsx)("div",{className:"grid gap-3",children:e.map((e,t)=>(0,ey.jsx)(erZ,{draft:e,onDraftChange:e=>l(t,()=>e),onSave:()=>{s(t)},onDelete:()=>{c(t)}},e.id??`draft-${t}`))})]})}function erZ({draft:e,onDraftChange:t,onSave:n,onDelete:r}){let a=ew.useRef(e),i=ew.useRef(t),o=[e.providerName,e.protocol,e.endpointUrl,e.apiKey||(e.savedKeyAvailable?"saved":"")].join("\n"),l=e.providerName.trim()&&e.endpointUrl.trim()&&e.apiKey.trim(),s=e.providerName.trim()&&e.endpointUrl.trim()&&(e.apiKey.trim()||e.savedKeyAvailable)&&e.selectedModelIds.length>0&&!e.saving;function c(n){t({...e,...n})}if(ew.useEffect(()=>{a.current=e,i.current=t},[e,t]),ew.useEffect(()=>{if(!l)return;let e=window.setTimeout(async()=>{let e=a.current;i.current({...e,loadingModels:!0,error:""});try{let t=await vM({providerName:e.providerName,protocol:e.protocol,endpointUrl:e.endpointUrl,apiKey:e.apiKey}),n=e.selectedModelIds.filter(e=>t.models.some(t=>t.id===e));i.current({...e,models:t.models,selectedModelIds:n,loadingModels:!1,error:""})}catch(t){i.current({...e,loadingModels:!1,error:t instanceof Error?t.message:"模型拉取失败"})}},650);return()=>window.clearTimeout(e)},[l,o]),!e.editing||e.builtin){let t=e.selectedModelIds.map(t=>e.models.find(e=>e.id===t)?.displayName||t).filter(Boolean),n=erG.find(t=>t.value===e.protocol)?.label??e.protocol;return(0,ey.jsxs)("section",{className:"grid min-h-16 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border bg-card px-3 py-2.5",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.builtin?(0,ey.jsx)(lK,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.providerName}),e.builtin?(0,ey.jsx)("span",{className:"ui-text-kbd rounded-full bg-muted px-2 py-0.5 text-muted-foreground",children:"官渠"}):null,(0,ey.jsx)("span",{className:"ui-text-kbd text-muted-foreground",children:n})]}),(0,ey.jsx)("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:t.length>0?t.join(", "):"未选择模型"})]}),e.builtin?null:(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>c({editing:!0}),children:[(0,ey.jsx)(V6,{className:"size-4"}),"编辑"]})]})}return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-3","data-tour":"model-route-form",children:[(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_11rem]",children:[(0,ey.jsx)(ez,{value:e.providerName,placeholder:"提供商名称",onChange:e=>c({providerName:e.currentTarget.value})}),(0,ey.jsxs)(gb,{value:e.protocol,onValueChange:e=>c({protocol:e}),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:erG.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)]",children:[(0,ey.jsx)(ez,{value:e.endpointUrl,placeholder:"API 端点 URL,例如 https://api.openai.com/v1",onChange:e=>c({endpointUrl:e.currentTarget.value})}),(0,ey.jsx)(ez,{value:e.apiKey,type:"password",placeholder:e.savedKeyAvailable?"已保存,留空沿用":"API Key",onChange:e=>c({apiKey:e.currentTarget.value})})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-h-6 items-center justify-between gap-2",children:[(0,ey.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-medium",children:[(0,ey.jsx)(p_,{className:"size-4 text-muted-foreground"}),"可用模型"]}),e.loadingModels?(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"拉取中"}):null]}),e.models.length>0?(0,ey.jsx)("div",{className:"grid max-h-64 gap-1 overflow-auto pr-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.models.map(t=>{let n=e.selectedModelIds.includes(t.id);return(0,ey.jsxs)("div",{className:(0,eI.cn)("grid min-h-8 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 text-sm hover:bg-muted/60",n&&"bg-muted/70"),children:[(0,ey.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,ey.jsx)(vN,{checked:n,onCheckedChange:n=>{var r;return r=t.id,void c({selectedModelIds:!0===n?[...e.selectedModelIds,r]:e.selectedModelIds.filter(e=>e!==r)})}}),(0,ey.jsx)("span",{className:"truncate",children:t.displayName||t.id})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ey.jsx)(ez,{type:"number",className:"h-6 w-16 px-1.5 text-center text-xs tabular-nums",value:t.contextLength||200,min:1,max:1e4,onChange:n=>{var r,a;return r=t.id,a=Number.parseInt(n.currentTarget.value,10)||0,void c({models:e.models.map(e=>e.id===r?{...e,contextLength:a>0?a:void 0}:e)})}}),(0,ey.jsx)("span",{className:"text-xs text-muted-foreground",children:"k"})]})]},t.id)})}):(0,ey.jsx)("div",{className:"rounded-md border border-dashed px-3 py-4 text-sm text-muted-foreground",children:"填写端点和密钥后会自动拉取模型。"})]}),e.error?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"模型路由错误"}),(0,ey.jsx)(Ji,{className:"break-words",children:e.error})]}):null,(0,ey.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,ey.jsxs)(eA.Button,{type:"button",variant:"destructive",onClick:r,disabled:e.saving,children:[(0,ey.jsx)(x2,{className:"size-4"}),"删除"]}),(0,ey.jsx)(eA.Button,{type:"button",onClick:n,disabled:!s,children:e.saving?"保存中":"保存"})]})]})}async function erJ(){return er0("/api/local/subagent-config")}async function erQ(e){return er0("/api/local/subagent-config",{method:"PUT",body:JSON.stringify(e)})}async function er0(e,t){let n=await fetch(eD(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"subagent config api failed");return r}function er1(e){return{explore:{...e.explore},workflow:{...e.workflow},operator:{...e.operator},custom:{...e.custom,models:[...e.custom.models??[]]}}}let er2={explore:{title:"探索子代理",icon:(0,ey.jsx)(Vo,{className:"size-4"}),tint:"text-sky-600 dark:text-sky-400",description:"只读的代码库探索/调研专家。彻底阅读、搜索代码库,返回带文件路径+行号引用的完整结论,替主 agent 节省上下文。",tools:"仅阅读(vantaloom_read)"},workflow:{title:"工作流子代理",icon:(0,ey.jsx)(uk,{className:"size-4"}),tint:"text-violet-600 dark:text-violet-400",description:"按 workflow-*.yml 严格执行可重复的多步流程,并把其中确定性的步骤自动固化为脚本、给 yml 添加批注。",tools:"阅读 / 编辑 / 终端(vantaloom_read · vantaloom_edit · vantaloom_shell)"},operator:{title:"操作员子代理",icon:(0,ey.jsx)(uj,{className:"size-4"}),tint:"text-pink-600 dark:text-pink-400",description:"专门驱动交互式终端(未来含浏览器)。执行大量终端操作并把结果回报给主 agent。",tools:"阅读 / 终端(vantaloom_read · vantaloom_shell)"}};function er5(){let[e,t]=ew.useState(null),{models:n,loading:r}=vI(),[a,i]=ew.useState(!0),[o,l]=ew.useState(!1),[s,c]=ew.useState(""),[d,u]=ew.useState(!1);async function f(){if(e&&!o){l(!0),c("");try{let n=await erQ({explore:e.explore,workflow:e.workflow,operator:e.operator,custom:e.custom});t(er1(n)),u(!1)}catch(e){c(e instanceof Error?e.message:"Save failed")}finally{l(!1)}}}return ew.useEffect(()=>{!async function(){try{let e=await erJ();t(er1(e))}catch(e){c(e instanceof Error?e.message:"Failed to load config")}finally{i(!1)}}()},[]),a?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取子代理配置"}):e?(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"子代理配置"}),(0,ey.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"主 agent 可以派发这些子代理来分担任务。每个子代理拥有独立上下文与受限工具集,完成后只把结果汇报给主 agent。"})]}),d&&(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void f(),disabled:o,children:[(0,ey.jsx)(KR,{className:"size-4"}),o?"保存中":"保存"]})]}),s?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"错误"}),(0,ey.jsx)(Ji,{children:s})]}):null,["explore","workflow","operator"].map(a=>(0,ey.jsx)(er4,{tourId:`subagent-${a}`,meta:er2[a],value:e[a],models:n,modelsLoading:r,onChange:e=>{t(t=>t?{...t,[a]:{...t[a],...e}}:t),u(!0)}},a)),(0,ey.jsx)(er3,{value:e.custom,models:n,modelsLoading:r,onChange:function(e){t(t=>t?{...t,custom:{...t.custom,...e}}:t),u(!0)}})]}):(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"读取失败"}),(0,ey.jsx)(Ji,{children:s||"无法加载子代理配置"})]})}function er4({meta:e,value:t,models:n,modelsLoading:r,onChange:a,tourId:i}){return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":i,children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:e.tint,children:e.icon}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:e.title})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description}),(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,ey.jsx)("span",{className:"text-foreground/70",children:"可用工具:"}),e.tools,(0,ey.jsx)("span",{className:"ml-1 text-muted-foreground/70",children:"(固定,不可更改)"})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"使用模型"}),(0,ey.jsx)(er6,{models:n,value:t.modelRef,onValueChange:e=>a({modelRef:e}),placeholder:r?"读取模型中":"继承上级模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"留空则继承派发它的上级 agent 当前使用的模型。"})]}),(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"允许上级指定模型"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"开启后,上级 agent 可在派发时动态指定该子代理使用的模型。"})]}),(0,ey.jsx)(xR,{checked:t.allowCallerModel,onCheckedChange:e=>a({allowCallerModel:e})})]}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"系统提示词"}),t.promptOverride?(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>a({promptOverride:""}),children:"恢复默认"}):null]}),(0,ey.jsx)(bq,{value:t.promptOverride,onChange:e=>a({promptOverride:e.currentTarget.value}),placeholder:"留空使用内置默认提示词;在此输入将覆盖默认提示词(环境/工具说明仍会自动附加)。",rows:t.promptOverride?10:3,className:"resize-y text-sm"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"覆盖该官方子代理的预设系统提示词。派发时还会自动附加工作区、操作系统与工具使用说明。"})]})]})}function er3({value:e,models:t,modelsLoading:n,onChange:r}){let a=ew.useCallback(e=>t.find(t=>t.value===e)?.label??e,[t]);return(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4","data-tour":"subagent-custom",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:(0,ey.jsx)(um,{className:"size-4"})}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"自定义子代理"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 可以自取名字、从下面的模型池中选一个模型来召唤自定义子代理,并可选择是否继承当前对话上下文。自定义子代理拥有完整工具集,还能进一步派发上面三种官方子代理。"}),(0,ey.jsx)(Q4,{}),(0,ey.jsxs)("div",{className:"grid gap-2",children:[(0,ey.jsx)(enD,{className:"text-sm",children:"可用模型池"}),(0,ey.jsx)(x_,{variant:"list-combobox",value:e.models,onValueChange:e=>r({models:e}),options:t,placeholder:n?"读取模型中":"选择可供自定义子代理使用的模型",searchPlaceholder:"搜索模型...",emptyText:"没有可用模型",renderItem:a}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"主 agent 召唤自定义子代理时会从这个池中选择一个模型。留空则沿用上级 agent 的模型。"})]})]})}function er6({models:e,value:t,onValueChange:n,placeholder:r}){return(0,ey.jsxs)(gb,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{placeholder:r})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"__none__",children:r}),e.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))]})]})}function er8(){let[e,t]=ew.useState(""),[n,r]=ew.useState(!0),[a,i]=ew.useState(!1),[o,l]=ew.useState(!1),[s,c]=ew.useState("");async function d(){if(!a){i(!0),c("");try{await w3({systemPrompt:{userPrompt:e}}),l(!1)}catch(e){c(e instanceof Error?e.message:"保存失败")}finally{i(!1)}}}return(ew.useEffect(()=>{(async()=>{try{let e=await w4();t(e.systemPrompt?.userPrompt??"")}catch(e){c(e instanceof Error?e.message:"加载失败")}finally{r(!1)}})()},[]),n)?(0,ey.jsx)("div",{className:"rounded-lg border border-dashed px-3 py-6 text-sm text-muted-foreground",children:"正在读取系统提示词配置"}):(0,ey.jsxs)("div",{className:"grid gap-6",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"兜底系统提示词"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"仅对 vantaloom 引擎对话生效。当某个对话未检测到任何项目文档(CLAUDE.md / AGENTS.md / vantaloom.md),也没有在该对话的“系统提示词”里单独设置时, 才使用这里的内容作为兜底。各对话独立的系统提示词请到对话设置 → 系统提示词中配置。"})]}),o?(0,ey.jsxs)(eA.Button,{type:"button",size:"sm",onClick:()=>void d(),disabled:a,children:[(0,ey.jsx)(KR,{className:"size-4"}),a?"保存中":"保存"]}):null]}),s?(0,ey.jsxs)(Jr,{variant:"destructive",children:[(0,ey.jsx)(eE,{}),(0,ey.jsx)(Ja,{children:"错误"}),(0,ey.jsx)(Ji,{children:s})]}):null,(0,ey.jsx)(bq,{value:e,onChange:e=>{t(e.currentTarget.value),l(!0)},placeholder:"例如:始终用中文回复;提交前先跑测试;优先复用现有代码……",rows:8,className:"resize-y text-sm"})]})}function er7({section:e}={}){return(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsx)("div",{className:"mx-auto w-full max-w-3xl","data-tour":`preferences-${e??"model-routes"}`,children:"agent-config"===e?(0,ey.jsx)(era,{}):"subagent-config"===e?(0,ey.jsx)(er5,{}):"cc-engine-config"===e?(0,ey.jsx)(erH,{}):"system-prompt"===e?(0,ey.jsx)(er8,{}):"layout"===e?(0,ey.jsx)(erK,{}):(0,ey.jsx)(erY,{})})})}let er9=(0,ek.default)("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);function eae(e,t){if(e.isLocal)return eD(t);let n=t.replace(/^\/v1(?=\/)/,"");return eD(`/v1/remote/${e.id}${n}`)}async function eat(e){try{let t=await fetch(`https://registry.npmjs.org/@vantaloom/runtime-${e}`,{headers:{Accept:"application/vnd.npm.install-v1+json"},cache:"no-store"});if(!t.ok)return;let n=await t.json();return n?.["dist-tags"]?.latest}catch{return}}function ean(){let[e,t]=ew.useState([]),[n,r]=ew.useState(!0),a=ew.useRef(!0),i=ew.useCallback((e,n)=>{t(t=>t.map(t=>t.machine.id===e?{...t,...n}:t))},[]),o=ew.useCallback(async()=>{r(!0);let e=[];try{let t=await fetch(eD("/v1/remote/machines"),{cache:"no-store"});e=(await t.json()).machines??[]}catch{e=[]}a.current&&(t(e.map(e=>({machine:e,loading:!0}))),r(!1),await Promise.all(e.map(async e=>{if(!e.isLocal&&"online"!==e.status){a.current&&i(e.id,{loading:!1,error:"离线"});return}try{let t,n=await fetch(eae(e,"/v1/runtime/info"),{cache:"no-store"});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.text();try{t=JSON.parse(r)}catch{throw Error("该机器运行时过旧,不支持版本检测")}let o=await eat(t.platform);a.current&&i(e.id,{info:t,latest:o,loading:!1})}catch(t){a.current&&i(e.id,{loading:!1,error:t instanceof Error?t.message:"无法获取版本"})}})))},[i]);async function l(e){if(e.info&&!e.updating){i(e.machine.id,{updating:!0});try{await fetch(eae(e.machine,"/v1/runtime/update"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:e.latest})})}catch{}window.setTimeout(()=>{a.current&&o()},25e3)}}return ew.useEffect(()=>(a.current=!0,o(),()=>{a.current=!1}),[o]),(0,ey.jsx)("div",{className:"h-full overflow-auto px-6 py-8","data-tour":"check-update",children:(0,ey.jsxs)("div",{className:"mx-auto flex max-w-3xl flex-col gap-5",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,ey.jsxs)("div",{children:[(0,ey.jsx)("h1",{className:"text-xl font-semibold",children:"检查更新"}),(0,ey.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"工作组内各机器的运行时版本与可用更新。点击「立即更新」可让对应机器自动更新(该机器会短暂重启)。"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",onClick:()=>void o(),disabled:n,children:[(0,ey.jsx)(x1,{className:(0,eI.cn)("size-4",n&&"animate-spin")}),"刷新"]})]}),n&&0===e.length?(0,ey.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl border bg-card p-8 text-sm text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 正在获取机器列表…"]}):0===e.length?(0,ey.jsx)("div",{className:"rounded-xl border bg-card p-8 text-center text-sm text-muted-foreground",children:"暂无可用机器。"}):(0,ey.jsx)("div",{className:"flex flex-col gap-2",children:e.map(e=>{let t=!!e.info&&!!e.latest&&e.latest!==e.info.version;return(0,ey.jsxs)("div",{className:"flex items-center gap-4 rounded-xl border bg-card px-4 py-3",children:[(0,ey.jsx)(eP,{className:"size-5 shrink-0 text-muted-foreground"}),(0,ey.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)("span",{className:"truncate text-sm font-medium",children:e.machine.name}),e.machine.isLocal?(0,ey.jsx)("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"本机"}):null]}),(0,ey.jsx)("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.loading?"读取版本中…":e.error?(0,ey.jsx)("span",{className:"text-amber-600",children:e.error}):(0,ey.jsxs)(ey.Fragment,{children:[function(e){switch(e){case"windows":return"Windows";case"darwin":return"macOS";case"linux":return"Linux";case"android":return"Android";default:return e||"未知"}}(e.info?.os??e.machine.platform??"")," · 当前 ",(0,ey.jsx)("span",{className:"font-mono",children:e.info?.version??"?"}),e.latest?(0,ey.jsxs)(ey.Fragment,{children:[" · 最新 ",(0,ey.jsx)("span",{className:"font-mono",children:e.latest})]}):null,e.info?.updatedAt?(0,ey.jsxs)(ey.Fragment,{children:[" · 更新于 ",function(e){if(!e)return"—";let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):"—"}(e.info.updatedAt)]}):null]})})]}),e.loading?(0,ey.jsx)(eM,{className:"size-4 animate-spin text-muted-foreground"}):e.updating?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-primary",children:[(0,ey.jsx)(eM,{className:"size-4 animate-spin"})," 更新中…"]}):t?(0,ey.jsxs)(eA.Button,{size:"sm",onClick:()=>void l(e),children:[(0,ey.jsx)(er9,{className:"size-4"})," 立即更新"]}):e.info?(0,ey.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,ey.jsx)(eO,{className:"size-4 text-emerald-500"})," 已是最新"]}):null]},e.machine.id)})}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"最新版本号来自 npm(@vantaloom/runtime-<平台>)。更新过程中该机器会停止并重启运行时, 若你的手机正连着它会短暂断开,更新完成后重新连接即可。"})]})})}let ear=(0,ek.default)("gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]),eaa=(0,ek.default)("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),eai=[{value:"24h",label:"近 24 小时"},{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"}];function eao(){let{user:e}=tl(),[t,n]=ew.useState(null),[r,a]=ew.useState(!0),[i,o]=ew.useState(null),[l,s]=ew.useState("7d"),[c,d]=ew.useState("all"),[u,f]=ew.useState([]),[h,p]=ew.useState([]),[m,g]=ew.useState(!0),[v,x]=ew.useState(""),[y,b]=ew.useState(!1),[w,j]=ew.useState(null),k=ew.useCallback(async()=>{a(!0),o(null);try{n(await e6())}catch(e){o(e instanceof Error?e.message:"读取余额失败")}finally{a(!1)}},[]);ew.useEffect(()=>{e&&(k(),e9().then(e=>f(e.models)).catch(()=>f([])))},[e,k]),ew.useEffect(()=>{if(!e)return;let t=!1;return g(!0),e8(l,"all"===c?void 0:c).then(e=>{t||p(e.points)}).catch(()=>{t||p([])}).finally(()=>{t||g(!1)}),()=>{t=!0}},[e,l,c]);let S=ew.useMemo(()=>h.reduce((e,t)=>(e.costMicro+=t.costMicro,e.requests+=t.requests,e.totalTokens+=t.totalTokens,e),{costMicro:0,requests:0,totalTokens:0}),[h]),N=ew.useMemo(()=>h.map(e=>{var t;let n;return{label:(t=e.time,n=new Date(t),"24h"===l?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})),cost:e.costMicro/1e6,requests:e.requests,tokens:e.totalTokens}}),[h,l]);async function C(){let e=v.trim();if(e){b(!0),j(null);try{let t=await e7(e);j({kind:"ok",text:`兑换成功,到账 ${e4(t.valueMicro)}`}),x(""),n(e=>e?{...e,balanceMicro:t.balanceMicro,balanceUsd:t.balanceMicro/1e6}:e)}catch(e){j({kind:"err",text:e instanceof Error?e.message:"兑换失败,请检查兑换码"})}finally{b(!1)}}}return e?(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"余额与用量"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"查看官方渠道的账户余额、调用用量,并使用兑换码充值。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eth,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"账户余额"})]}),(0,ey.jsxs)(eA.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void k(),disabled:r,children:[r?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(x1,{}),"刷新"]})]}),i?(0,ey.jsx)("p",{className:"text-xs text-destructive",children:i}):(0,ey.jsx)("p",{className:"text-3xl font-semibold tracking-tight",children:r&&!t?"—":e4(t?.balanceMicro??0,4)})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ear,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"兑换码充值"})]}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"输入兑换码,金额将立即计入账户余额。"}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(ez,{value:v,onChange:e=>x(e.target.value),placeholder:"请输入兑换码",className:"font-mono",onKeyDown:e=>{"Enter"===e.key&&C()}}),(0,ey.jsxs)(eA.Button,{className:"shrink-0",onClick:()=>void C(),disabled:y||!v.trim(),children:[y?(0,ey.jsx)(eM,{className:"animate-spin"}):null,"兑换"]})]}),w?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===w.kind?"text-primary":"text-destructive"),children:w.text}):null]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsx)(eaa,{className:"size-4 text-muted-foreground"}),(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"用量趋势"})]}),(0,ey.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ey.jsxs)(gb,{value:c,onValueChange:d,children:[(0,ey.jsx)(g9,{size:"sm",className:"w-44",children:(0,ey.jsx)(gS,{placeholder:"全部模型"})}),(0,ey.jsxs)(vn,{children:[(0,ey.jsx)(vr,{value:"all",children:"全部模型"}),u.map(e=>(0,ey.jsx)(vr,{value:e.id,children:e.displayName||e.id},e.id))]})]}),(0,ey.jsxs)(gb,{value:l,onValueChange:s,children:[(0,ey.jsx)(g9,{size:"sm",className:"w-32",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:eai.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]})]}),(0,ey.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,ey.jsx)(eal,{label:"花费",value:e4(S.costMicro,4)}),(0,ey.jsx)(eal,{label:"请求数",value:S.requests.toLocaleString("zh-CN")}),(0,ey.jsx)(eal,{label:"Tokens",value:S.totalTokens.toLocaleString("zh-CN")})]}),(0,ey.jsx)("div",{className:"h-56 w-full",children:m&&0===h.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===N.length?(0,ey.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"所选区间暂无用量记录"}):(0,ey.jsx)(Cn,{width:"100%",height:"100%",children:(0,ey.jsxs)(XJ,{data:N,margin:{top:8,right:8,left:0,bottom:0},children:[(0,ey.jsx)("defs",{children:(0,ey.jsxs)("linearGradient",{id:"usageCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ey.jsx)("stop",{offset:"5%",stopColor:"var(--color-primary)",stopOpacity:.35}),(0,ey.jsx)("stop",{offset:"95%",stopColor:"var(--color-primary)",stopOpacity:0})]})}),(0,ey.jsx)(Yk,{strokeDasharray:"3 3",stroke:"var(--color-border)",vertical:!1}),(0,ey.jsx)(Y$,{dataKey:"label",tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1}),(0,ey.jsx)(YY,{tick:{fontSize:11},stroke:"var(--color-muted-foreground)",tickLine:!1,axisLine:!1,width:48,tickFormatter:e=>`$${e.toFixed(2)}`}),(0,ey.jsx)(BA,{contentStyle:{borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-popover)",fontSize:12},formatter:e=>[`$${Number(e).toFixed(4)}`,"花费"]}),(0,ey.jsx)(Xq,{type:"monotone",dataKey:"cost",stroke:"var(--color-primary)",strokeWidth:2,fill:"url(#usageCost)"})]})})})]})]})}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(eth,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再查看余额与用量。"})]})})}function eal({label:e,value:t}){return(0,ey.jsxs)("div",{className:"rounded-md bg-muted/55 px-3 py-2",children:[(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),(0,ey.jsx)("p",{className:"mt-0.5 truncate text-sm font-semibold",children:t})]})}let eas=(0,ek.default)("image-plus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]),eac=(0,ek.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),ead=[{value:"bug",label:"功能异常"},{value:"feature",label:"功能建议"},{value:"billing",label:"计费与余额"},{value:"other",label:"其他"}],eau=Object.fromEntries(ead.map(e=>[e.value,e.label])),eaf={pending:{label:"待审批",variant:"secondary"},preparing:{label:"准备完成",variant:"outline"},done:{label:"已完成",variant:"default"},noplan:{label:"暂时无计划",variant:"secondary"}};function eah(){let{user:e}=tl(),[t,n]=ew.useState(""),[r,a]=ew.useState("bug"),[i,o]=ew.useState(""),[l,s]=ew.useState([]),[c,d]=ew.useState(!1),[u,f]=ew.useState(null),[h,p]=ew.useState(!1),m=ew.useRef(null),[g,v]=ew.useState([]),[x,y]=ew.useState(!0),[b,w]=ew.useState(null),j=ew.useCallback(async()=>{y(!0);try{let e=await tt();v(e.issues)}catch{v([])}finally{y(!1)}},[]);function k(e){let t=Array.from(e).filter(e=>e.type.startsWith("image/"));f(null),s(e=>{let n=[...e];for(let e of t){if(n.length>=10){f({kind:"err",text:`最多上传 10 张图片`});break}if(e.size>8388608){f({kind:"err",text:`「${e.name}」过大(上限 8MB)`});continue}n.push({id:`${e.name}-${e.size}-${n.length}`,file:e,url:URL.createObjectURL(e)})}return n})}async function S(){if(!t.trim())return void f({kind:"err",text:"请填写标题"});d(!0),f(null);try{let{issue:e}=await te({title:t.trim(),type:r,content:i.trim()}),c=!1;for(let t of l)try{await tn(e.id,t.file)}catch{c=!0}f({kind:"ok",text:c?"反馈已提交,但部分图片上传失败,请在下方列表确认":"反馈已提交,感谢您的反馈!"}),n(""),a("bug"),o(""),l.forEach(e=>URL.revokeObjectURL(e.url)),s([]),j()}catch(e){f({kind:"err",text:e instanceof Error?e.message:"提交失败,请重试"})}finally{d(!1)}}return ew.useEffect(()=>{e&&j()},[e,j]),ew.useEffect(()=>()=>{l.forEach(e=>URL.revokeObjectURL(e.url))},[]),e?(0,ey.jsxs)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 pb-14 text-foreground md:pb-6",children:[(0,ey.jsxs)("div",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,ey.jsxs)("div",{className:"min-w-0",children:[(0,ey.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"问题反馈"}),(0,ey.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"提交功能异常、建议或计费问题,我们会在看板中跟进处理。"})]}),(0,ey.jsxs)("section",{className:"grid gap-3 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"标题"}),(0,ey.jsx)(ez,{value:t,onChange:e=>n(e.target.value),maxLength:120,placeholder:"简要描述问题"})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"类型"}),(0,ey.jsxs)(gb,{value:r,onValueChange:a,children:[(0,ey.jsx)(g9,{className:"w-full",children:(0,ey.jsx)(gS,{})}),(0,ey.jsx)(vn,{children:ead.map(e=>(0,ey.jsx)(vr,{value:e.value,children:e.label},e.value))})]})]}),(0,ey.jsxs)("div",{className:"grid gap-1.5",children:[(0,ey.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"详细描述"}),(0,ey.jsx)(bq,{value:i,onChange:e=>o(e.target.value),rows:5,placeholder:"详细描述问题的复现步骤、期望行为等",onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith("image/"));t.length>0&&(e.preventDefault(),k(t))}})]}),(0,ey.jsxs)("div",{className:(0,eI.cn)("grid gap-3 rounded-lg border border-dashed p-3 transition-colors",h?"border-primary bg-primary/5":"border-input"),onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files)},children:[(0,ey.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ey.jsxs)("p",{className:"text-xs text-muted-foreground",children:["可拖拽、粘贴或选择图片(最多 ",10," 张,单张 ≤ 8MB)"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:()=>m.current?.click(),children:[(0,ey.jsx)(eas,{}),"添加图片"]}),(0,ey.jsx)("input",{ref:m,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&k(e.target.files),e.target.value=""}})]}),l.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,ey.jsxs)("div",{className:"relative size-16 overflow-hidden rounded-md border",children:[(0,ey.jsx)("img",{src:e.url,alt:e.file.name,className:"size-full object-cover"}),(0,ey.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void s(e=>{let n=e.find(e=>e.id===t);return n&&URL.revokeObjectURL(n.url),e.filter(e=>e.id!==t)})},className:"absolute right-0.5 top-0.5 rounded-full bg-black/55 p-0.5 text-white hover:bg-black/75","aria-label":"移除图片",children:(0,ey.jsx)(fc.XIcon,{className:"size-3"})})]},e.id))}):null]}),u?(0,ey.jsx)("p",{className:(0,eI.cn)("text-xs","ok"===u.kind?"text-primary":"text-destructive"),children:u.text}):null,(0,ey.jsx)("div",{className:"flex justify-end",children:(0,ey.jsxs)(eA.Button,{onClick:()=>void S(),disabled:c||!t.trim(),children:[c?(0,ey.jsx)(eM,{className:"animate-spin"}):(0,ey.jsx)(eac,{}),"提交反馈"]})})]}),(0,ey.jsxs)("section",{className:"grid gap-3",children:[(0,ey.jsx)("h4",{className:"text-sm font-semibold",children:"我的反馈"}),x?(0,ey.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})}):0===g.length?(0,ey.jsx)("p",{className:"rounded-lg border bg-card p-6 text-center text-xs text-muted-foreground",children:"你还没有提交过反馈。"}):g.map(e=>{let t=eaf[e.status]??{label:e.status,variant:"secondary"};return(0,ey.jsxs)("article",{className:"grid gap-2 rounded-lg border bg-card p-4",children:[(0,ey.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ey.jsx)("p",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:e.title}),(0,ey.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,ey.jsx)(F3,{variant:"outline",children:eau[e.type]??e.type}),(0,ey.jsx)(F3,{variant:t.variant,children:t.label})]})]}),e.content?(0,ey.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:e.content}):null,e.images.length>0?(0,ey.jsx)("div",{className:"flex flex-wrap gap-2",children:e.images.map(t=>(0,ey.jsx)("button",{type:"button",className:"size-16 overflow-hidden rounded-md border",onClick:()=>w({issueId:e.id,imageId:t.id}),children:(0,ey.jsx)(eam,{issueId:e.id,imageId:t.id})},t.id))}):null,(0,ey.jsx)("p",{className:"text-[11px] text-muted-foreground",children:new Date(e.createdAt).toLocaleString("zh-CN")})]},e.id)})]})]}),(0,ey.jsx)(dw,{open:null!==b,onOpenChange:e=>{e||w(null)},children:(0,ey.jsx)(fu,{className:"max-w-3xl",children:b?(0,ey.jsx)(eag,{issueId:b.issueId,imageId:b.imageId,className:"max-h-[75vh] w-full object-contain"}):null})})]}):(0,ey.jsx)("div",{className:"vtl-app-background h-full min-h-0 overflow-auto p-6 text-foreground",children:(0,ey.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col items-center gap-3 py-16 text-center",children:[(0,ey.jsx)(jl,{className:"size-8 text-muted-foreground/40"}),(0,ey.jsx)("p",{className:"text-sm font-medium",children:"未登录 Hub 账户"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"请先在「系统设置 · Hub 账户」中登录,再提交问题反馈。"})]})})}function eap(e,t){let[n,r]=ew.useState(null);return ew.useEffect(()=>{let n=!0,a=null;return tr(e,t).then(e=>{a=e,n?r(e):URL.revokeObjectURL(e)}).catch(()=>{}),()=>{n=!1,a&&URL.revokeObjectURL(a)}},[e,t]),n}function eam({issueId:e,imageId:t}){let n=eap(e,t);return n?(0,ey.jsx)("img",{src:n,alt:"",className:"size-full object-cover"}):(0,ey.jsx)("div",{className:"flex size-full items-center justify-center bg-muted"})}function eag({issueId:e,imageId:t,className:n}){let r=eap(e,t);return r?(0,ey.jsx)("img",{src:r,alt:"",className:n}):(0,ey.jsx)("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:(0,ey.jsx)(eM,{className:"size-5 animate-spin"})})}let eav={totals:{machines:0,online:0,runtime:0,tokens:0},machines:[],topology:{nodes:[],links:[]},pathTotals:{direct:0,p2p:0,relay:0,broken:0},latency:[],candidates:[]},eax={metrics:{online:0,health:0,latency:"local",events:0},machines:[],trend:[],networkLinks:[],events:[],serviceHealth:[]};function eay(e,t){let[n,r]=ew.useState(t);return ew.useEffect(()=>{let n=!0,a=!1;async function i(){if(!a){a=!0;try{let t=await fetch(eD(e),{cache:"no-store"});if(!t.ok)return;let a=await t.json();n&&r(a)}catch{n&&r(t)}finally{a=!1}}}i();let o=window.setInterval(i,2e3);return()=>{n=!1,window.clearInterval(o)}},[t,e]),n}function eab(){let e=eay("/api/local/machines/fleet",eav),{nodes:t,links:n}=e.topology;return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col text-foreground",children:[(0,ey.jsxs)("header",{className:"shrink-0 border-b px-6 py-4",children:[(0,ey.jsx)("h2",{className:"text-base font-semibold tracking-normal",children:"组网关系"}),(0,ey.jsx)("p",{className:"text-xs text-muted-foreground",children:"系统中各机器的拓扑关系图(自动生成)。节点为机器,连线表示机器之间的连接方式与实时延迟。"}),(0,ey.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs text-muted-foreground",children:[(0,ey.jsxs)("span",{children:["机器 ",e.totals.online,"/",e.totals.machines," 在线"]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"直连 ",e.pathTotals.direct]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-foreground"}),"P2P ",e.pathTotals.p2p]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-muted-foreground"}),"中继 ",e.pathTotals.relay]}),(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:"size-2 rounded-full bg-destructive"}),"断开 ",e.pathTotals.broken]})]})]}),(0,ey.jsx)("div",{className:"min-h-0 flex-1 p-4",children:0===t.length?(0,ey.jsx)("div",{className:"grid h-full place-items-center rounded-lg border border-dashed",children:(0,ey.jsx)("p",{className:"max-w-sm text-center text-sm text-muted-foreground",children:"暂未发现其它机器。登录 Hub 账户并把机器加入同一工作组后,这里会自动绘制组网拓扑。"})}):(0,ey.jsx)("div",{className:"h-full overflow-hidden rounded-lg border bg-card",children:(0,ey.jsx)(eeA,{nodes:t,links:n})})}),(0,ey.jsx)("footer",{className:"shrink-0 border-t px-6 py-2",children:(0,ey.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[(0,ey.jsx)("span",{children:"连接方式:"}),[{kind:"direct",label:"直连",className:"bg-foreground"},{kind:"p2p",label:"P2P",className:"bg-foreground"},{kind:"relay",label:"中继",className:"bg-muted-foreground"},{kind:"down",label:"断开",className:"bg-destructive"}].map(e=>(0,ey.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,ey.jsx)("span",{className:`h-0.5 w-4 rounded ${e.className}`}),e.label]},e.kind))]})})]})}let eaw=["light","dark","jelly"],eaj={light:{label:"Light",icon:etu,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:ets,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,ey.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,ey.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,ey.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,ey.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,ey.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,ey.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function eak(){let{resolvedTheme:e,setTheme:t}=(0,hw.useTheme)(),[n,r]=ew.useState(etC.defaultAppearanceTheme);ew.useEffect(()=>{let e=window.localStorage.getItem(etC.appearanceThemeStorageKey)??etC.defaultAppearanceTheme;r(e),(0,etC.applyAppearanceTheme)({theme:e})},[]);let a=n===etC.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=eaw.indexOf(a),o=eaw[(i+1)%eaw.length]??"light",{icon:l,label:s,className:c}=eaj[a];function d(e){r(e),window.localStorage.setItem(etC.appearanceThemeStorageKey,e),(0,etC.applyAppearanceTheme)({theme:e})}return(0,ey.jsx)(eA.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,eI.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${JD.theme}: ${s}`,title:`${JD.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(etC.jellyAppearanceTheme);return}d(etC.defaultAppearanceTheme),t(o)},children:(0,ey.jsx)(l,{})})}let eaS=(0,ek.default)("chart-area",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);(0,ek.default)("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);let eaN=(0,ek.default)("list-checks",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]]),eaC=((0,ek.default)("route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]),(0,ek.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]])),eaM=[{id:"run-ui-polish",title:"组件库视觉回归检查",machine:"Studio-PC",agent:"UI Polish",state:"running",started:"14:08",runtime:"22m",progress:68,load:54},{id:"run-runner-build",title:"Linux runner 镜像构建",machine:"Linux-runner-02",agent:"Build Agent",state:"running",started:"14:15",runtime:"15m",progress:41,load:86},{id:"run-access-audit",title:"工作组权限审阅",machine:"Studio-PC",agent:"Access Agent",state:"blocked",started:"14:21",runtime:"9m",progress:37,load:18},{id:"run-docs",title:"发布说明摘要",machine:"MacBook-build",agent:"Docs Agent",state:"queued",started:"等待",runtime:"0m",progress:0,load:0},{id:"run-cache-clean",title:"缓存清理策略验证",machine:"Linux-runner-02",agent:"Ops Sentinel",state:"failed",started:"13:54",runtime:"6m",progress:28,load:12}],eaE=[{id:"worker-studio",machine:"Studio-PC",role:"local coordinator",active:3,capacity:6,cpu:42,memory:68},{id:"worker-runner",machine:"Linux-runner-02",role:"gpu worker",active:4,capacity:5,cpu:76,memory:81},{id:"worker-mac",machine:"MacBook-build",role:"build host",active:0,capacity:3,cpu:8,memory:24}],eaO=[{id:"confirm-shell",title:"Studio-PC 请求执行发布前文件写入",meta:"UI Polish · apply_patch",tone:"normal"},{id:"confirm-service",title:"Linux-runner-02 请求重启 runner 服务",meta:"Ops Sentinel · Restart-Service",tone:"warning"},{id:"confirm-token",title:"工作组 token 加入新机器",meta:"Access Agent · admin required",tone:"normal"}],eaP=[["14:29","Studio-PC","pnpm --filter vantaloom-app lint","完成"],["14:27","Linux-runner-02","docker build agent-runtime","运行中"],["14:22","Studio-PC","apply_patch agent settings","完成"],["14:17","MacBook-build","pnpm typecheck","排队"],["14:03","Linux-runner-02","cache prune dry-run","失败"]],eaA={cpu:{label:"CPU",color:"var(--chart-1)"},memory:{label:"Memory",color:"var(--chart-3)"},network:{label:"Network",color:"var(--chart-5)"}};function eaI(e,t,n=42,r){return(0,ey.jsx)("section",{className:(0,eI.cn)("size-full rounded-xl border bg-card p-5",r&&"vtl-jelly-image-card",r&&r.includes("/bg")&&"vtl-jelly-image-card-shadowless"),style:r?Jz({image:r,opacity:.74,blur:"8px"}):void 0,children:(0,ey.jsx)(J7,{label:e,value:t,minSize:n})})}function eaz(e,t,n=""){return{title:e,dataSource:t,refreshRate:"10s",note:n}}let eaT={metrics:{online:2,health:88.4,latency:"38ms",events:17},machines:[{id:"studio",name:"Studio-PC",os:"Windows",status:"online",link:"direct",heartbeat:"3s",cpu:42,memory:68,disk:71,network:24},{id:"runner",name:"Linux-runner-02",os:"Linux",status:"online",link:"p2p",heartbeat:"5s",cpu:76,memory:81,disk:62,network:43},{id:"mac",name:"MacBook-build",os:"macOS",status:"sleeping",link:"direct",heartbeat:"2m",cpu:8,memory:24,disk:48,network:6}],trend:[{time:"09:00",cpu:36,memory:54,network:24},{time:"10:00",cpu:48,memory:61,network:29},{time:"11:00",cpu:44,memory:58,network:34},{time:"12:00",cpu:63,memory:72,network:41},{time:"13:00",cpu:58,memory:69,network:37},{time:"14:00",cpu:71,memory:76,network:46}],networkLinks:[["Studio-PC","Linux-runner-02","P2P","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","12ms","0.0%"],["Linux-runner-02","MacBook-build","Relay fallback","84ms","1.1%"]],events:[["14:31","Linux-runner-02 心跳延迟升高"],["14:28","Studio-PC 完成 2 个工具调用"],["14:19","MacBook-build 进入睡眠状态"],["14:12","工作组权限策略同步完成"],["14:04","P2P 链路切换到备用路径"]],serviceHealth:[{id:"local-service",name:"Local service",state:"正常",samples:[96,98,97,95,96,94,97,98,96,95,97,96]},{id:"agent-runtime",name:"Agent runtime",state:"正常",samples:[91,93,94,90,88,92,94,93,91,89,92,94]},{id:"p2p-mesh",name:"P2P mesh",state:"波动",samples:[78,82,76,73,68,71,74,79,83,80,77,72]},{id:"plugin-bridge",name:"Plugin bridge",state:"告警",samples:[88,86,84,82,79,74,63,54,48,52,67,76]}]},eaD=[{id:"metric-runs",title:"运行中",description:"当前正在执行的运行数量。",icon:(0,ey.jsx)(uk,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("运行中","运行队列"),render:e=>eaI(e.title,"07",44,JO)},{id:"metric-queued",title:"排队",description:"等待调度的任务数量。",icon:(0,ey.jsx)(up,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("排队","调度器"),render:e=>eaI(e.title,"04",44,JP)},{id:"metric-blocked",title:"待确认",description:"等待人工确认的任务数量。",icon:(0,ey.jsx)(eaC,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("待确认","确认队列"),render:e=>eaI(e.title,"03",44,JA)},{id:"metric-workers",title:"Worker",description:"当前可调度 worker 数量。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("Worker","Agent worker"),render:e=>eaI(e.title,"14",44,JI)},{id:"queue",title:"任务队列",description:"运行队列 Roadmap。",icon:(0,ey.jsx)(eaN,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eaz("任务队列","运行队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(JT,{title:e.title}),(0,ey.jsx)(eeD,{items:eaM})]})},{id:"workers",title:"Agent worker",description:"各 worker 的负载和容量。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eaz("Agent worker","Worker 状态"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(JT,{title:e.title}),(0,ey.jsx)(eeR,{workers:eaE})]})},{id:"log",title:"最近执行",description:"最近执行记录 Roadmap。",icon:(0,ey.jsx)(Qn,{className:"size-4"}),defaultSize:{w:7,h:4},defaultConfig:eaz("最近执行","执行日志"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(JT,{title:e.title}),(0,ey.jsx)(eeT,{items:eaP})]})},{id:"confirmations",title:"待确认",description:"等待人工确认的事项。",icon:(0,ey.jsx)(Q5,{className:"size-4"}),defaultSize:{w:5,h:4},defaultConfig:eaz("待确认","确认队列"),render:e=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(JT,{title:e.title}),(0,ey.jsx)(eez,{items:eaO})]})}],ea_=[{id:"metric-runs",kind:"metric-runs",x:0,y:0,w:3,h:2},{id:"metric-queued",kind:"metric-queued",x:3,y:0,w:3,h:2},{id:"metric-blocked",kind:"metric-blocked",x:6,y:0,w:3,h:2},{id:"metric-workers",kind:"metric-workers",x:9,y:0,w:3,h:2},{id:"queue",kind:"queue",x:0,y:2,w:7,h:5},{id:"workers",kind:"workers",x:7,y:2,w:5,h:5},{id:"log",kind:"log",x:0,y:7,w:7,h:4},{id:"confirmations",kind:"confirmations",x:7,y:7,w:5,h:4}];function eaR(e=eaT){return[{id:"metric-online",title:"在线机器",description:"当前在线机器数量。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("在线机器","机器心跳"),render:t=>eaI(t.title,String(e.metrics.online),44,JO)},{id:"metric-health",title:"健康度",description:"工作组整体健康度。",icon:(0,ey.jsx)(eO,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("健康度","服务遥测"),render:t=>eaI(t.title,`${e.metrics.health}%`,44,JP)},{id:"metric-latency",title:"平均延迟",description:"机器连接平均延迟。",icon:(0,ey.jsx)(Ql,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("平均延迟","网络遥测"),render:t=>eaI(t.title,e.metrics.latency,44,JA)},{id:"metric-events",title:"事件",description:"最近事件数量。",icon:(0,ey.jsx)(Q5,{className:"size-4"}),defaultSize:{w:3,h:2},defaultConfig:eaz("事件","事件流"),render:t=>eaI(t.title,String(e.metrics.events),44,JI)},{id:"machines",title:"机器健康矩阵",description:"各机器资源和心跳状态。",icon:(0,ey.jsx)(eP,{className:"size-4"}),defaultSize:{w:7,h:5},defaultConfig:eaz("机器健康矩阵","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"vtl-jelly-image-card flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",style:Jz({image:"/themes/jelly/card1.png",opacity:.88,blur:"10px"}),children:[(0,ey.jsx)(JT,{title:t.title}),(0,ey.jsx)(eeB,{machines:e.machines})]})},{id:"trend",title:"资源趋势",description:"CPU、内存和网络趋势。",icon:(0,ey.jsx)(eaS,{className:"size-4"}),defaultSize:{w:5,h:5},defaultConfig:eaz("资源趋势","机器遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(JT,{title:t.title}),(0,ey.jsx)(eeq,{config:eaA,data:e.trend})]})},{id:"network",title:"网络连接",description:"机器之间连接状态。",icon:(0,ey.jsx)(Jj,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eaz("网络连接","网络遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(JT,{title:t.title}),(0,ey.jsx)(eeW,{links:e.networkLinks})]})},{id:"events",title:"事件流",description:"最近遥测事件。",icon:(0,ey.jsx)(Q5,{className:"size-4"}),defaultSize:{w:6,h:4},defaultConfig:eaz("事件流","事件流"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden",children:[(0,ey.jsx)(JT,{title:t.title}),(0,ey.jsx)(eeF,{events:e.events})]})},{id:"services",title:"服务健康",description:"服务 30 分钟粒度健康条。",icon:(0,ey.jsx)(K7,{className:"size-4"}),defaultSize:{w:12,h:3},defaultConfig:eaz("服务健康","服务遥测"),render:t=>(0,ey.jsxs)("section",{className:"flex size-full flex-col overflow-hidden rounded-xl border bg-card p-3",children:[(0,ey.jsx)(JT,{title:t.title}),(0,ey.jsx)(eeK,{services:e.serviceHealth})]})}]}eaR();let eaL=[{id:"metric-online",kind:"metric-online",x:0,y:0,w:3,h:2},{id:"metric-health",kind:"metric-health",x:3,y:0,w:3,h:2},{id:"metric-latency",kind:"metric-latency",x:6,y:0,w:3,h:2},{id:"metric-events",kind:"metric-events",x:9,y:0,w:3,h:2},{id:"machines",kind:"machines",x:0,y:2,w:7,h:5},{id:"trend",kind:"trend",x:7,y:2,w:5,h:5},{id:"network",kind:"network",x:0,y:7,w:6,h:4},{id:"events",kind:"events",x:6,y:7,w:6,h:4},{id:"services",kind:"services",x:0,y:11,w:12,h:3}],ea$={totals:{machines:4,online:2,runtime:3,tokens:7},machines:[{id:"studio",name:"Studio-PC",role:"本机",group:"Core",os:"Windows 11",runtime:"0.16.4",state:"online",tags:["admin","shell","files","scheduler"],agent:"6/8",cpu:42,memory:68,version:"Agent runtime 0.16.4",admin:"Allay"},{id:"runner",name:"Linux-runner-02",role:"GPU worker",group:"Compute",os:"Ubuntu 24.04",runtime:"0.16.3",state:"online",tags:["gpu","agent","files"],agent:"4/6",cpu:76,memory:81,version:"Agent runtime 0.16.3",admin:"Ops"},{id:"mac",name:"MacBook-build",role:"构建机",group:"Build",os:"macOS 15.4",runtime:"0.15.9",state:"sleeping",tags:["build","readonly"],agent:"0/3",cpu:8,memory:24,version:"Agent runtime 0.15.9",admin:"Allay"},{id:"observer",name:"Observer-01",role:"只读观测节点",group:"Edge",os:"Debian 13",runtime:"0.16.2",state:"warning",tags:["readonly","audit"],agent:"1/2",cpu:18,memory:36,version:"Agent runtime 0.16.2",admin:"Security"}],topology:{nodes:[{id:"studio",label:"Studio-PC",meta:"本机",x:50,y:18},{id:"runner",label:"Linux-runner-02",meta:"GPU worker",x:22,y:60},{id:"mac",label:"MacBook-build",meta:"构建机",x:76,y:58,state:"warning"},{id:"observer",label:"Observer-01",meta:"只读观测",x:50,y:82,state:"warning"}],links:[{id:"sr",from:"studio",to:"runner",kind:"p2p",label:"P2P",meta:"38ms / 0.3%"},{id:"sm",from:"studio",to:"mac",kind:"direct",label:"Direct",meta:"12ms / 0%"},{id:"ro",from:"runner",to:"observer",kind:"relay",label:"Relay",meta:"84ms / 1.1%"},{id:"mo",from:"mac",to:"observer",kind:"down",label:"Down",meta:"lost"}]},pathTotals:{direct:1,p2p:1,relay:1,broken:1},latency:[{time:"09:00",p2p:42,direct:12,relay:96},{time:"10:00",p2p:39,direct:12,relay:88},{time:"11:00",p2p:44,direct:14,relay:91},{time:"12:00",p2p:38,direct:12,relay:84},{time:"13:00",p2p:36,direct:11,relay:86},{time:"14:00",p2p:41,direct:13,relay:93}],candidates:[["Studio-PC","Linux-runner-02","P2P","symmetric NAT","38ms","0.3%"],["Studio-PC","MacBook-build","Direct","open port 4178","12ms","0.0%"],["Linux-runner-02","Observer-01","Relay","udp blocked","84ms","1.1%"],["MacBook-build","Observer-01","Interrupted","sleep","-","-"]]};function eaF({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){return(0,ey.jsx)(J4,{boardId:"runtime-operations",definitions:eaD,initialLayouts:ea_,clipboardItems:e,actionLabel:"运行页面卡片操作",paletteGroupTitle:"运行页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eaB({clipboardItems:e=[],onClipboardItemsChange:t,onOverlayOpenChange:n}){let r=eay("/api/local/machines/telemetry",eax),a=ew.useMemo(()=>eaR(r),[r]);return(0,ey.jsx)(J4,{boardId:"telemetry",definitions:a,initialLayouts:eaL,clipboardItems:e,actionLabel:"遥测页面卡片操作",paletteGroupTitle:"遥测页面卡片",onClipboardItemsChange:t,onOverlayOpenChange:n})}function eaV({className:e,title:t="Vantaloom"}){return(0,ey.jsxs)("svg",{viewBox:"180 350 1130 260",fill:"currentColor",role:"img","aria-label":t,className:(0,eI.cn)("[[data-vtl-theme=jelly]_&]:opacity-70",e),children:[(0,ey.jsx)("path",{d:"m658 393 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,ey.jsx)("path",{d:"m1147 452h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,ey.jsx)("path",{d:"m556 449h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,ey.jsx)("path",{d:"m409 450h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,ey.jsx)("path",{d:"m918 450h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,ey.jsx)("path",{d:"m224 442h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,ey.jsx)("path",{d:"m1010 450h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,ey.jsx)("path",{d:"m848 371h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function eaH(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function eaU(e){return"u"<typeof document?null:document.querySelector(e)}function eaW(){return null!=eaU('[role="menu"]')}function eaq(){return null!=eaU('[data-tour="init-wizard"]')}function eaK(){let e=eaU('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}!function(e=ea$){eaz("机器","机器组"),eaz("在线","机器心跳"),eaz("Runtime","Agent runtime"),eaz("Token","机器注册"),eaz("机器组","机器组"),eaz("拓扑图","网络拓扑"),eaz("直连","网络拓扑"),eaz("P2P","网络拓扑"),eaz("Relay","网络拓扑"),eaz("中断","网络拓扑"),eaz("延迟","网络遥测"),eaz("候选路径","网络候选路径")}(),eaz("日志与审计","审计事件"),eaz("筛选","审计筛选"),eaz("拒绝事件","审计事件"),eaz("事件趋势","审计事件");var eaG=e.i(64990);function eaX(){let e=sb(),[t,n]=ew.useState(!1);ew.useEffect(()=>{try{n("1"===window.localStorage.getItem("vtl:sidebar-collapsed"))}catch{}},[]);let r=ew.useCallback(()=>{n(e=>{let t=!e;try{window.localStorage.setItem("vtl:sidebar-collapsed",t?"1":"0")}catch{}return t})},[]),[a,i]=ew.useState("home"),[o,l]=ew.useState(!1),[s,c]=ew.useState(),[d,u]=ew.useState(),[f,h]=ew.useState([]),[p,m]=ew.useState([]),[g,v]=ew.useState("conversation"),[x,y]=ew.useState(0),b=s?.conversation.id,w=s?.conversation.ownerMachineId;ew.useEffect(()=>{h([]),m([]),v("conversation")},[b]),ew.useEffect(()=>{let e;if(!b||"new-agent-conversation"!==a)return void m([]);let t=!1,n=async()=>{let r=await sz(b,w);t||(m(r),e=window.setTimeout(n,!function e(t){return t.some(t=>t.running||e(t.children??[]))}(r)?6e3:2e3))};return n(),()=>{t=!0,e&&window.clearTimeout(e)}},[b,w,a]);let[j,k]=ew.useState(),[S,N]=ew.useState(!1),[C,M]=ew.useState([]),[E,O]=ew.useState([]),[P,A]=ew.useState({}),[I,z]=ew.useState(),[T,D]=ew.useState(uP),[_,R]=ew.useState([]),[L,$]=ew.useState(),[F,B]=ew.useState(),[V,H]=ew.useState(),U=ew.useRef(!1),W=ew.useCallback(e=>{D(t=>iQ(e,t))},[]),q=ew.useCallback(e=>{R(t=>iQ(e,t))},[]),K=ew.useCallback(async(e,t)=>{let n="u">typeof performance?performance.now():Date.now();console.debug(`[open] click conversation=${e} owner=${t??"local"}`),u({id:e,ownerMachineId:t}),i("new-agent-conversation");let r=()=>Math.round(("u">typeof performance?performance.now():Date.now())-n);try{let n=await s_(e,t);console.debug(`[open] detail loaded in ${r()}ms (id=${e})`),c(n),u(t=>t?.id===e?void 0:t)}catch(n){if(n instanceof sk){let r=n.openedBy?.displayName||"另一台设备";if(window.confirm(`此对话正在「${r}」上打开,无法同时操作。是否强制接管(对方将被踢出)?`)){try{let n=await s_(e,t,{force:!0});c(n)}finally{u(t=>t?.id===e?void 0:t)}return}u(t=>t?.id===e?void 0:t),s||i("home");return}console.warn(`[open] failed after ${r()}ms (id=${e})`,n),u(t=>t?.id===e?void 0:t),s||i("home")}},[s]),G=ew.useCallback(async(e,t)=>{h([]),await K(e,t)},[K]),X=ew.useCallback(()=>{c(void 0),i("new-agent-conversation")},[]),Y=ew.useCallback(async()=>{let e=await sP();e?await K(e.conversation.id,e.conversation.ownerMachineId):X()},[K,X]),Z=ew.useCallback(async()=>{U.current=!0,D(uP),R([]),i("new-canvas");try{let e=await Jh({title:"新画布",nodes:uP,edges:[]});B(e.canvas.id),H("local")}catch{B(void 0),H(void 0),U.current=!1}},[]),J=ew.useCallback(async(e,t)=>{try{await Jm(e,t);let n=await Jf(e,t);U.current=!0,D(n.nodes),R(n.edges),B(n.canvas.id),H(n.canvas.ownerMachineId),i("new-canvas")}catch{}},[]);ew.useEffect(()=>{if(!F)return;if(U.current){U.current=!1;return}let e=window.setTimeout(()=>{Jp(F,{nodes:T,edges:_,nodeIds:T.map(e=>e.id)},V).catch(()=>{})},800);return()=>window.clearTimeout(e)},[T,_,F,V]);let Q=ew.useCallback(({item:t})=>{if(!e||"new-canvas"!==t.id&&"all-canvases"!==t.id&&"open-recent-canvas"!==t.id){if("new-canvas"===t.id)return void Z();if("all-canvases"===t.id)return void i("all-canvases");if("new-agent-conversation"===t.id)return void X();if("open-recent-conversation"===t.id)return void Y();if("runs"===t.id)return void i("runs");if("telemetry"===t.id)return void i("telemetry");("preferences"===t.id||"preferences-model-routes"===t.id||"preferences-agent-config"===t.id||"preferences-subagent-config"===t.id||"preferences-cc-engine-config"===t.id||"preferences-system-prompt"===t.id||"preferences-layout"===t.id||"network-topology"===t.id||"check-update"===t.id||"account"===t.id||"balance-usage"===t.id||"feedback"===t.id)&&i(t.id)}},[Z,e,Y,X]),{start:ee}=(0,eaG.useTour)(),et=ew.useCallback(()=>{var e;ee((e={select:e=>Q({item:{id:e}}),startNewConversation:X,goHome:()=>{i("home"),c(void 0)}},{id:"product-tour",steps:[{id:"intro",centered:!0,title:"欢迎使用 Vantaloom 👋",body:(0,ey.jsxs)(ey.Fragment,{children:["这是一份手把手向导,会高亮关键位置并在需要时",(0,ey.jsx)("b",{children:"请你亲自操作"}),"(没做完不会出现「下一步」)。 全程界面都可正常点击;随时按 ",(0,ey.jsx)("kbd",{children:"Esc"})," 或右上角 ✕ 退出。"]})},{id:"theme",before:eaH(()=>e.goHome()),target:()=>eaU('[role="menu"]')??eaU('[data-tour="account-button"]'),gate:eaW,gateHint:"点击用户名按钮展开菜单",padding:6,title:"切换主题",body:(0,ey.jsxs)(ey.Fragment,{children:["点击左下角的 ",(0,ey.jsx)("b",{children:"用户名按钮"})," 打开菜单。展开后,里面的 ",(0,ey.jsx)("b",{children:"外观 / 主题"})," 项每点一次就在"," ",(0,ey.jsx)("b",{children:"浅色 → 深色 → 果冻"})," 之间循环。"]})},{id:"model-routes-add",before:eaH(()=>e.select("preferences-model-routes")),target:()=>eaU('[data-tour="model-route-form"]')??eaU('[data-tour="add-model-route"]'),gate:()=>null!=eaU('[data-tour="model-route-form"]'),gateHint:"点击「添加模型路由」",title:"配置模型渠道(1/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["进入 ",(0,ey.jsx)("b",{children:"设置 → 模型路由"}),"。请点 ",(0,ey.jsx)("b",{children:"添加模型路由"})," 新增一个第三方渠道(任何 OpenAI / Anthropic 兼容 API 都行)。"]})},{id:"model-routes-fields",before:eaH(()=>e.select("preferences-model-routes")),target:'[data-tour="model-route-form"]',waitForTarget:2500,title:"配置模型渠道(2/2)",body:(0,ey.jsxs)(ey.Fragment,{children:["表单各项:",(0,ey.jsx)("b",{children:"提供商名称"})," 仅作标识;",(0,ey.jsx)("b",{children:"协议"})," 选 OpenAI / Anthropic 风格;",(0,ey.jsx)("b",{children:"Endpoint URL"})," 填到 ",(0,ey.jsx)("code",{children:"/v1"})," 这一级;",(0,ey.jsx)("b",{children:"API Key"})," 是密钥;",(0,ey.jsx)("b",{children:"可用模型"})," 勾选启用并可设上下文长度。",(0,ey.jsx)("br",{}),"⚠️ 填完",(0,ey.jsx)("b",{children:"务必点「保存」"}),",否则不生效。"]})},{id:"agent-config-compression",before:eaH(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-compression"]',title:"代理配置 · 压缩上下文",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 代理配置"})," 的第一块:当对话 token 接近模型上下文窗口的设定百分比时,自动用",(0,ey.jsx)("b",{children:"压缩模型"})," 压缩历史。阈值 0% 表示关闭,建议 70%-85%。"]})},{id:"agent-config-summary",before:eaH(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-summary"]',title:"代理配置 · 对话摘要",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"对话摘要"}),":开启后用",(0,ey.jsx)("b",{children:"摘要模型"}),"自动生成 / 更新对话标题与每轮的轮次标题,方便在侧边栏 与时间轴里快速辨认。"]})},{id:"agent-config-approval",before:eaH(()=>e.select("preferences-agent-config")),target:'[data-tour="agent-config-approval"]',title:"代理配置 · 命令审批",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"命令审批"}),":在 Auto 权限模式下,用",(0,ey.jsx)("b",{children:"审批模型"})," + ",(0,ey.jsx)("b",{children:"审批提示词"})," 判断 Agent 发起的命令 是否自动放行。留空则非危险命令全部放行。改完记得 ",(0,ey.jsx)("b",{children:"保存"}),"。"]})},{id:"subagent-explore",before:eaH(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-explore"]',title:"子代理 · 探索",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → 子代理配置"}),"。",(0,ey.jsx)("b",{children:"探索"})," 子代理擅长只读检索代码 / 资料。可单独设它的",(0,ey.jsx)("b",{children:"使用模型"}),"(留空则继承上级)与",(0,ey.jsx)("b",{children:"系统提示词"}),"。"]})},{id:"subagent-workflow",before:eaH(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-workflow"]',title:"子代理 · 工作流",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"工作流"})," 子代理负责多步骤任务编排,同样可单独配模型与提示词。"]})},{id:"subagent-operator",before:eaH(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-operator"]',title:"子代理 · 操作",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"操作"})," 子代理执行写文件 / 跑命令等动手类任务,工具集固定。"]})},{id:"subagent-custom",before:eaH(()=>e.select("preferences-subagent-config")),target:'[data-tour="subagent-custom"]',title:"子代理 · 自定义",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"自定义子代理"}),":主 Agent 可自取名字、从你设的",(0,ey.jsx)("b",{children:"可用模型池"}),"里挑模型来召唤,拥有完整 工具集,还能再派发上面三种官方子代理。"]})},{id:"check-update",before:eaH(()=>e.select("check-update")),target:'[data-tour="check-update"]',title:"检查更新",body:(0,ey.jsxs)(ey.Fragment,{children:["这里查看各机器的运行时版本并 ",(0,ey.jsx)("b",{children:"立即更新"}),"。原理:从 npm 拉取最新运行时包、就地替换二进制与 前端,",(0,ey.jsx)("b",{children:"无需重装"}),";P2P mesh 未变时更新还",(0,ey.jsx)("b",{children:"不需要管理员权限"}),"。"]})},{id:"hub-account",before:eaH(()=>e.select("account")),target:'[data-tour="hub-account"]',title:"Hub 账户",body:(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("b",{children:"设置 → Hub 账户"}),"。上方是你的",(0,ey.jsx)("b",{children:"账户信息"}),"与",(0,ey.jsx)("b",{children:"设备绑定"}),"状态——Hub 负责多机互联、组网 下发与云端身份。"]})},{id:"hub-account-danger",before:eaH(()=>e.select("account")),target:'[data-tour="hub-account-danger"]',title:"Hub 账户 · 危险操作",body:(0,ey.jsxs)(ey.Fragment,{children:["下方的 ",(0,ey.jsx)("b",{children:"危险操作"})," 区可",(0,ey.jsx)("b",{children:"解除设备绑定"}),"或",(0,ey.jsx)("b",{children:"退出登录"}),"。这些操作不可逆,会把本机移出 账户,请谨慎。"]})},{id:"new-conversation",before:eaH(()=>e.goHome()),target:'[data-tour="home-new-conversation"]',gate:eaq,gateHint:"点击「新建对话」继续",title:"创建新对话",body:(0,ey.jsxs)(ey.Fragment,{children:["回到主页,请点 ",(0,ey.jsx)("b",{children:"新建对话"})," 进入初始化向导(侧边栏顶部也有同样入口)。"]})},{id:"wizard-1",target:'[data-tour="init-wizard"]',placement:"left",padding:4,waitForTarget:5e3,gate:()=>!eaq()||eaK()>=2,gateHint:"配好运行环境后点向导的「下一步」",title:"向导 ① 运行环境与引擎",body:(0,ey.jsxs)(ey.Fragment,{children:["先选在",(0,ey.jsx)("b",{children:"哪台机器"}),"上运行;本机运行时还能选 ",(0,ey.jsx)("b",{children:"运行引擎"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," / ",(0,ey.jsx)("b",{children:"Claude Code"})," / ",(0,ey.jsx)("b",{children:"reclaude"}),"(Claude Code 仅限本机)。 整个向导区域已高亮,配好后点向导自己的 ",(0,ey.jsx)("b",{children:"下一步"}),"。"]})},{id:"wizard-2",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaq()||eaK()>=3,gateHint:"选好工作目录后点向导的「下一步」",title:"向导 ② 选择工作目录",body:(0,ey.jsxs)(ey.Fragment,{children:["先给对话",(0,ey.jsx)("b",{children:"起个名字"}),",再选 ",(0,ey.jsx)("b",{children:"工作目录"}),"——这是智能体能读写的根目录 (Claude Code 用单个目录作为工作根目录)。选好后点向导的「下一步」。"]})},{id:"wizard-3",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaq()||eaK()>=4,gateHint:"配好模型后点向导的「下一步」",title:"向导 ③ 模型设置",body:(0,ey.jsxs)(ey.Fragment,{children:["选择这段对话使用的",(0,ey.jsx)("b",{children:"模型"}),"——",(0,ey.jsx)("b",{children:"Vantaloom"})," 用你刚配置的模型路由,",(0,ey.jsx)("b",{children:"Claude Code"})," 则由其自身提供模型。选好后点向导的「下一步」。"]})},{id:"wizard-4",target:'[data-tour="init-wizard"]',placement:"left",padding:4,gate:()=>!eaq(),gateHint:"点向导的「确认开始」创建对话",title:"向导 ④ 确认开始",body:(0,ey.jsxs)(ey.Fragment,{children:["核对无误后,点向导右下角的 ",(0,ey.jsx)("b",{children:"确认开始"})," 创建对话。创建成功后会自动进入对话界面。"]})},{id:"composer-toolbar",target:'[data-slot="agent-input-composer-toolbar"]',waitForTarget:6e3,title:"输入框下方的按钮",body:(0,ey.jsxs)(ey.Fragment,{children:["输入框下面一排:",(0,ey.jsx)("b",{children:"权限模式"}),"(工具调用是否需审批)、",(0,ey.jsx)("b",{children:"模型选择"}),"、右侧 ",(0,ey.jsx)("b",{children:"发送 / 停止"}),"按钮(运行中变停止),以及 ",(0,ey.jsx)("b",{children:"上下文用量"})," 指示。"]})},{id:"queue-stack",target:'[data-slot="agent-input-composer-textarea"]',waitForTarget:3e3,title:"待发送栈(Tab 键)",body:(0,ey.jsxs)(ey.Fragment,{children:["输入内容后按 ",(0,ey.jsx)("kbd",{children:"Tab"})," 可把它压入",(0,ey.jsx)("b",{children:"待发送栈"}),"而不立即发送,便于排队多条指令。栈里每条都能 点击:用 ",(0,ey.jsx)("b",{children:"引导"})," 在合适时机插入对话,或删除。"]})},{id:"pane-toolbar",target:'[data-tour="pane-toolbar"]',waitForTarget:3e3,title:"工作区顶栏",body:(0,ey.jsxs)(ey.Fragment,{children:["右侧工作区最上面一排:左边 ",(0,ey.jsx)("b",{children:"布局标签"})," 切换分屏预设,中间 ",(0,ey.jsx)("b",{children:"位置切换"})," 控制对话面板在左 / 居中 / 在右。"]})},{id:"pane-split",target:'[aria-label="上下二分"]',waitForTarget:4e3,gate:()=>null!=eaU('[aria-label="上下二分"][data-state="active"]'),gateHint:"点「上下二分」分栏",title:"动手 · 上下分栏",body:(0,ey.jsxs)(ey.Fragment,{children:["在布局标签里点 ",(0,ey.jsx)("b",{children:"上下二分"}),"(顶部面板图标),把右侧工作区分成上下两块。"]})},{id:"pane-add-top",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=eaU('[placeholder="搜索组件..."]')||null!=eaU('[data-slot="multi-tab-list"]'),gateHint:"点上面板的「添加」",autoAdvance:!0,title:"动手 · 添加上面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["点",(0,ey.jsx)("b",{children:"上面板"}),"中间的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,打开组件选择面板。"]})},{id:"pane-pick-multitab",target:'[data-tour="pane-template-multi-tab-system"]',waitForTarget:3e3,gate:()=>null!=eaU('[data-slot="multi-tab-list"]'),gateHint:"选择「多标签页系统」",title:"动手 · 选多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["在弹出面板里找到 ",(0,ey.jsx)("b",{children:"多标签页系统"}),"(即多文件标签组件)并点击添加,它会填入上面板。"]})},{id:"multi-tab",target:'[data-slot="multi-tab-list"]',waitForTarget:3e3,title:"多文件标签组件",body:(0,ey.jsxs)(ey.Fragment,{children:["顶部是",(0,ey.jsx)("b",{children:"多文件标签条"}),":点 ",(0,ey.jsx)("b",{children:"+"})," 新增标签、点标签切换文件、",(0,ey.jsx)("b",{children:"×"})," 关闭。单文件内还能在",(0,ey.jsx)("b",{children:"查看 / 编辑"})," 与 ",(0,ey.jsx)("b",{children:"代码 / 预览 / 十六进制"})," 间切换,编辑后记得保存。"]})},{id:"pane-add-bottom",target:'[data-tour="pane-add"]',waitForTarget:3e3,gate:()=>null!=eaU('[placeholder="搜索组件..."]')||null!=eaU('[data-slot="terminal-tab-group"]'),gateHint:"点下面板的「添加」",autoAdvance:!0,title:"动手 · 添加下面板组件",body:(0,ey.jsxs)(ey.Fragment,{children:["现在点",(0,ey.jsx)("b",{children:"下面板"}),"的 ",(0,ey.jsx)("b",{children:"添加"})," 按钮,再次打开组件选择面板。"]})},{id:"pane-pick-terminal",target:'[data-tour="pane-template-terminal-tab-group"]',waitForTarget:3e3,gate:()=>null!=eaU('[data-slot="terminal-tab-group"]'),gateHint:"选择「终端标签组」",title:"动手 · 选终端",body:(0,ey.jsxs)(ey.Fragment,{children:["在面板里找到 ",(0,ey.jsx)("b",{children:"终端标签组"})," 并点击添加,它会填入下面板。"]})},{id:"terminal",target:'[data-slot="terminal-tab-group"]',waitForTarget:3e3,title:"终端组件",body:(0,ey.jsxs)(ey.Fragment,{children:["终端支持多会话标签:点 ",(0,ey.jsx)("b",{children:"+"})," 新开会话、点标签切换、",(0,ey.jsx)("b",{children:"×"})," 关闭。直接输入命令即可,输出实时回显,与本机真实 shell 一致。"]})},{id:"pane-cut-clear",target:'[aria-label="剪切窗口内容"]',waitForTarget:3e3,title:"剪切与粉碎",body:(0,ey.jsxs)(ey.Fragment,{children:["顶栏的 ",(0,ey.jsx)("b",{children:"剪切"}),"(剪刀)把窗口内容移动到别处;",(0,ey.jsx)("b",{children:"粉碎"}),"(碎纸机)清空该窗口。均对单个 pane 生效。"]})},{id:"control-room",target:'[data-tour="control-room-toggle"]',waitForTarget:3e3,title:"导播台视角",body:(0,ey.jsxs)(ey.Fragment,{children:["点位置切换中间的 ",(0,ey.jsx)("b",{children:"「隐藏面板」"}),"(矩形图标)进入",(0,ey.jsx)("b",{children:"导播台"}),":对话偏左,右侧悬浮显示主 Agent 与各子 Agent 的实时预览小窗,点小窗即可切换主面板。"]})},{id:"outro",centered:!0,title:"完成 🎉",body:(0,ey.jsxs)(ey.Fragment,{children:["你已走过核心功能。随时可从空白页的 ",(0,ey.jsx)("b",{children:"使用教程"})," 重新打开本向导。开始创造吧!"]})}]}))},[Q,X,ee]),en=ew.useCallback(()=>{i("account")},[]),er=d?.id??s?.conversation.id,ea=!!d&&s?.conversation.id!==d.id;return(0,ey.jsxs)("main",{className:"vtl-app-background relative flex h-svh overflow-hidden text-foreground",children:[e?(0,ey.jsx)(enj,{navItems:enN,contents:enC,activeWorkspace:a,activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:p,activeSubagentPath:f,onOpenSubagent:e=>h(e),title:"new-agent-conversation"===a&&s?s.conversation.title?.trim()||"新 Agent 对话":JD.product,trailing:"new-agent-conversation"===a&&s?(0,ey.jsx)(jc,{view:g,onViewChange:v,paneCount:x}):(0,ey.jsx)(eak,{})}):(0,ey.jsxs)(ey.Fragment,{children:[(0,ey.jsx)("div",{className:(0,eI.cn)("relative hidden h-svh shrink-0 overflow-hidden p-3 transition-[width,padding] duration-300 ease-out md:block",t?"w-0 p-0":"w-[19.5rem]"),children:(0,ey.jsx)(etE,{navItems:enN,contents:enC,activeWorkspace:a,activeConversationId:er,activeCanvasId:F,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenCanvas:(e,t)=>{J(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{s?.conversation.id===e&&(c(void 0),i("home")),k(t=>t?.id===e?void 0:t)},onAccountSettings:en,subagentTree:p,activeSubagentPath:f,onOpenSubagent:e=>h(e)})}),(0,ey.jsx)("div",{className:(0,eI.cn)("group/sb-handle absolute inset-y-0 z-30 hidden w-8 md:block","transition-[left] duration-300 ease-out",t?"left-0":"left-[18.5rem]"),children:(0,ey.jsx)("button",{type:"button",onClick:r,"aria-label":t?"展开侧边栏":"收起侧边栏",title:t?"展开侧边栏":"收起侧边栏",className:"absolute top-1/2 left-0 flex h-14 w-6 -translate-y-1/2 items-center justify-center rounded-r-md border border-l-0 border-border bg-background/85 text-muted-foreground opacity-0 shadow-md backdrop-blur transition-opacity duration-200 hover:text-foreground focus-visible:opacity-100 group-hover/sb-handle:opacity-100",children:t?(0,ey.jsx)(tu,{className:"size-4"}):(0,ey.jsx)(td,{className:"size-4"})})})]}),(0,ey.jsxs)("section",{className:(0,eI.cn)("relative h-full min-w-0 flex-1 overflow-hidden",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:["runs"===a?(0,ey.jsx)(eaF,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"telemetry"===a?(0,ey.jsx)(eaB,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):"preferences-model-routes"===a?(0,ey.jsx)(er7,{section:"model-routes"}):"preferences-agent-config"===a?(0,ey.jsx)(er7,{section:"agent-config"}):"preferences-subagent-config"===a?(0,ey.jsx)(er7,{section:"subagent-config"}):"preferences-cc-engine-config"===a?(0,ey.jsx)(er7,{section:"cc-engine-config"}):"preferences-system-prompt"===a?(0,ey.jsx)(er7,{section:"system-prompt"}):"preferences-layout"===a?(0,ey.jsx)(er7,{section:"layout"}):"network-topology"===a?(0,ey.jsx)(eab,{}):"preferences"===a?(0,ey.jsx)(er7,{}):"check-update"===a?(0,ey.jsx)(ean,{}):"balance-usage"===a?(0,ey.jsx)(eao,{}):"feedback"===a?(0,ey.jsx)(eah,{}):"account"===a?(0,ey.jsx)(enA,{}):e||"new-canvas"!==a?e||"all-canvases"!==a?"new-agent-conversation"===a&&ea?(0,ey.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,ey.jsx)(eM,{className:"size-6 animate-spin"}),(0,ey.jsx)("span",{className:"text-sm",children:"正在打开对话…"})]}):"new-agent-conversation"===a?(0,ey.jsx)(Z9,{conversation:s,clipboardItems:C,clipboardDraggingId:I,onClipboardItemsChange:M,onClipboardDraggingChange:z,onOverlayOpenChange:l,onConversationCreated:e=>{c(e)},onCancelDraft:()=>i("home"),subagentStack:f,onSubagentStackChange:h,subagentTree:p,mobileView:g,onMobilePaneCountChange:y}):e?(0,ey.jsx)(eaZ,{activeConversationId:er,onItemSelect:Q,onOpenConversation:(e,t)=>{G(e,t)},onOpenConversationSettings:(e,t)=>{k({id:e,owner:t})},onConversationDeleted:e=>{k(t=>t?.id===e?void 0:t)}}):(0,ey.jsx)(eaY,{onNewConversation:X,onStartTour:et}):(0,ey.jsx)(ee5,{clipboardItems:C,onClipboardItemsChange:M,onOverlayOpenChange:N}):(0,ey.jsx)(ete,{nodes:T,edges:_,selectedNodeId:L,clipboardItems:C,onNodesChange:W,onEdgesChange:q,onNodesSet:D,onEdgesSet:R,onSelectedNodeChange:$,onClipboardItemsChange:M}),j?(0,ey.jsx)("div",{className:(0,eI.cn)("absolute inset-0 z-30",e&&"pt-[calc(3rem+env(safe-area-inset-top))]"),children:(0,ey.jsx)(Jc,{conversationId:j.id,ownerMachineId:j.owner,open:!0,onOpenChange:e=>{e||k(void 0)},onEnterConversation:(e,t)=>{G(e,t)}})}):null,(0,ey.jsx)(etr,{hidden:!!j||("new-agent-conversation"===a?o:S),items:C,trashItems:E,draggingId:I,onDraggingChange:z,onItemsChange:M,onTrashItemsChange:O,onTrashClipboardItemsChange:A,trashClipboardItems:P})]})]})}function eaY({onNewConversation:e,onStartTour:t}){return(0,ey.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col items-center justify-center gap-5 px-6 text-center",children:[(0,ey.jsx)(eaV,{className:"h-20 w-auto max-w-[78vw] text-foreground"}),(0,ey.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"从左侧选择一个会话,或新建对话"}),(0,ey.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,ey.jsxs)(eA.Button,{type:"button",onClick:e,"data-tour":"home-new-conversation",children:[(0,ey.jsx)(tc,{className:"size-4"}),"新建对话"]}),(0,ey.jsxs)(eA.Button,{type:"button",variant:"outline",onClick:t,children:[(0,ey.jsx)(ts,{className:"size-4"}),"使用教程"]})]})]})}function eaZ({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a}){return(0,ey.jsx)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col px-3 pt-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:(0,ey.jsx)(etz,{activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a})})}function eaJ(){let{ready:e,user:t,logout:n}=tl();return e?t?(0,ey.jsx)(eaX,{}):(0,ey.jsx)(ta,{onComplete:()=>{window.location.reload()}}):(0,ey.jsx)("main",{className:"grid min-h-svh place-items-center bg-background",children:(0,ey.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,ey.jsx)("div",{className:"size-8 animate-spin rounded-full border-2 border-muted-foreground/20 border-t-primary"}),(0,ey.jsx)("span",{className:"text-sm text-muted-foreground",children:"连接中..."})]})})}function eaQ(){return(0,ey.jsx)(to,{children:(0,ey.jsx)(eaJ,{})})}e.s(["default",()=>eaQ],66204)}]);