PageSourceSearch

https://loothing.xyz/assets/LogsDashboard-VrvP7EV5.js

js loothing.xyz collected 2026-10-02 02:11:36 UTC 105,815 bytes, 1 lines download raw bytes

1import{r as e,j as t,R as n}from"./react-vendor-BR2bEzcq.js";import{f as r,W as s,M as a,T as i,U as o,Z as l,X as c,ay as u,R as d,V as h,u as f,n as p,a2 as m,D as x,e as g}from"./index-CpSDEIFT.js";import{c as y}from"./axios-ClGXtqae.js";import{i as v,r as b,D as j,u as w,a as _,b as N,c as k,s as M,Z as A,L as C,d as S,e as T,f as E,g as z,h as D,j as P,k as I,l as R,m as $,R as O,C as F,X as q,Y as U,T as L}from"./CartesianChart-CJP895CR.js";import{H as B}from"./heart-Df9HZ-_i.js";import{T as X}from"./trending-down-nNlnueFl.js";import{L as Y,a as K}from"./LineChart-DuppiAd8.js";import{L as V}from"./Legend-B_clldbU.js";import{c as H}from"./clsx-BeLtu-UY.js";import{D as G}from"./ActivePoints-CeXlCaxs.js";import{R as W}from"./rotate-ccw-CI66U1aK.js";import{f as Z}from"./format-BPQ5viyt.js";import{s as Q}from"./subDays-BNr-serX.js";import{C as J}from"./calendar-OSP8Zfeh.js";import{M as ee}from"./message-square-CUDp72-o.js";import{S as te}from"./share-2-BlQHCczL.js";import{C as ne}from"./cpu-Cmd8LMsD.js";import{D as re}from"./dollar-sign-DsNTuXUa.js";import{A as se,a as ae}from"./AreaChart-3hlWfU6s.js";import{P as ie,a as oe}from"./PieChart-BVx64xJE.js";import{C as le}from"./tooltipContext-D4fI65nP.js";import{B as ce,a as ue}from"./BarChart-CDq0sWXE.js";import{f as de}from"./formatDistanceToNow-DHqcac7O.js";import"./with-selector-Cp5zxiKA.js";import"./getRadiusAndStrokeWidthFromDot-u2LADL0U.js";import"./en-US-BlnZe3UH.js";import"./differenceInCalendarDays-D-3UYz_J.js";import"./normalizeDates-qiIF0jUi.js";import"./addDays-DIeWNO1l.js";import"./graphicalItemSelectors-DaiV37_D.js";import"./differenceInSeconds-CVG5JT0q.js";var he,fe=180/Math.PI,pe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function me(e,t,n,r,s,a){var i,o,l;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*fe,skewX:Math.atan(l)*fe,scaleX:i,scaleY:o}}function xe(e,t,n,r){function s(e){return e.length?e.pop()+" ":""}return function(a,i){var o=[],l=[];return a=e(a),i=e(i),function(e,r,s,a,i,o){if(e!==s||r!==a){var l=i.push("translate(",null,t,null,n);o.push({i:l-4,x:v(e,s)},{i:l-2,x:v(r,a)})}else(s||a)&&i.push("translate("+s+t+a+n)}(a.translateX,a.translateY,i.translateX,i.translateY,o,l),function(e,t,n,a){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(s(n)+"rotate(",null,r)-2,x:v(e,t)})):t&&n.push(s(n)+"rotate("+t+r)}(a.rotate,i.rotate,o,l),function(e,t,n,a){e!==t?a.push({i:n.push(s(n)+"skewX(",null,r)-2,x:v(e,t)}):t&&n.push(s(n)+"skewX("+t+r)}(a.skewX,i.skewX,o,l),function(e,t,n,r,a,i){if(e!==n||t!==r){var o=a.push(s(a)+"scale(",null,",",null,")");i.push({i:o-4,x:v(e,n)},{i:o-2,x:v(t,r)})}else 1===n&&1===r||a.push(s(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,i.scaleX,i.scaleY,o,l),a=i=null,function(e){for(var t,n=-1,r=l.length;++n<r;)o[(t=l[n]).i]=t.x(e);return o.join("")}}}var ge=xe(function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?pe:me(t.a,t.b,t.c,t.d,t.e,t.f)},"px, ","px)","deg)"),ye=xe(function(e){return null==e?pe:(he||(he=document.createElementNS("http://www.w3.org/2000/svg","g")),he.setAttribute("transform",e),(e=he.transform.baseVal.consolidate())?me((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):pe)},", ",")",")");function ve(e){return((e=Math.exp(e))+1/e)/2}const be=function e(t,n,r){function s(e,s){var a,i,o=e[0],l=e[1],c=e[2],u=s[0],d=s[1],h=s[2],f=u-o,p=d-l,m=f*f+p*p;if(m<1e-12)i=Math.log(h/c)/t,a=function(e){return[o+e*f,l+e*p,c*Math.exp(t*e*i)]};else{var x=Math.sqrt(m),g=(h*h-c*c+r*m)/(2*c*n*x),y=(h*h-c*c-r*m)/(2*h*n*x),v=Math.log(Math.sqrt(g*g+1)-g),b=Math.log(Math.sqrt(y*y+1)-y);i=(b-v)/t,a=function(e){var r,s=e*i,a=ve(v),u=c/(n*x)*(a*(r=t*s+v,((r=Math.exp(2*r))-1)/(r+1))-function(e){return((e=Math.exp(e))-1/e)/2}(v));return[o+u*f,l+u*p,c*a/ve(t*s+v)]}}return a.duration=1e3*i*t/Math.SQRT2,a}return s.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},s}(Math.SQRT2,2,4);class je{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var n,r,{position:s}=t;return{x:null!==(n=this.xAxisScale.map(e.x,{position:s}))&&void 0!==n?n:0,y:null!==(r=this.yAxisScale.map(e.y,{position:s}))&&void 0!==r?r:0}}mapWithFallback(e,t){var n,r,s,a,{position:i,fallback:o}=t;return s="rangeMin"===o?this.yAxisScale.rangeMin():"rangeMax"===o?this.yAxisScale.rangeMax():0,a="rangeMin"===o?this.xAxisScale.rangeMin():"rangeMax"===o?this.xAxisScale.rangeMax():0,{x:null!==(n=this.xAxisScale.map(e.x,{position:i}))&&void 0!==n?n:a,y:null!==(r=this.yAxisScale.map(e.y,{position:i}))&&void 0!==r?r:s}}isInRange(e){var{x:t,y:n}=e,r=null==t||this.xAxisScale.isInRange(t),s=null==n||this.yAxisScale.isInRange(n);return r&&s}}function we(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 _e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?we(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):we(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=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);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ke(){return ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ke.apply(null,arguments)}function Me(t){var n=w();return e.useEffect(()=>(n(_(t)),()=>{n(N(t))})),null}function Ae(t){var{x:n,y:r,r:s}=t,a=k(),i=((e,t,n,r,s)=>{var a=P(e),i=P(t),o=E(),l=z(e=>D(e,"xAxis",n,o)),c=z(e=>D(e,"yAxis",r,o));if(!a||!i||null==l||null==c)return null;var u=new je({x:l,y:c}),d=u.map({x:e,y:t},{position:"middle"});return"discard"!==s||u.isInRange(d)?d:null})(n,r,t.xAxisId,t.yAxisId,t.ifOverflow);if(!i)return null;var{x:o,y:l}=i,{shape:c,className:u,ifOverflow:d}=t,h=_e(_e({clipPath:"hidden"===d?"url(#".concat(a,")"):void 0},M(t)),{},{cx:null!=o?o:void 0,cy:null!=l?l:void 0});return e.createElement(A,{zIndex:t.zIndex},e.createElement(C,{className:H("recharts-reference-dot",u)},((t,n)=>e.isValidElement(t)?e.cloneElement(t,n):"function"==typeof t?t(n):e.createElement(G,ke({},n,{cx:n.cx,cy:n.cy,className:"recharts-reference-dot-dot"})))(c,h),e.createElement(S,{x:o-s,y:l-s,width:2*s,height:2*s,upperWidth:2*s,lowerWidth:2*s},e.createElement(T,{label:t.label}),t.children)))}var Ce={ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,label:!1,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1,zIndex:j.scatter};function Se(t){var n=b(t,Ce),{x:r,y:s,r:a,ifOverflow:i,yAxisId:o,xAxisId:l}=n;return e.createElement(e.Fragment,null,e.createElement(Me,{y:s,x:r,r:a,yAxisId:o,xAxisId:l,ifOverflow:i}),e.createElement(Ae,n))}Se.displayName="ReferenceDot";var Te={value:()=>{}};function Ee(){for(var e,t=0,n=arguments.length,r={};t<n;++t){if(!(e=arguments[t]+"")||e in r||/[\s.]/.test(e))throw new Error("illegal type: "+e);r[e]=[]}return new ze(r)}function ze(e){this._=e}function De(e,t){for(var n,r=0,s=e.length;r<s;++r)if((n=e[r]).name===t)return n.value}function Pe(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Te,e=e.slice(0,r).concat(e.slice(r+1));break}return null!=n&&e.push({name:t,value:n}),e}ze.prototype=Ee.prototype={constructor:ze,on:function(e,t){var n,r,s=this._,a=(r=s,(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 new Error("unknown type: "+e);return{type:e,name:t}})),i=-1,o=a.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++i<o;)if(n=(e=a[i]).type)s[n]=Pe(s[n],e.name,t);else if(null==t)for(n in s)s[n]=Pe(s[n],e.name,null);return this}for(;++i<o;)if((n=(e=a[i]).type)&&(n=De(s[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ze(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,r,s=new Array(n),a=0;a<n;++a)s[a]=arguments[a+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=0,n=(r=this._[e]).length;a<n;++a)r[a].value.apply(t,s)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,a=r.length;s<a;++s)r[s].value.apply(t,n)}};var Ie="http://www.w3.org/1999/xhtml";const Re={svg:"http://www.w3.org/2000/svg",xhtml:Ie,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function $e(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),Re.hasOwnProperty(t)?{space:Re[t],local:e}:e}function Oe(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ie&&t.documentElement.namespaceURI===Ie?t.createElement(e):t.createElementNS(n,e)}}function Fe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qe(e){var t=$e(e);return(t.local?Fe:Oe)(t)}function Ue(){}function Le(e){return null==e?Ue:function(){return this.querySelector(e)}}function Be(){return[]}function Xe(e){return null==e?Be:function(){return this.querySelectorAll(e)}}function Ye(e){return function(){return this.matches(e)}}function Ke(e){return function(t){return t.matches(e)}}var Ve=Array.prototype.find;function He(){return this.firstElementChild}var Ge=Array.prototype.filter;function We(){return Array.from(this.children)}function Ze(e){return new Array(e.length)}function Qe(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function Je(e,t,n,r,s,a){for(var i,o=0,l=t.length,c=a.length;o<c;++o)(i=t[o])?(i.__data__=a[o],r[o]=i):n[o]=new Qe(e,a[o]);for(;o<l;
vendor: 14,786 bytes, line 1
1++o)(i=t[o])&&(s[o]=i)}function et(e,t,n,r,s,a,i){var o,l,c,u=new Map,d=t.length,h=a.length,f=new Array(d);for(o=0;o<d;++o)(l=t[o])&&(f[o]=c=i.call(l,l.__data__,o,t)+"",u.has(c)?s[o]=l:u.set(c,l));for(o=0;o<h;++o)c=i.call(e,a[o],o,a)+"",(l=u.get(c))?(r[o]=l,l.__data__=a[o],u.delete(c)):n[o]=new Qe(e,a[o]);for(o=0;o<d;++o)(l=t[o])&&u.get(f[o])===l&&(s[o]=l)}function tt(e){return e.__data__}function nt(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function rt(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function st(e){return function(){this.removeAttribute(e)}}function at(e){return function(){this.removeAttributeNS(e.space,e.local)}}function it(e,t){return function(){this.setAttribute(e,t)}}function ot(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lt(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function ct(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 ut(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dt(e){return function(){this.style.removeProperty(e)}}function ht(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ft(e,t,n){return function(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function pt(e,t){return e.style.getPropertyValue(t)||ut(e).getComputedStyle(e,null).getPropertyValue(t)}function mt(e){return function(){delete this[e]}}function xt(e,t){return function(){this[e]=t}}function gt(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function yt(e){return e.trim().split(/^|\s+/)}function vt(e){return e.classList||new bt(e)}function bt(e){this._node=e,this._names=yt(e.getAttribute("class")||"")}function jt(e,t){for(var n=vt(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function wt(e,t){for(var n=vt(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function _t(e){return function(){jt(this,e)}}function Nt(e){return function(){wt(this,e)}}function kt(e,t){return function(){(t.apply(this,arguments)?jt:wt)(this,e)}}function Mt(){this.textContent=""}function At(e){return function(){this.textContent=e}}function Ct(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function St(){this.innerHTML=""}function Tt(e){return function(){this.innerHTML=e}}function Et(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function zt(){this.nextSibling&&this.parentNode.appendChild(this)}function Dt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Pt(){return null}function It(){var e=this.parentNode;e&&e.removeChild(this)}function Rt(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $t(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ot(e){return function(){var t=this.__on;if(t){for(var n,r=0,s=-1,a=t.length;r<a;++r)n=t[r],e.type&&n.type!==e.type||n.name!==e.name?t[++s]=n:this.removeEventListener(n.type,n.listener,n.options);++s?t.length=s:delete this.__on}}}function Ft(e,t,n){return function(){var r,s=this.__on,a=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(s)for(var i=0,o=s.length;i<o;++i)if((r=s[i]).type===e.type&&r.name===e.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=t);this.addEventListener(e.type,a,n),r={type:e.type,name:e.name,value:t,listener:a,options:n},s?s.push(r):this.__on=[r]}}function qt(e,t,n){var r=ut(e),s=r.CustomEvent;"function"==typeof s?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Ut(e,t){return function(){return qt(this,e,t)}}function Lt(e,t){return function(){return qt(this,e,t.apply(this,arguments))}}Qe.prototype={constructor:Qe,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)}},bt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var Bt=[null];function Xt(e,t){this._groups=e,this._parents=t}function Yt(){return new Xt([[document.documentElement]],Bt)}function Kt(e){return"string"==typeof e?new Xt([[document.querySelector(e)]],[document.documentElement]):new Xt([[e]],Bt)}function Vt(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 s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}Xt.prototype=Yt.prototype={constructor:Xt,select:function(e){"function"!=typeof e&&(e=Le(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a,i,o=t[s],l=o.length,c=r[s]=new Array(l),u=0;u<l;++u)(a=o[u])&&(i=e.call(a,a.__data__,u,o))&&("__data__"in a&&(i.__data__=a.__data__),c[u]=i);return new Xt(r,this._parents)},selectAll:function(e){e="function"==typeof e?function(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}(e):Xe(e);for(var t=this._groups,n=t.length,r=[],s=[],a=0;a<n;++a)for(var i,o=t[a],l=o.length,c=0;c<l;++c)(i=o[c])&&(r.push(e.call(i,i.__data__,c,o)),s.push(i));return new Xt(r,s)},selectChild:function(e){return this.select(null==e?He:function(e){return function(){return Ve.call(this.children,e)}}("function"==typeof e?e:Ke(e)))},selectChildren:function(e){return this.selectAll(null==e?We:function(e){return function(){return Ge.call(this.children,e)}}("function"==typeof e?e:Ke(e)))},filter:function(e){"function"!=typeof e&&(e=Ye(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a,i=t[s],o=i.length,l=r[s]=[],c=0;c<o;++c)(a=i[c])&&e.call(a,a.__data__,c,i)&&l.push(a);return new Xt(r,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,tt);var n,r=t?et:Je,s=this._parents,a=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var i=a.length,o=new Array(i),l=new Array(i),c=new Array(i),u=0;u<i;++u){var d=s[u],h=a[u],f=h.length,p=nt(e.call(d,d&&d.__data__,u,s)),m=p.length,x=l[u]=new Array(m),g=o[u]=new Array(m);r(d,h,x,g,c[u]=new Array(f),p,t);for(var y,v,b=0,j=0;b<m;++b)if(y=x[b]){for(b>=j&&(j=b+1);!(v=g[j])&&++j<m;);y._next=v||null}}return(o=new Xt(o,s))._enter=l,o._exit=c,o},enter:function(){return new Xt(this._enter||this._groups.map(Ze),this._parents)},exit:function(){return new Xt(this._exit||this._groups.map(Ze),this._parents)},join:function(e,t,n){var r=this.enter(),s=this,a=this.exit();return"function"==typeof e?(r=e(r))&&(r=r.selection()):r=r.append(e+""),null!=t&&(s=t(s))&&(s=s.selection()),null==n?a.remove():n(a),r&&s?r.merge(s).order():s},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,a=r.length,i=Math.min(s,a),o=new Array(s),l=0;l<i;++l)for(var c,u=n[l],d=r[l],h=u.length,f=o[l]=new Array(h),p=0;p<h;++p)(c=u[p]||d[p])&&(f[p]=c);for(;l<s;++l)o[l]=n[l];return new Xt(o,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r,s=e[t],a=s.length-1,i=s[a];--a>=0;)(r=s[a])&&(i&&4^r.compareDocumentPosition(i)&&i.parentNode.insertBefore(r,i),i=r);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=rt);for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a){for(var i,o=n[a],l=o.length,c=s[a]=new Array(l),u=0;u<l;++u)(i=o[u])&&(c[u]=i);c.sort(t)}return new Xt(s,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],s=0,a=r.length;s<a;++s){var i=r[s];if(i)return i}return null},size:function(){let e=0;for(const 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 s,a=t[n],i=0,o=a.length;i<o;++i)(s=a[i])&&e.call(s,s.__data__,i,a);return this},attr:function(e,t){var n=$e(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?at:st:"function"==typeof t?n.local?ct:lt:n.local?ot:it)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?dt:"function"==typeof t?ft:ht)(e,t,null==n?"":n)):pt(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?mt:"function"==typeof t?gt:xt)(e,t)):this.node()[e]},classed:function(e,t){var n=yt(e+"");if(arguments.length<2){for(var r=vt(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each(("function"==typeof t?kt:t?_t:Nt)(n,t))},text:function(e){return arguments.length?this.each(null==e?Mt:("function"==typeof e?Ct:At)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?St:("function"==typeof e?Et:Tt)(e)):this.node().innerHTML},raise:function(){return this.each(zt)},lower:function(){return this.each(Dt)},append:function(e){var t="function"==typeof e?e:qe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})},insert:function(e,t){var n="function"==typeof e?e:qe(e),r=null==t?Pt:"function"==typeof t?t:Le(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(It)},clone:function(e){return this.select(e?$t:Rt)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var r,s,a=function(e){return 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}})}(e+""),i=a.length;if(!(arguments.length<2)){for(o=t?Ft:Ot,r=0;r<i;++r)this.each(o(a[r],t,n));return this}var o=this.node().__on;if(o)for(var l,c=0,u=o.length;c<u;++c)for(r=0,l=o[c];r<i;++r)if((s=a[r]).type===l.type&&s.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?Lt:Ut)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r,s=e[t],a=0,i=s.length;a<i;++a)(r=s[a])&&(yield r)}};const Ht={passive:!1},Gt={capture:!0,passive:!1};function Wt(e){e.stopImmediatePropagation()}function Zt(e){e.preventDefault(),e.stopImmediatePropagation()}function Qt(e){var t=e.document.documentElement,n=Kt(e).on("dragstart.drag",Zt,Gt);"onselectstart"in t?n.on("selectstart.drag",Zt,Gt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Jt(e,t){var n=e.document.documentElement,r=Kt(e).on("dragstart.drag",null);t&&(r.on("click.drag",Zt,Gt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const en=e=>()=>e;function tn(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:o,dx:l,dy:c,dispatch:u}){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:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function nn(e){return!e.ctrlKey&&!e.button}function rn(){return this.parentNode}function sn(e,t){return null==t?{x:e.x,y:e.y}:t}function an(){return navigator.maxTouchPoints||"ontouchstart"in this}tn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var on,ln,cn=0,un=0,dn=0,hn=0,fn=0,pn=0,mn="object"==typeof performance&&performance.now?performance:Date,xn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function gn(){return fn||(xn(yn),fn=mn.now()+pn)}function yn(){fn=0}function vn(){this._call=this._time=this._next=null}function bn(e,t,n){var r=new vn;return r.restart(e,t,n),r}function jn(){fn=(hn=mn.now())+pn,cn=un=0;try{!function(){gn(),++cn;for(var e,t=on;t;)(e=fn-t._time)>=0&&t._call.call(void 0,e),t=t._next;--cn}()}finally{cn=0,function(){for(var e,t,n=on,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:on=t);ln=e,_n(r)}(),fn=0}}function wn(){var e=mn.now(),t=e-hn;t>1e3&&(pn-=t,hn=e)}function _n(e){cn||(un&&(un=clearTimeout(un)),e-fn>24?(e<1/0&&(un=setTimeout(jn,e-mn.now()-pn)),dn&&(dn=clearInterval(dn))):(dn||(hn=mn.now(),dn=setInterval(wn,1e3)),cn=1,xn(jn)))}function Nn(e,t,n){var r=new vn;return t=null==t?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}vn.prototype=bn.prototype={constructor:vn,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?gn():+n)+(null==t?0:+t),this._next||ln===this||(ln?ln._next=this:on=this,ln=this),this._call=e,this._time=n,_n()},stop:function(){this._call&&(this._call=null,this._time=1/0,_n())}};var kn=Ee("start","end","cancel","interrupt"),Mn=[];function An(e,t,n,r,s,a){var i=e.__transition;if(i){if(n in i)return}else e.__transition={};!function(e,t,n){var r,s=e.__transition;function a(l){var c,u,d,h;if(1!==n.state)return o();for(c in s)if((h=s[c]).name===n.name){if(3===h.state)return Nn(a);4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete s[c]):+c<t&&(h.state=6,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete s[c])}if(Nn(function(){3===n.state&&(n.state=4,n.timer.restart(i,n.delay,n.time),i(l))}),n.state=2,n.on.call("start",e,e.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=h);r.length=u+1}}function i(t){for(var s=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(o),n.state=5,1
vendor: 9,945 bytes, line 1
1),a=-1,i=r.length;++a<i;)r[a].call(e,s);5===n.state&&(n.on.call("end",e,e.__data__,n.index,n.group),o())}function o(){for(var r in n.state=6,n.timer.stop(),delete s[t],s)return;delete e.__transition}s[t]=n,n.timer=bn(function(e){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)},0,n.time)}(e,n,{name:t,index:r,group:s,on:kn,tween:Mn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Cn(e,t){var n=Tn(e,t);if(n.state>0)throw new Error("too late; already scheduled");return n}function Sn(e,t){var n=Tn(e,t);if(n.state>3)throw new Error("too late; already running");return n}function Tn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function En(e,t){var n,r,s,a=e.__transition,i=!0;if(a){for(s in t=null==t?null:t+"",a)(n=a[s]).name===t?(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 a[s]):i=!1;i&&delete e.__transition}}function zn(e,t){var n,r;return function(){var s=Sn(this,e),a=s.tween;if(a!==n)for(var i=0,o=(r=n=a).length;i<o;++i)if(r[i].name===t){(r=r.slice()).splice(i,1);break}s.tween=r}}function Dn(e,t,n){var r,s;if("function"!=typeof n)throw new Error;return function(){var a=Sn(this,e),i=a.tween;if(i!==r){s=(r=i).slice();for(var o={name:t,value:n},l=0,c=s.length;l<c;++l)if(s[l].name===t){s[l]=o;break}l===c&&s.push(o)}a.tween=s}}function Pn(e,t,n){var r=e._id;return e.each(function(){var e=Sn(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)}),function(e){return Tn(e,r).value[t]}}function In(e,t){var n;return("number"==typeof t?v:t instanceof I?R:(n=I(t))?(t=n,R):$)(e,t)}function Rn(e){return function(){this.removeAttribute(e)}}function $n(e){return function(){this.removeAttributeNS(e.space,e.local)}}function On(e,t,n){var r,s,a=n+"";return function(){var i=this.getAttribute(e);return i===a?null:i===r?s:s=t(r=i,n)}}function Fn(e,t,n){var r,s,a=n+"";return function(){var i=this.getAttributeNS(e.space,e.local);return i===a?null:i===r?s:s=t(r=i,n)}}function qn(e,t,n){var r,s,a;return function(){var i,o,l=n(this);if(null!=l)return(i=this.getAttribute(e))===(o=l+"")?null:i===r&&o===s?a:(s=o,a=t(r=i,l));this.removeAttribute(e)}}function Un(e,t,n){var r,s,a;return function(){var i,o,l=n(this);if(null!=l)return(i=this.getAttributeNS(e.space,e.local))===(o=l+"")?null:i===r&&o===s?a:(s=o,a=t(r=i,l));this.removeAttributeNS(e.space,e.local)}}function Ln(e,t){var n,r;function s(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,s)),n}return s._value=t,s}function Bn(e,t){var n,r;function s(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,s)),n}return s._value=t,s}function Xn(e,t){return function(){Cn(this,e).delay=+t.apply(this,arguments)}}function Yn(e,t){return t=+t,function(){Cn(this,e).delay=t}}function Kn(e,t){return function(){Sn(this,e).duration=+t.apply(this,arguments)}}function Vn(e,t){return t=+t,function(){Sn(this,e).duration=t}}var Hn=Yt.prototype.constructor;function Gn(e){return function(){this.style.removeProperty(e)}}var Wn=0;function Zn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Qn(){return++Wn}var Jn=Yt.prototype;Zn.prototype={constructor:Zn,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=Le(e));for(var r=this._groups,s=r.length,a=new Array(s),i=0;i<s;++i)for(var o,l,c=r[i],u=c.length,d=a[i]=new Array(u),h=0;h<u;++h)(o=c[h])&&(l=e.call(o,o.__data__,h,c))&&("__data__"in o&&(l.__data__=o.__data__),d[h]=l,An(d[h],t,n,h,d,Tn(o,n)));return new Zn(a,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=Xe(e));for(var r=this._groups,s=r.length,a=[],i=[],o=0;o<s;++o)for(var l,c=r[o],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var h,f=e.call(l,l.__data__,d,c),p=Tn(l,n),m=0,x=f.length;m<x;++m)(h=f[m])&&An(h,t,n,m,f,p);a.push(f),i.push(l)}return new Zn(a,i,t,n)},selectChild:Jn.selectChild,selectChildren:Jn.selectChildren,filter:function(e){"function"!=typeof e&&(e=Ye(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a,i=t[s],o=i.length,l=r[s]=[],c=0;c<o;++c)(a=i[c])&&e.call(a,a.__data__,c,i)&&l.push(a);return new Zn(r,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,a=Math.min(r,s),i=new Array(r),o=0;o<a;++o)for(var l,c=t[o],u=n[o],d=c.length,h=i[o]=new Array(d),f=0;f<d;++f)(l=c[f]||u[f])&&(h[f]=l);for(;o<r;++o)i[o]=t[o];return new Zn(i,this._parents,this._name,this._id)},selection:function(){return new Hn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Qn(),r=this._groups,s=r.length,a=0;a<s;++a)for(var i,o=r[a],l=o.length,c=0;c<l;++c)if(i=o[c]){var u=Tn(i,t);An(i,e,n,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Zn(r,this._parents,e,n)},call:Jn.call,nodes:Jn.nodes,node:Jn.node,size:Jn.size,empty:Jn.empty,each:Jn.each,on:function(e,t){var n=this._id;return arguments.length<2?Tn(this.node(),n).on.on(e):this.each(function(e,t,n){var r,s,a=function(e){return(e+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e})}(t)?Cn:Sn;return function(){var i=a(this,e),o=i.on;o!==r&&(s=(r=o).copy()).on(t,n),i.on=s}}(n,e,t))},attr:function(e,t){var n=$e(e),r="transform"===n?ye:In;return this.attrTween(e,"function"==typeof t?(n.local?Un:qn)(n,r,Pn(this,"attr."+e,t)):null==t?(n.local?$n:Rn)(n):(n.local?Fn:On)(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 new Error;var r=$e(e);return this.tween(n,(r.local?Ln:Bn)(r,t))},style:function(e,t,n){var r="transform"==(e+="")?ge:In;return null==t?this.styleTween(e,function(e,t){var n,r,s;return function(){var a=pt(this,e),i=(this.style.removeProperty(e),pt(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}(e,r)).on("end.style."+e,Gn(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var r,s,a;return function(){var i=pt(this,e),o=n(this),l=o+"";return null==o&&(this.style.removeProperty(e),l=o=pt(this,e)),i===l?null:i===r&&l===s?a:(s=l,a=t(r=i,o))}}(e,r,Pn(this,"style."+e,t))).each(function(e,t){var n,r,s,a,i="style."+t,o="end."+i;return function(){var l=Sn(this,e),c=l.on,u=null==l.value[i]?a||(a=Gn(t)):void 0;c===n&&s===u||(r=(n=c).copy()).on(o,s=u),l.on=r}}(this._id,e)):this.styleTween(e,function(e,t,n){var r,s,a=n+"";return function(){var i=pt(this,e);return i===a?null:i===r?s:s=t(r=i,n)}}(e,r,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 new Error;return this.tween(r,function(e,t,n){var r,s;function a(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&function(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}(e,a,n)),r}return a._value=t,a}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(Pn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},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 new 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){return function(t){this.textContent=e.call(this,t)}}(r)),t}return r._value=e,r}(e))},remove:function(){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)}));var e},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r,s=Tn(this.node(),n).tween,a=0,i=s.length;a<i;++a)if((r=s[a]).name===e)return r.value;return null}return this.each((null==t?zn:Dn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Xn:Yn)(t,e)):Tn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Kn:Vn)(t,e)):Tn(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){Sn(this,e).ease=t}}(t,e)):Tn(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;Sn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(a,i){var o={value:i},l={value:function(){0===--s&&a()}};n.each(function(){var n=Sn(this,r),s=n.on;s!==e&&((t=(e=s).copy())._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),n.on=t}),0===s&&a()})},[Symbol.iterator]:Jn[Symbol.iterator]};var er={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function tr(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function nr(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var s,a,i,o,l,c,u,d,h,f=e._root,p={data:r},m=e._x0,x=e._y0,g=e._x1,y=e._y1;if(!f)return e._root=p,e;for(;f.length;)if((c=t>=(a=(m+g)/2))?m=a:g=a,(u=n>=(i=(x+y)/2))?x=i:y=i,s=f,!(f=f[d=u<<1|c]))return s[d]=p,e;if(o=+e._x.call(null,f.data),l=+e._y.call(null,f.data),t===o&&n===l)return p.next=f,s?s[d]=p:e._root=p,e;do{s=s?s[d]=new Array(4):e._root=new Array(4),(c=t>=(a=(m+g)/2))?m=a:g=a,(u=n>=(i=(x+y)/2))?x=i:y=i}while((d=u<<1|c)==(h=(l>=i)<<1|o>=a));return s[h]=f,s[d]=p,e}
vendor: 6,826 bytes, line 1
1function rr(e,t,n,r,s){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=s}function sr(e){return e[0]}function ar(e){return e[1]}function ir(e,t,n){var r=new or(null==t?sr:t,null==n?ar:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}function or(e,t,n,r,s,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=s,this._y1=a,this._root=void 0}function lr(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}Yt.prototype.interrupt=function(e){return this.each(function(){En(this,e)})},Yt.prototype.transition=function(e){var t,n;e instanceof Zn?(t=e._id,e=e._name):(t=Qn(),(n=er).time=gn(),e=null==e?null:e+"");for(var r=this._groups,s=r.length,a=0;a<s;++a)for(var i,o=r[a],l=o.length,c=0;c<l;++c)(i=o[c])&&An(i,e,t,c,o,n||tr(i,t));return new Zn(r,this._parents,e,t)};var cr=ir.prototype=or.prototype;function ur(e){return function(){return e}}function dr(e){return 1e-6*(e()-.5)}function hr(e){return e.x+e.vx}function fr(e){return e.y+e.vy}function pr(e){return e.index}function mr(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}cr.copy=function(){var e,t,n=new or(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=lr(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var s=0;s<4;++s)(t=r.source[s])&&(t.length?e.push({source:t,target:r.target[s]=new Array(4)}):r.target[s]=lr(t));return n},cr.add=function(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return nr(this.cover(t,n),t,n,e)},cr.addAll=function(e){var t,n,r,s,a=e.length,i=new Array(a),o=new Array(a),l=1/0,c=1/0,u=-1/0,d=-1/0;for(n=0;n<a;++n)isNaN(r=+this._x.call(null,t=e[n]))||isNaN(s=+this._y.call(null,t))||(i[n]=r,o[n]=s,r<l&&(l=r),r>u&&(u=r),s<c&&(c=s),s>d&&(d=s));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),n=0;n<a;++n)nr(this,i[n],o[n],e[n]);return this},cr.cover=function(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,s=this._x1,a=this._y1;if(isNaN(n))s=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var i,o,l=s-n||1,c=this._root;n>e||e>=s||r>t||t>=a;)switch(o=(t<r)<<1|e<n,(i=new Array(4))[o]=c,c=i,l*=2,o){case 0:s=n+l,a=r+l;break;case 1:n=s-l,a=r+l;break;case 2:s=n+l,r=a-l;break;case 3:n=s-l,r=a-l}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=s,this._y1=a,this},cr.data=function(){var e=[];return this.visit(function(t){if(!t.length)do{e.push(t.data)}while(t=t.next)}),e},cr.extent=function(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},cr.find=function(e,t,n){var r,s,a,i,o,l,c,u=this._x0,d=this._y0,h=this._x1,f=this._y1,p=[],m=this._root;for(m&&p.push(new rr(m,u,d,h,f)),null==n?n=1/0:(u=e-n,d=t-n,h=e+n,f=t+n,n*=n);l=p.pop();)if(!(!(m=l.node)||(s=l.x0)>h||(a=l.y0)>f||(i=l.x1)<u||(o=l.y1)<d))if(m.length){var x=(s+i)/2,g=(a+o)/2;p.push(new rr(m[3],x,g,i,o),new rr(m[2],s,g,x,o),new rr(m[1],x,a,i,g),new rr(m[0],s,a,x,g)),(c=(t>=g)<<1|e>=x)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=l)}else{var y=e-+this._x.call(null,m.data),v=t-+this._y.call(null,m.data),b=y*y+v*v;if(b<n){var j=Math.sqrt(n=b);u=e-j,d=t-j,h=e+j,f=t+j,r=m.data}}return r},cr.remove=function(e){if(isNaN(a=+this._x.call(null,e))||isNaN(i=+this._y.call(null,e)))return this;var t,n,r,s,a,i,o,l,c,u,d,h,f=this._root,p=this._x0,m=this._y0,x=this._x1,g=this._y1;if(!f)return this;if(f.length)for(;;){if((c=a>=(o=(p+x)/2))?p=o:x=o,(u=i>=(l=(m+g)/2))?m=l:g=l,t=f,!(f=f[d=u<<1|c]))return this;if(!f.length)break;(t[d+1&3]||t[d+2&3]||t[d+3&3])&&(n=t,h=d)}for(;f.data!==e;)if(r=f,!(f=f.next))return this;return(s=f.next)&&delete f.next,r?(s?r.next=s:delete r.next,this):t?(s?t[d]=s:delete t[d],(f=t[0]||t[1]||t[2]||t[3])&&f===(t[3]||t[2]||t[1]||t[0])&&!f.length&&(n?n[h]=f:this._root=f),this):(this._root=s,this)},cr.removeAll=function(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this},cr.root=function(){return this._root},cr.size=function(){var e=0;return this.visit(function(t){if(!t.length)do{++e}while(t=t.next)}),e},cr.visit=function(e){var t,n,r,s,a,i,o=[],l=this._root;for(l&&o.push(new rr(l,this._x0,this._y0,this._x1,this._y1));t=o.pop();)if(!e(l=t.node,r=t.x0,s=t.y0,a=t.x1,i=t.y1)&&l.length){var c=(r+a)/2,u=(s+i)/2;(n=l[3])&&o.push(new rr(n,c,u,a,i)),(n=l[2])&&o.push(new rr(n,r,u,c,i)),(n=l[1])&&o.push(new rr(n,c,s,a,u)),(n=l[0])&&o.push(new rr(n,r,s,c,u))}return this},cr.visitAfter=function(e){var t,n=[],r=[];for(this._root&&n.push(new rr(this._root,this._x0,this._y0,this._x1,this._y1));t=n.pop();){var s=t.node;if(s.length){var a,i=t.x0,o=t.y0,l=t.x1,c=t.y1,u=(i+l)/2,d=(o+c)/2;(a=s[0])&&n.push(new rr(a,i,o,u,d)),(a=s[1])&&n.push(new rr(a,u,o,l,d)),(a=s[2])&&n.push(new rr(a,i,d,u,c)),(a=s[3])&&n.push(new rr(a,u,d,l,c))}r.push(t)}for(;t=r.pop();)e(t.node,t.x0,t.y0,t.x1,t.y1);return this},cr.x=function(e){return arguments.length?(this._x=e,this):this._x},cr.y=function(e){return arguments.length?(this._y=e,this):this._y};const xr=4294967296;function gr(e){return e.x}function yr(e){return e.y}var vr=Math.PI*(3-Math.sqrt(5));const br=e=>()=>e;function jr(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){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:s}})}function wr(e,t,n){this.k=e,this.x=t,this.y=n}wr.prototype={constructor:wr,scale:function(e){return 1===e?this:new wr(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new wr(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 _r=new wr(1,0,0);function Nr(e){e.stopImmediatePropagation()}function kr(e){e.preventDefault(),e.stopImmediatePropagation()}function Mr(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Ar(){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 Cr(){return this.__zoom||_r}function Sr(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?
11:.002)*(e.ctrlKey?10:1)}function Tr(){return navigator.maxTouchPoints||"ontouchstart"in this}function Er(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}wr.prototype;const zr={romantic_partner:{label:"Romantic Partner",color:"#f472b6",icon:B},friend:{label:"Friend",color:"#34d399",icon:o},mentor:{label:"Mentor",color:"#60a5fa",icon:i},rival:{label:"Rival",color:"#f97316",icon:a},not_friendly:{label:"Not Friendly",color:"#ef4444",icon:s}},Dr=({relationships:n,people:r,onNodeClick:s,onEdgeClick:a,filters:i})=>{const o=e.useRef(null),l=e.useRef(null),[c,u]=e.useState({width:800,height:600}),[d,h]=e.useState(null),[f,p]=e.useState(null),[m,x]=e.useState(null),g=e.useMemo(()=>{const e=new Map,t=[];return r.forEach(t=>{e.set(t.id,{id:t.id,label:t.discordDisplayName||t.discordUsername||"Unknown",avatar:t.discordAvatarUrl,discordUserId:t.discordUserId})}),n.forEach(n=>{if(!e.has(n.personAId)||!e.has(n.personBId))return;const r=n.relationshipTypesData||[];r[0];const s=n.sentiment||"neutral";t.push({id:n.id,source:n.personAId,target:n.personBId,types:r,sentiment:s,strength:n.strength||0,isSymmetric:!1!==n.isSymmetric,direction:n.direction,trend:n.strengthTrend,gamingContext:n.gamingContext||{},relationship:n})}),{nodes:Array.from(e.values()),edges:t}},[n,r]);return e.useEffect(()=>{if(!l.current)return;const e=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;u({width:e,height:n})}});return e.observe(l.current),()=>e.disconnect()},[]),e.useEffect(()=>{if(!o.current||0===g.nodes.length)return;const e=Kt(o.current);e.selectAll("*").remove();const{width:t,height:n}=c,r=function(e){var t,n=1,r=.001,s=1-Math.pow(r,1/300),a=0,i=.6,o=new Map,l=bn(d),c=Ee("tick","end"),u=function(){let e=1;return()=>(e=(1664525*e+1013904223)%xr)/xr}();function d(){h(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function h(r){var l,c,u=e.length;void 0===r&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*s,o.forEach(function(e){e(n)}),l=0;l<u;++l)null==(c=e[l]).fx?c.x+=c.vx*=i:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=i:(c.y=c.fy,c.vy=0);return t}function f(){for(var t,n=0,r=e.length;n<r;++n){if((t=e[n]).index=n,null!=t.fx&&(t.x=t.fx),null!=t.fy&&(t.y=t.fy),isNaN(t.x)||isNaN(t.y)){var s=10*Math.sqrt(.5+n),a=n*vr;t.x=s*Math.cos(a),t.y=s*Math.sin(a)}(isNaN(t.vx)||isNaN(t.vy))&&(t.vx=t.vy=0)}}function p(t){return t.initialize&&t.initialize(e,u),t}return null==e&&(e=[]),f(),t={tick:h,restart:function(){return l.restart(d),t},stop:function(){return l.stop(),t},nodes:function(n){return arguments.length?(e=n,f(),o.forEach(p),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(s=+e,t):+s},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(i=1-e,t):1-i},randomSource:function(e){return arguments.length?(u=e,o.forEach(p),t):u},force:function(e,n){return arguments.length>1?(null==n?o.delete(e):o.set(e,p(n)),t):o.get(e)},find:function(t,n,r){var s,a,i,o,l,c=0,u=e.length;for(null==r?r=1/0:r*=r,c=0;c<u;++c)(i=(s=t-(o=e[c]).x)*s+(a=n-o.y)*a)<r&&(l=o,r=i);return l},on:function(e,n){return arguments.length>1?(c.on(e,n),t):c.on(e)}}}(g.nodes).force("link",function(e){var t,n,r,s,a,i,o=pr,l=function(e){return 1/Math.min(s[e.source.index],s[e.target.index])},c=ur(30),u=1;function d(r){for(var s=0,o=e.length;s<u;++s)for(var l,c,d,h,f,p,m,x=0;x<o;++x)c=(l=e[x]).source,h=(d=l.target).x+d.vx-c.x-c.vx||dr(i),f=d.y+d.vy-c.y-c.vy||dr(i),h*=p=((p=Math.sqrt(h*h+f*f))-n[x])/p*r*t[x],f*=p,d.vx-=h*(m=a[x]),d.vy-=f*m,c.vx+=h*(m=1-m),c.vy+=f*m}function h(){if(r){var i,l,c=r.length,u=e.length,d=new Map(r.map((e,t)=>[o(e,t,r),e]));for(i=0,s=new Array(c);i<u;++i)(l=e[i]).index=i,"object"!=typeof l.source&&(l.source=mr(d,l.source)),"object"!=typeof l.target&&(l.target=mr(d,l.target)),s[l.source.index]=(s[l.source.index]||0)+1,s[l.target.index]=(s[l.target.index]||0)+1;for(i=0,a=new Array(u);i<u;++i)l=e[i],a[i]=s[l.source.index]/(s[l.source.index]+s[l.target.index]);t=new Array(u),f(),n=new Array(u),p()}}function f(){if(r)for(var n=0,s=e.length;n<s;++n)t[n]=+l(e[n],n,e)}function p(){if(r)for(var t=0,s=e.length;t<s;++t)n[t]=+c(e[t],t,e)}return null==e&&(e=[]),d.initialize=function(e,t){r=e,i=t,h()},d.links=function(t){return arguments.length?(e=t,h(),d):e},d.id=function(e){return arguments.length?(o=e,d):o},d.iterations=function(e){return arguments.length?(u=+e,d):u},d.strength=function(e){return arguments.length?(l="function"==typeof e?e:ur(+e),f(),d):l},d.distance=function(e){return arguments.length?(c="function"==typeof e?e:ur(+e),p(),d):c},d}(g.edges).id(e=>e.id).distance(150)).force("charge",function(){var e,t,n,r,s,a=ur(-30),i=1,o=1/0,l=.81;function c(n){var s,a=e.length,i=ir(e,gr,yr).visitAfter(d);for(r=n,s=0;s<a;++s)t=e[s],i.visit(h)}function u(){if(e){var t,n,r=e.length;for(s=new Array(r),t=0;t<r;++t)n=e[t],s[n.index]=+a(n,t,e)}}function d(e){var t,n,r,a,i,o=0,l=0;if(e.length){for(r=a=i=0;i<4;++i)(t=e[i])&&(n=Math.abs(t.value))&&(o+=t.value,l+=n,r+=n*t.x,a+=n*t.y);e.x=r/l,e.y=a/l}else{(t=e).x=t.data.x,t.y=t.data.y;do{o+=s[t.data.index]}while(t=t.next)}e.value=o}function h(e,a,c,u){if(!e.value)return!0;var d=e.x-t.x,h=e.y-t.y,f=u-a,p=d*d+h*h;if(f*f/l<p)return p<o&&(0===d&&(p+=(d=dr(n))*d),0===h&&(p+=(h=dr(n))*h),p<i&&(p=Math.sqrt(i*p)
vendor: 9,505 bytes, line 1
1),t.vx+=d*e.value*r/p,t.vy+=h*e.value*r/p),!0;if(!(e.length||p>=o)){(e.data!==t||e.next)&&(0===d&&(p+=(d=dr(n))*d),0===h&&(p+=(h=dr(n))*h),p<i&&(p=Math.sqrt(i*p)));do{e.data!==t&&(f=s[e.data.index]*r/p,t.vx+=d*f,t.vy+=h*f)}while(e=e.next)}}return c.initialize=function(t,r){e=t,n=r,u()},c.strength=function(e){return arguments.length?(a="function"==typeof e?e:ur(+e),u(),c):a},c.distanceMin=function(e){return arguments.length?(i=e*e,c):Math.sqrt(i)},c.distanceMax=function(e){return arguments.length?(o=e*e,c):Math.sqrt(o)},c.theta=function(e){return arguments.length?(l=e*e,c):Math.sqrt(l)},c}().strength(-300)).force("center",function(e,t){var n,r=1;function s(){var s,a,i=n.length,o=0,l=0;for(s=0;s<i;++s)o+=(a=n[s]).x,l+=a.y;for(o=(o/i-e)*r,l=(l/i-t)*r,s=0;s<i;++s)(a=n[s]).x-=o,a.y-=l}return null==e&&(e=0),null==t&&(t=0),s.initialize=function(e){n=e},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(e){return arguments.length?(t=+e,s):t},s.strength=function(e){return arguments.length?(r=+e,s):r},s}(t/2,n/2)).force("collision",function(e){var t,n,r,s=1,a=1;function i(){for(var e,i,l,c,u,d,h,f=t.length,p=0;p<a;++p)for(i=ir(t,hr,fr).visitAfter(o),e=0;e<f;++e)l=t[e],d=n[l.index],h=d*d,c=l.x+l.vx,u=l.y+l.vy,i.visit(m);function m(e,t,n,a,i){var o=e.data,f=e.r,p=d+f;if(!o)return t>c+p||a<c-p||n>u+p||i<u-p;if(o.index>l.index){var m=c-o.x-o.vx,x=u-o.y-o.vy,g=m*m+x*x;g<p*p&&(0===m&&(g+=(m=dr(r))*m),0===x&&(g+=(x=dr(r))*x),g=(p-(g=Math.sqrt(g)))/g*s,l.vx+=(m*=g)*(p=(f*=f)/(h+f)),l.vy+=(x*=g)*p,o.vx-=m*(p=1-p),o.vy-=x*p)}}}function o(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function l(){if(t){var r,s,a=t.length;for(n=new Array(a),r=0;r<a;++r)s=t[r],n[s.index]=+e(s,r,t)}}return"function"!=typeof e&&(e=ur(null==e?1:+e)),i.initialize=function(e,n){t=e,r=n,l()},i.iterations=function(e){return arguments.length?(a=+e,i):a},i.strength=function(e){return arguments.length?(s=+e,i):s},i.radius=function(t){return arguments.length?(e="function"==typeof t?t:ur(+t),l(),i):e},i}().radius(40)),i=function(){var e,t,n,r=Mr,s=Ar,a=Er,i=Sr,o=Tr,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=be,h=Ee("start","zoom","end"),f=0,p=10;function m(e){e.property("__zoom",Cr).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",N).filter(o).on("touchstart.zoom",k).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new wr(t,e.x,e.y)}function g(e,t,n){var r=t[0]-n[0]*e.k,s=t[1]-n[1]*e.k;return r===e.x&&s===e.y?e:new wr(e.k,r,s)}function y(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function v(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=this,a=arguments,i=b(e,a).event(r),o=s.apply(e,a),l=null==n?y(o):"function"==typeof n?n.apply(e,a):n,c=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),u=e.__zoom,h="function"==typeof t?t.apply(e,a):t,f=d(u.invert(l).concat(c/u.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new wr(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 j(e,t)}function j(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=s.apply(e,t),this.taps=0}function w(e,...t){if(r.apply(this,arguments)){var n=b(this,t).event(e),s=this.__zoom,o=Math.max(l[0],Math.min(l[1],s.k*Math.pow(2,i.apply(this,arguments)))),u=Vt(e);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=s.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(s.k===o)return;n.mouse=[u,s.invert(u)],En(this),n.start()}kr(e),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",a(g(x(s,o),n.mouse[0],n.mouse[1]),n.extent,c))}}function _(e,...t){if(!n&&r.apply(this,arguments)){var s=e.currentTarget,i=b(this,t,!0).event(e),o=Kt(e.view).on("mousemove.zoom",function(e){if(kr(e),!i.moved){var t=e.clientX-u,n=e.clientY-d;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",a(g(i.that.__zoom,i.mouse[0]=Vt(e,s),i.mouse[1]),i.extent,c))},!0).on("mouseup.zoom",function(e){o.on("mousemove.zoom mouseup.zoom",null),Jt(e.view,i.moved),kr(e),i.event(e).end()},!0),l=Vt(e,s),u=e.clientX,d=e.clientY;Qt(e.view),Nr(e),i.mouse=[l,this.__zoom.invert(l)],En(this),i.start()}}function N(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,i=Vt(e.changedTouches?e.changedTouches[0]:e,this),o=n.invert(i),l=n.k*(e.shiftKey?.5:2),d=a(g(x(n,l),i,o),s.apply(this,t),c);kr(e),u>0?Kt(this).transition().duration(u).call(v,d,i,e):Kt(this).call(m.transform,d,i,e)}}function k(n,...s){if(r.apply(this,arguments)){var a,i,o,l,c=n.touches,u=c.length,d=b(this,s,n.changedTouches.length===u).event(n);for(Nr(n),i=0;i<u;++i)l=[l=Vt(o=c[i],this),this.__zoom.invert(l),o.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,a=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(d.taps<2&&(t=l[0],e=setTimeout(function(){e=null},500)),En(this),d.start())}}function M(e,...t){if(this.__zooming){var n,r,s,i,o=b(this,t).event(e),l=e.changedTouches,u=l.length;for(kr(e),n=0;n<u;++n)s=Vt(r=l[n],this),o.touch0&&o.touch0[2]===r.identifier?o.touch0[0]=s:o.touch1&&o.touch1[2]===r.identifier&&(o.touch1[0]=s);if(r=o.that.__zoom,o.touch1){var d=o.touch0[0],h=o.touch0[1],f=o.touch1[0],p=o.touch1[1],m=(m=f[0]-d[0])*m+(m=f[1]-d[1])*m,y=(y=p[0]-h[0])*y+(y=p[1]-h[1])*y;r=x(r,Math.sqrt(m/y)),s=[(d[0]+f[0])/2,(d[1]+f[1])/2],i=[(h[0]+p[0])/2,(h[1]+p[1])/2]}else{if(!o.touch0)return;s=o.touch0[0],i=o.touch0[1]}o.zoom("touch",a(g(r,s,i),o.extent,c))}}function A(e,...r){if(this.__zooming){var s,a,i=b(this,r).event(e),o=e.changedTouches,l=o.length;for(Nr(e),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),s=0;s<l;++s)a=o[s],i.touch0&&i.touch0[2]===a.identifier?delete i.touch0:i.touch1&&i.touch1[2]===a.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps&&(a=Vt(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<p)){var c=Kt(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return m.transform=function(e,t,n,r){var s=e.selection?e.selection():e;s.property("__zoom",Cr),e!==s?v(e,t,n,r):s.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(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)},n,r)},m.scaleTo=function(e,t,n,r){m.transform(e,function(){var e=s.apply(this,arguments),r=this.__zoom,i=null==n?y(e):"function"==typeof n?n.apply(this,arguments):n,o=r.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return a(g(x(r,l),i,o),e,c)},n,r)},m.translateBy=function(e,t,n,r){m.transform(e,function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),s.apply(this,arguments),c)},null,r)},m.translateTo=function(e,t,n,r,i){m.transform(e,function(){var e=s.apply(this,arguments),i=this.__zoom,o=null==r?y(e):"function"==typeof r?r.apply(this,arguments):r;return a(_r.translate(o[0],o[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)},r,i)},j.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=Kt(this.that).datum();h.call(e,this.that,new jr(e,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:h}),t)}},m.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:br(+e),m):i},m.filter=function(e){return arguments.length?(r="function"==typeof e?e:br(!!e),m):r},m.touchable=function(e){return arguments.length?(o="function"==typeof e?e:br(!!e),m):o},m.extent=function(e){return arguments.length?(s="function"==typeof e?e:br([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),m):s},m.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],m):[l[0],l[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?(a=e,m):a},m.duration=function(e){return arguments.length?(u=+e,m):u},m.interpolate=function(e){return arguments.length?(d=e,m):d},m.on=function(){var e=h.on.apply(h,arguments);return e===h?m:e},m.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,m):Math.sqrt(f)},m.tapDistance=function(e){return arguments.length?(p=+e,m):p},m}().scaleExtent([.1,4]).on("zoom",e=>{l.attr("transform",e.transform)});e.call(i);const l=e.append("g"),u=l.append("g").attr("class","edges");(()=>{const e=u.selectAll(".edge-group").data(g.edges,e=>e.id);e.exit().remove();const t=e.enter().append("g").attr("class","edge-group").style("cursor","pointer").on("mouseenter",(e,t)=>p(t)).on("mouseleave",()=>p(null)).on("click",(e,t)=>
1{e.stopPropagation(),a?.(t.relationship)});t.append("line").attr("class","edge-base").attr("stroke","#374151").attr("stroke-width",3).attr("opacity",.3),t.each(function(e){const t=Kt(this),n=e.types||[],r=n.length>1?4:0;n.forEach((s,a)=>{const i=zr[s.type];if(!i)return;const o=r*(a-(n.length-1)/2);t.append("line").attr("class",`edge-type edge-type-${s.type}`).attr("stroke",i.color).attr("stroke-width",2).attr("opacity",.7).attr("data-y-offset",o).style("stroke-dasharray",e.isSymmetric?"none":"5,5")}),"increasing"!==e.trend&&"decreasing"!==e.trend||t.append("path").attr("class","edge-arrow").attr("fill","increasing"===e.trend?"#34d399":"#ef4444").attr("opacity",.8).attr("d","M0,-3 L6,0 L0,3 Z")});const n=t.merge(e);r.on("tick",()=>{n.selectAll(".edge-base, .edge-type").attr("x1",e=>e.source.x).attr("y1",e=>e.source.y).attr("x2",e=>e.target.x).attr("y2",e=>e.target.y),n.selectAll(".edge-type").attr("transform",function(e){return`translate(0, ${+this.getAttribute("data-y-offset")||0})`}),n.selectAll(".edge-arrow").attr("transform",e=>{const t=e.target.x-e.source.x,n=e.target.y-e.source.y,r=180*Math.atan2(n,t)/Math.PI;return`translate(${(e.source.x+e.target.x)/2}, ${(e.source.y+e.target.y)/2}) rotate(${r})`})})})();const d=l.append("g").attr("class","nodes").selectAll(".node-group").data(g.nodes,e=>e.id).enter().append("g").attr("class","node-group").style("cursor","pointer").on("mouseenter",(e,t)=>h(t)).on("mouseleave",()=>h(null)).on("click",(e,t)=>{e.stopPropagation(),x(t.id),s?.(t.id)}).call(function(){var e,t,n,r,s=nn,a=rn,i=sn,o=an,l={},c=Ee("start","drag","end"),u=0,d=0;function h(e){e.on("mousedown.drag",f).filter(o).on("touchstart.drag",x).on("touchmove.drag",g,Ht).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,o){if(!r&&s.call(this,i,o)){var l=v(this,a.call(this,i,o),i,o,"mouse");l&&(Kt(i.view).on("mousemove.drag",p,Gt).on("mouseup.drag",m,Gt),Qt(i.view),Wt(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function p(r){if(Zt(r),!n){var s=r.clientX-e,a=r.clientY-t;n=s*s+a*a>d}l.mouse("drag",r)}function m(e){Kt(e.view).on("mousemove.drag mouseup.drag",null),Jt(e.view,n),Zt(e),l.mouse("end",e)}function x(e,t){if(s.call(this,e,t)){var n,r,i=e.changedTouches,o=a.call(this,e,t),l=i.length;for(n=0;n<l;++n)(r=v(this,o,e,t,i[n].identifier,i[n]))&&(Wt(e),r("start",e,i[n]))}}function g(e){var t,n,r=e.changedTouches,s=r.length;for(t=0;t<s;++t)(n=l[r[t].identifier])&&(Zt(e),n("drag",e,r[t]))}function y(e){var t,n,s=e.changedTouches,a=s.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),t=0;t<a;++t)(n=l[s[t].identifier])&&(Wt(e),n("end",e,s[t]))}function v(e,t,n,r,s,a){var o,d,f,p=c.copy(),m=Vt(a||n,t);if(null!=(f=i.call(e,new tn("beforestart",{sourceEvent:n,target:h,identifier:s,active:u,x:m[0],y:m[1],dx:0,dy:0,dispatch:p}),r)))return o=f.x-m[0]||0,d=f.y-m[1]||0,function n(a,i,c){var x,g=m;switch(a){case"start":l[s]=n,x=u++;break;case"end":delete l[s],--u;case"drag":m=Vt(c||i,t),x=u}p.call(a,e,new tn(a,{sourceEvent:i,subject:f,target:h,identifier:s,active:x,x:m[0]+o,y:m[1]+d,dx:m[0]-g[0],dy:m[1]-g[1],dispatch:p}),r)}}return h.filter=function(e){return arguments.length?(s="function"==typeof e?e:en(!!e),h):s},h.container=function(e){return arguments.length?(a="function"==typeof e?e:en(e),h):a},h.subject=function(e){return arguments.length?(i="function"==typeof e?e:en(e),h):i},h.touchable=function(e){return arguments.length?(o="function"==typeof e?e:en(!!e),h):o},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,h):Math.sqrt(d)},h}().on("start",(e,t)=>{e.active||r.alphaTarget(.3).restart(),t.fx=t.x,t.fy=t.y}).on("drag",(e,t)=>{t.fx=e.x,t.fy=e.y}).on("end",(e,t)=>{e.active||r.alphaTarget(0),t.fx=null,t.fy=null}));return d.append("circle").attr("r",20).attr("fill","#2f3136").attr("stroke",e=>m===e.id?"#60a5fa":"#4b5563").attr("stroke-width",e=>m===e.id?3:2),d.append("clipPath").attr("id",e=>`clip-${e.id}`).append("circle").attr("r",18),d.append("image").attr("href",e=>e.avatar||`https://cdn.discordapp.com/embed/avatars/${Math.abs(e.discordUserId?.split("").reduce((e,t)=>
1(e<<5)-e+t.charCodeAt(0),0)||0)%6}.png`).attr("x",-18).attr("y",-18).attr("width",36).attr("height",36).attr("clip-path",e=>`url(#clip-${e.id})`),d.append("text").attr("y",32).attr("text-anchor","middle").attr("fill","#e5e7eb").attr("font-size","12px").attr("font-weight","500").text(e=>e.label.length>12?e.label.substring(0,12)+"...":e.label),r.on("tick",()=>{d.attr("transform",e=>`translate(${e.x}, ${e.y})`)}),()=>{r.stop()}},[g,c,m,s,a]),t.jsxs("div",{ref:l,className:"relative w-full h-full bg-[#202225] rounded-lg border border-gray-700",children:[t.jsx("svg",{ref:o,width:c.width,height:c.height,className:"w-full h-full"}),d&&t.jsx("div",{className:"absolute bg-[#2f3136] border border-gray-700 rounded-lg p-3 shadow-lg pointer-events-none",style:{left:"50%",top:"20px",transform:"translateX(-50%)",zIndex:100},children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("img",{src:d.avatar||"https://cdn.discordapp.com/embed/avatars/0.png",alt:d.label,className:"w-8 h-8 rounded-full"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-white font-semibold",children:d.label}),t.jsx("div",{className:"text-xs text-gray-400",children:"Click to view details"})]})]})}),f&&t.jsxs("div",{className:"absolute bg-[#2f3136] border border-gray-700 rounded-lg p-3 shadow-lg pointer-events-none max-w-xs",style:{left:"50%",bottom:"20px",transform:"translateX(-50%)",zIndex:100},children:[t.jsx("div",{className:"text-white font-semibold mb-2",children:"Relationship Details"}),t.jsx("div",{className:"space-y-1 text-sm",children:f.types?.map((e,n)=>{const r=zr[e.type];return r?t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-gray-300 capitalize flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:r.color}}),r.label]}),t.jsxs("span",{className:"text-white",children:[Math.round(100*(e.confidence||0)),"%"]})]},n):null})}),t.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-700 flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-gray-400",children:"Strength:"}),t.jsxs("span",{className:"text-white font-medium",children:[Math.round(100*(f.strength||0)),"%"]})]}),f.trend&&t.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-gray-400",children:"Trend:"}),t.jsx("span",{className:"capitalize font-medium "+("increasing"===f.trend?"text-green-400":"decreasing"===f.trend?"text-red-400":"new"===f.trend?"text-blue-400":"text-gray-400"),children:f.trend})]})]}),t.jsxs("div",{className:"absolute bottom-4 left-4 bg-[#2f3136] border border-gray-700 rounded-lg p-3 text-xs",children:[t.jsx("div",{className:"text-white font-semibold mb-2",children:"Relationship Types"}),t.jsx("div",{className:"space-y-1",children:Object.entries(zr).map(([e,n])=>t.jsxs("div",{className:"flex items-center gap-2 text-gray-300",children:[t.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:n.color}}),t.jsx("span",{children:n.label})]},e))})]}),t.jsxs("div",{className:"absolute top-4 right-4 bg-[#2f3136] border border-gray-700 rounded-lg p-3 text-xs space-y-1",children:[t.jsx("div",{className:"text-white font-semibold mb-1",children:"Graph Stats"}),t.jsxs("div",{className:"text-gray-300",children:["Nodes: ",t.jsx("span",{className:"text-white font-medium",children:g.nodes.length})]}),t.jsxs("div",{className:"text-gray-300",children:["Edges: ",t.jsx("span",{className:"text-white font-medium",children:g.edges.length})]})]})]})},Pr={romantic_partner:{label:"Romantic Partner",icon:B,color:"#f472b6"},friend:{label:"Friend",icon:o,color:"#34d399"},mentor:{label:"Mentor",icon:i,color:"#60a5fa"},rival:{label:"Rival",icon:a,color:"#f97316"},not_friendly:{label:"Not Friendly",icon:s,color:"#ef4444"}},Ir={positive:{bg:"bg-green-900/30",border:"border-green-500/50",text:"text-green-400"},neutral:{bg:"bg-gray-900/30",border:"border-gray-500/50",text:"text-gray-400"},negative:{bg:"bg-red-900/30",border:"border-red-500/50",text:"text-red-400"},mixed:{bg:"bg-yellow-900/30",border:"border-yellow-500/50",text:"text-yellow-400"}},Rr={increasing:{icon:i,color:"text-green-400",label:"Strengthening"},decreasing:{icon:X,color:"text-red-400",label:"Weakening"},new:{icon:l,color:"text-blue-400",label:"New"},stable:null},$r=({relationship:e,personA:n,personB:r,onClick:s})=>{const a=e.relationshipTypesData||[];a[0];const i=e.sentiment||"neutral",o=Ir[i]||Ir.neutral,l=Rr[e.strengthTrend],c=e.gamingContext||{},u=e=>{if(e?.discordAvatarUrl)return e.discordAvatarUrl;const t=e?.discordUserId?.split("").reduce((e,t)=>
1(e<<5)-e+t.charCodeAt(0),0);return`https://cdn.discordapp.com/embed/avatars/${Math.abs(t||0)%6}.png`};return t.jsxs("div",{onClick:s,className:`\n        relative p-4 rounded-lg border ${o.border} ${o.bg}\n        bg-[#2f3136] hover:bg-[#36393f] cursor-pointer transition-all duration-200\n        hover:shadow-lg hover:scale-[1.02]\n      `,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:u(n),alt:n?.discordDisplayName||"User A",className:"w-12 h-12 rounded-full border-2 border-gray-700"}),"positive"===i&&t.jsx("div",{className:"absolute -bottom-1 -right-1 w-4 h-4 bg-green-500 rounded-full border-2 border-[#2f3136]"})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-semibold text-white truncate",children:n?.discordDisplayName||n?.discordUsername||"Unknown"}),t.jsx("span",{className:"text-gray-500",children:"×"}),t.jsx("span",{className:"font-semibold text-white truncate",children:r?.discordDisplayName||r?.discordUsername||"Unknown"})]}),t.jsx("div",{className:"flex items-center gap-2 mt-1",children:l&&t.jsxs("div",{className:`flex items-center gap-1 ${l.color} text-xs`,children:[t.jsx(l.icon,{size:12}),t.jsx("span",{children:l.label})]})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:u(r),alt:r?.discordDisplayName||"User B",className:"w-12 h-12 rounded-full border-2 border-gray-700"}),"positive"===i&&t.jsx("div",{className:"absolute -bottom-1 -right-1 w-4 h-4 bg-green-500 rounded-full border-2 border-[#2f3136]"})]})]}),t.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:a.map((e,n)=>{const r=Pr[e.type];if(!r)return null;const s=r.icon,a=Math.round(100*(e.confidence||0));return t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium",style:{backgroundColor:`${r.color}20`,border:`1px solid ${r.color}40`,color:r.color},children:[t.jsx(s,{size:12}),t.jsx("span",{children:r.label}),t.jsxs("span",{className:"ml-1 opacity-70",children:[a,"%"]})]},n)})}),t.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[t.jsxs("div",{className:"bg-gray-800/50 rounded-sm px-2 py-1.5",children:[t.jsx("div",{className:"text-gray-400 mb-0.5",children:"Strength"}),t.jsxs("div",{className:"text-white font-semibold",children:[Math.round(100*(e.strength||0)),"%"]})]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-sm px-2 py-1.5",children:[t.jsx("div",{className:"text-gray-400 mb-0.5",children:"Evidence"}),t.jsx("div",{className:"text-white font-semibold",children:a.reduce((e,t)=>e+(t.evidenceCount||0),0)})]}),t.jsxs("div",{className:"bg-gray-800/50 rounded-sm px-2 py-1.5",children:[t.jsx("div",{className:"text-gray-400 mb-0.5",children:"Sentiment"}),t.jsx("div",{className:`font-semibold capitalize ${o.text}`,children:i})]})]}),(c.raid_count>0||c.mythic_plus_runs>0||c.pvp_matches>0)&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-700/50",children:[t.jsx("div",{className:"text-xs text-gray-400 mb-1.5",children:"Gaming Activity"}),t.jsxs("div",{className:"flex gap-3 text-xs",children:[c.raid_count>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-purple-500"}),t.jsxs("span",{className:"text-gray-300",children:[c.raid_count," Raids"]})]}),c.mythic_plus_runs>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"}),t.jsxs("span",{className:"text-gray-300",children:[c.mythic_plus_runs," M+"]})]}),c.pvp_matches>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500"}),t.jsxs("span",{className:"text-gray-300",children:[c.pvp_matches," PVP"]})]})]})]}),!e.isSymmetric&&t.jsx("div",{className:"absolute top-2 right-2 text-xs text-gray-500 bg-gray-800 px-2 py-0.5 rounded-sm",children:"A→B"===e.direction?"→":"←"})]})},Or=({relationship:n,personA:r,personB:s})=>{const a=n.relationshipTypesData||[],o=n.relationshipHistory||[],l=e.useMemo(()=>0===o.length?a.map(e=>({timestamp:new Date(e.lastConfirmed||e.firstDetected||Date.now()).getTime(),date:new Date(e.lastConfirmed||e.firstDetected||Date.now()).toLocaleDateString(),[e.type]:e.confidence,[`${e.type}_strength`]:e.strength,event:"Current"})):o.map(e=>{const t={timestamp:new Date(e.timestamp).getTime(),date:new Date(e.timestamp).toLocaleDateString(),event:e.event||"Update"};
1return e.types?.forEach(e=>{t[e.type]=e.confidence,t[`${e.type}_strength`]=e.strength}),t}).sort((e,t)=>e.timestamp-t.timestamp),[a,o]),c={romantic_partner:"#f472b6",friend:"#34d399",mentor:"#60a5fa",rival:"#f97316",not_friendly:"#ef4444"},u=({active:e,payload:n,label:r})=>e&&n&&0!==n.length?t.jsxs("div",{className:"bg-[#2f3136] border border-gray-700 rounded-lg p-3 shadow-lg",children:[t.jsx("div",{className:"text-white font-semibold mb-2",children:r}),n.map((e,r)=>{if(e.dataKey.includes("_strength"))return null;const s=e.dataKey,a=Math.round(100*(e.value||0)),i=n.find(e=>e.dataKey===`${s}_strength`)?.value,o=i?Math.round(100*i):null;return t.jsxs("div",{className:"flex items-center gap-2 text-sm mb-1",children:[t.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:e.color}}),t.jsxs("span",{className:"text-gray-300 capitalize",children:[s.replace("_"," "),":"]}),t.jsxs("span",{className:"text-white font-medium",children:[a,"%"]}),o&&t.jsxs("span",{className:"text-gray-400 text-xs",children:["(",o,"% strength)"]})]},r)}),n[0]?.payload?.event&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-700 text-xs text-gray-400",children:["Event: ",n[0].payload.event]})]}):null,d=e.useMemo(()=>{if(l.length<2)return null;const e=l[0],t=l[l.length-1],n=Object.keys(e).filter(e=>!e.includes("_strength")&&!["timestamp","date","event"].includes(e)).reduce((t,n)=>t+(e[n]||0),0),r=(Object.keys(t).filter(e=>!e.includes("_strength")&&!["timestamp","date","event"].includes(e)).reduce((e,n)=>e+(t[n]||0),0)-n)/n*100;return Math.abs(r)<5?{type:"stable",change:0}:r>0?{type:"increasing",change:Math.round(r)}:{type:"decreasing",change:Math.round(Math.abs(r))}},[l]);return 0===l.length?t.jsx("div",{className:"bg-[#2f3136] rounded-lg border border-gray-700 p-6 text-center text-gray-400",children:"No timeline data available"}):t.jsxs("div",{className:"bg-[#2f3136] rounded-lg border border-gray-700 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-white font-semibold",children:"Relationship Timeline"}),t.jsxs("div",{className:"text-sm text-gray-400 mt-1",children:[r?.discordDisplayName||"Person A"," × ",s?.discordDisplayName||"Person B"]})]}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg "+("increasing"===d.type?"bg-green-900/30 text-green-400":"decreasing"===d.type?"bg-red-900/30 text-red-400":"bg-gray-800 text-gray-400"),children:["increasing"===d.type&&t.jsx(i,{size:16}),"decreasing"===d.type&&t.jsx(X,{size:16}),"stable"===d.type&&t.jsx("span",{className:"text-xs",children:"─"}),t.jsx("span",{className:"text-sm font-medium",children:"stable"===d.type?"Stable":`${d.change}% ${d.type}`})]})]}),t.jsx(O,{width:"100%",height:300,children:t.jsxs(Y,{data:l,margin:{top:5,right:30,left:0,bottom:5},children:[t.jsx(F,{strokeDasharray:"3 3",stroke:"#374151"}),t.jsx(q,{dataKey:"date",stroke:"#9ca3af",tick:{fill:"#9ca3af",fontSize:12}}),t.jsx(U,{stroke:"#9ca3af",tick:{fill:"#9ca3af",fontSize:12},domain:[0,1],tickFormatter:e=>`${Math.round(100*e)}%`}),t.jsx(L,{content:t.jsx(u,{})}),t.jsx(V,{wrapperStyle:{paddingTop:"20px"},formatter:e=>t.jsx("span",{className:"text-gray-300 text-sm capitalize",children:e.replace("_"," ")})}),a.map((e,n)=>t.jsx(K,{type:"monotone",dataKey:e.type,stroke:c[e.type],strokeWidth:2,dot:{fill:c[e.type],r:4},activeDot:{r:6}},e.type)),l.map((e,n)=>"Type Added"===e.event||"Type Removed"===e.event?t.jsx(Se,{x:e.date,y:.5,r:6,fill:"#60a5fa",stroke:"#1e3a8a",strokeWidth:2},n):null)]})}),t.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[t.jsx("div",{className:"text-xs text-gray-400 mb-2",children:"Evidence Supporting This Relationship"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map((e,n)=>t.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-sm text-xs",style:{backgroundColor:`${c[e.type]}20`,border:`1px solid ${c[e.type]}40`,color:c[e.type]},children:[t.jsx("span",{className:"capitalize",children:e.type.replace("_"," ")}),t.jsx("span",{className:"font-semibold",children:e.evidenceCount||0}),t.jsx("span",{className:"opacity-70",children:"memories"})]},n))})]})]})},Fr=[{value:"romantic_partner",label:"Romantic Partner",icon:B,color:"#f472b6"}
1,{value:"friend",label:"Friend",icon:o,color:"#34d399"},{value:"mentor",label:"Mentor",icon:i,color:"#60a5fa"},{value:"rival",label:"Rival",icon:a,color:"#f97316"},{value:"not_friendly",label:"Not Friendly",icon:s,color:"#ef4444"}],qr=["positive","neutral","negative","mixed"],Ur=["increasing","decreasing","new","stable"],Lr=({filters:e,onFilterChange:n,onReset:r})=>t.jsxs("div",{className:"bg-[#2f3136] rounded-lg border border-gray-700 p-4 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"text-white font-semibold",children:"Filters"}),t.jsxs("button",{onClick:r,className:"text-xs text-gray-400 hover:text-white transition-colors flex items-center gap-1",children:[t.jsx(c,{size:12}),"Reset"]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-1.5",children:"Search People"}),t.jsxs("div",{className:"relative",children:[t.jsx(u,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-500",size:14}),t.jsx("input",{type:"text",value:e.search||"",onChange:t=>n({...e,search:t.target.value}),placeholder:"Search by name...",className:"w-full bg-[#202225] border border-gray-700 rounded-sm px-7 py-1.5 text-sm text-white placeholder-gray-500 focus:border-blue-500 focus:outline-hidden"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-2",children:"Relationship Types"}),t.jsx("div",{className:"space-y-1.5",children:Fr.map(r=>{const s=r.icon,a=e.types.includes(r.value);return t.jsxs("button",{onClick:()=>(t=>{const r=e.types.includes(t)?e.types.filter(e=>e!==t):[...e.types,t];n({...e,types:r})})(r.value),className:`\n                  w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm transition-all\n                  ${a?"bg-opacity-20 border":"bg-gray-800/50 border border-transparent hover:bg-gray-800"}\n                `,style:a?{backgroundColor:`${r.color}20`,borderColor:`${r.color}40`,color:r.color}:{color:"#9ca3af"},children:[t.jsx(s,{size:14}),t.jsx("span",{className:"flex-1 text-left",children:r.label}),a&&t.jsx("span",{className:"text-xs",children:"✓"})]},r.value)})})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs text-gray-400 mb-1.5",children:["Min Confidence: ",Math.round(100*(e.minConfidence||0)),"%"]}),t.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:Math.round(100*(e.minConfidence||0)),onChange:t=>n({...e,minConfidence:parseInt(t.target.value)/100}),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer slider"}),t.jsxs("div",{className:"flex justify-between text-xs text-gray-500 mt-1",children:[t.jsx("span",{children:"0%"}),t.jsx("span",{children:"50%"}),t.jsx("span",{children:"100%"})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs text-gray-400 mb-1.5",children:["Min Strength: ",Math.round(100*(e.minStrength||0)),"%"]}),t.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:Math.round(100*(e.minStrength||0)),onChange:t=>n({...e,minStrength:parseInt(t.target.value)/100}),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer slider"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-2",children:"Sentiment"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:qr.map(r=>{const s=e.sentiments?.includes(r);return t.jsx("button",{onClick:()=>(t=>{const r=e.sentiments?.includes(t)?e.sentiments.filter(e=>e!==t):[...e.sentiments||[],t];n({...e,sentiments:r})})(r),className:`\n                  px-2 py-1 rounded text-xs capitalize transition-all\n                  ${s?`${{positive:"text-green-400 border-green-500/50",neutral:"text-gray-400 border-gray-500/50",negative:"text-red-400 border-red-500/50",mixed:"text-yellow-400 border-yellow-500/50"}[r]} border bg-opacity-10`:"text-gray-500 border border-gray-700 hover:text-gray-300"}\n                `,children:r},r)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-2",children:"Trends"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ur.map(r=>{const s=e.trends?.includes(r);return t.jsx("button",{onClick:()=>(t=>{const r=e.trends?.includes(t)?e.trends.filter(e=>e!==t):[...e.trends||[],t];n({...e,trends:r})})(r),className:`\n                  px-2 py-1 rounded text-xs capitalize transition-all\n                  ${s?`${{increasing:"text-green-400 border-green-500/50",decreasing:"text-red-400 border-red-500/50",new:"text-blue-400 border-blue-500/50",stable:"text-gray-400 border-gray-500/50"}[r]} border bg-opacity-10`:"text-gray-500 border border-gray-700 hover:text-gray-300"}\n                `,children:r},r)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-gray-400 mb-2",children:"Gaming Activity"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:e.hasRaids||!1,onChange:t=>n({...e,hasRaids:t.target.checked}),className:"rounded-sm bg-gray-700 border-gray-600 text-blue-500 focus:ring-blue-500"}),"Has Raid Activity"]}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:e.hasMythicPlus||!1,onChange:t=>n({...e,hasMythicPlus:t.target.checked}),className:"rounded-sm bg-gray-700 border-gray-600 text-blue-500 focus:ring-blue-500"}),"Has M+ Activity"]}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:e.hasPvP||!1,onChange:t=>n({...e,hasPvP:t.target.checked}),className:"rounded-sm bg-gray-700 border-gray-600 text-blue-500 focus:ring-blue-500"}),"Has PVP Activity"]})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"block text-xs text-gray-400 mb-1.5",children:["Max Results: ",e.limit||1e3]}),t.jsx("input",{type:"number",min:"10",max:"2000",step:"10",value:e.limit||1e3,onChange:t=>n({...e,limit:parseInt(t.target.value)}),className:"w-full bg-[#202225] border border-gray-700 rounded-sm px-2 py-1.5 text-sm text-white focus:border-blue-500 focus:outline-hidden"})]})]}),Br=({relationships:n=[],people:r=[],onInfer:a,isInferring:i})=>{const[l,c]=e.useState(null),[u,h]=e.useState(null),[f,p]=e.useState("graph"),[m,x
1]=e.useState(60),[g,y]=e.useState({types:[],minConfidence:.3,minStrength:0,sentiments:[],trends:[],hasRaids:!1,hasMythicPlus:!1,hasPvP:!1,search:"",limit:1e3}),v=e.useMemo(()=>{const e=new Map;return r.forEach(t=>e.set(t.id,t)),e},[r]),b=e.useMemo(()=>{let e=[...n];if(g.types.length>0&&(e=e.filter(e=>(e.relationshipTypesData||[]).some(e=>g.types.includes(e.type)))),e=e.filter(e=>{const t=e.relationshipTypesData||[];return Math.max(...t.map(e=>e.confidence),0)>=g.minConfidence}),g.minStrength>0&&(e=e.filter(e=>(e.strength||0)>=g.minStrength)),g.sentiments.length>0&&(e=e.filter(e=>g.sentiments.includes(e.sentiment))),g.trends.length>0&&(e=e.filter(e=>g.trends.includes(e.strengthTrend))),g.hasRaids&&(e=e.filter(e=>(e.gamingContext?.raid_count||0)>0)),g.hasMythicPlus&&(e=e.filter(e=>(e.gamingContext?.mythic_plus_runs||0)>0)),g.hasPvP&&(e=e.filter(e=>(e.gamingContext?.pvp_matches||0)>0)),g.search){const t=g.search.toLowerCase();e=e.filter(e=>{const n=v.get(e.personAId),r=v.get(e.personBId),s=(n?.discordDisplayName||n?.discordUsername||"").toLowerCase(),a=(r?.discordDisplayName||r?.discordUsername||"").toLowerCase();return s.includes(t)||a.includes(t)})}return e.slice(0,g.limit)},[n,g,v]),j=e.useMemo(()=>{if(!l)return null;const e=b.find(e=>e.id===l);return e?{relationship:e,personA:v.get(e.personAId),personB:v.get(e.personBId)}:null},[l,b,v]),w=()=>{y({types:[],minConfidence:.3,minStrength:0,sentiments:[],trends:[],hasRaids:!1,hasMythicPlus:!1,hasPvP:!1,search:"",limit:1e3})};return t.jsxs("div",{className:"flex flex-col h-full bg-[#202225]",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[t.jsx(o,{size:24}),"Relationship Graph"]}),t.jsxs("div",{className:"text-sm text-gray-400 mt-1",children:[b.length," relationship",1!==b.length?"s":""," between ",r.length," people"]})]}),t.jsxs("button",{onClick:a,disabled:i,className:`\n            flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors\n            ${i?"bg-gray-700 text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white"}\n          `,children:[t.jsx(d,{size:16,className:i?"animate-spin":""}),i?"Inferring...":"Run Inference"]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"w-80 border-r border-gray-700 overflow-y-auto p-4",children:t.jsx(Lr,{filters:g,onFilterChange:y,onReset:w})}),t.jsx("div",{className:"flex-1 overflow-hidden",style:{width:`${m}%`},children:t.jsx(Dr,{relationships:b,people:r,onNodeClick:e=>{h(e);const t=b.filter(t=>t.personAId===e||t.personBId===e);t.length>0&&c(t[0].id)},onEdgeClick:e=>{c(e.id),p("timeline")},filters:g})}),t.jsxs("div",{className:"border-l border-gray-700 overflow-y-auto bg-[#2f3136]",style:{width:100-m+"%"},children:[t.jsxs("div",{className:"flex border-b border-gray-700",children:[t.jsx("button",{onClick:()=>p("cards"),className:"flex-1 px-4 py-3 text-sm font-medium transition-colors "+("cards"===f?"text-white bg-[#202225] border-b-2 border-blue-500":"text-gray-400 hover:text-white"),children:"Cards"}),t.jsx("button",{onClick:()=>p("timeline"),disabled:!j,className:"flex-1 px-4 py-3 text-sm font-medium transition-colors "+("timeline"===f&&j?"text-white bg-[#202225] border-b-2 border-blue-500":j?"text-gray-400 hover:text-white":"text-gray-600 cursor-not-allowed"),children:"Timeline"})]}),t.jsxs("div",{className:"p-4",children:["cards"===f&&t.jsx("div",{className:"space-y-3",children:0===b.length?t.jsxs("div",{className:"text-center py-12",children:[t.jsx(s,{size:48,className:"mx-auto mb-4 text-gray-600"}),t.jsx("div",{className:"text-gray-400",children:"No relationships match the current filters"}),t.jsx("button",{onClick:w,className:"mt-4 text-blue-400 hover:text-blue-300 text-sm",children:"Reset filters"})]}):b.map(e=>{const n=v.get(e.personAId),r=v.get(e.personBId);return t.jsx($r,{relationship:e,personA:n,personB:r,onClick:()=>{c(e.id),p("timeline")}},e.id)})}),"timeline"===f&&(j?t.jsx(Or,{relationship:j.relationship,personA:j.personA,personB:j.personB}):t.jsx("div",{className:"text-center py-12 text-gray-400",children:"Select a relationship from the graph or cards to view timeline"}))]})]})]}),t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-gray-700 bg-[#2f3136] text-xs",children:[t.jsxs("div",{className:"flex gap-4 text-gray-400",children:[t.jsxs("span",{children:["Total: ",t.jsx("span",{className:"text-white font-medium",children:n.length})]}),t.jsxs("span",{children:["Filtered: ",t.jsx("span",{className:"text-white font-medium",children:b.length})]}),t.jsxs("span",{children:["People: ",t.jsx("span",{className:"text-white font-medium",children:r.length})]})]}),t.jsx("div",{className:"text-gray-500",children:"Powered by Social-First Relationship System"})]})]})};n.Component;const Xr=()=>{const{primaryColor:n}=h(),a=n||"#a855f7",i=[a,"#ec4899","#06b6d4","#10b981","#f59e0b","#ef4444","#3b82f6","#6366f1","#84cc16","#f97316"],{selectedGuildId:o}
1=f(),[c,u]=p(),[v,b]=e.useState(!0),[j,w]=e.useState(null),[_,N]=e.useState({start:c.get("start")||Z(Q(new Date,7),"yyyy-MM-dd"),end:c.get("end")||Z(new Date,"yyyy-MM-dd")}),[k,M]=e.useState(null),[A,C]=e.useState([]),[S,T]=e.useState([]),[E,z]=e.useState([]),[D,P]=e.useState(null),[I,R]=e.useState(null),[$,B]=e.useState(1),[X,Y]=e.useState(1),[K,V]=e.useState("overview"),[H,G]=e.useState({minConfidence:.3,types:[],limit:1e3}),[W,he]=e.useState(!1),[fe,pe]=e.useState(null),[me,xe]=e.useState(null),[ge,ye]=e.useState(!1),ve=function(e,t={}){const{minConfidence:n=.3,types:s=null,limit:a=1e3,enabled:i=!0,...o}=t;return r({queryKey:["relationshipGraph",e,n,s,a],queryFn:async()=>{const t=new URLSearchParams;t.append("minConfidence",n),s&&s.length>0&&t.append("types",s.join(",")),t.append("limit",a);const r=await y.get(`/api/people/relationships/graph/${e}?${t}`,{withCredentials:!0});if(!r.data.success)throw new Error(r.data.message||"Failed to fetch graph data");return r.data},enabled:!!e&&i,staleTime:3e5,gcTime:6e5,...o})}(o,{minConfidence:H.minConfidence,types:H.types,limit:H.limit,enabled:"relationships"===K&&!!o});!function(e,t={}){const{minConfidence:n=.3,types:r=null,limit:s=1e3,guildName:a="Guild"}=t}(0,H);const be=e.useRef(null);e.useEffect(()=>{"relationships"===K&&o&&be.current!==o&&(be.current=o,je())},[K,o]);const je=async()=>{if(o){he(!0),pe(null);try{const e=await y.post(`/api/people/relationships/infer-advanced/${o}`,{minutesBack:10080,minConfidence:.3,enrichAliases:!0},{withCredentials:!0});e.data.success?(console.log("Advanced relationship inference completed:",e.data),console.log(`Found ${e.data.relationshipsFound} relationships:`,e.data.relationships),ve.refetch()):pe(e.data.message||"Failed to infer relationships")}catch(e){console.error("Error inferring relationships:",e),pe(m(e,"Failed to infer relationships"))}finally{he(!1)}}};e.useEffect(()=>{"relationships"===K&&o&&we()},[K,o]);const we=async()=>{try{const e=await y.get(`/api/people/profiles/sync/${o}/status`,{withCredentials:!0});e.data.success&&xe(e.data.status)}catch(e){console.error("Error fetching sync status:",e)}};e.useEffect(()=>{let e=!0;return b(!0),(async()=>{const t=new AbortController,n=setTimeout(()=>t.abort(),3e4);try{const[n,r,s,a]=await Promise.all([y.get("/api/admin/ai-logs/stats",{params:{startDate:_.start,endDate:_.end,groupBy:"day"},withCredentials:!0,signal:t.signal}),y.get("/api/admin/ai-logs",{params:{startDate:_.start,endDate:_.end,page:$,limit:50},withCredentials:!0,signal:t.signal}),y.get("/api/admin/ai-logs/sessions",{params:{startDate:_.start,endDate:_.end},withCredentials:!0,signal:t.signal}),y.get("/api/admin/ai-logs/errors",{params:{startDate:_.start,endDate:_.end},withCredentials:!0,signal:t.signal})]);e&&(M(n.data.data),C(r.data.data),Y(r.data.pagination?.pages||1),T(s.data.data),z(a.data.data),w(null))}catch(r){e&&"AbortError"!==r.name&&w(r.message)}finally{clearTimeout(n),b(!1)}})(),()=>{e=!1}},[_,$]);const _e=(e,t)=>{const n={..._,[e]:t};N(n),u({start:n.start,end:n.end})};return v?t.jsx("div",{className:"flex items-center justify-center h-screen",children:t.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[t.jsx(d,{className:"w-8 h-8 animate-spin text-primary"}),t.jsx("p",{className:"text-gray-400",children:"Loading dashboard..."})]})}):j?t.jsx("div",{className:"flex items-center justify-center h-screen",children:t.jsxs("div",{className:"bg-red-900/20 border border-red-500 rounded-lg p-6",children:[t.jsx(s,{className:"w-8 h-8 text-red-500 mb-2"}),t.jsx("p",{className:"text-red-400",children:j})]})}):t.jsxs("div",{className:"min-h-screen bg-gray-900 text-white p-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"flex justify-between items-start mb-6",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold mb-2",children:"AI Logs & Analytics"}),t.jsx("p",{className:"text-gray-400",children:"Monitor AI model usage, performance, and costs"})]}),t.jsxs("div",{className:"flex space-x-3",children:[t.jsxs("button",{onClick:async()=>{b(!0),w(null);try{const e=await y.get("/api/admin/ai-logs/stats",{params:{startDate:_.start,endDate:_.end,groupBy:"day"},withCredentials:!0});M(e.data.data);const t=await y.get("/api/admin/ai-logs",{params:{startDate:_.start,endDate:_.end,page:$,limit:20},withCredentials:!0});C(t.data.data),Y(t.data.pagination.totalPages);const n=await y.get("/api/admin/ai-logs/sessions",{params:{page:1,limit:10},withCredentials:!0});T(n.data.data);const r=await y.get("/api/admin/ai-logs/errors",{params:{limit:10},withCredentials:!0});z(r.data.data)}catch(e){console.error("Error fetching dashboard data:",e),w("Failed to load dashboard data")}finally{b(!1)}},className:"px-4 py-2 bg-gray-800 rounded-lg hover:bg-gray-700 transition-colors flex items-center space-x-2",children:[t.jsx(d,{className:"w-4 h-4"}),t.jsx("span",{children:"Refresh"})]}),t.jsxs("button",{onClick:()=>{const e=A.map(e=>({Timestamp:Z(new Date(e.requestTimestamp),"yyyy-MM-dd HH:mm:ss"),Model:e.model,Tokens:e.totalTokens,Cost:e.estimatedCost,Latency:e.latencyMs,Type:e.responseType,Error:e.error?"Yes":"No"})),t=[Object.keys(e[0]).join(","),...e.map(e=>Object.values(e).join(","))].join("\n"),n=new Blob([t],{type:"text/csv"}),r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=`ai-logs-${_.start}-${_.end}.csv`,s.click()},className:"px-4 py-2 btn-primary rounded-lg transition-colors flex items-center space-x-2",children:[t.jsx(x,{className:"w-4 h-4"}),t.jsx("span",{children:"Export"})]})]})]}),t.jsxs("div",{className:"flex items-center space-x-4 bg-gray-800 rounded-lg p-4",children:[t.jsx(J,{className:"w-5 h-5 text-gray-400"}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("label",{className:"text-sm text-gray-400",children:"From:"}
1),t.jsx("input",{type:"date",value:_.start,onChange:e=>_e("start",e.target.value),className:"bg-gray-700 text-white px-3 py-1 rounded-sm border border-gray-600 focus:border-primary focus:outline-hidden"})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("label",{className:"text-sm text-gray-400",children:"To:"}),t.jsx("input",{type:"date",value:_.end,onChange:e=>_e("end",e.target.value),className:"bg-gray-700 text-white px-3 py-1 rounded-sm border border-gray-600 focus:border-primary focus:outline-hidden"})]}),t.jsx("div",{className:"flex space-x-2 ml-auto",children:[{label:"7D",days:7},{label:"30D",days:30},{label:"90D",days:90}].map(e=>t.jsx("button",{onClick:()=>{const t=new Date,n=Q(t,e.days);_e("start",Z(n,"yyyy-MM-dd")),_e("end",Z(t,"yyyy-MM-dd"))},className:"px-3 py-1 bg-gray-700 rounded-sm hover:bg-gray-600 transition-colors text-sm",children:e.label},e.label))})]})]}),t.jsx("div",{className:"flex space-x-1 mb-6 bg-gray-800 rounded-lg p-1 overflow-x-auto",children:[{id:"overview",label:"Overview",icon:g},{id:"logs",label:"Logs",icon:ee},{id:"sessions",label:"Sessions",icon:l},{id:"errors",label:"Errors",icon:s},{id:"relationships",label:"Relationships",icon:te}].map(e=>t.jsxs("button",{onClick:()=>V(e.id),className:"flex-1 px-4 py-2 rounded-lg transition-colors flex items-center justify-center space-x-2 "+(K===e.id?"btn-primary text-white":"text-gray-400 hover:text-white hover:bg-gray-700"),children:[t.jsx(e.icon,{className:"w-4 h-4"}),t.jsx("span",{children:e.label})]},e.id))}),"overview"===K&&k&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsx(Yr,{title:"Total Requests",value:k.overall?.totalRequests||0,icon:g,color:"purple"}),t.jsx(Yr,{title:"Total Tokens",value:Kr(k.overall?.totalTokens||0),icon:ne,color:"blue"}),t.jsx(Yr,{title:"Total Cost",value:`$${(parseFloat(k.overall?.totalCost)||0).toFixed(4)}`,icon:re,color:"green"}),t.jsx(Yr,{title:"Error Rate",value:`${(k.overall?.totalRequests>0?(parseFloat(k.overall?.errorCount)||0)/parseFloat(k.overall?.totalRequests)*100:0).toFixed(1)}%`,icon:s,color:"red",trend:k.overall?.errorCount>0?"up":"stable"})]}),t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Usage Over Time"}),t.jsx(O,{width:"100%",height:300,children:t.jsxs(se,{data:k.timeSeries||[],children:[t.jsx(F,{strokeDasharray:"3 3",stroke:"#374151"}),t.jsx(q,{dataKey:"period",stroke:"#9ca3af",tickFormatter:e=>Z(new Date(e),"MMM d")}),t.jsx(U,{stroke:"#9ca3af"}),t.jsx(L,{contentStyle:{backgroundColor:"#1f2937",border:"none"},labelFormatter:e=>Z(new Date(e),"MMM d, yyyy")}),t.jsx(ae,{type:"monotone",dataKey:"requests",stroke:a,fill:a,fillOpacity:.3,name:"Requests"}
1),t.jsx(ae,{type:"monotone",dataKey:"tokens",stroke:"#06b6d4",fill:"#06b6d4",fillOpacity:.3,name:"Tokens",yAxisId:"right"}),t.jsx(U,{yAxisId:"right",orientation:"right",stroke:"#9ca3af"})]})})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Model Usage"}),t.jsx(O,{width:"100%",height:300,children:t.jsxs(ie,{children:[t.jsx(oe,{data:k.byModel||[],dataKey:"requests",nameKey:"model",cx:"50%",cy:"50%",outerRadius:100,label:({model:e,percent:t})=>`${e.split("/").pop()}: ${(100*t).toFixed(0)}%`,children:(k.byModel||[]).map((e,n)=>t.jsx(le,{fill:i[n%i.length]},`cell-${n}`))}),t.jsx(L,{contentStyle:{backgroundColor:"#1f2937",border:"none"}})]})})]}),t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Cost by Model"}),t.jsx(O,{width:"100%",height:300,children:t.jsxs(ce,{data:k.byModel||[],children:[t.jsx(F,{strokeDasharray:"3 3",stroke:"#374151"}),t.jsx(q,{dataKey:"model",stroke:"#9ca3af",tickFormatter:e=>e.split("/").pop(),angle:-45,textAnchor:"end",height:100}),t.jsx(U,{stroke:"#9ca3af"}),t.jsx(L,{contentStyle:{backgroundColor:"#1f2937",border:"none"},formatter:e=>`$${parseFloat(e).toFixed(4)}`}),t.jsx(ue,{dataKey:"cost",fill:"#10b981",name:"Cost ($)"})]})})]})]}),t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Performance Metrics"}),t.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"Average Latency"}),t.jsxs("p",{className:"text-2xl font-semibold",children:[Math.round(k.overall?.avgLatency||0),"ms"]})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"Max Latency"}),t.jsxs("p",{className:"text-2xl font-semibold",children:[Math.round(k.overall?.maxLatency||0),"ms"]})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"Tool Usage"}),t.jsxs("p",{className:"text-2xl font-semibold",children:[k.toolUsage?.totalToolCalls||0," calls"]})]})]})]})]}),"logs"===K&&t.jsxs("div",{className:"bg-gray-800 rounded-lg",children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"bg-gray-900",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Timestamp"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Model"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Type"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Tokens"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Cost"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Latency"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase tracking-wider",children:"Status"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-700",children:A.map(e=>t.jsxs("tr",{className:"hover:bg-gray-700/50 transition-colors",children:[t.jsx("td",{className:"px-4 py-3 text-sm",children:Z(new Date(e.requestTimestamp),"MMM d, HH:mm:ss")}),t.jsx("td",{className:"px-4 py-3 text-sm",children:t.jsx("span",{className:"text-primary",children:e.model.split("/").pop()})}),t.jsx("td",{className:"px-4 py-3 text-sm",children:t.jsx("span",{className:"px-2 py-1 text-xs rounded-full "+("tool_calls"===e.responseType?"bg-blue-900/50 text-blue-400":"message"===e.responseType?"bg-green-900/50 text-green-400":"bg-gray-700 text-gray-400"),children:e.responseType})}),t.jsx("td",{className:"px-4 py-3 text-sm",children:Kr(e.totalTokens)}),t.jsxs("td",{className:"px-4 py-3 text-sm",children:["$",(parseFloat(e.estimatedCost)||0).toFixed(4)]}),t.jsxs("td",{className:"px-4 py-3 text-sm",children:[e.latencyMs,"ms"]}),t.jsx("td",{className:"px-4 py-3 text-sm",children:e.error?t.jsxs("span",{className:"text-red-400 flex items-center space-x-1",children:[t.jsx(s,{className:"w-4 h-4"}),t.jsx("span",{children:"Error"})]}):t.jsx("span",{className:"text-green-400",children:"Success"})})]},e.id))})]})}),t.jsxs("div",{className:"flex justify-between items-center p-4 border-t border-gray-700",children:[t.jsx("button",{onClick:()=>B(Math.max(1,$-1)),disabled:1===$,className:"px-4 py-2 bg-gray-700 rounded-sm hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),t.jsxs("span",{className:"text-gray-400",children:["Page ",$," of ",X]}),t.jsx("button",{onClick:()=>B(Math.min(X,$+1)),disabled:$===X,className:"px-4 py-2 bg-gray-700 rounded-sm hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]}),"sessions"===K&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Recent Sessions"}),t.jsx("div",{className:"space-y-3",children:S.map(e=>t.jsxs("div",{onClick:()=>(async e=>{try{const t=await y.get(`/api/admin/ai-logs/session/${e}`,{withCredentials:!0});R(t.data.data),P(e)}catch(t){console.error("Error fetching session details:",t)}})(e.sessionId),className:"p-4 bg-gray-700 rounded-lg cursor-pointer hover:bg-gray-600 transition-colors "+(D===e.sessionId?"ring-2 ring-(--theme-primary-color)":""),children:[t.jsxs("div",{className:"flex justify-between items-start mb-2",children:[t.jsxs("div",{children:[t.jsxs("p",{className:"font-medium text-sm",children:[e.sessionId.substring(0,16),"..."]}),t.jsx("p",{className:"text-xs text-gray-400",children:de(new Date(e.startTime),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex space-x-2",children:[e.hasEndTurn&&t.jsx("span",{className:"px-2 py-1 bg-green-900/50 text-green-400 text-xs rounded-sm",children:"Completed"}),e.hasError&&t.jsx("span",{className:"px-2 py-1 bg-red-900/50 text-red-400 text-xs rounded-sm",children:"Error"})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Iterations"}),t.jsx("p",{className:"font-medium",children:e.iterations})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Tokens"}),t.jsx("p",{className:"font-medium",children:Kr(e.totalTokens)})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Duration"}),t.jsx("p",{className:"font-medium",children:e.duration?`${Math.round(e.duration/1e3)}s`:"N/A"})]})]})]},e.sessionId))})]}),I&&t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Session Details"}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-400 mb-2",children:"Summary"}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Duration"}),t.jsxs("p",{children:[Math.round(I.summary.duration/1e3),"s"]})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Total Cost"}),t.jsxs("p",{children:["$",(parseFloat(I.summary.totalCost)||0).toFixed(4)]})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Models Used"}),t.jsx("p",{children:I.summary.models.map(e=>e.split("/").pop()).join(", ")})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-gray-500",children:"Tools Used"}),t.jsx("p",{children:I.summary.toolsUsed.length||"None"})]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-400 mb-2",children:"Turn Flow"}),t.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:I.logs.map((e,n)=>t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"shrink-0 w-8 h-8 btn-primary rounded-full flex items-center justify-center text-xs",children:n+1}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm",children:"tool_calls"===e.responseType?t.jsxs("span",{className:"text-blue-400",children:["Tools: ",e.toolCallsMa
1de?.map(e=>e.name).join(", ")]}):t.jsx("span",{className:"text-gray-300",children:e.responseType})}),t.jsxs("p",{className:"text-xs text-gray-500",children:[e.latencyMs,"ms • ",Kr(e.totalTokens)," tokens"]})]})]},e.id))})]})]})]}),"errors"===K&&E&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-gray-800 rounded-lg p-6",children:[t.jsx("h3",{className:"text-xl font-semibold mb-4",children:"Error Types"}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:E.errorTypes?.map(e=>t.jsxs("div",{className:"bg-gray-700 rounded-lg p-4",children:[t.jsx("p",{className:"text-red-400 font-medium mb-1",children:e.errorCode||"Unknown Error"}),t.jsx("p",{className:"text-2xl font-bold",children:e.count}),t.jsx("p",{className:"text-xs text-gray-400",children:"occurrences"})]},e.errorCode||"unknown"))})]}),t.jsxs("div",{className:"bg-gray-800 rounded-lg",children:[t.jsx("div",{className:"p-6 border-b border-gray-700",children:t.jsx("h3",{className:"text-xl font-semibold",children:"Recent Errors"})}),t.jsx("div",{className:"divide-y divide-gray-700",children:E.errors?.map(e=>t.jsxs("div",{className:"p-4 hover:bg-gray-700/50 transition-colors",children:[t.jsxs("div",{className:"flex justify-between items-start mb-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-red-400 font-medium",children:e.errorCode||"Error"}),t.jsx("p",{className:"text-sm text-gray-300 mt-1",children:e.errorMessage})]}),t.jsx("p",{className:"text-xs text-gray-500",children:de(new Date(e.requestTimestamp),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex space-x-4 text-xs text-gray-400",children:[t.jsxs("span",{children:["Model: ",e.model?.split("/").pop()]}),t.jsxs("span",{children:["Retries: ",e.retryCount]}),t.jsxs("span",{children:["Latency: ",e.latencyMs,"ms"]})]})]},e.id))})]})]}),"relationships"===K&&t.jsx("div",{className:"h-[calc(100vh-200px)]",children:t.jsx(Br,{relationships:ve.data?.relationships||[],people:ve.data?.people||[],onInfer:je,isInferring:W})}),!1]})},Yr=({title:e,value:n,icon:r,color:s,trend:a})=>t.jsxs("div",{className:`p-4 rounded-lg border ${{purple:"bg-primary-20 text-primary border-primary",blue:"bg-blue-900/20 text-blue-400 border-blue-500",green:"bg-green-900/20 text-green-400 border-green-500",red:"bg-red-900/20 text-red-400 border-red-500"}[s]}`,children:[t.jsxs("div",{className:"flex justify-between items-start mb-2",children:[t.jsx(r,{className:"w-5 h-5"}),a&&t.jsx(i,{className:"w-4 h-4 "+("up"===a?"text-red-400":"text-green-400")})]}),t.jsx("p",{className:"text-2xl font-bold",children:n}),t.jsx("p",{className:"text-sm opacity-75",children:e})]}),Kr=e=>{const t=parseFloat(e)||0;return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()};export{Xr as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.