diff --git a/frontend/dist/assets/GraphView-B3bOxhlI.js b/frontend/dist/assets/GraphView-D0BHEwUM.js similarity index 99% rename from frontend/dist/assets/GraphView-B3bOxhlI.js rename to frontend/dist/assets/GraphView-D0BHEwUM.js index e250327..b0c7a13 100644 --- a/frontend/dist/assets/GraphView-B3bOxhlI.js +++ b/frontend/dist/assets/GraphView-D0BHEwUM.js @@ -1,4 +1,4 @@ -import{R as Fh,B as Ww,a as Xw,V as _n,F as qw,r as Iy,g as ki,b as q,c as go,d as Yw,e as jw,_ as Tc,u as $w,j as Zw,f as Kw,h as Se,l as Jw,S as Qw,i as Cg,T as eS}from"./index-B8ZgHkJP.js";const tS=r=>typeof r=="object"&&typeof r.then=="function",Zc=[];function nS(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e)return!1;const n=r.length;if(e.length!==n)return!1;for(let i=0;i0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,n.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:n.equal,remove:()=>{const s=Zc.indexOf(i);s!==-1&&Zc.splice(s,1)},promise:(tS(r)?r:r(...e)).then(s=>{i.response=s,n.lifespan&&n.lifespan>0&&(i.timeout=setTimeout(i.remove,n.lifespan))}).catch(s=>i.error=s)};if(Zc.push(i),!t)throw i.promise}const rS=(r,e,t)=>iS(r,e,!1,t);function sS(r,e,t){return Math.max(e,Math.min(r,t))}const Tt={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function Rg(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function Pg(r,e,t,n=.15){return n===0?sS(r,e,t):rt?+Rg(r-t,t-e,n)+t:r}function oS(r,[e,t],[n,i]){const[[s,o],[a,c]]=r;return[Pg(e,s,o,n),Pg(t,a,c,i)]}function aS(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function cS(r){var e=aS(r,"string");return typeof e=="symbol"?e:String(e)}function $t(r,e,t){return e=cS(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Lg(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function Ut(r){for(var e=1;e{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function gS(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Ny(r){return Du(r)?gS(r)[0]:r}function Pd(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,s=(e.clientY+r.clientY)/2,o=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function vS(r){return mS(r).map(e=>e.identifier)}function Ig(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return Pd(t,n)}function kh(r){const e=Ny(r);return Du(r)?e.identifier:e.pointerId}function To(r){const e=Ny(r);return[e.clientX,e.clientY]}const Ug=40,Og=800;function Fy(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=Ug,t*=Ug):n===2&&(e*=Og,t*=Og),[e,t]}function _S(r){var e,t;const{scrollX:n,scrollY:i,scrollLeft:s,scrollTop:o}=r.currentTarget;return[(e=n??s)!==null&&e!==void 0?e:0,(t=i??o)!==null&&t!==void 0?t:0]}function yS(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s})}return e}function gu(r,...e){return typeof r=="function"?r(...e):r}function xS(){}function bS(...r){return r.length===0?xS:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Ng(r,e){return Object.assign({},e,r||{})}const wS=32;class ky{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?gu(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let s=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,yS(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const w=t._delta.map(Math.abs);Tt.addTo(t._distance,w)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[c,l]=n.threshold,{_step:u,values:h}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=c&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=c&&Math.sign(o)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const f=[0,0];if(n.hasCustomTransform){const[w,S]=h;f[0]=u[0]!==!1?w-u[0]:0,f[1]=u[1]!==!1?S-u[1]:0}else f[0]=u[0]!==!1?o-u[0]:0,f[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(f);const d=t.offset,m=t._active&&!t._blocked||t.active;m&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=gu(n.bounds,t)),this.setup&&this.setup()),t.movement=f,this.computeOffset()));const[v,g]=t.offset,[[p,_],[y,x]]=t._bounds;t.overflow=[v_?1:0,gx?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const b=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=oS(t._bounds,t.offset,b),t.delta=Tt.sub(t.offset,d),this.computeMovement(),m&&(!t.last||s>wS)){t.delta=Tt.sub(t.offset,d);const w=t.delta.map(Math.abs);Tt.addTo(t.distance,w),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[w[0]/s,w[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(Ut(Ut(Ut({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function SS([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class Ac extends ky{constructor(...e){super(...e),$t(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Tt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Tt.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Oy(e)]:n.axisThreshold;t.axis=SS(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ES=r=>r,Fg=.15,zy={enabled(r=!0){return r},eventOptions(r,e,t){return Ut(Ut({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Fg,Fg];case!1:return[0,0];default:return Tt.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return Tt.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||ES},threshold(r){return Tt.toVector(r,0)}},MS=0,Es=Ut(Ut({},zy),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=MS){return r},bounds(r={}){if(typeof r=="function")return s=>Es.bounds(r(s));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),kg={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class TS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Es.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=kh(e),n._pointerActive=!0,this.computeValues(To(e)),this.computeInitial(),t.preventScrollAxis&&Oy(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const s=To(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=Tt.sub(s,t._values),this.computeValues(s)),Tt.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=t._distance;if(t.tap=s<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[l,u]=t._movement,[h,f]=n.swipe.velocity,[d,m]=n.swipe.distance,v=n.swipe.duration;if(t.elapsedTimeh&&Math.abs(l)>d&&(t.swipe[0]=Math.sign(a)),p>f&&Math.abs(u)>m&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,AS(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=kg[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,Tt.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in kg&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function AS(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Cc=typeof window<"u"&&window.document&&window.document.createElement;function By(){return Cc&&"ontouchstart"in window}function CS(){return By()||Cc&&window.navigator.maxTouchPoints>1}function RS(){return Cc&&"onpointerdown"in window}function PS(){return Cc&&"exitPointerLock"in window.document}function LS(){try{return"constructor"in GestureEvent}catch{return!1}}const Qn={isBrowser:Cc,gesture:LS(),touch:By(),touchscreen:CS(),pointer:RS(),pointerLock:PS()},DS=250,IS=180,US=.5,OS=50,NS=250,FS=10,zg={mouse:0,touch:0,pen:8},kS=Ut(Ut({},Es),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&Qn.pointerLock,Qn.touch&&t?"touch":this.pointerLock?"mouse":Qn.pointer&&!i?"pointer":Qn.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?DS:void 0,!(!Qn.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const s=Tt.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,s},swipe({velocity:r=US,distance:e=OS,duration:t=NS}={}){return{velocity:this.transform(Tt.toVector(r)),distance:this.transform(Tt.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return IS;case!1:return 0;default:return r}},axisThreshold(r){return r?Ut(Ut({},zg),r):zg},keyboardDisplacement(r=FS){return r}});function Gy(r){const[e,t]=r.overflow,[n,i]=r._delta,[s,o]=r._direction;(e<0&&n>0&&s<0||e>0&&n<0&&s>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&o<0||t>0&&i<0&&o>0)&&(r._movement[1]=r._movementBound[1])}const zS=30,BS=100;class GS extends ky{constructor(...e){super(...e),$t(this,"ingKey","pinching"),$t(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=Tt.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*zS-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>n.has(s))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=Ig(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(o=>i.has(o))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const s=Pd(...Array.from(n.values()));s&&this.pinchStart(e,s)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=Ig(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=Pd(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],s=t.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*o]),n.origin=t.origin,n.turns=o,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=Tt.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-Fy(e)[1]/BS*n.offset[0],0],Tt.addTo(n._movement,n._delta),Gy(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const VS=Ut(Ut({},zy),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!Qn.touch&&Qn.gesture)return"gesture";if(Qn.touch&&n)return"touch";if(Qn.touchscreen){if(Qn.pointer)return"pointer";if(Qn.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const a=Ng(gu(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=Ng(gu(n,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",Tt.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});class HS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(To(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const t=To(e),n=this.state;n._delta=Tt.sub(t,n._values),Tt.addTo(n._movement,n._delta),this.computeValues(t),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const WS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r});class XS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const t=this.state,n=_S(e);t._delta=Tt.sub(n,t._values),Tt.addTo(t._movement,t._delta),this.computeValues(n),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const qS=Es;class YS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=Fy(e),Tt.addTo(t._movement,t._delta),Gy(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const jS=Es;class $S extends Ac{constructor(...e){super(...e),$t(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(To(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const t=this.state;if(!t._active)return;t._active=!1;const n=To(e);t._movement=t._delta=Tt.sub(n,t._values),this.computeValues(n),this.compute(e),t.delta=t.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const ZS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r}),Gp=new Map,Ld=new Map;function KS(r){Gp.set(r.key,r.engine),Ld.set(r.key,r.resolver)}const JS={key:"drag",engine:TS,resolver:kS},QS={key:"hover",engine:$S,resolver:ZS},eE={key:"move",engine:HS,resolver:WS},tE={key:"pinch",engine:GS,resolver:VS},nE={key:"scroll",engine:XS,resolver:qS},iE={key:"wheel",engine:YS,resolver:jS};function rE(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s=0)&&(t[i]=r[i]);return t}function sE(r,e){if(r==null)return{};var t=rE(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const oE={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=Qn.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},aE=["target","eventOptions","window","enabled","transform"];function nu(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=nu(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function cE(r,e,t={}){const n=r,{target:i,eventOptions:s,window:o,enabled:a,transform:c}=n,l=sE(n,aE);if(t.shared=nu({target:i,eventOptions:s,window:o,enabled:a,transform:c},oE),e){const u=Ld.get(e);t[e]=nu(Ut({shared:t.shared},l),u)}else for(const u in l){const h=Ld.get(u);h&&(t[u]=nu(Ut({shared:t.shared},l[u]),h))}return t}class Vy{constructor(e,t){$t(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,s){const o=this._listeners,a=pS(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=Ut(Ut({},c),s);e.addEventListener(a,i,l);const u=()=>{e.removeEventListener(a,i,l),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class lE{constructor(){$t(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}let uE=class{constructor(e){$t(this,"gestures",new Set),$t(this,"_targetEventStore",new Vy(this)),$t(this,"gestureEventStores",{}),$t(this,"gestureTimeoutStores",{}),$t(this,"handlers",{}),$t(this,"config",{}),$t(this,"pointerIds",new Set),$t(this,"touchIds",new Set),$t(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),hE(this,e)}setEventIds(e){if(Du(e))return this.touchIds=new Set(vS(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=cE(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],c=Bg(n,a.eventOptions,!!i);if(a.enabled){const l=Gp.get(o);new l(this,e,o).bind(c)}}const s=Bg(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](Ut(Ut({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in n)n[s]=bS(...n[s]);if(!i)return n;for(const s in n){const{device:o,capture:a,passive:c}=dS(s);this._targetEventStore.add(i,o,"",n[s],{capture:a,passive:c})}}}};function Ds(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Vy(r,e),r.gestureTimeoutStores[e]=new lE}function hE(r,e){e.drag&&Ds(r,"drag"),e.wheel&&Ds(r,"wheel"),e.scroll&&Ds(r,"scroll"),e.move&&Ds(r,"move"),e.pinch&&Ds(r,"pinch"),e.hover&&Ds(r,"hover")}const Bg=(r,e,t)=>(n,i,s,o={},a=!1)=>{var c,l;const u=(c=o.capture)!==null&&c!==void 0?c:e.capture,h=(l=o.passive)!==null&&l!==void 0?l:e.passive;let f=a?n:hS(n,i,u);t&&h&&(f+="Passive"),r[f]=r[f]||[],r[f].push(s)},fE=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function dE(r){const e={},t={},n=new Set;for(let i in r)fE.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function Is(r,e,t,n,i,s){if(!r.has(t)||!Gp.has(n))return;const o=t+"Start",a=t+"End",c=l=>{let u;return l.first&&o in e&&e[o](l),t in e&&(u=e[t](l)),l.last&&a in e&&e[a](l),u};i[n]=c,s[n]=s[n]||{}}function pE(r,e){const[t,n,i]=dE(r),s={};return Is(i,t,"onDrag","drag",s,e),Is(i,t,"onWheel","wheel",s,e),Is(i,t,"onScroll","scroll",s,e),Is(i,t,"onPinch","pinch",s,e),Is(i,t,"onMove","move",s,e),Is(i,t,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:n}}function mE(r,e={},t,n){const i=Fh.useMemo(()=>new uE(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),Fh.useEffect(i.effect.bind(i)),Fh.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function gE(r){return r.forEach(KS),function(t,n){const{handlers:i,nativeHandlers:s,config:o}=pE(t,n||{});return mE(i,o,void 0,s)}}function vE(r,e){return gE([JS,tE,nE,iE,eE,QS])(r,e||{})}const Kc=(r,e)=>{const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,c=new Ww;let l=0;if(r.forEach((u,h)=>{let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(u.userData),e){let d;if(u.index)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,d,h),l+=d}}),t){let u=0;const h=[];r.forEach(f=>{const d=f.index;for(let m=0;m{let e,t,n,i=0;if(r.forEach(s=>{if(e===void 0&&(e=s.array.constructor),e!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=s.itemSize),t!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=s.normalized),n!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=s.array.length}),e&&t){const s=new e(i);let o=0;return r.forEach(a=>{s.set(a.array,o),o+=a.array.length}),new Xw(s,t,n)}},zh=new qw,Bh=new _n,Us=new _n,ci=new _n,Gi=new _n,Ti=new _n,Vi=new _n,Hi=new _n,Jo=new _n,Qo=new _n,ea=new _n,Jc=new _n,ta=new _n,na=new _n,ia=new _n;class Vg{constructor(e,t,n){this.camera=e,this.scene=t,this.startPoint=new _n,this.endPoint=new _n,this.collection=[],this.deep=n||Number.MAX_VALUE}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(zh,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Us.copy(e),Us.x=Math.min(e.x,t.x),Us.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),ci.setFromMatrixPosition(this.camera.matrixWorld),Gi.copy(Us),Ti.set(t.x,Us.y,0),Vi.copy(t),Hi.set(Us.x,t.y,0),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),ta.copy(Gi).sub(ci),na.copy(Ti).sub(ci),ia.copy(Vi).sub(ci),ta.normalize(),na.normalize(),ia.normalize(),ta.multiplyScalar(this.deep),na.multiplyScalar(this.deep),ia.multiplyScalar(this.deep),ta.add(ci),na.add(ci),ia.add(ci);var n=zh.planes;n[0].setFromCoplanarPoints(ci,Gi,Ti),n[1].setFromCoplanarPoints(ci,Ti,Vi),n[2].setFromCoplanarPoints(Vi,Hi,ci),n[3].setFromCoplanarPoints(Hi,Gi,ci),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ia,na,ta),n[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),s=Math.max(e.y,t.y),o=Math.max(e.x,t.x),a=Math.min(e.y,t.y);Gi.set(i,s,-1),Ti.set(o,s,-1),Vi.set(o,a,-1),Hi.set(i,a,-1),Jo.set(i,s,1),Qo.set(o,s,1),ea.set(o,a,1),Jc.set(i,a,1),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),Jo.unproject(this.camera),Qo.unproject(this.camera),ea.unproject(this.camera),Jc.unproject(this.camera);var n=zh.planes;n[0].setFromCoplanarPoints(Gi,Jo,Qo),n[1].setFromCoplanarPoints(Ti,Qo,ea),n[2].setFromCoplanarPoints(ea,Jc,Hi),n[3].setFromCoplanarPoints(Jc,Jo,Gi),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ea,Qo,Jo),n[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if((t.isMesh||t.isLine||t.isPoints)&&t.material!==void 0&&(t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),Bh.copy(t.geometry.boundingSphere.center),Bh.applyMatrix4(t.matrixWorld),e.containsPoint(Bh)&&this.collection.push(t)),t.children.length>0)for(let n=0;n0;)de[pe]=arguments[pe+2];var Me=xe[he]||(xe[he]=R.getUniformLocation(ce,he));R["uniform"+$].apply(R,[Me].concat(de))},setAttribute:function($,he,de,pe,Me){var we=fe[$];we||(we=fe[$]={buf:R.createBuffer(),loc:R.getAttribLocation(ce,$),data:null}),R.bindBuffer(R.ARRAY_BUFFER,we.buf),R.vertexAttribPointer(we.loc,he,R.FLOAT,!1,0,0),R.enableVertexAttribArray(we.loc),H?R.vertexAttribDivisor(we.loc,pe):ge("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(we.loc,pe),Me!==we.data&&(R.bufferData(R.ARRAY_BUFFER,Me,de),we.data=Me)}})}}}J[K].transaction(re)},D=function(K,W){ne++;try{R.activeTexture(R.TEXTURE0+ne);var ye=ie[K];ye||(ye=ie[K]=R.createTexture(),R.bindTexture(R.TEXTURE_2D,ye),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,R.NEAREST),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,R.NEAREST)),R.bindTexture(R.TEXTURE_2D,ye),W(ye,ne)}finally{ne--}},Q=function(K,W,ye){var re=R.createFramebuffer();ee.push(re),R.bindFramebuffer(R.FRAMEBUFFER,re),R.activeTexture(R.TEXTURE0+W),R.bindTexture(R.TEXTURE_2D,K),R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,K,0);try{ye(re)}finally{R.deleteFramebuffer(re),R.bindFramebuffer(R.FRAMEBUFFER,ee[--ee.length-1]||null)}},j=function(){Y={},J={},ie={},ne=-1,ee.length=0};var H=typeof WebGL2RenderingContext<"u"&&R instanceof WebGL2RenderingContext,Y={},J={},ie={},ne=-1,ee=[];R.canvas.addEventListener("webglcontextlost",function(K){j(),K.preventDefault()},!1),c.set(R,F={gl:R,isWebGL2:H,getExtension:ge,withProgram:te,withTexture:D,withTextureFramebuffer:Q,handleContextLoss:j})}U(F)}function h(k,U,R,F,H,Y,J,ie){J===void 0&&(J=15),ie===void 0&&(ie=null),u(k,function(ne){var ee=ne.gl,ge=ne.withProgram,me=ne.withTexture;me("copy",function(te,D){ee.texImage2D(ee.TEXTURE_2D,0,ee.RGBA,H,Y,0,ee.RGBA,ee.UNSIGNED_BYTE,U),ge("copy",o,a,function(Q){var j=Q.setUniform,K=Q.setAttribute;K("aUV",2,ee.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),j("1i","image",D),ee.bindFramebuffer(ee.FRAMEBUFFER,ie||null),ee.disable(ee.BLEND),ee.colorMask(J&8,J&4,J&2,J&1),ee.viewport(R,F,H,Y),ee.scissor(R,F,H,Y),ee.drawArrays(ee.TRIANGLES,0,3)})})})}function f(k,U,R){var F=k.width,H=k.height;u(k,function(Y){var J=Y.gl,ie=new Uint8Array(F*H*4);J.readPixels(0,0,F,H,J.RGBA,J.UNSIGNED_BYTE,ie),k.width=U,k.height=R,h(J,ie,0,0,F,H)})}var d=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:f});function m(k,U,R,F,H,Y){Y===void 0&&(Y=1);var J=new Uint8Array(k*U),ie=F[2]-F[0],ne=F[3]-F[1],ee=[];s(R,function(K,W,ye,re){ee.push({x1:K,y1:W,x2:ye,y2:re,minX:Math.min(K,ye),minY:Math.min(W,re),maxX:Math.max(K,ye),maxY:Math.max(W,re)})}),ee.sort(function(K,W){return K.maxX-W.maxX});for(var ge=0;gexe.minX&&W-rexe.minY){var ce=p(K,W,xe.x1,xe.y1,xe.x2,xe.y2);ceW!=fe.y2>W&&K<(fe.x2-fe.x1)*(W-fe.y1)/(fe.y2-fe.y1)+fe.x1;xe&&(ye+=fe.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function v(re,fe){var xe=36,ce=0,Pe=new Map,B=fe&&new Map,I;return re.split(",").forEach(function $(he){if(he.indexOf("+")!==-1)for(var de=+he;de--;)$(I);else{I=he;var pe=he.split(">"),Me=pe[0],we=pe[1];Me=String.fromCodePoint(ce+=parseInt(Me,xe)),we=String.fromCodePoint(ce+=parseInt(we,xe)),Pe.set(Me,we),fe&&B.set(we,Me)}}),{map:Pe,reverseMap:B}}var g,p,_;function y(){if(!g){var re=v(m.pairs,!0),fe=re.map,xe=re.reverseMap;g=fe,p=xe,_=v(m.canonical,!1).map}}function x(re){return y(),g.get(re)||null}function b(re){return y(),p.get(re)||null}function w(re){return y(),_.get(re)||null}var S=n.L,M=n.R,E=n.EN,T=n.ES,L=n.ET,P=n.AN,A=n.CS,z=n.B,V=n.S,N=n.ON,C=n.BN,O=n.NSM,k=n.AL,U=n.LRO,R=n.RLO,F=n.LRE,H=n.RLE,Y=n.PDF,J=n.LRI,ie=n.RLI,ne=n.FSI,ee=n.PDI;function ge(re,fe){for(var xe=125,ce=new Uint32Array(re.length),Pe=0;Pe0)De--;else if(je>0){for(Ve=0;!Le[Le.length-1]._isolate;)Le.pop();var tt=Le[Le.length-1]._isolInitIndex;tt!=null&&(he.set(tt,Z),he.set(Z,tt)),Le.pop(),je--}Ee=Le[Le.length-1],$[Z]=Ee._level,Ee._override&&I(Z,Ee._override)}else Ae&Y?(De===0&&(Ve>0?Ve--:!Ee._isolate&&Le.length>1&&(Le.pop(),Ee=Le[Le.length-1])),$[Z]=Ee._level):Ae&z&&($[Z]=pe.level);else $[Z]=Ee._level,Ee._override&&Ae!==C&&I(Z,Ee._override)}for(var lt=[],ft=null,ut=pe.start;ut<=pe.end;ut++){var xt=ce[ut];if(!(xt&c)){var dt=$[ut],ct=xt&s,Mn=xt===ee;ft&&dt===ft._level?(ft._end=ut,ft._endsWithIsolInit=ct):lt.push(ft={_start:ut,_end:ut,_level:dt,_startsWithPDI:Mn,_endsWithIsolInit:ct})}}for(var fn=[],yt=0;yt=0;se--)if(!(ce[se]&c)){ve=$[se];break}var _e=sn[sn.length-1],Ge=$[_e],We=pe.level;if(!(ce[_e]&s)){for(var qe=_e+1;qe<=pe.end;qe++)if(!(ce[qe]&c)){We=$[qe];break}}fn.push({_seqIndices:sn,_sosType:Math.max(ve,ae)%2?M:S,_eosType:Math.max(We,Ge)%2?M:S})}}for(var Ye=0;Ye=0;at--)if(!(ce[Te[at]]&c)){Ct=ce[Te[at]];break}I(Xn,Ct&(s|ee)?N:Ct)}}if(B.get(E))for(var fr=0;fr=-1;qn--){var Vo=qn===-1?Ze:ce[Te[qn]];if(Vo&o){Vo===k&&I(Wt,P);break}}}if(B.get(k))for(var Bi=0;Bi=0&&(Mi=ce[Te[zr]],!!(Mi&c));zr--);for(var Ho=Xt+1;Ho=0&&ce[Te[Hc]]&(L|c);Hc--)I(Te[Hc],E);for(On++;On=0&&ce[Te[Wc]]&c;Wc--)I(Te[Wc],N);for(var Xc=Wo+1;Xc=0;Yo--){var Rh=Ps[Yo].char;if(Rh===vg||Rh===b(w(qo))||x(w(Rh))===qo){qc.push([Ps[Yo].seqIndex,Ls]),Ps.length=Yo;break}}}qc.sort(function(Tn,ai){return Tn[0]-ai[0]})}for(var Ph=0;Ph=0;Ih--){var wg=Te[Ih];if(ce[wg]&gg){var Sg=ce[wg]&Xo?M:S;Sg!==bt?oi=Sg:oi=bt;break}}}if(oi){if(ce[Te[Yc]]=ce[Te[Lh]]=oi,oi!==bt){for(var jo=Yc+1;jo=0;Zo--)if(ce[Te[Zo]]&c)Eg=Zo;else{Oh=ce[Te[Zo]]&Xo?M:S;break}for(var Mg=At,Ko=dr+1;Ko=0&&f(re[$c])&l;$c--)$[$c]=pe.level}}return{levels:$,paragraphs:de};function Tg(Tn,ai){for(var An=Tn;An=$&&f(re[pe])&l;pe--)de[pe]=I.level;for(var Me=I.level,we=1/0,ue=0;ueMe&&(Me=Ce),Ce=we;ze--)for(var Le=0;Le=ze){for(var Ee=Le;Le+1=ze;)Le++;Le>Ee&&B.push([Ee+$,Le+$])}}}),B}function W(re,fe,xe,ce){var Pe=ye(re,fe,xe,ce),B=[].concat(re);return Pe.forEach(function(I,$){B[$]=(fe.levels[I]&1?Q(re[I]):null)||re[I]}),B.join("")}function ye(re,fe,xe,ce){for(var Pe=K(re,fe,xe,ce),B=[],I=0;Itypeof r=="object"&&typeof r.then=="function",Zc=[];function nS(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e)return!1;const n=r.length;if(e.length!==n)return!1;for(let i=0;i0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,n.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:n.equal,remove:()=>{const s=Zc.indexOf(i);s!==-1&&Zc.splice(s,1)},promise:(tS(r)?r:r(...e)).then(s=>{i.response=s,n.lifespan&&n.lifespan>0&&(i.timeout=setTimeout(i.remove,n.lifespan))}).catch(s=>i.error=s)};if(Zc.push(i),!t)throw i.promise}const rS=(r,e,t)=>iS(r,e,!1,t);function sS(r,e,t){return Math.max(e,Math.min(r,t))}const Tt={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function Rg(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function Pg(r,e,t,n=.15){return n===0?sS(r,e,t):rt?+Rg(r-t,t-e,n)+t:r}function oS(r,[e,t],[n,i]){const[[s,o],[a,c]]=r;return[Pg(e,s,o,n),Pg(t,a,c,i)]}function aS(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function cS(r){var e=aS(r,"string");return typeof e=="symbol"?e:String(e)}function $t(r,e,t){return e=cS(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Lg(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function Ut(r){for(var e=1;e{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function gS(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Ny(r){return Du(r)?gS(r)[0]:r}function Pd(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,s=(e.clientY+r.clientY)/2,o=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function vS(r){return mS(r).map(e=>e.identifier)}function Ig(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return Pd(t,n)}function kh(r){const e=Ny(r);return Du(r)?e.identifier:e.pointerId}function To(r){const e=Ny(r);return[e.clientX,e.clientY]}const Ug=40,Og=800;function Fy(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=Ug,t*=Ug):n===2&&(e*=Og,t*=Og),[e,t]}function _S(r){var e,t;const{scrollX:n,scrollY:i,scrollLeft:s,scrollTop:o}=r.currentTarget;return[(e=n??s)!==null&&e!==void 0?e:0,(t=i??o)!==null&&t!==void 0?t:0]}function yS(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s})}return e}function gu(r,...e){return typeof r=="function"?r(...e):r}function xS(){}function bS(...r){return r.length===0?xS:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Ng(r,e){return Object.assign({},e,r||{})}const wS=32;class ky{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?gu(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let s=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,yS(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const w=t._delta.map(Math.abs);Tt.addTo(t._distance,w)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[c,l]=n.threshold,{_step:u,values:h}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=c&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=c&&Math.sign(o)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const f=[0,0];if(n.hasCustomTransform){const[w,S]=h;f[0]=u[0]!==!1?w-u[0]:0,f[1]=u[1]!==!1?S-u[1]:0}else f[0]=u[0]!==!1?o-u[0]:0,f[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(f);const d=t.offset,m=t._active&&!t._blocked||t.active;m&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=gu(n.bounds,t)),this.setup&&this.setup()),t.movement=f,this.computeOffset()));const[v,g]=t.offset,[[p,_],[y,x]]=t._bounds;t.overflow=[v_?1:0,gx?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const b=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=oS(t._bounds,t.offset,b),t.delta=Tt.sub(t.offset,d),this.computeMovement(),m&&(!t.last||s>wS)){t.delta=Tt.sub(t.offset,d);const w=t.delta.map(Math.abs);Tt.addTo(t.distance,w),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[w[0]/s,w[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(Ut(Ut(Ut({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function SS([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class Ac extends ky{constructor(...e){super(...e),$t(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Tt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Tt.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Oy(e)]:n.axisThreshold;t.axis=SS(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ES=r=>r,Fg=.15,zy={enabled(r=!0){return r},eventOptions(r,e,t){return Ut(Ut({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Fg,Fg];case!1:return[0,0];default:return Tt.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return Tt.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||ES},threshold(r){return Tt.toVector(r,0)}},MS=0,Es=Ut(Ut({},zy),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=MS){return r},bounds(r={}){if(typeof r=="function")return s=>Es.bounds(r(s));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),kg={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class TS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Es.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=kh(e),n._pointerActive=!0,this.computeValues(To(e)),this.computeInitial(),t.preventScrollAxis&&Oy(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const s=To(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=Tt.sub(s,t._values),this.computeValues(s)),Tt.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=t._distance;if(t.tap=s<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[l,u]=t._movement,[h,f]=n.swipe.velocity,[d,m]=n.swipe.distance,v=n.swipe.duration;if(t.elapsedTimeh&&Math.abs(l)>d&&(t.swipe[0]=Math.sign(a)),p>f&&Math.abs(u)>m&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,AS(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=kg[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,Tt.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in kg&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function AS(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Cc=typeof window<"u"&&window.document&&window.document.createElement;function By(){return Cc&&"ontouchstart"in window}function CS(){return By()||Cc&&window.navigator.maxTouchPoints>1}function RS(){return Cc&&"onpointerdown"in window}function PS(){return Cc&&"exitPointerLock"in window.document}function LS(){try{return"constructor"in GestureEvent}catch{return!1}}const Qn={isBrowser:Cc,gesture:LS(),touch:By(),touchscreen:CS(),pointer:RS(),pointerLock:PS()},DS=250,IS=180,US=.5,OS=50,NS=250,FS=10,zg={mouse:0,touch:0,pen:8},kS=Ut(Ut({},Es),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&Qn.pointerLock,Qn.touch&&t?"touch":this.pointerLock?"mouse":Qn.pointer&&!i?"pointer":Qn.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?DS:void 0,!(!Qn.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const s=Tt.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,s},swipe({velocity:r=US,distance:e=OS,duration:t=NS}={}){return{velocity:this.transform(Tt.toVector(r)),distance:this.transform(Tt.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return IS;case!1:return 0;default:return r}},axisThreshold(r){return r?Ut(Ut({},zg),r):zg},keyboardDisplacement(r=FS){return r}});function Gy(r){const[e,t]=r.overflow,[n,i]=r._delta,[s,o]=r._direction;(e<0&&n>0&&s<0||e>0&&n<0&&s>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&o<0||t>0&&i<0&&o>0)&&(r._movement[1]=r._movementBound[1])}const zS=30,BS=100;class GS extends ky{constructor(...e){super(...e),$t(this,"ingKey","pinching"),$t(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=Tt.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*zS-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>n.has(s))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=Ig(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(o=>i.has(o))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const s=Pd(...Array.from(n.values()));s&&this.pinchStart(e,s)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=Ig(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=Pd(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],s=t.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*o]),n.origin=t.origin,n.turns=o,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=Tt.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-Fy(e)[1]/BS*n.offset[0],0],Tt.addTo(n._movement,n._delta),Gy(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const VS=Ut(Ut({},zy),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!Qn.touch&&Qn.gesture)return"gesture";if(Qn.touch&&n)return"touch";if(Qn.touchscreen){if(Qn.pointer)return"pointer";if(Qn.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const a=Ng(gu(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=Ng(gu(n,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",Tt.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});class HS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(To(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const t=To(e),n=this.state;n._delta=Tt.sub(t,n._values),Tt.addTo(n._movement,n._delta),this.computeValues(t),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const WS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r});class XS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const t=this.state,n=_S(e);t._delta=Tt.sub(n,t._values),Tt.addTo(t._movement,t._delta),this.computeValues(n),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const qS=Es;class YS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=Fy(e),Tt.addTo(t._movement,t._delta),Gy(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const jS=Es;class $S extends Ac{constructor(...e){super(...e),$t(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(To(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const t=this.state;if(!t._active)return;t._active=!1;const n=To(e);t._movement=t._delta=Tt.sub(n,t._values),this.computeValues(n),this.compute(e),t.delta=t.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const ZS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r}),Gp=new Map,Ld=new Map;function KS(r){Gp.set(r.key,r.engine),Ld.set(r.key,r.resolver)}const JS={key:"drag",engine:TS,resolver:kS},QS={key:"hover",engine:$S,resolver:ZS},eE={key:"move",engine:HS,resolver:WS},tE={key:"pinch",engine:GS,resolver:VS},nE={key:"scroll",engine:XS,resolver:qS},iE={key:"wheel",engine:YS,resolver:jS};function rE(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s=0)&&(t[i]=r[i]);return t}function sE(r,e){if(r==null)return{};var t=rE(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const oE={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=Qn.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},aE=["target","eventOptions","window","enabled","transform"];function nu(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=nu(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function cE(r,e,t={}){const n=r,{target:i,eventOptions:s,window:o,enabled:a,transform:c}=n,l=sE(n,aE);if(t.shared=nu({target:i,eventOptions:s,window:o,enabled:a,transform:c},oE),e){const u=Ld.get(e);t[e]=nu(Ut({shared:t.shared},l),u)}else for(const u in l){const h=Ld.get(u);h&&(t[u]=nu(Ut({shared:t.shared},l[u]),h))}return t}class Vy{constructor(e,t){$t(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,s){const o=this._listeners,a=pS(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=Ut(Ut({},c),s);e.addEventListener(a,i,l);const u=()=>{e.removeEventListener(a,i,l),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class lE{constructor(){$t(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}let uE=class{constructor(e){$t(this,"gestures",new Set),$t(this,"_targetEventStore",new Vy(this)),$t(this,"gestureEventStores",{}),$t(this,"gestureTimeoutStores",{}),$t(this,"handlers",{}),$t(this,"config",{}),$t(this,"pointerIds",new Set),$t(this,"touchIds",new Set),$t(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),hE(this,e)}setEventIds(e){if(Du(e))return this.touchIds=new Set(vS(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=cE(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],c=Bg(n,a.eventOptions,!!i);if(a.enabled){const l=Gp.get(o);new l(this,e,o).bind(c)}}const s=Bg(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](Ut(Ut({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in n)n[s]=bS(...n[s]);if(!i)return n;for(const s in n){const{device:o,capture:a,passive:c}=dS(s);this._targetEventStore.add(i,o,"",n[s],{capture:a,passive:c})}}}};function Ds(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Vy(r,e),r.gestureTimeoutStores[e]=new lE}function hE(r,e){e.drag&&Ds(r,"drag"),e.wheel&&Ds(r,"wheel"),e.scroll&&Ds(r,"scroll"),e.move&&Ds(r,"move"),e.pinch&&Ds(r,"pinch"),e.hover&&Ds(r,"hover")}const Bg=(r,e,t)=>(n,i,s,o={},a=!1)=>{var c,l;const u=(c=o.capture)!==null&&c!==void 0?c:e.capture,h=(l=o.passive)!==null&&l!==void 0?l:e.passive;let f=a?n:hS(n,i,u);t&&h&&(f+="Passive"),r[f]=r[f]||[],r[f].push(s)},fE=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function dE(r){const e={},t={},n=new Set;for(let i in r)fE.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function Is(r,e,t,n,i,s){if(!r.has(t)||!Gp.has(n))return;const o=t+"Start",a=t+"End",c=l=>{let u;return l.first&&o in e&&e[o](l),t in e&&(u=e[t](l)),l.last&&a in e&&e[a](l),u};i[n]=c,s[n]=s[n]||{}}function pE(r,e){const[t,n,i]=dE(r),s={};return Is(i,t,"onDrag","drag",s,e),Is(i,t,"onWheel","wheel",s,e),Is(i,t,"onScroll","scroll",s,e),Is(i,t,"onPinch","pinch",s,e),Is(i,t,"onMove","move",s,e),Is(i,t,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:n}}function mE(r,e={},t,n){const i=Fh.useMemo(()=>new uE(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),Fh.useEffect(i.effect.bind(i)),Fh.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function gE(r){return r.forEach(KS),function(t,n){const{handlers:i,nativeHandlers:s,config:o}=pE(t,n||{});return mE(i,o,void 0,s)}}function vE(r,e){return gE([JS,tE,nE,iE,eE,QS])(r,e||{})}const Kc=(r,e)=>{const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,c=new Ww;let l=0;if(r.forEach((u,h)=>{let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(u.userData),e){let d;if(u.index)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,d,h),l+=d}}),t){let u=0;const h=[];r.forEach(f=>{const d=f.index;for(let m=0;m{let e,t,n,i=0;if(r.forEach(s=>{if(e===void 0&&(e=s.array.constructor),e!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=s.itemSize),t!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=s.normalized),n!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=s.array.length}),e&&t){const s=new e(i);let o=0;return r.forEach(a=>{s.set(a.array,o),o+=a.array.length}),new Xw(s,t,n)}},zh=new qw,Bh=new _n,Us=new _n,ci=new _n,Gi=new _n,Ti=new _n,Vi=new _n,Hi=new _n,Jo=new _n,Qo=new _n,ea=new _n,Jc=new _n,ta=new _n,na=new _n,ia=new _n;class Vg{constructor(e,t,n){this.camera=e,this.scene=t,this.startPoint=new _n,this.endPoint=new _n,this.collection=[],this.deep=n||Number.MAX_VALUE}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(zh,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Us.copy(e),Us.x=Math.min(e.x,t.x),Us.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),ci.setFromMatrixPosition(this.camera.matrixWorld),Gi.copy(Us),Ti.set(t.x,Us.y,0),Vi.copy(t),Hi.set(Us.x,t.y,0),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),ta.copy(Gi).sub(ci),na.copy(Ti).sub(ci),ia.copy(Vi).sub(ci),ta.normalize(),na.normalize(),ia.normalize(),ta.multiplyScalar(this.deep),na.multiplyScalar(this.deep),ia.multiplyScalar(this.deep),ta.add(ci),na.add(ci),ia.add(ci);var n=zh.planes;n[0].setFromCoplanarPoints(ci,Gi,Ti),n[1].setFromCoplanarPoints(ci,Ti,Vi),n[2].setFromCoplanarPoints(Vi,Hi,ci),n[3].setFromCoplanarPoints(Hi,Gi,ci),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ia,na,ta),n[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),s=Math.max(e.y,t.y),o=Math.max(e.x,t.x),a=Math.min(e.y,t.y);Gi.set(i,s,-1),Ti.set(o,s,-1),Vi.set(o,a,-1),Hi.set(i,a,-1),Jo.set(i,s,1),Qo.set(o,s,1),ea.set(o,a,1),Jc.set(i,a,1),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),Jo.unproject(this.camera),Qo.unproject(this.camera),ea.unproject(this.camera),Jc.unproject(this.camera);var n=zh.planes;n[0].setFromCoplanarPoints(Gi,Jo,Qo),n[1].setFromCoplanarPoints(Ti,Qo,ea),n[2].setFromCoplanarPoints(ea,Jc,Hi),n[3].setFromCoplanarPoints(Jc,Jo,Gi),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ea,Qo,Jo),n[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if((t.isMesh||t.isLine||t.isPoints)&&t.material!==void 0&&(t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),Bh.copy(t.geometry.boundingSphere.center),Bh.applyMatrix4(t.matrixWorld),e.containsPoint(Bh)&&this.collection.push(t)),t.children.length>0)for(let n=0;n0;)de[pe]=arguments[pe+2];var Me=xe[he]||(xe[he]=R.getUniformLocation(ce,he));R["uniform"+$].apply(R,[Me].concat(de))},setAttribute:function($,he,de,pe,Me){var we=fe[$];we||(we=fe[$]={buf:R.createBuffer(),loc:R.getAttribLocation(ce,$),data:null}),R.bindBuffer(R.ARRAY_BUFFER,we.buf),R.vertexAttribPointer(we.loc,he,R.FLOAT,!1,0,0),R.enableVertexAttribArray(we.loc),H?R.vertexAttribDivisor(we.loc,pe):ge("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(we.loc,pe),Me!==we.data&&(R.bufferData(R.ARRAY_BUFFER,Me,de),we.data=Me)}})}}}J[K].transaction(re)},D=function(K,W){ne++;try{R.activeTexture(R.TEXTURE0+ne);var ye=ie[K];ye||(ye=ie[K]=R.createTexture(),R.bindTexture(R.TEXTURE_2D,ye),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,R.NEAREST),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,R.NEAREST)),R.bindTexture(R.TEXTURE_2D,ye),W(ye,ne)}finally{ne--}},Q=function(K,W,ye){var re=R.createFramebuffer();ee.push(re),R.bindFramebuffer(R.FRAMEBUFFER,re),R.activeTexture(R.TEXTURE0+W),R.bindTexture(R.TEXTURE_2D,K),R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,K,0);try{ye(re)}finally{R.deleteFramebuffer(re),R.bindFramebuffer(R.FRAMEBUFFER,ee[--ee.length-1]||null)}},j=function(){Y={},J={},ie={},ne=-1,ee.length=0};var H=typeof WebGL2RenderingContext<"u"&&R instanceof WebGL2RenderingContext,Y={},J={},ie={},ne=-1,ee=[];R.canvas.addEventListener("webglcontextlost",function(K){j(),K.preventDefault()},!1),c.set(R,F={gl:R,isWebGL2:H,getExtension:ge,withProgram:te,withTexture:D,withTextureFramebuffer:Q,handleContextLoss:j})}U(F)}function h(k,U,R,F,H,Y,J,ie){J===void 0&&(J=15),ie===void 0&&(ie=null),u(k,function(ne){var ee=ne.gl,ge=ne.withProgram,me=ne.withTexture;me("copy",function(te,D){ee.texImage2D(ee.TEXTURE_2D,0,ee.RGBA,H,Y,0,ee.RGBA,ee.UNSIGNED_BYTE,U),ge("copy",o,a,function(Q){var j=Q.setUniform,K=Q.setAttribute;K("aUV",2,ee.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),j("1i","image",D),ee.bindFramebuffer(ee.FRAMEBUFFER,ie||null),ee.disable(ee.BLEND),ee.colorMask(J&8,J&4,J&2,J&1),ee.viewport(R,F,H,Y),ee.scissor(R,F,H,Y),ee.drawArrays(ee.TRIANGLES,0,3)})})})}function f(k,U,R){var F=k.width,H=k.height;u(k,function(Y){var J=Y.gl,ie=new Uint8Array(F*H*4);J.readPixels(0,0,F,H,J.RGBA,J.UNSIGNED_BYTE,ie),k.width=U,k.height=R,h(J,ie,0,0,F,H)})}var d=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:f});function m(k,U,R,F,H,Y){Y===void 0&&(Y=1);var J=new Uint8Array(k*U),ie=F[2]-F[0],ne=F[3]-F[1],ee=[];s(R,function(K,W,ye,re){ee.push({x1:K,y1:W,x2:ye,y2:re,minX:Math.min(K,ye),minY:Math.min(W,re),maxX:Math.max(K,ye),maxY:Math.max(W,re)})}),ee.sort(function(K,W){return K.maxX-W.maxX});for(var ge=0;gexe.minX&&W-rexe.minY){var ce=p(K,W,xe.x1,xe.y1,xe.x2,xe.y2);ceW!=fe.y2>W&&K<(fe.x2-fe.x1)*(W-fe.y1)/(fe.y2-fe.y1)+fe.x1;xe&&(ye+=fe.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function v(re,fe){var xe=36,ce=0,Pe=new Map,B=fe&&new Map,I;return re.split(",").forEach(function $(he){if(he.indexOf("+")!==-1)for(var de=+he;de--;)$(I);else{I=he;var pe=he.split(">"),Me=pe[0],we=pe[1];Me=String.fromCodePoint(ce+=parseInt(Me,xe)),we=String.fromCodePoint(ce+=parseInt(we,xe)),Pe.set(Me,we),fe&&B.set(we,Me)}}),{map:Pe,reverseMap:B}}var g,p,_;function y(){if(!g){var re=v(m.pairs,!0),fe=re.map,xe=re.reverseMap;g=fe,p=xe,_=v(m.canonical,!1).map}}function x(re){return y(),g.get(re)||null}function b(re){return y(),p.get(re)||null}function w(re){return y(),_.get(re)||null}var S=n.L,M=n.R,E=n.EN,T=n.ES,L=n.ET,P=n.AN,A=n.CS,z=n.B,V=n.S,N=n.ON,C=n.BN,O=n.NSM,k=n.AL,U=n.LRO,R=n.RLO,F=n.LRE,H=n.RLE,Y=n.PDF,J=n.LRI,ie=n.RLI,ne=n.FSI,ee=n.PDI;function ge(re,fe){for(var xe=125,ce=new Uint32Array(re.length),Pe=0;Pe0)De--;else if(je>0){for(Ve=0;!Le[Le.length-1]._isolate;)Le.pop();var tt=Le[Le.length-1]._isolInitIndex;tt!=null&&(he.set(tt,Z),he.set(Z,tt)),Le.pop(),je--}Ee=Le[Le.length-1],$[Z]=Ee._level,Ee._override&&I(Z,Ee._override)}else Ae&Y?(De===0&&(Ve>0?Ve--:!Ee._isolate&&Le.length>1&&(Le.pop(),Ee=Le[Le.length-1])),$[Z]=Ee._level):Ae&z&&($[Z]=pe.level);else $[Z]=Ee._level,Ee._override&&Ae!==C&&I(Z,Ee._override)}for(var lt=[],ft=null,ut=pe.start;ut<=pe.end;ut++){var xt=ce[ut];if(!(xt&c)){var dt=$[ut],ct=xt&s,Mn=xt===ee;ft&&dt===ft._level?(ft._end=ut,ft._endsWithIsolInit=ct):lt.push(ft={_start:ut,_end:ut,_level:dt,_startsWithPDI:Mn,_endsWithIsolInit:ct})}}for(var fn=[],yt=0;yt=0;se--)if(!(ce[se]&c)){ve=$[se];break}var _e=sn[sn.length-1],Ge=$[_e],We=pe.level;if(!(ce[_e]&s)){for(var qe=_e+1;qe<=pe.end;qe++)if(!(ce[qe]&c)){We=$[qe];break}}fn.push({_seqIndices:sn,_sosType:Math.max(ve,ae)%2?M:S,_eosType:Math.max(We,Ge)%2?M:S})}}for(var Ye=0;Ye=0;at--)if(!(ce[Te[at]]&c)){Ct=ce[Te[at]];break}I(Xn,Ct&(s|ee)?N:Ct)}}if(B.get(E))for(var fr=0;fr=-1;qn--){var Vo=qn===-1?Ze:ce[Te[qn]];if(Vo&o){Vo===k&&I(Wt,P);break}}}if(B.get(k))for(var Bi=0;Bi=0&&(Mi=ce[Te[zr]],!!(Mi&c));zr--);for(var Ho=Xt+1;Ho=0&&ce[Te[Hc]]&(L|c);Hc--)I(Te[Hc],E);for(On++;On=0&&ce[Te[Wc]]&c;Wc--)I(Te[Wc],N);for(var Xc=Wo+1;Xc=0;Yo--){var Rh=Ps[Yo].char;if(Rh===vg||Rh===b(w(qo))||x(w(Rh))===qo){qc.push([Ps[Yo].seqIndex,Ls]),Ps.length=Yo;break}}}qc.sort(function(Tn,ai){return Tn[0]-ai[0]})}for(var Ph=0;Ph=0;Ih--){var wg=Te[Ih];if(ce[wg]&gg){var Sg=ce[wg]&Xo?M:S;Sg!==bt?oi=Sg:oi=bt;break}}}if(oi){if(ce[Te[Yc]]=ce[Te[Lh]]=oi,oi!==bt){for(var jo=Yc+1;jo=0;Zo--)if(ce[Te[Zo]]&c)Eg=Zo;else{Oh=ce[Te[Zo]]&Xo?M:S;break}for(var Mg=At,Ko=dr+1;Ko=0&&f(re[$c])&l;$c--)$[$c]=pe.level}}return{levels:$,paragraphs:de};function Tg(Tn,ai){for(var An=Tn;An=$&&f(re[pe])&l;pe--)de[pe]=I.level;for(var Me=I.level,we=1/0,ue=0;ueMe&&(Me=Ce),Ce=we;ze--)for(var Le=0;Le=ze){for(var Ee=Le;Le+1=ze;)Le++;Le>Ee&&B.push([Ee+$,Le+$])}}}),B}function W(re,fe,xe,ce){var Pe=ye(re,fe,xe,ce),B=[].concat(re);return Pe.forEach(function(I,$){B[$]=(fe.levels[I]&1?Q(re[I]):null)||re[I]}),B.join("")}function ye(re,fe,xe,ce){for(var Pe=K(re,fe,xe,ce),B=[],I=0;I0?` · ${Ho(Ee)} real belegt (inkl. KV)`:""," / ",Ho(le)]}),x.length>0&&g.jsx("button",{onClick:Ve,className:"h-6 px-2.5 rounded border border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/10 text-amber-400 text-[9px] font-bold uppercase transition-all cursor-pointer",children:"Alle entladen"})]})]}),g.jsx("div",{className:"h-7 w-full rounded-xl bg-background/50 border border-border/40 overflow-hidden flex p-0.5 relative group",children:at.length===0?g.jsx("div",{className:"w-full h-full flex items-center justify-center text-[10px] text-muted-foreground/60 italic font-mono select-none",children:"VRAM Leer — Auto-Swap lädt Modelle bei Anfrage"}):at.map((ue,ee)=>{var Fe;const Ae=(ue.size_bytes||0)/le*100,re=["from-teal-500 to-emerald-500","from-indigo-500 to-blue-500","from-purple-500 to-pink-500","from-cyan-500 to-sky-500"][ee%4];return g.jsxs("div",{style:{width:`${Ae}%`},className:nt("h-full rounded bg-gradient-to-r flex items-center justify-between px-2.5 transition-all text-white/95 shrink-0 shadow-inner select-none",re),title:`${ue.name} (${Ho(ue.size_bytes)})`,children:[g.jsxs("span",{className:"text-[9px] font-bold truncate max-w-[120px] font-space tracking-wide",children:[ue.role?`[${ue.role}] `:"",(Fe=ue.name.split("/").pop())==null?void 0:Fe.replace(".gguf","")]}),g.jsx("span",{className:"text-[8px] font-mono opacity-80",children:Ho(ue.size_bytes)})]},ue.name)})})]}),g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-6 shadow-lg shadow-black/10 space-y-4",children:[g.jsxs("div",{children:[g.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"Interactive Gateway Graph"}),g.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 leading-relaxed",children:"Klicke links auf Editoren, um Configs zu kopieren. Klicke rechts auf Rollen, um GGUF-Zuweisungen live zu ändern."})]}),g.jsxs("div",{ref:ge,className:"relative w-full h-96 border border-border/30 rounded-xl bg-black/25 overflow-hidden flex",children:[g.jsxs("svg",{className:"absolute inset-0 pointer-events-none w-full h-full",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"cyan-to-teal",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#06b6d4",stopOpacity:"0.45"}),g.jsx("stop",{offset:"100%",stopColor:"#0d9488",stopOpacity:"0.45"})]}),g.jsxs("linearGradient",{id:"active-glow",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.8"}),g.jsx("stop",{offset:"100%",stopColor:"#10b981",stopOpacity:"0.8"})]})]}),g.jsx("path",{d:we(.1),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="roocode"||w==="roocode")&&g.jsx("path",{d:we(.1),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.3),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="cursor"||w==="cursor")&&g.jsx("path",{d:we(.3),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.5),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="opencode"||w==="opencode")&&g.jsx("path",{d:we(.5),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.7),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="zed"||w==="zed")&&g.jsx("path",{d:we(.7),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.9),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="continue"||w==="continue")&&g.jsx("path",{d:we(.9),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.12),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("fast")&&g.jsx("path",{d:Me(.12),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.31),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("heavy")&&g.jsx("path",{d:Me(.31),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.5),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("coder")&&g.jsx("path",{d:Me(.5),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.69),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("vision")&&g.jsx("path",{d:Me(.69),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.88),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("scout")&&g.jsx("path",{d:Me(.88),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"10%"},onMouseEnter:()=>J("roocode"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="roocode"?null:"roocode"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Roo Code"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"30%"},onMouseEnter:()=>J("cursor"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="cursor"?null:"cursor"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Cursor IDE"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"50%"},onMouseEnter:()=>J("opencode"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="opencode"?null:"opencode"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"OpenCode"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"70%"},onMouseEnter:()=>J("zed"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="zed"?null:"zed"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Zed"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"90%"},onMouseEnter:()=>J("continue"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="continue"?null:"continue"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Continue"})]}),g.jsxs("div",{className:"absolute select-none z-10 w-36 py-3 px-4 -translate-y-1/2 -translate-x-1/2 rounded-2xl border border-primary/50 bg-card/90 backdrop-blur-md flex flex-col items-center justify-center text-center shadow-lg shadow-primary/5",style:{left:"50%",top:"50%"},children:[g.jsx("div",{className:"text-[10px] uppercase font-bold text-primary font-space tracking-wide",children:"Gateway Auto"}),g.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:["Schwelle: > ",i!=null&&i.heavy_threshold_chars?i.heavy_threshold_chars/1e3:"4","k Zeichen"]}),g.jsx("div",{className:"mt-1 px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[9px] font-semibold text-primary uppercase font-mono",children:"Auto-Swap"})]}),ZF.map(ue=>{var Te;const ee=["12%","31%","50%","69%","88%"],Ae=Ce(ue),re=Ae?x.includes(Ae.name):!1;if(ue==="agent")return null;const Fe={fast:0,heavy:1,coder:2,vision:3,scout:4}[ue];return g.jsxs("div",{className:nt("absolute z-10 w-44 py-1.5 px-3 -translate-y-1/2 -translate-x-1/2 rounded-xl border flex flex-col justify-center hover:border-primary/50 transition-all text-left shadow select-none cursor-pointer",re?"border-emerald-500/50 bg-emerald-500/5 shadow-emerald-500/5":Ae?"border-border/60 bg-card/75":"border-dashed border-border/40 bg-background/20"),style:{left:"90%",top:ee[Fe]},onClick:()=>fe(ue),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:ue}),re&&g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),g.jsx("div",{className:"text-[10px] font-mono font-medium truncate mt-0.5 text-foreground max-w-[150px]",children:Ae?(Te=Ae.name.split("/").pop())==null?void 0:Te.replace(".gguf",""):"Keine Zuweisung"})]},ue)}),w&&s&&g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200 flex flex-col justify-between",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("span",{className:"text-xs font-bold uppercase tracking-wider text-primary",children:[w==="roocode"&&"Roo Code Setup",w==="cursor"&&"Cursor Setup",w==="opencode"&&"OpenCode Setup",w==="zed"&&"Zed Setup",w==="continue"&&"Continue Setup"]}),g.jsx("button",{onClick:()=>E(null),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("div",{className:"text-xs text-muted-foreground leading-relaxed space-y-2",children:[w==="roocode"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Suche in VS Code nach der Erweiterung ",g.jsx("strong",{children:"Roo Code"})," und installiere sie."]}),g.jsxs("li",{children:["Wähle in den Roo Code Einstellungen: Provider: ",g.jsx("strong",{children:"OpenAI Compatible"}),"."]}),g.jsxs("li",{children:["Füge das untenstehende JSON-Snippet in die ",g.jsx("code",{children:"settings.json"})," ein."]})]}),w==="cursor"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne Cursor Settings ➔ ",g.jsx("strong",{children:"Models"}),"."]}),g.jsxs("li",{children:["Deaktiviere Cloud-Modelle, klappe ",g.jsx("strong",{children:"OpenAI API"})," auf."]}),g.jsxs("li",{children:["Trage die Base URL unten ein und aktiviere das Modell ",g.jsx("strong",{children:"auto"}),"."]})]}),w==="opencode"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne die ",g.jsx("code",{children:"opencode.jsonc"})," Konfigurationsdatei."]}),g.jsxs("li",{children:["Ersetze den Provider-Eintrag unter ",g.jsx("code",{children:"provider"})," mit dem Snippet unten."]})]}),w==="zed"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne die Zed Settings (",g.jsx("code",{children:"ctrl+,"}),")."]}),g.jsxs("li",{children:["Füge das untenstehende JSON-Segment unter ",g.jsx("code",{children:"language_models"})," ein."]})]}),w==="continue"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsx("li",{children:"Klicke auf das Zahnrad-Symbol in der Continue-Erweiterung."}),g.jsxs("li",{children:["Füge den Gateway-Eintrag zum ",g.jsx("code",{children:"models"}),"-Array hinzu."]})]})]}),s.tools&&g.jsxs("div",{className:"relative rounded-xl border border-border/40 bg-black/40 overflow-hidden mt-1 shrink-0",children:[g.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/20 bg-black/20",children:[g.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:"JSON Config"}),g.jsxs("button",{onClick:()=>{var ue,ee,Ae,re,Fe;return xt(w==="roocode"?(ue=s.tools.cline)==null?void 0:ue.snippet:w==="cursor"?(ee=s.tools.cursor)==null?void 0:ee.snippet:w==="opencode"?(Ae=s.tools.opencode)==null?void 0:Ae.snippet:w==="zed"?(re=s.tools.zed)==null?void 0:re.snippet:(Fe=s.tools.continue)==null?void 0:Fe.snippet)},className:"text-xs font-semibold text-primary hover:text-primary-foreground flex items-center gap-1 cursor-pointer",children:[U?g.jsx(bo,{className:"h-3.5 w-3.5 text-emerald-400"}):g.jsx(ew,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:U?"Kopiert":"Kopieren"})]})]}),g.jsx("pre",{className:"p-3 max-h-48 overflow-y-auto text-xs font-mono text-cyan-200/90 whitespace-pre scrollbar-thin select-text",children:g.jsxs("code",{children:[w==="roocode"&&((qe=s.tools.cline)==null?void 0:qe.snippet),w==="cursor"&&((dt=s.tools.cursor)==null?void 0:dt.snippet),w==="opencode"&&((Dt=s.tools.opencode)==null?void 0:Dt.snippet),w==="zed"&&((jt=s.tools.zed)==null?void 0:jt.snippet),w==="continue"&&((pt=s.tools.continue)==null?void 0:pt.snippet)]})})]}),g.jsx("button",{onClick:()=>E(null),className:"w-full h-9 rounded-lg bg-primary text-primary-foreground hover:opacity-90 font-semibold text-xs transition-opacity cursor-pointer mt-2",children:"Schließen"})]})})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-6 mt-3 text-[10px] text-muted-foreground border-t border-border/20 pt-3",children:[g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded-full bg-cyan-400"}),g.jsx("span",{children:"Cyan-Fluss: Client-Anfrage an Gateway"})]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500 animate-pulse"}),g.jsx("span",{children:"Grüner Puls: Aktive Verbindung / Warmes Modell geladen"})]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded bg-gradient-to-r from-teal-500 to-emerald-500"}),g.jsx("span",{children:"VRAM-Verlauf: Modellspezifischer Speicheranteil"})]})]})]}),g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-3.5",children:[g.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground px-1",children:"Gateway Steckplatz-Belegung (Slot-Zuweisung)"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:["fast","heavy","coder","vision","scout"].map(ue=>{var re;const ee=y.find(Fe=>Fe.role===ue),Ae=ee?x.includes(ee.name):!1;return g.jsxs("div",{onClick:()=>fe(ue),className:nt("rounded-xl border p-3 flex flex-col justify-between gap-2.5 transition-all cursor-pointer select-none text-left bg-background/25 hover:border-primary/45 hover:bg-background/40 group min-h-[90px]",Ae?"border-emerald-500/40 shadow-sm shadow-emerald-500/5":ee?"border-primary/20 bg-primary/5":"border-border/30 border-dashed opacity-75"),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:nt("text-[9px] font-bold uppercase tracking-wider font-mono px-1.5 py-0.5 rounded border",PP(ue)),children:ue}),Ae&&g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),g.jsx("div",{className:"text-[10px] font-mono font-medium truncate text-foreground/90 pr-1 font-space",title:ee==null?void 0:ee.name,children:ee?(re=ee.name.split("/").pop())==null?void 0:re.replace(/\.gguf$/i,""):"nicht zugewiesen"}),g.jsx("div",{className:"text-[8px] text-primary/70 group-hover:text-primary font-bold uppercase tracking-wider transition-colors font-space",children:"Ändern ➔"})]},ue)})})]}),(a==null?void 0:a.current)&&g.jsxs("div",{className:"rounded-2xl border border-indigo-500/30 bg-indigo-500/5 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-3.5",children:[g.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(qc,{className:"h-4.5 w-4.5 text-indigo-400"}),g.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"Agent-Hirn (Hermes)"}),a.current.version!=null&&g.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-indigo-500/15 text-indigo-300 border border-indigo-500/25",children:["v",a.current.version]})]}),g.jsx("button",{onClick:()=>O(!0),className:"h-7 px-3 rounded-lg border border-indigo-500/30 bg-indigo-500/5 text-indigo-300 text-[9px] font-bold uppercase hover:bg-indigo-500/15 transition-all cursor-pointer",children:"Hirn wechseln"})]}),g.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl bg-background/30 border border-border/30 p-3.5",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:a.current.name,children:a.current.name.split("/").pop()}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 mt-0.5",children:[g.jsx("span",{children:a.current.params_b?`${a.current.params_b}B`:"—"}),g.jsx("span",{children:"•"}),g.jsx("span",{children:a.current.quant||"GGUF"}),g.jsx("span",{children:"•"}),g.jsx("span",{children:Ho(a.current.size_bytes||0)})]})]}),a.update_available&&a.recommended?g.jsxs("button",{onClick:()=>We(a.recommended.repo),className:nt("h-8 px-3 shrink-0 flex items-center justify-center gap-1.5 rounded-lg text-[10px] font-bold uppercase transition-all cursor-pointer shadow-md",a.budget&&!a.budget.fits?"bg-red-500 text-white hover:bg-red-400 shadow-red-500/10":"bg-amber-500 text-black hover:bg-amber-400 shadow-amber-500/10"),children:[g.jsx(vg,{className:"h-3.5 w-3.5"})," Aktualisieren"]}):g.jsxs("span",{className:"h-8 px-3 shrink-0 flex items-center gap-1.5 text-[10px] font-bold text-emerald-400 uppercase tracking-wide bg-emerald-500/5 border border-emerald-500/15 rounded-lg select-none",children:[g.jsx(bo,{className:"h-4 w-4"})," Neueste Generation"]})]}),a.update_available&&a.recommended&&g.jsxs("div",{className:"text-[10px] text-amber-400/90 flex items-center gap-1.5",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping shrink-0"}),"Neuere Generation verfügbar: ",g.jsx("span",{className:"font-mono font-bold",children:a.recommended.name.replace(/-GGUF$/i,"")}),"(v",a.recommended.version,", ",a.recommended.params_b,"B) — von NousResearch."]}),a.budget&&g.jsxs("div",{className:nt("text-[10px] flex items-start gap-1.5 leading-relaxed",a.budget.fits?"text-muted-foreground/80":"text-red-400 font-semibold"),children:[g.jsx(nE,{className:"h-3 w-3 shrink-0 mt-0.5"}),g.jsxs("span",{children:["Always-On-Brain ~",a.budget.brain_gb," GB + größtes on-demand (~",a.budget.largest_ondemand_gb," GB) = ",(a.budget.brain_gb+a.budget.largest_ondemand_gb).toFixed(1)," / ",a.budget.gtt_gb," GB",a.budget.fits?" · passt gleichzeitig ✓":" · passt NICHT gleichzeitig ⚠ — heavy/coder würden das Brain verdrängen. Kleineres Brain oder weniger Kontext."]})]})]}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 px-1",children:[g.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:["Installierte Modell-Bibliothek (",K.length," von ",y.length,")"]}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("div",{className:"flex rounded-lg border border-border/40 bg-card/45 p-0.5",children:[g.jsx("button",{onClick:()=>B("all"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",he==="all"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Vorhanden"}),g.jsx("button",{onClick:()=>B("in_use"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",he==="in_use"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"In Benutzung"})]}),g.jsxs("div",{className:"flex rounded-lg border border-border/40 bg-card/45 p-0.5",children:[g.jsx("button",{onClick:()=>oe("grid"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",de==="grid"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Grid"}),g.jsx("button",{onClick:()=>oe("list"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",de==="list"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"List"})]})]})]}),de==="grid"?g.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:K.length===0?g.jsx("div",{className:"col-span-full text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center select-none",children:he==="in_use"?"Keine Modelle in Benutzung (keine Zuweisung oder warm geladene Modelle).":'Keine Modelle konfiguriert. Verwende den Tab "Modelle finden" zum Herunterladen.'}):K.map(ue=>{const ee=x.includes(ue.name),Ae=o==null?void 0:o.model_list.find(Fe=>Fe.role===ue.role),re=CI(ue.name);return g.jsxs("div",{className:nt("rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-4 transition-all duration-300 hover:border-primary/40 group relative overflow-hidden",ee?"border-primary/45 shadow-primary/5":ue.role?"border-primary/30 bg-primary/5 shadow-inner":"border-border/60"),children:[g.jsxs("div",{className:"space-y-3",children:[g.jsx("div",{className:"flex items-start justify-between gap-3",children:g.jsxs("div",{className:"flex gap-2.5 min-w-0",children:[g.jsx("div",{className:nt("w-7 h-7 rounded-lg border flex items-center justify-center font-bold text-xs shrink-0 shadow-sm",re.color),title:re.name,children:re.initial}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("h3",{className:"text-xs font-bold tracking-tight text-foreground line-clamp-2 break-all font-mono",title:ue.name,children:ue.name.split("/").pop()}),g.jsxs("div",{className:"flex items-center gap-2 flex-wrap mt-1",children:[g.jsx("span",{className:"text-[9px] font-mono text-muted-foreground bg-background/40 px-1.5 py-0.5 rounded border border-border/30",children:ue.quant||"GGUF"}),ee&&g.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-semibold text-emerald-400 uppercase tracking-wider",children:[g.jsx(i0,{className:"h-3 w-3 animate-pulse"})," Warm"]}),ue.role&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[9px] font-mono text-primary font-bold uppercase",children:ue.role}),ue.prompt_cache&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/10 border border-cyan-500/20 text-[9px] font-mono text-cyan-400 font-bold uppercase",title:"Prompt Caching aktiv",children:"PC"}),ue.spec_active?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20 text-[9px] font-mono text-emerald-400 font-bold uppercase",title:`Speculative Decoding aktiv (Draft: ${ue.spec_draft_model})`,children:"SPEC"}):ue.spec_draft_model?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[9px] font-mono text-amber-400 font-bold uppercase",title:`Draft gesetzt (${ue.spec_draft_model}), aber INAKTIV — --spec-type fehlt oder Vocab inkompatibel. Über 'Spec' neu konfigurieren.`,children:"SPEC?"}):null,ue.parallel_slots>1&&g.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-violet-500/10 border border-violet-500/20 text-[9px] font-mono text-violet-400 font-bold uppercase",title:`${ue.parallel_slots} parallele Slots aktiv`,children:["SLOTS: ",ue.parallel_slots]}),ue.incomplete&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[9px] font-mono text-amber-400 font-bold uppercase",title:"GGUF-Datei fehlt — Modell kann nicht geladen werden",children:"⚠ Datei fehlt"})]})]})]})}),g.jsx("div",{className:"border-t border-border/30 pt-3 flex flex-wrap gap-1",children:g.jsx(I3,{caps:ue.capabilities})})]}),g.jsxs("div",{className:"space-y-3 pt-1",children:[g.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px] font-mono text-muted-foreground",children:[g.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20",children:[g.jsx(nE,{className:"h-3.5 w-3.5 text-primary/80"}),g.jsxs("div",{children:[g.jsx("div",{className:"text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60",children:"Größe"}),g.jsx("div",{className:"text-foreground font-semibold",children:Ho(ue.size_bytes)})]})]}),g.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20",children:[g.jsx(Y8,{className:"h-3.5 w-3.5 text-primary/80"}),g.jsxs("div",{children:[g.jsx("div",{className:"text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60",children:"Kontext"}),g.jsx("div",{className:"text-foreground font-semibold",children:EI(ue.ctx)})]})]})]}),Ae&&g.jsxs("div",{className:"p-3 bg-amber-500/5 border border-amber-500/30 rounded-xl space-y-2 flex flex-col justify-between shrink-0",children:[g.jsxs("div",{className:"text-[9px] font-semibold text-amber-400 flex items-center gap-1",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping"}),g.jsxs("span",{children:["Upgrade verfügbar: ",Ae.repo.split("/").pop()]})]}),g.jsxs("button",{onClick:()=>je(Ae.repo,ue.role,ue.quant||"Q4_K_M",ue.capabilities.tools!=="no"),className:"h-7 w-full flex items-center justify-center gap-1 rounded-lg bg-amber-500 text-black text-[10px] font-bold hover:bg-amber-400 transition-colors cursor-pointer",children:[g.jsx(vg,{className:"h-3 w-3"})," Smart-Swap starten"]})]}),g.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/20 pt-3 mt-auto",children:[g.jsx("button",{onClick:()=>ee?Se(ue.name):$e(ue.name),disabled:ue.incomplete&&!ee,className:nt("flex-1 h-7 rounded-lg text-[9px] font-bold uppercase transition-all border flex items-center justify-center gap-1",ue.incomplete&&!ee?"border-border/30 bg-background/10 text-muted-foreground/50 cursor-not-allowed":ee?"border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/15 text-amber-400 cursor-pointer":"border-primary/30 bg-primary/5 hover:bg-primary/15 text-primary cursor-pointer"),children:ee?"Entladen":"Laden"}),g.jsx("button",{onClick:()=>Q(ue.name,ue.ctx),className:"h-7 px-2.5 rounded-lg border border-border/40 text-[9px] font-bold uppercase hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:"Kontextlänge anpassen",children:"Ctx"}),g.jsxs("button",{onClick:()=>F(ue),className:nt("h-7 px-2.5 rounded-lg border text-[9px] font-bold uppercase transition-colors cursor-pointer flex items-center gap-1",ue.spec_active?"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10":ue.spec_draft_model?"border-amber-500/30 text-amber-400 hover:bg-amber-500/10":"border-border/40 text-muted-foreground hover:bg-accent"),title:"Speculative Draft konfigurieren (Vocab-geprüft)",children:[g.jsx(xh,{className:"h-3 w-3"})," Spec"]}),g.jsx("button",{onClick:()=>Ge(ue.name),className:"h-7 w-7 rounded-lg border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 flex items-center justify-center transition-colors cursor-pointer",title:"Modell löschen",children:g.jsx(kT,{className:"h-3.5 w-3.5"})})]})]})]},ue.name)})}):g.jsx("div",{className:"space-y-2",children:K.length===0?g.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center select-none",children:he==="in_use"?"Keine Modelle in Benutzung (keine Zuweisung oder warm geladene Modelle).":'Keine Modelle konfiguriert. Verwende den Tab "Modelle finden" zum Herunterladen.'}):K.map(ue=>{const ee=x.includes(ue.name),Ae=CI(ue.name);return g.jsxs("div",{className:nt("rounded-xl border bg-card/45 backdrop-blur-md p-3.5 shadow-lg shadow-black/5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:border-primary/40 transition-all",ee?"border-primary/45":ue.role?"border-primary/30 bg-primary/5":"border-border/60"),children:[g.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[g.jsx("div",{className:nt("w-8 h-8 rounded-lg border border-border/40 flex items-center justify-center font-bold text-xs shrink-0 shadow-sm",Ae.color),title:Ae.name,children:Ae.initial}),g.jsxs("div",{className:"min-w-0 text-left",children:[g.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[g.jsx("h4",{className:"text-xs font-bold text-foreground truncate max-w-[250px] sm:max-w-[400px] break-all font-mono",title:ue.name,children:ue.name.split("/").pop()}),ue.role&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[8px] font-mono text-primary font-bold uppercase shrink-0",children:ue.role}),ue.prompt_cache&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/10 border border-cyan-500/20 text-[8px] font-mono text-cyan-400 font-bold uppercase shrink-0",title:"Prompt Caching aktiv",children:"PC"}),ue.spec_active?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20 text-[8px] font-mono text-emerald-400 font-bold uppercase shrink-0",title:`Speculative Decoding aktiv (Draft: ${ue.spec_draft_model})`,children:"SPEC"}):ue.spec_draft_model?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[8px] font-mono text-amber-400 font-bold uppercase shrink-0",title:`Draft gesetzt (${ue.spec_draft_model}), aber INAKTIV — --spec-type fehlt oder Vocab inkompatibel.`,children:"SPEC?"}):null,ue.parallel_slots>1&&g.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-violet-500/10 border border-violet-500/20 text-[8px] font-mono text-violet-400 font-bold uppercase shrink-0",title:`${ue.parallel_slots} parallele Slots aktiv`,children:["SLOTS: ",ue.parallel_slots]}),ue.incomplete&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[8px] font-mono text-amber-400 font-bold uppercase shrink-0",title:"GGUF-Datei fehlt",children:"⚠ Datei fehlt"}),ee&&g.jsxs("span",{className:"flex items-center gap-0.5 text-[8px] font-semibold text-emerald-400 uppercase tracking-wider shrink-0",children:[g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"})," warm"]})]}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 mt-0.5",children:[g.jsxs("span",{children:["Größe: ",Ho(ue.size_bytes)]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Kontext: ",EI(ue.ctx)]}),g.jsx("span",{children:"•"}),g.jsx("span",{className:"font-mono text-[9px]",children:ue.quant||"GGUF"})]})]})]}),g.jsxs("div",{className:"flex items-center gap-3 shrink-0 self-end sm:self-auto",children:[g.jsx("div",{className:"hidden lg:flex flex-wrap gap-1",children:g.jsx(I3,{caps:ue.capabilities})}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("button",{onClick:()=>ee?Se(ue.name):$e(ue.name),disabled:ue.incomplete&&!ee,className:nt("h-7 px-3 rounded-lg text-[9px] font-bold uppercase transition-all border flex items-center gap-1",ue.incomplete&&!ee?"border-border/30 bg-background/10 text-muted-foreground/50 cursor-not-allowed":ee?"border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/15 text-amber-400 cursor-pointer":"border-primary/30 bg-primary/5 hover:bg-primary/15 text-primary cursor-pointer"),children:ee?"Entladen":"Laden"}),g.jsx("button",{onClick:()=>Q(ue.name,ue.ctx),className:"h-7 px-2.5 rounded-lg border border-border/40 text-[9px] font-bold uppercase hover:bg-accent text-muted-foreground transition-all cursor-pointer",title:"Kontextlänge anpassen",children:"Ctx"}),g.jsxs("button",{onClick:()=>F(ue),className:nt("h-7 px-2.5 rounded-lg border text-[9px] font-bold uppercase transition-all cursor-pointer flex items-center gap-1",ue.spec_active?"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10":ue.spec_draft_model?"border-amber-500/30 text-amber-400 hover:bg-amber-500/10":"border-border/40 text-muted-foreground hover:bg-accent"),title:"Speculative Draft konfigurieren (Vocab-geprüft)",children:[g.jsx(xh,{className:"h-3 w-3"})," Spec"]}),g.jsx("button",{onClick:()=>Ge(ue.name),className:"h-7 w-7 rounded-lg flex items-center justify-center border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 transition-all cursor-pointer",title:"Modell löschen",children:g.jsx(kT,{className:"h-3.5 w-3.5"})})]})]})]},ue.name)})})]}),T&&(()=>{var Fe,Te;const ue=k&&k.role===T?k:null,ee={};ue==null||ue.models.forEach(Le=>{ee[Le.name]=Le});const Ae=ue?ue.models.map(Le=>y.find(Ke=>Ke.name===Le.name)).filter(Boolean):y,re=Le=>{Xe(T,Le),C(null)};return g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary",children:["Rolle '",T,"' konfigurieren"]}),g.jsx("button",{onClick:()=>C(null),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("p",{className:"text-xs text-muted-foreground",children:["Wähle ein Modell für die Rolle ",g.jsx("strong",{className:"text-foreground",children:T}),":"]}),(ue==null?void 0:ue.recommended)&&g.jsxs("button",{onClick:()=>re(ue.recommended),title:(Fe=ee[ue.recommended])==null?void 0:Fe.reason,className:"shrink-0 h-7 px-3 text-[11px] font-semibold text-primary border border-primary/50 bg-primary/10 hover:bg-primary/20 rounded-lg cursor-pointer flex items-center gap-1",children:[g.jsx(xh,{className:"h-3 w-3"})," Auto: ",(Te=ue.recommended.split("/").pop())==null?void 0:Te.replace(/\.gguf$/i,"")]})]}),g.jsxs("div",{className:"space-y-1.5 max-h-60 overflow-y-auto pr-1",children:[g.jsx("button",{onClick:()=>re(""),className:"w-full text-left px-3 py-2 rounded-lg text-xs hover:bg-accent text-red-400 font-semibold cursor-pointer border border-red-500/20 bg-red-500/5 flex items-center justify-between",children:g.jsx("span",{children:"Zuweisung entfernen"})}),Ae.map(Le=>{var Cn;const Ke=ee[Le.name],ut=Le.role===T,Kt=!!(Ke!=null&&Ke.recommended),un=!!Ke&&!Ke.suitable;return g.jsxs("button",{onClick:()=>re(Le.name),className:nt("w-full text-left px-3 py-2.5 rounded-lg text-xs hover:bg-accent flex items-center justify-between font-mono cursor-pointer border",Kt?"border-primary/50 bg-primary/10":ut?"text-primary font-bold bg-primary/5 border-primary/30":un?"border-border/20 bg-background/10 opacity-60":"text-foreground bg-background/20 border-border/30"),children:[g.jsxs("div",{className:"flex flex-col text-left min-w-0",children:[g.jsxs("span",{className:"truncate max-w-[260px] font-semibold flex items-center gap-1.5",children:[(Cn=Le.name.split("/").pop())==null?void 0:Cn.replace(/\.gguf$/i,""),Kt&&g.jsx("span",{className:"text-[8px] font-bold uppercase tracking-wide text-primary bg-primary/15 px-1.5 py-0.5 rounded",children:"Empfohlen"})]}),g.jsx("span",{className:"text-[9px] text-muted-foreground mt-0.5",children:Ke?`${Ke.params_b}B · ${Le.quant} · ${Ke.reason}`:`${Ho(Le.size_bytes)} · ${Le.quant}`})]}),ut&&g.jsx(bo,{className:"h-4 w-4 shrink-0 text-primary"})]},Le.name)})]})]})})})(),D&&g.jsx(Lfe,{model:D,onClose:()=>F(null),onChanged:_}),V&&g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-1.5",children:[g.jsx(qc,{className:"h-4 w-4"})," Agent-Hirn wechseln"]}),g.jsx("button",{onClick:()=>O(!1),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:["Wähle ein ",g.jsx("strong",{className:"text-foreground",children:"installiertes"})," Modell als Agent-Hirn. Es bekommt den",g.jsx("code",{className:"text-primary",children:" hermes"}),'-Alias, wird warm gehalten (brains-Gruppe), und Hermes nutzt es nach einem kurzen Gateway-Restart. Neues Modell (z.B. Hermes-4.3 oder Gemma-4)? Erst über „Modelle finden" laden.']}),g.jsx("div",{className:"space-y-1.5 max-h-72 overflow-y-auto pr-1",children:y.map(ue=>{var Ae;const ee=ue.role==="hermes";return g.jsxs("button",{onClick:()=>!ee&&Qe(ue.name),disabled:ee||ue.incomplete,className:nt("w-full text-left px-3 py-2.5 rounded-lg text-xs flex items-center justify-between font-mono border transition-all",ee?"border-indigo-500/40 bg-indigo-500/10 text-indigo-300":ue.incomplete?"border-border/20 bg-background/10 text-muted-foreground/50 cursor-not-allowed":"border-border/30 bg-background/20 text-foreground hover:bg-accent cursor-pointer"),children:[g.jsxs("div",{className:"flex flex-col min-w-0",children:[g.jsx("span",{className:"font-semibold truncate max-w-[280px]",children:(Ae=ue.name.split("/").pop())==null?void 0:Ae.replace(/\.gguf$/i,"")}),g.jsxs("span",{className:"text-[9px] text-muted-foreground mt-0.5",children:[ue.capabilities.params_b?`${ue.capabilities.params_b}B`:"?"," · ",Ho(ue.size_bytes),ue.role&&` · Rolle: ${ue.role}`,ue.capabilities.tools!=="no"?" · Tools ✓":" · ohne Tools"]})]}),ee?g.jsxs("span",{className:"text-[9px] font-bold uppercase text-indigo-300 shrink-0 flex items-center gap-1",children:[g.jsx(bo,{className:"h-3.5 w-3.5"})," Aktiv"]}):g.jsx("span",{className:"text-[9px] font-bold uppercase text-primary/70 shrink-0",children:"Als Hirn setzen →"})]},ue.name)})}),g.jsxs("div",{className:"text-[10px] text-amber-400/80 flex items-start gap-1.5 border-t border-border/20 pt-2.5",children:[g.jsx("span",{children:"💡"}),g.jsxs("span",{children:["Für einen ",g.jsx("strong",{children:"Agenten"})," sind Hermes-Modelle (natives Tool-Calling) meist die robustere Wahl als allgemeine Modelle."]})]})]})}),m]})}function jfe(){const[t,e]=R.useState(""),[n,r]=R.useState([]),[i,s]=R.useState("Q4_K_M"),[o,a]=R.useState(""),[l,c]=R.useState(""),[d,f]=R.useState(""),[m,y]=R.useState([]),[x,S]=R.useState(null),[_,w]=R.useState(!1),E=["fast","heavy","coder","vision","scout"],{data:T}=qh(),C=l?T==null?void 0:T.models.find(H=>(H.role||"").toLowerCase()===l):void 0;async function k(H,ne,J){if(w(!1),!H.trim()){S(null);return}try{const de=await Ut(`/api/fit?params_b=0&quant=${encodeURIComponent(ne)}&ctx=8192&name=${encodeURIComponent(H)}&role=${encodeURIComponent(J)}`);S(de)}catch{S(null)}}async function N(H){const ne=H??t;if(ne.trim()){a("Analysiere HuggingFace Repository..."),S(null);try{const J=await Ut(`/api/hf/quants?repo=${encodeURIComponent(ne)}`);e(J.repo),r(J.quants);const de=J.quants.length?J.quants.includes("Q4_K_M")?"Q4_K_M":J.quants[0]:i;J.quants.length&&s(de),a(J.quants.length?"":"Keine GGUF-Dateien in diesem Repository gefunden."),J.quants.length&&k(J.repo,de,l)}catch(J){a(`Fehler: ${J}`)}}}function D(H){s(H),k(t,H,l)}function F(H){c(H),n.length&&k(t,i,H)}async function V(){if(d.trim()){a("Durchsuche HuggingFace...");try{const H=await Ut(`/api/hf/search?q=${encodeURIComponent(d)}`);y(H.results),a(H.results.length?"":"Keine Ergebnisse gefunden.")}catch(H){a(`Suche fehlgeschlagen: ${H}`)}}}async function O(){if(t.trim()){if((x==null?void 0:x.fit.level)==="too_tight"&&!_){w(!0);return}a("Download-Job wird initiiert...");try{await Ut("/api/models/install",{method:"POST",body:JSON.stringify({repo:t,quant:i,role:l||void 0,jinja:!0})}),w(!1),a(`Download gestartet: ${t} (${i})${l?`, Rolle: ${l}`:""}. Fortschritt oben.`+(C?` „${l}" wurde von ${C.name} übernommen.`:"")+(l==="fast"||l==="coder"?" Speculative Draft (Vocab-geprüft) kannst du nach dem Download an der Modellkarte (»Spec«) setzen.":""))}catch(H){a(`Download-Fehler: ${H}`)}}}const U=(x==null?void 0:x.fit.level)==="perfect"?"text-emerald-400 border-emerald-500/40 bg-emerald-500/10":(x==null?void 0:x.fit.level)==="marginal"?"text-amber-400 border-amber-500/40 bg-amber-500/10":"text-red-400 border-red-500/40 bg-red-500/10";return g.jsxs("div",{className:"space-y-4 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10",children:[g.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"HF Download & Suche"}),g.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[g.jsx("input",{value:t,onChange:H=>{e(H.target.value),S(null),w(!1)},placeholder:"HF-URL oder org/repo (z.B. unsloth/Qwen2.5-Coder-7B-Instruct-GGUF)",className:"flex-1 h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx("button",{onClick:()=>N(),className:"h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer whitespace-nowrap",children:"Quants laden"}),n.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("select",{value:i,onChange:H=>D(H.target.value),className:"h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none text-foreground font-semibold",children:n.map(H=>g.jsx("option",{value:H,className:"bg-popover text-foreground",children:H},H))}),g.jsxs("select",{value:l,onChange:H=>F(H.target.value),title:"Rolle (optional) — bestimmt Auto-Konfiguration + setup-bewussten Kontext",className:"h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none text-foreground font-semibold",children:[g.jsx("option",{value:"",className:"bg-popover text-foreground",children:"Rolle…"}),E.map(H=>g.jsx("option",{value:H,className:"bg-popover text-foreground",children:H},H))]}),g.jsx("button",{onClick:O,className:`h-9 px-4 rounded-lg text-xs font-semibold transition-all cursor-pointer flex items-center gap-1.5 ${_?"bg-red-500 text-white hover:opacity-90":"bg-primary text-primary-foreground hover:opacity-90"}`,children:_?g.jsxs(g.Fragment,{children:[g.jsx(xg,{className:"h-3.5 w-3.5"})," OOM-Risiko — trotzdem laden"]}):g.jsxs(g.Fragment,{children:[g.jsx(vg,{className:"h-3.5 w-3.5"})," Herunterladen"]})})]})]})]}),x&&g.jsxs("div",{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border px-3 py-2 text-[11px] font-medium ${U}`,children:[g.jsx("span",{className:"font-bold uppercase tracking-wide",children:x.fit.text}),g.jsxs("span",{className:"font-mono opacity-90",children:["~",x.params_b,"B · ~",x.fit.req_gb," GB / ",x.sys_ram_gb," GB RAM · ~",x.fit.tps," t/s"]}),x.fit.level!=="too_tight"&&g.jsxs("span",{className:"font-mono opacity-80",title:`Setup-bewusst: GTT ${x.budget.gtt_gb} GB − reserviert ${x.budget.reserved_gb} GB (${x.budget.mode}) → ${x.budget.budget_gb} GB frei`,children:["ctx → ",(x.assigned_ctx/1024).toFixed(0),"k"]}),x.fit.level==="too_tight"&&g.jsx("span",{className:"opacity-90",children:"— passt nicht in den Speicher, würde beim Laden abstürzen (OOM)."})]}),C&&g.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] font-medium text-amber-400",children:[g.jsx(xg,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),g.jsxs("span",{children:["Rolle ",g.jsxs("strong",{children:["„",l,'"']})," ist aktuell ",g.jsx("strong",{children:C.name})," zugewiesen. Beim Download übernimmt das neue Modell diese Rolle — ",C.name," bleibt installiert, verliert sie aber."]})]}),g.jsxs("div",{className:"flex gap-2 border-t border-border/20 pt-4",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx("input",{value:d,onChange:H=>f(H.target.value),onKeyDown:H=>H.key==="Enter"&&V(),placeholder:"HuggingFace durchsuchen (z.B. Llama-3.1)...",className:"w-full h-9 pl-9 pr-3 rounded-lg border border-border/60 bg-background/40 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"}),g.jsx(xP,{className:"absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground"})]}),g.jsx("button",{onClick:V,className:"h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer",children:"Suchen"})]}),m.length>0&&g.jsx("div",{className:"max-h-48 space-y-1.5 overflow-y-auto border border-border/40 bg-background/20 p-2 rounded-xl scrollbar-thin",children:m.map(H=>g.jsxs("button",{onClick:()=>{e(H.repo),y([]),f(""),N(H.repo)},className:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-xs bg-background/10 border border-border/10 hover:border-primary/30 hover:bg-background/30 transition-all",children:[g.jsx("span",{className:"font-semibold truncate",children:H.repo}),g.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex items-center gap-1 shrink-0",children:[g.jsx(vg,{className:"h-3 w-3"})," ",H.downloads.toLocaleString()]})]},H.repo))}),o&&g.jsx("div",{className:"text-[10px] font-medium text-primary font-mono",children:o})]})}const Ufe={fast:{title:"Schnelles Alltags-Hirn",desc:"Schnelle MoE-Antworten für Chat, Zusammenfassungen und alltägliche Aufgaben.",icon:xh},heavy:{title:"Schweres Reasoning",desc:"Große Modelle für komplexe Logik, Mathematik und tiefgründiges Planen.",icon:V1},coder:{title:"Coden & Entwicklung",desc:"Autovervollständigung, Refactoring und Codegenerierung direkt in deiner IDE.",icon:sF},vision:{title:"Bilder & Vision",desc:"Verarbeitet Bilder, Screenshots und visuelle Diagramme in multimodalen Chats.",icon:RT},scout:{title:"Multimodal-Allrounder",desc:"Multimodaler Allrounder für schnelle Antworten, Übersetzungen und Alltag.",icon:PT}};function Ffe(){const{data:t,isLoading:e,error:n}=_7(),{data:r}=qh(),{data:i}=TP(),s=(r==null?void 0:r.models)??[],o=n?String(n):"",[a,l]=R.useState({}),[c,d]=R.useState({}),[f,m]=R.useState(!1);async function y(x,S,_,w){l(E=>({...E,[x]:"Starte..."}));try{await Ut("/api/models/install",{method:"POST",body:JSON.stringify({repo:x,role:S,quant:_,jinja:w})}),l(E=>({...E,[x]:"Download läuft"}))}catch{l(T=>({...T,[x]:"Fehler"}))}}return e?g.jsx("div",{className:"text-xs text-muted-foreground py-12 text-center",children:"Analysiere Hardware und suche passende GGUF-Empfehlungen…"}):o||!t?g.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Empfehlungsdienst temporär nicht erreichbar (",o,")."]}):g.jsxs("div",{className:"space-y-8",children:[g.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground bg-background/25 border border-border/40 p-4 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-sm",children:[g.jsxs("div",{children:["Modell-Registry geladen für ",g.jsxs("span",{className:"text-foreground font-bold",children:[t.sys_ram_gb," GB"]})," System-RAM."]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(i9,{className:"h-3.5 w-3.5 text-primary fill-primary/20"}),g.jsx("span",{children:"Empfehlungen sind automatisch auf deine Box-Hardware optimiert."})]})]}),g.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:t.categories.map(x=>{const S=Ufe[x.role]||{title:x.title||x.role,desc:"Spezifisches Modell für diese Systemrolle.",icon:G1},_=S.icon,w=s.find(D=>D.role===x.role),E=i==null?void 0:i.model_list.find(D=>D.role===x.role),T=x.models.find(D=>D.repo===x.recommended)||x.models[0];if(!T)return null;const C=a[T.repo],k=x.models.filter(D=>D.repo!==x.recommended),N=!!c[x.role];return g.jsxs("div",{className:nt("rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-5 transition-all duration-300 hover:border-primary/40",w?"border-border/60":"border-primary/20 shadow-primary/5"),children:[g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-start justify-between gap-3",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center text-primary shadow-sm shrink-0",children:g.jsx(_,{className:"h-5.5 w-5.5"})}),g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-bold tracking-tight text-foreground",children:S.title}),g.jsxs("span",{className:"text-[9px] font-mono text-muted-foreground uppercase bg-background/50 px-1.5 py-0.5 rounded border border-border/30 inline-block mt-0.5",children:["Rolle: ",x.role]})]})]}),w?g.jsxs("span",{className:"flex items-center gap-1.5 text-[9px] font-bold text-emerald-400 uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-1 rounded-lg",children:[g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Aktiviert"]}):g.jsx("span",{className:"text-[9px] font-bold text-primary/70 uppercase tracking-wider bg-primary/10 border border-primary/20 px-2.5 py-1 rounded-lg",children:"Frei"})]}),g.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:S.desc}),g.jsx("div",{className:"p-3.5 rounded-xl bg-background/35 border border-border/30 space-y-2.5",children:w?g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-muted-foreground/60",children:"Aktive GGUF-Belegung"}),g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:w.name,children:w.name.split("/").pop()}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2",children:[g.jsxs("span",{children:["Größe: ",zT(w.size_bytes||0)]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Quant: ",w.quant||"GGUF"]})]})]}):g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-primary/80",children:"Empfohlenes Modell"}),g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:T.name,children:T.name}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 flex-wrap",children:[g.jsxs("span",{children:["Ersteller: ",T.author]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Quant: ",T.quant]})]}),g.jsx("div",{className:"flex items-center gap-1.5 pt-0.5",children:g.jsx(iX,{fit:T.fit})})]})}),g.jsx("div",{className:"pt-1",children:w?E?g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"text-[9px] font-semibold text-amber-400 flex items-center gap-1.5",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping shrink-0"}),g.jsxs("span",{children:["Bessere Version in der Registry: ",E.repo.split("/").pop()]})]}),g.jsxs("button",{onClick:()=>y(E.repo,x.role,T.quant||"Q4_K_M",T.caps.tools!=="no"),disabled:!!a[E.repo],className:"h-8 w-full flex items-center justify-center gap-1.5 rounded-lg bg-amber-500 text-black text-xs font-bold hover:bg-amber-400 disabled:opacity-50 transition-all cursor-pointer shadow-md shadow-amber-500/10",children:[g.jsx(vg,{className:"h-3.5 w-3.5"}),a[E.repo]||"Auf neue Version aktualisieren"]})]}):g.jsxs("div",{className:"h-8 flex items-center justify-center gap-1.5 text-[10px] font-bold text-emerald-400 uppercase tracking-wide bg-emerald-500/5 border border-emerald-500/10 rounded-lg select-none",children:[g.jsx(bo,{className:"h-4 w-4"})," Auf neuestem Stand"]}):g.jsxs("button",{onClick:()=>y(T.repo,x.role,T.quant||"Q4_K_M",T.caps.tools!=="no"),disabled:!!C,className:nt("h-8 w-full flex items-center justify-center gap-1.5 rounded-lg text-xs font-bold transition-all cursor-pointer border",C?"border-primary/40 bg-primary/5 text-primary":"bg-primary text-primary-foreground hover:opacity-90 shadow-md shadow-primary/10"),children:[g.jsx(vg,{className:"h-3.5 w-3.5"}),C||"Optimales Modell einsetzen"]})})]}),k.length>0&&g.jsxs("div",{className:"border-t border-border/20 pt-3",children:[g.jsxs("button",{onClick:()=>d(D=>({...D,[x.role]:!N})),className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/80 hover:text-foreground transition-colors cursor-pointer",children:[N?g.jsx(A8,{className:"h-3 w-3"}):g.jsx(M8,{className:"h-3 w-3"}),g.jsxs("span",{children:["Alternative Empfehlungen anzeigen (",k.length,")"]})]}),N&&g.jsx("div",{className:"mt-2.5 space-y-2 max-h-36 overflow-y-auto pr-1 scrollbar-thin",children:k.map(D=>g.jsxs("div",{className:"p-2 rounded-lg bg-background/25 border border-border/20 flex items-center justify-between gap-3",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-[10px] font-mono font-bold text-foreground truncate",title:D.name,children:D.name}),g.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center gap-1.5 mt-0.5",children:[g.jsxs("span",{children:["Quant: ",D.quant]}),g.jsx("span",{children:"•"}),g.jsx("span",{children:D.fit.text})]})]}),g.jsx("button",{onClick:()=>y(D.repo,x.role,D.quant||"Q4_K_M",D.caps.tools!=="no"),disabled:!!a[D.repo],className:"h-6 px-2.5 rounded bg-background/40 hover:bg-background/80 border border-border/40 text-[9px] font-bold text-foreground transition-all cursor-pointer shrink-0 disabled:opacity-50",children:a[D.repo]||"Installieren"})]},D.repo))})]})]},x.role)})}),g.jsxs("div",{className:"border border-border/50 bg-card/20 rounded-2xl overflow-hidden shadow-md mt-4",children:[g.jsxs("button",{onClick:()=>m(!f),className:"w-full px-5 py-4 flex items-center justify-between text-xs font-bold uppercase tracking-wider text-muted-foreground hover:bg-card/30 transition-colors cursor-pointer",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(xP,{className:"h-4 w-4 text-primary"}),g.jsx("span",{children:"Eigenes Modell von Hugging Face laden (Erweiterte Ansicht)"})]}),g.jsx("span",{className:"text-[10px] text-primary hover:underline",children:f?"Ausblenden ▲":"Anzeigen ▼"})]}),f&&g.jsx("div",{className:"p-5 border-t border-border/20 bg-card/10",children:g.jsx(jfe,{})})]})]})}function zfe(){const[t,e]=R.useState("cockpit");return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center gap-4",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Modell-Manager"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"Verwalte deine Modelle und passe das Gateway-Routing live über das interaktive Cockpit an."})]}),g.jsx("div",{className:"flex rounded-xl border border-border/60 bg-card/45 backdrop-blur-md p-1 self-start",children:["cockpit","discover"].map(n=>g.jsx("button",{onClick:()=>e(n),className:nt("rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide uppercase transition-all cursor-pointer",t===n?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"text-muted-foreground hover:text-foreground"),children:n==="cockpit"?"Cockpit":"Modelle finden"},n))})]}),g.jsx(Ofe,{}),g.jsx("div",{className:"transition-all duration-300",children:t==="cockpit"?g.jsx(Dfe,{}):g.jsx(Ffe,{})})]})}const Bfe={cline:"cline_settings.json",cursor:"Settings → Models",opencode:"opencode.jsonc",zed:"settings.json",continue:"~/.continue/config.json",claude_code:"~/.zshrc / env"};function k3({line:t,loading:e}){return e||!t?g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-muted-foreground",children:[g.jsx(yP,{className:"h-3 w-3 animate-spin"})," prüfe…"]}):t.ok?g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-emerald-400",children:[g.jsx(T8,{className:"h-3 w-3"})," ",t.detail]}):g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-red-400",children:[g.jsx(P8,{className:"h-3 w-3"})," ",t.detail]})}function O3({tool:t,fileName:e,accent:n,copied:r,onCopy:i}){return g.jsxs("div",{className:"flex flex-col border border-border/60 bg-black/60 rounded-2xl overflow-hidden shadow-2xl",children:[g.jsxs("div",{className:"flex h-11 items-center justify-between px-4 border-b border-border/40 bg-black/40 shrink-0",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-3 w-3 rounded-full bg-red-500/80"}),g.jsx("span",{className:"h-3 w-3 rounded-full bg-amber-500/80"}),g.jsx("span",{className:"h-3 w-3 rounded-full bg-emerald-500/80"})]}),g.jsx("div",{className:"flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground/75 bg-background/30 px-3 py-1 rounded-md border border-border/20",children:g.jsx("span",{children:e})}),g.jsxs("button",{onClick:i,className:"flex h-7 px-2.5 items-center gap-1.5 rounded-lg border border-border/40 bg-background/30 text-[10px] font-semibold text-muted-foreground hover:text-foreground hover:bg-background/60 transition-all cursor-pointer",children:[r?g.jsx(bo,{className:"h-3.5 w-3.5 text-emerald-400"}):g.jsx(ew,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:r?"Kopiert":"Kopieren"})]})]}),g.jsx("pre",{className:nt("p-5 overflow-x-auto text-xs font-mono whitespace-pre leading-relaxed scrollbar-thin select-text bg-black/10",n==="teal"?"text-cyan-200/90":"text-violet-200/90"),children:g.jsx("code",{children:t.snippet})})]})}function Hfe(){const[t,e]=R.useState(localStorage.getItem("mc_host")||"192.168.178.151"),[n,r]=R.useState(localStorage.getItem("mc_mcp_path")||""),[i,s]=R.useState("cline"),[o,a]=R.useState(null),l=new URLSearchParams({host:t});n&&l.set("mcp_path",n);const{data:c,error:d}=GF(l.toString()),{data:f,isLoading:m}=S7(),y=d?String(d):"";function x(E){e(E),E&&localStorage.setItem("mc_host",E)}function S(E){r(E),localStorage.setItem("mc_mcp_path",E)}const _=c==null?void 0:c.tools[i];async function w(E,T){T&&(await navigator.clipboard.writeText(T),a(E),setTimeout(()=>a(null),1500))}return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Verbindung & Integration"}),g.jsxs("p",{className:"text-sm text-muted-foreground",children:["Binde deinen lokalen Agenten an die Box an — über ",g.jsx("span",{className:"text-foreground",children:"zwei getrennte Leitungen"}),": das Modell (Gateway) und das geteilte Gedächtnis (MCP)."]})]}),g.jsxs("div",{className:"p-5 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md shadow-lg shadow-black/10",children:[g.jsxs("div",{className:"grid gap-4 md:grid-cols-[170px_1fr] items-center",children:[g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-background/40 p-4 text-center",children:[g.jsx(F8,{className:"h-7 w-7 mx-auto text-muted-foreground"}),g.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:"Dein lokaler Agent"}),g.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Cline · Cursor · Zed …"})]}),g.jsxs("div",{className:"flex flex-col gap-2.5",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(iI,{className:"h-4 w-4 text-muted-foreground shrink-0"}),g.jsxs("div",{className:"flex-1 rounded-xl border border-primary/25 bg-primary/5 px-3.5 py-2.5",children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-primary",children:[g.jsx(El,{className:"h-3.5 w-3.5"})," Leitung 1 — Modell"]}),g.jsx(k3,{line:f==null?void 0:f.gateway,loading:m})]}),g.jsx("div",{className:"mt-1 text-[11px] font-mono text-primary/80",children:"Gateway · :9001/v1 · model auto"})]})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(iI,{className:"h-4 w-4 text-muted-foreground shrink-0"}),g.jsxs("div",{className:"flex-1 rounded-xl border border-violet-500/25 bg-violet-500/5 px-3.5 py-2.5",children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-violet-300",children:[g.jsx(V1,{className:"h-3.5 w-3.5"})," Leitung 2 — Gedächtnis"]}),g.jsx(k3,{line:f==null?void 0:f.memory,loading:m})]}),g.jsx("div",{className:"mt-1 text-[11px] font-mono text-violet-300/80",children:"MCP · mcp_memory.py · separat"})]})]})]})]}),g.jsxs("p",{className:"mt-3.5 text-[11px] text-muted-foreground leading-relaxed",children:["Der Gateway liefert ",g.jsx("span",{className:"text-foreground",children:"nur das LLM"}),". Das geteilte Gedächtnis läuft über einen",g.jsx("span",{className:"text-foreground",children:" eigenen MCP-Server"})," — beide werden unabhängig eingerichtet."]})]}),g.jsxs("div",{className:"grid gap-4 md:grid-cols-2 p-5 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md shadow-lg shadow-black/10",children:[g.jsxs("div",{className:"space-y-1.5",children:[g.jsxs("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[g.jsx(j8,{className:"h-3.5 w-3.5 text-primary"})," Box LAN IP-Adresse"]}),g.jsx("input",{value:t,onChange:E=>x(E.target.value),placeholder:"z.B. 192.168.178.151",className:"w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"})]}),g.jsxs("div",{className:"space-y-1.5",children:[g.jsxs("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[g.jsx(L8,{className:"h-3.5 w-3.5 text-violet-400"})," Lokaler MCP-Scriptpfad",g.jsx("span",{className:"text-violet-400/70 normal-case font-semibold tracking-normal",children:"(nur Leitung 2)"})]}),g.jsx("input",{value:n,onChange:E=>S(E.target.value),placeholder:"z.B. F:\\Coding Stuff\\mission-control-2\\mcp\\mcp_memory.py",className:"w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-violet-500/50 text-foreground"})]})]}),y&&g.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Fehler beim Generieren der Snippets: ",y]}),c&&g.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[g.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/60 border-t-2 border-t-primary/70 bg-card/30 p-4",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm font-space font-bold text-foreground",children:[g.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-primary/15 text-primary text-[11px]",children:"1"}),"Modell anbinden"]}),g.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Wähle dein Tool — das Snippet zeigt auf den Gateway."})]}),g.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(c.tools).map(([E,T])=>g.jsx("button",{onClick:()=>s(E),className:nt("rounded-lg px-3 py-1.5 text-[11px] font-semibold tracking-wide transition-all cursor-pointer",i===E?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"border border-border/50 text-muted-foreground hover:text-foreground"),children:T.label},E))}),_&&g.jsxs(g.Fragment,{children:[_.note&&g.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-xl bg-primary/5 border border-primary/20 text-[11px] text-muted-foreground leading-relaxed",children:[g.jsx(oI,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),g.jsx("span",{children:_.note})]}),g.jsx(O3,{tool:_,fileName:Bfe[i]||"config.json",accent:"teal",copied:o==="model",onCopy:()=>w("model",_.snippet)})]})]}),g.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/60 border-t-2 border-t-violet-500/70 bg-card/30 p-4",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm font-space font-bold text-foreground",children:[g.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-violet-500/15 text-violet-300 text-[11px]",children:"2"}),"Gedächtnis anbinden",g.jsx("span",{className:"text-[10px] font-medium text-muted-foreground normal-case",children:"optional"})]}),g.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:["Ein MCP-Block — gilt zusätzlich für ",g.jsx("em",{children:"jedes"})," Tool aus Schritt 1."]})]}),g.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-xl bg-violet-500/5 border border-violet-500/20 text-[11px] text-muted-foreground leading-relaxed",children:[g.jsx(oI,{className:"h-4 w-4 text-violet-400 shrink-0 mt-0.5"}),g.jsx("span",{children:c.memory.note})]}),g.jsx(O3,{tool:c.memory,fileName:"mcp.json",accent:"violet",copied:o==="memory",onCopy:()=>w("memory",c.memory.snippet)})]})]})]})}const Vfe="modulepreload",Gfe=function(t){return"/"+t},L3={},Wfe=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=Gfe(c),c in L3)return;L3[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Vfe,d||(m.as="script"),m.crossOrigin="",m.href=c,l&&m.setAttribute("nonce",l),document.head.appendChild(m),d)return new Promise((y,x)=>{m.addEventListener("load",y),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};class $fe extends R.Component{constructor(){super(...arguments);fo(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?g.jsxs("div",{className:"h-[480px] rounded-2xl border border-red-500/20 bg-red-500/5 p-6 text-xs text-red-400 overflow-auto",children:[g.jsx("div",{className:"font-semibold mb-2",children:"Graph konnte nicht gerendert werden"}),g.jsx("pre",{className:"whitespace-pre-wrap break-words text-[11px] leading-relaxed",children:this.state.error.message})]}):this.props.children}}const Xfe=R.lazy(()=>Wfe(()=>import("./GraphView-B3bOxhlI.js"),[]).then(t=>({default:t.GraphView}))),D3=["identity","knowledge","rules","events"],j3=new Set(["auto","agent","hermes"]),$E={identity:{label:"Identität",icon:o9,bg:"bg-cyan-500/10",text:"text-cyan-400"},knowledge:{label:"Wissen",icon:s0,bg:"bg-indigo-500/10",text:"text-indigo-400"},rules:{label:"Regeln",icon:e9,bg:"bg-violet-500/10",text:"text-violet-400"},events:{label:"Ereignisse",icon:R8,bg:"bg-amber-500/10",text:"text-amber-400"}},U3={label:"Gedächtnis",icon:TT,bg:"bg-muted/10",text:"text-muted-foreground"},qfe={identity:"border-l-cyan-500/80",knowledge:"border-l-indigo-500/80",rules:"border-l-violet-500/80",events:"border-l-amber-500/80"},F3=`Hi Hermes! Lass uns ein kurzes Onboarding machen, damit du dich künftig an mich erinnerst. Stell mir nacheinander ein paar kurze Fragen zu: + `}),g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-3.5",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(nE,{className:"h-4.5 w-4.5 text-primary"}),g.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"VRAM / Memory Belegung"})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground",children:["Speicher-Pool: ",Ho(te)," Gewichte",Ee>0?` · ${Ho(Ee)} real belegt (inkl. KV)`:""," / ",Ho(le)]}),x.length>0&&g.jsx("button",{onClick:Ve,className:"h-6 px-2.5 rounded border border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/10 text-amber-400 text-[9px] font-bold uppercase transition-all cursor-pointer",children:"Alle entladen"})]})]}),g.jsx("div",{className:"h-7 w-full rounded-xl bg-background/50 border border-border/40 overflow-hidden flex p-0.5 relative group",children:at.length===0?g.jsx("div",{className:"w-full h-full flex items-center justify-center text-[10px] text-muted-foreground/60 italic font-mono select-none",children:"VRAM Leer — Auto-Swap lädt Modelle bei Anfrage"}):at.map((ue,ee)=>{var Fe;const Ae=(ue.size_bytes||0)/le*100,re=["from-teal-500 to-emerald-500","from-indigo-500 to-blue-500","from-purple-500 to-pink-500","from-cyan-500 to-sky-500"][ee%4];return g.jsxs("div",{style:{width:`${Ae}%`},className:nt("h-full rounded bg-gradient-to-r flex items-center justify-between px-2.5 transition-all text-white/95 shrink-0 shadow-inner select-none",re),title:`${ue.name} (${Ho(ue.size_bytes)})`,children:[g.jsxs("span",{className:"text-[9px] font-bold truncate max-w-[120px] font-space tracking-wide",children:[ue.role?`[${ue.role}] `:"",(Fe=ue.name.split("/").pop())==null?void 0:Fe.replace(".gguf","")]}),g.jsx("span",{className:"text-[8px] font-mono opacity-80",children:Ho(ue.size_bytes)})]},ue.name)})})]}),g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-6 shadow-lg shadow-black/10 space-y-4",children:[g.jsxs("div",{children:[g.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"Interactive Gateway Graph"}),g.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 leading-relaxed",children:"Klicke links auf Editoren, um Configs zu kopieren. Klicke rechts auf Rollen, um GGUF-Zuweisungen live zu ändern."})]}),g.jsxs("div",{ref:ge,className:"relative w-full h-96 border border-border/30 rounded-xl bg-black/25 overflow-hidden flex",children:[g.jsxs("svg",{className:"absolute inset-0 pointer-events-none w-full h-full",children:[g.jsxs("defs",{children:[g.jsxs("linearGradient",{id:"cyan-to-teal",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#06b6d4",stopOpacity:"0.45"}),g.jsx("stop",{offset:"100%",stopColor:"#0d9488",stopOpacity:"0.45"})]}),g.jsxs("linearGradient",{id:"active-glow",x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[g.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:"0.8"}),g.jsx("stop",{offset:"100%",stopColor:"#10b981",stopOpacity:"0.8"})]})]}),g.jsx("path",{d:we(.1),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="roocode"||w==="roocode")&&g.jsx("path",{d:we(.1),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.3),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="cursor"||w==="cursor")&&g.jsx("path",{d:we(.3),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.5),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="opencode"||w==="opencode")&&g.jsx("path",{d:we(.5),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.7),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="zed"||w==="zed")&&g.jsx("path",{d:we(.7),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:we(.9),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),(ne==="continue"||w==="continue")&&g.jsx("path",{d:we(.9),stroke:"#06b6d4",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.12),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("fast")&&g.jsx("path",{d:Me(.12),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.31),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("heavy")&&g.jsx("path",{d:Me(.31),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.5),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("coder")&&g.jsx("path",{d:Me(.5),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.69),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("vision")&&g.jsx("path",{d:Me(.69),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"}),g.jsx("path",{d:Me(.88),stroke:"url(#cyan-to-teal)",strokeWidth:"1.5",fill:"none"}),lt("scout")&&g.jsx("path",{d:Me(.88),stroke:"url(#active-glow)",strokeWidth:"2.5",fill:"none",className:"svg-flow-path"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"10%"},onMouseEnter:()=>J("roocode"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="roocode"?null:"roocode"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Roo Code"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"30%"},onMouseEnter:()=>J("cursor"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="cursor"?null:"cursor"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Cursor IDE"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"50%"},onMouseEnter:()=>J("opencode"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="opencode"?null:"opencode"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"OpenCode"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"70%"},onMouseEnter:()=>J("zed"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="zed"?null:"zed"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Zed"})]}),g.jsxs("div",{className:"absolute cursor-pointer select-none z-10 w-28 h-8 -translate-y-1/2 -translate-x-1/2 rounded-xl border border-border/60 bg-card/75 backdrop-blur-md flex items-center justify-center gap-1.5 px-2 hover:border-primary transition-all text-[10px] font-semibold text-foreground shadow shadow-black/20",style:{left:"10%",top:"90%"},onMouseEnter:()=>J("continue"),onMouseLeave:()=>J(null),onClick:()=>E(ue=>ue==="continue"?null:"continue"),children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse"}),g.jsx("span",{children:"Continue"})]}),g.jsxs("div",{className:"absolute select-none z-10 w-36 py-3 px-4 -translate-y-1/2 -translate-x-1/2 rounded-2xl border border-primary/50 bg-card/90 backdrop-blur-md flex flex-col items-center justify-center text-center shadow-lg shadow-primary/5",style:{left:"50%",top:"50%"},children:[g.jsx("div",{className:"text-[10px] uppercase font-bold text-primary font-space tracking-wide",children:"Gateway Auto"}),g.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground mt-0.5",children:["Schwelle: > ",i!=null&&i.heavy_threshold_chars?i.heavy_threshold_chars/1e3:"4","k Zeichen"]}),g.jsx("div",{className:"mt-1 px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[9px] font-semibold text-primary uppercase font-mono",children:"Auto-Swap"})]}),ZF.map(ue=>{var Te;const ee=["12%","31%","50%","69%","88%"],Ae=Ce(ue),re=Ae?x.includes(Ae.name):!1;if(ue==="agent")return null;const Fe={fast:0,heavy:1,coder:2,vision:3,scout:4}[ue];return g.jsxs("div",{className:nt("absolute z-10 w-44 py-1.5 px-3 -translate-y-1/2 -translate-x-1/2 rounded-xl border flex flex-col justify-center hover:border-primary/50 transition-all text-left shadow select-none cursor-pointer",re?"border-emerald-500/50 bg-emerald-500/5 shadow-emerald-500/5":Ae?"border-border/60 bg-card/75":"border-dashed border-border/40 bg-background/20"),style:{left:"90%",top:ee[Fe]},onClick:()=>fe(ue),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:ue}),re&&g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),g.jsx("div",{className:"text-[10px] font-mono font-medium truncate mt-0.5 text-foreground max-w-[150px]",children:Ae?(Te=Ae.name.split("/").pop())==null?void 0:Te.replace(".gguf",""):"Keine Zuweisung"})]},ue)}),w&&s&&g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200 flex flex-col justify-between",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("span",{className:"text-xs font-bold uppercase tracking-wider text-primary",children:[w==="roocode"&&"Roo Code Setup",w==="cursor"&&"Cursor Setup",w==="opencode"&&"OpenCode Setup",w==="zed"&&"Zed Setup",w==="continue"&&"Continue Setup"]}),g.jsx("button",{onClick:()=>E(null),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("div",{className:"text-xs text-muted-foreground leading-relaxed space-y-2",children:[w==="roocode"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Suche in VS Code nach der Erweiterung ",g.jsx("strong",{children:"Roo Code"})," und installiere sie."]}),g.jsxs("li",{children:["Wähle in den Roo Code Einstellungen: Provider: ",g.jsx("strong",{children:"OpenAI Compatible"}),"."]}),g.jsxs("li",{children:["Füge das untenstehende JSON-Snippet in die ",g.jsx("code",{children:"settings.json"})," ein."]})]}),w==="cursor"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne Cursor Settings ➔ ",g.jsx("strong",{children:"Models"}),"."]}),g.jsxs("li",{children:["Deaktiviere Cloud-Modelle, klappe ",g.jsx("strong",{children:"OpenAI API"})," auf."]}),g.jsxs("li",{children:["Trage die Base URL unten ein und aktiviere das Modell ",g.jsx("strong",{children:"auto"}),"."]})]}),w==="opencode"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne die ",g.jsx("code",{children:"opencode.jsonc"})," Konfigurationsdatei."]}),g.jsxs("li",{children:["Ersetze den Provider-Eintrag unter ",g.jsx("code",{children:"provider"})," mit dem Snippet unten."]})]}),w==="zed"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsxs("li",{children:["Öffne die Zed Settings (",g.jsx("code",{children:"ctrl+,"}),")."]}),g.jsxs("li",{children:["Füge das untenstehende JSON-Segment unter ",g.jsx("code",{children:"language_models"})," ein."]})]}),w==="continue"&&g.jsxs("ul",{className:"list-decimal pl-4 space-y-1",children:[g.jsx("li",{children:"Klicke auf das Zahnrad-Symbol in der Continue-Erweiterung."}),g.jsxs("li",{children:["Füge den Gateway-Eintrag zum ",g.jsx("code",{children:"models"}),"-Array hinzu."]})]})]}),s.tools&&g.jsxs("div",{className:"relative rounded-xl border border-border/40 bg-black/40 overflow-hidden mt-1 shrink-0",children:[g.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/20 bg-black/20",children:[g.jsx("span",{className:"text-[10px] font-mono text-muted-foreground",children:"JSON Config"}),g.jsxs("button",{onClick:()=>{var ue,ee,Ae,re,Fe;return xt(w==="roocode"?(ue=s.tools.cline)==null?void 0:ue.snippet:w==="cursor"?(ee=s.tools.cursor)==null?void 0:ee.snippet:w==="opencode"?(Ae=s.tools.opencode)==null?void 0:Ae.snippet:w==="zed"?(re=s.tools.zed)==null?void 0:re.snippet:(Fe=s.tools.continue)==null?void 0:Fe.snippet)},className:"text-xs font-semibold text-primary hover:text-primary-foreground flex items-center gap-1 cursor-pointer",children:[U?g.jsx(bo,{className:"h-3.5 w-3.5 text-emerald-400"}):g.jsx(ew,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:U?"Kopiert":"Kopieren"})]})]}),g.jsx("pre",{className:"p-3 max-h-48 overflow-y-auto text-xs font-mono text-cyan-200/90 whitespace-pre scrollbar-thin select-text",children:g.jsxs("code",{children:[w==="roocode"&&((qe=s.tools.cline)==null?void 0:qe.snippet),w==="cursor"&&((dt=s.tools.cursor)==null?void 0:dt.snippet),w==="opencode"&&((Dt=s.tools.opencode)==null?void 0:Dt.snippet),w==="zed"&&((jt=s.tools.zed)==null?void 0:jt.snippet),w==="continue"&&((pt=s.tools.continue)==null?void 0:pt.snippet)]})})]}),g.jsx("button",{onClick:()=>E(null),className:"w-full h-9 rounded-lg bg-primary text-primary-foreground hover:opacity-90 font-semibold text-xs transition-opacity cursor-pointer mt-2",children:"Schließen"})]})})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-6 mt-3 text-[10px] text-muted-foreground border-t border-border/20 pt-3",children:[g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded-full bg-cyan-400"}),g.jsx("span",{children:"Cyan-Fluss: Client-Anfrage an Gateway"})]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500 animate-pulse"}),g.jsx("span",{children:"Grüner Puls: Aktive Verbindung / Warmes Modell geladen"})]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-2 w-2 rounded bg-gradient-to-r from-teal-500 to-emerald-500"}),g.jsx("span",{children:"VRAM-Verlauf: Modellspezifischer Speicheranteil"})]})]})]}),g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-3.5",children:[g.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground px-1",children:"Gateway Steckplatz-Belegung (Slot-Zuweisung)"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:["fast","heavy","coder","vision","scout"].map(ue=>{var re;const ee=y.find(Fe=>Fe.role===ue),Ae=ee?x.includes(ee.name):!1;return g.jsxs("div",{onClick:()=>fe(ue),className:nt("rounded-xl border p-3 flex flex-col justify-between gap-2.5 transition-all cursor-pointer select-none text-left bg-background/25 hover:border-primary/45 hover:bg-background/40 group min-h-[90px]",Ae?"border-emerald-500/40 shadow-sm shadow-emerald-500/5":ee?"border-primary/20 bg-primary/5":"border-border/30 border-dashed opacity-75"),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:nt("text-[9px] font-bold uppercase tracking-wider font-mono px-1.5 py-0.5 rounded border",PP(ue)),children:ue}),Ae&&g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),g.jsx("div",{className:"text-[10px] font-mono font-medium truncate text-foreground/90 pr-1 font-space",title:ee==null?void 0:ee.name,children:ee?(re=ee.name.split("/").pop())==null?void 0:re.replace(/\.gguf$/i,""):"nicht zugewiesen"}),g.jsx("div",{className:"text-[8px] text-primary/70 group-hover:text-primary font-bold uppercase tracking-wider transition-colors font-space",children:"Ändern ➔"})]},ue)})})]}),(a==null?void 0:a.current)&&g.jsxs("div",{className:"rounded-2xl border border-indigo-500/30 bg-indigo-500/5 backdrop-blur-md p-5 shadow-lg shadow-black/10 space-y-3.5",children:[g.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(qc,{className:"h-4.5 w-4.5 text-indigo-400"}),g.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:"Agent-Hirn (Hermes)"}),a.current.version!=null&&g.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-indigo-500/15 text-indigo-300 border border-indigo-500/25",children:["v",a.current.version]})]}),g.jsx("button",{onClick:()=>O(!0),className:"h-7 px-3 rounded-lg border border-indigo-500/30 bg-indigo-500/5 text-indigo-300 text-[9px] font-bold uppercase hover:bg-indigo-500/15 transition-all cursor-pointer",children:"Hirn wechseln"})]}),g.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 rounded-xl bg-background/30 border border-border/30 p-3.5",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:a.current.name,children:a.current.name.split("/").pop()}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 mt-0.5",children:[g.jsx("span",{children:a.current.params_b?`${a.current.params_b}B`:"—"}),g.jsx("span",{children:"•"}),g.jsx("span",{children:a.current.quant||"GGUF"}),g.jsx("span",{children:"•"}),g.jsx("span",{children:Ho(a.current.size_bytes||0)})]})]}),a.update_available&&a.recommended?g.jsxs("button",{onClick:()=>We(a.recommended.repo),className:nt("h-8 px-3 shrink-0 flex items-center justify-center gap-1.5 rounded-lg text-[10px] font-bold uppercase transition-all cursor-pointer shadow-md",a.budget&&!a.budget.fits?"bg-red-500 text-white hover:bg-red-400 shadow-red-500/10":"bg-amber-500 text-black hover:bg-amber-400 shadow-amber-500/10"),children:[g.jsx(vg,{className:"h-3.5 w-3.5"})," Aktualisieren"]}):g.jsxs("span",{className:"h-8 px-3 shrink-0 flex items-center gap-1.5 text-[10px] font-bold text-emerald-400 uppercase tracking-wide bg-emerald-500/5 border border-emerald-500/15 rounded-lg select-none",children:[g.jsx(bo,{className:"h-4 w-4"})," Neueste Generation"]})]}),a.update_available&&a.recommended&&g.jsxs("div",{className:"text-[10px] text-amber-400/90 flex items-center gap-1.5",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping shrink-0"}),"Neuere Generation verfügbar: ",g.jsx("span",{className:"font-mono font-bold",children:a.recommended.name.replace(/-GGUF$/i,"")}),"(v",a.recommended.version,", ",a.recommended.params_b,"B) — von NousResearch."]}),a.budget&&g.jsxs("div",{className:nt("text-[10px] flex items-start gap-1.5 leading-relaxed",a.budget.fits?"text-muted-foreground/80":"text-red-400 font-semibold"),children:[g.jsx(nE,{className:"h-3 w-3 shrink-0 mt-0.5"}),g.jsxs("span",{children:["Always-On-Brain ~",a.budget.brain_gb," GB + größtes on-demand (~",a.budget.largest_ondemand_gb," GB) = ",(a.budget.brain_gb+a.budget.largest_ondemand_gb).toFixed(1)," / ",a.budget.gtt_gb," GB",a.budget.fits?" · passt gleichzeitig ✓":" · passt NICHT gleichzeitig ⚠ — heavy/coder würden das Brain verdrängen. Kleineres Brain oder weniger Kontext."]})]})]}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 px-1",children:[g.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:["Installierte Modell-Bibliothek (",K.length," von ",y.length,")"]}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("div",{className:"flex rounded-lg border border-border/40 bg-card/45 p-0.5",children:[g.jsx("button",{onClick:()=>B("all"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",he==="all"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Vorhanden"}),g.jsx("button",{onClick:()=>B("in_use"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",he==="in_use"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"In Benutzung"})]}),g.jsxs("div",{className:"flex rounded-lg border border-border/40 bg-card/45 p-0.5",children:[g.jsx("button",{onClick:()=>oe("grid"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",de==="grid"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Grid"}),g.jsx("button",{onClick:()=>oe("list"),className:nt("px-2.5 py-1 rounded-md text-[9px] font-bold uppercase transition-all cursor-pointer",de==="list"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"List"})]})]})]}),de==="grid"?g.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:K.length===0?g.jsx("div",{className:"col-span-full text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center select-none",children:he==="in_use"?"Keine Modelle in Benutzung (keine Zuweisung oder warm geladene Modelle).":'Keine Modelle konfiguriert. Verwende den Tab "Modelle finden" zum Herunterladen.'}):K.map(ue=>{const ee=x.includes(ue.name),Ae=o==null?void 0:o.model_list.find(Fe=>Fe.role===ue.role),re=CI(ue.name);return g.jsxs("div",{className:nt("rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-4 transition-all duration-300 hover:border-primary/40 group relative overflow-hidden",ee?"border-primary/45 shadow-primary/5":ue.role?"border-primary/30 bg-primary/5 shadow-inner":"border-border/60"),children:[g.jsxs("div",{className:"space-y-3",children:[g.jsx("div",{className:"flex items-start justify-between gap-3",children:g.jsxs("div",{className:"flex gap-2.5 min-w-0",children:[g.jsx("div",{className:nt("w-7 h-7 rounded-lg border flex items-center justify-center font-bold text-xs shrink-0 shadow-sm",re.color),title:re.name,children:re.initial}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("h3",{className:"text-xs font-bold tracking-tight text-foreground line-clamp-2 break-all font-mono",title:ue.name,children:ue.name.split("/").pop()}),g.jsxs("div",{className:"flex items-center gap-2 flex-wrap mt-1",children:[g.jsx("span",{className:"text-[9px] font-mono text-muted-foreground bg-background/40 px-1.5 py-0.5 rounded border border-border/30",children:ue.quant||"GGUF"}),ee&&g.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-semibold text-emerald-400 uppercase tracking-wider",children:[g.jsx(i0,{className:"h-3 w-3 animate-pulse"})," Warm"]}),ue.role&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[9px] font-mono text-primary font-bold uppercase",children:ue.role}),ue.prompt_cache&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/10 border border-cyan-500/20 text-[9px] font-mono text-cyan-400 font-bold uppercase",title:"Prompt Caching aktiv",children:"PC"}),ue.spec_active?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20 text-[9px] font-mono text-emerald-400 font-bold uppercase",title:`Speculative Decoding aktiv (Draft: ${ue.spec_draft_model})`,children:"SPEC"}):ue.spec_draft_model?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[9px] font-mono text-amber-400 font-bold uppercase",title:`Draft gesetzt (${ue.spec_draft_model}), aber INAKTIV — --spec-type fehlt oder Vocab inkompatibel. Über 'Spec' neu konfigurieren.`,children:"SPEC?"}):null,ue.parallel_slots>1&&g.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-violet-500/10 border border-violet-500/20 text-[9px] font-mono text-violet-400 font-bold uppercase",title:`${ue.parallel_slots} parallele Slots aktiv`,children:["SLOTS: ",ue.parallel_slots]}),ue.incomplete&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[9px] font-mono text-amber-400 font-bold uppercase",title:"GGUF-Datei fehlt — Modell kann nicht geladen werden",children:"⚠ Datei fehlt"})]})]})]})}),g.jsx("div",{className:"border-t border-border/30 pt-3 flex flex-wrap gap-1",children:g.jsx(I3,{caps:ue.capabilities})})]}),g.jsxs("div",{className:"space-y-3 pt-1",children:[g.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[10px] font-mono text-muted-foreground",children:[g.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20",children:[g.jsx(nE,{className:"h-3.5 w-3.5 text-primary/80"}),g.jsxs("div",{children:[g.jsx("div",{className:"text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60",children:"Größe"}),g.jsx("div",{className:"text-foreground font-semibold",children:Ho(ue.size_bytes)})]})]}),g.jsxs("div",{className:"flex items-center gap-1.5 p-2 bg-background/20 rounded-lg border border-border/20",children:[g.jsx(Y8,{className:"h-3.5 w-3.5 text-primary/80"}),g.jsxs("div",{children:[g.jsx("div",{className:"text-[8px] uppercase tracking-wider font-semibold text-muted-foreground/60",children:"Kontext"}),g.jsx("div",{className:"text-foreground font-semibold",children:EI(ue.ctx)})]})]})]}),Ae&&g.jsxs("div",{className:"p-3 bg-amber-500/5 border border-amber-500/30 rounded-xl space-y-2 flex flex-col justify-between shrink-0",children:[g.jsxs("div",{className:"text-[9px] font-semibold text-amber-400 flex items-center gap-1",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping"}),g.jsxs("span",{children:["Upgrade verfügbar: ",Ae.repo.split("/").pop()]})]}),g.jsxs("button",{onClick:()=>je(Ae.repo,ue.role,ue.quant||"Q4_K_M",ue.capabilities.tools!=="no"),className:"h-7 w-full flex items-center justify-center gap-1 rounded-lg bg-amber-500 text-black text-[10px] font-bold hover:bg-amber-400 transition-colors cursor-pointer",children:[g.jsx(vg,{className:"h-3 w-3"})," Smart-Swap starten"]})]}),g.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/20 pt-3 mt-auto",children:[g.jsx("button",{onClick:()=>ee?Se(ue.name):$e(ue.name),disabled:ue.incomplete&&!ee,className:nt("flex-1 h-7 rounded-lg text-[9px] font-bold uppercase transition-all border flex items-center justify-center gap-1",ue.incomplete&&!ee?"border-border/30 bg-background/10 text-muted-foreground/50 cursor-not-allowed":ee?"border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/15 text-amber-400 cursor-pointer":"border-primary/30 bg-primary/5 hover:bg-primary/15 text-primary cursor-pointer"),children:ee?"Entladen":"Laden"}),g.jsx("button",{onClick:()=>Q(ue.name,ue.ctx),className:"h-7 px-2.5 rounded-lg border border-border/40 text-[9px] font-bold uppercase hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:"Kontextlänge anpassen",children:"Ctx"}),g.jsxs("button",{onClick:()=>F(ue),className:nt("h-7 px-2.5 rounded-lg border text-[9px] font-bold uppercase transition-colors cursor-pointer flex items-center gap-1",ue.spec_active?"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10":ue.spec_draft_model?"border-amber-500/30 text-amber-400 hover:bg-amber-500/10":"border-border/40 text-muted-foreground hover:bg-accent"),title:"Speculative Draft konfigurieren (Vocab-geprüft)",children:[g.jsx(xh,{className:"h-3 w-3"})," Spec"]}),g.jsx("button",{onClick:()=>Ge(ue.name),className:"h-7 w-7 rounded-lg border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 flex items-center justify-center transition-colors cursor-pointer",title:"Modell löschen",children:g.jsx(kT,{className:"h-3.5 w-3.5"})})]})]})]},ue.name)})}):g.jsx("div",{className:"space-y-2",children:K.length===0?g.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center select-none",children:he==="in_use"?"Keine Modelle in Benutzung (keine Zuweisung oder warm geladene Modelle).":'Keine Modelle konfiguriert. Verwende den Tab "Modelle finden" zum Herunterladen.'}):K.map(ue=>{const ee=x.includes(ue.name),Ae=CI(ue.name);return g.jsxs("div",{className:nt("rounded-xl border bg-card/45 backdrop-blur-md p-3.5 shadow-lg shadow-black/5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:border-primary/40 transition-all",ee?"border-primary/45":ue.role?"border-primary/30 bg-primary/5":"border-border/60"),children:[g.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[g.jsx("div",{className:nt("w-8 h-8 rounded-lg border border-border/40 flex items-center justify-center font-bold text-xs shrink-0 shadow-sm",Ae.color),title:Ae.name,children:Ae.initial}),g.jsxs("div",{className:"min-w-0 text-left",children:[g.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[g.jsx("h4",{className:"text-xs font-bold text-foreground truncate max-w-[250px] sm:max-w-[400px] break-all font-mono",title:ue.name,children:ue.name.split("/").pop()}),ue.role&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-primary/10 border border-primary/20 text-[8px] font-mono text-primary font-bold uppercase shrink-0",children:ue.role}),ue.prompt_cache&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/10 border border-cyan-500/20 text-[8px] font-mono text-cyan-400 font-bold uppercase shrink-0",title:"Prompt Caching aktiv",children:"PC"}),ue.spec_active?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/10 border border-emerald-500/20 text-[8px] font-mono text-emerald-400 font-bold uppercase shrink-0",title:`Speculative Decoding aktiv (Draft: ${ue.spec_draft_model})`,children:"SPEC"}):ue.spec_draft_model?g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[8px] font-mono text-amber-400 font-bold uppercase shrink-0",title:`Draft gesetzt (${ue.spec_draft_model}), aber INAKTIV — --spec-type fehlt oder Vocab inkompatibel.`,children:"SPEC?"}):null,ue.parallel_slots>1&&g.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-violet-500/10 border border-violet-500/20 text-[8px] font-mono text-violet-400 font-bold uppercase shrink-0",title:`${ue.parallel_slots} parallele Slots aktiv`,children:["SLOTS: ",ue.parallel_slots]}),ue.incomplete&&g.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 border border-amber-500/20 text-[8px] font-mono text-amber-400 font-bold uppercase shrink-0",title:"GGUF-Datei fehlt",children:"⚠ Datei fehlt"}),ee&&g.jsxs("span",{className:"flex items-center gap-0.5 text-[8px] font-semibold text-emerald-400 uppercase tracking-wider shrink-0",children:[g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"})," warm"]})]}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 mt-0.5",children:[g.jsxs("span",{children:["Größe: ",Ho(ue.size_bytes)]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Kontext: ",EI(ue.ctx)]}),g.jsx("span",{children:"•"}),g.jsx("span",{className:"font-mono text-[9px]",children:ue.quant||"GGUF"})]})]})]}),g.jsxs("div",{className:"flex items-center gap-3 shrink-0 self-end sm:self-auto",children:[g.jsx("div",{className:"hidden lg:flex flex-wrap gap-1",children:g.jsx(I3,{caps:ue.capabilities})}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("button",{onClick:()=>ee?Se(ue.name):$e(ue.name),disabled:ue.incomplete&&!ee,className:nt("h-7 px-3 rounded-lg text-[9px] font-bold uppercase transition-all border flex items-center gap-1",ue.incomplete&&!ee?"border-border/30 bg-background/10 text-muted-foreground/50 cursor-not-allowed":ee?"border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/15 text-amber-400 cursor-pointer":"border-primary/30 bg-primary/5 hover:bg-primary/15 text-primary cursor-pointer"),children:ee?"Entladen":"Laden"}),g.jsx("button",{onClick:()=>Q(ue.name,ue.ctx),className:"h-7 px-2.5 rounded-lg border border-border/40 text-[9px] font-bold uppercase hover:bg-accent text-muted-foreground transition-all cursor-pointer",title:"Kontextlänge anpassen",children:"Ctx"}),g.jsxs("button",{onClick:()=>F(ue),className:nt("h-7 px-2.5 rounded-lg border text-[9px] font-bold uppercase transition-all cursor-pointer flex items-center gap-1",ue.spec_active?"border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10":ue.spec_draft_model?"border-amber-500/30 text-amber-400 hover:bg-amber-500/10":"border-border/40 text-muted-foreground hover:bg-accent"),title:"Speculative Draft konfigurieren (Vocab-geprüft)",children:[g.jsx(xh,{className:"h-3 w-3"})," Spec"]}),g.jsx("button",{onClick:()=>Ge(ue.name),className:"h-7 w-7 rounded-lg flex items-center justify-center border border-border/40 text-muted-foreground hover:text-red-400 hover:bg-red-500/5 transition-all cursor-pointer",title:"Modell löschen",children:g.jsx(kT,{className:"h-3.5 w-3.5"})})]})]})]},ue.name)})})]}),T&&(()=>{var Fe,Te;const ue=k&&k.role===T?k:null,ee={};ue==null||ue.models.forEach(Le=>{ee[Le.name]=Le});const Ae=ue?ue.models.map(Le=>y.find(Ke=>Ke.name===Le.name)).filter(Boolean):y,re=Le=>{Xe(T,Le),C(null)};return g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary",children:["Rolle '",T,"' konfigurieren"]}),g.jsx("button",{onClick:()=>C(null),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("p",{className:"text-xs text-muted-foreground",children:["Wähle ein Modell für die Rolle ",g.jsx("strong",{className:"text-foreground",children:T}),":"]}),(ue==null?void 0:ue.recommended)&&g.jsxs("button",{onClick:()=>re(ue.recommended),title:(Fe=ee[ue.recommended])==null?void 0:Fe.reason,className:"shrink-0 h-7 px-3 text-[11px] font-semibold text-primary border border-primary/50 bg-primary/10 hover:bg-primary/20 rounded-lg cursor-pointer flex items-center gap-1",children:[g.jsx(xh,{className:"h-3 w-3"})," Auto: ",(Te=ue.recommended.split("/").pop())==null?void 0:Te.replace(/\.gguf$/i,"")]})]}),g.jsxs("div",{className:"space-y-1.5 max-h-60 overflow-y-auto pr-1",children:[g.jsx("button",{onClick:()=>re(""),className:"w-full text-left px-3 py-2 rounded-lg text-xs hover:bg-accent text-red-400 font-semibold cursor-pointer border border-red-500/20 bg-red-500/5 flex items-center justify-between",children:g.jsx("span",{children:"Zuweisung entfernen"})}),Ae.map(Le=>{var Cn;const Ke=ee[Le.name],ut=Le.role===T,Kt=!!(Ke!=null&&Ke.recommended),un=!!Ke&&!Ke.suitable;return g.jsxs("button",{onClick:()=>re(Le.name),className:nt("w-full text-left px-3 py-2.5 rounded-lg text-xs hover:bg-accent flex items-center justify-between font-mono cursor-pointer border",Kt?"border-primary/50 bg-primary/10":ut?"text-primary font-bold bg-primary/5 border-primary/30":un?"border-border/20 bg-background/10 opacity-60":"text-foreground bg-background/20 border-border/30"),children:[g.jsxs("div",{className:"flex flex-col text-left min-w-0",children:[g.jsxs("span",{className:"truncate max-w-[260px] font-semibold flex items-center gap-1.5",children:[(Cn=Le.name.split("/").pop())==null?void 0:Cn.replace(/\.gguf$/i,""),Kt&&g.jsx("span",{className:"text-[8px] font-bold uppercase tracking-wide text-primary bg-primary/15 px-1.5 py-0.5 rounded",children:"Empfohlen"})]}),g.jsx("span",{className:"text-[9px] text-muted-foreground mt-0.5",children:Ke?`${Ke.params_b}B · ${Le.quant} · ${Ke.reason}`:`${Ho(Le.size_bytes)} · ${Le.quant}`})]}),ut&&g.jsx(bo,{className:"h-4 w-4 shrink-0 text-primary"})]},Le.name)})]})]})})})(),D&&g.jsx(Lfe,{model:D,onClose:()=>F(null),onChanged:_}),V&&g.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4",children:g.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border/80 bg-card p-6 shadow-2xl space-y-4 animate-in fade-in zoom-in-95 duration-200",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/20 pb-2",children:[g.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-1.5",children:[g.jsx(qc,{className:"h-4 w-4"})," Agent-Hirn wechseln"]}),g.jsx("button",{onClick:()=>O(!1),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground cursor-pointer",children:g.jsx(Bc,{className:"h-4 w-4"})})]}),g.jsxs("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:["Wähle ein ",g.jsx("strong",{className:"text-foreground",children:"installiertes"})," Modell als Agent-Hirn. Es bekommt den",g.jsx("code",{className:"text-primary",children:" hermes"}),'-Alias, wird warm gehalten (brains-Gruppe), und Hermes nutzt es nach einem kurzen Gateway-Restart. Neues Modell (z.B. Hermes-4.3 oder Gemma-4)? Erst über „Modelle finden" laden.']}),g.jsx("div",{className:"space-y-1.5 max-h-72 overflow-y-auto pr-1",children:y.map(ue=>{var Ae;const ee=ue.role==="hermes";return g.jsxs("button",{onClick:()=>!ee&&Qe(ue.name),disabled:ee||ue.incomplete,className:nt("w-full text-left px-3 py-2.5 rounded-lg text-xs flex items-center justify-between font-mono border transition-all",ee?"border-indigo-500/40 bg-indigo-500/10 text-indigo-300":ue.incomplete?"border-border/20 bg-background/10 text-muted-foreground/50 cursor-not-allowed":"border-border/30 bg-background/20 text-foreground hover:bg-accent cursor-pointer"),children:[g.jsxs("div",{className:"flex flex-col min-w-0",children:[g.jsx("span",{className:"font-semibold truncate max-w-[280px]",children:(Ae=ue.name.split("/").pop())==null?void 0:Ae.replace(/\.gguf$/i,"")}),g.jsxs("span",{className:"text-[9px] text-muted-foreground mt-0.5",children:[ue.capabilities.params_b?`${ue.capabilities.params_b}B`:"?"," · ",Ho(ue.size_bytes),ue.role&&` · Rolle: ${ue.role}`,ue.capabilities.tools!=="no"?" · Tools ✓":" · ohne Tools"]})]}),ee?g.jsxs("span",{className:"text-[9px] font-bold uppercase text-indigo-300 shrink-0 flex items-center gap-1",children:[g.jsx(bo,{className:"h-3.5 w-3.5"})," Aktiv"]}):g.jsx("span",{className:"text-[9px] font-bold uppercase text-primary/70 shrink-0",children:"Als Hirn setzen →"})]},ue.name)})}),g.jsxs("div",{className:"text-[10px] text-amber-400/80 flex items-start gap-1.5 border-t border-border/20 pt-2.5",children:[g.jsx("span",{children:"💡"}),g.jsxs("span",{children:["Für einen ",g.jsx("strong",{children:"Agenten"})," sind Hermes-Modelle (natives Tool-Calling) meist die robustere Wahl als allgemeine Modelle."]})]})]})}),m]})}function jfe(){const[t,e]=R.useState(""),[n,r]=R.useState([]),[i,s]=R.useState("Q4_K_M"),[o,a]=R.useState(""),[l,c]=R.useState(""),[d,f]=R.useState(""),[m,y]=R.useState([]),[x,S]=R.useState(null),[_,w]=R.useState(!1),E=["fast","heavy","coder","vision","scout"],{data:T}=qh(),C=l?T==null?void 0:T.models.find(H=>(H.role||"").toLowerCase()===l):void 0;async function k(H,ne,J){if(w(!1),!H.trim()){S(null);return}try{const de=await Ut(`/api/fit?params_b=0&quant=${encodeURIComponent(ne)}&ctx=8192&name=${encodeURIComponent(H)}&role=${encodeURIComponent(J)}`);S(de)}catch{S(null)}}async function N(H){const ne=H??t;if(ne.trim()){a("Analysiere HuggingFace Repository..."),S(null);try{const J=await Ut(`/api/hf/quants?repo=${encodeURIComponent(ne)}`);e(J.repo),r(J.quants);const de=J.quants.length?J.quants.includes("Q4_K_M")?"Q4_K_M":J.quants[0]:i;J.quants.length&&s(de),a(J.quants.length?"":"Keine GGUF-Dateien in diesem Repository gefunden."),J.quants.length&&k(J.repo,de,l)}catch(J){a(`Fehler: ${J}`)}}}function D(H){s(H),k(t,H,l)}function F(H){c(H),n.length&&k(t,i,H)}async function V(){if(d.trim()){a("Durchsuche HuggingFace...");try{const H=await Ut(`/api/hf/search?q=${encodeURIComponent(d)}`);y(H.results),a(H.results.length?"":"Keine Ergebnisse gefunden.")}catch(H){a(`Suche fehlgeschlagen: ${H}`)}}}async function O(){if(t.trim()){if((x==null?void 0:x.fit.level)==="too_tight"&&!_){w(!0);return}a("Download-Job wird initiiert...");try{await Ut("/api/models/install",{method:"POST",body:JSON.stringify({repo:t,quant:i,role:l||void 0,jinja:!0})}),w(!1),a(`Download gestartet: ${t} (${i})${l?`, Rolle: ${l}`:""}. Fortschritt oben.`+(C?` „${l}" wurde von ${C.name} übernommen.`:"")+(l==="fast"||l==="coder"?" Speculative Draft (Vocab-geprüft) kannst du nach dem Download an der Modellkarte (»Spec«) setzen.":""))}catch(H){a(`Download-Fehler: ${H}`)}}}const U=(x==null?void 0:x.fit.level)==="perfect"?"text-emerald-400 border-emerald-500/40 bg-emerald-500/10":(x==null?void 0:x.fit.level)==="marginal"?"text-amber-400 border-amber-500/40 bg-amber-500/10":"text-red-400 border-red-500/40 bg-red-500/10";return g.jsxs("div",{className:"space-y-4 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10",children:[g.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"HF Download & Suche"}),g.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[g.jsx("input",{value:t,onChange:H=>{e(H.target.value),S(null),w(!1)},placeholder:"HF-URL oder org/repo (z.B. unsloth/Qwen2.5-Coder-7B-Instruct-GGUF)",className:"flex-1 h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx("button",{onClick:()=>N(),className:"h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer whitespace-nowrap",children:"Quants laden"}),n.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("select",{value:i,onChange:H=>D(H.target.value),className:"h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none text-foreground font-semibold",children:n.map(H=>g.jsx("option",{value:H,className:"bg-popover text-foreground",children:H},H))}),g.jsxs("select",{value:l,onChange:H=>F(H.target.value),title:"Rolle (optional) — bestimmt Auto-Konfiguration + setup-bewussten Kontext",className:"h-9 rounded-lg border border-border/60 bg-background/40 px-3 text-xs outline-none text-foreground font-semibold",children:[g.jsx("option",{value:"",className:"bg-popover text-foreground",children:"Rolle…"}),E.map(H=>g.jsx("option",{value:H,className:"bg-popover text-foreground",children:H},H))]}),g.jsx("button",{onClick:O,className:`h-9 px-4 rounded-lg text-xs font-semibold transition-all cursor-pointer flex items-center gap-1.5 ${_?"bg-red-500 text-white hover:opacity-90":"bg-primary text-primary-foreground hover:opacity-90"}`,children:_?g.jsxs(g.Fragment,{children:[g.jsx(xg,{className:"h-3.5 w-3.5"})," OOM-Risiko — trotzdem laden"]}):g.jsxs(g.Fragment,{children:[g.jsx(vg,{className:"h-3.5 w-3.5"})," Herunterladen"]})})]})]})]}),x&&g.jsxs("div",{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border px-3 py-2 text-[11px] font-medium ${U}`,children:[g.jsx("span",{className:"font-bold uppercase tracking-wide",children:x.fit.text}),g.jsxs("span",{className:"font-mono opacity-90",children:["~",x.params_b,"B · ~",x.fit.req_gb," GB / ",x.sys_ram_gb," GB RAM · ~",x.fit.tps," t/s"]}),x.fit.level!=="too_tight"&&g.jsxs("span",{className:"font-mono opacity-80",title:`Setup-bewusst: GTT ${x.budget.gtt_gb} GB − reserviert ${x.budget.reserved_gb} GB (${x.budget.mode}) → ${x.budget.budget_gb} GB frei`,children:["ctx → ",(x.assigned_ctx/1024).toFixed(0),"k"]}),x.fit.level==="too_tight"&&g.jsx("span",{className:"opacity-90",children:"— passt nicht in den Speicher, würde beim Laden abstürzen (OOM)."})]}),C&&g.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] font-medium text-amber-400",children:[g.jsx(xg,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),g.jsxs("span",{children:["Rolle ",g.jsxs("strong",{children:["„",l,'"']})," ist aktuell ",g.jsx("strong",{children:C.name})," zugewiesen. Beim Download übernimmt das neue Modell diese Rolle — ",C.name," bleibt installiert, verliert sie aber."]})]}),g.jsxs("div",{className:"flex gap-2 border-t border-border/20 pt-4",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx("input",{value:d,onChange:H=>f(H.target.value),onKeyDown:H=>H.key==="Enter"&&V(),placeholder:"HuggingFace durchsuchen (z.B. Llama-3.1)...",className:"w-full h-9 pl-9 pr-3 rounded-lg border border-border/60 bg-background/40 text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"}),g.jsx(xP,{className:"absolute left-3 top-2.5 h-3.5 w-3.5 text-muted-foreground"})]}),g.jsx("button",{onClick:V,className:"h-9 px-4 rounded-lg border border-border/60 bg-background/20 text-xs font-semibold hover:border-primary/50 hover:bg-background/40 transition-all cursor-pointer",children:"Suchen"})]}),m.length>0&&g.jsx("div",{className:"max-h-48 space-y-1.5 overflow-y-auto border border-border/40 bg-background/20 p-2 rounded-xl scrollbar-thin",children:m.map(H=>g.jsxs("button",{onClick:()=>{e(H.repo),y([]),f(""),N(H.repo)},className:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-xs bg-background/10 border border-border/10 hover:border-primary/30 hover:bg-background/30 transition-all",children:[g.jsx("span",{className:"font-semibold truncate",children:H.repo}),g.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground flex items-center gap-1 shrink-0",children:[g.jsx(vg,{className:"h-3 w-3"})," ",H.downloads.toLocaleString()]})]},H.repo))}),o&&g.jsx("div",{className:"text-[10px] font-medium text-primary font-mono",children:o})]})}const Ufe={fast:{title:"Schnelles Alltags-Hirn",desc:"Schnelle MoE-Antworten für Chat, Zusammenfassungen und alltägliche Aufgaben.",icon:xh},heavy:{title:"Schweres Reasoning",desc:"Große Modelle für komplexe Logik, Mathematik und tiefgründiges Planen.",icon:V1},coder:{title:"Coden & Entwicklung",desc:"Autovervollständigung, Refactoring und Codegenerierung direkt in deiner IDE.",icon:sF},vision:{title:"Bilder & Vision",desc:"Verarbeitet Bilder, Screenshots und visuelle Diagramme in multimodalen Chats.",icon:RT},scout:{title:"Multimodal-Allrounder",desc:"Multimodaler Allrounder für schnelle Antworten, Übersetzungen und Alltag.",icon:PT}};function Ffe(){const{data:t,isLoading:e,error:n}=_7(),{data:r}=qh(),{data:i}=TP(),s=(r==null?void 0:r.models)??[],o=n?String(n):"",[a,l]=R.useState({}),[c,d]=R.useState({}),[f,m]=R.useState(!1);async function y(x,S,_,w){l(E=>({...E,[x]:"Starte..."}));try{await Ut("/api/models/install",{method:"POST",body:JSON.stringify({repo:x,role:S,quant:_,jinja:w})}),l(E=>({...E,[x]:"Download läuft"}))}catch{l(T=>({...T,[x]:"Fehler"}))}}return e?g.jsx("div",{className:"text-xs text-muted-foreground py-12 text-center",children:"Analysiere Hardware und suche passende GGUF-Empfehlungen…"}):o||!t?g.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Empfehlungsdienst temporär nicht erreichbar (",o,")."]}):g.jsxs("div",{className:"space-y-8",children:[g.jsxs("div",{className:"text-[10px] font-mono text-muted-foreground bg-background/25 border border-border/40 p-4 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-sm",children:[g.jsxs("div",{children:["Modell-Registry geladen für ",g.jsxs("span",{className:"text-foreground font-bold",children:[t.sys_ram_gb," GB"]})," System-RAM."]}),g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx(i9,{className:"h-3.5 w-3.5 text-primary fill-primary/20"}),g.jsx("span",{children:"Empfehlungen sind automatisch auf deine Box-Hardware optimiert."})]})]}),g.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:t.categories.map(x=>{const S=Ufe[x.role]||{title:x.title||x.role,desc:"Spezifisches Modell für diese Systemrolle.",icon:G1},_=S.icon,w=s.find(D=>D.role===x.role),E=i==null?void 0:i.model_list.find(D=>D.role===x.role),T=x.models.find(D=>D.repo===x.recommended)||x.models[0];if(!T)return null;const C=a[T.repo],k=x.models.filter(D=>D.repo!==x.recommended),N=!!c[x.role];return g.jsxs("div",{className:nt("rounded-2xl border bg-card/45 backdrop-blur-md p-5 shadow-lg shadow-black/10 flex flex-col justify-between gap-5 transition-all duration-300 hover:border-primary/40",w?"border-border/60":"border-primary/20 shadow-primary/5"),children:[g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-start justify-between gap-3",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center text-primary shadow-sm shrink-0",children:g.jsx(_,{className:"h-5.5 w-5.5"})}),g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-bold tracking-tight text-foreground",children:S.title}),g.jsxs("span",{className:"text-[9px] font-mono text-muted-foreground uppercase bg-background/50 px-1.5 py-0.5 rounded border border-border/30 inline-block mt-0.5",children:["Rolle: ",x.role]})]})]}),w?g.jsxs("span",{className:"flex items-center gap-1.5 text-[9px] font-bold text-emerald-400 uppercase tracking-wider bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-1 rounded-lg",children:[g.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Aktiviert"]}):g.jsx("span",{className:"text-[9px] font-bold text-primary/70 uppercase tracking-wider bg-primary/10 border border-primary/20 px-2.5 py-1 rounded-lg",children:"Frei"})]}),g.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:S.desc}),g.jsx("div",{className:"p-3.5 rounded-xl bg-background/35 border border-border/30 space-y-2.5",children:w?g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-muted-foreground/60",children:"Aktive GGUF-Belegung"}),g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:w.name,children:w.name.split("/").pop()}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2",children:[g.jsxs("span",{children:["Größe: ",zT(w.size_bytes||0)]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Quant: ",w.quant||"GGUF"]})]})]}):g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-primary/80",children:"Empfohlenes Modell"}),g.jsx("div",{className:"text-xs font-mono font-bold text-foreground truncate",title:T.name,children:T.name}),g.jsxs("div",{className:"text-[10px] text-muted-foreground/80 flex items-center gap-2 flex-wrap",children:[g.jsxs("span",{children:["Ersteller: ",T.author]}),g.jsx("span",{children:"•"}),g.jsxs("span",{children:["Quant: ",T.quant]})]}),g.jsx("div",{className:"flex items-center gap-1.5 pt-0.5",children:g.jsx(iX,{fit:T.fit})})]})}),g.jsx("div",{className:"pt-1",children:w?E?g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"text-[9px] font-semibold text-amber-400 flex items-center gap-1.5",children:[g.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-ping shrink-0"}),g.jsxs("span",{children:["Bessere Version in der Registry: ",E.repo.split("/").pop()]})]}),g.jsxs("button",{onClick:()=>y(E.repo,x.role,T.quant||"Q4_K_M",T.caps.tools!=="no"),disabled:!!a[E.repo],className:"h-8 w-full flex items-center justify-center gap-1.5 rounded-lg bg-amber-500 text-black text-xs font-bold hover:bg-amber-400 disabled:opacity-50 transition-all cursor-pointer shadow-md shadow-amber-500/10",children:[g.jsx(vg,{className:"h-3.5 w-3.5"}),a[E.repo]||"Auf neue Version aktualisieren"]})]}):g.jsxs("div",{className:"h-8 flex items-center justify-center gap-1.5 text-[10px] font-bold text-emerald-400 uppercase tracking-wide bg-emerald-500/5 border border-emerald-500/10 rounded-lg select-none",children:[g.jsx(bo,{className:"h-4 w-4"})," Auf neuestem Stand"]}):g.jsxs("button",{onClick:()=>y(T.repo,x.role,T.quant||"Q4_K_M",T.caps.tools!=="no"),disabled:!!C,className:nt("h-8 w-full flex items-center justify-center gap-1.5 rounded-lg text-xs font-bold transition-all cursor-pointer border",C?"border-primary/40 bg-primary/5 text-primary":"bg-primary text-primary-foreground hover:opacity-90 shadow-md shadow-primary/10"),children:[g.jsx(vg,{className:"h-3.5 w-3.5"}),C||"Optimales Modell einsetzen"]})})]}),k.length>0&&g.jsxs("div",{className:"border-t border-border/20 pt-3",children:[g.jsxs("button",{onClick:()=>d(D=>({...D,[x.role]:!N})),className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/80 hover:text-foreground transition-colors cursor-pointer",children:[N?g.jsx(A8,{className:"h-3 w-3"}):g.jsx(M8,{className:"h-3 w-3"}),g.jsxs("span",{children:["Alternative Empfehlungen anzeigen (",k.length,")"]})]}),N&&g.jsx("div",{className:"mt-2.5 space-y-2 max-h-36 overflow-y-auto pr-1 scrollbar-thin",children:k.map(D=>g.jsxs("div",{className:"p-2 rounded-lg bg-background/25 border border-border/20 flex items-center justify-between gap-3",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-[10px] font-mono font-bold text-foreground truncate",title:D.name,children:D.name}),g.jsxs("div",{className:"text-[9px] text-muted-foreground flex items-center gap-1.5 mt-0.5",children:[g.jsxs("span",{children:["Quant: ",D.quant]}),g.jsx("span",{children:"•"}),g.jsx("span",{children:D.fit.text})]})]}),g.jsx("button",{onClick:()=>y(D.repo,x.role,D.quant||"Q4_K_M",D.caps.tools!=="no"),disabled:!!a[D.repo],className:"h-6 px-2.5 rounded bg-background/40 hover:bg-background/80 border border-border/40 text-[9px] font-bold text-foreground transition-all cursor-pointer shrink-0 disabled:opacity-50",children:a[D.repo]||"Installieren"})]},D.repo))})]})]},x.role)})}),g.jsxs("div",{className:"border border-border/50 bg-card/20 rounded-2xl overflow-hidden shadow-md mt-4",children:[g.jsxs("button",{onClick:()=>m(!f),className:"w-full px-5 py-4 flex items-center justify-between text-xs font-bold uppercase tracking-wider text-muted-foreground hover:bg-card/30 transition-colors cursor-pointer",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(xP,{className:"h-4 w-4 text-primary"}),g.jsx("span",{children:"Eigenes Modell von Hugging Face laden (Erweiterte Ansicht)"})]}),g.jsx("span",{className:"text-[10px] text-primary hover:underline",children:f?"Ausblenden ▲":"Anzeigen ▼"})]}),f&&g.jsx("div",{className:"p-5 border-t border-border/20 bg-card/10",children:g.jsx(jfe,{})})]})]})}function zfe(){const[t,e]=R.useState("cockpit");return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex flex-col sm:flex-row justify-between sm:items-center gap-4",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Modell-Manager"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"Verwalte deine Modelle und passe das Gateway-Routing live über das interaktive Cockpit an."})]}),g.jsx("div",{className:"flex rounded-xl border border-border/60 bg-card/45 backdrop-blur-md p-1 self-start",children:["cockpit","discover"].map(n=>g.jsx("button",{onClick:()=>e(n),className:nt("rounded-lg px-4 py-1.5 text-xs font-semibold tracking-wide uppercase transition-all cursor-pointer",t===n?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"text-muted-foreground hover:text-foreground"),children:n==="cockpit"?"Cockpit":"Modelle finden"},n))})]}),g.jsx(Ofe,{}),g.jsx("div",{className:"transition-all duration-300",children:t==="cockpit"?g.jsx(Dfe,{}):g.jsx(Ffe,{})})]})}const Bfe={cline:"cline_settings.json",cursor:"Settings → Models",opencode:"opencode.jsonc",zed:"settings.json",continue:"~/.continue/config.json",claude_code:"~/.zshrc / env"};function k3({line:t,loading:e}){return e||!t?g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-muted-foreground",children:[g.jsx(yP,{className:"h-3 w-3 animate-spin"})," prüfe…"]}):t.ok?g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-emerald-400",children:[g.jsx(T8,{className:"h-3 w-3"})," ",t.detail]}):g.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold text-red-400",children:[g.jsx(P8,{className:"h-3 w-3"})," ",t.detail]})}function O3({tool:t,fileName:e,accent:n,copied:r,onCopy:i}){return g.jsxs("div",{className:"flex flex-col border border-border/60 bg-black/60 rounded-2xl overflow-hidden shadow-2xl",children:[g.jsxs("div",{className:"flex h-11 items-center justify-between px-4 border-b border-border/40 bg-black/40 shrink-0",children:[g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-3 w-3 rounded-full bg-red-500/80"}),g.jsx("span",{className:"h-3 w-3 rounded-full bg-amber-500/80"}),g.jsx("span",{className:"h-3 w-3 rounded-full bg-emerald-500/80"})]}),g.jsx("div",{className:"flex items-center gap-1.5 text-[10px] font-mono text-muted-foreground/75 bg-background/30 px-3 py-1 rounded-md border border-border/20",children:g.jsx("span",{children:e})}),g.jsxs("button",{onClick:i,className:"flex h-7 px-2.5 items-center gap-1.5 rounded-lg border border-border/40 bg-background/30 text-[10px] font-semibold text-muted-foreground hover:text-foreground hover:bg-background/60 transition-all cursor-pointer",children:[r?g.jsx(bo,{className:"h-3.5 w-3.5 text-emerald-400"}):g.jsx(ew,{className:"h-3.5 w-3.5"}),g.jsx("span",{children:r?"Kopiert":"Kopieren"})]})]}),g.jsx("pre",{className:nt("p-5 overflow-x-auto text-xs font-mono whitespace-pre leading-relaxed scrollbar-thin select-text bg-black/10",n==="teal"?"text-cyan-200/90":"text-violet-200/90"),children:g.jsx("code",{children:t.snippet})})]})}function Hfe(){const[t,e]=R.useState(localStorage.getItem("mc_host")||"192.168.178.151"),[n,r]=R.useState(localStorage.getItem("mc_mcp_path")||""),[i,s]=R.useState("cline"),[o,a]=R.useState(null),l=new URLSearchParams({host:t});n&&l.set("mcp_path",n);const{data:c,error:d}=GF(l.toString()),{data:f,isLoading:m}=S7(),y=d?String(d):"";function x(E){e(E),E&&localStorage.setItem("mc_host",E)}function S(E){r(E),localStorage.setItem("mc_mcp_path",E)}const _=c==null?void 0:c.tools[i];async function w(E,T){T&&(await navigator.clipboard.writeText(T),a(E),setTimeout(()=>a(null),1500))}return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Verbindung & Integration"}),g.jsxs("p",{className:"text-sm text-muted-foreground",children:["Binde deinen lokalen Agenten an die Box an — über ",g.jsx("span",{className:"text-foreground",children:"zwei getrennte Leitungen"}),": das Modell (Gateway) und das geteilte Gedächtnis (MCP)."]})]}),g.jsxs("div",{className:"p-5 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md shadow-lg shadow-black/10",children:[g.jsxs("div",{className:"grid gap-4 md:grid-cols-[170px_1fr] items-center",children:[g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-background/40 p-4 text-center",children:[g.jsx(F8,{className:"h-7 w-7 mx-auto text-muted-foreground"}),g.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:"Dein lokaler Agent"}),g.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Cline · Cursor · Zed …"})]}),g.jsxs("div",{className:"flex flex-col gap-2.5",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(iI,{className:"h-4 w-4 text-muted-foreground shrink-0"}),g.jsxs("div",{className:"flex-1 rounded-xl border border-primary/25 bg-primary/5 px-3.5 py-2.5",children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-primary",children:[g.jsx(El,{className:"h-3.5 w-3.5"})," Leitung 1 — Modell"]}),g.jsx(k3,{line:f==null?void 0:f.gateway,loading:m})]}),g.jsx("div",{className:"mt-1 text-[11px] font-mono text-primary/80",children:"Gateway · :9001/v1 · model auto"})]})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(iI,{className:"h-4 w-4 text-muted-foreground shrink-0"}),g.jsxs("div",{className:"flex-1 rounded-xl border border-violet-500/25 bg-violet-500/5 px-3.5 py-2.5",children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-violet-300",children:[g.jsx(V1,{className:"h-3.5 w-3.5"})," Leitung 2 — Gedächtnis"]}),g.jsx(k3,{line:f==null?void 0:f.memory,loading:m})]}),g.jsx("div",{className:"mt-1 text-[11px] font-mono text-violet-300/80",children:"MCP · mcp_memory.py · separat"})]})]})]})]}),g.jsxs("p",{className:"mt-3.5 text-[11px] text-muted-foreground leading-relaxed",children:["Der Gateway liefert ",g.jsx("span",{className:"text-foreground",children:"nur das LLM"}),". Das geteilte Gedächtnis läuft über einen",g.jsx("span",{className:"text-foreground",children:" eigenen MCP-Server"})," — beide werden unabhängig eingerichtet."]})]}),g.jsxs("div",{className:"grid gap-4 md:grid-cols-2 p-5 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md shadow-lg shadow-black/10",children:[g.jsxs("div",{className:"space-y-1.5",children:[g.jsxs("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[g.jsx(j8,{className:"h-3.5 w-3.5 text-primary"})," Box LAN IP-Adresse"]}),g.jsx("input",{value:t,onChange:E=>x(E.target.value),placeholder:"z.B. 192.168.178.151",className:"w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-primary/50 text-foreground"})]}),g.jsxs("div",{className:"space-y-1.5",children:[g.jsxs("label",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[g.jsx(L8,{className:"h-3.5 w-3.5 text-violet-400"})," Lokaler MCP-Scriptpfad",g.jsx("span",{className:"text-violet-400/70 normal-case font-semibold tracking-normal",children:"(nur Leitung 2)"})]}),g.jsx("input",{value:n,onChange:E=>S(E.target.value),placeholder:"z.B. F:\\Coding Stuff\\mission-control-2\\mcp\\mcp_memory.py",className:"w-full h-9 rounded-lg border border-border/60 bg-background/40 px-3 font-mono text-xs outline-none focus:ring-1 focus:ring-violet-500/50 text-foreground"})]})]}),y&&g.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-xs text-red-400",children:["Fehler beim Generieren der Snippets: ",y]}),c&&g.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[g.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/60 border-t-2 border-t-primary/70 bg-card/30 p-4",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm font-space font-bold text-foreground",children:[g.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-primary/15 text-primary text-[11px]",children:"1"}),"Modell anbinden"]}),g.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Wähle dein Tool — das Snippet zeigt auf den Gateway."})]}),g.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(c.tools).map(([E,T])=>g.jsx("button",{onClick:()=>s(E),className:nt("rounded-lg px-3 py-1.5 text-[11px] font-semibold tracking-wide transition-all cursor-pointer",i===E?"bg-primary text-primary-foreground shadow-md shadow-primary/10":"border border-border/50 text-muted-foreground hover:text-foreground"),children:T.label},E))}),_&&g.jsxs(g.Fragment,{children:[_.note&&g.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-xl bg-primary/5 border border-primary/20 text-[11px] text-muted-foreground leading-relaxed",children:[g.jsx(oI,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),g.jsx("span",{children:_.note})]}),g.jsx(O3,{tool:_,fileName:Bfe[i]||"config.json",accent:"teal",copied:o==="model",onCopy:()=>w("model",_.snippet)})]})]}),g.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/60 border-t-2 border-t-violet-500/70 bg-card/30 p-4",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm font-space font-bold text-foreground",children:[g.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md bg-violet-500/15 text-violet-300 text-[11px]",children:"2"}),"Gedächtnis anbinden",g.jsx("span",{className:"text-[10px] font-medium text-muted-foreground normal-case",children:"optional"})]}),g.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:["Ein MCP-Block — gilt zusätzlich für ",g.jsx("em",{children:"jedes"})," Tool aus Schritt 1."]})]}),g.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-xl bg-violet-500/5 border border-violet-500/20 text-[11px] text-muted-foreground leading-relaxed",children:[g.jsx(oI,{className:"h-4 w-4 text-violet-400 shrink-0 mt-0.5"}),g.jsx("span",{children:c.memory.note})]}),g.jsx(O3,{tool:c.memory,fileName:"mcp.json",accent:"violet",copied:o==="memory",onCopy:()=>w("memory",c.memory.snippet)})]})]})]})}const Vfe="modulepreload",Gfe=function(t){return"/"+t},L3={},Wfe=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=Gfe(c),c in L3)return;L3[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":Vfe,d||(m.as="script"),m.crossOrigin="",m.href=c,l&&m.setAttribute("nonce",l),document.head.appendChild(m),d)return new Promise((y,x)=>{m.addEventListener("load",y),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};class $fe extends R.Component{constructor(){super(...arguments);fo(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?g.jsxs("div",{className:"h-[480px] rounded-2xl border border-red-500/20 bg-red-500/5 p-6 text-xs text-red-400 overflow-auto",children:[g.jsx("div",{className:"font-semibold mb-2",children:"Graph konnte nicht gerendert werden"}),g.jsx("pre",{className:"whitespace-pre-wrap break-words text-[11px] leading-relaxed",children:this.state.error.message})]}):this.props.children}}const Xfe=R.lazy(()=>Wfe(()=>import("./GraphView-D0BHEwUM.js"),[]).then(t=>({default:t.GraphView}))),D3=["identity","knowledge","rules","events"],j3=new Set(["auto","agent","hermes"]),$E={identity:{label:"Identität",icon:o9,bg:"bg-cyan-500/10",text:"text-cyan-400"},knowledge:{label:"Wissen",icon:s0,bg:"bg-indigo-500/10",text:"text-indigo-400"},rules:{label:"Regeln",icon:e9,bg:"bg-violet-500/10",text:"text-violet-400"},events:{label:"Ereignisse",icon:R8,bg:"bg-amber-500/10",text:"text-amber-400"}},U3={label:"Gedächtnis",icon:TT,bg:"bg-muted/10",text:"text-muted-foreground"},qfe={identity:"border-l-cyan-500/80",knowledge:"border-l-indigo-500/80",rules:"border-l-violet-500/80",events:"border-l-amber-500/80"},F3=`Hi Hermes! Lass uns ein kurzes Onboarding machen, damit du dich künftig an mich erinnerst. Stell mir nacheinander ein paar kurze Fragen zu: 1) wer ich bin und woran ich gerade arbeite, 2) wie ich angesprochen werden möchte, 3) meine bevorzugten Tools, Sprachen und Arbeitsweise, @@ -5443,7 +5443,7 @@ void main() { * Copyright (c) 2019-2026 pixiv Inc. * @pixiv/three-vrm-springbone is distributed under MIT License * https://github.com/pixiv/three-vrm/blob/release/LICENSE - */const q1e={leftUpperArm:[0,0,1.2],rightUpperArm:[0,0,-1.2],leftLowerArm:[0,-.2,0],rightLowerArm:[0,.2,0]};function vl(t,e,n,r,i){var o;const s=(o=t.humanoid)==null?void 0:o.getNormalizedBoneNode(e);s&&s.rotation.set(n,r,i)}function K1e(t){var e;for(const[n,r]of Object.entries(q1e))vl(t,n,r[0],r[1],r[2]);(e=t.humanoid)==null||e.update()}function Y1e(t,e,n){const r=Math.sin(e*1.7),i=Math.sin(e*.5),s=Math.min(1,n*1.4);vl(t,"spine",r*.025,i*.03,Math.sin(e*.43)*.015),vl(t,"chest",r*.02,i*.02,0),vl(t,"hips",0,Math.sin(e*.37)*.02,Math.sin(e*.29)*.01),vl(t,"neck",Math.sin(e*.8)*.03+s*.06,Math.sin(e*.31)*.05,0),vl(t,"head",Math.sin(e*.6)*.025+s*.05,Math.sin(e*.27)*.06,Math.sin(e*.5)*.02);const o=Math.sin(e*.8)*.04;vl(t,"leftUpperArm",0,0,1.2+o),vl(t,"rightUpperArm",0,0,-1.2-o),vl(t,"leftLowerArm",0,-.2-Math.sin(e*.8)*.03,0),vl(t,"rightLowerArm",0,.2+Math.sin(e*.8)*.03,0)}const Z1e=["happy","angry","sad","surprised","relaxed"],Q1e={neutral:null,happy:"happy",angry:"angry",sad:"sad",surprised:"surprised",relaxed:"relaxed"};function J1e({url:t,audioLevel:e,emotion:n,onError:r}){const[i,s]=R.useState(null),o=R.useRef({}),a=R.useRef({t:0,next:3,active:0});return R.useEffect(()=>{let l=!1,c=null;const d=new n_e;return d.register(f=>new M1e(f)),d.load(t,f=>{var y;if(l)return;const m=f.userData.vrm;if(!m){r("Datei enthält kein gültiges VRM-Modell.");return}Xc.removeUnnecessaryVertices(f.scene),((y=m.meta)==null?void 0:y.metaVersion)==="0"&&Xc.rotateVRM0(m),m.scene.rotation.y=Math.PI,K1e(m),c=m,s(m)},void 0,f=>{console.error("VRM-Load-Fehler:",f),r("Avatar konnte nicht geladen werden (CORS/URL?).")}),()=>{l=!0,c&&Xc.deepDispose(c.scene),s(null)}},[t,r]),xG((l,c)=>{var m;if(!i)return;const d=((m=e.current)==null?void 0:m.current)??0;Y1e(i,l.clock.elapsedTime,d);const f=i.expressionManager;if(f){const y=(o.current.aa??0)*.4+d*.6;o.current.aa=y,f.setValue("aa",y);const x=Q1e[n.current];for(const w of Z1e){const E=x===w?.75:0,T=o.current[w]??0,C=T+(E-T)*Math.min(1,c*4);o.current[w]=C,f.setValue(w,C)}const S=a.current;S.t+=c,S.active<=0&&S.t>S.next&&(S.active=.16,S.t=0,S.next=3+Math.random()*4);let _=0;if(S.active>0){S.active-=c;const w=1-S.active/.16;_=1-Math.abs(w-.5)*2}f.setValue("blink",Math.max(0,_))}i.update(c)}),i?g.jsx("primitive",{object:i.scene}):null}function eSe({url:t,audioLevel:e,emotion:n}){const[r,i]=R.useState(null);return g.jsxs("div",{className:"relative h-full w-full",children:[g.jsxs($be,{camera:{position:[0,1.35,1.25],fov:30},gl:{alpha:!0,antialias:!0},style:{background:"transparent"},children:[g.jsx("ambientLight",{intensity:.85}),g.jsx("directionalLight",{position:[1,2,2],intensity:1.1}),g.jsx("directionalLight",{position:[-1,1,-1],intensity:.4}),g.jsx(J1e,{url:t,audioLevel:e,emotion:n,onError:i},t),g.jsx(t_e,{target:[0,1.3,0],enablePan:!1,minDistance:.7,maxDistance:3,minPolarAngle:Math.PI/3,maxPolarAngle:Math.PI/1.8})]}),r&&g.jsx("div",{className:"absolute inset-x-0 bottom-3 mx-auto w-fit rounded-md bg-red-500/15 border border-red-500/30 px-3 py-1.5 text-xs text-red-300",children:r})]})}const tSe="mc2-voice",j0="avatar",KG="uploaded-vrm";function YG(){return new Promise((t,e)=>{const n=indexedDB.open(tSe,1);n.onupgradeneeded=()=>n.result.createObjectStore(j0),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)})}async function nSe(t){const e=await YG();await new Promise((n,r)=>{const i=e.transaction(j0,"readwrite");i.objectStore(j0).put(t,KG),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async function rSe(){const t=await YG();return new Promise((e,n)=>{const i=t.transaction(j0,"readonly").objectStore(j0).get(KG);i.onsuccess=()=>e(i.result??null),i.onerror=()=>n(i.error)})}const ZG=[{id:"sample-a",label:"VRoid Sample A",url:"https://raw.githubusercontent.com/madjin/vrm-samples/master/vroid/stable/AvatarSample_A.vrm",note:"Anime, weiblich"},{id:"sample-b",label:"VRoid Sample B",url:"https://raw.githubusercontent.com/madjin/vrm-samples/master/vroid/stable/AvatarSample_B.vrm",note:"Anime, männlich"},{id:"pixiv",label:"Pixiv Demo",url:"https://raw.githubusercontent.com/pixiv/three-vrm/dev/packages/three-vrm/examples/models/VRM1_Constraint_Twist_Sample.vrm",note:"VRM1-Testmodell"}],iSe=ZG[0].url;function sSe({avatarUrl:t,onAvatarChange:e}){const[n,r]=R.useState(""),[i,s]=R.useState([]),[o,a]=R.useState(localStorage.getItem("mc_voice_engine")||"piper"),[l,c]=R.useState(localStorage.getItem("mc_voice_voice")||""),[d,f]=R.useState(!1),m=R.useRef(null),y=R.useRef(null),x=async()=>{var k;if(!d){f(!0);try{const N=await fetch("/api/voice/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"Hallo! Ich bin deine Assistentin. So klingt diese Stimme auf Deutsch.",engine:o,voice:l})});if(!N.ok)throw new Error(`TTS ${N.status}`);const D=URL.createObjectURL(await N.blob());(k=y.current)==null||k.pause();const F=new Audio(D);y.current=F,F.onended=()=>URL.revokeObjectURL(D),await F.play()}catch(N){console.error("Probe fehlgeschlagen:",N)}finally{f(!1)}}};R.useEffect(()=>{localStorage.getItem("mc_voice_avatar_uploaded")==="1"&&rSe().then(k=>{k&&e(URL.createObjectURL(new Blob([k],{type:"model/gltf-binary"})))})},[e]),R.useEffect(()=>{fetch("/api/voice/voices").then(k=>k.ok?k.json():Promise.reject()).then(k=>s(k.voices||[])).catch(()=>s([]))},[]);const S=k=>{localStorage.setItem("mc_voice_avatar_url",k),localStorage.removeItem("mc_voice_avatar_uploaded"),e(k)},_=async k=>{const N=await k.arrayBuffer();await nSe(N),localStorage.setItem("mc_voice_avatar_uploaded","1"),localStorage.removeItem("mc_voice_avatar_url"),e(URL.createObjectURL(new Blob([N],{type:"model/gltf-binary"})))},w=()=>{const k=n.trim();k&&S(k)},E=(k,N)=>{a(k),c(N),localStorage.setItem("mc_voice_engine",k),localStorage.setItem("mc_voice_voice",N)},T=["edge","piper","chatterbox","elevenlabs"],C=i.filter(k=>k.engine===o);return g.jsxs("div",{className:"space-y-5 text-sm",children:[g.jsxs("div",{children:[g.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Avatar"}),g.jsx("div",{className:"space-y-1.5",children:ZG.map(k=>{const N=t===k.url;return g.jsxs("button",{onClick:()=>S(k.url),className:`flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition-colors ${N?"border-primary/50 bg-primary/10 text-primary":"border-border/40 hover:bg-accent"}`,children:[g.jsxs("span",{children:[g.jsx("span",{className:"font-medium",children:k.label}),k.note&&g.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground",children:k.note})]}),N&&g.jsx(bo,{className:"h-4 w-4"})]},k.id)})})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("input",{ref:m,type:"file",accept:".vrm,model/gltf-binary",className:"hidden",onChange:k=>{var D;const N=(D=k.target.files)==null?void 0:D[0];N&&_(N)}}),g.jsxs("button",{onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},className:"flex w-full items-center gap-2 rounded-md border border-border/40 bg-background/40 px-3 py-2 hover:bg-accent transition-colors",children:[g.jsx(s9,{className:"h-4 w-4"})," Eigenes .vrm hochladen"]}),g.jsxs("div",{className:"flex gap-1.5",children:[g.jsx("input",{value:n,onChange:k=>r(k.target.value),onKeyDown:k=>k.key==="Enter"&&w(),placeholder:"…oder VRM-URL einfügen",className:"min-w-0 flex-1 rounded-md border border-border/40 bg-background/40 px-2.5 py-2 text-xs outline-none focus:border-primary/50"}),g.jsx("button",{onClick:w,className:"rounded-md border border-border/40 bg-background/40 px-2.5 hover:bg-accent",title:"Laden",children:g.jsx(V8,{className:"h-4 w-4"})})]}),g.jsxs("a",{href:"https://hub.vroid.com/en/characters",target:"_blank",rel:"noopener",className:"flex items-center gap-1.5 text-xs text-primary/80 hover:text-primary",children:[g.jsx(yg,{className:"h-3.5 w-3.5"})," Mehr Avatare auf VRoid Hub (kostenlos) → herunterladen & hochladen"]})]}),g.jsxs("div",{children:[g.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[g.jsx(Vm,{className:"h-3.5 w-3.5"})," Stimme"]}),i.length===0?g.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-300",children:"Voice-Dienst nicht erreichbar — Stimmen werden geladen, sobald der Sidecar läuft."}):g.jsxs("div",{className:"space-y-2",children:[g.jsx("div",{className:"flex gap-1.5",children:T.map(k=>g.jsx("button",{onClick:()=>E(k,""),className:`flex-1 rounded-md border px-2.5 py-1.5 text-xs capitalize transition-colors ${o===k?"border-primary/50 bg-primary/10 text-primary":"border-border/40 hover:bg-accent"}`,children:k==="edge"?"Edge (natürlich · gratis)":k==="piper"?"Piper (lokal)":k==="chatterbox"?"Chatterbox (lokal)":k==="elevenlabs"?"ElevenLabs (premium)":k},k))}),g.jsxs("select",{value:l,onChange:k=>E(o,k.target.value),className:"w-full rounded-md border border-border/40 bg-background/40 px-2.5 py-2 text-xs outline-none focus:border-primary/50",children:[g.jsx("option",{value:"",children:"Standardstimme"}),C.map(k=>g.jsxs("option",{value:k.id,children:[k.label,k.clonable?" · klonbar":""]},k.id))]}),g.jsxs("button",{onClick:x,disabled:d,className:"flex w-full items-center justify-center gap-2 rounded-md border border-primary/40 bg-primary/10 px-2.5 py-2 text-xs text-primary hover:bg-primary/20 transition-colors disabled:opacity-60",children:[d?g.jsx(yP,{className:"h-3.5 w-3.5 animate-spin"}):g.jsx(cF,{className:"h-3.5 w-3.5"}),d?"Spielt …":"Probe hören"]}),o==="edge"&&g.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Edge-TTS: native deutsche Azure-Stimmen — sehr natürlich, kein Akzent, gratis & ohne Key. Probier ",g.jsx("code",{children:"Seraphina"})," oder ",g.jsx("code",{children:"Katja"}),". Echte Kinder-/Jungstimmen (Gisela) gäbe es nur über Azure direkt (Key). Cloud (Text → Microsoft)."]}),o==="chatterbox"&&g.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Chatterbox läuft auf CPU → erste Antwort kann ein paar Sekunden dauern. Lokal + Voice-Cloning (dt. mit Akzent)."}),o==="elevenlabs"&&g.jsx("p",{className:"text-[11px] text-muted-foreground",children:"ElevenLabs: sauberes natives Deutsch, junge/Anime-Stimmen via Voice Library. Cloud, Free-Tier ~50 kurze Antworten/Monat."}),o==="elevenlabs"&&i.filter(k=>k.engine==="elevenlabs").length===0&&g.jsxs("p",{className:"text-[11px] text-amber-300",children:["Noch kein ElevenLabs-Key hinterlegt — Stimmen erscheinen, sobald der Key in ",g.jsx("code",{children:"~/.hermes/.env"})," steht."]})]})]})]})}function oSe(t){const[e,n]=R.useState(!1),r=R.useRef(null),i=R.useRef([]),s=R.useRef(null),o=R.useCallback(async()=>{if(r.current)return;let l;try{l=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(f){console.error("Mikrofon-Zugriff verweigert:",f);return}s.current=l;const c=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",d=new MediaRecorder(l,{mimeType:c});i.current=[],d.ondataavailable=f=>{f.data.size&&i.current.push(f.data)},d.onstop=()=>{var m;const f=new Blob(i.current,{type:c});(m=s.current)==null||m.getTracks().forEach(y=>y.stop()),s.current=null,r.current=null,n(!1),f.size>1200&&t(f)},d.start(),r.current=d,n(!0)},[t]),a=R.useCallback(()=>{var l;(l=r.current)==null||l.stop()},[]);return R.useEffect(()=>()=>{var l,c;(l=r.current)==null||l.stop(),(c=s.current)==null||c.getTracks().forEach(d=>d.stop())},[]),{recording:e,start:o,stop:a}}class aSe{constructor(){fo(this,"ctx");fo(this,"analyser");fo(this,"queue",[]);fo(this,"playing",!1);fo(this,"raf",0);fo(this,"freq");fo(this,"level",{current:0});fo(this,"onSpeaking");const e=window.AudioContext||window.webkitAudioContext;this.ctx=new e,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=256,this.analyser.smoothingTimeConstant=.6,this.analyser.connect(this.ctx.destination),this.freq=new Uint8Array(new ArrayBuffer(this.analyser.frequencyBinCount))}async enqueue(e){this.queue.push(e),this.playing||await this.playNext()}clear(){this.queue=[]}async playNext(){var i,s;const e=this.queue.shift();if(!e){this.playing=!1,this.stopMeter(),(i=this.onSpeaking)==null||i.call(this,!1);return}if(this.playing=!0,(s=this.onSpeaking)==null||s.call(this,!0),this.ctx.state==="suspended")try{await this.ctx.resume()}catch{}let n;try{n=await this.ctx.decodeAudioData(e.slice(0))}catch{return this.playNext()}const r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.analyser),r.onended=()=>{this.playNext()},r.start(),this.startMeter()}startMeter(){cancelAnimationFrame(this.raf);const e=()=>{this.analyser.getByteFrequencyData(this.freq);const n=Math.min(this.freq.length,48);let r=0;for(let s=2;s{if(!l.current){const E=new aSe;E.onSpeaking=T=>e(C=>T?"speaking":C==="speaking"?"idle":C),l.current=E,o.current=E.level}return l.current},[]),f=R.useCallback(async E=>{var O,U,H,ne;s(null);const T=d();T.clear(),e("transcribing");let C="";try{const J=new FormData;J.append("audio",E,"rec.webm");const de=await fetch("/api/voice/stt",{method:"POST",body:J});if(!de.ok)throw new Error(`STT ${de.status}`);C=((O=(await de.json()).text)==null?void 0:O.trim())||""}catch(J){e("error"),s(`Spracherkennung fehlgeschlagen: ${J.message}`);return}if(!C){e("idle");return}r(J=>[...J,{role:"user",text:C}]),e("thinking");const{engine:k,voice:N}=dSe();let D="",F="";r(J=>[...J,{role:"assistant",text:""}]);const V=J=>{J.trim()&&fetch("/api/voice/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:J,engine:k,voice:N})}).then(de=>de.ok?de.arrayBuffer():Promise.reject(new Error(`TTS ${de.status}`))).then(de=>T.enqueue(de)).catch(de=>console.error("TTS-Fehler:",de))};try{const J=await fetch("/api/voice/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:C,session_id:c.current,system:uSe})});if(!J.ok||!J.body)throw new Error(`Agent ${J.status}`);const de=J.body.getReader(),oe=new TextDecoder;let he="";for(;;){const{done:B,value:K}=await de.read();if(B)break;he+=oe.decode(K,{stream:!0});const q=he.split(` + */const q1e={leftUpperArm:[0,0,1.2],rightUpperArm:[0,0,-1.2],leftLowerArm:[0,-.2,0],rightLowerArm:[0,.2,0]};function vl(t,e,n,r,i){var o;const s=(o=t.humanoid)==null?void 0:o.getNormalizedBoneNode(e);s&&s.rotation.set(n,r,i)}function K1e(t){var e;for(const[n,r]of Object.entries(q1e))vl(t,n,r[0],r[1],r[2]);(e=t.humanoid)==null||e.update()}function Y1e(t,e,n){const r=Math.sin(e*1.7),i=Math.sin(e*.5),s=Math.min(1,n*1.4);vl(t,"spine",r*.025,i*.03,Math.sin(e*.43)*.015),vl(t,"chest",r*.02,i*.02,0),vl(t,"hips",0,Math.sin(e*.37)*.02,Math.sin(e*.29)*.01),vl(t,"neck",Math.sin(e*.8)*.03+s*.06,Math.sin(e*.31)*.05,0),vl(t,"head",Math.sin(e*.6)*.025+s*.05,Math.sin(e*.27)*.06,Math.sin(e*.5)*.02);const o=Math.sin(e*.8)*.04;vl(t,"leftUpperArm",0,0,1.2+o),vl(t,"rightUpperArm",0,0,-1.2-o),vl(t,"leftLowerArm",0,-.2-Math.sin(e*.8)*.03,0),vl(t,"rightLowerArm",0,.2+Math.sin(e*.8)*.03,0)}const Z1e=["happy","angry","sad","surprised","relaxed"],Q1e={neutral:null,happy:"happy",angry:"angry",sad:"sad",surprised:"surprised",relaxed:"relaxed"};function J1e({url:t,audioLevel:e,emotion:n,onError:r}){const[i,s]=R.useState(null),o=R.useRef({}),a=R.useRef({t:0,next:3,active:0});return R.useEffect(()=>{let l=!1,c=null;const d=new n_e;return d.register(f=>new M1e(f)),d.load(t,f=>{var y;if(l)return;const m=f.userData.vrm;if(!m){r("Datei enthält kein gültiges VRM-Modell.");return}Xc.removeUnnecessaryVertices(f.scene),((y=m.meta)==null?void 0:y.metaVersion)==="0"&&Xc.rotateVRM0(m),m.scene.rotation.y=Math.PI,K1e(m),c=m,s(m)},void 0,f=>{console.error("VRM-Load-Fehler:",f),r("Avatar konnte nicht geladen werden (CORS/URL?).")}),()=>{l=!0,c&&Xc.deepDispose(c.scene),s(null)}},[t,r]),xG((l,c)=>{var m;if(!i)return;const d=((m=e.current)==null?void 0:m.current)??0;Y1e(i,l.clock.elapsedTime,d);const f=i.expressionManager;if(f){const y=(o.current.aa??0)*.4+d*.6;o.current.aa=y,f.setValue("aa",y);const x=Q1e[n.current];for(const w of Z1e){const E=x===w?.75:0,T=o.current[w]??0,C=T+(E-T)*Math.min(1,c*4);o.current[w]=C,f.setValue(w,C)}const S=a.current;S.t+=c,S.active<=0&&S.t>S.next&&(S.active=.16,S.t=0,S.next=3+Math.random()*4);let _=0;if(S.active>0){S.active-=c;const w=1-S.active/.16;_=1-Math.abs(w-.5)*2}f.setValue("blink",Math.max(0,_))}i.update(c)}),i?g.jsx("primitive",{object:i.scene}):null}function eSe({url:t,audioLevel:e,emotion:n}){const[r,i]=R.useState(null);return g.jsxs("div",{className:"relative h-full w-full",children:[g.jsxs($be,{camera:{position:[0,1.35,1.25],fov:30},gl:{alpha:!0,antialias:!0},style:{background:"transparent"},children:[g.jsx("ambientLight",{intensity:.85}),g.jsx("directionalLight",{position:[1,2,2],intensity:1.1}),g.jsx("directionalLight",{position:[-1,1,-1],intensity:.4}),g.jsx(J1e,{url:t,audioLevel:e,emotion:n,onError:i},t),g.jsx(t_e,{target:[0,1.3,0],enablePan:!1,minDistance:.7,maxDistance:3,minPolarAngle:Math.PI/3,maxPolarAngle:Math.PI/1.8})]}),r&&g.jsx("div",{className:"absolute inset-x-0 bottom-3 mx-auto w-fit rounded-md bg-red-500/15 border border-red-500/30 px-3 py-1.5 text-xs text-red-300",children:r})]})}const tSe="mc2-voice",j0="avatar",KG="uploaded-vrm";function YG(){return new Promise((t,e)=>{const n=indexedDB.open(tSe,1);n.onupgradeneeded=()=>n.result.createObjectStore(j0),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)})}async function nSe(t){const e=await YG();await new Promise((n,r)=>{const i=e.transaction(j0,"readwrite");i.objectStore(j0).put(t,KG),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async function rSe(){const t=await YG();return new Promise((e,n)=>{const i=t.transaction(j0,"readonly").objectStore(j0).get(KG);i.onsuccess=()=>e(i.result??null),i.onerror=()=>n(i.error)})}const ZG=[{id:"sample-a",label:"VRoid Sample A",url:"https://raw.githubusercontent.com/madjin/vrm-samples/master/vroid/stable/AvatarSample_A.vrm",note:"Anime, weiblich"},{id:"sample-b",label:"VRoid Sample B",url:"https://raw.githubusercontent.com/madjin/vrm-samples/master/vroid/stable/AvatarSample_B.vrm",note:"Anime, männlich"},{id:"pixiv",label:"Pixiv Demo",url:"https://raw.githubusercontent.com/pixiv/three-vrm/dev/packages/three-vrm/examples/models/VRM1_Constraint_Twist_Sample.vrm",note:"VRM1-Testmodell"}],iSe=ZG[0].url;function sSe({avatarUrl:t,onAvatarChange:e}){const[n,r]=R.useState(""),[i,s]=R.useState([]),[o,a]=R.useState(localStorage.getItem("mc_voice_engine")||"piper"),[l,c]=R.useState(localStorage.getItem("mc_voice_voice")||""),[d,f]=R.useState(!1),m=R.useRef(null),y=R.useRef(null),x=async()=>{var k;if(!d){f(!0);try{const N=await fetch("/api/voice/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"Hallo! Ich bin deine Assistentin. So klingt diese Stimme auf Deutsch.",engine:o,voice:l})});if(!N.ok)throw new Error(`TTS ${N.status}`);const D=URL.createObjectURL(await N.blob());(k=y.current)==null||k.pause();const F=new Audio(D);y.current=F,F.onended=()=>URL.revokeObjectURL(D),await F.play()}catch(N){console.error("Probe fehlgeschlagen:",N)}finally{f(!1)}}};R.useEffect(()=>{localStorage.getItem("mc_voice_avatar_uploaded")==="1"&&rSe().then(k=>{k&&e(URL.createObjectURL(new Blob([k],{type:"model/gltf-binary"})))})},[e]),R.useEffect(()=>{fetch("/api/voice/voices").then(k=>k.ok?k.json():Promise.reject()).then(k=>s(k.voices||[])).catch(()=>s([]))},[]);const S=k=>{localStorage.setItem("mc_voice_avatar_url",k),localStorage.removeItem("mc_voice_avatar_uploaded"),e(k)},_=async k=>{const N=await k.arrayBuffer();await nSe(N),localStorage.setItem("mc_voice_avatar_uploaded","1"),localStorage.removeItem("mc_voice_avatar_url"),e(URL.createObjectURL(new Blob([N],{type:"model/gltf-binary"})))},w=()=>{const k=n.trim();k&&S(k)},E=(k,N)=>{a(k),c(N),localStorage.setItem("mc_voice_engine",k),localStorage.setItem("mc_voice_voice",N)},T=["edge","piper","chatterbox","elevenlabs"],C=i.filter(k=>k.engine===o);return g.jsxs("div",{className:"space-y-5 text-sm",children:[g.jsxs("div",{children:[g.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Avatar"}),g.jsx("div",{className:"space-y-1.5",children:ZG.map(k=>{const N=t===k.url;return g.jsxs("button",{onClick:()=>S(k.url),className:`flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition-colors ${N?"border-primary/50 bg-primary/10 text-primary":"border-border/40 hover:bg-accent"}`,children:[g.jsxs("span",{children:[g.jsx("span",{className:"font-medium",children:k.label}),k.note&&g.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground",children:k.note})]}),N&&g.jsx(bo,{className:"h-4 w-4"})]},k.id)})})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("input",{ref:m,type:"file",accept:".vrm,model/gltf-binary",className:"hidden",onChange:k=>{var D;const N=(D=k.target.files)==null?void 0:D[0];N&&_(N)}}),g.jsxs("button",{onClick:()=>{var k;return(k=m.current)==null?void 0:k.click()},className:"flex w-full items-center gap-2 rounded-md border border-border/40 bg-background/40 px-3 py-2 hover:bg-accent transition-colors",children:[g.jsx(s9,{className:"h-4 w-4"})," Eigenes .vrm hochladen"]}),g.jsxs("div",{className:"flex gap-1.5",children:[g.jsx("input",{value:n,onChange:k=>r(k.target.value),onKeyDown:k=>k.key==="Enter"&&w(),placeholder:"…oder VRM-URL einfügen",className:"min-w-0 flex-1 rounded-md border border-border/40 bg-background/40 px-2.5 py-2 text-xs outline-none focus:border-primary/50"}),g.jsx("button",{onClick:w,className:"rounded-md border border-border/40 bg-background/40 px-2.5 hover:bg-accent",title:"Laden",children:g.jsx(V8,{className:"h-4 w-4"})})]}),g.jsxs("a",{href:"https://hub.vroid.com/en/characters",target:"_blank",rel:"noopener",className:"flex items-center gap-1.5 text-xs text-primary/80 hover:text-primary",children:[g.jsx(yg,{className:"h-3.5 w-3.5"})," Mehr Avatare auf VRoid Hub (kostenlos) → herunterladen & hochladen"]})]}),g.jsxs("div",{children:[g.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[g.jsx(Vm,{className:"h-3.5 w-3.5"})," Stimme"]}),i.length===0?g.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-300",children:"Voice-Dienst nicht erreichbar — Stimmen werden geladen, sobald der Sidecar läuft."}):g.jsxs("div",{className:"space-y-2",children:[g.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:T.map(k=>g.jsx("button",{onClick:()=>E(k,""),className:`rounded-md border px-2.5 py-1.5 text-xs transition-colors ${o===k?"border-primary/50 bg-primary/10 text-primary":"border-border/40 hover:bg-accent"}`,children:k==="edge"?"Edge (natürlich · gratis)":k==="piper"?"Piper (lokal)":k==="chatterbox"?"Chatterbox (lokal)":k==="elevenlabs"?"ElevenLabs (premium)":k},k))}),g.jsxs("select",{value:l,onChange:k=>E(o,k.target.value),className:"w-full rounded-md border border-border/40 bg-background/40 px-2.5 py-2 text-xs outline-none focus:border-primary/50",children:[g.jsx("option",{value:"",children:"Standardstimme"}),C.map(k=>g.jsxs("option",{value:k.id,children:[k.label,k.clonable?" · klonbar":""]},k.id))]}),g.jsxs("button",{onClick:x,disabled:d,className:"flex w-full items-center justify-center gap-2 rounded-md border border-primary/40 bg-primary/10 px-2.5 py-2 text-xs text-primary hover:bg-primary/20 transition-colors disabled:opacity-60",children:[d?g.jsx(yP,{className:"h-3.5 w-3.5 animate-spin"}):g.jsx(cF,{className:"h-3.5 w-3.5"}),d?"Spielt …":"Probe hören"]}),o==="edge"&&g.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Edge-TTS: native deutsche Azure-Stimmen — sehr natürlich, kein Akzent, gratis & ohne Key. Probier ",g.jsx("code",{children:"Seraphina"})," oder ",g.jsx("code",{children:"Katja"}),". Echte Kinder-/Jungstimmen (Gisela) gäbe es nur über Azure direkt (Key). Cloud (Text → Microsoft)."]}),o==="chatterbox"&&g.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Chatterbox läuft auf CPU → erste Antwort kann ein paar Sekunden dauern. Lokal + Voice-Cloning (dt. mit Akzent)."}),o==="elevenlabs"&&g.jsx("p",{className:"text-[11px] text-muted-foreground",children:"ElevenLabs: sauberes natives Deutsch, junge/Anime-Stimmen via Voice Library. Cloud, Free-Tier ~50 kurze Antworten/Monat."}),o==="elevenlabs"&&i.filter(k=>k.engine==="elevenlabs").length===0&&g.jsxs("p",{className:"text-[11px] text-amber-300",children:["Noch kein ElevenLabs-Key hinterlegt — Stimmen erscheinen, sobald der Key in ",g.jsx("code",{children:"~/.hermes/.env"})," steht."]})]})]})]})}function oSe(t){const[e,n]=R.useState(!1),r=R.useRef(null),i=R.useRef([]),s=R.useRef(null),o=R.useCallback(async()=>{if(r.current)return;let l;try{l=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(f){console.error("Mikrofon-Zugriff verweigert:",f);return}s.current=l;const c=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",d=new MediaRecorder(l,{mimeType:c});i.current=[],d.ondataavailable=f=>{f.data.size&&i.current.push(f.data)},d.onstop=()=>{var m;const f=new Blob(i.current,{type:c});(m=s.current)==null||m.getTracks().forEach(y=>y.stop()),s.current=null,r.current=null,n(!1),f.size>1200&&t(f)},d.start(),r.current=d,n(!0)},[t]),a=R.useCallback(()=>{var l;(l=r.current)==null||l.stop()},[]);return R.useEffect(()=>()=>{var l,c;(l=r.current)==null||l.stop(),(c=s.current)==null||c.getTracks().forEach(d=>d.stop())},[]),{recording:e,start:o,stop:a}}class aSe{constructor(){fo(this,"ctx");fo(this,"analyser");fo(this,"queue",[]);fo(this,"playing",!1);fo(this,"raf",0);fo(this,"freq");fo(this,"level",{current:0});fo(this,"onSpeaking");const e=window.AudioContext||window.webkitAudioContext;this.ctx=new e,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=256,this.analyser.smoothingTimeConstant=.6,this.analyser.connect(this.ctx.destination),this.freq=new Uint8Array(new ArrayBuffer(this.analyser.frequencyBinCount))}async enqueue(e){this.queue.push(e),this.playing||await this.playNext()}clear(){this.queue=[]}async playNext(){var i,s;const e=this.queue.shift();if(!e){this.playing=!1,this.stopMeter(),(i=this.onSpeaking)==null||i.call(this,!1);return}if(this.playing=!0,(s=this.onSpeaking)==null||s.call(this,!0),this.ctx.state==="suspended")try{await this.ctx.resume()}catch{}let n;try{n=await this.ctx.decodeAudioData(e.slice(0))}catch{return this.playNext()}const r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.analyser),r.onended=()=>{this.playNext()},r.start(),this.startMeter()}startMeter(){cancelAnimationFrame(this.raf);const e=()=>{this.analyser.getByteFrequencyData(this.freq);const n=Math.min(this.freq.length,48);let r=0;for(let s=2;s{if(!l.current){const E=new aSe;E.onSpeaking=T=>e(C=>T?"speaking":C==="speaking"?"idle":C),l.current=E,o.current=E.level}return l.current},[]),f=R.useCallback(async E=>{var O,U,H,ne;s(null);const T=d();T.clear(),e("transcribing");let C="";try{const J=new FormData;J.append("audio",E,"rec.webm");const de=await fetch("/api/voice/stt",{method:"POST",body:J});if(!de.ok)throw new Error(`STT ${de.status}`);C=((O=(await de.json()).text)==null?void 0:O.trim())||""}catch(J){e("error"),s(`Spracherkennung fehlgeschlagen: ${J.message}`);return}if(!C){e("idle");return}r(J=>[...J,{role:"user",text:C}]),e("thinking");const{engine:k,voice:N}=dSe();let D="",F="";r(J=>[...J,{role:"assistant",text:""}]);const V=J=>{J.trim()&&fetch("/api/voice/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:J,engine:k,voice:N})}).then(de=>de.ok?de.arrayBuffer():Promise.reject(new Error(`TTS ${de.status}`))).then(de=>T.enqueue(de)).catch(de=>console.error("TTS-Fehler:",de))};try{const J=await fetch("/api/voice/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:C,session_id:c.current,system:uSe})});if(!J.ok||!J.body)throw new Error(`Agent ${J.status}`);const de=J.body.getReader(),oe=new TextDecoder;let he="";for(;;){const{done:B,value:K}=await de.read();if(B)break;he+=oe.decode(K,{stream:!0});const q=he.split(` `);he=q.pop()||"";for(const $ of q){const Z=$.split(` `).find($e=>$e.startsWith("data:"));if(!Z)continue;const ge=Z.slice(5).trim();if(ge==="[DONE]")continue;let ae;try{ae=JSON.parse(ge)}catch{continue}if(ae.error)throw new Error(ae.error);const ce=((ne=(H=(U=ae.choices)==null?void 0:U[0])==null?void 0:H.delta)==null?void 0:ne.content)||"";if(!ce)continue;D+=ce,F+=ce,a.current=cSe(D),r($e=>{const Se=$e.slice();return Se[Se.length-1]={role:"assistant",text:D},Se});const{sentences:we,rest:Me}=fSe(F);F=Me,we.forEach(V)}}F.trim()&&V(F),D.trim()||e("idle")}catch(J){e("error"),s(`Agent-Antwort fehlgeschlagen: ${J.message}`)}},[d]),{recording:m,start:y,stop:x}=oSe(f),S=R.useCallback(()=>{d(),e("listening"),y()},[d,y]),_=R.useCallback(()=>{x()},[x]),w=R.useCallback(()=>{var E;(E=l.current)==null||E.clear(),r([]),s(null),e("idle"),localStorage.removeItem("mc_voice_session"),c.current=RU()},[]);return R.useEffect(()=>{!m&&t==="listening"&&e("transcribing")},[m,t]),{status:t,messages:n,error:i,recording:m,audioLevel:o,emotion:a,pressStart:S,pressEnd:_,reset:w}}const pSe={idle:"Bereit — halte zum Sprechen",listening:"Höre zu …",transcribing:"Verstehe …",thinking:"Hermes denkt …",speaking:"Hermes spricht …",error:"Fehler"};function mSe(){const[t,e]=R.useState(()=>localStorage.getItem("mc_voice_avatar_url")||iSe),{status:n,messages:r,error:i,recording:s,audioLevel:o,emotion:a,pressStart:l,pressEnd:c,reset:d}=hSe(),f=R.useRef(!1),m=R.useCallback(S=>e(S),[]);R.useEffect(()=>{const S=E=>E instanceof HTMLElement&&/^(INPUT|TEXTAREA|SELECT)$/.test(E.tagName),_=E=>{E.code!=="Space"||E.repeat||f.current||S(E.target)||(E.preventDefault(),f.current=!0,l())},w=E=>{E.code!=="Space"||!f.current||(E.preventDefault(),f.current=!1,c())};return window.addEventListener("keydown",_),window.addEventListener("keyup",w),()=>{window.removeEventListener("keydown",_),window.removeEventListener("keyup",w)}},[l,c]);const y=n==="speaking",x=n==="transcribing"||n==="thinking";return g.jsxs("div",{className:"flex h-full gap-5",children:[g.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col rounded-xl border border-border/40 bg-card/30 overflow-hidden",children:[g.jsx("div",{className:"flex-1 min-h-0",children:g.jsx(eSe,{url:t,audioLevel:o,emotion:a})}),g.jsxs("div",{className:"shrink-0 flex flex-col items-center gap-3 border-t border-border/40 bg-background/30 py-5 backdrop-blur-sm",children:[g.jsxs("div",{className:nt("flex items-center gap-2 text-sm",n==="error"?"text-red-400":y?"text-primary":"text-muted-foreground"),children:[x&&g.jsx(yP,{className:"h-4 w-4 animate-spin"}),y&&g.jsx(cF,{className:"h-4 w-4 animate-pulse"}),g.jsx("span",{children:i||pSe[n]})]}),g.jsx("button",{onPointerDown:S=>{S.preventDefault(),f.current=!0,l()},onPointerUp:()=>{f.current&&(f.current=!1,c())},onPointerLeave:()=>{f.current&&(f.current=!1,c())},className:nt("flex h-20 w-20 items-center justify-center rounded-full border-2 transition-all select-none touch-none",s?"border-red-500 bg-red-500/20 scale-110 shadow-lg shadow-red-500/30":"border-primary/60 bg-primary/15 hover:bg-primary/25 hover:scale-105"),title:"Gedrückt halten zum Sprechen (oder Leertaste halten)",children:g.jsx(oF,{className:nt("h-8 w-8",s?"text-red-400":"text-primary")})}),g.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Halten zum Sprechen · ",g.jsx("kbd",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:"Leertaste"})," geht auch"]})]})]}),g.jsxs("div",{className:"flex w-80 shrink-0 flex-col gap-4",children:[g.jsx("div",{className:"rounded-xl border border-border/40 bg-card/40 p-4 overflow-y-auto scrollbar-thin max-h-[55%]",children:g.jsx(sSe,{avatarUrl:t,onAvatarChange:m})}),g.jsxs("div",{className:"flex min-h-0 flex-1 flex-col rounded-xl border border-border/40 bg-card/40",children:[g.jsxs("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2.5",children:[g.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Gespräch"}),g.jsx("button",{onClick:d,className:"text-muted-foreground hover:text-foreground",title:"Neues Gespräch",children:g.jsx(J8,{className:"h-3.5 w-3.5"})})]}),g.jsxs("div",{className:"flex-1 space-y-2.5 overflow-y-auto p-4 scrollbar-thin",children:[r.length===0&&g.jsx("p",{className:"text-xs text-muted-foreground",children:"Halte den Knopf (oder die Leertaste) und sprich. Hermes hört zu, denkt mit seinem vollen Gedächtnis und seinen Werkzeugen — und antwortet hörbar."}),r.map((S,_)=>g.jsxs("div",{className:nt("text-sm",S.role==="user"?"text-foreground":"text-primary/90"),children:[g.jsx("span",{className:"mr-1.5 text-[10px] font-semibold uppercase text-muted-foreground",children:S.role==="user"?"Du":"Hermes"}),S.text||g.jsx("span",{className:"text-muted-foreground",children:"…"})]},_))]})]})]})]})}const NU=[{id:"grundlagen",label:"Grundlagen"},{id:"moe",label:"MoE & Quant"},{id:"lokal",label:"Lokal betreiben"},{id:"modelle",label:"Modell-Landschaft"},{id:"gateway",label:"Gateway-Trick"},{id:"mcp",label:"MCP"},{id:"skills",label:"Skills"},{id:"memory",label:"Gedächtnis & RAG"},{id:"agents",label:"Agenten"},{id:"ide",label:"IDE anbinden"},{id:"tricks",label:"Tricks & Kniffe"},{id:"wartung",label:"Sicherheit & Wartung"},{id:"ressourcen",label:"Ressourcen"},{id:"troubleshooting",label:"Troubleshooting"}];function gSe(t){var e;(e=document.getElementById(t))==null||e.scrollIntoView({behavior:"smooth",block:"start"})}function mo({id:t,icon:e,color:n,title:r,kicker:i,children:s,wide:o}){return g.jsxs("section",{id:t,className:nt("scroll-mt-20 rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-6 shadow-lg shadow-black/10 space-y-3",o&&"md:col-span-2"),children:[g.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border/20 pb-3",children:[g.jsx(e,{className:nt("h-5 w-5 shrink-0",n)}),g.jsxs("div",{children:[g.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-foreground",children:r}),i&&g.jsx("span",{className:nt("text-[9px] font-mono",n),children:i})]})]}),g.jsx("div",{className:"text-xs text-muted-foreground space-y-2.5 leading-relaxed",children:s})]})}function Vf({children:t}){return g.jsxs("div",{className:"mt-1 rounded-xl border border-primary/25 bg-primary/[0.06] p-3 text-[11px] leading-relaxed",children:[g.jsxs("div",{className:"flex items-center gap-1.5 font-bold text-primary mb-1",children:[g.jsx(Vm,{className:"h-3 w-3"})," Bei dir konkret"]}),g.jsx("div",{className:"text-muted-foreground space-y-1",children:t})]})}function pn({children:t}){return g.jsx("code",{className:"rounded bg-background/40 border border-border/30 px-1.5 py-0.5 font-mono text-[10px] text-foreground",children:t})}function Or({href:t,name:e,note:n}){return g.jsxs("li",{className:"leading-relaxed",children:[g.jsxs("a",{href:t,target:"_blank",rel:"noopener",className:"text-primary hover:underline font-semibold inline-flex items-center gap-0.5",children:[e,g.jsx(_8,{className:"h-3 w-3 opacity-60"})]}),g.jsxs("span",{className:"text-muted-foreground",children:[" — ",n]})]})}function vSe(){const[t,e]=R.useState(!1);return g.jsxs("div",{className:"space-y-7",children:[g.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-6 shadow-lg shadow-black/10 flex items-start gap-4",children:[g.jsx("div",{className:"h-11 w-11 rounded-xl bg-primary/15 flex items-center justify-center shrink-0",children:g.jsx(TT,{className:"h-6 w-6 text-primary"})}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("h1",{className:"text-2xl font-space font-bold tracking-tight bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text text-transparent",children:"Die AI-Bibel"}),g.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed max-w-2xl",children:["Allgemeines Nachschlagewerk für lokale & agentische AI — Konzepte, Tricks, Kniffe und kuratierte Quellen. ",g.jsx("span",{className:"font-semibold text-foreground",children:"Stand Juni 2026."})," ","Das meiste gilt überall; ",g.jsx("span",{className:"text-primary font-semibold",children:'„Bei dir konkret"'}),"-Kästen zeigen, was dein Stack daraus macht."]})]})]}),g.jsx("div",{className:"sticky top-0 z-10 -mx-1 px-1",children:g.jsx("div",{className:"rounded-xl border border-border/50 bg-card/70 backdrop-blur-xl p-2 shadow-lg shadow-black/20",children:g.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.jsx(PT,{className:"h-3.5 w-3.5 text-primary ml-1 mr-0.5 shrink-0"}),(t?NU:NU.slice(0,9)).map(n=>g.jsx("button",{onClick:()=>gSe(n.id),className:"rounded-lg px-2.5 py-1 text-[11px] font-semibold text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors cursor-pointer",children:n.label},n.id)),g.jsx("button",{onClick:()=>e(n=>!n),className:"rounded-lg px-2 py-1 text-[11px] font-semibold text-primary hover:bg-primary/10 transition-colors cursor-pointer",children:t?"weniger":"+ mehr"})]})})}),g.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[g.jsxs(mo,{id:"grundlagen",icon:El,color:"text-cyan-400",title:"1. Wie LLMs ticken",kicker:"Grundlagen",children:[g.jsxs("p",{children:["Ein LLM ist im Kern ein ",g.jsx("strong",{children:"Wahrscheinlichkeits-Rechner für das nächste Token"}),' (Wortteil). Es „weiß" nichts — es setzt fort, was statistisch am plausibelsten ist. Daraus folgt fast alles andere.']}),g.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[g.jsxs("li",{children:[g.jsx("strong",{children:"Tokens"})," sind die Einheit — ~¾ Wort. Ein- und Ausgabe werden in Tokens gezählt."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Kontextfenster"}),' = wie viele Tokens das Modell gleichzeitig „sehen" kann (Prompt + Antwort). Voll = Anfang fällt raus.']}),g.jsxs("li",{children:[g.jsx("strong",{children:"Parameter"})," = die trainierten Gewichte. Training ist einmalig, ",g.jsx("strong",{children:"Inferenz"})," ist jede Antwort."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Temperatur / Sampling"})," steuert Zufall: niedrig = deterministisch/präzise (Code), hoch = kreativ."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Halluzination"})," ist kein Bug, sondern die Kehrseite des Ratens. Gegenmittel: Grounding via Tools/RAG, Verifikation."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Reasoning-/Thinking-Modelle"}),' „denken" in unsichtbaren Tokens vor der Antwort — besser bei Logik, langsamer/teurer.']})]})]}),g.jsxs(mo,{id:"moe",icon:G1,color:"text-violet-400",title:"2. MoE & Quantisierung",kicker:"Mehr Modell, weniger Last",children:[g.jsxs("p",{children:[g.jsx("strong",{children:"Mixture of Experts (MoE):"})," Statt für jedes Token das ganze Netz zu aktivieren, wählt ein",g.jsx("em",{children:" Router"})," nur ein paar spezialisierte ",g.jsx("em",{children:"Experts"}),' aus. So läuft ein 100B-Modell mit der aktiven Rechenlast eines viel kleineren (z.B. „122B total / 10B aktiv").']}),g.jsxs("p",{children:[g.jsx("strong",{children:"Quantisierung:"})," Gewichte von FP16 auf weniger Bits eindampfen — kleiner & schneller bei minimalem Qualitätsverlust. Faustregel:"]}),g.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[g.jsxs("li",{children:[g.jsx(pn,{children:"Q8"})," nahezu verlustfrei, größter Footprint"]}),g.jsxs("li",{children:[g.jsx(pn,{children:"Q6_K"})," sehr gut, guter Mittelweg"]}),g.jsxs("li",{children:[g.jsx(pn,{children:"Q4_K_M"})," der Sweet-Spot für lokal — viel Modell pro GB"]})]}),g.jsxs(Vf,{children:["VRAM/RAM ist die harte Grenze — ",g.jsx("strong",{children:"darum"})," ist beides hier zentral: MoE lässt 100B+ überhaupt laufen, Quant entscheidet, was reinpasst. Dein Line-up fährt durchweg ",g.jsx(pn,{children:"Q4_K_M"}),"/",g.jsx(pn,{children:"Q6_K"}),"."]})]}),g.jsxs(mo,{id:"lokal",icon:bP,color:"text-emerald-400",title:"3. Lokal betreiben: Engines & Backends",kicker:"llama.cpp, vLLM & Co.",wide:!0,children:[g.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsxs("p",{children:[g.jsx("strong",{children:"Inference-Engines"})," — was die Modelle ausführt:"]}),g.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[g.jsxs("li",{children:[g.jsx("strong",{children:"llama.cpp / GGUF"})," — der De-facto-Standard für lokal, CPU+GPU, läuft überall."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Ollama / LM Studio"})," — bequeme Wrapper mit One-Click-Downloads (LM Studio mit GUI)."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"vLLM / TGI"})," — Server-Engines für maximalen Durchsatz auf dicken GPUs."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"llama-swap"})," — Proxy, der ",g.jsx("em",{children:"mehrere"})," Modelle hinter ",g.jsx("em",{children:"einem"})," Port hält und je nach Anfrage automatisch ein-/aussattelt."]})]})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("p",{children:[g.jsx("strong",{children:"GPU-Backends"})," — wie gerechnet wird:"]}),g.jsx("ul",{className:"list-disc pl-4 space-y-1",children:g.jsxs("li",{children:[g.jsx(pn,{children:"CUDA"})," NVIDIA · ",g.jsx(pn,{children:"ROCm"})," AMD · ",g.jsx(pn,{children:"Vulkan"})," herstellerübergreifend · ",g.jsx(pn,{children:"Metal"})," Apple"]})}),g.jsxs("p",{className:"pt-1",children:[g.jsx("strong",{children:"Begriffe, die immer wiederkommen:"})," Kontext (",g.jsx(pn,{children:"-c"}),"), Slots/Parallel, KV-Cache, Modell-TTL/Swap, ",g.jsx("strong",{children:"Speculative Decoding"})," (kleines Draft-Modell rät voraus → schneller)."]})]})]}),g.jsxs(Vf,{children:["Deine Box hat eine AMD-APU (gfx1151). ",g.jsx("strong",{children:"Einschränkung & Trick:"})," dort schlägt ",g.jsx(pn,{children:"Vulkan/RADV"})," das offizielle ",g.jsx(pn,{children:"ROCm"})," bei Token-Generierung um ~12–22 % — darum läuft die Engine auf Vulkan.",g.jsx(pn,{children:"llama-swap"})," hält die Alltags-Hirne dauerwarm; ",g.jsx(pn,{children:"coder"})," nutzt Spec-Decoding."]})]}),g.jsxs(mo,{id:"modelle",icon:CT,color:"text-sky-400",title:"4. Modell-Landschaft",kicker:"Stand Juni 2026",wide:!0,children:[g.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{children:g.jsx("strong",{children:"Open-Weight (lokal nutzbar):"})}),g.jsxs("ul",{className:"list-disc pl-4 space-y-1",children:[g.jsxs("li",{children:[g.jsx("strong",{children:"Qwen"})," (Alibaba) — starke Allrounder + Coder + Vision, viele Größen/MoE."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"Llama"})," (Meta), ",g.jsx("strong",{children:"Gemma"})," (Google), ",g.jsx("strong",{children:"Phi"})," (Microsoft) — solide Open-Familien."]}),g.jsxs("li",{children:[g.jsx("strong",{children:"DeepSeek"}),", ",g.jsx("strong",{children:"Mistral/Mixtral"})," — kräftige MoE-/Reasoning-Modelle."]})]})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{children:g.jsx("strong",{children:"Frontier (Cloud-API):"})}),g.jsx("ul",{className:"list-disc pl-4 space-y-1",children:g.jsxs("li",{children:[g.jsx("strong",{children:"Claude"})," (Anthropic), ",g.jsx("strong",{children:"GPT"})," (OpenAI), ",g.jsx("strong",{children:"Gemini"})," (Google) — die stärksten Allrounder, aber nicht lokal."]})}),g.jsxs("p",{className:"pt-1",children:[g.jsx("strong",{children:"Modellwahl nach Aufgabe:"})," schnelles Alltags-Hirn · großes Logik-Hirn für harte Tasks · dediziertes Code-Modell · multimodal für Bilder · Embedding-Modell fürs Gedächtnis."]})]})]}),g.jsx("p",{className:"text-[11px] italic",children:'Leaderboards (HF, LMArena) sind grobe Orientierung — der einzige Benchmark, der zählt, ist deine eigene Aufgabe. Vorsicht vor „Benchmaxxing".'}),g.jsxs(Vf,{children:["Dein Line-up via llama-swap: ",g.jsx(pn,{children:"fast"})," (Alltag/Vision/MoE) · ",g.jsx(pn,{children:"heavy"})," (schwere Logik) ·",g.jsx(pn,{children:"coder"})," · ",g.jsx(pn,{children:"scout"})," · ",g.jsx(pn,{children:"vision"})," · ",g.jsx(pn,{children:"embed"})," (fürs Gedächtnis) ·",g.jsx(pn,{children:"hermes"})," (Agent-Hirn). Verwalten/tauschen im ",g.jsx("strong",{children:"Modell-Manager"}),"-Tab."]})]}),g.jsxs(mo,{id:"gateway",icon:K8,color:"text-amber-400",title:"5. Der Gateway-Trick",kicker:"OpenAI-kompatibel = überall andocken",children:[g.jsxs("p",{children:["Fast jedes AI-Tool spricht heute das ",g.jsx("strong",{children:"OpenAI-Format"})," (",g.jsx(pn,{children:"/v1/chat/completions"}),"). Ein",g.jsx("strong",{children:" Gateway"})," davor gibt dir ",g.jsx("em",{children:"einen"})," Endpunkt für alles: zentrales Key-Management, Logging und transparentes ",g.jsx("strong",{children:"Routing"})," — der Client merkt nicht, welches Modell tatsächlich antwortet."]}),g.jsxs("p",{children:["Die ",g.jsx(pn,{children:"model:auto"}),'-Idee: du sagst „auto", das Gateway wählt das passende Modell je nach Anfrage und lädt es bei Bedarf.']}),g.jsxs(Vf,{children:["Dein Gateway: ",g.jsx(pn,{children:"http://192.168.178.151:9001/v1"}),", Model ",g.jsx(pn,{children:"auto"}),", API-Key beliebig. Fertige Configs erzeugt dir der ",g.jsx("strong",{children:"Verbinden"}),"-Tab live — eine Wahrheit, kein Abtippen."]})]}),g.jsxs(mo,{id:"mcp",icon:NT,color:"text-violet-400",title:"6. MCP — Werkzeuge für Agenten",kicker:"USB-C für AI-Tools",children:[g.jsxs("p",{children:["Das ",g.jsx("strong",{children:"Model Context Protocol"})," (offen, von Anthropic initiiert) standardisiert, wie ein AI-Client mit externen Tools & Datenquellen spricht. Ein ",g.jsx("strong",{children:"MCP-Server"})," bringt Fähigkeiten: Dateien, Web-Fetch, Git, Datenbanken, eigene APIs."]}),g.jsx("p",{children:"Statt für jeden Editor eigene Tools zu schreiben, bindet jeder MCP-fähige Agent denselben Server an."}),g.jsxs("div",{className:"flex items-start gap-1.5 rounded-xl border border-amber-500/25 bg-amber-500/[0.06] p-2.5 text-[11px]",children:[g.jsx(W8,{className:"h-3.5 w-3.5 text-amber-400 shrink-0 mt-0.5"}),g.jsxs("span",{children:[g.jsx("strong",{children:"Sicherheit:"})," ein MCP-Server hat echten Zugriff (Dateien, Shell). Nur vertrauenswürdige Server laufen lassen, Rechte minimal halten, Quelle prüfen."]})]})]}),g.jsxs(mo,{id:"skills",icon:Q8,color:"text-emerald-400",title:"7. Agent Skills",kicker:"Wiederverwendbare Fähigkeiten",children:[g.jsxs("p",{children:["Ein ",g.jsx("strong",{children:"Skill"})," ist ein Ordner mit einer ",g.jsx(pn,{children:"SKILL.md"})," (YAML-Kopf + Anleitung, optional Skripte/Beispiele), den der Agent für eine bestimmte Aufgabe lädt — z.B. TDD, Code-Vereinfachung, API-Design."]}),g.jsx("pre",{className:"p-2.5 bg-background/25 rounded-lg border border-border/30 font-mono text-[9px] text-foreground overflow-x-auto whitespace-pre",children:`--- diff --git a/frontend/dist/index.html b/frontend/dist/index.html index f359ec7..412ae1c 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -7,7 +7,7 @@ Mission Control 2.0 - + diff --git a/frontend/src/components/voice/AvatarPicker.tsx b/frontend/src/components/voice/AvatarPicker.tsx index 85ab23b..218a827 100644 --- a/frontend/src/components/voice/AvatarPicker.tsx +++ b/frontend/src/components/voice/AvatarPicker.tsx @@ -179,12 +179,12 @@ export function AvatarPicker({ avatarUrl, onAvatarChange }: { ) : (
-
+
{enginesAvail.map((eng) => (