@must-b/must-b 1.74.41 → 1.74.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,7 +22,7 @@ function Eb(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
|
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the MIT license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t(E,T){var O=E.length;E.push(T);e:for(;0<O;){var G=O-1>>>1,D=E[G];if(0<a(D,T))E[G]=T,E[O]=D,O=G;else break e}}function n(E){return E.length===0?null:E[0]}function r(E){if(E.length===0)return null;var T=E[0],O=E.pop();if(O!==T){E[0]=O;e:for(var G=0,D=E.length,K=D>>>1;G<K;){var F=2*(G+1)-1,Q=E[F],q=F+1,X=E[q];if(0>a(Q,O))q<D&&0>a(X,Q)?(E[G]=X,E[q]=O,G=q):(E[G]=Q,E[F]=O,G=F);else if(q<D&&0>a(X,O))E[G]=X,E[q]=O,G=q;else break e}}return T}function a(E,T){var O=E.sortIndex-T.sortIndex;return O!==0?O:E.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],h=1,p=null,f=3,m=!1,b=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(E){for(var T=n(d);T!==null;){if(T.callback===null)r(d);else if(T.startTime<=E)r(d),T.sortIndex=T.expirationTime,t(c,T);else break;T=n(d)}}function j(E){if(y=!1,w(E),!b)if(n(c)!==null)b=!0,
|
|
25
|
+
*/(function(e){function t(E,T){var O=E.length;E.push(T);e:for(;0<O;){var G=O-1>>>1,D=E[G];if(0<a(D,T))E[G]=T,E[O]=D,O=G;else break e}}function n(E){return E.length===0?null:E[0]}function r(E){if(E.length===0)return null;var T=E[0],O=E.pop();if(O!==T){E[0]=O;e:for(var G=0,D=E.length,K=D>>>1;G<K;){var F=2*(G+1)-1,Q=E[F],q=F+1,X=E[q];if(0>a(Q,O))q<D&&0>a(X,Q)?(E[G]=X,E[q]=O,G=q):(E[G]=Q,E[F]=O,G=F);else if(q<D&&0>a(X,O))E[G]=X,E[q]=O,G=q;else break e}}return T}function a(E,T){var O=E.sortIndex-T.sortIndex;return O!==0?O:E.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],h=1,p=null,f=3,m=!1,b=!1,y=!1,v=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(E){for(var T=n(d);T!==null;){if(T.callback===null)r(d);else if(T.startTime<=E)r(d),T.sortIndex=T.expirationTime,t(c,T);else break;T=n(d)}}function j(E){if(y=!1,w(E),!b)if(n(c)!==null)b=!0,z(k);else{var T=n(d);T!==null&&P(j,T.startTime-E)}}function k(E,T){b=!1,y&&(y=!1,x(A),A=-1),m=!0;var O=f;try{for(w(T),p=n(c);p!==null&&(!(p.expirationTime>T)||E&&!L());){var G=p.callback;if(typeof G=="function"){p.callback=null,f=p.priorityLevel;var D=G(p.expirationTime<=T);T=e.unstable_now(),typeof D=="function"?p.callback=D:p===n(c)&&r(c),w(T)}else r(c);p=n(c)}if(p!==null)var K=!0;else{var F=n(d);F!==null&&P(j,F.startTime-T),K=!1}return K}finally{p=null,f=O,m=!1}}var S=!1,C=null,A=-1,N=5,_=-1;function L(){return!(e.unstable_now()-_<N)}function B(){if(C!==null){var E=e.unstable_now();_=E;var T=!0;try{T=C(!0,E)}finally{T?M():(S=!1,C=null)}}else S=!1}var M;if(typeof g=="function")M=function(){g(B)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,R=$.port2;$.port1.onmessage=B,M=function(){R.postMessage(null)}}else M=function(){v(B,0)};function z(E){C=E,S||(S=!0,M())}function P(E,T){A=v(function(){E(e.unstable_now())},T)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(E){E.callback=null},e.unstable_continueExecution=function(){b||m||(b=!0,z(k))},e.unstable_forceFrameRate=function(E){0>E||125<E?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<E?Math.floor(1e3/E):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(E){switch(f){case 1:case 2:case 3:var T=3;break;default:T=f}var O=f;f=T;try{return E()}finally{f=O}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(E,T){switch(E){case 1:case 2:case 3:case 4:case 5:break;default:E=3}var O=f;f=E;try{return T()}finally{f=O}},e.unstable_scheduleCallback=function(E,T,O){var G=e.unstable_now();switch(typeof O=="object"&&O!==null?(O=O.delay,O=typeof O=="number"&&0<O?G+O:G):O=G,E){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=O+D,E={id:h++,callback:T,priorityLevel:E,startTime:O,expirationTime:D,sortIndex:-1},O>G?(E.sortIndex=O,t(d,E),n(c)===null&&E===n(d)&&(y?(x(A),A=-1):y=!0,P(j,O-G))):(E.sortIndex=D,t(c,E),b||m||(b=!0,z(k))),E},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(E){var T=f;return function(){var O=f;f=T;try{return E.apply(this,arguments)}finally{f=O}}}})(fx);px.exports=fx;var Yb=px.exports;/**
|
|
26
26
|
* @license React
|
|
27
27
|
* react-dom.production.min.js
|
|
28
28
|
*
|
|
@@ -65,7 +65,7 @@ Error generating stack: `+i.message+`
|
|
|
65
65
|
*
|
|
66
66
|
* @license MIT
|
|
67
67
|
*/function Kd(){return Kd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Kd.apply(this,arguments)}function qk(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function Yk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Xk(e,t){return e.button===0&&(!t||t==="_self")&&!Yk(e)}function Gd(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Qk(e,t){let n=Gd(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(i=>{n.append(a,i)})}),n}const Jk=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Zk="6";try{window.__reactRouterVersion=Zk}catch{}const ej="startTransition",$f=Eu[ej];function tj(e){let{basename:t,children:n,future:r,window:a}=e,i=u.useRef();i.current==null&&(i.current=Z2({window:a,v5Compat:!0}));let o=i.current,[l,c]=u.useState({action:o.action,location:o.location}),{v7_startTransition:d}=r||{},h=u.useCallback(p=>{d&&$f?$f(()=>c(p)):c(p)},[c,d]);return u.useLayoutEffect(()=>o.listen(h),[o,h]),u.useEffect(()=>Hk(r),[r]),u.createElement(Kk,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const nj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",sj=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ra=u.forwardRef(function(t,n){let{onClick:r,relative:a,reloadDocument:i,replace:o,state:l,target:c,to:d,preventScrollReset:h,viewTransition:p}=t,f=qk(t,Jk),{basename:m}=u.useContext(fs),b,y=!1;if(typeof d=="string"&&sj.test(d)&&(b=d,nj))try{let w=new URL(window.location.href),j=d.startsWith("//")?new URL(w.protocol+d):new URL(d),k=bh(j.pathname,m);j.origin===w.origin&&k!=null?d=k+j.search+j.hash:y=!0}catch{}let v=Ek(d,{relative:a}),x=rj(d,{replace:o,state:l,target:c,preventScrollReset:h,relative:a,viewTransition:p});function g(w){r&&r(w),w.defaultPrevented||x(w)}return u.createElement("a",Kd({},f,{href:b||v,onClick:y||i?r:g,ref:n,target:c}))});var Vf;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Vf||(Vf={}));var Uf;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Uf||(Uf={}));function rj(e,t){let{target:n,replace:r,state:a,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,c=gt(),d=ms(),h=by(e,{relative:o});return u.useCallback(p=>{if(Xk(p,n)){p.preventDefault();let f=r!==void 0?r:sl(d)===sl(h);c(e,{replace:f,state:a,preventScrollReset:i,relative:o,viewTransition:l})}},[d,c,h,r,a,n,e,i,o,l])}function aj(e){let t=u.useRef(Gd(e)),n=u.useRef(!1),r=ms(),a=u.useMemo(()=>Qk(r.search,n.current?null:t.current),[r.search]),i=gt(),o=u.useCallback((l,c)=>{const d=Gd(typeof l=="function"?l(a):l);n.current=!0,i("?"+d,c)},[i,a]);return[a,o]}var ij=e=>{switch(e){case"success":return cj;case"info":return uj;case"warning":return dj;case"error":return hj;default:return null}},oj=Array(12).fill(0),lj=({visible:e,className:t})=>Y.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},Y.createElement("div",{className:"sonner-spinner"},oj.map((n,r)=>Y.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),cj=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),dj=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),uj=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),hj=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),pj=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Y.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Y.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fj=()=>{let[e,t]=Y.useState(document.hidden);return Y.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},qd=1,mj=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,a=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:qd++,i=this.toasts.find(l=>l.id===a),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...e,id:a,title:n}),{...l,...e,id:a,dismissible:o,title:n}):l):this.addToast({title:n,...r,dismissible:o,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),a=n!==void 0,i,o=r.then(async c=>{if(i=["resolve",c],Y.isValidElement(c))a=!1,this.create({id:n,type:"default",message:c});else if(gj(c)&&!c.ok){a=!1;let d=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,h=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:d,description:h})}else if(t.success!==void 0){a=!1;let d=typeof t.success=="function"?await t.success(c):t.success,h=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:d,description:h})}}).catch(async c=>{if(i=["reject",c],t.error!==void 0){a=!1;let d=typeof t.error=="function"?await t.error(c):t.error,h=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:d,description:h})}}).finally(()=>{var c;a&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,d)=>o.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||qd++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},dt=new mj,xj=(e,t)=>{let n=(t==null?void 0:t.id)||qd++;return dt.addToast({title:e,...t,id:n}),n},gj=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",yj=xj,vj=()=>dt.toasts,bj=()=>dt.getActiveToasts(),te=Object.assign(yj,{success:dt.success,info:dt.info,warning:dt.warning,error:dt.error,custom:dt.custom,message:dt.message,promise:dt.promise,dismiss:dt.dismiss,loading:dt.loading},{getHistory:vj,getToasts:bj});function wj(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}wj(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
68
|
-
`);function qi(e){return e.label!==void 0}var kj=3,jj="32px",Nj="16px",Hf=4e3,Sj=356,Cj=14,Ej=20,_j=200;function Ut(...e){return e.filter(Boolean).join(" ")}function Tj(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var Pj=e=>{var t,n,r,a,i,o,l,c,d,h,p;let{invert:f,toast:m,unstyled:b,interacting:y,setHeights:v,visibleToasts:x,heights:g,index:w,toasts:j,expanded:k,removeToast:S,defaultRichColors:C,closeButton:A,style:N,cancelButtonStyle:_,actionButtonStyle:L,className:B="",descriptionClassName:z="",duration:$,position:R,gap:M,loadingIcon:P,expandByDefault:E,classNames:T,icons:O,closeButtonAriaLabel:G="Close toast",pauseWhenPageIsHidden:D}=e,[K,F]=Y.useState(null),[Q,q]=Y.useState(null),[X,le]=Y.useState(!1),[H,se]=Y.useState(!1),[ce,oe]=Y.useState(!1),[de,Et]=Y.useState(!1),[bs,ra]=Y.useState(!1),[ee,Z]=Y.useState(0),[xe,Zs]=Y.useState(0),Re=Y.useRef(m.duration||$||Hf),er=Y.useRef(null),yn=Y.useRef(null),ct=w===0,Ti=w+1<=x,_t=m.type,tr=m.dismissible!==!1,bb=m.className||"",wb=m.descriptionClassName||"",Pi=Y.useMemo(()=>g.findIndex(ie=>ie.toastId===m.id)||0,[g,m.id]),kb=Y.useMemo(()=>{var ie;return(ie=m.closeButton)!=null?ie:A},[m.closeButton,A]),wp=Y.useMemo(()=>m.duration||$||Hf,[m.duration,$]),Gl=Y.useRef(0),nr=Y.useRef(0),kp=Y.useRef(0),sr=Y.useRef(null),[jb,Nb]=R.split("-"),jp=Y.useMemo(()=>g.reduce((ie,ve,Se)=>Se>=Pi?ie:ie+ve.height,0),[g,Pi]),Np=fj(),Sb=m.invert||f,ql=_t==="loading";nr.current=Y.useMemo(()=>Pi*M+jp,[Pi,jp]),Y.useEffect(()=>{Re.current=wp},[wp]),Y.useEffect(()=>{le(!0)},[]),Y.useEffect(()=>{let ie=yn.current;if(ie){let ve=ie.getBoundingClientRect().height;return Zs(ve),v(Se=>[{toastId:m.id,height:ve,position:m.position},...Se]),()=>v(Se=>Se.filter(Bt=>Bt.toastId!==m.id))}},[v,m.id]),Y.useLayoutEffect(()=>{if(!X)return;let ie=yn.current,ve=ie.style.height;ie.style.height="auto";let Se=ie.getBoundingClientRect().height;ie.style.height=ve,Zs(Se),v(Bt=>Bt.find(Ft=>Ft.toastId===m.id)?Bt.map(Ft=>Ft.toastId===m.id?{...Ft,height:Se}:Ft):[{toastId:m.id,height:Se,position:m.position},...Bt])},[X,m.title,m.description,v,m.id]);let In=Y.useCallback(()=>{se(!0),Z(nr.current),v(ie=>ie.filter(ve=>ve.toastId!==m.id)),setTimeout(()=>{S(m)},_j)},[m,S,v,nr]);Y.useEffect(()=>{if(m.promise&&_t==="loading"||m.duration===1/0||m.type==="loading")return;let ie;return k||y||D&&Np?(()=>{if(kp.current<Gl.current){let ve=new Date().getTime()-Gl.current;Re.current=Re.current-ve}kp.current=new Date().getTime()})():Re.current!==1/0&&(Gl.current=new Date().getTime(),ie=setTimeout(()=>{var ve;(ve=m.onAutoClose)==null||ve.call(m,m),In()},Re.current)),()=>clearTimeout(ie)},[k,y,m,_t,D,Np,In]),Y.useEffect(()=>{m.delete&&In()},[In,m.delete]);function Cb(){var ie,ve,Se;return O!=null&&O.loading?Y.createElement("div",{className:Ut(T==null?void 0:T.loader,(ie=m==null?void 0:m.classNames)==null?void 0:ie.loader,"sonner-loader"),"data-visible":_t==="loading"},O.loading):P?Y.createElement("div",{className:Ut(T==null?void 0:T.loader,(ve=m==null?void 0:m.classNames)==null?void 0:ve.loader,"sonner-loader"),"data-visible":_t==="loading"},P):Y.createElement(lj,{className:Ut(T==null?void 0:T.loader,(Se=m==null?void 0:m.classNames)==null?void 0:Se.loader),visible:_t==="loading"})}return Y.createElement("li",{tabIndex:0,ref:yn,className:Ut(B,bb,T==null?void 0:T.toast,(t=m==null?void 0:m.classNames)==null?void 0:t.toast,T==null?void 0:T.default,T==null?void 0:T[_t],(n=m==null?void 0:m.classNames)==null?void 0:n[_t]),"data-sonner-toast":"","data-rich-colors":(r=m.richColors)!=null?r:C,"data-styled":!(m.jsx||m.unstyled||b),"data-mounted":X,"data-promise":!!m.promise,"data-swiped":bs,"data-removed":H,"data-visible":Ti,"data-y-position":jb,"data-x-position":Nb,"data-index":w,"data-front":ct,"data-swiping":ce,"data-dismissible":tr,"data-type":_t,"data-invert":Sb,"data-swipe-out":de,"data-swipe-direction":Q,"data-expanded":!!(k||E&&X),style:{"--index":w,"--toasts-before":w,"--z-index":j.length-w,"--offset":`${H?ee:nr.current}px`,"--initial-height":E?"auto":`${xe}px`,...N,...m.style},onDragEnd:()=>{oe(!1),F(null),sr.current=null},onPointerDown:ie=>{ql||!tr||(er.current=new Date,Z(nr.current),ie.target.setPointerCapture(ie.pointerId),ie.target.tagName!=="BUTTON"&&(oe(!0),sr.current={x:ie.clientX,y:ie.clientY}))},onPointerUp:()=>{var ie,ve,Se,Bt;if(de||!tr)return;sr.current=null;let Ft=Number(((ie=yn.current)==null?void 0:ie.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Dn=Number(((ve=yn.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ws=new Date().getTime()-((Se=er.current)==null?void 0:Se.getTime()),$t=K==="x"?Ft:Dn,Bn=Math.abs($t)/ws;if(Math.abs($t)>=Ej||Bn>.11){Z(nr.current),(Bt=m.onDismiss)==null||Bt.call(m,m),q(K==="x"?Ft>0?"right":"left":Dn>0?"down":"up"),In(),Et(!0),ra(!1);return}oe(!1),F(null)},onPointerMove:ie=>{var ve,Se,Bt,Ft;if(!sr.current||!tr||((ve=window.getSelection())==null?void 0:ve.toString().length)>0)return;let Dn=ie.clientY-sr.current.y,ws=ie.clientX-sr.current.x,$t=(Se=e.swipeDirections)!=null?Se:Tj(R);!K&&(Math.abs(ws)>1||Math.abs(Dn)>1)&&F(Math.abs(ws)>Math.abs(Dn)?"x":"y");let Bn={x:0,y:0};K==="y"?($t.includes("top")||$t.includes("bottom"))&&($t.includes("top")&&Dn<0||$t.includes("bottom")&&Dn>0)&&(Bn.y=Dn):K==="x"&&($t.includes("left")||$t.includes("right"))&&($t.includes("left")&&ws<0||$t.includes("right")&&ws>0)&&(Bn.x=ws),(Math.abs(Bn.x)>0||Math.abs(Bn.y)>0)&&ra(!0),(Bt=yn.current)==null||Bt.style.setProperty("--swipe-amount-x",`${Bn.x}px`),(Ft=yn.current)==null||Ft.style.setProperty("--swipe-amount-y",`${Bn.y}px`)}},kb&&!m.jsx?Y.createElement("button",{"aria-label":G,"data-disabled":ql,"data-close-button":!0,onClick:ql||!tr?()=>{}:()=>{var ie;In(),(ie=m.onDismiss)==null||ie.call(m,m)},className:Ut(T==null?void 0:T.closeButton,(a=m==null?void 0:m.classNames)==null?void 0:a.closeButton)},(i=O==null?void 0:O.close)!=null?i:pj):null,m.jsx||u.isValidElement(m.title)?m.jsx?m.jsx:typeof m.title=="function"?m.title():m.title:Y.createElement(Y.Fragment,null,_t||m.icon||m.promise?Y.createElement("div",{"data-icon":"",className:Ut(T==null?void 0:T.icon,(o=m==null?void 0:m.classNames)==null?void 0:o.icon)},m.promise||m.type==="loading"&&!m.icon?m.icon||Cb():null,m.type!=="loading"?m.icon||(O==null?void 0:O[_t])||ij(_t):null):null,Y.createElement("div",{"data-content":"",className:Ut(T==null?void 0:T.content,(l=m==null?void 0:m.classNames)==null?void 0:l.content)},Y.createElement("div",{"data-title":"",className:Ut(T==null?void 0:T.title,(c=m==null?void 0:m.classNames)==null?void 0:c.title)},typeof m.title=="function"?m.title():m.title),m.description?Y.createElement("div",{"data-description":"",className:Ut(z,wb,T==null?void 0:T.description,(d=m==null?void 0:m.classNames)==null?void 0:d.description)},typeof m.description=="function"?m.description():m.description):null),u.isValidElement(m.cancel)?m.cancel:m.cancel&&qi(m.cancel)?Y.createElement("button",{"data-button":!0,"data-cancel":!0,style:m.cancelButtonStyle||_,onClick:ie=>{var ve,Se;qi(m.cancel)&&tr&&((Se=(ve=m.cancel).onClick)==null||Se.call(ve,ie),In())},className:Ut(T==null?void 0:T.cancelButton,(h=m==null?void 0:m.classNames)==null?void 0:h.cancelButton)},m.cancel.label):null,u.isValidElement(m.action)?m.action:m.action&&qi(m.action)?Y.createElement("button",{"data-button":!0,"data-action":!0,style:m.actionButtonStyle||L,onClick:ie=>{var ve,Se;qi(m.action)&&((Se=(ve=m.action).onClick)==null||Se.call(ve,ie),!ie.defaultPrevented&&In())},className:Ut(T==null?void 0:T.actionButton,(p=m==null?void 0:m.classNames)==null?void 0:p.actionButton)},m.action.label):null))};function Wf(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Aj(e,t){let n={};return[e,t].forEach((r,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",l=i?Nj:jj;function c(d){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${o}-${d}`]=l:n[`${o}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):c(l)}),n}var Mj=u.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:h="light",richColors:p,duration:f,style:m,visibleToasts:b=kj,toastOptions:y,dir:v=Wf(),gap:x=Cj,loadingIcon:g,icons:w,containerAriaLabel:j="Notifications",pauseWhenPageIsHidden:k}=e,[S,C]=Y.useState([]),A=Y.useMemo(()=>Array.from(new Set([r].concat(S.filter(D=>D.position).map(D=>D.position)))),[S,r]),[N,_]=Y.useState([]),[L,B]=Y.useState(!1),[z,$]=Y.useState(!1),[R,M]=Y.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),P=Y.useRef(null),E=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),T=Y.useRef(null),O=Y.useRef(!1),G=Y.useCallback(D=>{C(K=>{var F;return(F=K.find(Q=>Q.id===D.id))!=null&&F.delete||dt.dismiss(D.id),K.filter(({id:Q})=>Q!==D.id)})},[]);return Y.useEffect(()=>dt.subscribe(D=>{if(D.dismiss){C(K=>K.map(F=>F.id===D.id?{...F,delete:!0}:F));return}setTimeout(()=>{py.flushSync(()=>{C(K=>{let F=K.findIndex(Q=>Q.id===D.id);return F!==-1?[...K.slice(0,F),{...K[F],...D},...K.slice(F+1)]:[D,...K]})})})}),[]),Y.useEffect(()=>{if(h!=="system"){M(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:K})=>{M(K?"dark":"light")})}catch{D.addListener(({matches:F})=>{try{M(F?"dark":"light")}catch(Q){console.error(Q)}})}},[h]),Y.useEffect(()=>{S.length<=1&&B(!1)},[S]),Y.useEffect(()=>{let D=K=>{var F,Q;a.every(q=>K[q]||K.code===q)&&(B(!0),(F=P.current)==null||F.focus()),K.code==="Escape"&&(document.activeElement===P.current||(Q=P.current)!=null&&Q.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[a]),Y.useEffect(()=>{if(P.current)return()=>{T.current&&(T.current.focus({preventScroll:!0}),T.current=null,O.current=!1)}},[P.current]),Y.createElement("section",{ref:t,"aria-label":`${j} ${E}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((D,K)=>{var F;let[Q,q]=D.split("-");return S.length?Y.createElement("ol",{key:D,dir:v==="auto"?Wf():v,tabIndex:-1,ref:P,className:l,"data-sonner-toaster":!0,"data-theme":R,"data-y-position":Q,"data-lifted":L&&S.length>1&&!i,"data-x-position":q,style:{"--front-toast-height":`${((F=N[0])==null?void 0:F.height)||0}px`,"--width":`${Sj}px`,"--gap":`${x}px`,...m,...Aj(c,d)},onBlur:X=>{O.current&&!X.currentTarget.contains(X.relatedTarget)&&(O.current=!1,T.current&&(T.current.focus({preventScroll:!0}),T.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||O.current||(O.current=!0,T.current=X.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{z||B(!1)},onDragEnd:()=>B(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},S.filter(X=>!X.position&&K===0||X.position===D).map((X,le)=>{var H,se;return Y.createElement(Pj,{key:X.id,icons:w,index:le,toast:X,defaultRichColors:p,duration:(H=y==null?void 0:y.duration)!=null?H:f,className:y==null?void 0:y.className,descriptionClassName:y==null?void 0:y.descriptionClassName,invert:n,visibleToasts:b,closeButton:(se=y==null?void 0:y.closeButton)!=null?se:o,interacting:z,position:D,style:y==null?void 0:y.style,unstyled:y==null?void 0:y.unstyled,classNames:y==null?void 0:y.classNames,cancelButtonStyle:y==null?void 0:y.cancelButtonStyle,actionButtonStyle:y==null?void 0:y.actionButtonStyle,removeToast:G,toasts:S.filter(ce=>ce.position==X.position),heights:N.filter(ce=>ce.position==X.position),setHeights:_,expandByDefault:i,gap:x,loadingIcon:g,expanded:L,pauseWhenPageIsHidden:k,swipeDirections:e.swipeDirections})})):null}))});const Nh=u.createContext({});function Al(e){const t=u.useRef(null);return t.current===null&&(t.current=e()),t.current}const Ml=u.createContext(null),ai=u.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class zj extends u.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Rj({children:e,isPresent:t}){const n=u.useId(),r=u.useRef(null),a=u.useRef({width:0,height:0,top:0,left:0}),{nonce:i}=u.useContext(ai);return u.useInsertionEffect(()=>{const{width:o,height:l,top:c,left:d}=a.current;if(t||!r.current||!o||!l)return;r.current.dataset.motionPopId=n;const h=document.createElement("style");return i&&(h.nonce=i),document.head.appendChild(h),h.sheet&&h.sheet.insertRule(`
|
|
68
|
+
`);function qi(e){return e.label!==void 0}var kj=3,jj="32px",Nj="16px",Hf=4e3,Sj=356,Cj=14,Ej=20,_j=200;function Ut(...e){return e.filter(Boolean).join(" ")}function Tj(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var Pj=e=>{var t,n,r,a,i,o,l,c,d,h,p;let{invert:f,toast:m,unstyled:b,interacting:y,setHeights:v,visibleToasts:x,heights:g,index:w,toasts:j,expanded:k,removeToast:S,defaultRichColors:C,closeButton:A,style:N,cancelButtonStyle:_,actionButtonStyle:L,className:B="",descriptionClassName:M="",duration:$,position:R,gap:z,loadingIcon:P,expandByDefault:E,classNames:T,icons:O,closeButtonAriaLabel:G="Close toast",pauseWhenPageIsHidden:D}=e,[K,F]=Y.useState(null),[Q,q]=Y.useState(null),[X,le]=Y.useState(!1),[H,se]=Y.useState(!1),[ce,oe]=Y.useState(!1),[de,Et]=Y.useState(!1),[bs,ra]=Y.useState(!1),[ee,Z]=Y.useState(0),[xe,Zs]=Y.useState(0),Re=Y.useRef(m.duration||$||Hf),er=Y.useRef(null),yn=Y.useRef(null),ct=w===0,Ti=w+1<=x,_t=m.type,tr=m.dismissible!==!1,bb=m.className||"",wb=m.descriptionClassName||"",Pi=Y.useMemo(()=>g.findIndex(ie=>ie.toastId===m.id)||0,[g,m.id]),kb=Y.useMemo(()=>{var ie;return(ie=m.closeButton)!=null?ie:A},[m.closeButton,A]),wp=Y.useMemo(()=>m.duration||$||Hf,[m.duration,$]),Gl=Y.useRef(0),nr=Y.useRef(0),kp=Y.useRef(0),sr=Y.useRef(null),[jb,Nb]=R.split("-"),jp=Y.useMemo(()=>g.reduce((ie,ve,Se)=>Se>=Pi?ie:ie+ve.height,0),[g,Pi]),Np=fj(),Sb=m.invert||f,ql=_t==="loading";nr.current=Y.useMemo(()=>Pi*z+jp,[Pi,jp]),Y.useEffect(()=>{Re.current=wp},[wp]),Y.useEffect(()=>{le(!0)},[]),Y.useEffect(()=>{let ie=yn.current;if(ie){let ve=ie.getBoundingClientRect().height;return Zs(ve),v(Se=>[{toastId:m.id,height:ve,position:m.position},...Se]),()=>v(Se=>Se.filter(Bt=>Bt.toastId!==m.id))}},[v,m.id]),Y.useLayoutEffect(()=>{if(!X)return;let ie=yn.current,ve=ie.style.height;ie.style.height="auto";let Se=ie.getBoundingClientRect().height;ie.style.height=ve,Zs(Se),v(Bt=>Bt.find(Ft=>Ft.toastId===m.id)?Bt.map(Ft=>Ft.toastId===m.id?{...Ft,height:Se}:Ft):[{toastId:m.id,height:Se,position:m.position},...Bt])},[X,m.title,m.description,v,m.id]);let In=Y.useCallback(()=>{se(!0),Z(nr.current),v(ie=>ie.filter(ve=>ve.toastId!==m.id)),setTimeout(()=>{S(m)},_j)},[m,S,v,nr]);Y.useEffect(()=>{if(m.promise&&_t==="loading"||m.duration===1/0||m.type==="loading")return;let ie;return k||y||D&&Np?(()=>{if(kp.current<Gl.current){let ve=new Date().getTime()-Gl.current;Re.current=Re.current-ve}kp.current=new Date().getTime()})():Re.current!==1/0&&(Gl.current=new Date().getTime(),ie=setTimeout(()=>{var ve;(ve=m.onAutoClose)==null||ve.call(m,m),In()},Re.current)),()=>clearTimeout(ie)},[k,y,m,_t,D,Np,In]),Y.useEffect(()=>{m.delete&&In()},[In,m.delete]);function Cb(){var ie,ve,Se;return O!=null&&O.loading?Y.createElement("div",{className:Ut(T==null?void 0:T.loader,(ie=m==null?void 0:m.classNames)==null?void 0:ie.loader,"sonner-loader"),"data-visible":_t==="loading"},O.loading):P?Y.createElement("div",{className:Ut(T==null?void 0:T.loader,(ve=m==null?void 0:m.classNames)==null?void 0:ve.loader,"sonner-loader"),"data-visible":_t==="loading"},P):Y.createElement(lj,{className:Ut(T==null?void 0:T.loader,(Se=m==null?void 0:m.classNames)==null?void 0:Se.loader),visible:_t==="loading"})}return Y.createElement("li",{tabIndex:0,ref:yn,className:Ut(B,bb,T==null?void 0:T.toast,(t=m==null?void 0:m.classNames)==null?void 0:t.toast,T==null?void 0:T.default,T==null?void 0:T[_t],(n=m==null?void 0:m.classNames)==null?void 0:n[_t]),"data-sonner-toast":"","data-rich-colors":(r=m.richColors)!=null?r:C,"data-styled":!(m.jsx||m.unstyled||b),"data-mounted":X,"data-promise":!!m.promise,"data-swiped":bs,"data-removed":H,"data-visible":Ti,"data-y-position":jb,"data-x-position":Nb,"data-index":w,"data-front":ct,"data-swiping":ce,"data-dismissible":tr,"data-type":_t,"data-invert":Sb,"data-swipe-out":de,"data-swipe-direction":Q,"data-expanded":!!(k||E&&X),style:{"--index":w,"--toasts-before":w,"--z-index":j.length-w,"--offset":`${H?ee:nr.current}px`,"--initial-height":E?"auto":`${xe}px`,...N,...m.style},onDragEnd:()=>{oe(!1),F(null),sr.current=null},onPointerDown:ie=>{ql||!tr||(er.current=new Date,Z(nr.current),ie.target.setPointerCapture(ie.pointerId),ie.target.tagName!=="BUTTON"&&(oe(!0),sr.current={x:ie.clientX,y:ie.clientY}))},onPointerUp:()=>{var ie,ve,Se,Bt;if(de||!tr)return;sr.current=null;let Ft=Number(((ie=yn.current)==null?void 0:ie.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Dn=Number(((ve=yn.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ws=new Date().getTime()-((Se=er.current)==null?void 0:Se.getTime()),$t=K==="x"?Ft:Dn,Bn=Math.abs($t)/ws;if(Math.abs($t)>=Ej||Bn>.11){Z(nr.current),(Bt=m.onDismiss)==null||Bt.call(m,m),q(K==="x"?Ft>0?"right":"left":Dn>0?"down":"up"),In(),Et(!0),ra(!1);return}oe(!1),F(null)},onPointerMove:ie=>{var ve,Se,Bt,Ft;if(!sr.current||!tr||((ve=window.getSelection())==null?void 0:ve.toString().length)>0)return;let Dn=ie.clientY-sr.current.y,ws=ie.clientX-sr.current.x,$t=(Se=e.swipeDirections)!=null?Se:Tj(R);!K&&(Math.abs(ws)>1||Math.abs(Dn)>1)&&F(Math.abs(ws)>Math.abs(Dn)?"x":"y");let Bn={x:0,y:0};K==="y"?($t.includes("top")||$t.includes("bottom"))&&($t.includes("top")&&Dn<0||$t.includes("bottom")&&Dn>0)&&(Bn.y=Dn):K==="x"&&($t.includes("left")||$t.includes("right"))&&($t.includes("left")&&ws<0||$t.includes("right")&&ws>0)&&(Bn.x=ws),(Math.abs(Bn.x)>0||Math.abs(Bn.y)>0)&&ra(!0),(Bt=yn.current)==null||Bt.style.setProperty("--swipe-amount-x",`${Bn.x}px`),(Ft=yn.current)==null||Ft.style.setProperty("--swipe-amount-y",`${Bn.y}px`)}},kb&&!m.jsx?Y.createElement("button",{"aria-label":G,"data-disabled":ql,"data-close-button":!0,onClick:ql||!tr?()=>{}:()=>{var ie;In(),(ie=m.onDismiss)==null||ie.call(m,m)},className:Ut(T==null?void 0:T.closeButton,(a=m==null?void 0:m.classNames)==null?void 0:a.closeButton)},(i=O==null?void 0:O.close)!=null?i:pj):null,m.jsx||u.isValidElement(m.title)?m.jsx?m.jsx:typeof m.title=="function"?m.title():m.title:Y.createElement(Y.Fragment,null,_t||m.icon||m.promise?Y.createElement("div",{"data-icon":"",className:Ut(T==null?void 0:T.icon,(o=m==null?void 0:m.classNames)==null?void 0:o.icon)},m.promise||m.type==="loading"&&!m.icon?m.icon||Cb():null,m.type!=="loading"?m.icon||(O==null?void 0:O[_t])||ij(_t):null):null,Y.createElement("div",{"data-content":"",className:Ut(T==null?void 0:T.content,(l=m==null?void 0:m.classNames)==null?void 0:l.content)},Y.createElement("div",{"data-title":"",className:Ut(T==null?void 0:T.title,(c=m==null?void 0:m.classNames)==null?void 0:c.title)},typeof m.title=="function"?m.title():m.title),m.description?Y.createElement("div",{"data-description":"",className:Ut(M,wb,T==null?void 0:T.description,(d=m==null?void 0:m.classNames)==null?void 0:d.description)},typeof m.description=="function"?m.description():m.description):null),u.isValidElement(m.cancel)?m.cancel:m.cancel&&qi(m.cancel)?Y.createElement("button",{"data-button":!0,"data-cancel":!0,style:m.cancelButtonStyle||_,onClick:ie=>{var ve,Se;qi(m.cancel)&&tr&&((Se=(ve=m.cancel).onClick)==null||Se.call(ve,ie),In())},className:Ut(T==null?void 0:T.cancelButton,(h=m==null?void 0:m.classNames)==null?void 0:h.cancelButton)},m.cancel.label):null,u.isValidElement(m.action)?m.action:m.action&&qi(m.action)?Y.createElement("button",{"data-button":!0,"data-action":!0,style:m.actionButtonStyle||L,onClick:ie=>{var ve,Se;qi(m.action)&&((Se=(ve=m.action).onClick)==null||Se.call(ve,ie),!ie.defaultPrevented&&In())},className:Ut(T==null?void 0:T.actionButton,(p=m==null?void 0:m.classNames)==null?void 0:p.actionButton)},m.action.label):null))};function Wf(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Aj(e,t){let n={};return[e,t].forEach((r,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",l=i?Nj:jj;function c(d){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${o}-${d}`]=l:n[`${o}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):c(l)}),n}var Mj=u.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:h="light",richColors:p,duration:f,style:m,visibleToasts:b=kj,toastOptions:y,dir:v=Wf(),gap:x=Cj,loadingIcon:g,icons:w,containerAriaLabel:j="Notifications",pauseWhenPageIsHidden:k}=e,[S,C]=Y.useState([]),A=Y.useMemo(()=>Array.from(new Set([r].concat(S.filter(D=>D.position).map(D=>D.position)))),[S,r]),[N,_]=Y.useState([]),[L,B]=Y.useState(!1),[M,$]=Y.useState(!1),[R,z]=Y.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),P=Y.useRef(null),E=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),T=Y.useRef(null),O=Y.useRef(!1),G=Y.useCallback(D=>{C(K=>{var F;return(F=K.find(Q=>Q.id===D.id))!=null&&F.delete||dt.dismiss(D.id),K.filter(({id:Q})=>Q!==D.id)})},[]);return Y.useEffect(()=>dt.subscribe(D=>{if(D.dismiss){C(K=>K.map(F=>F.id===D.id?{...F,delete:!0}:F));return}setTimeout(()=>{py.flushSync(()=>{C(K=>{let F=K.findIndex(Q=>Q.id===D.id);return F!==-1?[...K.slice(0,F),{...K[F],...D},...K.slice(F+1)]:[D,...K]})})})}),[]),Y.useEffect(()=>{if(h!=="system"){z(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?z("dark"):z("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:K})=>{z(K?"dark":"light")})}catch{D.addListener(({matches:F})=>{try{z(F?"dark":"light")}catch(Q){console.error(Q)}})}},[h]),Y.useEffect(()=>{S.length<=1&&B(!1)},[S]),Y.useEffect(()=>{let D=K=>{var F,Q;a.every(q=>K[q]||K.code===q)&&(B(!0),(F=P.current)==null||F.focus()),K.code==="Escape"&&(document.activeElement===P.current||(Q=P.current)!=null&&Q.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[a]),Y.useEffect(()=>{if(P.current)return()=>{T.current&&(T.current.focus({preventScroll:!0}),T.current=null,O.current=!1)}},[P.current]),Y.createElement("section",{ref:t,"aria-label":`${j} ${E}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((D,K)=>{var F;let[Q,q]=D.split("-");return S.length?Y.createElement("ol",{key:D,dir:v==="auto"?Wf():v,tabIndex:-1,ref:P,className:l,"data-sonner-toaster":!0,"data-theme":R,"data-y-position":Q,"data-lifted":L&&S.length>1&&!i,"data-x-position":q,style:{"--front-toast-height":`${((F=N[0])==null?void 0:F.height)||0}px`,"--width":`${Sj}px`,"--gap":`${x}px`,...m,...Aj(c,d)},onBlur:X=>{O.current&&!X.currentTarget.contains(X.relatedTarget)&&(O.current=!1,T.current&&(T.current.focus({preventScroll:!0}),T.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||O.current||(O.current=!0,T.current=X.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{M||B(!1)},onDragEnd:()=>B(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},S.filter(X=>!X.position&&K===0||X.position===D).map((X,le)=>{var H,se;return Y.createElement(Pj,{key:X.id,icons:w,index:le,toast:X,defaultRichColors:p,duration:(H=y==null?void 0:y.duration)!=null?H:f,className:y==null?void 0:y.className,descriptionClassName:y==null?void 0:y.descriptionClassName,invert:n,visibleToasts:b,closeButton:(se=y==null?void 0:y.closeButton)!=null?se:o,interacting:M,position:D,style:y==null?void 0:y.style,unstyled:y==null?void 0:y.unstyled,classNames:y==null?void 0:y.classNames,cancelButtonStyle:y==null?void 0:y.cancelButtonStyle,actionButtonStyle:y==null?void 0:y.actionButtonStyle,removeToast:G,toasts:S.filter(ce=>ce.position==X.position),heights:N.filter(ce=>ce.position==X.position),setHeights:_,expandByDefault:i,gap:x,loadingIcon:g,expanded:L,pauseWhenPageIsHidden:k,swipeDirections:e.swipeDirections})})):null}))});const Nh=u.createContext({});function Al(e){const t=u.useRef(null);return t.current===null&&(t.current=e()),t.current}const Ml=u.createContext(null),ai=u.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class zj extends u.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Rj({children:e,isPresent:t}){const n=u.useId(),r=u.useRef(null),a=u.useRef({width:0,height:0,top:0,left:0}),{nonce:i}=u.useContext(ai);return u.useInsertionEffect(()=>{const{width:o,height:l,top:c,left:d}=a.current;if(t||!r.current||!o||!l)return;r.current.dataset.motionPopId=n;const h=document.createElement("style");return i&&(h.nonce=i),document.head.appendChild(h),h.sheet&&h.sheet.insertRule(`
|
|
69
69
|
[data-motion-pop-id="${n}"] {
|
|
70
70
|
position: absolute !important;
|
|
71
71
|
width: ${o}px !important;
|
|
@@ -73,7 +73,7 @@ Error generating stack: `+i.message+`
|
|
|
73
73
|
top: ${c}px !important;
|
|
74
74
|
left: ${d}px !important;
|
|
75
75
|
}
|
|
76
|
-
`),()=>{document.head.removeChild(h)}},[t]),s.jsx(zj,{isPresent:t,childRef:r,sizeRef:a,children:u.cloneElement(e,{ref:r})})}const Lj=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:i,mode:o})=>{const l=Al(Oj),c=u.useId(),d=u.useCallback(p=>{l.set(p,!0);for(const f of l.values())if(!f)return;r&&r()},[l,r]),h=u.useMemo(()=>({id:c,initial:t,isPresent:n,custom:a,onExitComplete:d,register:p=>(l.set(p,!1),()=>l.delete(p))}),i?[Math.random(),d]:[n,d]);return u.useMemo(()=>{l.forEach((p,f)=>l.set(f,!1))},[n]),u.useEffect(()=>{!n&&!l.size&&r&&r()},[n]),o==="popLayout"&&(e=s.jsx(Rj,{isPresent:n,children:e})),s.jsx(Ml.Provider,{value:h,children:e})};function Oj(){return new Map}function Ny(e=!0){const t=u.useContext(Ml);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=t,i=u.useId();u.useEffect(()=>{e&&a(i)},[e]);const o=u.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,o]:[!0]}const Yi=e=>e.key||"";function Kf(e){const t=[];return u.Children.forEach(e,n=>{u.isValidElement(n)&&t.push(n)}),t}const Sh=typeof window<"u",Sy=Sh?u.useLayoutEffect:u.useEffect,ae=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:i="sync",propagate:o=!1})=>{const[l,c]=Ny(o),d=u.useMemo(()=>Kf(e),[e]),h=o&&!l?[]:d.map(Yi),p=u.useRef(!0),f=u.useRef(d),m=Al(()=>new Map),[b,y]=u.useState(d),[v,x]=u.useState(d);Sy(()=>{p.current=!1,f.current=d;for(let j=0;j<v.length;j++){const k=Yi(v[j]);h.includes(k)?m.delete(k):m.get(k)!==!0&&m.set(k,!1)}},[v,h.length,h.join("-")]);const g=[];if(d!==b){let j=[...d];for(let k=0;k<v.length;k++){const S=v[k],C=Yi(S);h.includes(C)||(j.splice(k,0,S),g.push(S))}i==="wait"&&g.length&&(j=g),x(Kf(j)),y(d);return}const{forceRender:w}=u.useContext(Nh);return s.jsx(s.Fragment,{children:v.map(j=>{const k=Yi(j),S=o&&!l?!1:d===v||h.includes(k),C=()=>{if(m.has(k))m.set(k,!0);else return;let A=!0;m.forEach(N=>{N||(A=!1)}),A&&(w==null||w(),x(f.current),o&&(c==null||c()),r&&r())};return s.jsx(Lj,{isPresent:S,initial:!p.current||n?void 0:!1,custom:S?void 0:t,presenceAffectsLayout:a,mode:i,onExitComplete:S?void 0:C,children:j},k)})})},kt=e=>e;let Cy=kt;function Ch(e){let t;return()=>(t===void 0&&(t=e()),t)}const Vr=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Sn=e=>e*1e3,Cn=e=>e/1e3,Ij={useManualTiming:!1};function Dj(e){let t=new Set,n=new Set,r=!1,a=!1;const i=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(c.schedule(d),e()),d(o)}const c={schedule:(d,h=!1,p=!1)=>{const m=p&&r?t:n;return h&&i.add(d),m.has(d)||m.add(d),d},cancel:d=>{n.delete(d),i.delete(d)},process:d=>{if(o=d,r){a=!0;return}r=!0,[t,n]=[n,t],t.forEach(l),t.clear(),r=!1,a&&(a=!1,c.process(d))}};return c}const Xi=["read","resolveKeyframes","update","preRender","render","postRender"],Bj=40;function Ey(e,t){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=Xi.reduce((x,g)=>(x[g]=Dj(i),x),{}),{read:l,resolveKeyframes:c,update:d,preRender:h,render:p,postRender:f}=o,m=()=>{const x=performance.now();n=!1,a.delta=r?1e3/60:Math.max(Math.min(x-a.timestamp,Bj),1),a.timestamp=x,a.isProcessing=!0,l.process(a),c.process(a),d.process(a),h.process(a),p.process(a),f.process(a),a.isProcessing=!1,n&&t&&(r=!1,e(m))},b=()=>{n=!0,r=!0,a.isProcessing||e(m)};return{schedule:Xi.reduce((x,g)=>{const w=o[g];return x[g]=(j,k=!1,S=!1)=>(n||b(),w.schedule(j,k,S)),x},{}),cancel:x=>{for(let g=0;g<Xi.length;g++)o[Xi[g]].cancel(x)},state:a,steps:o}}const{schedule:Ne,cancel:cs,state:Ye,steps:kc}=Ey(typeof requestAnimationFrame<"u"?requestAnimationFrame:kt,!0),_y=u.createContext({strict:!1}),Gf={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ur={};for(const e in Gf)Ur[e]={isEnabled:t=>Gf[e].some(n=>!!t[n])};function Fj(e){for(const t in e)Ur[t]={...Ur[t],...e[t]}}const $j=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function rl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||$j.has(e)}let Ty=e=>!rl(e);function Py(e){e&&(Ty=t=>t.startsWith("on")?!rl(t):e(t))}try{Py(require("@emotion/is-prop-valid").default)}catch{}function Vj(e,t,n){const r={};for(const a in e)a==="values"&&typeof e.values=="object"||(Ty(a)||n===!0&&rl(a)||!t&&!rl(a)||e.draggable&&a.startsWith("onDrag"))&&(r[a]=e[a]);return r}function Uj({children:e,isValidProp:t,...n}){t&&Py(t),n={...u.useContext(ai),...n},n.isStatic=Al(()=>n.isStatic);const r=u.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return s.jsx(ai.Provider,{value:r,children:e})}function Hj(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...r)=>e(...r);return new Proxy(n,{get:(r,a)=>a==="create"?e:(t.has(a)||t.set(a,e(a)),t.get(a))})}const zl=u.createContext({});function ii(e){return typeof e=="string"||Array.isArray(e)}function Rl(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Eh=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],_h=["initial",...Eh];function Ll(e){return Rl(e.animate)||_h.some(t=>ii(e[t]))}function Ay(e){return!!(Ll(e)||e.variants)}function Wj(e,t){if(Ll(e)){const{initial:n,animate:r}=e;return{initial:n===!1||ii(n)?n:void 0,animate:ii(r)?r:void 0}}return e.inherit!==!1?t:{}}function Kj(e){const{initial:t,animate:n}=Wj(e,u.useContext(zl));return u.useMemo(()=>({initial:t,animate:n}),[qf(t),qf(n)])}function qf(e){return Array.isArray(e)?e.join(" "):e}const Gj=Symbol.for("motionComponentSymbol");function jr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function qj(e,t,n){return u.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):jr(n)&&(n.current=r))},[t])}const Th=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Yj="framerAppearId",My="data-"+Th(Yj),{schedule:Ph}=Ey(queueMicrotask,!1),zy=u.createContext({});function Xj(e,t,n,r,a){var i,o;const{visualElement:l}=u.useContext(zl),c=u.useContext(_y),d=u.useContext(Ml),h=u.useContext(ai).reducedMotion,p=u.useRef(null);r=r||c.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:l,props:n,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:h}));const f=p.current,m=u.useContext(zy);f&&!f.projection&&a&&(f.type==="html"||f.type==="svg")&&Qj(p.current,n,a,m);const b=u.useRef(!1);u.useInsertionEffect(()=>{f&&b.current&&f.update(n,d)});const y=n[My],v=u.useRef(!!y&&!(!((i=window.MotionHandoffIsComplete)===null||i===void 0)&&i.call(window,y))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,y)));return Sy(()=>{f&&(b.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),Ph.render(f.render),v.current&&f.animationState&&f.animationState.animateChanges())}),u.useEffect(()=>{f&&(!v.current&&f.animationState&&f.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{var x;(x=window.MotionHandoffMarkAsComplete)===null||x===void 0||x.call(window,y)}),v.current=!1))}),f}function Qj(e,t,n,r){const{layoutId:a,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Ry(e.parent)),e.projection.setOptions({layoutId:a,layout:i,alwaysMeasureLayout:!!o||l&&jr(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,layoutScroll:c,layoutRoot:d})}function Ry(e){if(e)return e.options.allowProjection!==!1?e.projection:Ry(e.parent)}function Jj({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:r,Component:a}){var i,o;e&&Fj(e);function l(d,h){let p;const f={...u.useContext(ai),...d,layoutId:Zj(d)},{isStatic:m}=f,b=Kj(d),y=r(d,m);if(!m&&Sh){e5();const v=t5(f);p=v.MeasureLayout,b.visualElement=Xj(a,y,f,t,v.ProjectionNode)}return s.jsxs(zl.Provider,{value:b,children:[p&&b.visualElement?s.jsx(p,{visualElement:b.visualElement,...f}):null,n(a,d,qj(y,b.visualElement,h),y,m,b.visualElement)]})}l.displayName=`motion.${typeof a=="string"?a:`create(${(o=(i=a.displayName)!==null&&i!==void 0?i:a.name)!==null&&o!==void 0?o:""})`}`;const c=u.forwardRef(l);return c[Gj]=a,c}function Zj({layoutId:e}){const t=u.useContext(Nh).id;return t&&e!==void 0?t+"-"+e:e}function e5(e,t){u.useContext(_y).strict}function t5(e){const{drag:t,layout:n}=Ur;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}const n5=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ah(e){return typeof e!="string"||e.includes("-")?!1:!!(n5.indexOf(e)>-1||/[A-Z]/u.test(e))}function Yf(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Mh(e,t,n,r){if(typeof t=="function"){const[a,i]=Yf(r);t=t(n!==void 0?n:e.custom,a,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,i]=Yf(r);t=t(n!==void 0?n:e.custom,a,i)}return t}const Yd=e=>Array.isArray(e),s5=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),r5=e=>Yd(e)?e[e.length-1]||0:e,nt=e=>!!(e&&e.getVelocity);function jo(e){const t=nt(e)?e.get():e;return s5(t)?t.toValue():t}function a5({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},r,a,i){const o={latestValues:i5(r,a,i,e),renderState:t()};return n&&(o.onMount=l=>n({props:r,current:l,...o}),o.onUpdate=l=>n(l)),o}const Ly=e=>(t,n)=>{const r=u.useContext(zl),a=u.useContext(Ml),i=()=>a5(e,t,r,a);return n?i():Al(i)};function i5(e,t,n,r){const a={},i=r(e,{});for(const f in i)a[f]=jo(i[f]);let{initial:o,animate:l}=e;const c=Ll(e),d=Ay(e);t&&d&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?l:o;if(p&&typeof p!="boolean"&&!Rl(p)){const f=Array.isArray(p)?p:[p];for(let m=0;m<f.length;m++){const b=Mh(e,f[m]);if(b){const{transitionEnd:y,transition:v,...x}=b;for(const g in x){let w=x[g];if(Array.isArray(w)){const j=h?w.length-1:0;w=w[j]}w!==null&&(a[g]=w)}for(const g in y)a[g]=y[g]}}}return a}const ea=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ys=new Set(ea),Oy=e=>t=>typeof t=="string"&&t.startsWith(e),Iy=Oy("--"),o5=Oy("var(--"),zh=e=>o5(e)?l5.test(e.split("/*")[0].trim()):!1,l5=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Dy=(e,t)=>t&&typeof e=="number"?t.transform(e):e,An=(e,t,n)=>n>t?t:n<e?e:n,ta={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},oi={...ta,transform:e=>An(0,1,e)},Qi={...ta,default:1},bi=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$n=bi("deg"),un=bi("%"),re=bi("px"),c5=bi("vh"),d5=bi("vw"),Xf={...un,parse:e=>un.parse(e)/100,transform:e=>un.transform(e*100)},u5={borderWidth:re,borderTopWidth:re,borderRightWidth:re,borderBottomWidth:re,borderLeftWidth:re,borderRadius:re,radius:re,borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomRightRadius:re,borderBottomLeftRadius:re,width:re,maxWidth:re,height:re,maxHeight:re,top:re,right:re,bottom:re,left:re,padding:re,paddingTop:re,paddingRight:re,paddingBottom:re,paddingLeft:re,margin:re,marginTop:re,marginRight:re,marginBottom:re,marginLeft:re,backgroundPositionX:re,backgroundPositionY:re},h5={rotate:$n,rotateX:$n,rotateY:$n,rotateZ:$n,scale:Qi,scaleX:Qi,scaleY:Qi,scaleZ:Qi,skew:$n,skewX:$n,skewY:$n,distance:re,translateX:re,translateY:re,translateZ:re,x:re,y:re,z:re,perspective:re,transformPerspective:re,opacity:oi,originX:Xf,originY:Xf,originZ:re},Qf={...ta,transform:Math.round},Rh={...u5,...h5,zIndex:Qf,size:re,fillOpacity:oi,strokeOpacity:oi,numOctaves:Qf},p5={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},f5=ea.length;function m5(e,t,n){let r="",a=!0;for(let i=0;i<f5;i++){const o=ea[i],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const d=Dy(l,Rh[o]);if(!c){a=!1;const h=p5[o]||o;r+=`${h}(${d}) `}n&&(t[o]=d)}}return r=r.trim(),n?r=n(t,a?"":r):a&&(r="none"),r}function Lh(e,t,n){const{style:r,vars:a,transformOrigin:i}=e;let o=!1,l=!1;for(const c in t){const d=t[c];if(Ys.has(c)){o=!0;continue}else if(Iy(c)){a[c]=d;continue}else{const h=Dy(d,Rh[c]);c.startsWith("origin")?(l=!0,i[c]=h):r[c]=h}}if(t.transform||(o||n?r.transform=m5(t,e.transform,n):r.transform&&(r.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:h=0}=i;r.transformOrigin=`${c} ${d} ${h}`}}const x5={offset:"stroke-dashoffset",array:"stroke-dasharray"},g5={offset:"strokeDashoffset",array:"strokeDasharray"};function y5(e,t,n=1,r=0,a=!0){e.pathLength=1;const i=a?x5:g5;e[i.offset]=re.transform(-r);const o=re.transform(t),l=re.transform(n);e[i.array]=`${o} ${l}`}function Jf(e,t,n){return typeof e=="string"?e:re.transform(t+n*e)}function v5(e,t,n){const r=Jf(t,e.x,e.width),a=Jf(n,e.y,e.height);return`${r} ${a}`}function Oh(e,{attrX:t,attrY:n,attrScale:r,originX:a,originY:i,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...d},h,p){if(Lh(e,d,p),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:m,dimensions:b}=e;f.transform&&(b&&(m.transform=f.transform),delete f.transform),b&&(a!==void 0||i!==void 0||m.transform)&&(m.transformOrigin=v5(b,a!==void 0?a:.5,i!==void 0?i:.5)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),r!==void 0&&(f.scale=r),o!==void 0&&y5(f,o,l,c,!1)}const Ih=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),By=()=>({...Ih(),attrs:{}}),Dh=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Fy(e,{style:t,vars:n},r,a){Object.assign(e.style,t,a&&a.getProjectionStyles(r));for(const i in n)e.style.setProperty(i,n[i])}const $y=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Vy(e,t,n,r){Fy(e,t,void 0,r);for(const a in t.attrs)e.setAttribute($y.has(a)?a:Th(a),t.attrs[a])}const al={};function b5(e){Object.assign(al,e)}function Uy(e,{layout:t,layoutId:n}){return Ys.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!al[e]||e==="opacity")}function Bh(e,t,n){var r;const{style:a}=e,i={};for(const o in a)(nt(a[o])||t.style&&nt(t.style[o])||Uy(o,e)||((r=n==null?void 0:n.getValue(o))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(i[o]=a[o]);return i}function Hy(e,t,n){const r=Bh(e,t,n);for(const a in e)if(nt(e[a])||nt(t[a])){const i=ea.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[i]=e[a]}return r}function w5(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const Zf=["x","y","width","height","cx","cy","r"],k5={useVisualState:Ly({scrapeMotionValuesFromProps:Hy,createRenderState:By,onUpdate:({props:e,prevProps:t,current:n,renderState:r,latestValues:a})=>{if(!n)return;let i=!!e.drag;if(!i){for(const l in a)if(Ys.has(l)){i=!0;break}}if(!i)return;let o=!t;if(t)for(let l=0;l<Zf.length;l++){const c=Zf[l];e[c]!==t[c]&&(o=!0)}o&&Ne.read(()=>{w5(n,r),Ne.render(()=>{Oh(r,a,Dh(n.tagName),e.transformTemplate),Vy(n,r)})})}})},j5={useVisualState:Ly({scrapeMotionValuesFromProps:Bh,createRenderState:Ih})};function Wy(e,t,n){for(const r in t)!nt(t[r])&&!Uy(r,n)&&(e[r]=t[r])}function N5({transformTemplate:e},t){return u.useMemo(()=>{const n=Ih();return Lh(n,t,e),Object.assign({},n.vars,n.style)},[t])}function S5(e,t){const n=e.style||{},r={};return Wy(r,n,e),Object.assign(r,N5(e,t)),r}function C5(e,t){const n={},r=S5(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function E5(e,t,n,r){const a=u.useMemo(()=>{const i=By();return Oh(i,t,Dh(r),e.transformTemplate),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Wy(i,e.style,e),a.style={...i,...a.style}}return a}function _5(e=!1){return(n,r,a,{latestValues:i},o)=>{const c=(Ah(n)?E5:C5)(r,i,o,n),d=Vj(r,typeof n=="string",e),h=n!==u.Fragment?{...d,...c,ref:a}:{},{children:p}=r,f=u.useMemo(()=>nt(p)?p.get():p,[p]);return u.createElement(n,{...h,children:f})}}function T5(e,t){return function(r,{forwardMotionProps:a}={forwardMotionProps:!1}){const o={...Ah(r)?k5:j5,preloadedFeatures:e,useRender:_5(a),createVisualElement:t,Component:r};return Jj(o)}}function Ky(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Ol(e,t,n){const r=e.getProps();return Mh(r,t,n!==void 0?n:r.custom,e)}const P5=Ch(()=>window.ScrollTimeline!==void 0);class A5{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t,n){const r=this.animations.map(a=>{if(P5()&&a.attachTimeline)return a.attachTimeline(t);if(typeof n=="function")return n(a)});return()=>{r.forEach((a,i)=>{a&&a(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class M5 extends A5{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Fh(e,t){return e?e[t]||e.default||e:void 0}const Xd=2e4;function Gy(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<Xd;)t+=n,r=e.next(t);return t>=Xd?1/0:t}function $h(e){return typeof e=="function"}function em(e,t){e.timeline=t,e.onfinish=null}const Vh=e=>Array.isArray(e)&&typeof e[0]=="number",z5={linearEasing:void 0};function R5(e,t){const n=Ch(e);return()=>{var r;return(r=z5[t])!==null&&r!==void 0?r:n()}}const il=R5(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),qy=(e,t,n=10)=>{let r="";const a=Math.max(Math.round(t/n),2);for(let i=0;i<a;i++)r+=e(Vr(0,a-1,i))+", ";return`linear(${r.substring(0,r.length-2)})`};function Yy(e){return!!(typeof e=="function"&&il()||!e||typeof e=="string"&&(e in Qd||il())||Vh(e)||Array.isArray(e)&&e.every(Yy))}const ba=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Qd={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ba([0,.65,.55,1]),circOut:ba([.55,0,1,.45]),backIn:ba([.31,.01,.66,-.59]),backOut:ba([.33,1.53,.69,.99])};function Xy(e,t){if(e)return typeof e=="function"&&il()?qy(e,t):Vh(e)?ba(e):Array.isArray(e)?e.map(n=>Xy(n,t)||Qd.easeOut):Qd[e]}const Ht={x:!1,y:!1};function Qy(){return Ht.x||Ht.y}function L5(e,t,n){var r;if(e instanceof Element)return[e];if(typeof e=="string"){let a=document;const i=(r=void 0)!==null&&r!==void 0?r:a.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}function Jy(e,t){const n=L5(e),r=new AbortController,a={passive:!0,...t,signal:r.signal};return[n,a,()=>r.abort()]}function tm(e){return t=>{t.pointerType==="touch"||Qy()||e(t)}}function O5(e,t,n={}){const[r,a,i]=Jy(e,n),o=tm(l=>{const{target:c}=l,d=t(l);if(typeof d!="function"||!c)return;const h=tm(p=>{d(p),c.removeEventListener("pointerleave",h)});c.addEventListener("pointerleave",h,a)});return r.forEach(l=>{l.addEventListener("pointerenter",o,a)}),i}const Zy=(e,t)=>t?e===t?!0:Zy(e,t.parentElement):!1,Uh=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,I5=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function D5(e){return I5.has(e.tagName)||e.tabIndex!==-1}const wa=new WeakSet;function nm(e){return t=>{t.key==="Enter"&&e(t)}}function jc(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const B5=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=nm(()=>{if(wa.has(n))return;jc(n,"down");const a=nm(()=>{jc(n,"up")}),i=()=>jc(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",i,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function sm(e){return Uh(e)&&!Qy()}function F5(e,t,n={}){const[r,a,i]=Jy(e,n),o=l=>{const c=l.currentTarget;if(!sm(l)||wa.has(c))return;wa.add(c);const d=t(l),h=(m,b)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",f),!(!sm(m)||!wa.has(c))&&(wa.delete(c),typeof d=="function"&&d(m,{success:b}))},p=m=>{h(m,n.useGlobalTarget||Zy(c,m.target))},f=m=>{h(m,!1)};window.addEventListener("pointerup",p,a),window.addEventListener("pointercancel",f,a)};return r.forEach(l=>{!D5(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,a),l.addEventListener("focus",d=>B5(d,a),a)}),i}function $5(e){return e==="x"||e==="y"?Ht[e]?null:(Ht[e]=!0,()=>{Ht[e]=!1}):Ht.x||Ht.y?null:(Ht.x=Ht.y=!0,()=>{Ht.x=Ht.y=!1})}const e1=new Set(["width","height","top","left","right","bottom",...ea]);let No;function V5(){No=void 0}const hn={now:()=>(No===void 0&&hn.set(Ye.isProcessing||Ij.useManualTiming?Ye.timestamp:performance.now()),No),set:e=>{No=e,queueMicrotask(V5)}};function Hh(e,t){e.indexOf(t)===-1&&e.push(t)}function Wh(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class Kh{constructor(){this.subscriptions=[]}add(t){return Hh(this.subscriptions,t),()=>Wh(this.subscriptions,t)}notify(t,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,r);else for(let i=0;i<a;i++){const o=this.subscriptions[i];o&&o(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function t1(e,t){return t?e*(1e3/t):0}const rm=30,U5=e=>!isNaN(parseFloat(e));class H5{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,a=!0)=>{const i=hn.now();this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),a&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=hn.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=U5(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Kh);const r=this.events[t].add(n);return t==="change"?()=>{r(),Ne.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=hn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>rm)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,rm);return t1(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function li(e,t){return new H5(e,t)}function W5(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,li(n))}function K5(e,t){const n=Ol(e,t);let{transitionEnd:r={},transition:a={},...i}=n||{};i={...i,...r};for(const o in i){const l=r5(i[o]);W5(e,o,l)}}function G5(e){return!!(nt(e)&&e.add)}function Jd(e,t){const n=e.getValue("willChange");if(G5(n))return n.add(t)}function n1(e){return e.props[My]}const s1=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,q5=1e-7,Y5=12;function X5(e,t,n,r,a){let i,o,l=0;do o=t+(n-t)/2,i=s1(o,r,a)-e,i>0?n=o:t=o;while(Math.abs(i)>q5&&++l<Y5);return o}function wi(e,t,n,r){if(e===t&&n===r)return kt;const a=i=>X5(i,0,1,e,n);return i=>i===0||i===1?i:s1(a(i),t,r)}const r1=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,a1=e=>t=>1-e(1-t),i1=wi(.33,1.53,.69,.99),Gh=a1(i1),o1=r1(Gh),l1=e=>(e*=2)<1?.5*Gh(e):.5*(2-Math.pow(2,-10*(e-1))),qh=e=>1-Math.sin(Math.acos(e)),c1=a1(qh),d1=r1(qh),u1=e=>/^0[^.\s]+$/u.test(e);function Q5(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||u1(e):!0}const La=e=>Math.round(e*1e5)/1e5,Yh=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function J5(e){return e==null}const Z5=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Xh=(e,t)=>n=>!!(typeof n=="string"&&Z5.test(n)&&n.startsWith(e)||t&&!J5(n)&&Object.prototype.hasOwnProperty.call(n,t)),h1=(e,t,n)=>r=>{if(typeof r!="string")return r;const[a,i,o,l]=r.match(Yh);return{[e]:parseFloat(a),[t]:parseFloat(i),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},eN=e=>An(0,255,e),Nc={...ta,transform:e=>Math.round(eN(e))},As={test:Xh("rgb","red"),parse:h1("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Nc.transform(e)+", "+Nc.transform(t)+", "+Nc.transform(n)+", "+La(oi.transform(r))+")"};function tN(e){let t="",n="",r="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,r+=r,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:a?parseInt(a,16)/255:1}}const Zd={test:Xh("#"),parse:tN,transform:As.transform},Nr={test:Xh("hsl","hue"),parse:h1("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+un.transform(La(t))+", "+un.transform(La(n))+", "+La(oi.transform(r))+")"},et={test:e=>As.test(e)||Zd.test(e)||Nr.test(e),parse:e=>As.test(e)?As.parse(e):Nr.test(e)?Nr.parse(e):Zd.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?As.transform(e):Nr.transform(e)},nN=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function sN(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Yh))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(nN))===null||n===void 0?void 0:n.length)||0)>0}const p1="number",f1="color",rN="var",aN="var(",am="${}",iN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function ci(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},a=[];let i=0;const l=t.replace(iN,c=>(et.test(c)?(r.color.push(i),a.push(f1),n.push(et.parse(c))):c.startsWith(aN)?(r.var.push(i),a.push(rN),n.push(c)):(r.number.push(i),a.push(p1),n.push(parseFloat(c))),++i,am)).split(am);return{values:n,split:l,indexes:r,types:a}}function m1(e){return ci(e).values}function x1(e){const{split:t,types:n}=ci(e),r=t.length;return a=>{let i="";for(let o=0;o<r;o++)if(i+=t[o],a[o]!==void 0){const l=n[o];l===p1?i+=La(a[o]):l===f1?i+=et.transform(a[o]):i+=a[o]}return i}}const oN=e=>typeof e=="number"?0:e;function lN(e){const t=m1(e);return x1(e)(t.map(oN))}const ds={test:sN,parse:m1,createTransformer:x1,getAnimatableNone:lN},cN=new Set(["brightness","contrast","saturate","opacity"]);function dN(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Yh)||[];if(!r)return e;const a=n.replace(r,"");let i=cN.has(t)?1:0;return r!==n&&(i*=100),t+"("+i+a+")"}const uN=/\b([a-z-]*)\(.*?\)/gu,eu={...ds,getAnimatableNone:e=>{const t=e.match(uN);return t?t.map(dN).join(" "):e}},hN={...Rh,color:et,backgroundColor:et,outlineColor:et,fill:et,stroke:et,borderColor:et,borderTopColor:et,borderRightColor:et,borderBottomColor:et,borderLeftColor:et,filter:eu,WebkitFilter:eu},Qh=e=>hN[e];function g1(e,t){let n=Qh(e);return n!==eu&&(n=ds),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const pN=new Set(["auto","none","0"]);function fN(e,t,n){let r=0,a;for(;r<e.length&&!a;){const i=e[r];typeof i=="string"&&!pN.has(i)&&ci(i).values.length&&(a=e[r]),r++}if(a&&n)for(const i of t)e[i]=g1(n,a)}const im=e=>e===ta||e===re,om=(e,t)=>parseFloat(e.split(", ")[t]),lm=(e,t)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;const a=r.match(/^matrix3d\((.+)\)$/u);if(a)return om(a[1],t);{const i=r.match(/^matrix\((.+)\)$/u);return i?om(i[1],e):0}},mN=new Set(["x","y","z"]),xN=ea.filter(e=>!mN.has(e));function gN(e){const t=[];return xN.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Hr={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:lm(4,13),y:lm(5,14)};Hr.translateX=Hr.x;Hr.translateY=Hr.y;const Ls=new Set;let tu=!1,nu=!1;function y1(){if(nu){const e=Array.from(Ls).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const a=gN(r);a.length&&(n.set(r,a),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([i,o])=>{var l;(l=r.getValue(i))===null||l===void 0||l.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}nu=!1,tu=!1,Ls.forEach(e=>e.complete()),Ls.clear()}function v1(){Ls.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(nu=!0)})}function yN(){v1(),y1()}class Jh{constructor(t,n,r,a,i,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=a,this.element=i,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ls.add(this),tu||(tu=!0,Ne.read(v1),Ne.resolveKeyframes(y1))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:a}=this;for(let i=0;i<t.length;i++)if(t[i]===null)if(i===0){const o=a==null?void 0:a.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const c=r.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),a&&o===void 0&&a.set(t[0])}else t[i]=t[i-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Ls.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Ls.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const b1=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),vN=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function bN(e){const t=vN.exec(e);if(!t)return[,];const[,n,r,a]=t;return[`--${n??r}`,a]}function w1(e,t,n=1){const[r,a]=bN(e);if(!r)return;const i=window.getComputedStyle(t).getPropertyValue(r);if(i){const o=i.trim();return b1(o)?parseFloat(o):o}return zh(a)?w1(a,t,n+1):a}const k1=e=>t=>t.test(e),wN={test:e=>e==="auto",parse:e=>e},j1=[ta,re,un,$n,d5,c5,wN],cm=e=>j1.find(k1(e));class N1 extends Jh{constructor(t,n,r,a,i){super(t,n,r,a,i,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let d=t[c];if(typeof d=="string"&&(d=d.trim(),zh(d))){const h=w1(d,n.current);h!==void 0&&(t[c]=h),c===t.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!e1.has(r)||t.length!==2)return;const[a,i]=t,o=cm(a),l=cm(i);if(o!==l)if(im(o)&&im(l))for(let c=0;c<t.length;c++){const d=t[c];typeof d=="string"&&(t[c]=parseFloat(d))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let a=0;a<t.length;a++)Q5(t[a])&&r.push(a);r.length&&fN(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Hr[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&t.getValue(r,a).jump(a,!1)}measureEndState(){var t;const{element:n,name:r,unresolvedKeyframes:a}=this;if(!n||!n.current)return;const i=n.getValue(r);i&&i.jump(this.measuredOrigin,!1);const o=a.length-1,l=a[o];a[o]=Hr[r](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,d])=>{n.getValue(c).set(d)}),this.resolveNoneKeyframes()}}const dm=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ds.test(e)||e==="0")&&!e.startsWith("url("));function kN(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function jN(e,t,n,r){const a=e[0];if(a===null)return!1;if(t==="display"||t==="visibility")return!0;const i=e[e.length-1],o=dm(a,t),l=dm(i,t);return!o||!l?!1:kN(e)||(n==="spring"||$h(n))&&r}const NN=e=>e!==null;function Il(e,{repeat:t,repeatType:n="loop"},r){const a=e.filter(NN),i=t&&n!=="loop"&&t%2===1?0:a.length-1;return!i||r===void 0?a[i]:r}const SN=40;class S1{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:i=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=hn.now(),this.options={autoplay:t,delay:n,type:r,repeat:a,repeatDelay:i,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>SN?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&yN(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=hn.now(),this.hasAttemptedResolve=!0;const{name:r,type:a,velocity:i,delay:o,onComplete:l,onUpdate:c,isGenerator:d}=this.options;if(!d&&!jN(t,r,a,i))if(o)this.options.duration=0;else{c&&c(Il(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const h=this.initPlayback(t,n);h!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...h},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const _e=(e,t,n)=>e+(t-e)*n;function Sc(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function CN({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let a=0,i=0,o=0;if(!t)a=i=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;a=Sc(c,l,e+1/3),i=Sc(c,l,e),o=Sc(c,l,e-1/3)}return{red:Math.round(a*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}function ol(e,t){return n=>n>0?t:e}const Cc=(e,t,n)=>{const r=e*e,a=n*(t*t-r)+r;return a<0?0:Math.sqrt(a)},EN=[Zd,As,Nr],_N=e=>EN.find(t=>t.test(e));function um(e){const t=_N(e);if(!t)return!1;let n=t.parse(e);return t===Nr&&(n=CN(n)),n}const hm=(e,t)=>{const n=um(e),r=um(t);if(!n||!r)return ol(e,t);const a={...n};return i=>(a.red=Cc(n.red,r.red,i),a.green=Cc(n.green,r.green,i),a.blue=Cc(n.blue,r.blue,i),a.alpha=_e(n.alpha,r.alpha,i),As.transform(a))},TN=(e,t)=>n=>t(e(n)),ki=(...e)=>e.reduce(TN),su=new Set(["none","hidden"]);function PN(e,t){return su.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function AN(e,t){return n=>_e(e,t,n)}function Zh(e){return typeof e=="number"?AN:typeof e=="string"?zh(e)?ol:et.test(e)?hm:RN:Array.isArray(e)?C1:typeof e=="object"?et.test(e)?hm:MN:ol}function C1(e,t){const n=[...e],r=n.length,a=e.map((i,o)=>Zh(i)(i,t[o]));return i=>{for(let o=0;o<r;o++)n[o]=a[o](i);return n}}function MN(e,t){const n={...e,...t},r={};for(const a in n)e[a]!==void 0&&t[a]!==void 0&&(r[a]=Zh(e[a])(e[a],t[a]));return a=>{for(const i in r)n[i]=r[i](a);return n}}function zN(e,t){var n;const r=[],a={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],l=e.indexes[o][a[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;r[i]=c,a[o]++}return r}const RN=(e,t)=>{const n=ds.createTransformer(t),r=ci(e),a=ci(t);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?su.has(e)&&!a.values.length||su.has(t)&&!r.values.length?PN(e,t):ki(C1(zN(r,a),a.values),n):ol(e,t)};function E1(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?_e(e,t,n):Zh(e)(e,t)}const LN=5;function _1(e,t,n){const r=Math.max(t-LN,0);return t1(n-e(r),t-r)}const Ae={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ec=.001;function ON({duration:e=Ae.duration,bounce:t=Ae.bounce,velocity:n=Ae.velocity,mass:r=Ae.mass}){let a,i,o=1-t;o=An(Ae.minDamping,Ae.maxDamping,o),e=An(Ae.minDuration,Ae.maxDuration,Cn(e)),o<1?(a=d=>{const h=d*o,p=h*e,f=h-n,m=ru(d,o),b=Math.exp(-p);return Ec-f/m*b},i=d=>{const p=d*o*e,f=p*n+n,m=Math.pow(o,2)*Math.pow(d,2)*e,b=Math.exp(-p),y=ru(Math.pow(d,2),o);return(-a(d)+Ec>0?-1:1)*((f-m)*b)/y}):(a=d=>{const h=Math.exp(-d*e),p=(d-n)*e+1;return-Ec+h*p},i=d=>{const h=Math.exp(-d*e),p=(n-d)*(e*e);return h*p});const l=5/e,c=DN(a,i,l);if(e=Sn(e),isNaN(c))return{stiffness:Ae.stiffness,damping:Ae.damping,duration:e};{const d=Math.pow(c,2)*r;return{stiffness:d,damping:o*2*Math.sqrt(r*d),duration:e}}}const IN=12;function DN(e,t,n){let r=n;for(let a=1;a<IN;a++)r=r-e(r)/t(r);return r}function ru(e,t){return e*Math.sqrt(1-t*t)}const BN=["duration","bounce"],FN=["stiffness","damping","mass"];function pm(e,t){return t.some(n=>e[n]!==void 0)}function $N(e){let t={velocity:Ae.velocity,stiffness:Ae.stiffness,damping:Ae.damping,mass:Ae.mass,isResolvedFromDuration:!1,...e};if(!pm(e,FN)&&pm(e,BN))if(e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,i=2*An(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:Ae.mass,stiffness:a,damping:i}}else{const n=ON(e);t={...t,...n,mass:Ae.mass},t.isResolvedFromDuration=!0}return t}function T1(e=Ae.visualDuration,t=Ae.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:a}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:i},{stiffness:c,damping:d,mass:h,duration:p,velocity:f,isResolvedFromDuration:m}=$N({...n,velocity:-Cn(n.velocity||0)}),b=f||0,y=d/(2*Math.sqrt(c*h)),v=o-i,x=Cn(Math.sqrt(c/h)),g=Math.abs(v)<5;r||(r=g?Ae.restSpeed.granular:Ae.restSpeed.default),a||(a=g?Ae.restDelta.granular:Ae.restDelta.default);let w;if(y<1){const k=ru(x,y);w=S=>{const C=Math.exp(-y*x*S);return o-C*((b+y*x*v)/k*Math.sin(k*S)+v*Math.cos(k*S))}}else if(y===1)w=k=>o-Math.exp(-x*k)*(v+(b+x*v)*k);else{const k=x*Math.sqrt(y*y-1);w=S=>{const C=Math.exp(-y*x*S),A=Math.min(k*S,300);return o-C*((b+y*x*v)*Math.sinh(A)+k*v*Math.cosh(A))/k}}const j={calculatedDuration:m&&p||null,next:k=>{const S=w(k);if(m)l.done=k>=p;else{let C=0;y<1&&(C=k===0?Sn(b):_1(w,k,S));const A=Math.abs(C)<=r,N=Math.abs(o-S)<=a;l.done=A&&N}return l.value=l.done?o:S,l},toString:()=>{const k=Math.min(Gy(j),Xd),S=qy(C=>j.next(k*C).value,k,30);return k+"ms "+S}};return j}function fm({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:i=500,modifyTarget:o,min:l,max:c,restDelta:d=.5,restSpeed:h}){const p=e[0],f={done:!1,value:p},m=A=>l!==void 0&&A<l||c!==void 0&&A>c,b=A=>l===void 0?c:c===void 0||Math.abs(l-A)<Math.abs(c-A)?l:c;let y=n*t;const v=p+y,x=o===void 0?v:o(v);x!==v&&(y=x-p);const g=A=>-y*Math.exp(-A/r),w=A=>x+g(A),j=A=>{const N=g(A),_=w(A);f.done=Math.abs(N)<=d,f.value=f.done?x:_};let k,S;const C=A=>{m(f.value)&&(k=A,S=T1({keyframes:[f.value,b(f.value)],velocity:_1(w,A,f.value),damping:a,stiffness:i,restDelta:d,restSpeed:h}))};return C(0),{calculatedDuration:null,next:A=>{let N=!1;return!S&&k===void 0&&(N=!0,j(A),C(A)),k!==void 0&&A>=k?S.next(A-k):(!N&&j(A),f)}}}const VN=wi(.42,0,1,1),UN=wi(0,0,.58,1),P1=wi(.42,0,.58,1),HN=e=>Array.isArray(e)&&typeof e[0]!="number",WN={linear:kt,easeIn:VN,easeInOut:P1,easeOut:UN,circIn:qh,circInOut:d1,circOut:c1,backIn:Gh,backInOut:o1,backOut:i1,anticipate:l1},mm=e=>{if(Vh(e)){Cy(e.length===4);const[t,n,r,a]=e;return wi(t,n,r,a)}else if(typeof e=="string")return WN[e];return e};function KN(e,t,n){const r=[],a=n||E1,i=e.length-1;for(let o=0;o<i;o++){let l=a(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||kt:t;l=ki(c,l)}r.push(l)}return r}function GN(e,t,{clamp:n=!0,ease:r,mixer:a}={}){const i=e.length;if(Cy(i===t.length),i===1)return()=>t[0];if(i===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=KN(t,r,a),c=l.length,d=h=>{if(o&&h<e[0])return t[0];let p=0;if(c>1)for(;p<e.length-2&&!(h<e[p+1]);p++);const f=Vr(e[p],e[p+1],h);return l[p](f)};return n?h=>d(An(e[0],e[i-1],h)):d}function qN(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const a=Vr(0,t,r);e.push(_e(n,1,a))}}function YN(e){const t=[0];return qN(t,e.length-1),t}function XN(e,t){return e.map(n=>n*t)}function QN(e,t){return e.map(()=>t||P1).splice(0,e.length-1)}function ll({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const a=HN(r)?r.map(mm):mm(r),i={done:!1,value:t[0]},o=XN(n&&n.length===t.length?n:YN(t),e),l=GN(o,t,{ease:Array.isArray(a)?a:QN(t,a)});return{calculatedDuration:e,next:c=>(i.value=l(c),i.done=c>=e,i)}}const JN=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Ne.update(t,!0),stop:()=>cs(t),now:()=>Ye.isProcessing?Ye.timestamp:hn.now()}},ZN={decay:fm,inertia:fm,tween:ll,keyframes:ll,spring:T1},eS=e=>e/100;class ep extends S1{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:r,element:a,keyframes:i}=this.options,o=(a==null?void 0:a.KeyframeResolver)||Jh,l=(c,d)=>this.onKeyframesResolved(c,d);this.resolver=new o(i,l,n,r,a),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:r=0,repeatDelay:a=0,repeatType:i,velocity:o=0}=this.options,l=$h(n)?n:ZN[n]||ll;let c,d;l!==ll&&typeof t[0]!="number"&&(c=ki(eS,E1(t[0],t[1])),t=[0,100]);const h=l({...this.options,keyframes:t});i==="mirror"&&(d=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),h.calculatedDuration===null&&(h.calculatedDuration=Gy(h));const{calculatedDuration:p}=h,f=p+a,m=f*(r+1)-a;return{generator:h,mirroredGenerator:d,mapPercentToKeyframes:c,calculatedDuration:p,resolvedDuration:f,totalDuration:m}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:r}=this;if(!r){const{keyframes:A}=this.options;return{done:!0,value:A[A.length-1]}}const{finalKeyframe:a,generator:i,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:d,totalDuration:h,resolvedDuration:p}=r;if(this.startTime===null)return i.next(0);const{delay:f,repeat:m,repeatType:b,repeatDelay:y,onUpdate:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-h/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const x=this.currentTime-f*(this.speed>=0?1:-1),g=this.speed>=0?x<0:x>h;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=h);let w=this.currentTime,j=i;if(m){const A=Math.min(this.currentTime,h)/p;let N=Math.floor(A),_=A%1;!_&&A>=1&&(_=1),_===1&&N--,N=Math.min(N,m+1),!!(N%2)&&(b==="reverse"?(_=1-_,y&&(_-=y/p)):b==="mirror"&&(j=o)),w=An(0,1,_)*p}const k=g?{done:!1,value:c[0]}:j.next(w);l&&(k.value=l(k.value));let{done:S}=k;!g&&d!==null&&(S=this.speed>=0?this.currentTime>=h:this.currentTime<=0);const C=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&S);return C&&a!==void 0&&(k.value=Il(c,this.options,a)),v&&v(k.value),C&&this.finish(),k}get duration(){const{resolved:t}=this;return t?Cn(t.calculatedDuration):0}get time(){return Cn(this.currentTime)}set time(t){t=Sn(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Cn(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=JN,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),n&&n();const a=this.driver.now();this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=a):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const tS=new Set(["opacity","clipPath","filter","transform"]);function nS(e,t,n,{delay:r=0,duration:a=300,repeat:i=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const d={[t]:n};c&&(d.offset=c);const h=Xy(l,a);return Array.isArray(h)&&(d.easing=h),e.animate(d,{delay:r,duration:a,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"})}const sS=Ch(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),cl=10,rS=2e4;function aS(e){return $h(e.type)||e.type==="spring"||!Yy(e.ease)}function iS(e,t){const n=new ep({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:e[0]};const a=[];let i=0;for(;!r.done&&i<rS;)r=n.sample(i),a.push(r.value),i+=cl;return{times:void 0,keyframes:a,duration:i-cl,ease:"linear"}}const A1={anticipate:l1,backInOut:o1,circInOut:d1};function oS(e){return e in A1}class xm extends S1{constructor(t){super(t);const{name:n,motionValue:r,element:a,keyframes:i}=this.options;this.resolver=new N1(i,(o,l)=>this.onKeyframesResolved(o,l),n,r,a),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:r=300,times:a,ease:i,type:o,motionValue:l,name:c,startTime:d}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof i=="string"&&il()&&oS(i)&&(i=A1[i]),aS(this.options)){const{onComplete:p,onUpdate:f,motionValue:m,element:b,...y}=this.options,v=iS(t,y);t=v.keyframes,t.length===1&&(t[1]=t[0]),r=v.duration,a=v.times,i=v.ease,o="keyframes"}const h=nS(l.owner.current,c,t,{...this.options,duration:r,times:a,ease:i});return h.startTime=d??this.calcStartTime(),this.pendingTimeline?(em(h,this.pendingTimeline),this.pendingTimeline=void 0):h.onfinish=()=>{const{onComplete:p}=this.options;l.set(Il(t,this.options,n)),p&&p(),this.cancel(),this.resolveFinishedPromise()},{animation:h,duration:r,times:a,type:o,ease:i,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return Cn(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return Cn(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.currentTime=Sn(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return kt;const{animation:r}=n;em(r,t)}return kt}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:r,duration:a,type:i,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:d,onUpdate:h,onComplete:p,element:f,...m}=this.options,b=new ep({...m,keyframes:r,duration:a,type:i,ease:o,times:l,isGenerator:!0}),y=Sn(this.time);d.setWithVelocity(b.sample(y-cl).value,b.sample(y).value,cl)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:r,repeatDelay:a,repeatType:i,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:d}=n.owner.getProps();return sS()&&r&&tS.has(r)&&!c&&!d&&!a&&i!=="mirror"&&o!==0&&l!=="inertia"}}const lS={type:"spring",stiffness:500,damping:25,restSpeed:10},cS=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),dS={type:"keyframes",duration:.8},uS={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},hS=(e,{keyframes:t})=>t.length>2?dS:Ys.has(e)?e.startsWith("scale")?cS(t[1]):lS:uS;function pS({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:i,repeatType:o,repeatDelay:l,from:c,elapsed:d,...h}){return!!Object.keys(h).length}const tp=(e,t,n,r={},a,i)=>o=>{const l=Fh(r,e)||{},c=l.delay||r.delay||0;let{elapsed:d=0}=r;d=d-Sn(c);let h={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:i?void 0:a};pS(l)||(h={...h,...hS(e,h)}),h.duration&&(h.duration=Sn(h.duration)),h.repeatDelay&&(h.repeatDelay=Sn(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let p=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(h.duration=0,h.delay===0&&(p=!0)),p&&!i&&t.get()!==void 0){const f=Il(h.keyframes,l);if(f!==void 0)return Ne.update(()=>{h.onUpdate(f),h.onComplete()}),new M5([])}return!i&&xm.supports(h)?new xm(h):new ep(h)};function fS({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function M1(e,t,{delay:n=0,transitionOverride:r,type:a}={}){var i;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;r&&(o=r);const d=[],h=a&&e.animationState&&e.animationState.getState()[a];for(const p in c){const f=e.getValue(p,(i=e.latestValues[p])!==null&&i!==void 0?i:null),m=c[p];if(m===void 0||h&&fS(h,p))continue;const b={delay:n,...Fh(o||{},p)};let y=!1;if(window.MotionHandoffAnimation){const x=n1(e);if(x){const g=window.MotionHandoffAnimation(x,p,Ne);g!==null&&(b.startTime=g,y=!0)}}Jd(e,p),f.start(tp(p,f,m,e.shouldReduceMotion&&e1.has(p)?{type:!1}:b,e,y));const v=f.animation;v&&d.push(v)}return l&&Promise.all(d).then(()=>{Ne.update(()=>{l&&K5(e,l)})}),d}function au(e,t,n={}){var r;const a=Ol(e,t,n.type==="exit"?(r=e.presenceContext)===null||r===void 0?void 0:r.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(i=n.transitionOverride);const o=a?()=>Promise.all(M1(e,a,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:h=0,staggerChildren:p,staggerDirection:f}=i;return mS(e,t,h+d,p,f,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[d,h]=c==="beforeChildren"?[o,l]:[l,o];return d().then(()=>h())}else return Promise.all([o(),l(n.delay)])}function mS(e,t,n=0,r=0,a=1,i){const o=[],l=(e.variantChildren.size-1)*r,c=a===1?(d=0)=>d*r:(d=0)=>l-d*r;return Array.from(e.variantChildren).sort(xS).forEach((d,h)=>{d.notify("AnimationStart",t),o.push(au(d,t,{...i,delay:n+c(h)}).then(()=>d.notify("AnimationComplete",t)))}),Promise.all(o)}function xS(e,t){return e.sortNodePosition(t)}function gS(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const a=t.map(i=>au(e,i,n));r=Promise.all(a)}else if(typeof t=="string")r=au(e,t,n);else{const a=typeof t=="function"?Ol(e,t,n.custom):t;r=Promise.all(M1(e,a,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const yS=_h.length;function z1(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?z1(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<yS;n++){const r=_h[n],a=e.props[r];(ii(a)||a===!1)&&(t[r]=a)}return t}const vS=[...Eh].reverse(),bS=Eh.length;function wS(e){return t=>Promise.all(t.map(({animation:n,options:r})=>gS(e,n,r)))}function kS(e){let t=wS(e),n=gm(),r=!0;const a=c=>(d,h)=>{var p;const f=Ol(e,h,c==="exit"?(p=e.presenceContext)===null||p===void 0?void 0:p.custom:void 0);if(f){const{transition:m,transitionEnd:b,...y}=f;d={...d,...y,...b}}return d};function i(c){t=c(e)}function o(c){const{props:d}=e,h=z1(e.parent)||{},p=[],f=new Set;let m={},b=1/0;for(let v=0;v<bS;v++){const x=vS[v],g=n[x],w=d[x]!==void 0?d[x]:h[x],j=ii(w),k=x===c?g.isActive:null;k===!1&&(b=v);let S=w===h[x]&&w!==d[x]&&j;if(S&&r&&e.manuallyAnimateOnMount&&(S=!1),g.protectedKeys={...m},!g.isActive&&k===null||!w&&!g.prevProp||Rl(w)||typeof w=="boolean")continue;const C=jS(g.prevProp,w);let A=C||x===c&&g.isActive&&!S&&j||v>b&&j,N=!1;const _=Array.isArray(w)?w:[w];let L=_.reduce(a(x),{});k===!1&&(L={});const{prevResolvedValues:B={}}=g,z={...B,...L},$=P=>{A=!0,f.has(P)&&(N=!0,f.delete(P)),g.needsAnimating[P]=!0;const E=e.getValue(P);E&&(E.liveStyle=!1)};for(const P in z){const E=L[P],T=B[P];if(m.hasOwnProperty(P))continue;let O=!1;Yd(E)&&Yd(T)?O=!Ky(E,T):O=E!==T,O?E!=null?$(P):f.add(P):E!==void 0&&f.has(P)?$(P):g.protectedKeys[P]=!0}g.prevProp=w,g.prevResolvedValues=L,g.isActive&&(m={...m,...L}),r&&e.blockInitialAnimation&&(A=!1),A&&(!(S&&C)||N)&&p.push(..._.map(P=>({animation:P,options:{type:x}})))}if(f.size){const v={};f.forEach(x=>{const g=e.getBaseTarget(x),w=e.getValue(x);w&&(w.liveStyle=!0),v[x]=g??null}),p.push({animation:v})}let y=!!p.length;return r&&(d.initial===!1||d.initial===d.animate)&&!e.manuallyAnimateOnMount&&(y=!1),r=!1,y?t(p):Promise.resolve()}function l(c,d){var h;if(n[c].isActive===d)return Promise.resolve();(h=e.variantChildren)===null||h===void 0||h.forEach(f=>{var m;return(m=f.animationState)===null||m===void 0?void 0:m.setActive(c,d)}),n[c].isActive=d;const p=o(c);for(const f in n)n[f].protectedKeys={};return p}return{animateChanges:o,setActive:l,setAnimateFunction:i,getState:()=>n,reset:()=>{n=gm(),r=!0}}}function jS(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Ky(t,e):!1}function ks(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function gm(){return{animate:ks(!0),whileInView:ks(),whileHover:ks(),whileTap:ks(),whileDrag:ks(),whileFocus:ks(),exit:ks()}}class xs{constructor(t){this.isMounted=!1,this.node=t}update(){}}class NS extends xs{constructor(t){super(t),t.animationState||(t.animationState=kS(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Rl(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let SS=0;class CS extends xs{constructor(){super(...arguments),this.id=SS++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const ES={animation:{Feature:NS},exit:{Feature:CS}};function di(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function ji(e){return{point:{x:e.pageX,y:e.pageY}}}const _S=e=>t=>Uh(t)&&e(t,ji(t));function Oa(e,t,n,r){return di(e,t,_S(n),r)}const ym=(e,t)=>Math.abs(e-t);function TS(e,t){const n=ym(e.x,t.x),r=ym(e.y,t.y);return Math.sqrt(n**2+r**2)}class R1{constructor(t,n,{transformPagePoint:r,contextWindow:a,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const p=Tc(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,m=TS(p.offset,{x:0,y:0})>=3;if(!f&&!m)return;const{point:b}=p,{timestamp:y}=Ye;this.history.push({...b,timestamp:y});const{onStart:v,onMove:x}=this.handlers;f||(v&&v(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,p)},this.handlePointerMove=(p,f)=>{this.lastMoveEvent=p,this.lastMoveEventInfo=_c(f,this.transformPagePoint),Ne.update(this.updatePoint,!0)},this.handlePointerUp=(p,f)=>{this.end();const{onEnd:m,onSessionEnd:b,resumeAnimation:y}=this.handlers;if(this.dragSnapToOrigin&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tc(p.type==="pointercancel"?this.lastMoveEventInfo:_c(f,this.transformPagePoint),this.history);this.startEvent&&m&&m(p,v),b&&b(p,v)},!Uh(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.contextWindow=a||window;const o=ji(t),l=_c(o,this.transformPagePoint),{point:c}=l,{timestamp:d}=Ye;this.history=[{...c,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Tc(l,this.history)),this.removeListeners=ki(Oa(this.contextWindow,"pointermove",this.handlePointerMove),Oa(this.contextWindow,"pointerup",this.handlePointerUp),Oa(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),cs(this.updatePoint)}}function _c(e,t){return t?{point:t(e.point)}:e}function vm(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tc({point:e},t){return{point:e,delta:vm(e,L1(t)),offset:vm(e,PS(t)),velocity:AS(t,.1)}}function PS(e){return e[0]}function L1(e){return e[e.length-1]}function AS(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const a=L1(e);for(;n>=0&&(r=e[n],!(a.timestamp-r.timestamp>Sn(t)));)n--;if(!r)return{x:0,y:0};const i=Cn(a.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const o={x:(a.x-r.x)/i,y:(a.y-r.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const O1=1e-4,MS=1-O1,zS=1+O1,I1=.01,RS=0-I1,LS=0+I1;function Nt(e){return e.max-e.min}function OS(e,t,n){return Math.abs(e-t)<=n}function bm(e,t,n,r=.5){e.origin=r,e.originPoint=_e(t.min,t.max,e.origin),e.scale=Nt(n)/Nt(t),e.translate=_e(n.min,n.max,e.origin)-e.originPoint,(e.scale>=MS&&e.scale<=zS||isNaN(e.scale))&&(e.scale=1),(e.translate>=RS&&e.translate<=LS||isNaN(e.translate))&&(e.translate=0)}function Ia(e,t,n,r){bm(e.x,t.x,n.x,r?r.originX:void 0),bm(e.y,t.y,n.y,r?r.originY:void 0)}function wm(e,t,n){e.min=n.min+t.min,e.max=e.min+Nt(t)}function IS(e,t,n){wm(e.x,t.x,n.x),wm(e.y,t.y,n.y)}function km(e,t,n){e.min=t.min-n.min,e.max=e.min+Nt(t)}function Da(e,t,n){km(e.x,t.x,n.x),km(e.y,t.y,n.y)}function DS(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?_e(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?_e(n,e,r.max):Math.min(e,n)),e}function jm(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function BS(e,{top:t,left:n,bottom:r,right:a}){return{x:jm(e.x,n,a),y:jm(e.y,t,r)}}function Nm(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function FS(e,t){return{x:Nm(e.x,t.x),y:Nm(e.y,t.y)}}function $S(e,t){let n=.5;const r=Nt(e),a=Nt(t);return a>r?n=Vr(t.min,t.max-r,e.min):r>a&&(n=Vr(e.min,e.max-a,t.min)),An(0,1,n)}function VS(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const iu=.35;function US(e=iu){return e===!1?e=0:e===!0&&(e=iu),{x:Sm(e,"left","right"),y:Sm(e,"top","bottom")}}function Sm(e,t,n){return{min:Cm(e,t),max:Cm(e,n)}}function Cm(e,t){return typeof e=="number"?e:e[t]||0}const Em=()=>({translate:0,scale:1,origin:0,originPoint:0}),Sr=()=>({x:Em(),y:Em()}),_m=()=>({min:0,max:0}),Le=()=>({x:_m(),y:_m()});function Pt(e){return[e("x"),e("y")]}function D1({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function HS({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WS(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Pc(e){return e===void 0||e===1}function ou({scale:e,scaleX:t,scaleY:n}){return!Pc(e)||!Pc(t)||!Pc(n)}function Cs(e){return ou(e)||B1(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function B1(e){return Tm(e.x)||Tm(e.y)}function Tm(e){return e&&e!=="0%"}function dl(e,t,n){const r=e-n,a=t*r;return n+a}function Pm(e,t,n,r,a){return a!==void 0&&(e=dl(e,a,r)),dl(e,n,r)+t}function lu(e,t=0,n=1,r,a){e.min=Pm(e.min,t,n,r,a),e.max=Pm(e.max,t,n,r,a)}function F1(e,{x:t,y:n}){lu(e.x,t.translate,t.scale,t.originPoint),lu(e.y,n.translate,n.scale,n.originPoint)}const Am=.999999999999,Mm=1.0000000000001;function KS(e,t,n,r=!1){const a=n.length;if(!a)return;t.x=t.y=1;let i,o;for(let l=0;l<a;l++){i=n[l],o=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Er(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,F1(e,o)),r&&Cs(i.latestValues)&&Er(e,i.latestValues))}t.x<Mm&&t.x>Am&&(t.x=1),t.y<Mm&&t.y>Am&&(t.y=1)}function Cr(e,t){e.min=e.min+t,e.max=e.max+t}function zm(e,t,n,r,a=.5){const i=_e(e.min,e.max,a);lu(e,t,n,i,r)}function Er(e,t){zm(e.x,t.x,t.scaleX,t.scale,t.originX),zm(e.y,t.y,t.scaleY,t.scale,t.originY)}function $1(e,t){return D1(WS(e.getBoundingClientRect(),t))}function GS(e,t,n){const r=$1(e,n),{scroll:a}=t;return a&&(Cr(r.x,a.offset.x),Cr(r.y,a.offset.y)),r}const V1=({current:e})=>e?e.ownerDocument.defaultView:null,qS=new WeakMap;class YS{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Le(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const a=h=>{const{dragSnapToOrigin:p}=this.getProps();p?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(ji(h).point)},i=(h,p)=>{const{drag:f,dragPropagation:m,onDragStart:b}=this.getProps();if(f&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=$5(f),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Pt(v=>{let x=this.getAxisMotionValue(v).get()||0;if(un.test(x)){const{projection:g}=this.visualElement;if(g&&g.layout){const w=g.layout.layoutBox[v];w&&(x=Nt(w)*(parseFloat(x)/100))}}this.originPoint[v]=x}),b&&Ne.postRender(()=>b(h,p)),Jd(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},o=(h,p)=>{const{dragPropagation:f,dragDirectionLock:m,onDirectionLock:b,onDrag:y}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:v}=p;if(m&&this.currentDirection===null){this.currentDirection=XS(v),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",p.point,v),this.updateAxis("y",p.point,v),this.visualElement.render(),y&&y(h,p)},l=(h,p)=>this.stop(h,p),c=()=>Pt(h=>{var p;return this.getAnimationState(h)==="paused"&&((p=this.getAxisMotionValue(h).animation)===null||p===void 0?void 0:p.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new R1(t,{onSessionStart:a,onStart:i,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,contextWindow:V1(this.visualElement)})}stop(t,n){const r=this.isDragging;if(this.cancel(),!r)return;const{velocity:a}=n;this.startAnimation(a);const{onDragEnd:i}=this.getProps();i&&Ne.postRender(()=>i(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:a}=this.getProps();if(!r||!Ji(t,a,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=DS(o,this.constraints[t],this.elastic[t])),i.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:r}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,i=this.constraints;n&&jr(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&a?this.constraints=BS(a.layoutBox,n):this.constraints=!1,this.elastic=US(r),i!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&Pt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=VS(a.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!jr(t))return!1;const r=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const i=GS(r,a.root,this.visualElement.getTransformPagePoint());let o=FS(a.layout.layoutBox,i);if(n){const l=n(HS(o));this.hasMutatedConstraints=!!l,l&&(o=D1(l))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=Pt(h=>{if(!Ji(h,n,this.currentDirection))return;let p=c&&c[h]||{};o&&(p={min:0,max:0});const f=a?200:1e6,m=a?40:1e7,b={type:"inertia",velocity:r?t[h]:0,bounceStiffness:f,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(h,b)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Jd(this.visualElement,t),r.start(tp(t,r,0,n,this.visualElement,!1))}stopAnimation(){Pt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Pt(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){Pt(n=>{const{drag:r}=this.getProps();if(!Ji(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,i=this.getAxisMotionValue(n);if(a&&a.layout){const{min:o,max:l}=a.layout.layoutBox[n];i.set(t[n]-_e(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!jr(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Pt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();a[o]=$S({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Pt(o=>{if(!Ji(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:d}=this.constraints[o];l.set(_e(c,d,a[o]))})}addListeners(){if(!this.visualElement.current)return;qS.set(this.visualElement,this);const t=this.visualElement.current,n=Oa(t,"pointerdown",c=>{const{drag:d,dragListener:h=!0}=this.getProps();d&&h&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();jr(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,i=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),Ne.read(r);const o=di(window,"resize",()=>this.scalePositionWithinConstraints()),l=a.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d})=>{this.isDragging&&d&&(Pt(h=>{const p=this.getAxisMotionValue(h);p&&(this.originPoint[h]+=c[h].translate,p.set(p.get()+c[h].translate))}),this.visualElement.render())});return()=>{o(),n(),i(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:i=!1,dragElastic:o=iu,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function Ji(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function XS(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class QS extends xs{constructor(t){super(t),this.removeGroupControls=kt,this.removeListeners=kt,this.controls=new YS(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||kt}unmount(){this.removeGroupControls(),this.removeListeners()}}const Rm=e=>(t,n)=>{e&&Ne.postRender(()=>e(t,n))};class JS extends xs{constructor(){super(...arguments),this.removePointerDownListener=kt}onPointerDown(t){this.session=new R1(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:V1(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:Rm(t),onStart:Rm(n),onMove:r,onEnd:(i,o)=>{delete this.session,a&&Ne.postRender(()=>a(i,o))}}}mount(){this.removePointerDownListener=Oa(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const So={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Lm(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const pa={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(re.test(e))e=parseFloat(e);else return e;const n=Lm(e,t.target.x),r=Lm(e,t.target.y);return`${n}% ${r}%`}},ZS={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,a=ds.parse(e);if(a.length>5)return r;const i=ds.createTransformer(e),o=typeof a[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;a[0+o]/=l,a[1+o]/=c;const d=_e(l,c,.5);return typeof a[2+o]=="number"&&(a[2+o]/=d),typeof a[3+o]=="number"&&(a[3+o]/=d),i(a)}};class e4 extends u.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:i}=t;b5(t4),i&&(n.group&&n.group.add(i),r&&r.register&&a&&r.register(i),i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),So.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:a,isPresent:i}=this.props,o=r.projection;return o&&(o.isPresent=i,a||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||Ne.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Ph.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=t;a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function U1(e){const[t,n]=Ny(),r=u.useContext(Nh);return s.jsx(e4,{...e,layoutGroup:r,switchLayoutGroup:u.useContext(zy),isPresent:t,safeToRemove:n})}const t4={borderRadius:{...pa,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:pa,borderTopRightRadius:pa,borderBottomLeftRadius:pa,borderBottomRightRadius:pa,boxShadow:ZS};function n4(e,t,n){const r=nt(e)?e:li(e);return r.start(tp("",r,t,n)),r.animation}function s4(e){return e instanceof SVGElement&&e.tagName!=="svg"}const r4=(e,t)=>e.depth-t.depth;class a4{constructor(){this.children=[],this.isDirty=!1}add(t){Hh(this.children,t),this.isDirty=!0}remove(t){Wh(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(r4),this.isDirty=!1,this.children.forEach(t)}}function i4(e,t){const n=hn.now(),r=({timestamp:a})=>{const i=a-n;i>=t&&(cs(r),e(i-t))};return Ne.read(r,!0),()=>cs(r)}const H1=["TopLeft","TopRight","BottomLeft","BottomRight"],o4=H1.length,Om=e=>typeof e=="string"?parseFloat(e):e,Im=e=>typeof e=="number"||re.test(e);function l4(e,t,n,r,a,i){a?(e.opacity=_e(0,n.opacity!==void 0?n.opacity:1,c4(r)),e.opacityExit=_e(t.opacity!==void 0?t.opacity:1,0,d4(r))):i&&(e.opacity=_e(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let o=0;o<o4;o++){const l=`border${H1[o]}Radius`;let c=Dm(t,l),d=Dm(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||Im(c)===Im(d)?(e[l]=Math.max(_e(Om(c),Om(d),r),0),(un.test(d)||un.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=_e(t.rotate||0,n.rotate||0,r))}function Dm(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const c4=W1(0,.5,c1),d4=W1(.5,.95,kt);function W1(e,t,n){return r=>r<e?0:r>t?1:n(Vr(e,t,r))}function Bm(e,t){e.min=t.min,e.max=t.max}function Tt(e,t){Bm(e.x,t.x),Bm(e.y,t.y)}function Fm(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function $m(e,t,n,r,a){return e-=t,e=dl(e,1/n,r),a!==void 0&&(e=dl(e,1/a,r)),e}function u4(e,t=0,n=1,r=.5,a,i=e,o=e){if(un.test(t)&&(t=parseFloat(t),t=_e(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=_e(i.min,i.max,r);e===i&&(l-=t),e.min=$m(e.min,t,n,l,a),e.max=$m(e.max,t,n,l,a)}function Vm(e,t,[n,r,a],i,o){u4(e,t[n],t[r],t[a],t.scale,i,o)}const h4=["x","scaleX","originX"],p4=["y","scaleY","originY"];function Um(e,t,n,r){Vm(e.x,t,h4,n?n.x:void 0,r?r.x:void 0),Vm(e.y,t,p4,n?n.y:void 0,r?r.y:void 0)}function Hm(e){return e.translate===0&&e.scale===1}function K1(e){return Hm(e.x)&&Hm(e.y)}function Wm(e,t){return e.min===t.min&&e.max===t.max}function f4(e,t){return Wm(e.x,t.x)&&Wm(e.y,t.y)}function Km(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function G1(e,t){return Km(e.x,t.x)&&Km(e.y,t.y)}function Gm(e){return Nt(e.x)/Nt(e.y)}function qm(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class m4{constructor(){this.members=[]}add(t){Hh(this.members,t),t.scheduleRender()}remove(t){if(Wh(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(a=>t===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const i=this.members[a];if(i.isPresent!==!1){r=i;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:a}=t.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function x4(e,t,n){let r="";const a=e.x.translate/t.x,i=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((a||i||o)&&(r=`translate3d(${a}px, ${i}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:h,rotateX:p,rotateY:f,skewX:m,skewY:b}=n;d&&(r=`perspective(${d}px) ${r}`),h&&(r+=`rotate(${h}deg) `),p&&(r+=`rotateX(${p}deg) `),f&&(r+=`rotateY(${f}deg) `),m&&(r+=`skewX(${m}deg) `),b&&(r+=`skewY(${b}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(r+=`scale(${l}, ${c})`),r||"none"}const Es={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},ka=typeof window<"u"&&window.MotionDebug!==void 0,Ac=["","X","Y","Z"],g4={visibility:"hidden"},Ym=1e3;let y4=0;function Mc(e,t,n,r){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),r&&(r[e]=0))}function q1(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=n1(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Ne,!(a||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&q1(r)}function Y1({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(o={},l=t==null?void 0:t()){this.id=y4++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,ka&&(Es.totalNodes=Es.resolvedTargetDeltas=Es.recalculatedProjection=0),this.nodes.forEach(w4),this.nodes.forEach(C4),this.nodes.forEach(E4),this.nodes.forEach(k4),ka&&window.MotionDebug.record(Es)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new a4)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Kh),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=s4(o),this.instance=o;const{layoutId:c,layout:d,visualElement:h}=this.options;if(h&&!h.current&&h.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(d||c)&&(this.isLayoutDirty=!0),e){let p;const f=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,p&&p(),p=i4(f,250),So.hasAnimatedSinceResize&&(So.hasAnimatedSinceResize=!1,this.nodes.forEach(Qm))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&h&&(c||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeTargetChanged:m,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||h.getDefaultTransition()||M4,{onLayoutAnimationStart:v,onLayoutAnimationComplete:x}=h.getProps(),g=!this.targetLayout||!G1(this.targetLayout,b)||m,w=!f&&m;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||w||f&&(g||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(p,w);const j={...Fh(y,"layout"),onPlay:v,onComplete:x};(h.shouldReduceMotion||this.options.layoutRoot)&&(j.delay=0,j.type=!1),this.startAnimation(j)}else f||Qm(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,cs(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(_4),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&q1(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const p=this.path[h];p.shouldResetTransform=!0,p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Xm);return}this.isUpdating||this.nodes.forEach(N4),this.isUpdating=!1,this.nodes.forEach(S4),this.nodes.forEach(v4),this.nodes.forEach(b4),this.clearAllSnapshots();const l=hn.now();Ye.delta=An(0,1e3/60,l-Ye.timestamp),Ye.timestamp=l,Ye.isProcessing=!0,kc.update.process(Ye),kc.preRender.process(Ye),kc.render.process(Ye),Ye.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ph.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(j4),this.sharedNodes.forEach(T4)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ne.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ne.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Le(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!a)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!K1(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,h=d!==this.prevTransformTemplateValue;o&&(l||Cs(this.latestValues)||h)&&(a(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),z4(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Le();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(R4))){const{scroll:h}=this.root;h&&(Cr(c.x,h.offset.x),Cr(c.y,h.offset.y))}return c}removeElementScroll(o){var l;const c=Le();if(Tt(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let d=0;d<this.path.length;d++){const h=this.path[d],{scroll:p,options:f}=h;h!==this.root&&p&&f.layoutScroll&&(p.wasRoot&&Tt(c,o),Cr(c.x,p.offset.x),Cr(c.y,p.offset.y))}return c}applyTransform(o,l=!1){const c=Le();Tt(c,o);for(let d=0;d<this.path.length;d++){const h=this.path[d];!l&&h.options.layoutScroll&&h.scroll&&h!==h.root&&Er(c,{x:-h.scroll.offset.x,y:-h.scroll.offset.y}),Cs(h.latestValues)&&Er(c,h.latestValues)}return Cs(this.latestValues)&&Er(c,this.latestValues),c}removeTransform(o){const l=Le();Tt(l,o);for(let c=0;c<this.path.length;c++){const d=this.path[c];if(!d.instance||!Cs(d.latestValues))continue;ou(d.latestValues)&&d.updateSnapshot();const h=Le(),p=d.measurePageBox();Tt(h,p),Um(l,d.latestValues,d.snapshot?d.snapshot.layoutBox:void 0,h)}return Cs(this.latestValues)&&Um(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ye.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const d=!!this.resumingFrom||this!==c;if(!(o||d&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:f}=this.options;if(!(!this.layout||!(p||f))){if(this.resolvedRelativeTargetAt=Ye.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Da(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Tt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Le(),this.targetWithTransforms=Le()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),IS(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Tt(this.target,this.layout.layoutBox),F1(this.target,this.targetDelta)):Tt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Da(this.relativeTargetOrigin,this.target,m.target),Tt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}ka&&Es.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||ou(this.parent.latestValues)||B1(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let d=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(d=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(d=!1),this.resolvedRelativeTargetAt===Ye.timestamp&&(d=!1),d)return;const{layout:h,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||p))return;Tt(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,m=this.treeScale.y;KS(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Le());const{target:b}=l;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Fm(this.prevProjectionDelta.x,this.projectionDelta.x),Fm(this.prevProjectionDelta.y,this.projectionDelta.y)),Ia(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==m||!qm(this.projectionDelta.x,this.prevProjectionDelta.x)||!qm(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",b)),ka&&Es.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Sr(),this.projectionDelta=Sr(),this.projectionDeltaWithTransform=Sr()}setAnimationOrigin(o,l=!1){const c=this.snapshot,d=c?c.latestValues:{},h={...this.latestValues},p=Sr();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Le(),m=c?c.source:void 0,b=this.layout?this.layout.source:void 0,y=m!==b,v=this.getStack(),x=!v||v.members.length<=1,g=!!(y&&!x&&this.options.crossfade===!0&&!this.path.some(A4));this.animationProgress=0;let w;this.mixTargetDelta=j=>{const k=j/1e3;Jm(p.x,o.x,k),Jm(p.y,o.y,k),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Da(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),P4(this.relativeTarget,this.relativeTargetOrigin,f,k),w&&f4(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Le()),Tt(w,this.relativeTarget)),y&&(this.animationValues=h,l4(h,d,this.latestValues,k,g,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(cs(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ne.update(()=>{So.hasAnimatedSinceResize=!0,this.currentAnimation=n4(0,Ym,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Ym),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:h}=o;if(!(!l||!c||!d)){if(this!==o&&this.layout&&d&&X1(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||Le();const p=Nt(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+p;const f=Nt(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}Tt(l,c),Er(l,h),Ia(this.projectionDeltaWithTransform,this.layoutCorrected,l,h)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new m4),this.sharedNodes.get(o).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Mc("z",o,d,this.animationValues);for(let h=0;h<Ac.length;h++)Mc(`rotate${Ac[h]}`,o,d,this.animationValues),Mc(`skew${Ac[h]}`,o,d,this.animationValues);o.render();for(const h in d)o.setStaticValue(h,d[h]),this.animationValues&&(this.animationValues[h]=d[h]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return g4;const d={visibility:""},h=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,d.opacity="",d.pointerEvents=jo(o==null?void 0:o.pointerEvents)||"",d.transform=h?h(this.latestValues,""):"none",d;const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){const y={};return this.options.layoutId&&(y.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,y.pointerEvents=jo(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Cs(this.latestValues)&&(y.transform=h?h({},""):"none",this.hasProjected=!1),y}const f=p.animationValues||p.latestValues;this.applyTransformsToTarget(),d.transform=x4(this.projectionDeltaWithTransform,this.treeScale,f),h&&(d.transform=h(f,d.transform));const{x:m,y:b}=this.projectionDelta;d.transformOrigin=`${m.origin*100}% ${b.origin*100}% 0`,p.animationValues?d.opacity=p===this?(c=(l=f.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:d.opacity=p===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const y in al){if(f[y]===void 0)continue;const{correct:v,applyTo:x}=al[y],g=d.transform==="none"?f[y]:v(f[y],p);if(x){const w=x.length;for(let j=0;j<w;j++)d[x[j]]=g}else d[y]=g}return this.options.layoutId&&(d.pointerEvents=p===this?jo(o==null?void 0:o.pointerEvents)||"":"none"),d}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Xm),this.root.sharedNodes.clear()}}}function v4(e){e.updateLayout()}function b4(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:a}=e.layout,{animationType:i}=e.options,o=n.source!==e.layout.source;i==="size"?Pt(p=>{const f=o?n.measuredBox[p]:n.layoutBox[p],m=Nt(f);f.min=r[p].min,f.max=f.min+m}):X1(i,n.layoutBox,r)&&Pt(p=>{const f=o?n.measuredBox[p]:n.layoutBox[p],m=Nt(r[p]);f.max=f.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+m)});const l=Sr();Ia(l,r,n.layoutBox);const c=Sr();o?Ia(c,e.applyTransform(a,!0),n.measuredBox):Ia(c,r,n.layoutBox);const d=!K1(l);let h=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:f,layout:m}=p;if(f&&m){const b=Le();Da(b,n.layoutBox,f.layoutBox);const y=Le();Da(y,r,m.layoutBox),G1(b,y)||(h=!0),p.options.layoutRoot&&(e.relativeTarget=y,e.relativeTargetOrigin=b,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeTargetChanged:h})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function w4(e){ka&&Es.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function k4(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function j4(e){e.clearSnapshot()}function Xm(e){e.clearMeasurements()}function N4(e){e.isLayoutDirty=!1}function S4(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Qm(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function C4(e){e.resolveTargetDelta()}function E4(e){e.calcProjection()}function _4(e){e.resetSkewAndRotation()}function T4(e){e.removeLeadSnapshot()}function Jm(e,t,n){e.translate=_e(t.translate,0,n),e.scale=_e(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Zm(e,t,n,r){e.min=_e(t.min,n.min,r),e.max=_e(t.max,n.max,r)}function P4(e,t,n,r){Zm(e.x,t.x,n.x,r),Zm(e.y,t.y,n.y,r)}function A4(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const M4={duration:.45,ease:[.4,0,.1,1]},e0=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),t0=e0("applewebkit/")&&!e0("chrome/")?Math.round:kt;function n0(e){e.min=t0(e.min),e.max=t0(e.max)}function z4(e){n0(e.x),n0(e.y)}function X1(e,t,n){return e==="position"||e==="preserve-aspect"&&!OS(Gm(t),Gm(n),.2)}function R4(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const L4=Y1({attachResizeListener:(e,t)=>di(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),zc={current:void 0},Q1=Y1({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!zc.current){const e=new L4({});e.mount(window),e.setOptions({layoutScroll:!0}),zc.current=e}return zc.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),O4={pan:{Feature:JS},drag:{Feature:QS,ProjectionNode:Q1,MeasureLayout:U1}};function s0(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,i=r[a];i&&Ne.postRender(()=>i(t,ji(t)))}class I4 extends xs{mount(){const{current:t}=this.node;t&&(this.unmount=O5(t,n=>(s0(this.node,n,"Start"),r=>s0(this.node,r,"End"))))}unmount(){}}class D4 extends xs{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=ki(di(this.node.current,"focus",()=>this.onFocus()),di(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function r0(e,t,n){const{props:r}=e;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),i=r[a];i&&Ne.postRender(()=>i(t,ji(t)))}class B4 extends xs{mount(){const{current:t}=this.node;t&&(this.unmount=F5(t,n=>(r0(this.node,n,"Start"),(r,{success:a})=>r0(this.node,r,a?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cu=new WeakMap,Rc=new WeakMap,F4=e=>{const t=cu.get(e.target);t&&t(e)},$4=e=>{e.forEach(F4)};function V4({root:e,...t}){const n=e||document;Rc.has(n)||Rc.set(n,{});const r=Rc.get(n),a=JSON.stringify(t);return r[a]||(r[a]=new IntersectionObserver($4,{root:e,...t})),r[a]}function U4(e,t,n){const r=V4(t);return cu.set(e,n),r.observe(e),()=>{cu.delete(e),r.unobserve(e)}}const H4={some:0,all:1};class W4 extends xs{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:H4[a]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,i&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:h,onViewportLeave:p}=this.node.getProps(),f=d?h:p;f&&f(c)};return U4(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(K4(t,n))&&this.startObserver()}unmount(){}}function K4({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const G4={inView:{Feature:W4},tap:{Feature:B4},focus:{Feature:D4},hover:{Feature:I4}},q4={layout:{ProjectionNode:Q1,MeasureLayout:U1}},du={current:null},J1={current:!1};function Y4(){if(J1.current=!0,!!Sh)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>du.current=e.matches;e.addListener(t),t()}else du.current=!1}const X4=[...j1,et,ds],Q4=e=>X4.find(k1(e)),a0=new WeakMap;function J4(e,t,n){for(const r in t){const a=t[r],i=n[r];if(nt(a))e.addValue(r,a);else if(nt(i))e.addValue(r,li(a,{owner:e}));else if(i!==a)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(a):o.hasAnimated||o.set(a)}else{const o=e.getStaticValue(r);e.addValue(r,li(o!==void 0?o:a,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const i0=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Z4{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:i,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Jh,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=hn.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Ne.render(this.render,!1,!0))};const{latestValues:c,renderState:d,onUpdate:h}=o;this.onUpdate=h,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=d,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.options=l,this.blockInitialAnimation=!!i,this.isControllingVariants=Ll(n),this.isVariantNode=Ay(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in f){const b=f[m];c[m]!==void 0&&nt(b)&&b.set(c[m],!1)}}mount(t){this.current=t,a0.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),J1.current||Y4(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:du.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){a0.delete(this.current),this.projection&&this.projection.unmount(),cs(this.notifyUpdate),cs(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Ys.has(t),a=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&Ne.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),i=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Ur){const n=Ur[t];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[t]&&a&&r(this.props)&&(this.features[t]=new a(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Le()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<i0.length;r++){const a=i0[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const i="on"+a,o=t[i];o&&(this.propEventSubscriptions[a]=this.on(a,o))}this.prevMotionValues=J4(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=li(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){var r;let a=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(r=this.getBaseTargetFromProps(this.props,t))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,t,this.options);return a!=null&&(typeof a=="string"&&(b1(a)||u1(a))?a=parseFloat(a):!Q4(a)&&ds.test(n)&&(a=g1(t,n)),this.setBaseTarget(t,nt(a)?a.get():a)),nt(a)?a.get():a}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:r}=this.props;let a;if(typeof r=="string"||typeof r=="object"){const o=Mh(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(a=o[t])}if(r&&a!==void 0)return a;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!nt(i)?i:this.initialValues[t]!==void 0&&a===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Kh),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Z1 extends Z4{constructor(){super(...arguments),this.KeyframeResolver=N1}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;nt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function e3(e){return window.getComputedStyle(e)}class t3 extends Z1{constructor(){super(...arguments),this.type="html",this.renderInstance=Fy}readValueFromInstance(t,n){if(Ys.has(n)){const r=Qh(n);return r&&r.default||0}else{const r=e3(t),a=(Iy(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $1(t,n)}build(t,n,r){Lh(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return Bh(t,n,r)}}class n3 extends Z1{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Le}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Ys.has(n)){const r=Qh(n);return r&&r.default||0}return n=$y.has(n)?n:Th(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return Hy(t,n,r)}build(t,n,r){Oh(t,n,this.isSVGTag,r.transformTemplate)}renderInstance(t,n,r,a){Vy(t,n,r,a)}mount(t){this.isSVGTag=Dh(t.tagName),super.mount(t)}}const s3=(e,t)=>Ah(e)?new n3(t):new t3(t,{allowProjection:e!==u.Fragment}),r3=T5({...ES,...G4,...O4,...q4},s3),V=Hj(r3);/**
|
|
76
|
+
`),()=>{document.head.removeChild(h)}},[t]),s.jsx(zj,{isPresent:t,childRef:r,sizeRef:a,children:u.cloneElement(e,{ref:r})})}const Lj=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:a,presenceAffectsLayout:i,mode:o})=>{const l=Al(Oj),c=u.useId(),d=u.useCallback(p=>{l.set(p,!0);for(const f of l.values())if(!f)return;r&&r()},[l,r]),h=u.useMemo(()=>({id:c,initial:t,isPresent:n,custom:a,onExitComplete:d,register:p=>(l.set(p,!1),()=>l.delete(p))}),i?[Math.random(),d]:[n,d]);return u.useMemo(()=>{l.forEach((p,f)=>l.set(f,!1))},[n]),u.useEffect(()=>{!n&&!l.size&&r&&r()},[n]),o==="popLayout"&&(e=s.jsx(Rj,{isPresent:n,children:e})),s.jsx(Ml.Provider,{value:h,children:e})};function Oj(){return new Map}function Ny(e=!0){const t=u.useContext(Ml);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=t,i=u.useId();u.useEffect(()=>{e&&a(i)},[e]);const o=u.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,o]:[!0]}const Yi=e=>e.key||"";function Kf(e){const t=[];return u.Children.forEach(e,n=>{u.isValidElement(n)&&t.push(n)}),t}const Sh=typeof window<"u",Sy=Sh?u.useLayoutEffect:u.useEffect,ae=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:a=!0,mode:i="sync",propagate:o=!1})=>{const[l,c]=Ny(o),d=u.useMemo(()=>Kf(e),[e]),h=o&&!l?[]:d.map(Yi),p=u.useRef(!0),f=u.useRef(d),m=Al(()=>new Map),[b,y]=u.useState(d),[v,x]=u.useState(d);Sy(()=>{p.current=!1,f.current=d;for(let j=0;j<v.length;j++){const k=Yi(v[j]);h.includes(k)?m.delete(k):m.get(k)!==!0&&m.set(k,!1)}},[v,h.length,h.join("-")]);const g=[];if(d!==b){let j=[...d];for(let k=0;k<v.length;k++){const S=v[k],C=Yi(S);h.includes(C)||(j.splice(k,0,S),g.push(S))}i==="wait"&&g.length&&(j=g),x(Kf(j)),y(d);return}const{forceRender:w}=u.useContext(Nh);return s.jsx(s.Fragment,{children:v.map(j=>{const k=Yi(j),S=o&&!l?!1:d===v||h.includes(k),C=()=>{if(m.has(k))m.set(k,!0);else return;let A=!0;m.forEach(N=>{N||(A=!1)}),A&&(w==null||w(),x(f.current),o&&(c==null||c()),r&&r())};return s.jsx(Lj,{isPresent:S,initial:!p.current||n?void 0:!1,custom:S?void 0:t,presenceAffectsLayout:a,mode:i,onExitComplete:S?void 0:C,children:j},k)})})},kt=e=>e;let Cy=kt;function Ch(e){let t;return()=>(t===void 0&&(t=e()),t)}const Vr=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Sn=e=>e*1e3,Cn=e=>e/1e3,Ij={useManualTiming:!1};function Dj(e){let t=new Set,n=new Set,r=!1,a=!1;const i=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(c.schedule(d),e()),d(o)}const c={schedule:(d,h=!1,p=!1)=>{const m=p&&r?t:n;return h&&i.add(d),m.has(d)||m.add(d),d},cancel:d=>{n.delete(d),i.delete(d)},process:d=>{if(o=d,r){a=!0;return}r=!0,[t,n]=[n,t],t.forEach(l),t.clear(),r=!1,a&&(a=!1,c.process(d))}};return c}const Xi=["read","resolveKeyframes","update","preRender","render","postRender"],Bj=40;function Ey(e,t){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=Xi.reduce((x,g)=>(x[g]=Dj(i),x),{}),{read:l,resolveKeyframes:c,update:d,preRender:h,render:p,postRender:f}=o,m=()=>{const x=performance.now();n=!1,a.delta=r?1e3/60:Math.max(Math.min(x-a.timestamp,Bj),1),a.timestamp=x,a.isProcessing=!0,l.process(a),c.process(a),d.process(a),h.process(a),p.process(a),f.process(a),a.isProcessing=!1,n&&t&&(r=!1,e(m))},b=()=>{n=!0,r=!0,a.isProcessing||e(m)};return{schedule:Xi.reduce((x,g)=>{const w=o[g];return x[g]=(j,k=!1,S=!1)=>(n||b(),w.schedule(j,k,S)),x},{}),cancel:x=>{for(let g=0;g<Xi.length;g++)o[Xi[g]].cancel(x)},state:a,steps:o}}const{schedule:Ne,cancel:cs,state:Ye,steps:kc}=Ey(typeof requestAnimationFrame<"u"?requestAnimationFrame:kt,!0),_y=u.createContext({strict:!1}),Gf={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ur={};for(const e in Gf)Ur[e]={isEnabled:t=>Gf[e].some(n=>!!t[n])};function Fj(e){for(const t in e)Ur[t]={...Ur[t],...e[t]}}const $j=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function rl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||$j.has(e)}let Ty=e=>!rl(e);function Py(e){e&&(Ty=t=>t.startsWith("on")?!rl(t):e(t))}try{Py(require("@emotion/is-prop-valid").default)}catch{}function Vj(e,t,n){const r={};for(const a in e)a==="values"&&typeof e.values=="object"||(Ty(a)||n===!0&&rl(a)||!t&&!rl(a)||e.draggable&&a.startsWith("onDrag"))&&(r[a]=e[a]);return r}function Uj({children:e,isValidProp:t,...n}){t&&Py(t),n={...u.useContext(ai),...n},n.isStatic=Al(()=>n.isStatic);const r=u.useMemo(()=>n,[JSON.stringify(n.transition),n.transformPagePoint,n.reducedMotion]);return s.jsx(ai.Provider,{value:r,children:e})}function Hj(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...r)=>e(...r);return new Proxy(n,{get:(r,a)=>a==="create"?e:(t.has(a)||t.set(a,e(a)),t.get(a))})}const zl=u.createContext({});function ii(e){return typeof e=="string"||Array.isArray(e)}function Rl(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Eh=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],_h=["initial",...Eh];function Ll(e){return Rl(e.animate)||_h.some(t=>ii(e[t]))}function Ay(e){return!!(Ll(e)||e.variants)}function Wj(e,t){if(Ll(e)){const{initial:n,animate:r}=e;return{initial:n===!1||ii(n)?n:void 0,animate:ii(r)?r:void 0}}return e.inherit!==!1?t:{}}function Kj(e){const{initial:t,animate:n}=Wj(e,u.useContext(zl));return u.useMemo(()=>({initial:t,animate:n}),[qf(t),qf(n)])}function qf(e){return Array.isArray(e)?e.join(" "):e}const Gj=Symbol.for("motionComponentSymbol");function jr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function qj(e,t,n){return u.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):jr(n)&&(n.current=r))},[t])}const Th=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Yj="framerAppearId",My="data-"+Th(Yj),{schedule:Ph}=Ey(queueMicrotask,!1),zy=u.createContext({});function Xj(e,t,n,r,a){var i,o;const{visualElement:l}=u.useContext(zl),c=u.useContext(_y),d=u.useContext(Ml),h=u.useContext(ai).reducedMotion,p=u.useRef(null);r=r||c.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:l,props:n,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:h}));const f=p.current,m=u.useContext(zy);f&&!f.projection&&a&&(f.type==="html"||f.type==="svg")&&Qj(p.current,n,a,m);const b=u.useRef(!1);u.useInsertionEffect(()=>{f&&b.current&&f.update(n,d)});const y=n[My],v=u.useRef(!!y&&!(!((i=window.MotionHandoffIsComplete)===null||i===void 0)&&i.call(window,y))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,y)));return Sy(()=>{f&&(b.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),Ph.render(f.render),v.current&&f.animationState&&f.animationState.animateChanges())}),u.useEffect(()=>{f&&(!v.current&&f.animationState&&f.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{var x;(x=window.MotionHandoffMarkAsComplete)===null||x===void 0||x.call(window,y)}),v.current=!1))}),f}function Qj(e,t,n,r){const{layoutId:a,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Ry(e.parent)),e.projection.setOptions({layoutId:a,layout:i,alwaysMeasureLayout:!!o||l&&jr(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,layoutScroll:c,layoutRoot:d})}function Ry(e){if(e)return e.options.allowProjection!==!1?e.projection:Ry(e.parent)}function Jj({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:r,Component:a}){var i,o;e&&Fj(e);function l(d,h){let p;const f={...u.useContext(ai),...d,layoutId:Zj(d)},{isStatic:m}=f,b=Kj(d),y=r(d,m);if(!m&&Sh){e5();const v=t5(f);p=v.MeasureLayout,b.visualElement=Xj(a,y,f,t,v.ProjectionNode)}return s.jsxs(zl.Provider,{value:b,children:[p&&b.visualElement?s.jsx(p,{visualElement:b.visualElement,...f}):null,n(a,d,qj(y,b.visualElement,h),y,m,b.visualElement)]})}l.displayName=`motion.${typeof a=="string"?a:`create(${(o=(i=a.displayName)!==null&&i!==void 0?i:a.name)!==null&&o!==void 0?o:""})`}`;const c=u.forwardRef(l);return c[Gj]=a,c}function Zj({layoutId:e}){const t=u.useContext(Nh).id;return t&&e!==void 0?t+"-"+e:e}function e5(e,t){u.useContext(_y).strict}function t5(e){const{drag:t,layout:n}=Ur;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}const n5=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ah(e){return typeof e!="string"||e.includes("-")?!1:!!(n5.indexOf(e)>-1||/[A-Z]/u.test(e))}function Yf(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Mh(e,t,n,r){if(typeof t=="function"){const[a,i]=Yf(r);t=t(n!==void 0?n:e.custom,a,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,i]=Yf(r);t=t(n!==void 0?n:e.custom,a,i)}return t}const Yd=e=>Array.isArray(e),s5=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),r5=e=>Yd(e)?e[e.length-1]||0:e,nt=e=>!!(e&&e.getVelocity);function jo(e){const t=nt(e)?e.get():e;return s5(t)?t.toValue():t}function a5({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},r,a,i){const o={latestValues:i5(r,a,i,e),renderState:t()};return n&&(o.onMount=l=>n({props:r,current:l,...o}),o.onUpdate=l=>n(l)),o}const Ly=e=>(t,n)=>{const r=u.useContext(zl),a=u.useContext(Ml),i=()=>a5(e,t,r,a);return n?i():Al(i)};function i5(e,t,n,r){const a={},i=r(e,{});for(const f in i)a[f]=jo(i[f]);let{initial:o,animate:l}=e;const c=Ll(e),d=Ay(e);t&&d&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let h=n?n.initial===!1:!1;h=h||o===!1;const p=h?l:o;if(p&&typeof p!="boolean"&&!Rl(p)){const f=Array.isArray(p)?p:[p];for(let m=0;m<f.length;m++){const b=Mh(e,f[m]);if(b){const{transitionEnd:y,transition:v,...x}=b;for(const g in x){let w=x[g];if(Array.isArray(w)){const j=h?w.length-1:0;w=w[j]}w!==null&&(a[g]=w)}for(const g in y)a[g]=y[g]}}}return a}const ea=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ys=new Set(ea),Oy=e=>t=>typeof t=="string"&&t.startsWith(e),Iy=Oy("--"),o5=Oy("var(--"),zh=e=>o5(e)?l5.test(e.split("/*")[0].trim()):!1,l5=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Dy=(e,t)=>t&&typeof e=="number"?t.transform(e):e,An=(e,t,n)=>n>t?t:n<e?e:n,ta={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},oi={...ta,transform:e=>An(0,1,e)},Qi={...ta,default:1},bi=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$n=bi("deg"),un=bi("%"),re=bi("px"),c5=bi("vh"),d5=bi("vw"),Xf={...un,parse:e=>un.parse(e)/100,transform:e=>un.transform(e*100)},u5={borderWidth:re,borderTopWidth:re,borderRightWidth:re,borderBottomWidth:re,borderLeftWidth:re,borderRadius:re,radius:re,borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomRightRadius:re,borderBottomLeftRadius:re,width:re,maxWidth:re,height:re,maxHeight:re,top:re,right:re,bottom:re,left:re,padding:re,paddingTop:re,paddingRight:re,paddingBottom:re,paddingLeft:re,margin:re,marginTop:re,marginRight:re,marginBottom:re,marginLeft:re,backgroundPositionX:re,backgroundPositionY:re},h5={rotate:$n,rotateX:$n,rotateY:$n,rotateZ:$n,scale:Qi,scaleX:Qi,scaleY:Qi,scaleZ:Qi,skew:$n,skewX:$n,skewY:$n,distance:re,translateX:re,translateY:re,translateZ:re,x:re,y:re,z:re,perspective:re,transformPerspective:re,opacity:oi,originX:Xf,originY:Xf,originZ:re},Qf={...ta,transform:Math.round},Rh={...u5,...h5,zIndex:Qf,size:re,fillOpacity:oi,strokeOpacity:oi,numOctaves:Qf},p5={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},f5=ea.length;function m5(e,t,n){let r="",a=!0;for(let i=0;i<f5;i++){const o=ea[i],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const d=Dy(l,Rh[o]);if(!c){a=!1;const h=p5[o]||o;r+=`${h}(${d}) `}n&&(t[o]=d)}}return r=r.trim(),n?r=n(t,a?"":r):a&&(r="none"),r}function Lh(e,t,n){const{style:r,vars:a,transformOrigin:i}=e;let o=!1,l=!1;for(const c in t){const d=t[c];if(Ys.has(c)){o=!0;continue}else if(Iy(c)){a[c]=d;continue}else{const h=Dy(d,Rh[c]);c.startsWith("origin")?(l=!0,i[c]=h):r[c]=h}}if(t.transform||(o||n?r.transform=m5(t,e.transform,n):r.transform&&(r.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:h=0}=i;r.transformOrigin=`${c} ${d} ${h}`}}const x5={offset:"stroke-dashoffset",array:"stroke-dasharray"},g5={offset:"strokeDashoffset",array:"strokeDasharray"};function y5(e,t,n=1,r=0,a=!0){e.pathLength=1;const i=a?x5:g5;e[i.offset]=re.transform(-r);const o=re.transform(t),l=re.transform(n);e[i.array]=`${o} ${l}`}function Jf(e,t,n){return typeof e=="string"?e:re.transform(t+n*e)}function v5(e,t,n){const r=Jf(t,e.x,e.width),a=Jf(n,e.y,e.height);return`${r} ${a}`}function Oh(e,{attrX:t,attrY:n,attrScale:r,originX:a,originY:i,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...d},h,p){if(Lh(e,d,p),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:m,dimensions:b}=e;f.transform&&(b&&(m.transform=f.transform),delete f.transform),b&&(a!==void 0||i!==void 0||m.transform)&&(m.transformOrigin=v5(b,a!==void 0?a:.5,i!==void 0?i:.5)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),r!==void 0&&(f.scale=r),o!==void 0&&y5(f,o,l,c,!1)}const Ih=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),By=()=>({...Ih(),attrs:{}}),Dh=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Fy(e,{style:t,vars:n},r,a){Object.assign(e.style,t,a&&a.getProjectionStyles(r));for(const i in n)e.style.setProperty(i,n[i])}const $y=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Vy(e,t,n,r){Fy(e,t,void 0,r);for(const a in t.attrs)e.setAttribute($y.has(a)?a:Th(a),t.attrs[a])}const al={};function b5(e){Object.assign(al,e)}function Uy(e,{layout:t,layoutId:n}){return Ys.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!al[e]||e==="opacity")}function Bh(e,t,n){var r;const{style:a}=e,i={};for(const o in a)(nt(a[o])||t.style&&nt(t.style[o])||Uy(o,e)||((r=n==null?void 0:n.getValue(o))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(i[o]=a[o]);return i}function Hy(e,t,n){const r=Bh(e,t,n);for(const a in e)if(nt(e[a])||nt(t[a])){const i=ea.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[i]=e[a]}return r}function w5(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const Zf=["x","y","width","height","cx","cy","r"],k5={useVisualState:Ly({scrapeMotionValuesFromProps:Hy,createRenderState:By,onUpdate:({props:e,prevProps:t,current:n,renderState:r,latestValues:a})=>{if(!n)return;let i=!!e.drag;if(!i){for(const l in a)if(Ys.has(l)){i=!0;break}}if(!i)return;let o=!t;if(t)for(let l=0;l<Zf.length;l++){const c=Zf[l];e[c]!==t[c]&&(o=!0)}o&&Ne.read(()=>{w5(n,r),Ne.render(()=>{Oh(r,a,Dh(n.tagName),e.transformTemplate),Vy(n,r)})})}})},j5={useVisualState:Ly({scrapeMotionValuesFromProps:Bh,createRenderState:Ih})};function Wy(e,t,n){for(const r in t)!nt(t[r])&&!Uy(r,n)&&(e[r]=t[r])}function N5({transformTemplate:e},t){return u.useMemo(()=>{const n=Ih();return Lh(n,t,e),Object.assign({},n.vars,n.style)},[t])}function S5(e,t){const n=e.style||{},r={};return Wy(r,n,e),Object.assign(r,N5(e,t)),r}function C5(e,t){const n={},r=S5(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function E5(e,t,n,r){const a=u.useMemo(()=>{const i=By();return Oh(i,t,Dh(r),e.transformTemplate),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Wy(i,e.style,e),a.style={...i,...a.style}}return a}function _5(e=!1){return(n,r,a,{latestValues:i},o)=>{const c=(Ah(n)?E5:C5)(r,i,o,n),d=Vj(r,typeof n=="string",e),h=n!==u.Fragment?{...d,...c,ref:a}:{},{children:p}=r,f=u.useMemo(()=>nt(p)?p.get():p,[p]);return u.createElement(n,{...h,children:f})}}function T5(e,t){return function(r,{forwardMotionProps:a}={forwardMotionProps:!1}){const o={...Ah(r)?k5:j5,preloadedFeatures:e,useRender:_5(a),createVisualElement:t,Component:r};return Jj(o)}}function Ky(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Ol(e,t,n){const r=e.getProps();return Mh(r,t,n!==void 0?n:r.custom,e)}const P5=Ch(()=>window.ScrollTimeline!==void 0);class A5{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t,n){const r=this.animations.map(a=>{if(P5()&&a.attachTimeline)return a.attachTimeline(t);if(typeof n=="function")return n(a)});return()=>{r.forEach((a,i)=>{a&&a(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class M5 extends A5{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Fh(e,t){return e?e[t]||e.default||e:void 0}const Xd=2e4;function Gy(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<Xd;)t+=n,r=e.next(t);return t>=Xd?1/0:t}function $h(e){return typeof e=="function"}function em(e,t){e.timeline=t,e.onfinish=null}const Vh=e=>Array.isArray(e)&&typeof e[0]=="number",z5={linearEasing:void 0};function R5(e,t){const n=Ch(e);return()=>{var r;return(r=z5[t])!==null&&r!==void 0?r:n()}}const il=R5(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),qy=(e,t,n=10)=>{let r="";const a=Math.max(Math.round(t/n),2);for(let i=0;i<a;i++)r+=e(Vr(0,a-1,i))+", ";return`linear(${r.substring(0,r.length-2)})`};function Yy(e){return!!(typeof e=="function"&&il()||!e||typeof e=="string"&&(e in Qd||il())||Vh(e)||Array.isArray(e)&&e.every(Yy))}const ba=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Qd={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ba([0,.65,.55,1]),circOut:ba([.55,0,1,.45]),backIn:ba([.31,.01,.66,-.59]),backOut:ba([.33,1.53,.69,.99])};function Xy(e,t){if(e)return typeof e=="function"&&il()?qy(e,t):Vh(e)?ba(e):Array.isArray(e)?e.map(n=>Xy(n,t)||Qd.easeOut):Qd[e]}const Ht={x:!1,y:!1};function Qy(){return Ht.x||Ht.y}function L5(e,t,n){var r;if(e instanceof Element)return[e];if(typeof e=="string"){let a=document;const i=(r=void 0)!==null&&r!==void 0?r:a.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}function Jy(e,t){const n=L5(e),r=new AbortController,a={passive:!0,...t,signal:r.signal};return[n,a,()=>r.abort()]}function tm(e){return t=>{t.pointerType==="touch"||Qy()||e(t)}}function O5(e,t,n={}){const[r,a,i]=Jy(e,n),o=tm(l=>{const{target:c}=l,d=t(l);if(typeof d!="function"||!c)return;const h=tm(p=>{d(p),c.removeEventListener("pointerleave",h)});c.addEventListener("pointerleave",h,a)});return r.forEach(l=>{l.addEventListener("pointerenter",o,a)}),i}const Zy=(e,t)=>t?e===t?!0:Zy(e,t.parentElement):!1,Uh=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,I5=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function D5(e){return I5.has(e.tagName)||e.tabIndex!==-1}const wa=new WeakSet;function nm(e){return t=>{t.key==="Enter"&&e(t)}}function jc(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const B5=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=nm(()=>{if(wa.has(n))return;jc(n,"down");const a=nm(()=>{jc(n,"up")}),i=()=>jc(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",i,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function sm(e){return Uh(e)&&!Qy()}function F5(e,t,n={}){const[r,a,i]=Jy(e,n),o=l=>{const c=l.currentTarget;if(!sm(l)||wa.has(c))return;wa.add(c);const d=t(l),h=(m,b)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",f),!(!sm(m)||!wa.has(c))&&(wa.delete(c),typeof d=="function"&&d(m,{success:b}))},p=m=>{h(m,n.useGlobalTarget||Zy(c,m.target))},f=m=>{h(m,!1)};window.addEventListener("pointerup",p,a),window.addEventListener("pointercancel",f,a)};return r.forEach(l=>{!D5(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,a),l.addEventListener("focus",d=>B5(d,a),a)}),i}function $5(e){return e==="x"||e==="y"?Ht[e]?null:(Ht[e]=!0,()=>{Ht[e]=!1}):Ht.x||Ht.y?null:(Ht.x=Ht.y=!0,()=>{Ht.x=Ht.y=!1})}const e1=new Set(["width","height","top","left","right","bottom",...ea]);let No;function V5(){No=void 0}const hn={now:()=>(No===void 0&&hn.set(Ye.isProcessing||Ij.useManualTiming?Ye.timestamp:performance.now()),No),set:e=>{No=e,queueMicrotask(V5)}};function Hh(e,t){e.indexOf(t)===-1&&e.push(t)}function Wh(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class Kh{constructor(){this.subscriptions=[]}add(t){return Hh(this.subscriptions,t),()=>Wh(this.subscriptions,t)}notify(t,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,r);else for(let i=0;i<a;i++){const o=this.subscriptions[i];o&&o(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function t1(e,t){return t?e*(1e3/t):0}const rm=30,U5=e=>!isNaN(parseFloat(e));class H5{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,a=!0)=>{const i=hn.now();this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),a&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=hn.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=U5(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Kh);const r=this.events[t].add(n);return t==="change"?()=>{r(),Ne.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=hn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>rm)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,rm);return t1(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function li(e,t){return new H5(e,t)}function W5(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,li(n))}function K5(e,t){const n=Ol(e,t);let{transitionEnd:r={},transition:a={},...i}=n||{};i={...i,...r};for(const o in i){const l=r5(i[o]);W5(e,o,l)}}function G5(e){return!!(nt(e)&&e.add)}function Jd(e,t){const n=e.getValue("willChange");if(G5(n))return n.add(t)}function n1(e){return e.props[My]}const s1=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,q5=1e-7,Y5=12;function X5(e,t,n,r,a){let i,o,l=0;do o=t+(n-t)/2,i=s1(o,r,a)-e,i>0?n=o:t=o;while(Math.abs(i)>q5&&++l<Y5);return o}function wi(e,t,n,r){if(e===t&&n===r)return kt;const a=i=>X5(i,0,1,e,n);return i=>i===0||i===1?i:s1(a(i),t,r)}const r1=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,a1=e=>t=>1-e(1-t),i1=wi(.33,1.53,.69,.99),Gh=a1(i1),o1=r1(Gh),l1=e=>(e*=2)<1?.5*Gh(e):.5*(2-Math.pow(2,-10*(e-1))),qh=e=>1-Math.sin(Math.acos(e)),c1=a1(qh),d1=r1(qh),u1=e=>/^0[^.\s]+$/u.test(e);function Q5(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||u1(e):!0}const La=e=>Math.round(e*1e5)/1e5,Yh=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function J5(e){return e==null}const Z5=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Xh=(e,t)=>n=>!!(typeof n=="string"&&Z5.test(n)&&n.startsWith(e)||t&&!J5(n)&&Object.prototype.hasOwnProperty.call(n,t)),h1=(e,t,n)=>r=>{if(typeof r!="string")return r;const[a,i,o,l]=r.match(Yh);return{[e]:parseFloat(a),[t]:parseFloat(i),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},eN=e=>An(0,255,e),Nc={...ta,transform:e=>Math.round(eN(e))},As={test:Xh("rgb","red"),parse:h1("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Nc.transform(e)+", "+Nc.transform(t)+", "+Nc.transform(n)+", "+La(oi.transform(r))+")"};function tN(e){let t="",n="",r="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,r+=r,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:a?parseInt(a,16)/255:1}}const Zd={test:Xh("#"),parse:tN,transform:As.transform},Nr={test:Xh("hsl","hue"),parse:h1("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+un.transform(La(t))+", "+un.transform(La(n))+", "+La(oi.transform(r))+")"},et={test:e=>As.test(e)||Zd.test(e)||Nr.test(e),parse:e=>As.test(e)?As.parse(e):Nr.test(e)?Nr.parse(e):Zd.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?As.transform(e):Nr.transform(e)},nN=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function sN(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Yh))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(nN))===null||n===void 0?void 0:n.length)||0)>0}const p1="number",f1="color",rN="var",aN="var(",am="${}",iN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function ci(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},a=[];let i=0;const l=t.replace(iN,c=>(et.test(c)?(r.color.push(i),a.push(f1),n.push(et.parse(c))):c.startsWith(aN)?(r.var.push(i),a.push(rN),n.push(c)):(r.number.push(i),a.push(p1),n.push(parseFloat(c))),++i,am)).split(am);return{values:n,split:l,indexes:r,types:a}}function m1(e){return ci(e).values}function x1(e){const{split:t,types:n}=ci(e),r=t.length;return a=>{let i="";for(let o=0;o<r;o++)if(i+=t[o],a[o]!==void 0){const l=n[o];l===p1?i+=La(a[o]):l===f1?i+=et.transform(a[o]):i+=a[o]}return i}}const oN=e=>typeof e=="number"?0:e;function lN(e){const t=m1(e);return x1(e)(t.map(oN))}const ds={test:sN,parse:m1,createTransformer:x1,getAnimatableNone:lN},cN=new Set(["brightness","contrast","saturate","opacity"]);function dN(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Yh)||[];if(!r)return e;const a=n.replace(r,"");let i=cN.has(t)?1:0;return r!==n&&(i*=100),t+"("+i+a+")"}const uN=/\b([a-z-]*)\(.*?\)/gu,eu={...ds,getAnimatableNone:e=>{const t=e.match(uN);return t?t.map(dN).join(" "):e}},hN={...Rh,color:et,backgroundColor:et,outlineColor:et,fill:et,stroke:et,borderColor:et,borderTopColor:et,borderRightColor:et,borderBottomColor:et,borderLeftColor:et,filter:eu,WebkitFilter:eu},Qh=e=>hN[e];function g1(e,t){let n=Qh(e);return n!==eu&&(n=ds),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const pN=new Set(["auto","none","0"]);function fN(e,t,n){let r=0,a;for(;r<e.length&&!a;){const i=e[r];typeof i=="string"&&!pN.has(i)&&ci(i).values.length&&(a=e[r]),r++}if(a&&n)for(const i of t)e[i]=g1(n,a)}const im=e=>e===ta||e===re,om=(e,t)=>parseFloat(e.split(", ")[t]),lm=(e,t)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;const a=r.match(/^matrix3d\((.+)\)$/u);if(a)return om(a[1],t);{const i=r.match(/^matrix\((.+)\)$/u);return i?om(i[1],e):0}},mN=new Set(["x","y","z"]),xN=ea.filter(e=>!mN.has(e));function gN(e){const t=[];return xN.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Hr={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:lm(4,13),y:lm(5,14)};Hr.translateX=Hr.x;Hr.translateY=Hr.y;const Ls=new Set;let tu=!1,nu=!1;function y1(){if(nu){const e=Array.from(Ls).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const a=gN(r);a.length&&(n.set(r,a),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([i,o])=>{var l;(l=r.getValue(i))===null||l===void 0||l.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}nu=!1,tu=!1,Ls.forEach(e=>e.complete()),Ls.clear()}function v1(){Ls.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(nu=!0)})}function yN(){v1(),y1()}class Jh{constructor(t,n,r,a,i,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=a,this.element=i,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ls.add(this),tu||(tu=!0,Ne.read(v1),Ne.resolveKeyframes(y1))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:a}=this;for(let i=0;i<t.length;i++)if(t[i]===null)if(i===0){const o=a==null?void 0:a.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const c=r.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),a&&o===void 0&&a.set(t[0])}else t[i]=t[i-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Ls.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Ls.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const b1=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),vN=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function bN(e){const t=vN.exec(e);if(!t)return[,];const[,n,r,a]=t;return[`--${n??r}`,a]}function w1(e,t,n=1){const[r,a]=bN(e);if(!r)return;const i=window.getComputedStyle(t).getPropertyValue(r);if(i){const o=i.trim();return b1(o)?parseFloat(o):o}return zh(a)?w1(a,t,n+1):a}const k1=e=>t=>t.test(e),wN={test:e=>e==="auto",parse:e=>e},j1=[ta,re,un,$n,d5,c5,wN],cm=e=>j1.find(k1(e));class N1 extends Jh{constructor(t,n,r,a,i){super(t,n,r,a,i,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let d=t[c];if(typeof d=="string"&&(d=d.trim(),zh(d))){const h=w1(d,n.current);h!==void 0&&(t[c]=h),c===t.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!e1.has(r)||t.length!==2)return;const[a,i]=t,o=cm(a),l=cm(i);if(o!==l)if(im(o)&&im(l))for(let c=0;c<t.length;c++){const d=t[c];typeof d=="string"&&(t[c]=parseFloat(d))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let a=0;a<t.length;a++)Q5(t[a])&&r.push(a);r.length&&fN(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Hr[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&t.getValue(r,a).jump(a,!1)}measureEndState(){var t;const{element:n,name:r,unresolvedKeyframes:a}=this;if(!n||!n.current)return;const i=n.getValue(r);i&&i.jump(this.measuredOrigin,!1);const o=a.length-1,l=a[o];a[o]=Hr[r](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,d])=>{n.getValue(c).set(d)}),this.resolveNoneKeyframes()}}const dm=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ds.test(e)||e==="0")&&!e.startsWith("url("));function kN(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function jN(e,t,n,r){const a=e[0];if(a===null)return!1;if(t==="display"||t==="visibility")return!0;const i=e[e.length-1],o=dm(a,t),l=dm(i,t);return!o||!l?!1:kN(e)||(n==="spring"||$h(n))&&r}const NN=e=>e!==null;function Il(e,{repeat:t,repeatType:n="loop"},r){const a=e.filter(NN),i=t&&n!=="loop"&&t%2===1?0:a.length-1;return!i||r===void 0?a[i]:r}const SN=40;class S1{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:i=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=hn.now(),this.options={autoplay:t,delay:n,type:r,repeat:a,repeatDelay:i,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>SN?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&yN(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=hn.now(),this.hasAttemptedResolve=!0;const{name:r,type:a,velocity:i,delay:o,onComplete:l,onUpdate:c,isGenerator:d}=this.options;if(!d&&!jN(t,r,a,i))if(o)this.options.duration=0;else{c&&c(Il(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const h=this.initPlayback(t,n);h!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...h},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const _e=(e,t,n)=>e+(t-e)*n;function Sc(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function CN({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let a=0,i=0,o=0;if(!t)a=i=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;a=Sc(c,l,e+1/3),i=Sc(c,l,e),o=Sc(c,l,e-1/3)}return{red:Math.round(a*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}function ol(e,t){return n=>n>0?t:e}const Cc=(e,t,n)=>{const r=e*e,a=n*(t*t-r)+r;return a<0?0:Math.sqrt(a)},EN=[Zd,As,Nr],_N=e=>EN.find(t=>t.test(e));function um(e){const t=_N(e);if(!t)return!1;let n=t.parse(e);return t===Nr&&(n=CN(n)),n}const hm=(e,t)=>{const n=um(e),r=um(t);if(!n||!r)return ol(e,t);const a={...n};return i=>(a.red=Cc(n.red,r.red,i),a.green=Cc(n.green,r.green,i),a.blue=Cc(n.blue,r.blue,i),a.alpha=_e(n.alpha,r.alpha,i),As.transform(a))},TN=(e,t)=>n=>t(e(n)),ki=(...e)=>e.reduce(TN),su=new Set(["none","hidden"]);function PN(e,t){return su.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function AN(e,t){return n=>_e(e,t,n)}function Zh(e){return typeof e=="number"?AN:typeof e=="string"?zh(e)?ol:et.test(e)?hm:RN:Array.isArray(e)?C1:typeof e=="object"?et.test(e)?hm:MN:ol}function C1(e,t){const n=[...e],r=n.length,a=e.map((i,o)=>Zh(i)(i,t[o]));return i=>{for(let o=0;o<r;o++)n[o]=a[o](i);return n}}function MN(e,t){const n={...e,...t},r={};for(const a in n)e[a]!==void 0&&t[a]!==void 0&&(r[a]=Zh(e[a])(e[a],t[a]));return a=>{for(const i in r)n[i]=r[i](a);return n}}function zN(e,t){var n;const r=[],a={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],l=e.indexes[o][a[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;r[i]=c,a[o]++}return r}const RN=(e,t)=>{const n=ds.createTransformer(t),r=ci(e),a=ci(t);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?su.has(e)&&!a.values.length||su.has(t)&&!r.values.length?PN(e,t):ki(C1(zN(r,a),a.values),n):ol(e,t)};function E1(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?_e(e,t,n):Zh(e)(e,t)}const LN=5;function _1(e,t,n){const r=Math.max(t-LN,0);return t1(n-e(r),t-r)}const Ae={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ec=.001;function ON({duration:e=Ae.duration,bounce:t=Ae.bounce,velocity:n=Ae.velocity,mass:r=Ae.mass}){let a,i,o=1-t;o=An(Ae.minDamping,Ae.maxDamping,o),e=An(Ae.minDuration,Ae.maxDuration,Cn(e)),o<1?(a=d=>{const h=d*o,p=h*e,f=h-n,m=ru(d,o),b=Math.exp(-p);return Ec-f/m*b},i=d=>{const p=d*o*e,f=p*n+n,m=Math.pow(o,2)*Math.pow(d,2)*e,b=Math.exp(-p),y=ru(Math.pow(d,2),o);return(-a(d)+Ec>0?-1:1)*((f-m)*b)/y}):(a=d=>{const h=Math.exp(-d*e),p=(d-n)*e+1;return-Ec+h*p},i=d=>{const h=Math.exp(-d*e),p=(n-d)*(e*e);return h*p});const l=5/e,c=DN(a,i,l);if(e=Sn(e),isNaN(c))return{stiffness:Ae.stiffness,damping:Ae.damping,duration:e};{const d=Math.pow(c,2)*r;return{stiffness:d,damping:o*2*Math.sqrt(r*d),duration:e}}}const IN=12;function DN(e,t,n){let r=n;for(let a=1;a<IN;a++)r=r-e(r)/t(r);return r}function ru(e,t){return e*Math.sqrt(1-t*t)}const BN=["duration","bounce"],FN=["stiffness","damping","mass"];function pm(e,t){return t.some(n=>e[n]!==void 0)}function $N(e){let t={velocity:Ae.velocity,stiffness:Ae.stiffness,damping:Ae.damping,mass:Ae.mass,isResolvedFromDuration:!1,...e};if(!pm(e,FN)&&pm(e,BN))if(e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,i=2*An(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:Ae.mass,stiffness:a,damping:i}}else{const n=ON(e);t={...t,...n,mass:Ae.mass},t.isResolvedFromDuration=!0}return t}function T1(e=Ae.visualDuration,t=Ae.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:a}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:i},{stiffness:c,damping:d,mass:h,duration:p,velocity:f,isResolvedFromDuration:m}=$N({...n,velocity:-Cn(n.velocity||0)}),b=f||0,y=d/(2*Math.sqrt(c*h)),v=o-i,x=Cn(Math.sqrt(c/h)),g=Math.abs(v)<5;r||(r=g?Ae.restSpeed.granular:Ae.restSpeed.default),a||(a=g?Ae.restDelta.granular:Ae.restDelta.default);let w;if(y<1){const k=ru(x,y);w=S=>{const C=Math.exp(-y*x*S);return o-C*((b+y*x*v)/k*Math.sin(k*S)+v*Math.cos(k*S))}}else if(y===1)w=k=>o-Math.exp(-x*k)*(v+(b+x*v)*k);else{const k=x*Math.sqrt(y*y-1);w=S=>{const C=Math.exp(-y*x*S),A=Math.min(k*S,300);return o-C*((b+y*x*v)*Math.sinh(A)+k*v*Math.cosh(A))/k}}const j={calculatedDuration:m&&p||null,next:k=>{const S=w(k);if(m)l.done=k>=p;else{let C=0;y<1&&(C=k===0?Sn(b):_1(w,k,S));const A=Math.abs(C)<=r,N=Math.abs(o-S)<=a;l.done=A&&N}return l.value=l.done?o:S,l},toString:()=>{const k=Math.min(Gy(j),Xd),S=qy(C=>j.next(k*C).value,k,30);return k+"ms "+S}};return j}function fm({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:i=500,modifyTarget:o,min:l,max:c,restDelta:d=.5,restSpeed:h}){const p=e[0],f={done:!1,value:p},m=A=>l!==void 0&&A<l||c!==void 0&&A>c,b=A=>l===void 0?c:c===void 0||Math.abs(l-A)<Math.abs(c-A)?l:c;let y=n*t;const v=p+y,x=o===void 0?v:o(v);x!==v&&(y=x-p);const g=A=>-y*Math.exp(-A/r),w=A=>x+g(A),j=A=>{const N=g(A),_=w(A);f.done=Math.abs(N)<=d,f.value=f.done?x:_};let k,S;const C=A=>{m(f.value)&&(k=A,S=T1({keyframes:[f.value,b(f.value)],velocity:_1(w,A,f.value),damping:a,stiffness:i,restDelta:d,restSpeed:h}))};return C(0),{calculatedDuration:null,next:A=>{let N=!1;return!S&&k===void 0&&(N=!0,j(A),C(A)),k!==void 0&&A>=k?S.next(A-k):(!N&&j(A),f)}}}const VN=wi(.42,0,1,1),UN=wi(0,0,.58,1),P1=wi(.42,0,.58,1),HN=e=>Array.isArray(e)&&typeof e[0]!="number",WN={linear:kt,easeIn:VN,easeInOut:P1,easeOut:UN,circIn:qh,circInOut:d1,circOut:c1,backIn:Gh,backInOut:o1,backOut:i1,anticipate:l1},mm=e=>{if(Vh(e)){Cy(e.length===4);const[t,n,r,a]=e;return wi(t,n,r,a)}else if(typeof e=="string")return WN[e];return e};function KN(e,t,n){const r=[],a=n||E1,i=e.length-1;for(let o=0;o<i;o++){let l=a(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||kt:t;l=ki(c,l)}r.push(l)}return r}function GN(e,t,{clamp:n=!0,ease:r,mixer:a}={}){const i=e.length;if(Cy(i===t.length),i===1)return()=>t[0];if(i===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=KN(t,r,a),c=l.length,d=h=>{if(o&&h<e[0])return t[0];let p=0;if(c>1)for(;p<e.length-2&&!(h<e[p+1]);p++);const f=Vr(e[p],e[p+1],h);return l[p](f)};return n?h=>d(An(e[0],e[i-1],h)):d}function qN(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const a=Vr(0,t,r);e.push(_e(n,1,a))}}function YN(e){const t=[0];return qN(t,e.length-1),t}function XN(e,t){return e.map(n=>n*t)}function QN(e,t){return e.map(()=>t||P1).splice(0,e.length-1)}function ll({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const a=HN(r)?r.map(mm):mm(r),i={done:!1,value:t[0]},o=XN(n&&n.length===t.length?n:YN(t),e),l=GN(o,t,{ease:Array.isArray(a)?a:QN(t,a)});return{calculatedDuration:e,next:c=>(i.value=l(c),i.done=c>=e,i)}}const JN=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Ne.update(t,!0),stop:()=>cs(t),now:()=>Ye.isProcessing?Ye.timestamp:hn.now()}},ZN={decay:fm,inertia:fm,tween:ll,keyframes:ll,spring:T1},eS=e=>e/100;class ep extends S1{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:r,element:a,keyframes:i}=this.options,o=(a==null?void 0:a.KeyframeResolver)||Jh,l=(c,d)=>this.onKeyframesResolved(c,d);this.resolver=new o(i,l,n,r,a),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:r=0,repeatDelay:a=0,repeatType:i,velocity:o=0}=this.options,l=$h(n)?n:ZN[n]||ll;let c,d;l!==ll&&typeof t[0]!="number"&&(c=ki(eS,E1(t[0],t[1])),t=[0,100]);const h=l({...this.options,keyframes:t});i==="mirror"&&(d=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),h.calculatedDuration===null&&(h.calculatedDuration=Gy(h));const{calculatedDuration:p}=h,f=p+a,m=f*(r+1)-a;return{generator:h,mirroredGenerator:d,mapPercentToKeyframes:c,calculatedDuration:p,resolvedDuration:f,totalDuration:m}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:r}=this;if(!r){const{keyframes:A}=this.options;return{done:!0,value:A[A.length-1]}}const{finalKeyframe:a,generator:i,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:d,totalDuration:h,resolvedDuration:p}=r;if(this.startTime===null)return i.next(0);const{delay:f,repeat:m,repeatType:b,repeatDelay:y,onUpdate:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-h/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const x=this.currentTime-f*(this.speed>=0?1:-1),g=this.speed>=0?x<0:x>h;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=h);let w=this.currentTime,j=i;if(m){const A=Math.min(this.currentTime,h)/p;let N=Math.floor(A),_=A%1;!_&&A>=1&&(_=1),_===1&&N--,N=Math.min(N,m+1),!!(N%2)&&(b==="reverse"?(_=1-_,y&&(_-=y/p)):b==="mirror"&&(j=o)),w=An(0,1,_)*p}const k=g?{done:!1,value:c[0]}:j.next(w);l&&(k.value=l(k.value));let{done:S}=k;!g&&d!==null&&(S=this.speed>=0?this.currentTime>=h:this.currentTime<=0);const C=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&S);return C&&a!==void 0&&(k.value=Il(c,this.options,a)),v&&v(k.value),C&&this.finish(),k}get duration(){const{resolved:t}=this;return t?Cn(t.calculatedDuration):0}get time(){return Cn(this.currentTime)}set time(t){t=Sn(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Cn(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=JN,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),n&&n();const a=this.driver.now();this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=a):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const tS=new Set(["opacity","clipPath","filter","transform"]);function nS(e,t,n,{delay:r=0,duration:a=300,repeat:i=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const d={[t]:n};c&&(d.offset=c);const h=Xy(l,a);return Array.isArray(h)&&(d.easing=h),e.animate(d,{delay:r,duration:a,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"})}const sS=Ch(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),cl=10,rS=2e4;function aS(e){return $h(e.type)||e.type==="spring"||!Yy(e.ease)}function iS(e,t){const n=new ep({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:e[0]};const a=[];let i=0;for(;!r.done&&i<rS;)r=n.sample(i),a.push(r.value),i+=cl;return{times:void 0,keyframes:a,duration:i-cl,ease:"linear"}}const A1={anticipate:l1,backInOut:o1,circInOut:d1};function oS(e){return e in A1}class xm extends S1{constructor(t){super(t);const{name:n,motionValue:r,element:a,keyframes:i}=this.options;this.resolver=new N1(i,(o,l)=>this.onKeyframesResolved(o,l),n,r,a),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:r=300,times:a,ease:i,type:o,motionValue:l,name:c,startTime:d}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof i=="string"&&il()&&oS(i)&&(i=A1[i]),aS(this.options)){const{onComplete:p,onUpdate:f,motionValue:m,element:b,...y}=this.options,v=iS(t,y);t=v.keyframes,t.length===1&&(t[1]=t[0]),r=v.duration,a=v.times,i=v.ease,o="keyframes"}const h=nS(l.owner.current,c,t,{...this.options,duration:r,times:a,ease:i});return h.startTime=d??this.calcStartTime(),this.pendingTimeline?(em(h,this.pendingTimeline),this.pendingTimeline=void 0):h.onfinish=()=>{const{onComplete:p}=this.options;l.set(Il(t,this.options,n)),p&&p(),this.cancel(),this.resolveFinishedPromise()},{animation:h,duration:r,times:a,type:o,ease:i,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return Cn(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return Cn(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.currentTime=Sn(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return kt;const{animation:r}=n;em(r,t)}return kt}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:r,duration:a,type:i,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:d,onUpdate:h,onComplete:p,element:f,...m}=this.options,b=new ep({...m,keyframes:r,duration:a,type:i,ease:o,times:l,isGenerator:!0}),y=Sn(this.time);d.setWithVelocity(b.sample(y-cl).value,b.sample(y).value,cl)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:r,repeatDelay:a,repeatType:i,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:d}=n.owner.getProps();return sS()&&r&&tS.has(r)&&!c&&!d&&!a&&i!=="mirror"&&o!==0&&l!=="inertia"}}const lS={type:"spring",stiffness:500,damping:25,restSpeed:10},cS=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),dS={type:"keyframes",duration:.8},uS={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},hS=(e,{keyframes:t})=>t.length>2?dS:Ys.has(e)?e.startsWith("scale")?cS(t[1]):lS:uS;function pS({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:i,repeatType:o,repeatDelay:l,from:c,elapsed:d,...h}){return!!Object.keys(h).length}const tp=(e,t,n,r={},a,i)=>o=>{const l=Fh(r,e)||{},c=l.delay||r.delay||0;let{elapsed:d=0}=r;d=d-Sn(c);let h={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:i?void 0:a};pS(l)||(h={...h,...hS(e,h)}),h.duration&&(h.duration=Sn(h.duration)),h.repeatDelay&&(h.repeatDelay=Sn(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let p=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(h.duration=0,h.delay===0&&(p=!0)),p&&!i&&t.get()!==void 0){const f=Il(h.keyframes,l);if(f!==void 0)return Ne.update(()=>{h.onUpdate(f),h.onComplete()}),new M5([])}return!i&&xm.supports(h)?new xm(h):new ep(h)};function fS({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function M1(e,t,{delay:n=0,transitionOverride:r,type:a}={}){var i;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;r&&(o=r);const d=[],h=a&&e.animationState&&e.animationState.getState()[a];for(const p in c){const f=e.getValue(p,(i=e.latestValues[p])!==null&&i!==void 0?i:null),m=c[p];if(m===void 0||h&&fS(h,p))continue;const b={delay:n,...Fh(o||{},p)};let y=!1;if(window.MotionHandoffAnimation){const x=n1(e);if(x){const g=window.MotionHandoffAnimation(x,p,Ne);g!==null&&(b.startTime=g,y=!0)}}Jd(e,p),f.start(tp(p,f,m,e.shouldReduceMotion&&e1.has(p)?{type:!1}:b,e,y));const v=f.animation;v&&d.push(v)}return l&&Promise.all(d).then(()=>{Ne.update(()=>{l&&K5(e,l)})}),d}function au(e,t,n={}){var r;const a=Ol(e,t,n.type==="exit"?(r=e.presenceContext)===null||r===void 0?void 0:r.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(i=n.transitionOverride);const o=a?()=>Promise.all(M1(e,a,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:h=0,staggerChildren:p,staggerDirection:f}=i;return mS(e,t,h+d,p,f,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[d,h]=c==="beforeChildren"?[o,l]:[l,o];return d().then(()=>h())}else return Promise.all([o(),l(n.delay)])}function mS(e,t,n=0,r=0,a=1,i){const o=[],l=(e.variantChildren.size-1)*r,c=a===1?(d=0)=>d*r:(d=0)=>l-d*r;return Array.from(e.variantChildren).sort(xS).forEach((d,h)=>{d.notify("AnimationStart",t),o.push(au(d,t,{...i,delay:n+c(h)}).then(()=>d.notify("AnimationComplete",t)))}),Promise.all(o)}function xS(e,t){return e.sortNodePosition(t)}function gS(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const a=t.map(i=>au(e,i,n));r=Promise.all(a)}else if(typeof t=="string")r=au(e,t,n);else{const a=typeof t=="function"?Ol(e,t,n.custom):t;r=Promise.all(M1(e,a,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const yS=_h.length;function z1(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?z1(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<yS;n++){const r=_h[n],a=e.props[r];(ii(a)||a===!1)&&(t[r]=a)}return t}const vS=[...Eh].reverse(),bS=Eh.length;function wS(e){return t=>Promise.all(t.map(({animation:n,options:r})=>gS(e,n,r)))}function kS(e){let t=wS(e),n=gm(),r=!0;const a=c=>(d,h)=>{var p;const f=Ol(e,h,c==="exit"?(p=e.presenceContext)===null||p===void 0?void 0:p.custom:void 0);if(f){const{transition:m,transitionEnd:b,...y}=f;d={...d,...y,...b}}return d};function i(c){t=c(e)}function o(c){const{props:d}=e,h=z1(e.parent)||{},p=[],f=new Set;let m={},b=1/0;for(let v=0;v<bS;v++){const x=vS[v],g=n[x],w=d[x]!==void 0?d[x]:h[x],j=ii(w),k=x===c?g.isActive:null;k===!1&&(b=v);let S=w===h[x]&&w!==d[x]&&j;if(S&&r&&e.manuallyAnimateOnMount&&(S=!1),g.protectedKeys={...m},!g.isActive&&k===null||!w&&!g.prevProp||Rl(w)||typeof w=="boolean")continue;const C=jS(g.prevProp,w);let A=C||x===c&&g.isActive&&!S&&j||v>b&&j,N=!1;const _=Array.isArray(w)?w:[w];let L=_.reduce(a(x),{});k===!1&&(L={});const{prevResolvedValues:B={}}=g,M={...B,...L},$=P=>{A=!0,f.has(P)&&(N=!0,f.delete(P)),g.needsAnimating[P]=!0;const E=e.getValue(P);E&&(E.liveStyle=!1)};for(const P in M){const E=L[P],T=B[P];if(m.hasOwnProperty(P))continue;let O=!1;Yd(E)&&Yd(T)?O=!Ky(E,T):O=E!==T,O?E!=null?$(P):f.add(P):E!==void 0&&f.has(P)?$(P):g.protectedKeys[P]=!0}g.prevProp=w,g.prevResolvedValues=L,g.isActive&&(m={...m,...L}),r&&e.blockInitialAnimation&&(A=!1),A&&(!(S&&C)||N)&&p.push(..._.map(P=>({animation:P,options:{type:x}})))}if(f.size){const v={};f.forEach(x=>{const g=e.getBaseTarget(x),w=e.getValue(x);w&&(w.liveStyle=!0),v[x]=g??null}),p.push({animation:v})}let y=!!p.length;return r&&(d.initial===!1||d.initial===d.animate)&&!e.manuallyAnimateOnMount&&(y=!1),r=!1,y?t(p):Promise.resolve()}function l(c,d){var h;if(n[c].isActive===d)return Promise.resolve();(h=e.variantChildren)===null||h===void 0||h.forEach(f=>{var m;return(m=f.animationState)===null||m===void 0?void 0:m.setActive(c,d)}),n[c].isActive=d;const p=o(c);for(const f in n)n[f].protectedKeys={};return p}return{animateChanges:o,setActive:l,setAnimateFunction:i,getState:()=>n,reset:()=>{n=gm(),r=!0}}}function jS(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Ky(t,e):!1}function ks(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function gm(){return{animate:ks(!0),whileInView:ks(),whileHover:ks(),whileTap:ks(),whileDrag:ks(),whileFocus:ks(),exit:ks()}}class xs{constructor(t){this.isMounted=!1,this.node=t}update(){}}class NS extends xs{constructor(t){super(t),t.animationState||(t.animationState=kS(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Rl(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let SS=0;class CS extends xs{constructor(){super(...arguments),this.id=SS++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const ES={animation:{Feature:NS},exit:{Feature:CS}};function di(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function ji(e){return{point:{x:e.pageX,y:e.pageY}}}const _S=e=>t=>Uh(t)&&e(t,ji(t));function Oa(e,t,n,r){return di(e,t,_S(n),r)}const ym=(e,t)=>Math.abs(e-t);function TS(e,t){const n=ym(e.x,t.x),r=ym(e.y,t.y);return Math.sqrt(n**2+r**2)}class R1{constructor(t,n,{transformPagePoint:r,contextWindow:a,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const p=Tc(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,m=TS(p.offset,{x:0,y:0})>=3;if(!f&&!m)return;const{point:b}=p,{timestamp:y}=Ye;this.history.push({...b,timestamp:y});const{onStart:v,onMove:x}=this.handlers;f||(v&&v(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,p)},this.handlePointerMove=(p,f)=>{this.lastMoveEvent=p,this.lastMoveEventInfo=_c(f,this.transformPagePoint),Ne.update(this.updatePoint,!0)},this.handlePointerUp=(p,f)=>{this.end();const{onEnd:m,onSessionEnd:b,resumeAnimation:y}=this.handlers;if(this.dragSnapToOrigin&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tc(p.type==="pointercancel"?this.lastMoveEventInfo:_c(f,this.transformPagePoint),this.history);this.startEvent&&m&&m(p,v),b&&b(p,v)},!Uh(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.contextWindow=a||window;const o=ji(t),l=_c(o,this.transformPagePoint),{point:c}=l,{timestamp:d}=Ye;this.history=[{...c,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Tc(l,this.history)),this.removeListeners=ki(Oa(this.contextWindow,"pointermove",this.handlePointerMove),Oa(this.contextWindow,"pointerup",this.handlePointerUp),Oa(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),cs(this.updatePoint)}}function _c(e,t){return t?{point:t(e.point)}:e}function vm(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tc({point:e},t){return{point:e,delta:vm(e,L1(t)),offset:vm(e,PS(t)),velocity:AS(t,.1)}}function PS(e){return e[0]}function L1(e){return e[e.length-1]}function AS(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const a=L1(e);for(;n>=0&&(r=e[n],!(a.timestamp-r.timestamp>Sn(t)));)n--;if(!r)return{x:0,y:0};const i=Cn(a.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const o={x:(a.x-r.x)/i,y:(a.y-r.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const O1=1e-4,MS=1-O1,zS=1+O1,I1=.01,RS=0-I1,LS=0+I1;function Nt(e){return e.max-e.min}function OS(e,t,n){return Math.abs(e-t)<=n}function bm(e,t,n,r=.5){e.origin=r,e.originPoint=_e(t.min,t.max,e.origin),e.scale=Nt(n)/Nt(t),e.translate=_e(n.min,n.max,e.origin)-e.originPoint,(e.scale>=MS&&e.scale<=zS||isNaN(e.scale))&&(e.scale=1),(e.translate>=RS&&e.translate<=LS||isNaN(e.translate))&&(e.translate=0)}function Ia(e,t,n,r){bm(e.x,t.x,n.x,r?r.originX:void 0),bm(e.y,t.y,n.y,r?r.originY:void 0)}function wm(e,t,n){e.min=n.min+t.min,e.max=e.min+Nt(t)}function IS(e,t,n){wm(e.x,t.x,n.x),wm(e.y,t.y,n.y)}function km(e,t,n){e.min=t.min-n.min,e.max=e.min+Nt(t)}function Da(e,t,n){km(e.x,t.x,n.x),km(e.y,t.y,n.y)}function DS(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?_e(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?_e(n,e,r.max):Math.min(e,n)),e}function jm(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function BS(e,{top:t,left:n,bottom:r,right:a}){return{x:jm(e.x,n,a),y:jm(e.y,t,r)}}function Nm(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function FS(e,t){return{x:Nm(e.x,t.x),y:Nm(e.y,t.y)}}function $S(e,t){let n=.5;const r=Nt(e),a=Nt(t);return a>r?n=Vr(t.min,t.max-r,e.min):r>a&&(n=Vr(e.min,e.max-a,t.min)),An(0,1,n)}function VS(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const iu=.35;function US(e=iu){return e===!1?e=0:e===!0&&(e=iu),{x:Sm(e,"left","right"),y:Sm(e,"top","bottom")}}function Sm(e,t,n){return{min:Cm(e,t),max:Cm(e,n)}}function Cm(e,t){return typeof e=="number"?e:e[t]||0}const Em=()=>({translate:0,scale:1,origin:0,originPoint:0}),Sr=()=>({x:Em(),y:Em()}),_m=()=>({min:0,max:0}),Le=()=>({x:_m(),y:_m()});function Pt(e){return[e("x"),e("y")]}function D1({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function HS({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WS(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Pc(e){return e===void 0||e===1}function ou({scale:e,scaleX:t,scaleY:n}){return!Pc(e)||!Pc(t)||!Pc(n)}function Cs(e){return ou(e)||B1(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function B1(e){return Tm(e.x)||Tm(e.y)}function Tm(e){return e&&e!=="0%"}function dl(e,t,n){const r=e-n,a=t*r;return n+a}function Pm(e,t,n,r,a){return a!==void 0&&(e=dl(e,a,r)),dl(e,n,r)+t}function lu(e,t=0,n=1,r,a){e.min=Pm(e.min,t,n,r,a),e.max=Pm(e.max,t,n,r,a)}function F1(e,{x:t,y:n}){lu(e.x,t.translate,t.scale,t.originPoint),lu(e.y,n.translate,n.scale,n.originPoint)}const Am=.999999999999,Mm=1.0000000000001;function KS(e,t,n,r=!1){const a=n.length;if(!a)return;t.x=t.y=1;let i,o;for(let l=0;l<a;l++){i=n[l],o=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Er(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,F1(e,o)),r&&Cs(i.latestValues)&&Er(e,i.latestValues))}t.x<Mm&&t.x>Am&&(t.x=1),t.y<Mm&&t.y>Am&&(t.y=1)}function Cr(e,t){e.min=e.min+t,e.max=e.max+t}function zm(e,t,n,r,a=.5){const i=_e(e.min,e.max,a);lu(e,t,n,i,r)}function Er(e,t){zm(e.x,t.x,t.scaleX,t.scale,t.originX),zm(e.y,t.y,t.scaleY,t.scale,t.originY)}function $1(e,t){return D1(WS(e.getBoundingClientRect(),t))}function GS(e,t,n){const r=$1(e,n),{scroll:a}=t;return a&&(Cr(r.x,a.offset.x),Cr(r.y,a.offset.y)),r}const V1=({current:e})=>e?e.ownerDocument.defaultView:null,qS=new WeakMap;class YS{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Le(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const a=h=>{const{dragSnapToOrigin:p}=this.getProps();p?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(ji(h).point)},i=(h,p)=>{const{drag:f,dragPropagation:m,onDragStart:b}=this.getProps();if(f&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=$5(f),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Pt(v=>{let x=this.getAxisMotionValue(v).get()||0;if(un.test(x)){const{projection:g}=this.visualElement;if(g&&g.layout){const w=g.layout.layoutBox[v];w&&(x=Nt(w)*(parseFloat(x)/100))}}this.originPoint[v]=x}),b&&Ne.postRender(()=>b(h,p)),Jd(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},o=(h,p)=>{const{dragPropagation:f,dragDirectionLock:m,onDirectionLock:b,onDrag:y}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:v}=p;if(m&&this.currentDirection===null){this.currentDirection=XS(v),this.currentDirection!==null&&b&&b(this.currentDirection);return}this.updateAxis("x",p.point,v),this.updateAxis("y",p.point,v),this.visualElement.render(),y&&y(h,p)},l=(h,p)=>this.stop(h,p),c=()=>Pt(h=>{var p;return this.getAnimationState(h)==="paused"&&((p=this.getAxisMotionValue(h).animation)===null||p===void 0?void 0:p.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new R1(t,{onSessionStart:a,onStart:i,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,contextWindow:V1(this.visualElement)})}stop(t,n){const r=this.isDragging;if(this.cancel(),!r)return;const{velocity:a}=n;this.startAnimation(a);const{onDragEnd:i}=this.getProps();i&&Ne.postRender(()=>i(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:a}=this.getProps();if(!r||!Ji(t,a,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=DS(o,this.constraints[t],this.elastic[t])),i.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:r}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,i=this.constraints;n&&jr(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&a?this.constraints=BS(a.layoutBox,n):this.constraints=!1,this.elastic=US(r),i!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&Pt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=VS(a.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!jr(t))return!1;const r=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const i=GS(r,a.root,this.visualElement.getTransformPagePoint());let o=FS(a.layout.layoutBox,i);if(n){const l=n(HS(o));this.hasMutatedConstraints=!!l,l&&(o=D1(l))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=Pt(h=>{if(!Ji(h,n,this.currentDirection))return;let p=c&&c[h]||{};o&&(p={min:0,max:0});const f=a?200:1e6,m=a?40:1e7,b={type:"inertia",velocity:r?t[h]:0,bounceStiffness:f,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(h,b)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Jd(this.visualElement,t),r.start(tp(t,r,0,n,this.visualElement,!1))}stopAnimation(){Pt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Pt(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){Pt(n=>{const{drag:r}=this.getProps();if(!Ji(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,i=this.getAxisMotionValue(n);if(a&&a.layout){const{min:o,max:l}=a.layout.layoutBox[n];i.set(t[n]-_e(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!jr(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Pt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();a[o]=$S({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Pt(o=>{if(!Ji(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:d}=this.constraints[o];l.set(_e(c,d,a[o]))})}addListeners(){if(!this.visualElement.current)return;qS.set(this.visualElement,this);const t=this.visualElement.current,n=Oa(t,"pointerdown",c=>{const{drag:d,dragListener:h=!0}=this.getProps();d&&h&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();jr(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,i=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),Ne.read(r);const o=di(window,"resize",()=>this.scalePositionWithinConstraints()),l=a.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d})=>{this.isDragging&&d&&(Pt(h=>{const p=this.getAxisMotionValue(h);p&&(this.originPoint[h]+=c[h].translate,p.set(p.get()+c[h].translate))}),this.visualElement.render())});return()=>{o(),n(),i(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:i=!1,dragElastic:o=iu,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function Ji(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function XS(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class QS extends xs{constructor(t){super(t),this.removeGroupControls=kt,this.removeListeners=kt,this.controls=new YS(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||kt}unmount(){this.removeGroupControls(),this.removeListeners()}}const Rm=e=>(t,n)=>{e&&Ne.postRender(()=>e(t,n))};class JS extends xs{constructor(){super(...arguments),this.removePointerDownListener=kt}onPointerDown(t){this.session=new R1(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:V1(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:Rm(t),onStart:Rm(n),onMove:r,onEnd:(i,o)=>{delete this.session,a&&Ne.postRender(()=>a(i,o))}}}mount(){this.removePointerDownListener=Oa(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const So={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Lm(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const pa={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(re.test(e))e=parseFloat(e);else return e;const n=Lm(e,t.target.x),r=Lm(e,t.target.y);return`${n}% ${r}%`}},ZS={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,a=ds.parse(e);if(a.length>5)return r;const i=ds.createTransformer(e),o=typeof a[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;a[0+o]/=l,a[1+o]/=c;const d=_e(l,c,.5);return typeof a[2+o]=="number"&&(a[2+o]/=d),typeof a[3+o]=="number"&&(a[3+o]/=d),i(a)}};class e4 extends u.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:i}=t;b5(t4),i&&(n.group&&n.group.add(i),r&&r.register&&a&&r.register(i),i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),So.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:a,isPresent:i}=this.props,o=r.projection;return o&&(o.isPresent=i,a||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||Ne.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Ph.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=t;a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function U1(e){const[t,n]=Ny(),r=u.useContext(Nh);return s.jsx(e4,{...e,layoutGroup:r,switchLayoutGroup:u.useContext(zy),isPresent:t,safeToRemove:n})}const t4={borderRadius:{...pa,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:pa,borderTopRightRadius:pa,borderBottomLeftRadius:pa,borderBottomRightRadius:pa,boxShadow:ZS};function n4(e,t,n){const r=nt(e)?e:li(e);return r.start(tp("",r,t,n)),r.animation}function s4(e){return e instanceof SVGElement&&e.tagName!=="svg"}const r4=(e,t)=>e.depth-t.depth;class a4{constructor(){this.children=[],this.isDirty=!1}add(t){Hh(this.children,t),this.isDirty=!0}remove(t){Wh(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(r4),this.isDirty=!1,this.children.forEach(t)}}function i4(e,t){const n=hn.now(),r=({timestamp:a})=>{const i=a-n;i>=t&&(cs(r),e(i-t))};return Ne.read(r,!0),()=>cs(r)}const H1=["TopLeft","TopRight","BottomLeft","BottomRight"],o4=H1.length,Om=e=>typeof e=="string"?parseFloat(e):e,Im=e=>typeof e=="number"||re.test(e);function l4(e,t,n,r,a,i){a?(e.opacity=_e(0,n.opacity!==void 0?n.opacity:1,c4(r)),e.opacityExit=_e(t.opacity!==void 0?t.opacity:1,0,d4(r))):i&&(e.opacity=_e(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let o=0;o<o4;o++){const l=`border${H1[o]}Radius`;let c=Dm(t,l),d=Dm(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||Im(c)===Im(d)?(e[l]=Math.max(_e(Om(c),Om(d),r),0),(un.test(d)||un.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=_e(t.rotate||0,n.rotate||0,r))}function Dm(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const c4=W1(0,.5,c1),d4=W1(.5,.95,kt);function W1(e,t,n){return r=>r<e?0:r>t?1:n(Vr(e,t,r))}function Bm(e,t){e.min=t.min,e.max=t.max}function Tt(e,t){Bm(e.x,t.x),Bm(e.y,t.y)}function Fm(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function $m(e,t,n,r,a){return e-=t,e=dl(e,1/n,r),a!==void 0&&(e=dl(e,1/a,r)),e}function u4(e,t=0,n=1,r=.5,a,i=e,o=e){if(un.test(t)&&(t=parseFloat(t),t=_e(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=_e(i.min,i.max,r);e===i&&(l-=t),e.min=$m(e.min,t,n,l,a),e.max=$m(e.max,t,n,l,a)}function Vm(e,t,[n,r,a],i,o){u4(e,t[n],t[r],t[a],t.scale,i,o)}const h4=["x","scaleX","originX"],p4=["y","scaleY","originY"];function Um(e,t,n,r){Vm(e.x,t,h4,n?n.x:void 0,r?r.x:void 0),Vm(e.y,t,p4,n?n.y:void 0,r?r.y:void 0)}function Hm(e){return e.translate===0&&e.scale===1}function K1(e){return Hm(e.x)&&Hm(e.y)}function Wm(e,t){return e.min===t.min&&e.max===t.max}function f4(e,t){return Wm(e.x,t.x)&&Wm(e.y,t.y)}function Km(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function G1(e,t){return Km(e.x,t.x)&&Km(e.y,t.y)}function Gm(e){return Nt(e.x)/Nt(e.y)}function qm(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class m4{constructor(){this.members=[]}add(t){Hh(this.members,t),t.scheduleRender()}remove(t){if(Wh(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(a=>t===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const i=this.members[a];if(i.isPresent!==!1){r=i;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:a}=t.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function x4(e,t,n){let r="";const a=e.x.translate/t.x,i=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((a||i||o)&&(r=`translate3d(${a}px, ${i}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:h,rotateX:p,rotateY:f,skewX:m,skewY:b}=n;d&&(r=`perspective(${d}px) ${r}`),h&&(r+=`rotate(${h}deg) `),p&&(r+=`rotateX(${p}deg) `),f&&(r+=`rotateY(${f}deg) `),m&&(r+=`skewX(${m}deg) `),b&&(r+=`skewY(${b}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(r+=`scale(${l}, ${c})`),r||"none"}const Es={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},ka=typeof window<"u"&&window.MotionDebug!==void 0,Ac=["","X","Y","Z"],g4={visibility:"hidden"},Ym=1e3;let y4=0;function Mc(e,t,n,r){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),r&&(r[e]=0))}function q1(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=n1(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Ne,!(a||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&q1(r)}function Y1({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(o={},l=t==null?void 0:t()){this.id=y4++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,ka&&(Es.totalNodes=Es.resolvedTargetDeltas=Es.recalculatedProjection=0),this.nodes.forEach(w4),this.nodes.forEach(C4),this.nodes.forEach(E4),this.nodes.forEach(k4),ka&&window.MotionDebug.record(Es)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new a4)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Kh),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=s4(o),this.instance=o;const{layoutId:c,layout:d,visualElement:h}=this.options;if(h&&!h.current&&h.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(d||c)&&(this.isLayoutDirty=!0),e){let p;const f=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,p&&p(),p=i4(f,250),So.hasAnimatedSinceResize&&(So.hasAnimatedSinceResize=!1,this.nodes.forEach(Qm))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&h&&(c||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeTargetChanged:m,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||h.getDefaultTransition()||M4,{onLayoutAnimationStart:v,onLayoutAnimationComplete:x}=h.getProps(),g=!this.targetLayout||!G1(this.targetLayout,b)||m,w=!f&&m;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||w||f&&(g||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(p,w);const j={...Fh(y,"layout"),onPlay:v,onComplete:x};(h.shouldReduceMotion||this.options.layoutRoot)&&(j.delay=0,j.type=!1),this.startAnimation(j)}else f||Qm(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,cs(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(_4),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&q1(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const p=this.path[h];p.shouldResetTransform=!0,p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Xm);return}this.isUpdating||this.nodes.forEach(N4),this.isUpdating=!1,this.nodes.forEach(S4),this.nodes.forEach(v4),this.nodes.forEach(b4),this.clearAllSnapshots();const l=hn.now();Ye.delta=An(0,1e3/60,l-Ye.timestamp),Ye.timestamp=l,Ye.isProcessing=!0,kc.update.process(Ye),kc.preRender.process(Ye),kc.render.process(Ye),Ye.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ph.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(j4),this.sharedNodes.forEach(T4)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ne.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ne.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Le(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!a)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!K1(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,h=d!==this.prevTransformTemplateValue;o&&(l||Cs(this.latestValues)||h)&&(a(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),z4(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Le();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(R4))){const{scroll:h}=this.root;h&&(Cr(c.x,h.offset.x),Cr(c.y,h.offset.y))}return c}removeElementScroll(o){var l;const c=Le();if(Tt(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let d=0;d<this.path.length;d++){const h=this.path[d],{scroll:p,options:f}=h;h!==this.root&&p&&f.layoutScroll&&(p.wasRoot&&Tt(c,o),Cr(c.x,p.offset.x),Cr(c.y,p.offset.y))}return c}applyTransform(o,l=!1){const c=Le();Tt(c,o);for(let d=0;d<this.path.length;d++){const h=this.path[d];!l&&h.options.layoutScroll&&h.scroll&&h!==h.root&&Er(c,{x:-h.scroll.offset.x,y:-h.scroll.offset.y}),Cs(h.latestValues)&&Er(c,h.latestValues)}return Cs(this.latestValues)&&Er(c,this.latestValues),c}removeTransform(o){const l=Le();Tt(l,o);for(let c=0;c<this.path.length;c++){const d=this.path[c];if(!d.instance||!Cs(d.latestValues))continue;ou(d.latestValues)&&d.updateSnapshot();const h=Le(),p=d.measurePageBox();Tt(h,p),Um(l,d.latestValues,d.snapshot?d.snapshot.layoutBox:void 0,h)}return Cs(this.latestValues)&&Um(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ye.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const d=!!this.resumingFrom||this!==c;if(!(o||d&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:f}=this.options;if(!(!this.layout||!(p||f))){if(this.resolvedRelativeTargetAt=Ye.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Da(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Tt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Le(),this.targetWithTransforms=Le()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),IS(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Tt(this.target,this.layout.layoutBox),F1(this.target,this.targetDelta)):Tt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Da(this.relativeTargetOrigin,this.target,m.target),Tt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}ka&&Es.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||ou(this.parent.latestValues)||B1(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let d=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(d=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(d=!1),this.resolvedRelativeTargetAt===Ye.timestamp&&(d=!1),d)return;const{layout:h,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||p))return;Tt(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,m=this.treeScale.y;KS(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Le());const{target:b}=l;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Fm(this.prevProjectionDelta.x,this.projectionDelta.x),Fm(this.prevProjectionDelta.y,this.projectionDelta.y)),Ia(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==m||!qm(this.projectionDelta.x,this.prevProjectionDelta.x)||!qm(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",b)),ka&&Es.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Sr(),this.projectionDelta=Sr(),this.projectionDeltaWithTransform=Sr()}setAnimationOrigin(o,l=!1){const c=this.snapshot,d=c?c.latestValues:{},h={...this.latestValues},p=Sr();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Le(),m=c?c.source:void 0,b=this.layout?this.layout.source:void 0,y=m!==b,v=this.getStack(),x=!v||v.members.length<=1,g=!!(y&&!x&&this.options.crossfade===!0&&!this.path.some(A4));this.animationProgress=0;let w;this.mixTargetDelta=j=>{const k=j/1e3;Jm(p.x,o.x,k),Jm(p.y,o.y,k),this.setTargetDelta(p),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Da(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),P4(this.relativeTarget,this.relativeTargetOrigin,f,k),w&&f4(this.relativeTarget,w)&&(this.isProjectionDirty=!1),w||(w=Le()),Tt(w,this.relativeTarget)),y&&(this.animationValues=h,l4(h,d,this.latestValues,k,g,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(cs(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ne.update(()=>{So.hasAnimatedSinceResize=!0,this.currentAnimation=n4(0,Ym,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Ym),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:h}=o;if(!(!l||!c||!d)){if(this!==o&&this.layout&&d&&X1(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||Le();const p=Nt(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+p;const f=Nt(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}Tt(l,c),Er(l,h),Ia(this.projectionDeltaWithTransform,this.layoutCorrected,l,h)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new m4),this.sharedNodes.get(o).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Mc("z",o,d,this.animationValues);for(let h=0;h<Ac.length;h++)Mc(`rotate${Ac[h]}`,o,d,this.animationValues),Mc(`skew${Ac[h]}`,o,d,this.animationValues);o.render();for(const h in d)o.setStaticValue(h,d[h]),this.animationValues&&(this.animationValues[h]=d[h]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return g4;const d={visibility:""},h=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,d.opacity="",d.pointerEvents=jo(o==null?void 0:o.pointerEvents)||"",d.transform=h?h(this.latestValues,""):"none",d;const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){const y={};return this.options.layoutId&&(y.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,y.pointerEvents=jo(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Cs(this.latestValues)&&(y.transform=h?h({},""):"none",this.hasProjected=!1),y}const f=p.animationValues||p.latestValues;this.applyTransformsToTarget(),d.transform=x4(this.projectionDeltaWithTransform,this.treeScale,f),h&&(d.transform=h(f,d.transform));const{x:m,y:b}=this.projectionDelta;d.transformOrigin=`${m.origin*100}% ${b.origin*100}% 0`,p.animationValues?d.opacity=p===this?(c=(l=f.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:d.opacity=p===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const y in al){if(f[y]===void 0)continue;const{correct:v,applyTo:x}=al[y],g=d.transform==="none"?f[y]:v(f[y],p);if(x){const w=x.length;for(let j=0;j<w;j++)d[x[j]]=g}else d[y]=g}return this.options.layoutId&&(d.pointerEvents=p===this?jo(o==null?void 0:o.pointerEvents)||"":"none"),d}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Xm),this.root.sharedNodes.clear()}}}function v4(e){e.updateLayout()}function b4(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:a}=e.layout,{animationType:i}=e.options,o=n.source!==e.layout.source;i==="size"?Pt(p=>{const f=o?n.measuredBox[p]:n.layoutBox[p],m=Nt(f);f.min=r[p].min,f.max=f.min+m}):X1(i,n.layoutBox,r)&&Pt(p=>{const f=o?n.measuredBox[p]:n.layoutBox[p],m=Nt(r[p]);f.max=f.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+m)});const l=Sr();Ia(l,r,n.layoutBox);const c=Sr();o?Ia(c,e.applyTransform(a,!0),n.measuredBox):Ia(c,r,n.layoutBox);const d=!K1(l);let h=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:f,layout:m}=p;if(f&&m){const b=Le();Da(b,n.layoutBox,f.layoutBox);const y=Le();Da(y,r,m.layoutBox),G1(b,y)||(h=!0),p.options.layoutRoot&&(e.relativeTarget=y,e.relativeTargetOrigin=b,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeTargetChanged:h})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function w4(e){ka&&Es.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function k4(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function j4(e){e.clearSnapshot()}function Xm(e){e.clearMeasurements()}function N4(e){e.isLayoutDirty=!1}function S4(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Qm(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function C4(e){e.resolveTargetDelta()}function E4(e){e.calcProjection()}function _4(e){e.resetSkewAndRotation()}function T4(e){e.removeLeadSnapshot()}function Jm(e,t,n){e.translate=_e(t.translate,0,n),e.scale=_e(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Zm(e,t,n,r){e.min=_e(t.min,n.min,r),e.max=_e(t.max,n.max,r)}function P4(e,t,n,r){Zm(e.x,t.x,n.x,r),Zm(e.y,t.y,n.y,r)}function A4(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const M4={duration:.45,ease:[.4,0,.1,1]},e0=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),t0=e0("applewebkit/")&&!e0("chrome/")?Math.round:kt;function n0(e){e.min=t0(e.min),e.max=t0(e.max)}function z4(e){n0(e.x),n0(e.y)}function X1(e,t,n){return e==="position"||e==="preserve-aspect"&&!OS(Gm(t),Gm(n),.2)}function R4(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const L4=Y1({attachResizeListener:(e,t)=>di(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),zc={current:void 0},Q1=Y1({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!zc.current){const e=new L4({});e.mount(window),e.setOptions({layoutScroll:!0}),zc.current=e}return zc.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),O4={pan:{Feature:JS},drag:{Feature:QS,ProjectionNode:Q1,MeasureLayout:U1}};function s0(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,i=r[a];i&&Ne.postRender(()=>i(t,ji(t)))}class I4 extends xs{mount(){const{current:t}=this.node;t&&(this.unmount=O5(t,n=>(s0(this.node,n,"Start"),r=>s0(this.node,r,"End"))))}unmount(){}}class D4 extends xs{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=ki(di(this.node.current,"focus",()=>this.onFocus()),di(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function r0(e,t,n){const{props:r}=e;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),i=r[a];i&&Ne.postRender(()=>i(t,ji(t)))}class B4 extends xs{mount(){const{current:t}=this.node;t&&(this.unmount=F5(t,n=>(r0(this.node,n,"Start"),(r,{success:a})=>r0(this.node,r,a?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cu=new WeakMap,Rc=new WeakMap,F4=e=>{const t=cu.get(e.target);t&&t(e)},$4=e=>{e.forEach(F4)};function V4({root:e,...t}){const n=e||document;Rc.has(n)||Rc.set(n,{});const r=Rc.get(n),a=JSON.stringify(t);return r[a]||(r[a]=new IntersectionObserver($4,{root:e,...t})),r[a]}function U4(e,t,n){const r=V4(t);return cu.set(e,n),r.observe(e),()=>{cu.delete(e),r.unobserve(e)}}const H4={some:0,all:1};class W4 extends xs{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:H4[a]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,i&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:h,onViewportLeave:p}=this.node.getProps(),f=d?h:p;f&&f(c)};return U4(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(K4(t,n))&&this.startObserver()}unmount(){}}function K4({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const G4={inView:{Feature:W4},tap:{Feature:B4},focus:{Feature:D4},hover:{Feature:I4}},q4={layout:{ProjectionNode:Q1,MeasureLayout:U1}},du={current:null},J1={current:!1};function Y4(){if(J1.current=!0,!!Sh)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>du.current=e.matches;e.addListener(t),t()}else du.current=!1}const X4=[...j1,et,ds],Q4=e=>X4.find(k1(e)),a0=new WeakMap;function J4(e,t,n){for(const r in t){const a=t[r],i=n[r];if(nt(a))e.addValue(r,a);else if(nt(i))e.addValue(r,li(a,{owner:e}));else if(i!==a)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(a):o.hasAnimated||o.set(a)}else{const o=e.getStaticValue(r);e.addValue(r,li(o!==void 0?o:a,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const i0=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Z4{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:i,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Jh,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=hn.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Ne.render(this.render,!1,!0))};const{latestValues:c,renderState:d,onUpdate:h}=o;this.onUpdate=h,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=d,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.options=l,this.blockInitialAnimation=!!i,this.isControllingVariants=Ll(n),this.isVariantNode=Ay(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in f){const b=f[m];c[m]!==void 0&&nt(b)&&b.set(c[m],!1)}}mount(t){this.current=t,a0.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),J1.current||Y4(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:du.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){a0.delete(this.current),this.projection&&this.projection.unmount(),cs(this.notifyUpdate),cs(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Ys.has(t),a=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&Ne.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),i=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Ur){const n=Ur[t];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[t]&&a&&r(this.props)&&(this.features[t]=new a(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Le()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<i0.length;r++){const a=i0[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const i="on"+a,o=t[i];o&&(this.propEventSubscriptions[a]=this.on(a,o))}this.prevMotionValues=J4(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=li(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){var r;let a=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(r=this.getBaseTargetFromProps(this.props,t))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,t,this.options);return a!=null&&(typeof a=="string"&&(b1(a)||u1(a))?a=parseFloat(a):!Q4(a)&&ds.test(n)&&(a=g1(t,n)),this.setBaseTarget(t,nt(a)?a.get():a)),nt(a)?a.get():a}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:r}=this.props;let a;if(typeof r=="string"||typeof r=="object"){const o=Mh(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(a=o[t])}if(r&&a!==void 0)return a;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!nt(i)?i:this.initialValues[t]!==void 0&&a===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Kh),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Z1 extends Z4{constructor(){super(...arguments),this.KeyframeResolver=N1}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;nt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function e3(e){return window.getComputedStyle(e)}class t3 extends Z1{constructor(){super(...arguments),this.type="html",this.renderInstance=Fy}readValueFromInstance(t,n){if(Ys.has(n)){const r=Qh(n);return r&&r.default||0}else{const r=e3(t),a=(Iy(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $1(t,n)}build(t,n,r){Lh(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return Bh(t,n,r)}}class n3 extends Z1{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Le}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Ys.has(n)){const r=Qh(n);return r&&r.default||0}return n=$y.has(n)?n:Th(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return Hy(t,n,r)}build(t,n,r){Oh(t,n,this.isSVGTag,r.transformTemplate)}renderInstance(t,n,r,a){Vy(t,n,r,a)}mount(t){this.isSVGTag=Dh(t.tagName),super.mount(t)}}const s3=(e,t)=>Ah(e)?new n3(t):new t3(t,{allowProjection:e!==u.Fragment}),r3=T5({...ES,...G4,...O4,...q4},s3),V=Hj(r3);/**
|
|
77
77
|
* @license lucide-react v0.462.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
@@ -736,18 +736,18 @@ Error generating stack: `+i.message+`
|
|
|
736
736
|
*/const Ue=I("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),vv={welcome:{tagline:"Your AI Brain",title:"Must-b",sleeping:"Sleeping...",waking:"Waking up...",awake:"Awakening...",wakeBtn:"Wake Must-b",wakeHint:"Tap to continue",reconfigure:"Reconfigure",footer:"© 2026 Must-b — Auto Step Platform"},sidebar:{newChat:"New Chat",recentChats:"Recent Chats",primary:"Primary",personalization:"Personalization",platform:"Platform",system:"System",automations:"My Automations",activeWorkflows:"Active Workflows",products:"Skills & Plugins",clients:"Client Management",integrations:"Integrations",logs:"Logs & Activity",settings:"Settings",logout:"Logout",poweredBy:"Powered by",deleteChat:"Delete Chat?",deleteConfirm:"This action cannot be undone.",cancel:"Cancel",delete:"Delete"},rightPanel:{agentRole:"Agent Role",hardware:"Hardware Score",model:"Active Model",connected:"Gateway Connected",rank:{master:"Master",planner:"Planner",worker:"Worker"}},workflow:{title:"Active Workflow",idle:"Idle — awaiting task",goal:"Goal",steps:{browse:"Opening browser",write:"Writing file",think:"Thinking",exec:"Executing command"}},dashboard:{placeholder:"Send a message to Must-b...",thinking:"Must-b is thinking..."},layout:{chats:"Chats",system:"System",openChats:"Open chat history",openSystem:"Open system panel",closePanel:"Close panel"},chat:{inputPlaceholder:"Ask Must-b anything…",listening:"Listening…",thoughtProcess:"Thought Process",saveAsSkill:"Save as Skill",skillSaved:"Skill saved to your library!",saving:"Saving…",retry:"Retry",save:"Save",guidance:"Guidance",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation",settingsAck:"Got it, settings updated permanently.",professionAck:"I've completed the necessary research on your profession and noted it in my mind (must-b.md). I'm now ready as your **{profession}** assistant."},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",skills:"Skills",plugins:"Plugins",mind:"Must-b Mind",channels:"Channels"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I'm listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"Chat",files:"Files",browser:"Browser",skills:"Skills",memory:"Memory",plugins:"Plugins",workflows:"Workflows",settings:"Settings",system:"System",close:"Close",cat_webTools:"Web Tools",cat_fileMedia:"File & Media",cat_aiAgents:"AI & Agents",cat_systemTools:"System Tools",skill_webSearch:"Web Search",skill_webFetch:"Web Fetch",skill_browserControl:"Browser Control",skill_pdfReader:"PDF Reader",skill_imageAnalysis:"Image Analysis",skill_imageGeneration:"Image Generation",skill_tts:"Text-to-Speech",skill_spawnAgent:"Spawn Sub-Agent",skill_agentSessions:"Agent Sessions",skill_canvas:"Canvas",skill_git:"Git Operations",skill_gateway:"Gateway",skill_fileManager:"File Manager",skill_cron:"Cron Scheduler",skill_messages:"Messages",desc_webSearch:"Real-time web search (multi-provider)",desc_webFetch:"Fetch any URL as clean text",desc_browserControl:"Full Playwright browser automation",desc_pdfReader:"Extract & analyse PDF documents",desc_imageAnalysis:"Describe and analyse images",desc_imageGeneration:"Create AI-generated images",desc_tts:"Convert text to natural speech",desc_spawnAgent:"Launch a new autonomous agent session",desc_agentSessions:"List and manage active sessions",desc_canvas:"Visual drawing & whiteboard workspace",desc_git:"Commit, branch, diff, push/pull",desc_gateway:"Inter-system & A2A communication",desc_fileManager:"Read, write & manage files",desc_cron:"Schedule recurring tasks",desc_messages:"Send & receive inter-agent messages",cat_knowledgeBase:"Knowledge Base",cat_personalOrg:"Personal Organisation",mem_browse:"Browse Memories",mem_search:"Search Memory",mem_add:"Add Memory",mem_contacts:"Contacts",mem_calendar:"Calendar",desc_memBrowse:"View all stored knowledge entries",desc_memSearch:"Semantic search across your KB",desc_memAdd:"Store new facts and knowledge",desc_contacts:"Manage people and organisations",desc_calendar:"Schedule and manage events",cat_pluginManager:"Plugin Manager",cat_developer:"Developer",plug_marketplace:"Marketplace",plug_installed:"Installed",plug_mcp:"MCP Servers",plug_bundleMcp:"Bundle MCP",plug_cliCmds:"CLI Commands",desc_marketplace:"Discover plugins on ClawHub",desc_installed:"Manage and configure installed plugins",desc_mcp:"Model Context Protocol integrations",desc_bundleMcp:"Package & deploy MCP tool bundles",desc_cliCmds:"Custom slash command registration",cat_automation:"Automation",cat_advanced:"Advanced",wf_automations:"Automations",wf_scheduled:"Scheduled Tasks",wf_commands:"Commands",wf_nodes:"Nodes Workflow",wf_multiAgent:"Multi-Agent",desc_automations:"Build and run automated workflows",desc_scheduled:"Manage all cron schedules",desc_commands:"Custom slash commands",desc_nodes:"Visual node-graph pipelines",desc_multiAgent:"Orchestrate agent collaboration"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",moreModels:"More Models / API Settings",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},alerts:{cpu_high:"High CPU usage — LLM load is saturating the system.",ram_high:"High memory usage — performance may degrade.",ram_critical:"Memory critical — system lockup risk."},recommendations:{cpu_high:"Close background processes or switch to a smaller model.",ram_high:"Consider switching to a lighter model.",ram_critical:"Switch to an 8B or 14B model immediately."}},panels:{memory:{title:"Memory Insights",indexLabel:"Index:",clearIndex:"Clear Index",searchPlaceholder:"Search your memory…",searchHint:"Semantic similarity search — press Enter or click",emptyTitle:"Search your AI memory",emptyNoResults:"No memories found",emptyHint:"Type a phrase to find semantically similar skills, conversations, and workspace files.",emptyNoResultsHint:"Try a different phrase or index more content using the controls above.",refreshStats:"Refresh stats",indexControls:"Index controls",vectors:"vectors",skills:"skills",files:"files",indexed:"Indexed",indexCleared:"Index cleared",opFailed:"Operation failed",reqError:"Request error"},plugins:{title:"Plugin Architect",newPlugin:"New Plugin",buildTitle:"Build New Plugin",namePlaceholder:"Plugin name (e.g. weather-monitor)",goalPlaceholder:"Goal (e.g. poll OpenWeather API every 5 min)",contextPlaceholder:"Optional context / notes",generatePlugin:"Generate Plugin",emptyTitle:"No plugins installed",emptyHint:'Click "New Plugin" to generate your first plugin.',installed:"installed",running:"RUNNING",stop:"Stop",run:"Run",opFailed:"Operation failed",reqError:"Request error",buildFailed:"Build failed",refresh:"Refresh"},skills:{title:"Skill Library",loading:"Loading skills…",emptyTitle:"No skills saved yet",emptyHint:"Complete a workflow in the Chat tab, then click",saveAsSkill:"Save as Skill",emptyHint2:"to build your library.",runningStatus:"Running skill…",completedStatus:"Skill completed",failedStatus:"Skill run failed",never:"Never",deleteConfirm:"Delete?",yes:"Yes",no:"No",runBtn:"Run",runningBtn:"Running…",doneBtn:"Done",lastRun:"last run"},settings:{title:"Settings",hardwareScore:"Hardware Score",searchPlaceholder:"Search providers…",allProviders:"All",apiKey:"API Key",baseUrl:"Base URL",model:"Model",testConnection:"Test Connection",save:"Save",testOk:"Connection successful",testFail:"Connection failed",saved:"Saved",saving:"Saving…",testing:"Testing…",apiKeyWarning:"API key required — update your key to continue."}}},Z3={welcome:{tagline:"Yapay Zeka Beyniniz",title:"Must-b",sleeping:"Uyuyor...",waking:"Uyandırılıyor...",awake:"Uyanıyor...",wakeBtn:"Must-b'yi Uyandır",wakeHint:"Devam etmek için uyandır",reconfigure:"Yeniden Yapılandır",footer:"© 2026 Must-b — Auto Step Platform"},sidebar:{newChat:"Yeni Sohbet",recentChats:"Son Sohbetler",primary:"Birincil",personalization:"Kişiselleştirme",platform:"Platform",system:"Sistem",automations:"Otomasyonlarım",activeWorkflows:"Aktif İş Akışları",products:"Araçlar & Eklentiler",clients:"Müşteri Yönetimi",integrations:"Entegrasyonlar",logs:"Kayıtlar & Aktivite",settings:"Ayarlar",logout:"Çıkış",poweredBy:"Altyapısı:",deleteChat:"Sohbet Silinsin mi?",deleteConfirm:"Bu işlem geri alınamaz.",cancel:"İptal",delete:"Sil"},rightPanel:{agentRole:"Ajan Rolü",hardware:"Donanım Puanı",model:"Aktif Model",connected:"Gateway Bağlı",rank:{master:"Usta",planner:"Planlayıcı",worker:"İşçi"}},workflow:{title:"Aktif İş Akışı",idle:"Boşta — görev bekleniyor",goal:"Hedef",steps:{browse:"Tarayıcı açılıyor",write:"Dosya yazılıyor",think:"Düşünülüyor",exec:"Komut çalıştırılıyor"}},dashboard:{placeholder:"Must-b'ye bir mesaj gönderin...",thinking:"Must-b düşünüyor..."},layout:{chats:"Sohbetler",system:"Sistem",openChats:"Sohbet geçmişini aç",openSystem:"Sistem panelini aç",closePanel:"Paneli kapat"},chat:{inputPlaceholder:"Must-b'ye her şeyi sorun…",listening:"Dinleniyor…",thoughtProcess:"Düşünce Süreci",saveAsSkill:"Beceri Olarak Kaydet",skillSaved:"Beceri kütüphanenize kaydedildi!",saving:"Kaydediliyor…",retry:"Tekrar Dene",save:"Kaydet",guidance:"Rehberlik",errorBoundary:"Sohbet render hatası — yeniden yükleniyor…",disclaimer:"Must-b bilişsel bir asistandır; kritik çıktıları doğrulamanız önerilir.",placeholder:"Ne öğrenmek istiyorsunuz?",tools:"Araçlar",attachFile:"Dosya ekle",startDictation:"Sesli giriş başlat",stopDictation:"Durdur",settingsAck:"Anlaşıldı, ayarlar kalıcı olarak güncellendi.",professionAck:"Mesleğiniz hakkında gerekli araştırmaları yaptım ve zihnime (must-b.md) not aldım. Artık bir **{profession}** asistanı olarak hazırım."},nav:{chat:"Sohbet",browser:"Tarayıcı",workflows:"İş Akışları",voice:"Sesli",settings:"Ayarlar",files:"Dosyalar",memory:"Bellek",apiKeys:"API Anahtarları",skills:"Beceriler",plugins:"Eklentiler",mind:"Must-b Zihni",channels:"Kanallar"},voice:{title:"Must-b Sesli Komuta",back:"Geri Dön",wakeHint:'"Hey Must-b" demeyi dene.',tapHint:"Başlamak için mikrofona dokunun.",heard:"Sizi duyuyorum…",listening:"Dinleniyor…",stopHint:"Durdurmak için tıklayın",thinking:"İşleniyor…",cmdHint:"Buyurun, dinliyorum…",speakingHint:"Must-b konuşuyor…"},systemHealth:{lite:"LITE",safe:"GÜVENLİ",critical:"Kritik",warning:"Uyarı",info:"Bilgi",title:"Sistem Durumu",moreModels:"Daha Fazla Model / API Ayarları",kinds:{cpu:"İşlemci",ram:"RAM",memory:"Bellek",storage:"Depolama",network:"Ağ",process:"İşlem",battery:"Batarya",thermal:"Isı",disk:"Disk"},alerts:{cpu_high:"İşlemci kullanımı yüksek — LLM yükü sistemi doyuruyor.",ram_high:"Bellek kullanımı yüksek — performans düşebilir.",ram_critical:"Bellek kritik — sistem kilitlenme riski var."},recommendations:{cpu_high:"Arka plan işlemlerini kapatın veya daha küçük bir modele geçin.",ram_high:"Daha hafif bir modele geçmeyi düşünün.",ram_critical:"Hemen 8B veya 14B bir modele geçin."}},dock:{chat:"Sohbet",files:"Dosyalar",browser:"Tarayıcı",skills:"Beceriler",memory:"Bellek",plugins:"Eklentiler",workflows:"İş Akışları",settings:"Ayarlar",system:"Sistem",close:"Kapat",cat_webTools:"Web Araçları",cat_fileMedia:"Dosya & Medya",cat_aiAgents:"Yapay Zeka & Ajanlar",cat_systemTools:"Sistem Araçları",skill_webSearch:"Web Arama",skill_webFetch:"Web Çekme",skill_browserControl:"Tarayıcı Kontrolü",skill_pdfReader:"PDF Okuyucu",skill_imageAnalysis:"Görüntü Analizi",skill_imageGeneration:"Görüntü Oluşturma",skill_tts:"Metinden Sese",skill_spawnAgent:"Alt Ajan Başlat",skill_agentSessions:"Ajan Oturumları",skill_canvas:"Tuval",skill_git:"Git İşlemleri",skill_gateway:"Ağ Geçidi",skill_fileManager:"Dosya Yöneticisi",skill_cron:"Zamanlayıcı",skill_messages:"Mesajlar",desc_webSearch:"Gerçek zamanlı web araması (çoklu sağlayıcı)",desc_webFetch:"Herhangi bir URL'yi metin olarak çek",desc_browserControl:"Tam Playwright tarayıcı otomasyonu",desc_pdfReader:"PDF belgelerini çıkar ve analiz et",desc_imageAnalysis:"Görüntüleri tanımla ve analiz et",desc_imageGeneration:"Yapay zeka ile görüntü oluştur",desc_tts:"Metni doğal sese dönüştür",desc_spawnAgent:"Yeni özerk ajan oturumu başlat",desc_agentSessions:"Aktif oturumları listele ve yönet",desc_canvas:"Görsel çizim & beyaz tahta",desc_git:"Commit, branch, diff, push/pull",desc_gateway:"Sistemler arası & A2A iletişim",desc_fileManager:"Dosyaları oku, yaz ve yönet",desc_cron:"Tekrarlayan görevleri zamanla",desc_messages:"Ajanlar arası mesaj gönder ve al",cat_knowledgeBase:"Bilgi Tabanı",cat_personalOrg:"Kişisel Organizasyon",mem_browse:"Belleklere Göz At",mem_search:"Bellekte Ara",mem_add:"Bellek Ekle",mem_contacts:"Kişiler",mem_calendar:"Takvim",desc_memBrowse:"Tüm saklanan bilgi girişlerini görüntüle",desc_memSearch:"Bilgi tabanında anlamsal arama",desc_memAdd:"Yeni bilgi ve gerçekleri sakla",desc_contacts:"Kişileri ve kuruluşları yönet",desc_calendar:"Etkinlikleri zamanla ve yönet",cat_pluginManager:"Eklenti Yöneticisi",cat_developer:"Geliştirici",plug_marketplace:"Pazar Yeri",plug_installed:"Yüklü Eklentiler",plug_mcp:"MCP Sunucuları",plug_bundleMcp:"MCP Paketi",plug_cliCmds:"CLI Komutları",desc_marketplace:"ClawHub'da eklentileri keşfet",desc_installed:"Yüklü eklentileri yönet ve yapılandır",desc_mcp:"Model Context Protocol entegrasyonları",desc_bundleMcp:"MCP araç paketlerini oluştur ve dağıt",desc_cliCmds:"Özel eğik çizgi komutları kaydı",cat_automation:"Otomasyon",cat_advanced:"Gelişmiş",wf_automations:"Otomasyonlar",wf_scheduled:"Zamanlanmış Görevler",wf_commands:"Komutlar",wf_nodes:"Düğüm İş Akışı",wf_multiAgent:"Çoklu Ajan",desc_automations:"Otomatik iş akışları oluştur ve çalıştır",desc_scheduled:"Tüm cron zamanlamalarını yönet",desc_commands:"Özel eğik çizgi komutları",desc_nodes:"Görsel düğüm-grafik iş hatları",desc_multiAgent:"Ajan işbirliğini düzenle"},panels:{memory:{title:"Bellek Görüşleri",indexLabel:"İndeks:",clearIndex:"İndeksi Temizle",searchPlaceholder:"Belleğinizde arayın…",searchHint:"Anlamsal benzerlik araması — Enter'a basın veya tıklayın",emptyTitle:"Yapay Zeka Belleğinizi Arayın",emptyNoResults:"Bellek bulunamadı",emptyHint:"Beceriler, sohbetler ve dosyalarda anlamsal olarak benzer içerik bulmak için bir ifade yazın.",emptyNoResultsHint:"Farklı bir ifade deneyin veya yukarıdaki kontrollerle daha fazla içerik ekleyin.",refreshStats:"İstatistikleri yenile",indexControls:"İndeks kontrolleri",vectors:"vektör",skills:"beceri",files:"dosya",indexed:"İndekslendi",indexCleared:"İndeks temizlendi",opFailed:"İşlem başarısız",reqError:"İstek hatası"},plugins:{title:"Eklenti Mimarı",newPlugin:"Yeni Eklenti",buildTitle:"Yeni Eklenti Oluştur",namePlaceholder:"Eklenti adı (örn. hava-durumu-monitörü)",goalPlaceholder:"Hedef (örn. OpenWeather API'yi 5 dakikada bir sorgula)",contextPlaceholder:"İsteğe bağlı bağlam / notlar",generatePlugin:"Eklenti Oluştur",emptyTitle:"Yüklü eklenti yok",emptyHint:'İlk eklentinizi oluşturmak için "Yeni Eklenti"ye tıklayın.',installed:"yüklü",running:"ÇALIŞIYOR",stop:"Durdur",run:"Çalıştır",opFailed:"İşlem başarısız",reqError:"İstek hatası",buildFailed:"Oluşturma başarısız",refresh:"Yenile"},skills:{title:"Beceri Kütüphanesi",loading:"Beceriler yükleniyor…",emptyTitle:"Henüz kaydedilmiş beceri yok",emptyHint:"Sohbet sekmesinde bir iş akışını tamamlayın, ardından tıklayın",saveAsSkill:"Beceri Olarak Kaydet",emptyHint2:"kütüphanenizi oluşturmak için.",runningStatus:"Beceri çalışıyor…",completedStatus:"Beceri tamamlandı",failedStatus:"Beceri çalıştırma başarısız",never:"Hiçbir zaman",deleteConfirm:"Sil?",yes:"Evet",no:"Hayır",runBtn:"Çalıştır",runningBtn:"Çalışıyor…",doneBtn:"Tamamlandı",lastRun:"son çalıştırma"},settings:{title:"Ayarlar",hardwareScore:"Donanım Puanı",searchPlaceholder:"Sağlayıcı ara…",allProviders:"Tümü",apiKey:"API Anahtarı",baseUrl:"Temel URL",model:"Model",testConnection:"Bağlantıyı Test Et",save:"Kaydet",testOk:"Bağlantı başarılı",testFail:"Bağlantı başarısız",saved:"Kaydedildi",saving:"Kaydediliyor…",testing:"Test ediliyor…",apiKeyWarning:"API anahtarı gerekli — devam etmek için anahtarınızı güncelleyin."}}},eC={welcome:{tagline:"Ihr KI-Gehirn",title:"Must-b",sleeping:"Schläft...",waking:"Wird geweckt...",awake:"Erwacht...",wakeBtn:"Must-b wecken",wakeHint:"Tippen zum Fortfahren",reconfigure:"Neu konfigurieren",footer:"© 2026 Must-b — Auto Step Platform"},sidebar:{newChat:"Neuer Chat",recentChats:"Letzte Chats",platform:"Plattform",system:"System",automations:"Meine Automatisierungen",activeWorkflows:"Aktive Workflows",products:"Skills & Plugins",clients:"Kundenverwaltung",integrations:"Integrationen",logs:"Protokolle & Aktivität",settings:"Einstellungen",logout:"Abmelden",poweredBy:"Betrieben von",deleteChat:"Chat löschen?",deleteConfirm:"Diese Aktion kann nicht rückgängig gemacht werden.",cancel:"Abbrechen",delete:"Löschen"},rightPanel:{agentRole:"Agentenrolle",hardware:"Hardware-Score",model:"Aktives Modell",connected:"Gateway verbunden",rank:{master:"Meister",planner:"Planer",worker:"Arbeiter"}},workflow:{title:"Aktiver Workflow",idle:"Leerlauf — wartet auf Aufgabe",goal:"Ziel",steps:{browse:"Browser wird geöffnet",write:"Datei wird geschrieben",think:"Wird nachgedacht",exec:"Befehl wird ausgeführt"}},dashboard:{placeholder:"Nachricht an Must-b senden...",thinking:"Must-b denkt nach..."},layout:{chats:"Chats",system:"System",openChats:"Chatverlauf öffnen",openSystem:"Systembereich öffnen",closePanel:"Bereich schließen"},chat:{inputPlaceholder:"Fragen Sie Must-b alles…",listening:"Höre zu…",thoughtProcess:"Denkprozess",saveAsSkill:"Als Fähigkeit speichern",skillSaved:"Fähigkeit in Ihrer Bibliothek gespeichert!",saving:"Speichere…",retry:"Erneut versuchen",save:"Speichern",guidance:"Hinweis",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"Kanäle"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"Chat",files:"Dateien",browser:"Browser",skills:"Fähigkeiten",memory:"Gedächtnis",plugins:"Plugins",workflows:"Workflows",settings:"Einstellungen",system:"System",close:"Schließen",cat_webTools:"Web-Werkzeuge",cat_fileMedia:"Datei & Medien",cat_aiAgents:"KI & Agenten",cat_systemTools:"Systemwerkzeuge",skill_webSearch:"Websuche",skill_webFetch:"Web-Abruf",skill_browserControl:"Browser-Steuerung",skill_pdfReader:"PDF-Leser",skill_imageAnalysis:"Bildanalyse",skill_imageGeneration:"Bilderzeugung",skill_tts:"Text-zu-Sprache",skill_spawnAgent:"Unteragent starten",skill_agentSessions:"Agentensitzungen",skill_canvas:"Leinwand",skill_git:"Git-Operationen",skill_gateway:"Gateway",skill_fileManager:"Dateimanager",skill_cron:"Aufgabenplaner",skill_messages:"Nachrichten",desc_webSearch:"Echtzeit-Websuche (Multi-Provider)",desc_webFetch:"Beliebige URL als sauberen Text abrufen",desc_browserControl:"Vollständige Playwright-Browserautomatisierung",desc_pdfReader:"PDF-Dokumente extrahieren & analysieren",desc_imageAnalysis:"Bilder beschreiben und analysieren",desc_imageGeneration:"KI-generierte Bilder erstellen",desc_tts:"Text in natürliche Sprache umwandeln",desc_spawnAgent:"Neue autonome Agentensitzung starten",desc_agentSessions:"Aktive Sitzungen auflisten und verwalten",desc_canvas:"Visueller Zeichen- & Whiteboard-Bereich",desc_git:"Commit, Branch, Diff, Push/Pull",desc_gateway:"Systemübergreifende & A2A-Kommunikation",desc_fileManager:"Dateien lesen, schreiben & verwalten",desc_cron:"Wiederkehrende Aufgaben planen",desc_messages:"Agenten-Nachrichten senden & empfangen",cat_knowledgeBase:"Wissensdatenbank",cat_personalOrg:"Persönliche Organisation",mem_browse:"Erinnerungen durchsuchen",mem_search:"Gedächtnis suchen",mem_add:"Erinnerung hinzufügen",mem_contacts:"Kontakte",mem_calendar:"Kalender",desc_memBrowse:"Alle gespeicherten Wissenseinträge anzeigen",desc_memSearch:"Semantische Suche in der Wissensdatenbank",desc_memAdd:"Neue Fakten und Wissen speichern",desc_contacts:"Personen und Organisationen verwalten",desc_calendar:"Termine planen und verwalten",cat_pluginManager:"Plugin-Manager",cat_developer:"Entwickler",plug_marketplace:"Marktplatz",plug_installed:"Installiert",plug_mcp:"MCP-Server",plug_bundleMcp:"MCP bündeln",plug_cliCmds:"CLI-Befehle",desc_marketplace:"Plugins auf ClawHub entdecken",desc_installed:"Installierte Plugins verwalten und konfigurieren",desc_mcp:"Model Context Protocol-Integrationen",desc_bundleMcp:"MCP-Werkzeugpakete erstellen & bereitstellen",desc_cliCmds:"Benutzerdefinierte Schrägstrichbefehle registrieren",cat_automation:"Automatisierung",cat_advanced:"Erweitert",wf_automations:"Automatisierungen",wf_scheduled:"Geplante Aufgaben",wf_commands:"Befehle",wf_nodes:"Knoten-Workflow",wf_multiAgent:"Multi-Agent",desc_automations:"Automatisierte Workflows erstellen und ausführen",desc_scheduled:"Alle Cron-Zeitpläne verwalten",desc_commands:"Benutzerdefinierte Schrägstrichbefehle",desc_nodes:"Visuelle Knoten-Graph-Pipelines",desc_multiAgent:"Agentenzusammenarbeit orchestrieren"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"Gedächtnisübersicht",indexLabel:"Index:",clearIndex:"Index löschen",searchPlaceholder:"Gedächtnis durchsuchen…",searchHint:"Semantische Ähnlichkeitssuche — Enter drücken oder klicken",emptyTitle:"KI-Gedächtnis durchsuchen",emptyNoResults:"Keine Erinnerungen gefunden",emptyHint:"Geben Sie einen Begriff ein, um semantisch ähnliche Fähigkeiten, Gespräche und Dateien zu finden.",emptyNoResultsHint:"Versuchen Sie eine andere Formulierung oder indizieren Sie mehr Inhalte.",refreshStats:"Statistiken aktualisieren",indexControls:"Indexsteuerung",vectors:"Vektoren",skills:"Fähigkeiten",files:"Dateien",indexed:"Indiziert",indexCleared:"Index gelöscht",opFailed:"Vorgang fehlgeschlagen",reqError:"Anfragefehler"},plugins:{title:"Plugin-Architekt",newPlugin:"Neues Plugin",buildTitle:"Neues Plugin erstellen",namePlaceholder:"Plugin-Name (z.B. wetter-monitor)",goalPlaceholder:"Ziel (z.B. OpenWeather API alle 5 Min. abfragen)",contextPlaceholder:"Optionaler Kontext / Notizen",generatePlugin:"Plugin generieren",emptyTitle:"Keine Plugins installiert",emptyHint:'Klicken Sie auf "Neues Plugin", um Ihr erstes Plugin zu erstellen.',installed:"installiert",running:"LÄUFT",stop:"Stoppen",run:"Ausführen",opFailed:"Vorgang fehlgeschlagen",reqError:"Anfragefehler",buildFailed:"Erstellung fehlgeschlagen",refresh:"Aktualisieren"},skills:{title:"Fähigkeitenbibliothek",loading:"Fähigkeiten werden geladen…",emptyTitle:"Noch keine Fähigkeiten gespeichert",emptyHint:"Schließen Sie einen Workflow im Chat-Tab ab, dann klicken Sie auf",saveAsSkill:"Als Fähigkeit speichern",emptyHint2:"um Ihre Bibliothek aufzubauen.",runningStatus:"Fähigkeit wird ausgeführt…",completedStatus:"Fähigkeit abgeschlossen",failedStatus:"Ausführung fehlgeschlagen",never:"Nie",deleteConfirm:"Löschen?",yes:"Ja",no:"Nein",runBtn:"Ausführen",runningBtn:"Läuft…",doneBtn:"Fertig",lastRun:"letzter Lauf"},settings:{title:"Einstellungen",hardwareScore:"Hardware-Score",searchPlaceholder:"Anbieter suchen…",allProviders:"Alle",apiKey:"API-Schlüssel",baseUrl:"Basis-URL",model:"Modell",testConnection:"Verbindung testen",save:"Speichern",testOk:"Verbindung erfolgreich",testFail:"Verbindung fehlgeschlagen",saved:"Gespeichert",saving:"Speichern…",testing:"Teste…",apiKeyWarning:"API-Schlüssel erforderlich — aktualisieren Sie Ihren Schlüssel."}}},tC={welcome:{tagline:"Votre cerveau IA",title:"Must-b",sleeping:"En veille...",waking:"Réveil en cours...",awake:"Éveil...",wakeBtn:"Réveiller Must-b",wakeHint:"Appuyez pour continuer",reconfigure:"Reconfigurer",footer:"© 2026 Must-b — Plateforme Auto Step"},sidebar:{newChat:"Nouvelle discussion",recentChats:"Discussions récentes",platform:"Plateforme",system:"Système",automations:"Mes automatisations",activeWorkflows:"Flux de travail actifs",products:"Skills & Plugins",clients:"Gestion des clients",integrations:"Intégrations",logs:"Journaux & Activité",settings:"Paramètres",logout:"Déconnexion",poweredBy:"Propulsé par",deleteChat:"Supprimer la discussion ?",deleteConfirm:"Cette action est irréversible.",cancel:"Annuler",delete:"Supprimer"},rightPanel:{agentRole:"Rôle de l'agent",hardware:"Score matériel",model:"Modèle actif",connected:"Passerelle connectée",rank:{master:"Maître",planner:"Planificateur",worker:"Exécutant"}},workflow:{title:"Flux de travail actif",idle:"Inactif — en attente d'une tâche",goal:"Objectif",steps:{browse:"Ouverture du navigateur",write:"Écriture du fichier",think:"Réflexion",exec:"Exécution de la commande"}},dashboard:{placeholder:"Envoyer un message à Must-b...",thinking:"Must-b réfléchit..."},layout:{chats:"Discussions",system:"Système",openChats:"Ouvrir l'historique des discussions",openSystem:"Ouvrir le panneau système",closePanel:"Fermer le panneau"},chat:{inputPlaceholder:"Posez n'importe quelle question à Must-b…",listening:"Écoute en cours…",thoughtProcess:"Processus de réflexion",saveAsSkill:"Enregistrer comme compétence",skillSaved:"Compétence enregistrée dans votre bibliothèque !",saving:"Enregistrement…",retry:"Réessayer",save:"Enregistrer",guidance:"Conseils",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"Canaux"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"Discussion",files:"Fichiers",browser:"Navigateur",skills:"Compétences",memory:"Mémoire",plugins:"Plugins",workflows:"Flux de travail",settings:"Paramètres",system:"Système",close:"Fermer",cat_webTools:"Outils web",cat_fileMedia:"Fichiers & Médias",cat_aiAgents:"IA & Agents",cat_systemTools:"Outils système",skill_webSearch:"Recherche web",skill_webFetch:"Récupération web",skill_browserControl:"Contrôle du navigateur",skill_pdfReader:"Lecteur PDF",skill_imageAnalysis:"Analyse d'image",skill_imageGeneration:"Génération d'image",skill_tts:"Synthèse vocale",skill_spawnAgent:"Créer un sous-agent",skill_agentSessions:"Sessions d'agents",skill_canvas:"Tableau de travail",skill_git:"Opérations Git",skill_gateway:"Passerelle",skill_fileManager:"Gestionnaire de fichiers",skill_cron:"Planificateur Cron",skill_messages:"Messages",desc_webSearch:"Recherche web en temps réel (multi-fournisseur)",desc_webFetch:"Récupérer n'importe quelle URL en texte brut",desc_browserControl:"Automatisation complète du navigateur Playwright",desc_pdfReader:"Extraire et analyser des documents PDF",desc_imageAnalysis:"Décrire et analyser des images",desc_imageGeneration:"Créer des images générées par IA",desc_tts:"Convertir du texte en parole naturelle",desc_spawnAgent:"Lancer une nouvelle session d'agent autonome",desc_agentSessions:"Lister et gérer les sessions actives",desc_canvas:"Espace de dessin visuel et tableau blanc",desc_git:"Commit, branche, diff, push/pull",desc_gateway:"Communication inter-systèmes & A2A",desc_fileManager:"Lire, écrire et gérer des fichiers",desc_cron:"Planifier des tâches récurrentes",desc_messages:"Envoyer & recevoir des messages inter-agents",cat_knowledgeBase:"Base de connaissances",cat_personalOrg:"Organisation personnelle",mem_browse:"Parcourir les souvenirs",mem_search:"Rechercher dans la mémoire",mem_add:"Ajouter un souvenir",mem_contacts:"Contacts",mem_calendar:"Calendrier",desc_memBrowse:"Voir toutes les entrées de connaissances stockées",desc_memSearch:"Recherche sémantique dans votre base de connaissances",desc_memAdd:"Stocker de nouveaux faits et connaissances",desc_contacts:"Gérer les personnes et organisations",desc_calendar:"Planifier et gérer des événements",cat_pluginManager:"Gestionnaire de plugins",cat_developer:"Développeur",plug_marketplace:"Marché",plug_installed:"Installés",plug_mcp:"Serveurs MCP",plug_bundleMcp:"Bundle MCP",plug_cliCmds:"Commandes CLI",desc_marketplace:"Découvrir des plugins sur ClawHub",desc_installed:"Gérer et configurer les plugins installés",desc_mcp:"Intégrations du protocole de contexte de modèle",desc_bundleMcp:"Empaqueter et déployer des bundles d'outils MCP",desc_cliCmds:"Enregistrement de commandes slash personnalisées",cat_automation:"Automatisation",cat_advanced:"Avancé",wf_automations:"Automatisations",wf_scheduled:"Tâches planifiées",wf_commands:"Commandes",wf_nodes:"Flux de nœuds",wf_multiAgent:"Multi-Agent",desc_automations:"Créer et exécuter des flux de travail automatisés",desc_scheduled:"Gérer tous les plannings cron",desc_commands:"Commandes slash personnalisées",desc_nodes:"Pipelines visuels en graphe de nœuds",desc_multiAgent:"Orchestrer la collaboration entre agents"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"Aperçus de la mémoire",indexLabel:"Index :",clearIndex:"Effacer l'index",searchPlaceholder:"Rechercher dans votre mémoire…",searchHint:"Recherche par similarité sémantique — appuyez sur Entrée ou cliquez",emptyTitle:"Recherchez dans votre mémoire IA",emptyNoResults:"Aucun souvenir trouvé",emptyHint:"Saisissez une phrase pour trouver des compétences, conversations et fichiers sémantiquement similaires.",emptyNoResultsHint:"Essayez une phrase différente ou indexez plus de contenu via les contrôles ci-dessus.",refreshStats:"Actualiser les statistiques",indexControls:"Contrôles de l'index",vectors:"vecteurs",skills:"compétences",files:"fichiers",indexed:"Indexé",indexCleared:"Index effacé",opFailed:"Opération échouée",reqError:"Erreur de requête"},plugins:{title:"Architecte de plugins",newPlugin:"Nouveau plugin",buildTitle:"Créer un nouveau plugin",namePlaceholder:"Nom du plugin (ex. weather-monitor)",goalPlaceholder:"Objectif (ex. interroger l'API OpenWeather toutes les 5 min)",contextPlaceholder:"Contexte / notes optionnels",generatePlugin:"Générer le plugin",emptyTitle:"Aucun plugin installé",emptyHint:"Cliquez sur « Nouveau plugin » pour générer votre premier plugin.",installed:"installé",running:"EN COURS",stop:"Arrêter",run:"Exécuter",opFailed:"Opération échouée",reqError:"Erreur de requête",buildFailed:"Échec de la compilation",refresh:"Actualiser"},skills:{title:"Bibliothèque de compétences",loading:"Chargement des compétences…",emptyTitle:"Aucune compétence enregistrée",emptyHint:"Terminez un flux de travail dans l'onglet Discussion, puis cliquez sur",saveAsSkill:"Enregistrer comme compétence",emptyHint2:"pour constituer votre bibliothèque.",runningStatus:"Exécution de la compétence…",completedStatus:"Compétence terminée",failedStatus:"Échec de l'exécution",never:"Jamais",deleteConfirm:"Supprimer ?",yes:"Oui",no:"Non",runBtn:"Exécuter",runningBtn:"En cours…",doneBtn:"Terminé",lastRun:"dernière exécution"},settings:{title:"Paramètres",hardwareScore:"Score matériel",searchPlaceholder:"Rechercher des fournisseurs…",allProviders:"Tous",apiKey:"Clé API",baseUrl:"URL de base",model:"Modèle",testConnection:"Tester la connexion",save:"Enregistrer",testOk:"Connexion réussie",testFail:"Échec de la connexion",saved:"Enregistré",saving:"Enregistrement…",testing:"Test en cours…",apiKeyWarning:"Clé API requise — mettez à jour votre clé pour continuer."}}},nC={welcome:{tagline:"Tu cerebro de IA",title:"Must-b",sleeping:"Durmiendo...",waking:"Despertando...",awake:"Despertando...",wakeBtn:"Despertar Must-b",wakeHint:"Toca para continuar",reconfigure:"Reconfigurar",footer:"© 2026 Must-b — Plataforma Auto Step"},sidebar:{newChat:"Nueva conversación",recentChats:"Conversaciones recientes",platform:"Plataforma",system:"Sistema",automations:"Mis automatizaciones",activeWorkflows:"Flujos de trabajo activos",products:"Skills & Plugins",clients:"Gestión de clientes",integrations:"Integraciones",logs:"Registros y actividad",settings:"Configuración",logout:"Cerrar sesión",poweredBy:"Desarrollado por",deleteChat:"¿Eliminar conversación?",deleteConfirm:"Esta acción no se puede deshacer.",cancel:"Cancelar",delete:"Eliminar"},rightPanel:{agentRole:"Rol del agente",hardware:"Puntuación de hardware",model:"Modelo activo",connected:"Puerta de enlace conectada",rank:{master:"Maestro",planner:"Planificador",worker:"Trabajador"}},workflow:{title:"Flujo de trabajo activo",idle:"Inactivo — esperando tarea",goal:"Objetivo",steps:{browse:"Abriendo navegador",write:"Escribiendo archivo",think:"Pensando",exec:"Ejecutando comando"}},dashboard:{placeholder:"Envía un mensaje a Must-b...",thinking:"Must-b está pensando..."},layout:{chats:"Conversaciones",system:"Sistema",openChats:"Abrir historial de conversaciones",openSystem:"Abrir panel del sistema",closePanel:"Cerrar panel"},chat:{inputPlaceholder:"Pregunta cualquier cosa a Must-b…",listening:"Escuchando…",thoughtProcess:"Proceso de pensamiento",saveAsSkill:"Guardar como habilidad",skillSaved:"¡Habilidad guardada en tu biblioteca!",saving:"Guardando…",retry:"Reintentar",save:"Guardar",guidance:"Orientación",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"Canales"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"Conversación",files:"Archivos",browser:"Navegador",skills:"Habilidades",memory:"Memoria",plugins:"Plugins",workflows:"Flujos de trabajo",settings:"Configuración",system:"Sistema",close:"Cerrar",cat_webTools:"Herramientas web",cat_fileMedia:"Archivos y medios",cat_aiAgents:"IA y agentes",cat_systemTools:"Herramientas del sistema",skill_webSearch:"Búsqueda web",skill_webFetch:"Recuperación web",skill_browserControl:"Control del navegador",skill_pdfReader:"Lector de PDF",skill_imageAnalysis:"Análisis de imagen",skill_imageGeneration:"Generación de imágenes",skill_tts:"Texto a voz",skill_spawnAgent:"Crear subagente",skill_agentSessions:"Sesiones de agentes",skill_canvas:"Lienzo",skill_git:"Operaciones Git",skill_gateway:"Puerta de enlace",skill_fileManager:"Gestor de archivos",skill_cron:"Planificador Cron",skill_messages:"Mensajes",desc_webSearch:"Búsqueda web en tiempo real (multi-proveedor)",desc_webFetch:"Obtener cualquier URL como texto limpio",desc_browserControl:"Automatización completa del navegador con Playwright",desc_pdfReader:"Extraer y analizar documentos PDF",desc_imageAnalysis:"Describir y analizar imágenes",desc_imageGeneration:"Crear imágenes generadas por IA",desc_tts:"Convertir texto en habla natural",desc_spawnAgent:"Iniciar una nueva sesión de agente autónomo",desc_agentSessions:"Listar y gestionar sesiones activas",desc_canvas:"Espacio de dibujo visual y pizarra",desc_git:"Commit, rama, diff, push/pull",desc_gateway:"Comunicación entre sistemas y A2A",desc_fileManager:"Leer, escribir y gestionar archivos",desc_cron:"Programar tareas recurrentes",desc_messages:"Enviar y recibir mensajes entre agentes",cat_knowledgeBase:"Base de conocimientos",cat_personalOrg:"Organización personal",mem_browse:"Explorar recuerdos",mem_search:"Buscar en memoria",mem_add:"Agregar recuerdo",mem_contacts:"Contactos",mem_calendar:"Calendario",desc_memBrowse:"Ver todas las entradas de conocimiento almacenadas",desc_memSearch:"Búsqueda semántica en tu base de conocimientos",desc_memAdd:"Almacenar nuevos hechos y conocimientos",desc_contacts:"Gestionar personas y organizaciones",desc_calendar:"Programar y gestionar eventos",cat_pluginManager:"Gestor de plugins",cat_developer:"Desarrollador",plug_marketplace:"Mercado",plug_installed:"Instalados",plug_mcp:"Servidores MCP",plug_bundleMcp:"Bundle MCP",plug_cliCmds:"Comandos CLI",desc_marketplace:"Descubrir plugins en ClawHub",desc_installed:"Gestionar y configurar plugins instalados",desc_mcp:"Integraciones del Protocolo de Contexto de Modelo",desc_bundleMcp:"Empaquetar y desplegar bundles de herramientas MCP",desc_cliCmds:"Registro de comandos slash personalizados",cat_automation:"Automatización",cat_advanced:"Avanzado",wf_automations:"Automatizaciones",wf_scheduled:"Tareas programadas",wf_commands:"Comandos",wf_nodes:"Flujo de nodos",wf_multiAgent:"Multi-Agente",desc_automations:"Crear y ejecutar flujos de trabajo automatizados",desc_scheduled:"Gestionar todos los programas cron",desc_commands:"Comandos slash personalizados",desc_nodes:"Pipelines visuales en grafo de nodos",desc_multiAgent:"Orquestar la colaboración entre agentes"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"Perspectivas de memoria",indexLabel:"Índice:",clearIndex:"Limpiar índice",searchPlaceholder:"Buscar en tu memoria…",searchHint:"Búsqueda por similitud semántica — presiona Enter o haz clic",emptyTitle:"Busca en tu memoria de IA",emptyNoResults:"No se encontraron recuerdos",emptyHint:"Escribe una frase para encontrar habilidades, conversaciones y archivos semánticamente similares.",emptyNoResultsHint:"Prueba una frase diferente o indexa más contenido usando los controles de arriba.",refreshStats:"Actualizar estadísticas",indexControls:"Controles de índice",vectors:"vectores",skills:"habilidades",files:"archivos",indexed:"Indexado",indexCleared:"Índice limpiado",opFailed:"Operación fallida",reqError:"Error de solicitud"},plugins:{title:"Arquitecto de plugins",newPlugin:"Nuevo plugin",buildTitle:"Crear nuevo plugin",namePlaceholder:"Nombre del plugin (ej. weather-monitor)",goalPlaceholder:"Objetivo (ej. consultar la API OpenWeather cada 5 min)",contextPlaceholder:"Contexto / notas opcionales",generatePlugin:"Generar plugin",emptyTitle:"No hay plugins instalados",emptyHint:"Haz clic en «Nuevo plugin» para generar tu primer plugin.",installed:"instalado",running:"EN EJECUCIÓN",stop:"Detener",run:"Ejecutar",opFailed:"Operación fallida",reqError:"Error de solicitud",buildFailed:"Error de compilación",refresh:"Actualizar"},skills:{title:"Biblioteca de habilidades",loading:"Cargando habilidades…",emptyTitle:"No hay habilidades guardadas aún",emptyHint:"Completa un flujo de trabajo en la pestaña Conversación, luego haz clic en",saveAsSkill:"Guardar como habilidad",emptyHint2:"para construir tu biblioteca.",runningStatus:"Ejecutando habilidad…",completedStatus:"Habilidad completada",failedStatus:"Fallo en la ejecución",never:"Nunca",deleteConfirm:"¿Eliminar?",yes:"Sí",no:"No",runBtn:"Ejecutar",runningBtn:"Ejecutando…",doneBtn:"Listo",lastRun:"última ejecución"},settings:{title:"Configuración",hardwareScore:"Puntuación de hardware",searchPlaceholder:"Buscar proveedores…",allProviders:"Todos",apiKey:"Clave API",baseUrl:"URL base",model:"Modelo",testConnection:"Probar conexión",save:"Guardar",testOk:"Conexión exitosa",testFail:"Conexión fallida",saved:"Guardado",saving:"Guardando…",testing:"Probando…",apiKeyWarning:"Clave API requerida — actualiza tu clave para continuar."}}},sC={welcome:{tagline:"あなたのAIブレイン",title:"Must-b",sleeping:"スリープ中...",waking:"起動中...",awake:"覚醒中...",wakeBtn:"Must-bを起動",wakeHint:"タップして続行",reconfigure:"再設定",footer:"© 2026 Must-b — Auto Step Platform"},sidebar:{newChat:"新しいチャット",recentChats:"最近のチャット",platform:"プラットフォーム",system:"システム",automations:"マイオートメーション",activeWorkflows:"アクティブなワークフロー",products:"スキル & プラグイン",clients:"クライアント管理",integrations:"インテグレーション",logs:"ログ・アクティビティ",settings:"設定",logout:"ログアウト",poweredBy:"提供:",deleteChat:"チャットを削除しますか?",deleteConfirm:"この操作は元に戻せません。",cancel:"キャンセル",delete:"削除"},rightPanel:{agentRole:"エージェントの役割",hardware:"ハードウェアスコア",model:"アクティブモデル",connected:"ゲートウェイ接続済み",rank:{master:"マスター",planner:"プランナー",worker:"ワーカー"}},workflow:{title:"アクティブなワークフロー",idle:"待機中 — タスクを待っています",goal:"目標",steps:{browse:"ブラウザを開いています",write:"ファイルを書き込んでいます",think:"考えています",exec:"コマンドを実行しています"}},dashboard:{placeholder:"Must-bにメッセージを送信...",thinking:"Must-bが考えています..."},layout:{chats:"チャット",system:"システム",openChats:"チャット履歴を開く",openSystem:"システムパネルを開く",closePanel:"パネルを閉じる"},chat:{inputPlaceholder:"Must-bに何でも聞いてください…",listening:"聞いています…",thoughtProcess:"思考プロセス",saveAsSkill:"スキルとして保存",skillSaved:"スキルがライブラリに保存されました!",saving:"保存中…",retry:"再試行",save:"保存",guidance:"ガイダンス",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"チャンネル"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"チャット",files:"ファイル",browser:"ブラウザ",skills:"スキル",memory:"メモリ",plugins:"プラグイン",workflows:"ワークフロー",settings:"設定",system:"システム",close:"閉じる",cat_webTools:"ウェブツール",cat_fileMedia:"ファイル・メディア",cat_aiAgents:"AI・エージェント",cat_systemTools:"システムツール",skill_webSearch:"ウェブ検索",skill_webFetch:"ウェブ取得",skill_browserControl:"ブラウザ制御",skill_pdfReader:"PDFリーダー",skill_imageAnalysis:"画像分析",skill_imageGeneration:"画像生成",skill_tts:"テキスト読み上げ",skill_spawnAgent:"サブエージェント作成",skill_agentSessions:"エージェントセッション",skill_canvas:"キャンバス",skill_git:"Git操作",skill_gateway:"ゲートウェイ",skill_fileManager:"ファイルマネージャー",skill_cron:"Cronスケジューラー",skill_messages:"メッセージ",desc_webSearch:"リアルタイムウェブ検索(マルチプロバイダー)",desc_webFetch:"任意のURLをクリーンなテキストとして取得",desc_browserControl:"Playwrightによる完全なブラウザ自動化",desc_pdfReader:"PDFドキュメントの抽出と分析",desc_imageAnalysis:"画像の説明と分析",desc_imageGeneration:"AI生成画像の作成",desc_tts:"テキストを自然な音声に変換",desc_spawnAgent:"新しい自律エージェントセッションを起動",desc_agentSessions:"アクティブセッションの一覧と管理",desc_canvas:"ビジュアル描画・ホワイトボードワークスペース",desc_git:"コミット、ブランチ、差分、プッシュ/プル",desc_gateway:"システム間・A2A通信",desc_fileManager:"ファイルの読み取り、書き込み、管理",desc_cron:"定期タスクのスケジュール",desc_messages:"エージェント間メッセージの送受信",cat_knowledgeBase:"ナレッジベース",cat_personalOrg:"個人管理",mem_browse:"メモリを閲覧",mem_search:"メモリを検索",mem_add:"メモリを追加",mem_contacts:"連絡先",mem_calendar:"カレンダー",desc_memBrowse:"保存されたすべての知識エントリを表示",desc_memSearch:"ナレッジベース全体のセマンティック検索",desc_memAdd:"新しい事実と知識を保存",desc_contacts:"人物と組織の管理",desc_calendar:"イベントのスケジュールと管理",cat_pluginManager:"プラグインマネージャー",cat_developer:"開発者",plug_marketplace:"マーケットプレイス",plug_installed:"インストール済み",plug_mcp:"MCPサーバー",plug_bundleMcp:"MCPバンドル",plug_cliCmds:"CLIコマンド",desc_marketplace:"ClawHubでプラグインを探す",desc_installed:"インストール済みプラグインの管理と設定",desc_mcp:"モデルコンテキストプロトコル統合",desc_bundleMcp:"MCPツールバンドルのパッケージ化とデプロイ",desc_cliCmds:"カスタムスラッシュコマンドの登録",cat_automation:"自動化",cat_advanced:"高度な設定",wf_automations:"自動化",wf_scheduled:"スケジュールタスク",wf_commands:"コマンド",wf_nodes:"ノードワークフロー",wf_multiAgent:"マルチエージェント",desc_automations:"自動化されたワークフローの構築と実行",desc_scheduled:"すべてのCronスケジュールを管理",desc_commands:"カスタムスラッシュコマンド",desc_nodes:"ビジュアルノードグラフパイプライン",desc_multiAgent:"エージェント間の協調をオーケストレーション"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"メモリインサイト",indexLabel:"インデックス:",clearIndex:"インデックスをクリア",searchPlaceholder:"メモリを検索…",searchHint:"セマンティック類似性検索 — Enterキーを押すかクリック",emptyTitle:"AIメモリを検索",emptyNoResults:"メモリが見つかりません",emptyHint:"フレーズを入力して、意味的に類似したスキル、会話、ワークスペースファイルを見つけてください。",emptyNoResultsHint:"別のフレーズを試すか、上のコントロールを使ってより多くのコンテンツをインデックスしてください。",refreshStats:"統計を更新",indexControls:"インデックスコントロール",vectors:"ベクター",skills:"スキル",files:"ファイル",indexed:"インデックス済み",indexCleared:"インデックスをクリアしました",opFailed:"操作に失敗しました",reqError:"リクエストエラー"},plugins:{title:"プラグインアーキテクト",newPlugin:"新しいプラグイン",buildTitle:"新しいプラグインを作成",namePlaceholder:"プラグイン名(例:weather-monitor)",goalPlaceholder:"目標(例:5分ごとにOpenWeather APIをポーリング)",contextPlaceholder:"オプションのコンテキスト / メモ",generatePlugin:"プラグインを生成",emptyTitle:"プラグインがインストールされていません",emptyHint:"「新しいプラグイン」をクリックして最初のプラグインを生成してください。",installed:"インストール済み",running:"実行中",stop:"停止",run:"実行",opFailed:"操作に失敗しました",reqError:"リクエストエラー",buildFailed:"ビルド失敗",refresh:"更新"},skills:{title:"スキルライブラリ",loading:"スキルを読み込んでいます…",emptyTitle:"スキルがまだ保存されていません",emptyHint:"チャットタブでワークフローを完了したら、クリック",saveAsSkill:"スキルとして保存",emptyHint2:"してライブラリを構築してください。",runningStatus:"スキルを実行中…",completedStatus:"スキル完了",failedStatus:"スキルの実行に失敗しました",never:"なし",deleteConfirm:"削除しますか?",yes:"はい",no:"いいえ",runBtn:"実行",runningBtn:"実行中…",doneBtn:"完了",lastRun:"最終実行"},settings:{title:"設定",hardwareScore:"ハードウェアスコア",searchPlaceholder:"プロバイダーを検索…",allProviders:"すべて",apiKey:"APIキー",baseUrl:"ベースURL",model:"モデル",testConnection:"接続をテスト",save:"保存",testOk:"接続成功",testFail:"接続失敗",saved:"保存済み",saving:"保存中…",testing:"テスト中…",apiKeyWarning:"APIキーが必要です — 続行するにはキーを更新してください。"}}},rC={welcome:{tagline:"您的AI大脑",title:"Must-b",sleeping:"休眠中...",waking:"唤醒中...",awake:"正在觉醒...",wakeBtn:"唤醒 Must-b",wakeHint:"点击继续",reconfigure:"重新配置",footer:"© 2026 Must-b — Auto Step 平台"},sidebar:{newChat:"新建对话",recentChats:"最近对话",platform:"平台",system:"系统",automations:"我的自动化",activeWorkflows:"活跃工作流",products:"技能与插件",clients:"客户管理",integrations:"集成",logs:"日志与活动",settings:"设置",logout:"退出登录",poweredBy:"技术支持:",deleteChat:"删除对话?",deleteConfirm:"此操作无法撤销。",cancel:"取消",delete:"删除"},rightPanel:{agentRole:"代理角色",hardware:"硬件评分",model:"活跃模型",connected:"网关已连接",rank:{master:"主控",planner:"规划者",worker:"执行者"}},workflow:{title:"活跃工作流",idle:"空闲中 — 等待任务",goal:"目标",steps:{browse:"正在打开浏览器",write:"正在写入文件",think:"正在思考",exec:"正在执行命令"}},dashboard:{placeholder:"向 Must-b 发送消息...",thinking:"Must-b 正在思考..."},layout:{chats:"对话",system:"系统",openChats:"打开对话历史",openSystem:"打开系统面板",closePanel:"关闭面板"},chat:{inputPlaceholder:"向 Must-b 提问任何问题…",listening:"正在聆听…",thoughtProcess:"思考过程",saveAsSkill:"保存为技能",skillSaved:"技能已保存到您的库中!",saving:"保存中…",retry:"重试",save:"保存",guidance:"指导",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"频道"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"对话",files:"文件",browser:"浏览器",skills:"技能",memory:"记忆",plugins:"插件",workflows:"工作流",settings:"设置",system:"系统",close:"关闭",cat_webTools:"网络工具",cat_fileMedia:"文件与媒体",cat_aiAgents:"AI与代理",cat_systemTools:"系统工具",skill_webSearch:"网络搜索",skill_webFetch:"网络获取",skill_browserControl:"浏览器控制",skill_pdfReader:"PDF阅读器",skill_imageAnalysis:"图像分析",skill_imageGeneration:"图像生成",skill_tts:"文字转语音",skill_spawnAgent:"创建子代理",skill_agentSessions:"代理会话",skill_canvas:"画布",skill_git:"Git操作",skill_gateway:"网关",skill_fileManager:"文件管理器",skill_cron:"Cron调度器",skill_messages:"消息",desc_webSearch:"实时网络搜索(多供应商)",desc_webFetch:"将任意URL获取为纯文本",desc_browserControl:"完整的Playwright浏览器自动化",desc_pdfReader:"提取和分析PDF文档",desc_imageAnalysis:"描述和分析图像",desc_imageGeneration:"创建AI生成的图像",desc_tts:"将文本转换为自然语音",desc_spawnAgent:"启动新的自主代理会话",desc_agentSessions:"列出并管理活跃会话",desc_canvas:"可视化绘图与白板工作区",desc_git:"提交、分支、差异、推送/拉取",desc_gateway:"系统间与A2A通信",desc_fileManager:"读取、写入和管理文件",desc_cron:"调度定期任务",desc_messages:"发送和接收代理间消息",cat_knowledgeBase:"知识库",cat_personalOrg:"个人组织",mem_browse:"浏览记忆",mem_search:"搜索记忆",mem_add:"添加记忆",mem_contacts:"联系人",mem_calendar:"日历",desc_memBrowse:"查看所有存储的知识条目",desc_memSearch:"在知识库中进行语义搜索",desc_memAdd:"存储新的事实和知识",desc_contacts:"管理人员和组织",desc_calendar:"安排和管理事件",cat_pluginManager:"插件管理器",cat_developer:"开发者",plug_marketplace:"市场",plug_installed:"已安装",plug_mcp:"MCP服务器",plug_bundleMcp:"MCP捆绑包",plug_cliCmds:"CLI命令",desc_marketplace:"在ClawHub上发现插件",desc_installed:"管理和配置已安装的插件",desc_mcp:"模型上下文协议集成",desc_bundleMcp:"打包和部署MCP工具捆绑包",desc_cliCmds:"自定义斜杠命令注册",cat_automation:"自动化",cat_advanced:"高级",wf_automations:"自动化",wf_scheduled:"计划任务",wf_commands:"命令",wf_nodes:"节点工作流",wf_multiAgent:"多代理",desc_automations:"构建和运行自动化工作流",desc_scheduled:"管理所有Cron计划",desc_commands:"自定义斜杠命令",desc_nodes:"可视化节点图管道",desc_multiAgent:"协调代理间协作"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"记忆洞察",indexLabel:"索引:",clearIndex:"清除索引",searchPlaceholder:"搜索您的记忆…",searchHint:"语义相似性搜索 — 按回车键或点击",emptyTitle:"搜索您的AI记忆",emptyNoResults:"未找到记忆",emptyHint:"输入短语以查找语义相似的技能、对话和工作区文件。",emptyNoResultsHint:"尝试不同的短语,或使用上方控件索引更多内容。",refreshStats:"刷新统计",indexControls:"索引控件",vectors:"向量",skills:"技能",files:"文件",indexed:"已索引",indexCleared:"索引已清除",opFailed:"操作失败",reqError:"请求错误"},plugins:{title:"插件架构师",newPlugin:"新建插件",buildTitle:"创建新插件",namePlaceholder:"插件名称(例:weather-monitor)",goalPlaceholder:"目标(例:每5分钟轮询OpenWeather API)",contextPlaceholder:"可选上下文 / 备注",generatePlugin:"生成插件",emptyTitle:"未安装任何插件",emptyHint:"点击「新建插件」生成您的第一个插件。",installed:"已安装",running:"运行中",stop:"停止",run:"运行",opFailed:"操作失败",reqError:"请求错误",buildFailed:"构建失败",refresh:"刷新"},skills:{title:"技能库",loading:"正在加载技能…",emptyTitle:"尚未保存任何技能",emptyHint:"在对话标签中完成工作流,然后点击",saveAsSkill:"保存为技能",emptyHint2:"来构建您的技能库。",runningStatus:"正在运行技能…",completedStatus:"技能已完成",failedStatus:"技能运行失败",never:"从未",deleteConfirm:"删除?",yes:"是",no:"否",runBtn:"运行",runningBtn:"运行中…",doneBtn:"完成",lastRun:"上次运行"},settings:{title:"设置",hardwareScore:"硬件评分",searchPlaceholder:"搜索供应商…",allProviders:"全部",apiKey:"API密钥",baseUrl:"基础URL",model:"模型",testConnection:"测试连接",save:"保存",testOk:"连接成功",testFail:"连接失败",saved:"已保存",saving:"保存中…",testing:"测试中…",apiKeyWarning:"需要API密钥 — 请更新您的密钥以继续。"}}},aC={welcome:{tagline:"Seu cérebro de IA",title:"Must-b",sleeping:"Dormindo...",waking:"Acordando...",awake:"Despertando...",wakeBtn:"Acordar Must-b",wakeHint:"Toque para continuar",reconfigure:"Reconfigurar",footer:"© 2026 Must-b — Plataforma Auto Step"},sidebar:{newChat:"Nova conversa",recentChats:"Conversas recentes",platform:"Plataforma",system:"Sistema",automations:"Minhas automações",activeWorkflows:"Fluxos de trabalho ativos",products:"Skills & Plugins",clients:"Gestão de clientes",integrations:"Integrações",logs:"Registros e atividade",settings:"Configurações",logout:"Sair",poweredBy:"Desenvolvido por",deleteChat:"Excluir conversa?",deleteConfirm:"Esta ação não pode ser desfeita.",cancel:"Cancelar",delete:"Excluir"},rightPanel:{agentRole:"Função do agente",hardware:"Pontuação de hardware",model:"Modelo ativo",connected:"Gateway conectado",rank:{master:"Mestre",planner:"Planejador",worker:"Trabalhador"}},workflow:{title:"Fluxo de trabalho ativo",idle:"Ocioso — aguardando tarefa",goal:"Objetivo",steps:{browse:"Abrindo navegador",write:"Escrevendo arquivo",think:"Pensando",exec:"Executando comando"}},dashboard:{placeholder:"Envie uma mensagem para Must-b...",thinking:"Must-b está pensando..."},layout:{chats:"Conversas",system:"Sistema",openChats:"Abrir histórico de conversas",openSystem:"Abrir painel do sistema",closePanel:"Fechar painel"},chat:{inputPlaceholder:"Pergunte qualquer coisa ao Must-b…",listening:"Ouvindo…",thoughtProcess:"Processo de pensamento",saveAsSkill:"Salvar como habilidade",skillSaved:"Habilidade salva na sua biblioteca!",saving:"Salvando…",retry:"Tentar novamente",save:"Salvar",guidance:"Orientação",errorBoundary:"Chat rendering error — reloading…",disclaimer:"Must-b is a cognitive assistant; verify critical outputs for accuracy.",placeholder:"What do you want to know?",tools:"Tools",attachFile:"Attach file",startDictation:"Start voice dictation",stopDictation:"Stop dictation"},nav:{chat:"Chat",browser:"Browser",workflows:"Workflows",voice:"Voice",settings:"Settings",files:"Files",memory:"Memory",apiKeys:"API Keys",channels:"Canais"},voice:{title:"Must-b Voice Command",back:"Go Back",wakeHint:'Say "Hey Must-b" to get started.',tapHint:"Tap the microphone to begin.",heard:"I hear you…",listening:"Listening…",stopHint:"Click to stop",thinking:"Processing…",cmdHint:"Go ahead, I am listening…",speakingHint:"Must-b is speaking…"},dock:{chat:"Conversa",files:"Arquivos",browser:"Navegador",skills:"Habilidades",memory:"Memória",plugins:"Plugins",workflows:"Fluxos de trabalho",settings:"Configurações",system:"Sistema",close:"Fechar",cat_webTools:"Ferramentas web",cat_fileMedia:"Arquivos e mídia",cat_aiAgents:"IA e agentes",cat_systemTools:"Ferramentas do sistema",skill_webSearch:"Pesquisa web",skill_webFetch:"Busca web",skill_browserControl:"Controle do navegador",skill_pdfReader:"Leitor de PDF",skill_imageAnalysis:"Análise de imagem",skill_imageGeneration:"Geração de imagens",skill_tts:"Texto para fala",skill_spawnAgent:"Criar subagente",skill_agentSessions:"Sessões de agentes",skill_canvas:"Canvas",skill_git:"Operações Git",skill_gateway:"Gateway",skill_fileManager:"Gerenciador de arquivos",skill_cron:"Agendador Cron",skill_messages:"Mensagens",desc_webSearch:"Pesquisa web em tempo real (multi-provedor)",desc_webFetch:"Buscar qualquer URL como texto limpo",desc_browserControl:"Automação completa do navegador com Playwright",desc_pdfReader:"Extrair e analisar documentos PDF",desc_imageAnalysis:"Descrever e analisar imagens",desc_imageGeneration:"Criar imagens geradas por IA",desc_tts:"Converter texto em fala natural",desc_spawnAgent:"Iniciar uma nova sessão de agente autônomo",desc_agentSessions:"Listar e gerenciar sessões ativas",desc_canvas:"Espaço de desenho visual e quadro branco",desc_git:"Commit, branch, diff, push/pull",desc_gateway:"Comunicação entre sistemas e A2A",desc_fileManager:"Ler, escrever e gerenciar arquivos",desc_cron:"Agendar tarefas recorrentes",desc_messages:"Enviar e receber mensagens entre agentes",cat_knowledgeBase:"Base de conhecimento",cat_personalOrg:"Organização pessoal",mem_browse:"Explorar memórias",mem_search:"Pesquisar memória",mem_add:"Adicionar memória",mem_contacts:"Contatos",mem_calendar:"Calendário",desc_memBrowse:"Ver todas as entradas de conhecimento armazenadas",desc_memSearch:"Pesquisa semântica na sua base de conhecimento",desc_memAdd:"Armazenar novos fatos e conhecimentos",desc_contacts:"Gerenciar pessoas e organizações",desc_calendar:"Agendar e gerenciar eventos",cat_pluginManager:"Gerenciador de plugins",cat_developer:"Desenvolvedor",plug_marketplace:"Marketplace",plug_installed:"Instalados",plug_mcp:"Servidores MCP",plug_bundleMcp:"Bundle MCP",plug_cliCmds:"Comandos CLI",desc_marketplace:"Descobrir plugins no ClawHub",desc_installed:"Gerenciar e configurar plugins instalados",desc_mcp:"Integrações do Protocolo de Contexto de Modelo",desc_bundleMcp:"Empacotar e implantar bundles de ferramentas MCP",desc_cliCmds:"Registro de comandos slash personalizados",cat_automation:"Automação",cat_advanced:"Avançado",wf_automations:"Automações",wf_scheduled:"Tarefas agendadas",wf_commands:"Comandos",wf_nodes:"Fluxo de nós",wf_multiAgent:"Multi-Agente",desc_automations:"Criar e executar fluxos de trabalho automatizados",desc_scheduled:"Gerenciar todos os agendamentos cron",desc_commands:"Comandos slash personalizados",desc_nodes:"Pipelines visuais em grafo de nós",desc_multiAgent:"Orquestrar colaboração entre agentes"},systemHealth:{lite:"LITE",safe:"SAFE",critical:"Critical",warning:"Warning",info:"Info",title:"System Health",kinds:{cpu:"CPU",ram:"RAM",memory:"Memory",storage:"Storage",network:"Network",process:"Process",battery:"Battery",thermal:"Thermal",disk:"Disk"},moreModels:"More Models / API Settings"},panels:{memory:{title:"Insights de memória",indexLabel:"Índice:",clearIndex:"Limpar índice",searchPlaceholder:"Pesquisar na sua memória…",searchHint:"Pesquisa por similaridade semântica — pressione Enter ou clique",emptyTitle:"Pesquise na sua memória de IA",emptyNoResults:"Nenhuma memória encontrada",emptyHint:"Digite uma frase para encontrar habilidades, conversas e arquivos semanticamente similares.",emptyNoResultsHint:"Tente uma frase diferente ou indexe mais conteúdo usando os controles acima.",refreshStats:"Atualizar estatísticas",indexControls:"Controles de índice",vectors:"vetores",skills:"habilidades",files:"arquivos",indexed:"Indexado",indexCleared:"Índice limpo",opFailed:"Operação falhou",reqError:"Erro de requisição"},plugins:{title:"Arquiteto de plugins",newPlugin:"Novo plugin",buildTitle:"Criar novo plugin",namePlaceholder:"Nome do plugin (ex.: weather-monitor)",goalPlaceholder:"Objetivo (ex.: consultar a API OpenWeather a cada 5 min)",contextPlaceholder:"Contexto / notas opcionais",generatePlugin:"Gerar plugin",emptyTitle:"Nenhum plugin instalado",emptyHint:"Clique em «Novo plugin» para gerar seu primeiro plugin.",installed:"instalado",running:"EM EXECUÇÃO",stop:"Parar",run:"Executar",opFailed:"Operação falhou",reqError:"Erro de requisição",buildFailed:"Falha na compilação",refresh:"Atualizar"},skills:{title:"Biblioteca de habilidades",loading:"Carregando habilidades…",emptyTitle:"Nenhuma habilidade salva ainda",emptyHint:"Conclua um fluxo de trabalho na aba Conversa, depois clique em",saveAsSkill:"Salvar como habilidade",emptyHint2:"para construir sua biblioteca.",runningStatus:"Executando habilidade…",completedStatus:"Habilidade concluída",failedStatus:"Falha na execução",never:"Nunca",deleteConfirm:"Excluir?",yes:"Sim",no:"Não",runBtn:"Executar",runningBtn:"Executando…",doneBtn:"Concluído",lastRun:"última execução"},settings:{title:"Configurações",hardwareScore:"Pontuação de hardware",searchPlaceholder:"Pesquisar provedores…",allProviders:"Todos",apiKey:"Chave API",baseUrl:"URL base",model:"Modelo",testConnection:"Testar conexão",save:"Salvar",testOk:"Conexão bem-sucedida",testFail:"Falha na conexão",saved:"Salvo",saving:"Salvando…",testing:"Testando…",apiKeyWarning:"Chave API necessária — atualize sua chave para continuar."}}},Oc={en:vv,tr:Z3,de:eC,fr:tC,es:nC,ja:sC,zh:rC,pt:aC},bv=u.createContext({locale:"en",t:vv,setLocale:()=>{}});function iC({children:e}){const t=typeof localStorage<"u"?localStorage.getItem("mustb-lang"):null,[n,r]=u.useState(t&&t in Oc?t:"en"),a=i=>{r(i);try{localStorage.setItem("mustb-lang",i)}catch{}fetch("/api/settings/language",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({language:i})}).catch(()=>{})};return u.useEffect(()=>{fetch("/api/setup/status").then(i=>i.ok?i.json():null).then(i=>{if(!(i!=null&&i.activeLanguage))return;const o=i.activeLanguage;if(o in Oc&&o!==n){r(o);try{localStorage.setItem("mustb-lang",o)}catch{}}}).catch(()=>{})},[]),s.jsx(bv.Provider,{value:{locale:n,t:Oc[n],setLocale:a},children:e})}const yt=()=>u.useContext(bv);function d0(){const e=gt(),{t}=yt(),[n,r]=u.useState("sleeping"),a=async()=>{if(n==="sleeping"){r("exiting");try{const i=await fetch("/api/setup/status");if(i.ok&&!(await i.json()).configured){e("/setup",{replace:!0});return}await fetch("/api/auth/local").catch(()=>{})}catch{}setTimeout(()=>e("/app/chat",{replace:!0}),450)}};return s.jsxs("div",{className:"relative min-h-screen overflow-hidden flex flex-col",children:[s.jsx(ae,{children:n==="sleeping"&&s.jsxs(V.div,{className:"fixed inset-0 z-40 flex flex-col items-center justify-center",initial:{opacity:1},exit:{opacity:0,filter:"blur(24px)"},transition:{duration:.65,ease:"easeInOut"},children:[s.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat",style:{backgroundImage:"url(/avatar/sleep.png)"}}),s.jsx("div",{className:"absolute inset-0 bg-black/55"}),s.jsxs("div",{className:"relative z-10 flex flex-col items-center gap-8 px-6",children:[s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(V.div,{animate:{opacity:[.5,1,.5]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:s.jsx(Si,{size:20,className:"text-orange-400/70"})}),s.jsx("span",{className:"text-white/30 text-sm font-semibold tracking-widest uppercase select-none",children:"Must-b"})]}),s.jsxs(V.button,{onClick:a,disabled:n==="exiting",className:`group relative flex items-center gap-3 px-8 py-4 rounded-2xl
|
|
737
737
|
bg-orange-500/15 border border-orange-500/35 text-orange-300
|
|
738
738
|
backdrop-blur-md hover:bg-orange-500/25 hover:border-orange-500/60
|
|
739
|
-
transition-all duration-300 disabled:opacity-50 select-none`,animate:{y:[0,-6,0]},transition:{duration:4,repeat:1/0,ease:"easeInOut"},whileHover:{scale:1.04},whileTap:{scale:.97},children:[s.jsx("span",{className:"text-[15px] font-bold tracking-wider",children:t.welcome.wakeBtn}),s.jsx("div",{className:"w-8 h-8 rounded-full bg-orange-500/20 border border-orange-500/40 flex items-center justify-center",children:s.jsx(u3,{size:14,className:"text-orange-400"})})]}),s.jsx("p",{className:"text-white/20 text-[11px] tracking-widest uppercase select-none",children:t.welcome.wakeHint})]})]},"sleep-screen")}),s.jsx(ae,{children:n==="exiting"&&s.jsx(V.div,{className:"fixed inset-0 z-50 pointer-events-none",style:{background:"linear-gradient(180deg, #1a0802 0%, #f97316 40%, #0d0602 100%)"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.45}})})]})}function wv(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=wv(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ht(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=wv(e))&&(r&&(r+=" "),r+=t);return r}const xn=Object.create(null);xn.open="0";xn.close="1";xn.ping="2";xn.pong="3";xn.message="4";xn.upgrade="5";xn.noop="6";const _o=Object.create(null);Object.keys(xn).forEach(e=>{_o[xn[e]]=e});const fu={type:"error",data:"parser error"},kv=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",jv=typeof ArrayBuffer=="function",Nv=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,hp=({type:e,data:t},n,r)=>kv&&t instanceof Blob?n?r(t):u0(t,r):jv&&(t instanceof ArrayBuffer||Nv(t))?n?r(t):u0(new Blob([t]),r):r(xn[e]+(t||"")),u0=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function h0(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Ic;function oC(e,t){if(kv&&e.data instanceof Blob)return e.data.arrayBuffer().then(h0).then(t);if(jv&&(e.data instanceof ArrayBuffer||Nv(e.data)))return t(h0(e.data));hp(e,!1,n=>{Ic||(Ic=new TextEncoder),t(Ic.encode(n))})}const p0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ja=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<p0.length;e++)ja[p0.charCodeAt(e)]=e;const lC=e=>{let t=e.length*.75,n=e.length,r,a=0,i,o,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const d=new ArrayBuffer(t),h=new Uint8Array(d);for(r=0;r<n;r+=4)i=ja[e.charCodeAt(r)],o=ja[e.charCodeAt(r+1)],l=ja[e.charCodeAt(r+2)],c=ja[e.charCodeAt(r+3)],h[a++]=i<<2|o>>4,h[a++]=(o&15)<<4|l>>2,h[a++]=(l&3)<<6|c&63;return d},cC=typeof ArrayBuffer=="function",pp=(e,t)=>{if(typeof e!="string")return{type:"message",data:Sv(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:dC(e.substring(1),t)}:_o[n]?e.length>1?{type:_o[n],data:e.substring(1)}:{type:_o[n]}:fu},dC=(e,t)=>{if(cC){const n=lC(e);return Sv(n,t)}else return{base64:!0,data:e}},Sv=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Cv="",uC=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{hp(i,!1,l=>{r[o]=l,++a===n&&t(r.join(Cv))})})},hC=(e,t)=>{const n=e.split(Cv),r=[];for(let a=0;a<n.length;a++){const i=pp(n[a],t);if(r.push(i),i.type==="error")break}return r};function pC(){return new TransformStream({transform(e,t){oC(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let Dc;function eo(e){return e.reduce((t,n)=>t+n.length,0)}function to(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function fC(e,t){Dc||(Dc=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,l){for(n.push(o);;){if(r===0){if(eo(n)<1)break;const c=to(n,1);i=(c[0]&128)===128,a=c[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(eo(n)<2)break;const c=to(n,2);a=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(eo(n)<8)break;const c=to(n,8),d=new DataView(c.buffer,c.byteOffset,c.length),h=d.getUint32(0);if(h>Math.pow(2,21)-1){l.enqueue(fu);break}a=h*Math.pow(2,32)+d.getUint32(4),r=3}else{if(eo(n)<a)break;const c=to(n,a);l.enqueue(pp(i?c:Dc.decode(c),t)),r=0}if(a===0||a>e){l.enqueue(fu);break}}}})}const Ev=4;function Be(e){if(e)return mC(e)}function mC(e){for(var t in Be.prototype)e[t]=Be.prototype[t];return e}Be.prototype.on=Be.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Be.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Be.prototype.off=Be.prototype.removeListener=Be.prototype.removeAllListeners=Be.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Be.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};Be.prototype.emitReserved=Be.prototype.emit;Be.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Be.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Vl=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),zt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),xC="arraybuffer";function _v(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const gC=zt.setTimeout,yC=zt.clearTimeout;function Ul(e,t){t.useNativeTimers?(e.setTimeoutFn=gC.bind(zt),e.clearTimeoutFn=yC.bind(zt)):(e.setTimeoutFn=zt.setTimeout.bind(zt),e.clearTimeoutFn=zt.clearTimeout.bind(zt))}const vC=1.33;function bC(e){return typeof e=="string"?wC(e):Math.ceil((e.byteLength||e.size)*vC)}function wC(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Tv(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function kC(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function jC(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class NC extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class fp extends Be{constructor(t){super(),this.writable=!1,Ul(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new NC(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=pp(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=kC(t);return n.length?"?"+n:""}}class SC extends fp{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};hC(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,uC(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Tv()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Pv=!1;try{Pv=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const CC=Pv;function EC(){}class _C extends SC{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class pn extends Be{constructor(t,n,r){super(),this.createRequest=t,Ul(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=_v(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=pn.requestsCount++,pn.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=EC,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete pn.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}pn.requestsCount=0;pn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",f0);else if(typeof addEventListener=="function"){const e="onpagehide"in zt?"pagehide":"unload";addEventListener(e,f0,!1)}}function f0(){for(let e in pn.requests)pn.requests.hasOwnProperty(e)&&pn.requests[e].abort()}const TC=function(){const e=Av({xdomain:!1});return e&&e.responseType!==null}();class PC extends _C{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=TC&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new pn(Av,this.uri(),t)}}function Av(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||CC))return new XMLHttpRequest}catch{}if(!t)try{return new zt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mv=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class AC extends fp{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Mv?{}:_v(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;hp(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&Vl(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Tv()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Bc=zt.WebSocket||zt.MozWebSocket;class MC extends AC{createSocket(t,n,r){return Mv?new Bc(t,n,r):n?new Bc(t,n):new Bc(t)}doWrite(t,n){this.ws.send(n)}}class zC extends fp{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=fC(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=pC();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:l,value:c})=>{l||(this.onPacket(c),i())}).catch(l=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&Vl(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const RC={websocket:MC,webtransport:zC,polling:PC},LC=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,OC=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function mu(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=LC.exec(e||""),i={},o=14;for(;o--;)i[OC[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=IC(i,i.path),i.queryKey=DC(i,i.query),i}function IC(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function DC(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const xu=typeof addEventListener=="function"&&typeof removeEventListener=="function",To=[];xu&&addEventListener("offline",()=>{To.forEach(e=>e())},!1);class as extends Be{constructor(t,n){if(super(),this.binaryType=xC,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=mu(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=mu(n.host).host);Ul(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=jC(this.opts.query)),xu&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},To.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Ev,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&as.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",as.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=bC(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Vl(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(as.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xu&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=To.indexOf(this._offlineEventListener);r!==-1&&To.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}as.protocol=Ev;class BC extends as{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;as.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;as.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(h(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function i(){r||(r=!0,h(),n.close(),n=null)}const o=p=>{const f=new Error("probe error: "+p);f.transport=n.name,i(),this.emitReserved("upgradeError",f)};function l(){o("transport closed")}function c(){o("socket closed")}function d(p){n&&p.name!==n.name&&i()}const h=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",l),this.off("close",c),this.off("upgrading",d)};n.once("open",a),n.once("error",o),n.once("close",l),this.once("close",c),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let FC=class extends BC{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>RC[a]).filter(a=>!!a)),super(t,r)}};function $C(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=mu(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const VC=typeof ArrayBuffer=="function",UC=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,zv=Object.prototype.toString,HC=typeof Blob=="function"||typeof Blob<"u"&&zv.call(Blob)==="[object BlobConstructor]",WC=typeof File=="function"||typeof File<"u"&&zv.call(File)==="[object FileConstructor]";function mp(e){return VC&&(e instanceof ArrayBuffer||UC(e))||HC&&e instanceof Blob||WC&&e instanceof File}function Po(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Po(e[n]))return!0;return!1}if(mp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Po(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Po(e[n]))return!0;return!1}function KC(e){const t=[],n=e.data,r=e;return r.data=gu(n,t),r.attachments=t.length,{packet:r,buffers:t}}function gu(e,t){if(!e)return e;if(mp(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=gu(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=gu(e[r],t));return n}return e}function GC(e,t){return e.data=yu(e.data,t),delete e.attachments,e}function yu(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=yu(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=yu(e[n],t));return e}const qC=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var he;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(he||(he={}));class YC{constructor(t){this.replacer=t}encode(t){return(t.type===he.EVENT||t.type===he.ACK)&&Po(t)?this.encodeAsBinary({type:t.type===he.EVENT?he.BINARY_EVENT:he.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===he.BINARY_EVENT||t.type===he.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=KC(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class xp extends Be{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===he.BINARY_EVENT;r||n.type===he.BINARY_ACK?(n.type=r?he.EVENT:he.ACK,this.reconstructor=new XC(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(mp(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(he[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===he.BINARY_EVENT||r.type===he.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(xp.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case he.CONNECT:return m0(n);case he.DISCONNECT:return n===void 0;case he.CONNECT_ERROR:return typeof n=="string"||m0(n);case he.EVENT:case he.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&qC.indexOf(n[0])===-1);case he.ACK:case he.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class XC{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=GC(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function m0(e){return Object.prototype.toString.call(e)==="[object Object]"}const QC=Object.freeze(Object.defineProperty({__proto__:null,Decoder:xp,Encoder:YC,get PacketType(){return he}},Symbol.toStringTag,{value:"Module"}));function Gt(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const JC=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Rv extends Be{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Gt(t,"open",this.onopen.bind(this)),Gt(t,"packet",this.onpacket.bind(this)),Gt(t,"error",this.onerror.bind(this)),Gt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,i;if(JC.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:he.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const h=this.ids++,p=n.pop();this._registerAckCallback(h,p),o.id=h}const l=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!l||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},a),o=(...l)=>{this.io.clearTimeoutFn(i),n.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,a)=>{const i=(o,l)=>o?a(o):r(l);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:he.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case he.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case he.EVENT:case he.BINARY_EVENT:this.onevent(t);break;case he.ACK:case he.BINARY_ACK:this.onack(t);break;case he.DISCONNECT:this.ondisconnect();break;case he.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:he.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:he.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function sa(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}sa.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};sa.prototype.reset=function(){this.attempts=0};sa.prototype.setMin=function(e){this.ms=e};sa.prototype.setMax=function(e){this.max=e};sa.prototype.setJitter=function(e){this.jitter=e};class vu extends Be{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Ul(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new sa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||QC;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new FC(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Gt(n,"open",function(){r.onopen(),t&&t()}),i=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Gt(n,"error",i);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},l);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Gt(t,"ping",this.onping.bind(this)),Gt(t,"data",this.ondata.bind(this)),Gt(t,"error",this.onerror.bind(this)),Gt(t,"close",this.onclose.bind(this)),Gt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Vl(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Rv(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const fa={};function Ba(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=$C(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=fa[a]&&i in fa[a].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new vu(r,t):(fa[a]||(fa[a]=new vu(r,t)),c=fa[a]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Ba,{Manager:vu,Socket:Rv,io:Ba,connect:Ba});const ZC={};let js=null;function eE(){const e=ZC;if(e!=null&&e.VITE_BACKEND_URL)return e.VITE_BACKEND_URL.replace(/\/$/,"");const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||/^\d{1,3}(\.\d{1,3}){3}$/.test(t)?window.location.origin:"http://localhost:4309"}function pe(){return js||(js=Ba(eE(),{transports:["websocket","polling"],withCredentials:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,randomizationFactor:.3,timeout:1e4}),js.on("agentUpdate",e=>{try{e!=null&&window.dispatchEvent(new CustomEvent("mustb:agentUpdate",{detail:e}))}catch{}}),js.on("connect",()=>{window.dispatchEvent(new CustomEvent("mustb:connected"))}),js.on("disconnect",e=>{window.dispatchEvent(new CustomEvent("mustb:disconnected",{detail:{reason:e}}))}),js.io.on("reconnect",e=>{window.dispatchEvent(new CustomEvent("mustb:reconnected",{detail:{attemptNumber:e}}))})),js}const x0=[{value:"tr-TR",label:"Türkçe (TR)"},{value:"en-US",label:"English (US)"},{value:"de-DE",label:"Deutsch"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"}];function tE(){var M;gt();const[e,t]=u.useState(0),[n,r]=u.useState(""),[a,i]=u.useState("tr-TR"),[o,l]=u.useState("local"),[c,d]=u.useState("Pro"),[h,p]=u.useState(""),[f,m]=u.useState("idle"),[b,y]=u.useState(""),[v,x]=u.useState(0),[g,w]=u.useState(null),[j,k]=u.useState(!1),[S,C]=u.useState(null),[A,N]=u.useState(!1),[_,L]=u.useState(null);u.useEffect(()=>{const P=pe(),E=T=>{if(!T)return;const O=T.model||"",G=typeof T.percent=="number"?T.percent:0,D=T.status||"",K=T.error||"";O==="llama3.2"&&(x(G),m(D),y(D==="success"?"Yerel model başarıyla kuruldu ve çevrimdışı kullanım için hazır!":D==="error"?K||"Model indirme sırasında bir hata oluştu.":`İndiriliyor: %${G} - ${D}`))};return P.on("ollama_pull_progress",E),()=>{P.off("ollama_pull_progress",E)}},[]);const B=async()=>{var P;k(!0),C(null);try{const E=await fetch("/api/ollama/models");if(!E.ok){w(!1),C("Ollama kapalı.");return}const T=await E.json();w(!!(T!=null&&T.running)),(T==null?void 0:T.running)===!1&&C((P=T==null?void 0:T.error)!=null&&P.includes("ECONNREFUSED")?"Ollama kapalı.":(T==null?void 0:T.error)||"Ollama kapalı.")}catch{w(!1),C("Ollama kapalı.")}finally{k(!1)}};u.useEffect(()=>{e===2&&B()},[e]);const z=async()=>{if(f!=="pulling"){m("pulling"),x(0),y("İndirme talebi iletiliyor...");try{const P=await fetch("/api/ollama/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelName:"llama3.2"})});if(!P.ok){const E=await P.json().catch(()=>({}));throw new Error(E.error||"Ollama pull başlatılamadı.")}y("Yerel model indiriliyor (llama3.2)...")}catch(P){m("error"),y(P.message)}}},$=()=>e===0?n.trim().length>0:e===1&&(c==="free"||c==="Pro")?h.trim().length>0:!0,R=async()=>{N(!0),L(null);try{const P=c==="Local",E={name:n.trim()||"Kullanıcı",language:a,provider:P?"ollama":"openrouter",apiKey:P?"http://localhost:11434":h,model:P?"llama3.2":"meta-llama/llama-4-scout:free",skills:["browser","terminal","memory","web_search","filesystem","git","vision","input","telegram","analyzer"],mode:o,workspacePath:"",wakeWord:!1,telemetry:!1,plan:c},T=await fetch("/api/setup/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!T.ok){const O=await T.json().catch(()=>({}));throw new Error(O.error||"Kurulum kaydedilemedi.")}localStorage.setItem("mustb_setup_complete","1"),window.location.href="/app"}catch(P){L(P.message||"Bilinmeyen bir hata oluştu."),N(!1)}};return s.jsxs("div",{className:"min-h-screen bg-[#02040a] flex flex-col items-center justify-center px-4 py-12 relative overflow-hidden",children:[s.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[s.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[700px] h-[700px] bg-emerald-950/10 rounded-full blur-[140px]"}),s.jsx("div",{className:"absolute top-10 left-10 w-[300px] h-[300px] bg-cyan-950/10 rounded-full blur-[100px]"})]}),s.jsxs("div",{className:"relative z-10 w-full max-w-xl",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsx("div",{className:"relative w-14 h-14 rounded-full bg-gradient-to-tr from-emerald-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:s.jsx(mn,{size:24,className:"text-white"})})}),s.jsx("h1",{className:"text-3xl font-extrabold text-white tracking-tight",children:"Must-b Kurulum Sihirbazı"}),s.jsx("p",{className:"text-gray-400 mt-1.5 text-sm",children:"Proaktif Çevrimdışı Güvenlik Entegrasyonu"})]}),s.jsx("div",{className:"flex justify-center items-center gap-2 mb-8",children:[0,1,2,3].map(P=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:ht("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all duration-300",P<e?"bg-emerald-600 text-white":P===e?"bg-emerald-500/20 border-2 border-emerald-500 text-emerald-400 shadow-md shadow-emerald-500/10":"bg-white/5 border border-white/10 text-gray-500"),children:P<e?s.jsx(it,{size:14}):P+1}),s.jsx("span",{className:ht("text-xs font-semibold uppercase tracking-wider",P===e?"text-emerald-400":"text-gray-600"),children:P===0?"Mod & Kimlik":P===1?"Plan & API":P===2?"Yerel Zeka":"Tamamla"}),P<3&&s.jsx("div",{className:"w-8 h-px bg-white/10"})]},P))}),s.jsxs("div",{className:"bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-2xl p-6 shadow-2xl backdrop-blur-md relative",children:[s.jsxs("p",{className:"text-[10px] font-bold text-emerald-500/60 uppercase tracking-widest mb-1",children:["Adım ",e+1," / 4"]}),s.jsxs(ae,{mode:"wait",children:[e===0&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Mod ve Profil Tercihleri"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold flex items-center gap-1.5",children:[s.jsx(hi,{size:12})," İsminiz / Name"]}),s.jsx("input",{type:"text",value:n,onChange:P=>r(P.target.value),placeholder:"Örn: Burak",className:"w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:ring-1 focus:ring-emerald-500/50 transition-all text-base"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold flex items-center gap-1.5",children:[s.jsx(Ge,{size:12})," Dil Seçimi / Language"]}),s.jsx("select",{value:a,onChange:P=>i(P.target.value),className:"w-full bg-[#0d1117] border border-white/10 rounded-xl px-4 py-3 text-white focus:outline-none focus:ring-1 focus:ring-emerald-500/50 transition-all text-sm appearance-none cursor-pointer",children:x0.map(P=>s.jsx("option",{value:P.value,children:P.label},P.value))})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold",children:"Çalışma Modu Seçimi"}),s.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[s.jsxs("button",{onClick:()=>l("local"),className:ht("flex items-start gap-4 p-4 rounded-xl border transition-all text-left",o==="local"?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx(Mn,{size:20,className:"mt-1 flex-shrink-0 text-emerald-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-sm",children:"Terminal Asistanı (Local Mode)"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Hafif ve terminal ortamında çalışarak doğrudan komut satırı üzerinden asistanlık yapar."})]})]}),s.jsxs("button",{onClick:()=>l("world"),className:ht("flex items-start gap-4 p-4 rounded-xl border transition-all text-left",o==="world"?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx(dv,{size:20,className:"mt-1 flex-shrink-0 text-cyan-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-sm",children:"Must-b.os (World Mode)"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Gelişmiş görsel arayüz, entegrasyonlar ve çoklu platform desteği sunan tam işletim sistemi orkestrasyonu."})]})]})]})]})]},"step0"),e===1&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Plan & API Yetkilendirme"}),s.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{id:"free",title:"Free (BYOK)",desc:"Kendi anahtarınla ücretsiz kullan."},{id:"Pro",title:"Must-b Pro",desc:"Bulut destekli zeka motoru gücü."},{id:"Elite",title:"Must-b Elite",desc:"Bulut Zekası + Çevrimdışı Koruması."},{id:"Local",title:"Must-b Local",desc:"Tamamen internetsiz ve yerel."}].map(P=>s.jsxs("button",{onClick:()=>{d(P.id),P.id==="Local"&&p("")},className:ht("p-4 rounded-xl border transition-all text-left flex flex-col justify-between h-[100px]",c===P.id?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx("p",{className:"font-bold text-sm leading-tight text-white",children:P.title}),s.jsx("p",{className:"text-[11px] text-gray-400 mt-1.5 leading-relaxed",children:P.desc})]},P.id))}),(c==="free"||c==="Pro")&&s.jsxs("div",{className:"space-y-2 pt-2 border-t border-white/5",children:[s.jsx("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold",children:"OpenRouter veya OpenAI API Anahtarı"}),s.jsx("input",{type:"password",value:h,onChange:P=>p(P.target.value),placeholder:"sk-or-v1-...",className:"w-full bg-white/5 border border-white/10 rounded-xl px-4 py-2.5 text-white font-mono text-sm focus:outline-none focus:ring-1 focus:ring-emerald-500/50"}),s.jsx("p",{className:"text-gray-400 text-xs mt-1",children:"Girilen tüm anahtarlar yerelde şifreli olarak saklanır ve sunucularımıza gitmez."})]})]},"step1"),e===2&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Yerel Yapay Zeka Kurulumu"}),s.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:"Must-b.os, Elite ve Local planlarda tamamen çevrimdışı ve yerel çalışabilmek için **Ollama** entegrasyonunu destekler."}),j?s.jsxs("div",{className:"flex items-center justify-center gap-2.5 py-8 text-zinc-400",children:[s.jsx(ne,{size:18,className:"animate-spin text-emerald-400"}),s.jsx("span",{className:"text-sm font-medium",children:"Ollama durumu kontrol ediliyor..."})]}):g===!1?s.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-5 space-y-4 backdrop-blur-md shadow-lg shadow-red-500/5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ke,{size:20,className:"text-red-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h4",{className:"text-sm font-bold text-red-300",children:S||"Ollama kapalı."}),s.jsx("p",{className:"text-xs text-red-200/80 leading-relaxed",children:"Ollama servisi yanıt vermiyor. Arka planda çalıştığından emin olun."})]})]}),s.jsxs("div",{className:"text-xs text-zinc-400 space-y-2 pl-8",children:[s.jsx("p",{className:"font-semibold text-zinc-300",children:"Nasıl kurulur?"}),s.jsxs("ol",{className:"list-decimal pl-4 space-y-1 leading-relaxed",children:[s.jsxs("li",{children:[s.jsx("a",{href:"https://ollama.com",target:"_blank",rel:"noreferrer",className:"text-emerald-400 hover:underline",children:"https://ollama.com"})," adresinden Ollama'yı indirip kurun."]}),s.jsx("li",{children:"Kurulum tamamlandıktan sonra Ollama uygulamasını arka planda çalıştırın."}),s.jsx("li",{children:"Aşağıdaki butonla durumu tekrar kontrol edin."})]})]}),s.jsx("button",{type:"button",onClick:B,className:"w-full py-2.5 px-4 rounded-xl font-bold text-xs text-white bg-zinc-800 hover:bg-zinc-700 transition-all border border-zinc-700 active:scale-[0.98]",children:"Tekrar Kontrol Et"})]}):g===!0?s.jsxs("div",{className:"space-y-4 bg-zinc-900/40 rounded-xl p-5 border border-zinc-800",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(tn,{size:20,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-bold text-white",children:"Ollama Bağlantısı Hazır ✓"}),s.jsx("p",{className:"text-xs text-zinc-400",children:"Arka planda çalışan yerel Ollama servisiyle bağlantı kuruldu."})]})]}),s.jsxs("div",{className:"pt-2 border-t border-zinc-800 space-y-3",children:[s.jsxs("p",{className:"text-xs text-zinc-300 leading-relaxed",children:["Çevrimdışı/Yerel kullanım için önerilen hafif yapay zeka modelini (",s.jsx("strong",{children:"llama3.2"}),") indirebilirsiniz:"]}),s.jsxs("button",{type:"button",onClick:z,disabled:f==="pulling",className:"w-full flex items-center justify-center gap-2 py-3 px-4 rounded-xl font-bold text-sm text-white bg-gradient-to-r from-emerald-600 to-cyan-600 hover:from-emerald-500 hover:to-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all active:scale-[0.98] shadow-lg shadow-emerald-500/10",children:[f==="pulling"?s.jsx(ne,{size:16,className:"animate-spin"}):s.jsx(Os,{size:16}),s.jsx("span",{children:"llama3.2 İndir / Pull"})]}),f!=="idle"&&s.jsxs("div",{className:"space-y-2 pt-2",children:[f==="pulling"&&s.jsx("div",{className:"w-full bg-zinc-950 border border-zinc-800 rounded-full h-3 overflow-hidden relative shadow-inner",children:s.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-cyan-500 h-full rounded-full transition-all duration-300 relative shadow-[0_0_8px_rgba(16,185,129,0.3)]",style:{width:`${v}%`}})}),s.jsxs("div",{className:ht("rounded-xl px-4 py-3 text-xs flex items-start gap-2.5 border",f==="success"?"bg-emerald-500/10 border-emerald-500/20 text-emerald-400":f==="error"?"bg-red-500/10 border-red-500/20 text-red-400":"bg-zinc-950 border-zinc-800 text-zinc-300"),children:[f==="pulling"&&s.jsx(ne,{size:12,className:"animate-spin shrink-0 mt-0.5 text-emerald-400"}),f==="success"&&s.jsx("span",{className:"text-[12px] font-bold text-emerald-400",children:"✓"}),f==="error"&&s.jsx(Ke,{size:12,className:"shrink-0 mt-0.5 text-red-400"}),s.jsx("p",{className:"leading-relaxed font-medium",children:b})]})]})]})]}):s.jsx("div",{className:"bg-zinc-900/40 rounded-xl p-5 border border-zinc-800 text-center py-8",children:s.jsx("p",{className:"text-xs text-zinc-500 font-medium",children:"Durum sorgulanıyor..."})})]},"step2"),e===3&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Kurulumu Tamamla"}),s.jsxs("div",{className:"rounded-xl bg-white/3 border border-white/6 p-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mb-1",children:"Kurulum Özeti"}),[{label:"Kullanıcı Adı",value:n||"—"},{label:"Seçilen Dil",value:((M=x0.find(P=>P.value===a))==null?void 0:M.label)||a},{label:"Çalışma Modu",value:o==="world"?"Must-b.os (Visual)":"Terminal Asistanı (CLI)"},{label:"Üyelik Planı",value:c},{label:"Çevrimdışı Desteği",value:c==="Local"||c==="Elite"?"Aktif (llama3.2)":"Kısıtlı / Bulut Bağlantılı"}].map(P=>s.jsxs("div",{className:"flex items-center justify-between text-xs border-b border-white/5 pb-2 last:border-b-0 last:pb-0",children:[s.jsx("span",{className:"text-gray-400",children:P.label}),s.jsx("span",{className:"text-gray-200 font-semibold",children:P.value})]},P.label))]}),_&&s.jsxs("div",{className:"rounded-xl bg-red-500/10 border border-red-500/20 p-3 text-red-400 text-sm flex items-start gap-2",children:[s.jsx(Ke,{size:16,className:"flex-shrink-0 mt-0.5"}),s.jsx("span",{children:_})]}),s.jsx("button",{onClick:R,disabled:A,className:"w-full flex items-center justify-center gap-3 px-8 py-4 rounded-2xl bg-gradient-to-r from-emerald-600 to-cyan-600 hover:from-emerald-500 hover:to-cyan-500 text-white font-bold text-base transition-all shadow-lg shadow-emerald-500/20 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:A?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:20,className:"animate-spin"})," Kurulum Tamamlanıyor..."]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-lg",children:"🚀"})," Kurulumu Tamamla ve Başlat / Finalize Setup"]})})]},"step3")]}),s.jsxs("div",{className:"flex items-center justify-between mt-8 pt-4 border-t border-white/5",children:[s.jsxs("button",{onClick:()=>t(P=>P-1),disabled:e===0||A,className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed transition-all text-xs font-semibold",children:[s.jsx(x3,{size:14})," Geri / Back"]}),e<3&&s.jsxs("button",{onClick:()=>t(P=>P+1),disabled:!$()||A,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs transition-all active:scale-[0.97] disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10",children:["Devam Et / Continue ",s.jsx(gn,{size:14})]})]})]}),s.jsxs("p",{className:"text-center text-xs text-gray-700 mt-5",children:["Tüm verileriniz yerelde güvenle saklanır · Doğrulamak için ",s.jsx("code",{className:"text-emerald-500/60 font-mono",children:"must-b doctor"})," çalıştırabilirsiniz"]})]})]})}const nE={};let Na=null;const sE=(()=>{const e=nE,t=(e==null?void 0:e.VITE_BACKEND_URL)??"";return t&&!t.includes(window.location.hostname)?t.replace(/\/$/,""):""})();function Lv(e){return e.startsWith("http")?e:`${sE}${e}`}async function rE(){if(Na)return Na;try{const e=await fetch(Lv("/api/auth/local"));if(e.ok)return Na=(await e.json()).token??null,Na}catch{}return null}async function U(e,t={},{retries:n=3,retryDelay:r=800}={}){const a=await rE(),i={"Content-Type":"application/json",...t.headers};a&&(i.Authorization=`Bearer ${a}`);const o=Lv(e);let l;for(let c=1;c<=n;c++)try{const d=await fetch(o,{...t,headers:i});return d.status===401&&(Na=null,window.dispatchEvent(new CustomEvent("mustb:401",{detail:{url:o}}))),d}catch(d){l=d,c<n&&await new Promise(h=>setTimeout(h,r*c))}throw window.dispatchEvent(new CustomEvent("mustb:offline",{detail:{url:o}})),l}function g0(e){const t=e.toLowerCase();if(t.includes("gemini-2")||t.includes("gemini-flash"))return 9999;if(t.includes("llama-3")&&(t.includes("70b")||t.includes("405b")))return 9998;if(t.includes("gpt-4o"))return 8888;if(t.includes("claude-3-5")||t.includes("claude-3.5"))return 8887;if(t.includes("gemini-pro")||t.includes("gemini-1.5-pro"))return 8886;const n=t.match(/(\d+)x(\d+)b/);if(n)return parseFloat(n[1])*parseFloat(n[2]);const r=t.match(/(\d+(?:\.\d+)?)b/);return r?parseFloat(r[1]):0}function Fc(e){return[...e].sort((t,n)=>g0(n.id)-g0(t.id))}function aE(){const{t:e}=yt(),[t,n]=u.useState(!1),[r,a]=u.useState(()=>localStorage.getItem("mustb_active_model")??"Loading…"),[i,o]=u.useState([]),l=u.useRef(null);u.useEffect(()=>{const f=localStorage.getItem("mustb_active_model");f&&f!=="Loading…"&&U("/api/settings/model",{method:"POST",body:JSON.stringify({model:f})}).catch(()=>{}),U("/api/setup/status").then(m=>m.ok?m.json():null).then(m=>{if(!m)return;const b=localStorage.getItem("mustb_active_model");m.activeModel&&(!b||b==="Loading…")&&(a(m.activeModel),localStorage.setItem("mustb_active_model",m.activeModel)),(m.activeProvider??"openrouter").toLowerCase()==="ollama"?U("/api/models").then(v=>v.ok?v.json():[]).then(v=>{const g=(Array.isArray(v)?v:[]).map(w=>({id:w.id??String(w),name:w.name??w.id??String(w),free:!0}));o(Fc(g))}).catch(()=>{}):U("/api/providers/openrouter/models").then(v=>v.ok?v.json():{}).then(v=>{const x=Fc((v.free??[]).map(j=>({id:j.id,name:j.name??j.id,free:!0}))),g=Fc((v.power??[]).map(j=>({id:j.id,name:j.name??j.id,free:!1}))),w=[...x,...g];o(w),!(m!=null&&m.activeModel)&&w.length>0&&a(w[0].id)}).catch(()=>{})}).catch(()=>{})},[]),u.useEffect(()=>{if(!t)return;const f=m=>{l.current&&!l.current.contains(m.target)&&n(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[t]);const c=async f=>{a(f),localStorage.setItem("mustb_active_model",f),n(!1),await U("/api/settings/model",{method:"POST",body:JSON.stringify({model:f})}).catch(()=>{})},d=i.filter(f=>f.free),h=i.filter(f=>!f.free),p=r.length>28?r.slice(0,26)+"…":r;return s.jsxs("div",{ref:l,className:"relative",children:[s.jsxs("button",{onClick:()=>n(f=>!f),className:"flex items-center gap-1 px-2 py-1 rounded-lg border border-white/10 bg-white/5 hover:bg-white/10 text-white/50 hover:text-white/80 text-[11px] font-medium transition-all",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-500 shrink-0"}),s.jsx("span",{className:"truncate max-w-[110px]",children:p}),s.jsx(Xs,{size:10,className:`transition-transform duration-200 shrink-0 text-white/30 ${t?"rotate-180":""}`})]}),s.jsx(ae,{children:t&&s.jsxs(V.div,{initial:{opacity:0,y:6,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.97},transition:{duration:.14,ease:[.22,1,.36,1]},className:"absolute bottom-full mb-2 left-0 z-50 w-72 rounded-xl shadow-xl border border-white/10 flex flex-col",style:{background:"rgba(18,8,2,0.97)",backdropFilter:"blur(24px)",maxHeight:"400px"},children:[s.jsxs("div",{className:"overflow-y-auto flex-1 p-1.5",children:[d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2.5 pt-2 pb-1 text-[9.5px] font-black uppercase tracking-[0.12em] text-emerald-500/80",children:"Free"}),d.slice(0,5).map(f=>s.jsxs("button",{onClick:()=>c(f.id),className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-left transition-colors ${r===f.id?"bg-orange-500/15 text-orange-300":"text-white/60 hover:bg-white/5 hover:text-white/90"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r===f.id?"bg-orange-500":"bg-emerald-400"}`}),s.jsx("span",{className:"text-[12px] font-medium truncate",children:f.name}),r===f.id&&s.jsx("span",{className:"ml-auto text-[9px] font-semibold text-orange-400 shrink-0",children:"active"})]},f.id))]}),h.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2.5 pt-2 pb-1 text-[9.5px] font-black uppercase tracking-[0.12em] text-orange-400/80",children:"Pro"}),h.map(f=>s.jsxs("button",{onClick:()=>c(f.id),className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-left transition-colors ${r===f.id?"bg-orange-500/15 text-orange-300":"text-white/60 hover:bg-white/5 hover:text-white/90"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r===f.id?"bg-orange-500":"bg-orange-300"}`}),s.jsx("span",{className:"text-[12px] font-medium truncate",children:f.name}),r===f.id&&s.jsx("span",{className:"ml-auto text-[9px] font-semibold text-orange-400 shrink-0",children:"active"})]},f.id))]}),i.length===0&&s.jsx("div",{className:"px-3 py-4 text-[12px] text-white/30 text-center",children:"No models available"})]}),s.jsx("div",{className:"shrink-0 border-t border-white/8 p-1.5",children:s.jsxs(Ra,{to:"/app/settings",onClick:()=>n(!1),className:"flex items-center justify-center gap-1.5 w-full px-2.5 py-2 rounded-lg text-[11px] font-medium text-white/35 hover:text-orange-400 hover:bg-orange-500/8 transition-colors",children:[s.jsx(Ci,{size:11}),e.systemHealth.moreModels]})})]})})]})}function Yt(e){if(typeof e=="string")return e;if(e==null)return"";if(typeof e=="object"){const t=e,n=t.message??t.error??t.text??t.content??t.result;return n!==void 0?Yt(n):JSON.stringify(e)}return String(e)}function iE(e,t){switch(e){case"planGenerated":{const n=t.steps;return`Plan ready — ${(n==null?void 0:n.length)??0} step(s)`}case"stepStart":{const n=t.step;return`▶ ${(n==null?void 0:n.description)??Yt(t.step)}`}case"stepFinish":{if(t.status==="error")return`✗ ${Yt(t.error)}`;const n=t.step,r=t.result!==void 0?Yt(t.result):void 0,a=(n==null?void 0:n.description)??"Step complete";return r&&r.length<180?`✓ ${a} → ${r}`:`✓ ${a}`}case"agentRepair":{const n=Yt(t.action),r=t.reason?` — ${Yt(t.reason).slice(0,120)}`:"";return`⟳ Repair: ${n}${r}`}default:return null}}function oE(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function lE({lang:e,code:t}){const[n,r]=u.useState(!1);return s.jsxs("div",{className:"my-3 rounded-xl overflow-hidden border border-white/8 bg-[#1a0800]/90",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 border-b border-white/6 select-none",children:[s.jsx("span",{className:"text-[11px] font-mono text-orange-300/50",children:e||"code"}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t).catch(()=>{}),r(!0),setTimeout(()=>r(!1),2e3)},className:"flex items-center gap-1.5 text-[11px] text-orange-300/50 hover:text-orange-200 transition-colors",children:n?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:10,className:"text-orange-400"}),s.jsx("span",{className:"text-orange-400",children:"Copied"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Vs,{size:10}),"Copy"]})})]}),s.jsx("pre",{className:"overflow-x-auto px-4 py-3 text-[13px] text-orange-50 font-mono leading-relaxed whitespace-pre",children:s.jsx("code",{children:t})})]})}function ir(e,t){return e.split(/(`[^`\n]+`)/).map((r,a)=>{if(r.startsWith("`")&&r.endsWith("`")&&r.length>2)return s.jsx("code",{className:"px-1.5 py-0.5 rounded bg-black/15 text-orange-700 font-mono text-[12px]",children:r.slice(1,-1)},`${t}-ic${a}`);const i=r.split(/(\*\*[^*\n]+\*\*|\*[^*\n]+\*)/);return s.jsx(u.Fragment,{children:i.map((o,l)=>o.startsWith("**")&&o.endsWith("**")&&o.length>4?s.jsx("strong",{className:"font-bold text-inherit dark:text-gray-100",children:o.slice(2,-2)},`${t}-b${a}-${l}`):o.startsWith("*")&&o.endsWith("*")&&o.length>2?s.jsx("em",{className:"italic",children:o.slice(1,-1)},`${t}-em${a}-${l}`):s.jsx("span",{children:o},`${t}-s${a}-${l}`))},`${t}-bi${a}`)})}function cE({text:e,dark:t=!1}){const n=t?"text-orange-50":"text-[#3d1a06]",r=[],a=e.split(`
|
|
739
|
+
transition-all duration-300 disabled:opacity-50 select-none`,animate:{y:[0,-6,0]},transition:{duration:4,repeat:1/0,ease:"easeInOut"},whileHover:{scale:1.04},whileTap:{scale:.97},children:[s.jsx("span",{className:"text-[15px] font-bold tracking-wider",children:t.welcome.wakeBtn}),s.jsx("div",{className:"w-8 h-8 rounded-full bg-orange-500/20 border border-orange-500/40 flex items-center justify-center",children:s.jsx(u3,{size:14,className:"text-orange-400"})})]}),s.jsx("p",{className:"text-white/20 text-[11px] tracking-widest uppercase select-none",children:t.welcome.wakeHint})]})]},"sleep-screen")}),s.jsx(ae,{children:n==="exiting"&&s.jsx(V.div,{className:"fixed inset-0 z-50 pointer-events-none",style:{background:"linear-gradient(180deg, #1a0802 0%, #f97316 40%, #0d0602 100%)"},initial:{opacity:0},animate:{opacity:1},transition:{duration:.45}})})]})}function wv(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=wv(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function ht(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=wv(e))&&(r&&(r+=" "),r+=t);return r}const xn=Object.create(null);xn.open="0";xn.close="1";xn.ping="2";xn.pong="3";xn.message="4";xn.upgrade="5";xn.noop="6";const _o=Object.create(null);Object.keys(xn).forEach(e=>{_o[xn[e]]=e});const fu={type:"error",data:"parser error"},kv=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",jv=typeof ArrayBuffer=="function",Nv=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,hp=({type:e,data:t},n,r)=>kv&&t instanceof Blob?n?r(t):u0(t,r):jv&&(t instanceof ArrayBuffer||Nv(t))?n?r(t):u0(new Blob([t]),r):r(xn[e]+(t||"")),u0=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function h0(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Ic;function oC(e,t){if(kv&&e.data instanceof Blob)return e.data.arrayBuffer().then(h0).then(t);if(jv&&(e.data instanceof ArrayBuffer||Nv(e.data)))return t(h0(e.data));hp(e,!1,n=>{Ic||(Ic=new TextEncoder),t(Ic.encode(n))})}const p0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ja=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<p0.length;e++)ja[p0.charCodeAt(e)]=e;const lC=e=>{let t=e.length*.75,n=e.length,r,a=0,i,o,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const d=new ArrayBuffer(t),h=new Uint8Array(d);for(r=0;r<n;r+=4)i=ja[e.charCodeAt(r)],o=ja[e.charCodeAt(r+1)],l=ja[e.charCodeAt(r+2)],c=ja[e.charCodeAt(r+3)],h[a++]=i<<2|o>>4,h[a++]=(o&15)<<4|l>>2,h[a++]=(l&3)<<6|c&63;return d},cC=typeof ArrayBuffer=="function",pp=(e,t)=>{if(typeof e!="string")return{type:"message",data:Sv(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:dC(e.substring(1),t)}:_o[n]?e.length>1?{type:_o[n],data:e.substring(1)}:{type:_o[n]}:fu},dC=(e,t)=>{if(cC){const n=lC(e);return Sv(n,t)}else return{base64:!0,data:e}},Sv=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Cv="",uC=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{hp(i,!1,l=>{r[o]=l,++a===n&&t(r.join(Cv))})})},hC=(e,t)=>{const n=e.split(Cv),r=[];for(let a=0;a<n.length;a++){const i=pp(n[a],t);if(r.push(i),i.type==="error")break}return r};function pC(){return new TransformStream({transform(e,t){oC(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let Dc;function eo(e){return e.reduce((t,n)=>t+n.length,0)}function to(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function fC(e,t){Dc||(Dc=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,l){for(n.push(o);;){if(r===0){if(eo(n)<1)break;const c=to(n,1);i=(c[0]&128)===128,a=c[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(eo(n)<2)break;const c=to(n,2);a=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(eo(n)<8)break;const c=to(n,8),d=new DataView(c.buffer,c.byteOffset,c.length),h=d.getUint32(0);if(h>Math.pow(2,21)-1){l.enqueue(fu);break}a=h*Math.pow(2,32)+d.getUint32(4),r=3}else{if(eo(n)<a)break;const c=to(n,a);l.enqueue(pp(i?c:Dc.decode(c),t)),r=0}if(a===0||a>e){l.enqueue(fu);break}}}})}const Ev=4;function Be(e){if(e)return mC(e)}function mC(e){for(var t in Be.prototype)e[t]=Be.prototype[t];return e}Be.prototype.on=Be.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Be.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Be.prototype.off=Be.prototype.removeListener=Be.prototype.removeAllListeners=Be.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Be.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};Be.prototype.emitReserved=Be.prototype.emit;Be.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Be.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Vl=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),zt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),xC="arraybuffer";function _v(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const gC=zt.setTimeout,yC=zt.clearTimeout;function Ul(e,t){t.useNativeTimers?(e.setTimeoutFn=gC.bind(zt),e.clearTimeoutFn=yC.bind(zt)):(e.setTimeoutFn=zt.setTimeout.bind(zt),e.clearTimeoutFn=zt.clearTimeout.bind(zt))}const vC=1.33;function bC(e){return typeof e=="string"?wC(e):Math.ceil((e.byteLength||e.size)*vC)}function wC(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Tv(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function kC(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function jC(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class NC extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class fp extends Be{constructor(t){super(),this.writable=!1,Ul(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new NC(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=pp(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=kC(t);return n.length?"?"+n:""}}class SC extends fp{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};hC(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,uC(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Tv()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Pv=!1;try{Pv=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const CC=Pv;function EC(){}class _C extends SC{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class pn extends Be{constructor(t,n,r){super(),this.createRequest=t,Ul(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=_v(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=pn.requestsCount++,pn.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=EC,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete pn.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}pn.requestsCount=0;pn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",f0);else if(typeof addEventListener=="function"){const e="onpagehide"in zt?"pagehide":"unload";addEventListener(e,f0,!1)}}function f0(){for(let e in pn.requests)pn.requests.hasOwnProperty(e)&&pn.requests[e].abort()}const TC=function(){const e=Av({xdomain:!1});return e&&e.responseType!==null}();class PC extends _C{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=TC&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new pn(Av,this.uri(),t)}}function Av(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||CC))return new XMLHttpRequest}catch{}if(!t)try{return new zt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Mv=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class AC extends fp{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Mv?{}:_v(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;hp(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&Vl(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Tv()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Bc=zt.WebSocket||zt.MozWebSocket;class MC extends AC{createSocket(t,n,r){return Mv?new Bc(t,n,r):n?new Bc(t,n):new Bc(t)}doWrite(t,n){this.ws.send(n)}}class zC extends fp{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=fC(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=pC();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:l,value:c})=>{l||(this.onPacket(c),i())}).catch(l=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&Vl(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const RC={websocket:MC,webtransport:zC,polling:PC},LC=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,OC=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function mu(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=LC.exec(e||""),i={},o=14;for(;o--;)i[OC[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=IC(i,i.path),i.queryKey=DC(i,i.query),i}function IC(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function DC(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const xu=typeof addEventListener=="function"&&typeof removeEventListener=="function",To=[];xu&&addEventListener("offline",()=>{To.forEach(e=>e())},!1);class as extends Be{constructor(t,n){if(super(),this.binaryType=xC,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=mu(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=mu(n.host).host);Ul(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=jC(this.opts.query)),xu&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},To.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Ev,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&as.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",as.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=bC(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Vl(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(as.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xu&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=To.indexOf(this._offlineEventListener);r!==-1&&To.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}as.protocol=Ev;class BC extends as{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;as.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;as.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(h(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function i(){r||(r=!0,h(),n.close(),n=null)}const o=p=>{const f=new Error("probe error: "+p);f.transport=n.name,i(),this.emitReserved("upgradeError",f)};function l(){o("transport closed")}function c(){o("socket closed")}function d(p){n&&p.name!==n.name&&i()}const h=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",l),this.off("close",c),this.off("upgrading",d)};n.once("open",a),n.once("error",o),n.once("close",l),this.once("close",c),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let FC=class extends BC{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>RC[a]).filter(a=>!!a)),super(t,r)}};function $C(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=mu(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const VC=typeof ArrayBuffer=="function",UC=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,zv=Object.prototype.toString,HC=typeof Blob=="function"||typeof Blob<"u"&&zv.call(Blob)==="[object BlobConstructor]",WC=typeof File=="function"||typeof File<"u"&&zv.call(File)==="[object FileConstructor]";function mp(e){return VC&&(e instanceof ArrayBuffer||UC(e))||HC&&e instanceof Blob||WC&&e instanceof File}function Po(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Po(e[n]))return!0;return!1}if(mp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Po(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Po(e[n]))return!0;return!1}function KC(e){const t=[],n=e.data,r=e;return r.data=gu(n,t),r.attachments=t.length,{packet:r,buffers:t}}function gu(e,t){if(!e)return e;if(mp(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=gu(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=gu(e[r],t));return n}return e}function GC(e,t){return e.data=yu(e.data,t),delete e.attachments,e}function yu(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=yu(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=yu(e[n],t));return e}const qC=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var he;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(he||(he={}));class YC{constructor(t){this.replacer=t}encode(t){return(t.type===he.EVENT||t.type===he.ACK)&&Po(t)?this.encodeAsBinary({type:t.type===he.EVENT?he.BINARY_EVENT:he.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===he.BINARY_EVENT||t.type===he.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=KC(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}class xp extends Be{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===he.BINARY_EVENT;r||n.type===he.BINARY_ACK?(n.type=r?he.EVENT:he.ACK,this.reconstructor=new XC(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(mp(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(he[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===he.BINARY_EVENT||r.type===he.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(xp.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case he.CONNECT:return m0(n);case he.DISCONNECT:return n===void 0;case he.CONNECT_ERROR:return typeof n=="string"||m0(n);case he.EVENT:case he.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&qC.indexOf(n[0])===-1);case he.ACK:case he.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class XC{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=GC(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function m0(e){return Object.prototype.toString.call(e)==="[object Object]"}const QC=Object.freeze(Object.defineProperty({__proto__:null,Decoder:xp,Encoder:YC,get PacketType(){return he}},Symbol.toStringTag,{value:"Module"}));function Gt(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const JC=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Rv extends Be{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Gt(t,"open",this.onopen.bind(this)),Gt(t,"packet",this.onpacket.bind(this)),Gt(t,"error",this.onerror.bind(this)),Gt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,i;if(JC.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:he.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const h=this.ids++,p=n.pop();this._registerAckCallback(h,p),o.id=h}const l=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!l||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},a),o=(...l)=>{this.io.clearTimeoutFn(i),n.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,a)=>{const i=(o,l)=>o?a(o):r(l);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>(this._queue[0],a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:he.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case he.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case he.EVENT:case he.BINARY_EVENT:this.onevent(t);break;case he.ACK:case he.BINARY_ACK:this.onack(t);break;case he.DISCONNECT:this.ondisconnect();break;case he.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:he.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:he.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function sa(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}sa.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};sa.prototype.reset=function(){this.attempts=0};sa.prototype.setMin=function(e){this.ms=e};sa.prototype.setMax=function(e){this.max=e};sa.prototype.setJitter=function(e){this.jitter=e};class vu extends Be{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Ul(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new sa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||QC;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new FC(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Gt(n,"open",function(){r.onopen(),t&&t()}),i=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Gt(n,"error",i);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},l);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Gt(t,"ping",this.onping.bind(this)),Gt(t,"data",this.ondata.bind(this)),Gt(t,"error",this.onerror.bind(this)),Gt(t,"close",this.onclose.bind(this)),Gt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Vl(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Rv(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const fa={};function Ba(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=$C(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=fa[a]&&i in fa[a].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new vu(r,t):(fa[a]||(fa[a]=new vu(r,t)),c=fa[a]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Ba,{Manager:vu,Socket:Rv,io:Ba,connect:Ba});const ZC={};let js=null;function eE(){const e=ZC;if(e!=null&&e.VITE_BACKEND_URL)return e.VITE_BACKEND_URL.replace(/\/$/,"");const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||/^\d{1,3}(\.\d{1,3}){3}$/.test(t)?window.location.origin:"http://localhost:4309"}function pe(){return js||(js=Ba(eE(),{transports:["websocket","polling"],withCredentials:!0,reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,randomizationFactor:.3,timeout:1e4}),js.on("agentUpdate",e=>{try{e!=null&&window.dispatchEvent(new CustomEvent("mustb:agentUpdate",{detail:e}))}catch{}}),js.on("connect",()=>{window.dispatchEvent(new CustomEvent("mustb:connected"))}),js.on("disconnect",e=>{window.dispatchEvent(new CustomEvent("mustb:disconnected",{detail:{reason:e}}))}),js.io.on("reconnect",e=>{window.dispatchEvent(new CustomEvent("mustb:reconnected",{detail:{attemptNumber:e}}))})),js}const x0=[{value:"tr-TR",label:"Türkçe (TR)"},{value:"en-US",label:"English (US)"},{value:"de-DE",label:"Deutsch"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"}];function tE(){var z;gt();const[e,t]=u.useState(0),[n,r]=u.useState(""),[a,i]=u.useState("tr-TR"),[o,l]=u.useState("local"),[c,d]=u.useState("Pro"),[h,p]=u.useState(""),[f,m]=u.useState("idle"),[b,y]=u.useState(""),[v,x]=u.useState(0),[g,w]=u.useState(null),[j,k]=u.useState(!1),[S,C]=u.useState(null),[A,N]=u.useState(!1),[_,L]=u.useState(null);u.useEffect(()=>{const P=pe(),E=T=>{if(!T)return;const O=T.model||"",G=typeof T.percent=="number"?T.percent:0,D=T.status||"",K=T.error||"";O==="llama3.2"&&(x(G),m(D),y(D==="success"?"Yerel model başarıyla kuruldu ve çevrimdışı kullanım için hazır!":D==="error"?K||"Model indirme sırasında bir hata oluştu.":`İndiriliyor: %${G} - ${D}`))};return P.on("ollama_pull_progress",E),()=>{P.off("ollama_pull_progress",E)}},[]);const B=async()=>{var P;k(!0),C(null);try{const E=await fetch("/api/ollama/models");if(!E.ok){w(!1),C("Ollama kapalı.");return}const T=await E.json();w(!!(T!=null&&T.running)),(T==null?void 0:T.running)===!1&&C((P=T==null?void 0:T.error)!=null&&P.includes("ECONNREFUSED")?"Ollama kapalı.":(T==null?void 0:T.error)||"Ollama kapalı.")}catch{w(!1),C("Ollama kapalı.")}finally{k(!1)}};u.useEffect(()=>{e===2&&B()},[e]);const M=async()=>{if(f!=="pulling"){m("pulling"),x(0),y("İndirme talebi iletiliyor...");try{const P=await fetch("/api/ollama/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelName:"llama3.2"})});if(!P.ok){const E=await P.json().catch(()=>({}));throw new Error(E.error||"Ollama pull başlatılamadı.")}y("Yerel model indiriliyor (llama3.2)...")}catch(P){m("error"),y(P.message)}}},$=()=>e===0?n.trim().length>0:e===1&&(c==="free"||c==="Pro")?h.trim().length>0:!0,R=async()=>{N(!0),L(null);try{const P=c==="Local",E={name:n.trim()||"Kullanıcı",language:a,provider:P?"ollama":"openrouter",apiKey:P?"http://localhost:11434":h,model:P?"llama3.2":"meta-llama/llama-4-scout:free",skills:["browser","terminal","memory","web_search","filesystem","git","vision","input","telegram","analyzer"],mode:o,workspacePath:"",wakeWord:!1,telemetry:!1,plan:c},T=await fetch("/api/setup/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!T.ok){const O=await T.json().catch(()=>({}));throw new Error(O.error||"Kurulum kaydedilemedi.")}localStorage.setItem("mustb_setup_complete","1"),window.location.href="/app"}catch(P){L(P.message||"Bilinmeyen bir hata oluştu."),N(!1)}};return s.jsxs("div",{className:"min-h-screen bg-[#02040a] flex flex-col items-center justify-center px-4 py-12 relative overflow-hidden",children:[s.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[s.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[700px] h-[700px] bg-emerald-950/10 rounded-full blur-[140px]"}),s.jsx("div",{className:"absolute top-10 left-10 w-[300px] h-[300px] bg-cyan-950/10 rounded-full blur-[100px]"})]}),s.jsxs("div",{className:"relative z-10 w-full max-w-xl",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsx("div",{className:"relative w-14 h-14 rounded-full bg-gradient-to-tr from-emerald-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-emerald-500/20",children:s.jsx(mn,{size:24,className:"text-white"})})}),s.jsx("h1",{className:"text-3xl font-extrabold text-white tracking-tight",children:"Must-b Kurulum Sihirbazı"}),s.jsx("p",{className:"text-gray-400 mt-1.5 text-sm",children:"Proaktif Çevrimdışı Güvenlik Entegrasyonu"})]}),s.jsx("div",{className:"flex justify-center items-center gap-2 mb-8",children:[0,1,2,3].map(P=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:ht("w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold transition-all duration-300",P<e?"bg-emerald-600 text-white":P===e?"bg-emerald-500/20 border-2 border-emerald-500 text-emerald-400 shadow-md shadow-emerald-500/10":"bg-white/5 border border-white/10 text-gray-500"),children:P<e?s.jsx(it,{size:14}):P+1}),s.jsx("span",{className:ht("text-xs font-semibold uppercase tracking-wider",P===e?"text-emerald-400":"text-gray-600"),children:P===0?"Mod & Kimlik":P===1?"Plan & API":P===2?"Yerel Zeka":"Tamamla"}),P<3&&s.jsx("div",{className:"w-8 h-px bg-white/10"})]},P))}),s.jsxs("div",{className:"bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-2xl p-6 shadow-2xl backdrop-blur-md relative",children:[s.jsxs("p",{className:"text-[10px] font-bold text-emerald-500/60 uppercase tracking-widest mb-1",children:["Adım ",e+1," / 4"]}),s.jsxs(ae,{mode:"wait",children:[e===0&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Mod ve Profil Tercihleri"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold flex items-center gap-1.5",children:[s.jsx(hi,{size:12})," İsminiz / Name"]}),s.jsx("input",{type:"text",value:n,onChange:P=>r(P.target.value),placeholder:"Örn: Burak",className:"w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:ring-1 focus:ring-emerald-500/50 transition-all text-base"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold flex items-center gap-1.5",children:[s.jsx(Ge,{size:12})," Dil Seçimi / Language"]}),s.jsx("select",{value:a,onChange:P=>i(P.target.value),className:"w-full bg-[#0d1117] border border-white/10 rounded-xl px-4 py-3 text-white focus:outline-none focus:ring-1 focus:ring-emerald-500/50 transition-all text-sm appearance-none cursor-pointer",children:x0.map(P=>s.jsx("option",{value:P.value,children:P.label},P.value))})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold",children:"Çalışma Modu Seçimi"}),s.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[s.jsxs("button",{onClick:()=>l("local"),className:ht("flex items-start gap-4 p-4 rounded-xl border transition-all text-left",o==="local"?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx(Mn,{size:20,className:"mt-1 flex-shrink-0 text-emerald-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-sm",children:"Terminal Asistanı (Local Mode)"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Hafif ve terminal ortamında çalışarak doğrudan komut satırı üzerinden asistanlık yapar."})]})]}),s.jsxs("button",{onClick:()=>l("world"),className:ht("flex items-start gap-4 p-4 rounded-xl border transition-all text-left",o==="world"?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx(dv,{size:20,className:"mt-1 flex-shrink-0 text-cyan-400"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-sm",children:"Must-b.os (World Mode)"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Gelişmiş görsel arayüz, entegrasyonlar ve çoklu platform desteği sunan tam işletim sistemi orkestrasyonu."})]})]})]})]})]},"step0"),e===1&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Plan & API Yetkilendirme"}),s.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{id:"free",title:"Free (BYOK)",desc:"Kendi anahtarınla ücretsiz kullan."},{id:"Pro",title:"Must-b Pro",desc:"Bulut destekli zeka motoru gücü."},{id:"Elite",title:"Must-b Elite",desc:"Bulut Zekası + Çevrimdışı Koruması."},{id:"Local",title:"Must-b Local",desc:"Tamamen internetsiz ve yerel."}].map(P=>s.jsxs("button",{onClick:()=>{d(P.id),P.id==="Local"&&p("")},className:ht("p-4 rounded-xl border transition-all text-left flex flex-col justify-between h-[100px]",c===P.id?"bg-emerald-500/10 border-emerald-500/40 text-white":"bg-white/3 border-white/8 text-gray-400 hover:border-white/20 hover:text-white"),children:[s.jsx("p",{className:"font-bold text-sm leading-tight text-white",children:P.title}),s.jsx("p",{className:"text-[11px] text-gray-400 mt-1.5 leading-relaxed",children:P.desc})]},P.id))}),(c==="free"||c==="Pro")&&s.jsxs("div",{className:"space-y-2 pt-2 border-t border-white/5",children:[s.jsx("label",{className:"text-xs text-gray-400 uppercase tracking-widest font-bold",children:"OpenRouter veya OpenAI API Anahtarı"}),s.jsx("input",{type:"password",value:h,onChange:P=>p(P.target.value),placeholder:"sk-or-v1-...",className:"w-full bg-white/5 border border-white/10 rounded-xl px-4 py-2.5 text-white font-mono text-sm focus:outline-none focus:ring-1 focus:ring-emerald-500/50"}),s.jsx("p",{className:"text-gray-400 text-xs mt-1",children:"Girilen tüm anahtarlar yerelde şifreli olarak saklanır ve sunucularımıza gitmez."})]})]},"step1"),e===2&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Yerel Yapay Zeka Kurulumu"}),s.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:"Must-b.os, Elite ve Local planlarda tamamen çevrimdışı ve yerel çalışabilmek için **Ollama** entegrasyonunu destekler."}),j?s.jsxs("div",{className:"flex items-center justify-center gap-2.5 py-8 text-zinc-400",children:[s.jsx(ne,{size:18,className:"animate-spin text-emerald-400"}),s.jsx("span",{className:"text-sm font-medium",children:"Ollama durumu kontrol ediliyor..."})]}):g===!1?s.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-5 space-y-4 backdrop-blur-md shadow-lg shadow-red-500/5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ke,{size:20,className:"text-red-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h4",{className:"text-sm font-bold text-red-300",children:S||"Ollama kapalı."}),s.jsx("p",{className:"text-xs text-red-200/80 leading-relaxed",children:"Ollama servisi yanıt vermiyor. Arka planda çalıştığından emin olun."})]})]}),s.jsxs("div",{className:"text-xs text-zinc-400 space-y-2 pl-8",children:[s.jsx("p",{className:"font-semibold text-zinc-300",children:"Nasıl kurulur?"}),s.jsxs("ol",{className:"list-decimal pl-4 space-y-1 leading-relaxed",children:[s.jsxs("li",{children:[s.jsx("a",{href:"https://ollama.com",target:"_blank",rel:"noreferrer",className:"text-emerald-400 hover:underline",children:"https://ollama.com"})," adresinden Ollama'yı indirip kurun."]}),s.jsx("li",{children:"Kurulum tamamlandıktan sonra Ollama uygulamasını arka planda çalıştırın."}),s.jsx("li",{children:"Aşağıdaki butonla durumu tekrar kontrol edin."})]})]}),s.jsx("button",{type:"button",onClick:B,className:"w-full py-2.5 px-4 rounded-xl font-bold text-xs text-white bg-zinc-800 hover:bg-zinc-700 transition-all border border-zinc-700 active:scale-[0.98]",children:"Tekrar Kontrol Et"})]}):g===!0?s.jsxs("div",{className:"space-y-4 bg-zinc-900/40 rounded-xl p-5 border border-zinc-800",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(tn,{size:20,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-bold text-white",children:"Ollama Bağlantısı Hazır ✓"}),s.jsx("p",{className:"text-xs text-zinc-400",children:"Arka planda çalışan yerel Ollama servisiyle bağlantı kuruldu."})]})]}),s.jsxs("div",{className:"pt-2 border-t border-zinc-800 space-y-3",children:[s.jsxs("p",{className:"text-xs text-zinc-300 leading-relaxed",children:["Çevrimdışı/Yerel kullanım için önerilen hafif yapay zeka modelini (",s.jsx("strong",{children:"llama3.2"}),") indirebilirsiniz:"]}),s.jsxs("button",{type:"button",onClick:M,disabled:f==="pulling",className:"w-full flex items-center justify-center gap-2 py-3 px-4 rounded-xl font-bold text-sm text-white bg-gradient-to-r from-emerald-600 to-cyan-600 hover:from-emerald-500 hover:to-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all active:scale-[0.98] shadow-lg shadow-emerald-500/10",children:[f==="pulling"?s.jsx(ne,{size:16,className:"animate-spin"}):s.jsx(Os,{size:16}),s.jsx("span",{children:"llama3.2 İndir / Pull"})]}),f!=="idle"&&s.jsxs("div",{className:"space-y-2 pt-2",children:[f==="pulling"&&s.jsx("div",{className:"w-full bg-zinc-950 border border-zinc-800 rounded-full h-3 overflow-hidden relative shadow-inner",children:s.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-cyan-500 h-full rounded-full transition-all duration-300 relative shadow-[0_0_8px_rgba(16,185,129,0.3)]",style:{width:`${v}%`}})}),s.jsxs("div",{className:ht("rounded-xl px-4 py-3 text-xs flex items-start gap-2.5 border",f==="success"?"bg-emerald-500/10 border-emerald-500/20 text-emerald-400":f==="error"?"bg-red-500/10 border-red-500/20 text-red-400":"bg-zinc-950 border-zinc-800 text-zinc-300"),children:[f==="pulling"&&s.jsx(ne,{size:12,className:"animate-spin shrink-0 mt-0.5 text-emerald-400"}),f==="success"&&s.jsx("span",{className:"text-[12px] font-bold text-emerald-400",children:"✓"}),f==="error"&&s.jsx(Ke,{size:12,className:"shrink-0 mt-0.5 text-red-400"}),s.jsx("p",{className:"leading-relaxed font-medium",children:b})]})]})]})]}):s.jsx("div",{className:"bg-zinc-900/40 rounded-xl p-5 border border-zinc-800 text-center py-8",children:s.jsx("p",{className:"text-xs text-zinc-500 font-medium",children:"Durum sorgulanıyor..."})})]},"step2"),e===3&&s.jsxs(V.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"space-y-6",children:[s.jsx("h2",{className:"text-xl font-bold text-white",children:"Kurulumu Tamamla"}),s.jsxs("div",{className:"rounded-xl bg-white/3 border border-white/6 p-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest mb-1",children:"Kurulum Özeti"}),[{label:"Kullanıcı Adı",value:n||"—"},{label:"Seçilen Dil",value:((z=x0.find(P=>P.value===a))==null?void 0:z.label)||a},{label:"Çalışma Modu",value:o==="world"?"Must-b.os (Visual)":"Terminal Asistanı (CLI)"},{label:"Üyelik Planı",value:c},{label:"Çevrimdışı Desteği",value:c==="Local"||c==="Elite"?"Aktif (llama3.2)":"Kısıtlı / Bulut Bağlantılı"}].map(P=>s.jsxs("div",{className:"flex items-center justify-between text-xs border-b border-white/5 pb-2 last:border-b-0 last:pb-0",children:[s.jsx("span",{className:"text-gray-400",children:P.label}),s.jsx("span",{className:"text-gray-200 font-semibold",children:P.value})]},P.label))]}),_&&s.jsxs("div",{className:"rounded-xl bg-red-500/10 border border-red-500/20 p-3 text-red-400 text-sm flex items-start gap-2",children:[s.jsx(Ke,{size:16,className:"flex-shrink-0 mt-0.5"}),s.jsx("span",{children:_})]}),s.jsx("button",{onClick:R,disabled:A,className:"w-full flex items-center justify-center gap-3 px-8 py-4 rounded-2xl bg-gradient-to-r from-emerald-600 to-cyan-600 hover:from-emerald-500 hover:to-cyan-500 text-white font-bold text-base transition-all shadow-lg shadow-emerald-500/20 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:A?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:20,className:"animate-spin"})," Kurulum Tamamlanıyor..."]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-lg",children:"🚀"})," Kurulumu Tamamla ve Başlat / Finalize Setup"]})})]},"step3")]}),s.jsxs("div",{className:"flex items-center justify-between mt-8 pt-4 border-t border-white/5",children:[s.jsxs("button",{onClick:()=>t(P=>P-1),disabled:e===0||A,className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-gray-500 hover:text-white disabled:opacity-20 disabled:cursor-not-allowed transition-all text-xs font-semibold",children:[s.jsx(x3,{size:14})," Geri / Back"]}),e<3&&s.jsxs("button",{onClick:()=>t(P=>P+1),disabled:!$()||A,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs transition-all active:scale-[0.97] disabled:opacity-40 disabled:cursor-not-allowed shadow-md shadow-emerald-500/10",children:["Devam Et / Continue ",s.jsx(gn,{size:14})]})]})]}),s.jsxs("p",{className:"text-center text-xs text-gray-700 mt-5",children:["Tüm verileriniz yerelde güvenle saklanır · Doğrulamak için ",s.jsx("code",{className:"text-emerald-500/60 font-mono",children:"must-b doctor"})," çalıştırabilirsiniz"]})]})]})}const nE={};let Na=null;const sE=(()=>{const e=nE,t=(e==null?void 0:e.VITE_BACKEND_URL)??"";return t&&!t.includes(window.location.hostname)?t.replace(/\/$/,""):""})();function Lv(e){return e.startsWith("http")?e:`${sE}${e}`}async function rE(){if(Na)return Na;try{const e=await fetch(Lv("/api/auth/local"));if(e.ok)return Na=(await e.json()).token??null,Na}catch{}return null}async function U(e,t={},{retries:n=3,retryDelay:r=800}={}){const a=await rE(),i={"Content-Type":"application/json",...t.headers};a&&(i.Authorization=`Bearer ${a}`);const o=Lv(e);let l;for(let c=1;c<=n;c++)try{const d=await fetch(o,{...t,headers:i});return d.status===401&&(Na=null,window.dispatchEvent(new CustomEvent("mustb:401",{detail:{url:o}}))),d}catch(d){l=d,c<n&&await new Promise(h=>setTimeout(h,r*c))}throw window.dispatchEvent(new CustomEvent("mustb:offline",{detail:{url:o}})),l}function g0(e){const t=e.toLowerCase();if(t.includes("gemini-2")||t.includes("gemini-flash"))return 9999;if(t.includes("llama-3")&&(t.includes("70b")||t.includes("405b")))return 9998;if(t.includes("gpt-4o"))return 8888;if(t.includes("claude-3-5")||t.includes("claude-3.5"))return 8887;if(t.includes("gemini-pro")||t.includes("gemini-1.5-pro"))return 8886;const n=t.match(/(\d+)x(\d+)b/);if(n)return parseFloat(n[1])*parseFloat(n[2]);const r=t.match(/(\d+(?:\.\d+)?)b/);return r?parseFloat(r[1]):0}function Fc(e){return[...e].sort((t,n)=>g0(n.id)-g0(t.id))}function aE(){const{t:e}=yt(),[t,n]=u.useState(!1),[r,a]=u.useState(()=>localStorage.getItem("mustb_active_model")??"Loading…"),[i,o]=u.useState([]),l=u.useRef(null);u.useEffect(()=>{const f=localStorage.getItem("mustb_active_model");f&&f!=="Loading…"&&U("/api/settings/model",{method:"POST",body:JSON.stringify({model:f})}).catch(()=>{}),U("/api/setup/status").then(m=>m.ok?m.json():null).then(m=>{if(!m)return;const b=localStorage.getItem("mustb_active_model");m.activeModel&&(!b||b==="Loading…")&&(a(m.activeModel),localStorage.setItem("mustb_active_model",m.activeModel)),(m.activeProvider??"openrouter").toLowerCase()==="ollama"?U("/api/models").then(v=>v.ok?v.json():[]).then(v=>{const g=(Array.isArray(v)?v:[]).map(w=>({id:w.id??String(w),name:w.name??w.id??String(w),free:!0}));o(Fc(g))}).catch(()=>{}):U("/api/providers/openrouter/models").then(v=>v.ok?v.json():{}).then(v=>{const x=Fc((v.free??[]).map(j=>({id:j.id,name:j.name??j.id,free:!0}))),g=Fc((v.power??[]).map(j=>({id:j.id,name:j.name??j.id,free:!1}))),w=[...x,...g];o(w),!(m!=null&&m.activeModel)&&w.length>0&&a(w[0].id)}).catch(()=>{})}).catch(()=>{})},[]),u.useEffect(()=>{if(!t)return;const f=m=>{l.current&&!l.current.contains(m.target)&&n(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[t]);const c=async f=>{a(f),localStorage.setItem("mustb_active_model",f),n(!1),await U("/api/settings/model",{method:"POST",body:JSON.stringify({model:f})}).catch(()=>{})},d=i.filter(f=>f.free),h=i.filter(f=>!f.free),p=r.length>28?r.slice(0,26)+"…":r;return s.jsxs("div",{ref:l,className:"relative",children:[s.jsxs("button",{onClick:()=>n(f=>!f),className:"flex items-center gap-1 px-2 py-1 rounded-lg border border-white/10 bg-white/5 hover:bg-white/10 text-white/50 hover:text-white/80 text-[11px] font-medium transition-all",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-500 shrink-0"}),s.jsx("span",{className:"truncate max-w-[110px]",children:p}),s.jsx(Xs,{size:10,className:`transition-transform duration-200 shrink-0 text-white/30 ${t?"rotate-180":""}`})]}),s.jsx(ae,{children:t&&s.jsxs(V.div,{initial:{opacity:0,y:6,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.97},transition:{duration:.14,ease:[.22,1,.36,1]},className:"absolute bottom-full mb-2 left-0 z-50 w-72 rounded-xl shadow-xl border border-white/10 flex flex-col",style:{background:"rgba(18,8,2,0.97)",backdropFilter:"blur(24px)",maxHeight:"400px"},children:[s.jsxs("div",{className:"overflow-y-auto flex-1 p-1.5",children:[d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2.5 pt-2 pb-1 text-[9.5px] font-black uppercase tracking-[0.12em] text-emerald-500/80",children:"Free"}),d.slice(0,5).map(f=>s.jsxs("button",{onClick:()=>c(f.id),className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-left transition-colors ${r===f.id?"bg-orange-500/15 text-orange-300":"text-white/60 hover:bg-white/5 hover:text-white/90"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r===f.id?"bg-orange-500":"bg-emerald-400"}`}),s.jsx("span",{className:"text-[12px] font-medium truncate",children:f.name}),r===f.id&&s.jsx("span",{className:"ml-auto text-[9px] font-semibold text-orange-400 shrink-0",children:"active"})]},f.id))]}),h.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2.5 pt-2 pb-1 text-[9.5px] font-black uppercase tracking-[0.12em] text-orange-400/80",children:"Pro"}),h.map(f=>s.jsxs("button",{onClick:()=>c(f.id),className:`w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-left transition-colors ${r===f.id?"bg-orange-500/15 text-orange-300":"text-white/60 hover:bg-white/5 hover:text-white/90"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${r===f.id?"bg-orange-500":"bg-orange-300"}`}),s.jsx("span",{className:"text-[12px] font-medium truncate",children:f.name}),r===f.id&&s.jsx("span",{className:"ml-auto text-[9px] font-semibold text-orange-400 shrink-0",children:"active"})]},f.id))]}),i.length===0&&s.jsx("div",{className:"px-3 py-4 text-[12px] text-white/30 text-center",children:"No models available"})]}),s.jsx("div",{className:"shrink-0 border-t border-white/8 p-1.5",children:s.jsxs(Ra,{to:"/app/settings",onClick:()=>n(!1),className:"flex items-center justify-center gap-1.5 w-full px-2.5 py-2 rounded-lg text-[11px] font-medium text-white/35 hover:text-orange-400 hover:bg-orange-500/8 transition-colors",children:[s.jsx(Ci,{size:11}),e.systemHealth.moreModels]})})]})})]})}function Yt(e){if(typeof e=="string")return e;if(e==null)return"";if(typeof e=="object"){const t=e,n=t.message??t.error??t.text??t.content??t.result;return n!==void 0?Yt(n):JSON.stringify(e)}return String(e)}function iE(e,t){switch(e){case"planGenerated":{const n=t.steps;return`Plan ready — ${(n==null?void 0:n.length)??0} step(s)`}case"stepStart":{const n=t.step;return`▶ ${(n==null?void 0:n.description)??Yt(t.step)}`}case"stepFinish":{if(t.status==="error")return`✗ ${Yt(t.error)}`;const n=t.step,r=t.result!==void 0?Yt(t.result):void 0,a=(n==null?void 0:n.description)??"Step complete";return r&&r.length<180?`✓ ${a} → ${r}`:`✓ ${a}`}case"agentRepair":{const n=Yt(t.action),r=t.reason?` — ${Yt(t.reason).slice(0,120)}`:"";return`⟳ Repair: ${n}${r}`}default:return null}}function oE(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function lE({lang:e,code:t}){const[n,r]=u.useState(!1);return s.jsxs("div",{className:"my-3 rounded-xl overflow-hidden border border-white/8 bg-[#1a0800]/90",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5 border-b border-white/6 select-none",children:[s.jsx("span",{className:"text-[11px] font-mono text-orange-300/50",children:e||"code"}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t).catch(()=>{}),r(!0),setTimeout(()=>r(!1),2e3)},className:"flex items-center gap-1.5 text-[11px] text-orange-300/50 hover:text-orange-200 transition-colors",children:n?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:10,className:"text-orange-400"}),s.jsx("span",{className:"text-orange-400",children:"Copied"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Vs,{size:10}),"Copy"]})})]}),s.jsx("pre",{className:"overflow-x-auto px-4 py-3 text-[13px] text-orange-50 font-mono leading-relaxed whitespace-pre",children:s.jsx("code",{children:t})})]})}function ir(e,t){return e.split(/(`[^`\n]+`)/).map((r,a)=>{if(r.startsWith("`")&&r.endsWith("`")&&r.length>2)return s.jsx("code",{className:"px-1.5 py-0.5 rounded bg-black/15 text-orange-700 font-mono text-[12px]",children:r.slice(1,-1)},`${t}-ic${a}`);const i=r.split(/(\*\*[^*\n]+\*\*|\*[^*\n]+\*)/);return s.jsx(u.Fragment,{children:i.map((o,l)=>o.startsWith("**")&&o.endsWith("**")&&o.length>4?s.jsx("strong",{className:"font-bold text-inherit dark:text-gray-100",children:o.slice(2,-2)},`${t}-b${a}-${l}`):o.startsWith("*")&&o.endsWith("*")&&o.length>2?s.jsx("em",{className:"italic",children:o.slice(1,-1)},`${t}-em${a}-${l}`):s.jsx("span",{children:o},`${t}-s${a}-${l}`))},`${t}-bi${a}`)})}function cE({text:e,dark:t=!1}){const n=t?"text-orange-50":"text-[#3d1a06]",r=[],a=e.split(`
|
|
740
740
|
`);let i=0,o=0;const l=()=>`md-${o++}`;for(;i<a.length;){const c=a[i],d=c.match(/^```(\w*)/);if(d){const b=d[1]??"",y=[];for(i++;i<a.length&&!a[i].startsWith("```");)y.push(a[i]),i++;i<a.length&&i++,r.push(s.jsx(lE,{lang:b,code:y.join(`
|
|
741
741
|
`)},l()));continue}const h=c.match(/^### (.+)/);if(h){r.push(s.jsx("h3",{className:`text-sm font-bold mt-4 mb-1 ${n}`,children:ir(h[1],l())},l())),i++;continue}const p=c.match(/^## (.+)/);if(p){r.push(s.jsx("h2",{className:`text-base font-bold mt-5 mb-1.5 ${n}`,children:ir(p[1],l())},l())),i++;continue}const f=c.match(/^# (.+)/);if(f){r.push(s.jsx("h1",{className:`text-lg font-bold mt-6 mb-2 ${n}`,children:ir(f[1],l())},l())),i++;continue}if(c.match(/^[-*]{3,}$/)){r.push(s.jsx("hr",{className:"border-black/10 my-4"},l())),i++;continue}if(c.match(/^[-*•] /)){const b=[];for(;i<a.length&&a[i].match(/^[-*•] /);)b.push(a[i].replace(/^[-*•] /,"")),i++;r.push(s.jsx("ul",{className:"my-2 space-y-1.5 pl-1",children:b.map((y,v)=>s.jsxs("li",{className:`flex items-start gap-2.5 text-[14px] leading-relaxed ${n}`,children:[s.jsx("span",{className:"mt-[7px] w-1.5 h-1.5 rounded-full bg-orange-500/60 flex-shrink-0"}),s.jsx("span",{children:ir(y,`ul-${v}`)})]},v))},l()));continue}if(c.match(/^\d+\. /)){const b=[];for(;i<a.length&&a[i].match(/^\d+\. /);)b.push(a[i].replace(/^\d+\. /,"")),i++;r.push(s.jsx("ol",{className:"my-2 space-y-1.5 pl-1",children:b.map((y,v)=>s.jsxs("li",{className:`flex items-start gap-2.5 text-[14px] leading-relaxed ${n}`,children:[s.jsxs("span",{className:"flex-shrink-0 mt-px font-mono text-[12px] w-5 text-right text-orange-600/60",children:[v+1,"."]}),s.jsx("span",{children:ir(y,`ol-${v}`)})]},v))},l()));continue}if(c.trim()===""){i++;continue}const m=[];for(;i<a.length&&a[i].trim()!==""&&!a[i].match(/^(```|#{1,3} |[-*•] |\d+\. |[-*]{3,}$)/);)m.push(a[i]),i++;m.length&&r.push(s.jsx("p",{className:`text-[14px] leading-[1.75] my-1.5 ${n}`,children:ir(m.join(" "),`p-${o}`)},l()))}return s.jsx("div",{children:r})}function dE(){const[e,t]=u.useState(0);u.useEffect(()=>{const a=setInterval(()=>t(i=>i+1),1e3);return()=>clearInterval(a)},[]);const n=String(Math.floor(e/60)).padStart(2,"0"),r=String(e%60).padStart(2,"0");return s.jsxs("span",{className:"text-[10px] text-white/20 font-mono ml-1",children:["[",n,":",r,"]"]})}function uE({startedAt:e}){const[t,n]=u.useState(()=>e?Math.floor((Date.now()-e)/1e3):0);u.useEffect(()=>{if(!e)return;const i=setInterval(()=>n(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(i)},[e]);const r=Math.floor(t/60),a=t%60;return s.jsxs("span",{className:"text-[10px] text-orange-400/40 font-mono",children:["Working… ",r>0?`${r}m ${a}s`:`${a}s`]})}function hE({block:e}){const t=u.useRef(null);return u.useEffect(()=>{e.status==="running"&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.lines.length,e.status]),s.jsxs("div",{className:"mb-3 rounded-xl overflow-hidden font-mono text-[10px]",style:{background:"#0d0d0d",border:"1px solid rgba(255,255,255,0.09)"},children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-white/6",style:{background:"#1a1a1a"},children:[s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-red-500/60"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400/60"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-green-500/60"}),s.jsx("span",{className:"ml-2 text-white/30 tracking-widest uppercase truncate flex-1",children:e.command}),e.status==="running"&&s.jsx(ne,{size:9,className:"animate-spin text-orange-400/60 shrink-0"}),e.status==="done"&&s.jsx(Fe,{size:9,className:"text-emerald-400/60 shrink-0"}),e.status==="error"&&s.jsx("span",{className:"text-red-400/60 shrink-0",children:"✗"})]}),s.jsxs("div",{ref:t,className:"px-3 py-2 max-h-52 overflow-y-auto scrollbar-hide space-y-0.5",children:[e.lines.length===0?s.jsx("span",{className:"text-white/20 italic",children:"Connecting…"}):e.lines.map((n,r)=>s.jsx("div",{className:`leading-relaxed whitespace-pre-wrap break-all ${n.startsWith("$ ")?"text-green-400/90":n.startsWith("[stderr]")?"text-red-400/70":n.startsWith("⚠")?"text-amber-400/80":"text-white/45"}`,children:n},r)),e.status==="running"&&s.jsx("span",{className:"inline-block w-1.5 h-3 bg-green-400/70 animate-pulse ml-0.5"})]})]})}function pE({block:e}){const[t,n]=u.useState(!1),r=e.op==="write",a=e.content.length>3e3?e.content.slice(0,3e3)+`
|
|
742
|
-
…`:e.content;return s.jsxs("div",{className:"mb-3 rounded-xl overflow-hidden font-mono text-[10px]",style:{background:"#060d1a",border:`1px solid ${r?"rgba(52,211,153,0.18)":"rgba(99,179,237,0.15)"}`},children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/6",style:{background:"#0c1528"},children:[s.jsx(en,{size:9,className:r?"text-emerald-400/70 shrink-0":"text-sky-400/60 shrink-0"}),s.jsx("span",{className:"text-white/50 truncate flex-1",children:e.filename}),s.jsx("span",{className:`text-[9px] font-bold tracking-widest uppercase shrink-0 ${r?"text-emerald-400/60":"text-sky-400/50"}`,children:r?"SAVED":"READ"}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e.content).catch(()=>{}),n(!0),setTimeout(()=>n(!1),2e3)},className:"ml-2 text-white/25 hover:text-white/60 transition-colors shrink-0",title:"Copy content",children:t?s.jsx(it,{size:9,className:"text-green-400"}):s.jsx(Vs,{size:9})})]}),s.jsx("div",{className:"px-3 py-2 max-h-52 overflow-y-auto scrollbar-hide",children:s.jsx("pre",{className:"text-[10px] leading-relaxed whitespace-pre-wrap break-all",style:{color:r?"rgba(52,211,153,0.7)":"rgba(147,197,253,0.65)"},children:a})})]})}function fE({workflow:e,onDismiss:t}){const[n,r]=u.useState("idle"),[a,i]=u.useState(e.goal.slice(0,52)+(e.goal.length>52?"…":"")),o=async()=>{r("saving");try{const l=await U("/api/skills/save",{method:"POST",body:JSON.stringify({goal:e.goal,answer:e.answer,steps:e.steps,name:a.trim()||void 0})});if(!l.ok)throw new Error(`HTTP ${l.status}`);r("saved"),setTimeout(t,1800)}catch{r("error"),setTimeout(()=>r("idle"),3e3)}};return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},className:"mt-3",children:s.jsx("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-orange-900/20 border border-orange-600/30",children:n==="saved"?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:13,className:"text-orange-400 shrink-0"}),s.jsx("span",{className:"text-xs font-medium text-orange-400",children:"Skill saved!"})]}):s.jsxs(s.Fragment,{children:[s.jsx(sv,{size:13,className:"text-orange-600 shrink-0"}),s.jsx("span",{className:"text-[11px] text-orange-200 shrink-0 font-medium",children:"Save as Skill:"}),s.jsx("input",{value:a,onChange:l=>i(l.target.value),onKeyDown:l=>l.key==="Enter"&&n==="idle"&&o(),placeholder:"Skill name…",className:"flex-1 bg-transparent text-[12px] text-orange-100 outline-none placeholder-orange-600/50 min-w-0"}),s.jsx("button",{onClick:o,disabled:n!=="idle",className:"flex items-center gap-1 px-3 py-1 rounded-lg bg-orange-900/30 hover:bg-orange-900/50 border border-orange-800/40 text-orange-200 text-[11px] font-semibold transition-all shrink-0 disabled:opacity-50",children:n==="saving"?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:10,className:"animate-spin"})," Saving…"]}):n==="error"?"Retry":"Save"}),s.jsx("button",{onClick:t,className:"text-orange-700 hover:text-orange-500 transition-colors text-[11px] shrink-0",children:"✕"})]})})})}function mE({src:e,onClose:t}){const[n,r]=u.useState(!1);u.useEffect(()=>{const o=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]);const a=()=>{const o=document.createElement("a");o.href=e,o.download=`mustb-image-${Date.now()}.jpg`,o.click()},i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{}};return s.jsxs("div",{className:"fixed inset-0 z-[9999] flex flex-col items-center justify-center bg-black/90 backdrop-blur-sm",onClick:t,children:[s.jsxs("div",{className:"absolute top-5 right-5 flex items-center gap-2",onClick:o=>o.stopPropagation(),children:[s.jsxs("button",{onClick:i,title:"Copy link",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white text-[12px] font-medium transition-all",children:[n?s.jsx(it,{size:14,className:"text-green-400"}):s.jsx(Vs,{size:14}),n?"Copied!":"Copy"]}),s.jsxs("button",{onClick:a,title:"Download image",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white text-[12px] font-medium transition-all",children:[s.jsx(Os,{size:14}),"Download"]}),s.jsx("button",{onClick:t,className:"w-9 h-9 flex items-center justify-center rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white transition-all",children:s.jsx(ze,{size:18})})]}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-[90vw] max-h-[85vh] object-contain rounded-2xl shadow-2xl",onClick:o=>o.stopPropagation()})]})}class xE extends u.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t.message??"Unknown error"}}componentDidCatch(t,n){console.error("[ChatErrorBoundary]",t,n.componentStack)}render(){return this.state.error?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("span",{className:"text-2xl",children:"⚠️"}),s.jsx("p",{className:"text-red-400 font-bold text-sm",children:"Chat render error"}),s.jsx("p",{className:"text-orange-200/70 text-xs font-mono max-w-sm break-all",children:this.state.error}),s.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-1 px-4 py-2 rounded-xl bg-orange-900/20 border border-orange-800/30 text-orange-200 text-xs font-bold hover:bg-orange-900/40 transition-all",children:"Retry"})]}):this.props.children}}const y0=[{id:"terminal",label:"Terminal",Icon:Mn},{id:"browser",label:"Browser",Icon:Ge},{id:"image-gen",label:"Görsel Üret",Icon:fv},{id:"web-search",label:"Web Search",Icon:fn},{id:"file-manager",label:"Files",Icon:Ln},{id:"code",label:"Code",Icon:en},{id:"screen-sense",label:"Ekranı Gör",Icon:op}];function gE({onSend:e,onStop:t,disabled:n}){const{t:r}=yt(),[a,i]=u.useState(""),[o,l]=u.useState(!1),[c,d]=u.useState(""),[h,p]=u.useState([]),[f,m]=u.useState([]),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useRef(!1),g=u.useRef(null),w=u.useRef(null),j=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),k=()=>{const R=window.SpeechRecognition||window.webkitSpeechRecognition;if(!R)return;const M=new R;M.continuous=!0,M.interimResults=!0,M.lang="tr-TR",M.onresult=P=>{let E="",T="";for(let O=P.resultIndex;O<P.results.length;O++)P.results[O].isFinal?E+=P.results[O][0].transcript:T+=P.results[O][0].transcript;E?(i(O=>(O.trim()?O.trimEnd()+" ":"")+E.trim()),d("")):d(T)},M.onend=()=>{d(""),x.current?setTimeout(k,150):(l(!1),v.current=null)},M.onerror=P=>{P.error!=="no-speech"&&l(!1),d(""),x.current&&P.error!=="not-allowed"&&setTimeout(k,500)},v.current=M;try{M.start()}catch{}},S=()=>{var R;o?(x.current=!1,(R=v.current)==null||R.stop(),d("")):(x.current=!0,l(!0),k())},C=R=>{p(M=>[...M,...Array.from(R)])},A=R=>{const M=Array.from(R.clipboardData.files);M.length&&(R.preventDefault(),C(M))},N=R=>{R.preventDefault(),C(R.dataTransfer.files)},_=R=>p(M=>M.filter((P,E)=>E!==R));u.useEffect(()=>{if(!b)return;const R=M=>{w.current&&!w.current.contains(M.target)&&y(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[b]);const L=async()=>{try{const R=await navigator.mediaDevices.getDisplayMedia({video:!0}),M=document.createElement("video");M.srcObject=R,M.muted=!0,await new Promise(E=>{M.onloadedmetadata=()=>{M.play(),E()}}),await new Promise(E=>setTimeout(E,120));const P=document.createElement("canvas");P.width=M.videoWidth,P.height=M.videoHeight,P.getContext("2d").drawImage(M,0,0),R.getTracks().forEach(E=>E.stop()),P.toBlob(E=>{if(!E)return;const T=new File([E],`ekran-${Date.now()}.png`,{type:"image/png"});C([T]),i(O=>O.trim()?O:"Bu ekranı analiz et ve ne gördüğünü açıkla."),te.success("Ekran yakalandı — göndermek için ▶ basın.")},"image/png",.9)}catch(R){(R==null?void 0:R.name)!=="NotAllowedError"&&te.error("Ekran yakalanamadı.")}},B=R=>{if(R==="screen-sense"){L(),y(!1);return}m(M=>M.includes(R)?M.filter(P=>P!==R):[...M,R])},z=()=>{var P;const R=a.trim();if(!R||n)return;o&&(x.current=!1,(P=v.current)==null||P.stop(),d(""));const M=[...h];i(""),p([]),e(R,f.length>0?f:void 0,M.length>0?M:void 0)};u.useEffect(()=>{g.current&&(g.current.style.height="auto",g.current.style.height=`${Math.min(g.current.scrollHeight,160)}px`)},[a]),u.useEffect(()=>{const R=M=>{var E;const P=((E=M.detail)==null?void 0:E.text)??"";i(P),setTimeout(()=>{var T;return(T=g.current)==null?void 0:T.focus()},60)};return window.addEventListener("mustb:prefill",R),()=>window.removeEventListener("mustb:prefill",R)},[]);const $=o?c||r.chat.listening:"What do you want to know?";return s.jsx("div",{className:"max-w-3xl mx-auto w-full",children:s.jsxs("div",{className:"glass-input rounded-2xl flex flex-col px-4 pt-3 pb-3 gap-2.5",onPaste:A,onDrop:N,onDragOver:R=>R.preventDefault(),children:[h.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 px-1",children:h.map((R,M)=>s.jsxs("div",{className:"relative group w-12 h-12",children:[R.type.startsWith("image/")?s.jsx("img",{src:URL.createObjectURL(R),alt:R.name,className:"w-12 h-12 object-cover rounded-lg border border-orange-500/20"}):s.jsx("div",{className:"w-12 h-12 rounded-lg border border-orange-500/20 bg-orange-500/10 flex items-center justify-center",children:s.jsx(nn,{size:16,className:"text-orange-400"})}),s.jsx("button",{onClick:()=>_(M),className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(ze,{size:9})})]},M))}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs("div",{ref:w,className:"flex items-center gap-0.5 mb-0.5 shrink-0 relative",children:[s.jsx("button",{type:"button",onClick:()=>y(R=>!R),title:"Araçlar",className:`p-2 rounded-full transition-all ${b||f.length>0?"text-orange-400 bg-orange-500/15 border border-orange-500/25":"text-white/30 hover:text-white/70 hover:bg-white/8"}`,children:s.jsx(up,{size:16})}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.97},transition:{duration:.14,ease:[.22,1,.36,1]},className:"absolute bottom-full mb-2 left-0 z-50 w-52 rounded-2xl p-2 shadow-2xl",style:{background:"rgba(16,7,2,0.97)",border:"1px solid rgba(249,115,22,0.18)",backdropFilter:"blur(24px)"},children:[s.jsx("p",{className:"px-2.5 pt-1.5 pb-1 text-[9.5px] font-black uppercase tracking-[0.14em] text-orange-400/60",children:"Araçlar"}),y0.map(({id:R,label:M,Icon:P})=>{const E=f.includes(R);return s.jsxs("button",{onClick:()=>B(R),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-xl transition-all text-left ${E?"bg-orange-500/15 text-orange-300":"text-white/55 hover:bg-white/6 hover:text-white/90"}`,children:[s.jsx(P,{size:13,className:E?"text-orange-400":"text-white/30"}),s.jsx("span",{className:"text-[12px] font-medium",children:M}),E&&s.jsx("span",{className:"ml-auto w-3.5 h-3.5 rounded-full bg-orange-500/30 border border-orange-500/60 flex items-center justify-center text-[8px] text-orange-300",children:"✓"})]},R)})]})}),s.jsxs("label",{className:"p-2 rounded-full cursor-pointer text-white/30 hover:text-white/70 hover:bg-white/8 transition-all",title:r.chat.attachFile,children:[s.jsx(D3,{size:16}),s.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:R=>R.target.files&&C(R.target.files)})]})]}),s.jsx("textarea",{ref:g,value:a,onChange:R=>i(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),z())},placeholder:$,disabled:n,rows:1,className:"flex-1 bg-transparent text-white/90 placeholder-white/35 text-[15px] outline-none resize-none min-h-[28px] max-h-[160px] scrollbar-hide leading-relaxed"}),s.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5 shrink-0",children:[j&&s.jsx("button",{onClick:S,title:o?"Stop dictation":"Start voice dictation (append mode)",className:`p-2 rounded-full transition-all ${o?"text-red-400 bg-red-500/15 border border-red-500/30 shadow-[0_0_10px_rgba(239,68,68,0.3)]":"text-white/40 hover:text-white/70 hover:bg-white/8"}`,children:o?s.jsx(h3,{size:17,className:"animate-pulse"}):s.jsx(Gr,{size:17})}),n?s.jsx("button",{onClick:t,title:"Durdur",className:"w-9 h-9 rounded-full flex items-center justify-center transition-all bg-red-600/80 hover:bg-red-500 text-white shadow-[0_0_12px_rgba(239,68,68,0.5)] active:scale-95",children:s.jsx($l,{size:14})}):s.jsx("button",{onClick:z,disabled:!a.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center transition-all ${a.trim()?"bg-orange-600 hover:bg-orange-500 text-white shadow-[0_0_15px_rgba(249,115,22,0.4)] active:scale-95":"bg-white/10 text-white/25 cursor-not-allowed"}`,children:s.jsx(cp,{size:16})})]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 flex-1",children:f.map(R=>{const M=y0.find(T=>T.id===R);if(!M)return null;const{Icon:P,label:E}=M;return s.jsxs("span",{className:"flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-orange-500/15 border border-orange-500/25 text-orange-300 text-[11px] font-medium",children:[s.jsx(P,{size:10}),s.jsx("span",{children:E}),s.jsx("button",{type:"button",onClick:()=>B(R),className:"ml-0.5 p-0.5 rounded-full hover:bg-orange-500/20 text-orange-400/60 hover:text-orange-300 transition-colors",children:s.jsx(ze,{size:9})})]},R)})}):s.jsx("div",{className:"flex-1"}),s.jsx(aE,{})]})]})})}function yE(){const{t:e,setLocale:t}=yt(),n=u.useRef(e);u.useEffect(()=>{n.current=e},[e]);const[r]=aj(),a=gt(),i=r.get("chat")??"default",o=u.useRef(null),[l,c]=u.useState(null),[d,h]=u.useState(null),[p,f]=u.useState(""),[m,b]=u.useState(null),[y,v]=u.useState([]),x=u.useRef(null),g=u.useRef(null),w=u.useRef(i),[j,k]=u.useState(!1),[S,C]=u.useState(null),A=y.some(z=>z.kind==="assistant"&&z.status==="pending");u.useEffect(()=>{w.current=i,x.current=null,i!=="default"?U(`/api/chats/${i}/messages`).then(async z=>{if(z.ok){const $=await z.json();Array.isArray($)&&v($)}}).catch(()=>{}):v([])},[i]),u.useEffect(()=>{if(i==="default"||!o.current)return;const z=o.current;o.current=null,setTimeout(()=>L(z.text,z.tools,z.files),0)},[i]),u.useEffect(()=>{const z=pe();return z.on("thought_stream",$=>{const R=x.current;if(!R)return;const M=($.message??"").trim();M&&(M.length>200||M.includes("|")||M.includes(`
|
|
743
|
-
`)||v(P=>P.map(E=>E.id===R?{...E,thoughts:[...E.thoughts,
|
|
744
|
-
A: ${
|
|
745
|
-
`)){const oe=ce.trim();if(oe.startsWith("data: ")&&oe!=="data: [DONE]")try{const de=JSON.parse(oe.slice(6));if(de.error)throw new Error(de.error);de.chunk&&(X+=de.chunk,v(Et=>Et.map(bs=>bs.id===D?{...bs,content:X}:bs)))}catch{}}}v(le=>le.map(H=>H.id===D?{...H,status:"done"}:H))}catch(K){v(F=>F.map(Q=>Q.id===D?{...Q,status:"error",content:K.message||"Bir hata oluştu."}:Q))}finally{k(!1)}return}const G={goal:
|
|
746
|
-
`).length+1),className:"w-full rounded-2xl px-5 py-3 text-white text-[14px] leading-relaxed resize-none outline-none",style:{background:"rgba(25,10,2,0.85)",border:"1px solid rgba(249,115,22,0.5)",backdropFilter:"blur(12px)"}}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:()=>h(null),className:"px-3 py-1.5 rounded-xl text-[12px] text-white/40 hover:text-white/70 border border-white/10 hover:bg-white/5 transition-all",children:"Cancel"}),s.jsx("button",{onClick:()=>{const X=p.trim();if(!X)return;const le=y.findIndex(H=>H.id===
|
|
742
|
+
…`:e.content;return s.jsxs("div",{className:"mb-3 rounded-xl overflow-hidden font-mono text-[10px]",style:{background:"#060d1a",border:`1px solid ${r?"rgba(52,211,153,0.18)":"rgba(99,179,237,0.15)"}`},children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/6",style:{background:"#0c1528"},children:[s.jsx(en,{size:9,className:r?"text-emerald-400/70 shrink-0":"text-sky-400/60 shrink-0"}),s.jsx("span",{className:"text-white/50 truncate flex-1",children:e.filename}),s.jsx("span",{className:`text-[9px] font-bold tracking-widest uppercase shrink-0 ${r?"text-emerald-400/60":"text-sky-400/50"}`,children:r?"SAVED":"READ"}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e.content).catch(()=>{}),n(!0),setTimeout(()=>n(!1),2e3)},className:"ml-2 text-white/25 hover:text-white/60 transition-colors shrink-0",title:"Copy content",children:t?s.jsx(it,{size:9,className:"text-green-400"}):s.jsx(Vs,{size:9})})]}),s.jsx("div",{className:"px-3 py-2 max-h-52 overflow-y-auto scrollbar-hide",children:s.jsx("pre",{className:"text-[10px] leading-relaxed whitespace-pre-wrap break-all",style:{color:r?"rgba(52,211,153,0.7)":"rgba(147,197,253,0.65)"},children:a})})]})}function fE({workflow:e,onDismiss:t}){const[n,r]=u.useState("idle"),[a,i]=u.useState(e.goal.slice(0,52)+(e.goal.length>52?"…":"")),o=async()=>{r("saving");try{const l=await U("/api/skills/save",{method:"POST",body:JSON.stringify({goal:e.goal,answer:e.answer,steps:e.steps,name:a.trim()||void 0})});if(!l.ok)throw new Error(`HTTP ${l.status}`);r("saved"),setTimeout(t,1800)}catch{r("error"),setTimeout(()=>r("idle"),3e3)}};return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.2},className:"mt-3",children:s.jsx("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-orange-900/20 border border-orange-600/30",children:n==="saved"?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:13,className:"text-orange-400 shrink-0"}),s.jsx("span",{className:"text-xs font-medium text-orange-400",children:"Skill saved!"})]}):s.jsxs(s.Fragment,{children:[s.jsx(sv,{size:13,className:"text-orange-600 shrink-0"}),s.jsx("span",{className:"text-[11px] text-orange-200 shrink-0 font-medium",children:"Save as Skill:"}),s.jsx("input",{value:a,onChange:l=>i(l.target.value),onKeyDown:l=>l.key==="Enter"&&n==="idle"&&o(),placeholder:"Skill name…",className:"flex-1 bg-transparent text-[12px] text-orange-100 outline-none placeholder-orange-600/50 min-w-0"}),s.jsx("button",{onClick:o,disabled:n!=="idle",className:"flex items-center gap-1 px-3 py-1 rounded-lg bg-orange-900/30 hover:bg-orange-900/50 border border-orange-800/40 text-orange-200 text-[11px] font-semibold transition-all shrink-0 disabled:opacity-50",children:n==="saving"?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:10,className:"animate-spin"})," Saving…"]}):n==="error"?"Retry":"Save"}),s.jsx("button",{onClick:t,className:"text-orange-700 hover:text-orange-500 transition-colors text-[11px] shrink-0",children:"✕"})]})})})}function mE({src:e,onClose:t}){const[n,r]=u.useState(!1);u.useEffect(()=>{const o=l=>{l.key==="Escape"&&t()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]);const a=()=>{const o=document.createElement("a");o.href=e,o.download=`mustb-image-${Date.now()}.jpg`,o.click()},i=async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch{}};return s.jsxs("div",{className:"fixed inset-0 z-[9999] flex flex-col items-center justify-center bg-black/90 backdrop-blur-sm",onClick:t,children:[s.jsxs("div",{className:"absolute top-5 right-5 flex items-center gap-2",onClick:o=>o.stopPropagation(),children:[s.jsxs("button",{onClick:i,title:"Copy link",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white text-[12px] font-medium transition-all",children:[n?s.jsx(it,{size:14,className:"text-green-400"}):s.jsx(Vs,{size:14}),n?"Copied!":"Copy"]}),s.jsxs("button",{onClick:a,title:"Download image",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white text-[12px] font-medium transition-all",children:[s.jsx(Os,{size:14}),"Download"]}),s.jsx("button",{onClick:t,className:"w-9 h-9 flex items-center justify-center rounded-full bg-white/10 hover:bg-white/20 text-white/80 hover:text-white transition-all",children:s.jsx(ze,{size:18})})]}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-[90vw] max-h-[85vh] object-contain rounded-2xl shadow-2xl",onClick:o=>o.stopPropagation()})]})}class xE extends u.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t.message??"Unknown error"}}componentDidCatch(t,n){console.error("[ChatErrorBoundary]",t,n.componentStack)}render(){return this.state.error?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx("span",{className:"text-2xl",children:"⚠️"}),s.jsx("p",{className:"text-red-400 font-bold text-sm",children:"Chat render error"}),s.jsx("p",{className:"text-orange-200/70 text-xs font-mono max-w-sm break-all",children:this.state.error}),s.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-1 px-4 py-2 rounded-xl bg-orange-900/20 border border-orange-800/30 text-orange-200 text-xs font-bold hover:bg-orange-900/40 transition-all",children:"Retry"})]}):this.props.children}}const y0=[{id:"terminal",label:"Terminal",Icon:Mn},{id:"browser",label:"Browser",Icon:Ge},{id:"image-gen",label:"Görsel Üret",Icon:fv},{id:"web-search",label:"Web Search",Icon:fn},{id:"file-manager",label:"Files",Icon:Ln},{id:"code",label:"Code",Icon:en},{id:"screen-sense",label:"Ekranı Gör",Icon:op}];function gE({onSend:e,onStop:t,disabled:n}){const{t:r}=yt(),[a,i]=u.useState(""),[o,l]=u.useState(!1),[c,d]=u.useState(""),[h,p]=u.useState([]),[f,m]=u.useState([]),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useRef(!1),g=u.useRef(null),w=u.useRef(null),j=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition),k=()=>{const R=window.SpeechRecognition||window.webkitSpeechRecognition;if(!R)return;const z=new R;z.continuous=!0,z.interimResults=!0,z.lang="tr-TR",z.onresult=P=>{let E="",T="";for(let O=P.resultIndex;O<P.results.length;O++)P.results[O].isFinal?E+=P.results[O][0].transcript:T+=P.results[O][0].transcript;E?(i(O=>(O.trim()?O.trimEnd()+" ":"")+E.trim()),d("")):d(T)},z.onend=()=>{d(""),x.current?setTimeout(k,150):(l(!1),v.current=null)},z.onerror=P=>{P.error!=="no-speech"&&l(!1),d(""),x.current&&P.error!=="not-allowed"&&setTimeout(k,500)},v.current=z;try{z.start()}catch{}},S=()=>{var R;o?(x.current=!1,(R=v.current)==null||R.stop(),d("")):(x.current=!0,l(!0),k())},C=R=>{p(z=>[...z,...Array.from(R)])},A=R=>{const z=Array.from(R.clipboardData.files);z.length&&(R.preventDefault(),C(z))},N=R=>{R.preventDefault(),C(R.dataTransfer.files)},_=R=>p(z=>z.filter((P,E)=>E!==R));u.useEffect(()=>{if(!b)return;const R=z=>{w.current&&!w.current.contains(z.target)&&y(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[b]);const L=async()=>{try{const R=await navigator.mediaDevices.getDisplayMedia({video:!0}),z=document.createElement("video");z.srcObject=R,z.muted=!0,await new Promise(E=>{z.onloadedmetadata=()=>{z.play(),E()}}),await new Promise(E=>setTimeout(E,120));const P=document.createElement("canvas");P.width=z.videoWidth,P.height=z.videoHeight,P.getContext("2d").drawImage(z,0,0),R.getTracks().forEach(E=>E.stop()),P.toBlob(E=>{if(!E)return;const T=new File([E],`ekran-${Date.now()}.png`,{type:"image/png"});C([T]),i(O=>O.trim()?O:"Bu ekranı analiz et ve ne gördüğünü açıkla."),te.success("Ekran yakalandı — göndermek için ▶ basın.")},"image/png",.9)}catch(R){(R==null?void 0:R.name)!=="NotAllowedError"&&te.error("Ekran yakalanamadı.")}},B=R=>{if(R==="screen-sense"){L(),y(!1);return}m(z=>z.includes(R)?z.filter(P=>P!==R):[...z,R])},M=()=>{var P;const R=a.trim();if(!R||n)return;o&&(x.current=!1,(P=v.current)==null||P.stop(),d(""));const z=[...h];i(""),p([]),e(R,f.length>0?f:void 0,z.length>0?z:void 0)};u.useEffect(()=>{g.current&&(g.current.style.height="auto",g.current.style.height=`${Math.min(g.current.scrollHeight,160)}px`)},[a]),u.useEffect(()=>{const R=z=>{var E;const P=((E=z.detail)==null?void 0:E.text)??"";i(P),setTimeout(()=>{var T;return(T=g.current)==null?void 0:T.focus()},60)};return window.addEventListener("mustb:prefill",R),()=>window.removeEventListener("mustb:prefill",R)},[]);const $=o?c||r.chat.listening:"What do you want to know?";return s.jsx("div",{className:"max-w-3xl mx-auto w-full",children:s.jsxs("div",{className:"glass-input rounded-2xl flex flex-col px-4 pt-3 pb-3 gap-2.5",onPaste:A,onDrop:N,onDragOver:R=>R.preventDefault(),children:[h.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 px-1",children:h.map((R,z)=>s.jsxs("div",{className:"relative group w-12 h-12",children:[R.type.startsWith("image/")?s.jsx("img",{src:URL.createObjectURL(R),alt:R.name,className:"w-12 h-12 object-cover rounded-lg border border-orange-500/20"}):s.jsx("div",{className:"w-12 h-12 rounded-lg border border-orange-500/20 bg-orange-500/10 flex items-center justify-center",children:s.jsx(nn,{size:16,className:"text-orange-400"})}),s.jsx("button",{onClick:()=>_(z),className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-red-500 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(ze,{size:9})})]},z))}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs("div",{ref:w,className:"flex items-center gap-0.5 mb-0.5 shrink-0 relative",children:[s.jsx("button",{type:"button",onClick:()=>y(R=>!R),title:"Araçlar",className:`p-2 rounded-full transition-all ${b||f.length>0?"text-orange-400 bg-orange-500/15 border border-orange-500/25":"text-white/30 hover:text-white/70 hover:bg-white/8"}`,children:s.jsx(up,{size:16})}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.97},transition:{duration:.14,ease:[.22,1,.36,1]},className:"absolute bottom-full mb-2 left-0 z-50 w-52 rounded-2xl p-2 shadow-2xl",style:{background:"rgba(16,7,2,0.97)",border:"1px solid rgba(249,115,22,0.18)",backdropFilter:"blur(24px)"},children:[s.jsx("p",{className:"px-2.5 pt-1.5 pb-1 text-[9.5px] font-black uppercase tracking-[0.14em] text-orange-400/60",children:"Araçlar"}),y0.map(({id:R,label:z,Icon:P})=>{const E=f.includes(R);return s.jsxs("button",{onClick:()=>B(R),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-xl transition-all text-left ${E?"bg-orange-500/15 text-orange-300":"text-white/55 hover:bg-white/6 hover:text-white/90"}`,children:[s.jsx(P,{size:13,className:E?"text-orange-400":"text-white/30"}),s.jsx("span",{className:"text-[12px] font-medium",children:z}),E&&s.jsx("span",{className:"ml-auto w-3.5 h-3.5 rounded-full bg-orange-500/30 border border-orange-500/60 flex items-center justify-center text-[8px] text-orange-300",children:"✓"})]},R)})]})}),s.jsxs("label",{className:"p-2 rounded-full cursor-pointer text-white/30 hover:text-white/70 hover:bg-white/8 transition-all",title:r.chat.attachFile,children:[s.jsx(D3,{size:16}),s.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:R=>R.target.files&&C(R.target.files)})]})]}),s.jsx("textarea",{ref:g,value:a,onChange:R=>i(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),M())},placeholder:$,disabled:n,rows:1,className:"flex-1 bg-transparent text-white/90 placeholder-white/35 text-[15px] outline-none resize-none min-h-[28px] max-h-[160px] scrollbar-hide leading-relaxed"}),s.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5 shrink-0",children:[j&&s.jsx("button",{onClick:S,title:o?"Stop dictation":"Start voice dictation (append mode)",className:`p-2 rounded-full transition-all ${o?"text-red-400 bg-red-500/15 border border-red-500/30 shadow-[0_0_10px_rgba(239,68,68,0.3)]":"text-white/40 hover:text-white/70 hover:bg-white/8"}`,children:o?s.jsx(h3,{size:17,className:"animate-pulse"}):s.jsx(Gr,{size:17})}),n?s.jsx("button",{onClick:t,title:"Durdur",className:"w-9 h-9 rounded-full flex items-center justify-center transition-all bg-red-600/80 hover:bg-red-500 text-white shadow-[0_0_12px_rgba(239,68,68,0.5)] active:scale-95",children:s.jsx($l,{size:14})}):s.jsx("button",{onClick:M,disabled:!a.trim(),className:`w-9 h-9 rounded-full flex items-center justify-center transition-all ${a.trim()?"bg-orange-600 hover:bg-orange-500 text-white shadow-[0_0_15px_rgba(249,115,22,0.4)] active:scale-95":"bg-white/10 text-white/25 cursor-not-allowed"}`,children:s.jsx(cp,{size:16})})]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 flex-1",children:f.map(R=>{const z=y0.find(T=>T.id===R);if(!z)return null;const{Icon:P,label:E}=z;return s.jsxs("span",{className:"flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-orange-500/15 border border-orange-500/25 text-orange-300 text-[11px] font-medium",children:[s.jsx(P,{size:10}),s.jsx("span",{children:E}),s.jsx("button",{type:"button",onClick:()=>B(R),className:"ml-0.5 p-0.5 rounded-full hover:bg-orange-500/20 text-orange-400/60 hover:text-orange-300 transition-colors",children:s.jsx(ze,{size:9})})]},R)})}):s.jsx("div",{className:"flex-1"}),s.jsx(aE,{})]})]})})}function yE(){const{t:e,setLocale:t}=yt(),n=u.useRef(e);u.useEffect(()=>{n.current=e},[e]);const[r]=aj(),a=gt(),i=r.get("chat")??"default",o=u.useRef(null),[l,c]=u.useState(null),[d,h]=u.useState(null),[p,f]=u.useState(""),[m,b]=u.useState(null),[y,v]=u.useState([]),x=u.useRef(null),g=u.useRef(null),w=u.useRef(i),[j,k]=u.useState(!1),[S,C]=u.useState(null),A=y.some(M=>M.kind==="assistant"&&M.status==="pending");u.useEffect(()=>{w.current=i,x.current=null,i!=="default"?U(`/api/chats/${i}/messages`).then(async M=>{if(M.ok){const $=await M.json();Array.isArray($)&&v($)}}).catch(()=>{}):v([])},[i]),u.useEffect(()=>{if(i==="default"||!o.current)return;const M=o.current;o.current=null,setTimeout(()=>L(M.text,M.tools,M.files),0)},[i]),u.useEffect(()=>{const M=pe();return M.on("thought_stream",$=>{const R=x.current;if(!R)return;const z=($.message??"").trim();z&&(z.length>200||z.includes("|")||z.includes(`
|
|
743
|
+
`)||v(P=>P.map(E=>E.id===R?{...E,thoughts:[...E.thoughts,z]}:E)))}),M.on("agentUpdate",$=>{const{type:R,...z}=$;if(R==="memorySearch")return;if(R==="planStart"){const T=`asst-${Date.now()}-${Math.random().toString(36).slice(2)}`;x.current=T,v(O=>[...O,{id:T,kind:"assistant",content:"",thoughts:[],steps:[],status:"pending",startedAt:Date.now()}]);return}if(R==="stepStart"){const T=x.current;if(!T)return;const O=z.step,G=(O==null?void 0:O.description)??Yt(z.step);v(D=>D.map(K=>K.id===T?{...K,steps:[...K.steps??[],{label:G,status:"running"}]}:K));return}if(R==="stepFinish"){const T=x.current;if(!T)return;const O=z.status==="error",G=z.step,D=(G==null?void 0:G.description)??"Step",K=z.result!==void 0?Yt(z.result):void 0,F=K&&K.length>120?K.slice(0,120)+"…":K;v(Q=>Q.map(q=>{if(q.id!==T)return q;const X=[...q.steps??[]],le=X.map(ce=>ce.status).lastIndexOf("running");le>=0&&(X[le]={label:D,status:O?"error":"done",result:F});const H=[...q.terminals??[]],se=H.map(ce=>ce.status).lastIndexOf("running");return se>=0&&(H[se]={...H[se],status:O?"error":"done"}),{...q,steps:X,...H.length>0?{terminals:H}:{}}}));return}if(R==="codeArtifact"){const T=x.current;if(!T)return;const O={id:`code-${Date.now()}-${Math.random().toString(36).slice(2)}`,filename:String(z.filename??"file"),lang:String(z.lang??"text"),content:String(z.content??""),op:z.op??"read"};v(G=>G.map(D=>D.id===T?{...D,codeArtifacts:[...D.codeArtifacts??[],O]}:D));return}if(R==="terminalLog"){const T=x.current;if(!T)return;const O=Yt(z.line??"");if(!O)return;v(G=>G.map(D=>{if(D.id!==T)return D;const K=[...D.terminals??[]],F=K.map(H=>H.status).lastIndexOf("running");if(F>=0){const H=K[F];return H.lines.length<200&&(K[F]={...H,lines:[...H.lines,O]}),{...D,terminals:K}}const Q=D.steps??[],q=Q.map(H=>H.status).lastIndexOf("running"),X=q>=0?Q[q].label:"shell",le={id:`term-${Date.now()}-${Math.random().toString(36).slice(2)}`,command:X,lines:[O],status:"running"};return{...D,terminals:[...K,le]}}));return}if(R==="resourceWarning"){const T=x.current;if(!T)return;const O=Yt(z.message??"⚠ Sistem Uyarısı: Yüksek kaynak kullanımı");v(G=>G.map(D=>{if(D.id!==T)return D;const K=[...D.steps??[]],F=K.map(X=>X.status).lastIndexOf("running");if(F<0)return D;const Q=K[F],q=Q.logs??[];return K[F]={...Q,logs:[...q,O]},{...D,steps:K}}));return}if(R==="finalAnswer"){const T=x.current;if(!T)return;v(O=>O.map(G=>G.id===T?{...G,content:Yt(z.answer??"Done.")}:G));return}if(R==="planFinish"){k(!1);const T=x.current;if(!T)return;const O=z.status==="failed"?"error":"done",G=z.status==="completed"?{goal:String(z.goal??""),answer:String(z.answer??""),steps:z.steps??[]}:void 0;v(D=>D.map(K=>K.id===T?{...K,status:O,...G?{workflow:G}:{}}:K)),x.current=null;return}if(R==="professionResearched"){const T=String(z.profession??"");if(!T)return;const O=n.current.chat.professionAck.replace("{profession}",T);v(G=>[...G,{id:`prof-ack-${Date.now()}`,kind:"assistant",content:O,thoughts:[],status:"done"}]);return}const P=iE(R,z);if(!P)return;const E=x.current;E&&v(T=>T.map(O=>O.id===E?{...O,thoughts:[...O.thoughts,P]}:O))}),()=>{M.off("thought_stream"),M.off("agentUpdate")}},[]),u.useEffect(()=>{var M;(M=g.current)==null||M.scrollIntoView({behavior:"smooth"})},[y]),u.useEffect(()=>{const M=async()=>{var R;const $=x.current;if($)try{const z=await U("/api/goal/status");if(!z.ok)return;const P=await z.json();if(!P.busy||!((R=P.events)!=null&&R.length))return;for(const E of P.events)if(E.type==="stepStart"){const T=E.step,O=(T==null?void 0:T.description)??"";v(G=>G.map(D=>D.id===$?{...D,steps:[...D.steps??[],{label:O,status:"running"}]}:D))}else if(E.type==="stepFinish"){const T=E.step,O=(T==null?void 0:T.description)??"Step",G=E.result!==void 0?String(E.result).slice(0,120):void 0;v(D=>D.map(K=>{if(K.id!==$)return K;const F=[...K.steps??[]],Q=F.map(q=>q.status).lastIndexOf("running");return Q>=0&&(F[Q]={label:O,status:E.status==="error"?"error":"done",result:G}),{...K,steps:F}}))}else if(E.type==="finalAnswer"){const T=String(E.answer??"");T&&v(O=>O.map(G=>G.id===$?{...G,content:T}:G))}else if(E.type==="planFinish"){k(!1);const T=E.status==="failed"?"error":"done";v(O=>O.map(G=>G.id===$?{...G,status:T}:G)),x.current=null}}catch{}};return window.addEventListener("mustb:reconnected",M),()=>window.removeEventListener("mustb:reconnected",M)},[]),u.useEffect(()=>{const M=$=>{var E;const R=(E=$.detail)==null?void 0:E.skill;if(!R)return;const P={"web-search":"Search the web for: ","web-fetch":"Fetch and summarize this URL: ",browser:"Open the browser and navigate to: ",pdf:"Read and summarize this PDF: ","image-analysis":"Analyze this image: ","image-generate":"Generate an image of: ",tts:"Convert this text to speech: ","spawn-agent":"Spawn a new agent to: ",sessions:"List all active agent sessions",canvas:"Open the canvas workspace",git:"Run a git operation: ",gateway:"Connect to Must-b gateway node: ","file-manager":"Open the file manager",cron:"Create a scheduled task: ",messages:"Check and reply to messages","memory-add":"Save this to memory: ",contacts:"Look up contact: ",calendar:"Check my calendar for: ",automations:"Create an automation that: ","scheduled-tasks":"List all scheduled tasks",commands:"Run this command: ",nodes:"List all gateway nodes","multi-agent":"Start a multi-agent workflow to: ","chat-focus":""}[R]??`Run skill "${R}": `;window.dispatchEvent(new CustomEvent("mustb:prefill",{detail:{text:P}}))};return window.addEventListener("mustb:invoke-skill",M),()=>window.removeEventListener("mustb:invoke-skill",M)},[]),u.useEffect(()=>{w.current===i&&i!=="default"&&U(`/api/chats/${i}/messages`,{method:"POST",body:JSON.stringify({messages:y})}).catch(()=>{})},[y,i]),u.useEffect(()=>{if(!j)return;let M=null;const $=setTimeout(()=>{M=setInterval(async()=>{try{const R=await U("/api/status");if(!R.ok)return;(await R.json()).busy===!1&&(M&&(clearInterval(M),M=null),k(!1),v(P=>P.map(E=>E.status!=="pending"?E:{...E,status:E.content?"done":"error",content:E.content||"Görev tamamlandı ancak sonuç alınamadı (bağlantı koptu). Lütfen tekrar deneyin."})),x.current=null)}catch{}},5e3)},1e4);return()=>{clearTimeout($),M&&clearInterval(M)}},[j]),u.useEffect(()=>{const M=y[y.length-1];if(!M||M.kind!=="assistant"||M.status!=="done"||!M.content)return;const $=[...y].reverse().find(z=>z.kind==="user");if(!$)return;const R=`Q: ${$.content}
|
|
744
|
+
A: ${M.content.slice(0,400)}`;fetch("/api/memory/ltm/semantic",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:R,tags:["chat","autosave"]})}).catch(()=>{})},[y.length]);const N=M=>{const $=[[/\b(spanish mode|speak spanish|habla español|en español)\b/i,"es"],[/\b(french mode|speak french|en français|parle français)\b/i,"fr"],[/\b(german mode|speak german|auf deutsch|deutsch mode)\b/i,"de"],[/\b(japanese mode|speak japanese|日本語モード)\b/i,"ja"],[/\b(chinese mode|speak chinese|中文模式)\b/i,"zh"],[/\b(portuguese mode|fala português)\b/i,"pt"],[/\b(turkish mode|türkçe mode|türkçe konuş)\b/i,"tr"],[/\b(english mode|switch to english|speak english)\b/i,"en"]],R={tr:"Anlaşıldı, ayarlar kalıcı olarak güncellendi.",en:"Got it, settings updated permanently.",es:"Entendido, configuración actualizada permanentemente.",fr:"Compris, paramètres mis à jour définitivement.",de:"Verstanden, Einstellungen dauerhaft aktualisiert.",ja:"了解です。設定が永久に更新されました。",zh:"明白,设置已永久更新。",pt:"Entendido, configurações atualizadas permanentemente."};for(const[P,E]of $)if(P.test(M)){t(E);const T=R[E]??R.en;return v(O=>[...O,{id:`cfg-lang-${Date.now()}`,kind:"assistant",content:T,thoughts:[],status:"done"}]),!0}const z=[[/use\s+gpt[-\s]?4o?\b/i,"openai/gpt-4o"],[/use\s+(claude[-\s]?3\.5|claude[-\s]?sonnet|claude[-\s]?opus)\b/i,"anthropic/claude-3-5-sonnet"],[/use\s+(gemini[-\s]?flash|gemini[-\s]?pro|gemini)\b/i,"google/gemini-flash"],[/use\s+(llama[-\s]?3|llama)\b/i,"meta-llama/llama-3-70b-instruct:free"],[/use\s+mistral\b/i,"mistralai/mistral-7b-instruct:free"],[/use\s+deepseek\b/i,"deepseek/deepseek-chat"]];for(const[P,E]of z)if(P.test(M))return U("/api/settings/model",{method:"POST",body:JSON.stringify({model:E})}).catch(()=>{}),v(T=>[...T,{id:`cfg-model-${Date.now()}`,kind:"assistant",content:e.chat.settingsAck,thoughts:[],status:"done"}]),!0;return!1},_=M=>{const $=[[/\bi(?:'m| am)\s+a(?:n)?\s+(lawyer|attorney|solicitor|barrister)\b/i,"lawyer"],[/\bi(?:'m| am)\s+a(?:n)?\s+(doctor|physician|nurse|surgeon|pharmacist)\b/i,"medical"],[/\bi(?:'m| am)\s+a(?:n?)?\s+(software engineer|developer|programmer|coder)\b/i,"software-engineer"],[/\bi(?:'m| am)\s+a(?:n)?\s+(teacher|professor|educator|instructor)\b/i,"educator"],[/\bi(?:'m| am)\s+a(?:n)?\s+(accountant|auditor|financial advisor|analyst)\b/i,"finance"],[/\bi(?:'m| am)\s+a(?:n)?\s+(architect|civil engineer|structural engineer)\b/i,"engineering"],[/\bi(?:'m| am)\s+a(?:n)?\s+(designer|ux designer|graphic designer)\b/i,"designer"],[/\bi(?:'m| am)\s+a(?:n?)?\s+(data scientist|ml engineer|ai researcher)\b/i,"data-science"],[/\bben\s+bir?\s+avukat\b/i,"lawyer"],[/\bavukat(?:ım|ım)?\b/i,"lawyer"],[/\bben\s+bir?\s+doktor\b/i,"medical"],[/\bdoktor(?:um|um)?\b/i,"medical"],[/\bben\s+bir?\s+hemşire\b/i,"medical"],[/\bben\s+bir?\s+mühendis\b/i,"engineering"],[/\bmühendis(?:im|im)?\b/i,"engineering"],[/\bben\s+bir?\s+yazılımcı\b/i,"software-engineer"],[/\byazılımcı(?:yım|yım)?\b/i,"software-engineer"],[/\bben\s+bir?\s+öğretmen\b/i,"educator"],[/\böğretmen(?:im|im)?\b/i,"educator"],[/\bben\s+bir?\s+muhasebeci\b/i,"finance"],[/\bmuhasebeci(?:yim|yim)?\b/i,"finance"],[/\bben\s+bir?\s+tasarımcı\b/i,"designer"],[/\btasarımcı(?:yım|yım)?\b/i,"designer"],[/\bben\s+bir?\s+mimar\b/i,"engineering"],[/\bmimar(?:ım|ım)?\b/i,"engineering"]];for(const[R,z]of $)if(R.test(M)){U("/api/memory/profession-research",{method:"POST",body:JSON.stringify({profession:z,userMessage:M})}).catch(()=>{});break}},L=async(M,$,R)=>{if(M.startsWith("__GUIDANCE__")){const D=M.slice(12);v(K=>[...K,{id:`guidance-${Date.now()}`,kind:"assistant",content:`ℹ ${D}`,thoughts:[],status:"done"}]);return}if(N(M))return;_(M);let z=M;if($!=null&&$.includes("image-gen")&&!M.toLowerCase().startsWith("generate")&&!M.toLowerCase().startsWith("create")&&(z=`Görsel oluştur: ${M}`),i==="default")try{const D=M.trim().split(/\s+/).slice(0,4).join(" "),K=await U("/api/chats",{method:"POST",body:JSON.stringify({title:D})});if(K.ok){const F=await K.json();o.current={text:z,tools:$,files:R},a(`/app?chat=${F.id}`);return}}catch{}if(!y.some(D=>D.kind==="user")&&i!=="default"){const D=M.trim().split(/\s+/).slice(0,4).join(" ");D&&U(`/api/chats/${i}`,{method:"PATCH",body:JSON.stringify({title:D})}).then(()=>{window.dispatchEvent(new CustomEvent("mustb:chat-renamed",{detail:{id:i,title:D}}))}).catch(()=>{})}v(D=>D.map(K=>({...K,workflow:void 0})));const E=R==null?void 0:R.filter(D=>D.type.startsWith("image/")).map(D=>URL.createObjectURL(D)),T={id:`user-${Date.now()}`,kind:"user",content:M,thoughts:[],status:"done",...E!=null&&E.length?{attachments:E}:{}};if(v(D=>[...D,T]),!($!=null&&$.length)&&!(R!=null&&R.length)&&!M.startsWith("/")){const D=`asst-${Date.now()}`;v(K=>[...K,{id:D,kind:"assistant",content:"",thoughts:[],status:"pending"}]),k(!0);try{const K=y.filter(le=>le.status==="done"&&le.content).map(le=>({role:le.kind,content:le.content})),F=await U("/api/chat",{method:"POST",body:JSON.stringify({messages:[...K,{role:"user",content:M}]})});if(!F.ok||!F.body)throw new Error("Sohbet bağlantısı kurulamadı.");const Q=F.body.getReader(),q=new TextDecoder;let X="";for(;;){const{done:le,value:H}=await Q.read();if(le)break;const se=q.decode(H);for(const ce of se.split(`
|
|
745
|
+
`)){const oe=ce.trim();if(oe.startsWith("data: ")&&oe!=="data: [DONE]")try{const de=JSON.parse(oe.slice(6));if(de.error)throw new Error(de.error);de.chunk&&(X+=de.chunk,v(Et=>Et.map(bs=>bs.id===D?{...bs,content:X}:bs)))}catch{}}}v(le=>le.map(H=>H.id===D?{...H,status:"done"}:H))}catch(K){v(F=>F.map(Q=>Q.id===D?{...Q,status:"error",content:K.message||"Bir hata oluştu."}:Q))}finally{k(!1)}return}const G={goal:z};if($&&$.length>0&&(G.focus_tools=$),R&&R.length>0)try{G.attachments=await Promise.all(R.map(async D=>({name:D.name,type:D.type,data:await oE(D)})))}catch{}k(!0);try{await U("/api/goal",{method:"POST",body:JSON.stringify(G)})}catch{k(!1)}},B=y.length>0;return s.jsxs(xE,{children:[l&&s.jsx(mE,{src:l,onClose:()=>c(null)}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:B?s.jsxs("div",{className:"max-w-3xl mx-auto w-full px-5 pt-6 pb-4",children:[y.map(M=>{if(M.kind==="user"){const q=d===M.id;return s.jsx("div",{className:"flex justify-end mb-5 group/userturn",children:s.jsxs("div",{className:q?"w-full max-w-3xl flex flex-col items-end gap-2":"max-w-[78%] flex flex-col items-end gap-2",children:[M.attachments&&M.attachments.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2 justify-end",children:M.attachments.map((X,le)=>s.jsxs("div",{className:"relative group w-24 h-24 shrink-0",children:[s.jsx("img",{src:X,alt:`attachment-${le}`,onClick:()=>c(X),width:96,height:96,className:"w-24 h-24 object-cover rounded-xl border border-orange-500/25 hover:opacity-90 transition-opacity duration-150 cursor-zoom-in",style:{minWidth:96,minHeight:96}}),s.jsx("button",{onClick:H=>{H.stopPropagation(),L("Bu görseli analiz et ve açıkla",void 0,void 0)},title:"Düzenle / Analiz Et",className:"absolute bottom-1 right-1 w-6 h-6 flex items-center justify-center rounded-full bg-black/70 hover:bg-orange-600 opacity-0 group-hover:opacity-100 transition-all duration-150 text-white",children:s.jsx(hu,{size:11})})]},le))}),q?s.jsxs("div",{className:"w-full flex flex-col gap-2",children:[s.jsx("textarea",{autoFocus:!0,value:p,onChange:X=>f(X.target.value),onKeyDown:X=>{if(X.key==="Enter"&&!X.shiftKey){X.preventDefault();const le=p.trim();if(!le)return;const H=y.findIndex(se=>se.id===M.id);v(se=>se.slice(0,H)),h(null),setTimeout(()=>L(le),0)}X.key==="Escape"&&h(null)},rows:Math.min(8,p.split(`
|
|
746
|
+
`).length+1),className:"w-full rounded-2xl px-5 py-3 text-white text-[14px] leading-relaxed resize-none outline-none",style:{background:"rgba(25,10,2,0.85)",border:"1px solid rgba(249,115,22,0.5)",backdropFilter:"blur(12px)"}}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:()=>h(null),className:"px-3 py-1.5 rounded-xl text-[12px] text-white/40 hover:text-white/70 border border-white/10 hover:bg-white/5 transition-all",children:"Cancel"}),s.jsx("button",{onClick:()=>{const X=p.trim();if(!X)return;const le=y.findIndex(H=>H.id===M.id);v(H=>H.slice(0,le)),h(null),setTimeout(()=>L(X),0)},className:"px-3 py-1.5 rounded-xl text-[12px] bg-orange-600 hover:bg-orange-500 text-white font-semibold transition-all",children:"Resend"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"rounded-2xl rounded-br-sm px-5 py-3 text-white text-[14px] leading-relaxed whitespace-pre-wrap",style:{background:"rgba(25,10,2,0.72)",border:"1px solid rgba(249,115,22,0.22)",backdropFilter:"blur(12px)"},children:M.content}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover/userturn:opacity-100 transition-opacity duration-150",children:[s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(M.content).catch(()=>{}),b(M.id),setTimeout(()=>b(null),2e3)},title:"Copy message",className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/6 transition-all",children:m===M.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:10,className:"text-green-400"}),s.jsx("span",{className:"text-green-400",children:"Copied"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Vs,{size:10}),"Copy"]})}),s.jsxs("button",{onClick:()=>{h(M.id),f(M.content)},title:"Edit and resend",className:"flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] text-white/30 hover:text-orange-400 hover:bg-orange-500/8 border border-white/6 transition-all",children:[s.jsx(hu,{size:10}),"Edit"]})]})]})]})},M.id)}const $=M.thoughts.length>0,R=M.content.length>0,z=M.status==="pending",P=M.status==="error"&&!R,E=M.steps??[],T=M.terminals??[],O=T.length>0,G=M.codeArtifacts??[],D=G.length>0,K=z?E.find(q=>q.status==="running"):null,F=E.filter(q=>q.status==="done").length,Q=E.length>0;return s.jsxs("div",{className:"mb-8",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[s.jsxs("div",{className:"relative w-5 h-5 shrink-0",children:[s.jsx("div",{className:"absolute inset-0 bg-orange-600/30 rounded-full blur-sm"}),s.jsx("img",{src:"/logo.png",alt:"Must-b",className:"w-full h-full object-contain relative z-10"})]}),s.jsx("span",{className:"text-[12px] font-semibold text-white/70 tracking-wide",children:"Must-b"}),$&&s.jsxs("span",{className:"text-[10px] text-white/35 font-mono",children:[M.thoughts.length," step",M.thoughts.length!==1?"s":""]})]}),K&&s.jsxs("div",{className:"mb-2 flex items-center gap-2 px-3 py-1.5 rounded-lg",style:{background:"rgba(0,0,0,0.22)",border:"1px solid rgba(255,255,255,0.05)"},children:[s.jsx(ne,{size:10,className:"animate-spin text-orange-400/70 shrink-0"}),s.jsx("span",{className:"text-[11px] font-mono text-white/40 truncate flex-1",children:K.label}),F>0&&s.jsxs("span",{className:"text-[10px] text-white/20 font-mono shrink-0",children:[F," done"]}),s.jsx("div",{className:"ml-1 shrink-0",children:s.jsx(uE,{startedAt:M.startedAt})})]}),O&&T.map(q=>s.jsx(hE,{block:q},q.id)),D&&G.map(q=>s.jsx(pE,{block:q},q.id)),$&&s.jsxs("details",{className:"mb-3 group",style:{background:"rgba(255,255,255,0.025)",borderRadius:"10px",padding:"6px 10px"},children:[s.jsxs("summary",{className:"flex items-center gap-1.5 cursor-pointer list-none select-none w-fit",children:[s.jsx(gn,{size:10,className:"text-orange-400/50 group-open:rotate-90 transition-transform duration-150 flex-shrink-0"}),s.jsxs("span",{className:"text-[10px] font-semibold text-orange-300/50 hover:text-orange-300/80 transition-colors tracking-wide uppercase",children:[M.thoughts.length," detail",M.thoughts.length!==1?"s":""," · Thought process"]})]}),s.jsx("div",{className:"mt-2 ml-3.5 pl-3 border-l border-orange-500/15 space-y-1",children:M.thoughts.map((q,X)=>s.jsx("p",{className:"text-[11px] font-mono text-white/30 leading-relaxed break-all",children:q},X))})]}),R?s.jsxs("div",{className:"w-full py-2",children:[s.jsx(cE,{text:M.content,dark:!0}),s.jsx("div",{className:"flex justify-end mt-3",children:s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(M.content).catch(()=>{}),C(M.id),setTimeout(()=>C(null),2e3)},className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 text-[11px] transition-all border border-white/6",children:S===M.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:12,className:"text-green-400"})," Kopyalandı"]}):s.jsxs(s.Fragment,{children:[s.jsx(Vs,{size:12})," Kopyala"]})})})]}):z?Q?null:s.jsxs("div",{className:"flex items-center gap-2 py-2 px-1",children:[[0,120,240].map(q=>s.jsx("div",{className:"w-1.5 h-1.5 rounded-full animate-bounce",style:{background:"rgba(251,146,60,0.7)",animationDelay:`${q}ms`}},q)),s.jsx("span",{className:"text-[11px] text-white/25 ml-1",children:"Planning…"}),s.jsx(dE,{})]}):P?s.jsxs("div",{className:"rounded-xl px-4 py-3 flex items-center gap-2",style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)"},children:[s.jsx("span",{className:"text-red-400 text-sm",children:"⚠"}),s.jsx("p",{className:"text-sm text-red-300/80",children:"Something went wrong. Please try again."})]}):null,s.jsx(ae,{children:M.workflow&&!z&&s.jsx(fE,{workflow:M.workflow,onDismiss:()=>v(q=>q.map(X=>X.id===M.id?{...X,workflow:void 0}:X))})})]},M.id)}),s.jsx("div",{ref:g,className:"h-2"})]}):s.jsx("div",{className:"flex flex-col items-center justify-center h-full px-6 select-none",children:s.jsx(ae,{children:s.jsx(V.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-10,scale:.96},transition:{duration:.55,ease:"easeOut"},className:"flex flex-col items-center gap-4 mb-10",children:s.jsx("span",{className:"font-black tracking-tighter select-none leading-none px-2 w-full text-center",style:{fontSize:"clamp(56px, 16vw, 120px)",background:"linear-gradient(135deg, rgba(249,115,22,0.92) 0%, rgba(253,186,116,0.75) 40%, rgba(255,255,255,0.30) 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",paddingBottom:"0.05em",paddingRight:"20px"},children:"Must-b"})},"hero")})})}),s.jsxs("div",{className:"shrink-0 px-4 pb-3 pt-2",children:[s.jsx(gE,{onSend:(M,$,R)=>L(M,$,R),onStop:()=>{k(!1),U("/api/goal/abort",{method:"POST"}).catch(()=>{}),v(M=>M.map($=>{if($.status!=="pending")return $;const R=$.content||($.thoughts.length>0?`⏹ Durduruldu.
|
|
747
747
|
|
|
748
748
|
**Tamamlanan adımlar:**
|
|
749
749
|
${$.thoughts.join(`
|
|
750
|
-
`)}`:"⏹ Durduruldu.");return{...$,status:"done",content:R}})),x.current=null},disabled:j||A}),s.jsx("p",{className:"text-center text-[11px] text-white/20 mt-2 select-none",children:e.chat.disclaimer})]})]})]})}function vE(){const[e,t]=u.useState(!1);return u.useEffect(()=>{const n=pe();return n.on("agentUpdate",r=>{r.type==="SCREEN_CAPTURE_START"&&t(!0),(r.type==="SCREEN_CAPTURED"||r.type==="SCREEN_CAPTURE_END")&&setTimeout(()=>t(!1),700)}),()=>{n.off("agentUpdate")}},[]),s.jsx(ae,{children:e&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:"fixed inset-0 z-[9999] pointer-events-none",children:[s.jsxs("div",{className:"absolute inset-0",children:[s.jsx("div",{className:"absolute top-0 left-0 w-12 h-12 border-t-2 border-l-2 border-orange-500/70"}),s.jsx("div",{className:"absolute top-0 right-0 w-12 h-12 border-t-2 border-r-2 border-orange-500/70"}),s.jsx("div",{className:"absolute bottom-0 left-0 w-12 h-12 border-b-2 border-l-2 border-orange-500/70"}),s.jsx("div",{className:"absolute bottom-0 right-0 w-12 h-12 border-b-2 border-r-2 border-orange-500/70"})]}),s.jsx(V.div,{className:"absolute left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-orange-500/60 to-transparent",animate:{top:["0%","100%"]},transition:{duration:1.4,repeat:1/0,ease:"linear"}}),s.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2",children:s.jsxs(V.div,{initial:{y:-10,opacity:0},animate:{y:0,opacity:1},className:"flex items-center gap-2 px-4 py-2 bg-black/80 border border-orange-500/30 rounded-full shadow-[0_0_20px_rgba(234,88,12,0.3)] backdrop-blur-xl",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-orange-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-orange-500"})]}),s.jsx(ui,{size:12,className:"text-orange-400 animate-spin"}),s.jsx("span",{className:"text-orange-300 text-xs font-semibold tracking-wide",children:"Scanning screen…"})]})})]},"scan-overlay")})}const no={button:"rgba(234,88,12,0.7)",input:"rgba(59,130,246,0.7)",image:"rgba(168,85,247,0.6)",unknown:"rgba(255,255,255,0.3)"},bE={browse:Ge,write:nn,think:Zt,exec:Mn},wE={running:"bg-orange-500/8 border border-orange-500/20 text-orange-300",done:"bg-green-500/5 border border-green-500/10 text-gray-500",queued:"bg-white/2 border border-white/5 text-gray-600"},kE={mouseMove:L3,mouseClick:pv,typeText:E3,visionClick:Us},jE={mouseMove:"text-gray-500",mouseClick:"text-orange-400",typeText:"text-blue-400",visionClick:"text-purple-400"};function NE(){const{t:e}=yt(),[t,n]=u.useState(!1),[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useRef(null),[h,p]=u.useState(null),[f,m]=u.useState(!1),[b,y]=u.useState(()=>new Array(3).fill(null)),[v,x]=u.useState(0),[g,w]=u.useState([]),[j,k]=u.useState(null),[S,C]=u.useState([]),A=u.useRef(null),[N,_]=u.useState(!1),[L,B]=u.useState(!1);u.useEffect(()=>{if(!r||!d.current)return;const M=d.current,P=M.getContext("2d");if(!P)return;const E=new Image;E.onload=()=>{var T;if(M.width=E.width,M.height=E.height,P.drawImage(E,0,0),(T=r.elements)!=null&&T.length)for(const O of r.elements)P.strokeStyle=no[O.type]??no.unknown,P.lineWidth=Math.max(2,Math.round(E.width/400)),P.strokeRect(O.x,O.y,O.width,O.height),P.fillStyle=no[O.type]??no.unknown,P.font=`${Math.max(10,Math.round(E.width/120))}px monospace`,P.fillText(O.type,O.x+4,O.y+14)},E.src=`data:image/png;base64,${r.base64}`},[r]),u.useEffect(()=>{const M=pe(),P=E=>{if(E.type==="SCREEN_CAPTURE_START"&&n(!0),E.type==="SCREEN_CAPTURED"&&(n(!1),a({base64:E.base64,width:E.width,height:E.height,source:E.source,elements:E.elements}),_(!1),B(!1)),E.type==="workflowStart"&&(k(E.goal??null),w(E.steps??[]),_(!1),B(!1)),E.type==="workflowStep"&&E.step){const T=E.step;w(O=>O.map(G=>G.id===T.id?T:G))}if(E.type==="workflowDone"&&setTimeout(()=>{w([]),k(null)},2500),E.type==="shadowFrame"&&typeof E.slot!="number"&&(p(E.base64),m(!0),_(!1)),E.type==="shadowToggle"&&typeof E.slot!="number"&&(m(E.enabled),E.enabled||p(null)),E.type==="ghostFrame"){const T=typeof E.slot=="number"?E.slot:-1;T>=0&&T<=2&&typeof E.base64=="string"&&(y(O=>{const G=[...O];return G[T]=E.base64,G}),_(!1))}if(E.type==="ghostSlot"){const T=typeof E.slot=="number"?E.slot:-1;T>=0&&T<=2&&x(T)}if(E.type==="shadowToggle"&&typeof E.slot=="number"){const T=E.slot;T>=0&&T<=2&&!E.enabled&&y(O=>{const G=[...O];return G[T]=null,G})}if(E.type==="inputAction"){const T={id:`${Date.now()}-${Math.random()}`,action:E.action??"mouseClick",label:E.label??"",timestamp:E.timestamp??Date.now()};C(O=>[...O.slice(-11),T]),_(!1),B(!1)}};return M.on("agentUpdate",P),()=>{M.off("agentUpdate",P)}},[]),u.useEffect(()=>{var M;(M=A.current)==null||M.scrollIntoView({behavior:"smooth"})},[S]);const z=async()=>{if(!t){try{const M=await U("/api/system/vision-guidance");if(M.ok){const P=await M.json();P.warn&&P.message&&o(P.message)}}catch{}await U("/api/system/screenshot",{method:"POST",body:JSON.stringify({detect:!0})}).catch(()=>{})}},$=b.some(M=>M!==null);return!(r||g.length>0||S.length>0||t||f||$)||L?null:s.jsx(ae,{children:s.jsxs(V.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.22},className:"mx-4 mb-3 bg-[#0a0d16] border border-orange-500/12 rounded-2xl overflow-hidden shadow-xl shadow-orange-500/4 shrink-0",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-500 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-orange-400 uppercase tracking-widest",children:"War Room"}),r&&s.jsxs("span",{className:"text-[10px] text-gray-600 font-mono",children:[r.width,"×",r.height]}),f&&s.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/25 px-2 py-0.5 rounded-full",children:[s.jsx(Zi,{size:9,className:"animate-pulse"}),"Shadow Active"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:z,disabled:t,className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-all ${t?"text-orange-400 bg-orange-500/10 animate-pulse cursor-not-allowed":"text-gray-600 hover:text-orange-400 hover:bg-orange-500/8 border border-white/5"}`,children:[s.jsx(ui,{size:10}),t?"Scanning…":"Capture"]}),r&&s.jsx("button",{onClick:()=>c(M=>!M),className:"text-gray-700 hover:text-gray-400 transition-colors",title:l?"Collapse preview":"Expand preview",children:l?s.jsx(np,{size:12}):s.jsx(Us,{size:12})}),s.jsx("button",{onClick:()=>_(M=>!M),className:"text-gray-700 hover:text-gray-400 transition-colors",title:N?"Expand war room":"Collapse war room",children:N?s.jsx(Xs,{size:12}):s.jsx(Bl,{size:12})}),s.jsx("button",{onClick:()=>B(!0),className:"text-gray-700 hover:text-red-400 transition-colors",title:"Dismiss war room",children:s.jsx(ze,{size:12})})]})]}),s.jsx(ae,{children:!N&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:[i&&s.jsxs("div",{className:"px-4 py-2 bg-amber-500/8 border-b border-amber-500/15 flex items-start justify-between gap-2",children:[s.jsx("p",{className:"text-[11px] text-amber-400 leading-relaxed flex-1",children:i}),s.jsx("button",{onClick:()=>o(null),className:"text-[10px] text-amber-600 hover:text-amber-400 shrink-0",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-0 divide-x divide-white/5",children:[s.jsx("div",{className:"w-1/2 shrink-0",children:$&&b[v]?s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"flex border-b border-white/5",children:[0,1,2].map(M=>b[M]!==null&&s.jsxs("button",{onClick:()=>x(M),className:`flex items-center gap-0.5 px-2 py-1 text-[9px] font-bold transition-colors ${v===M?"text-purple-400 border-b-2 border-purple-500":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Zi,{size:7})," G",M+1]},M))}),s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[110px]"}`,children:[s.jsx("img",{src:`data:image/jpeg;base64,${b[v]}`,alt:`Ghost ${v+1}`,className:"w-full object-contain"}),s.jsxs("div",{className:"absolute top-1.5 left-1.5 flex items-center gap-1 px-2 py-0.5 bg-black/75 rounded-lg text-[9px] font-bold text-purple-400 border border-purple-500/30",children:[s.jsx(Zi,{size:8,className:"animate-pulse"})," G",v+1]}),s.jsx("div",{className:"absolute bottom-1.5 right-1.5 px-1.5 py-0.5 bg-black/70 rounded text-[8px] font-mono text-purple-300 border border-purple-500/20",children:"LIVE"})]})]}):f&&h?s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[120px]"}`,children:[s.jsx("img",{src:`data:image/jpeg;base64,${h}`,alt:"Shadow browser",className:"w-full object-contain"}),s.jsxs("div",{className:"absolute top-1.5 left-1.5 flex items-center gap-1 px-2 py-0.5 bg-black/75 rounded-lg text-[9px] font-bold text-purple-400 border border-purple-500/30",children:[s.jsx(Zi,{size:8,className:"animate-pulse"})," SHADOW"]}),s.jsx("div",{className:"absolute bottom-1.5 right-1.5 px-1.5 py-0.5 bg-black/70 rounded text-[8px] font-mono text-purple-300 border border-purple-500/20",children:"LIVE"})]}):r?s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[120px]"}`,children:[s.jsx("canvas",{ref:d,className:"w-full object-contain",style:{imageRendering:"auto"}}),r.elements&&r.elements.length>0&&s.jsxs("div",{className:"absolute bottom-1.5 right-1.5 px-2 py-0.5 bg-black/70 rounded text-[9px] font-mono text-orange-400 border border-orange-500/20",children:[r.elements.length," elements"]})]}):t?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-orange-400 text-xs animate-pulse",children:[s.jsx(ui,{size:13,className:"animate-spin"})," Scanning…"]}):s.jsx("div",{className:"flex items-center justify-center py-8 text-gray-700 text-[11px]",children:"No capture yet"})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[g.length>0&&s.jsxs("div",{className:"border-b border-white/5",children:[j&&s.jsx("div",{className:"px-3 py-1.5 border-b border-white/4 bg-white/[0.01]",children:s.jsxs("p",{className:"text-[10px] text-gray-500 truncate",children:[e.workflow.goal,": ",s.jsx("span",{className:"text-gray-300",children:j})]})}),s.jsx("div",{className:"p-2 space-y-1 max-h-[100px] overflow-y-auto scrollbar-hide",children:g.map(M=>{const P=bE[M.type]??Zt;return s.jsxs("div",{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-xl text-[11px] font-medium ${wE[M.status]}`,children:[M.status==="running"?s.jsx(ne,{size:11,className:"animate-spin text-orange-400 shrink-0"}):M.status==="done"?s.jsx(Fe,{size:11,className:"text-green-500 shrink-0"}):s.jsx(P,{size:11,className:"text-gray-600 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:M.label})]},M.id)})})]}),S.length>0&&s.jsxs("div",{className:"flex-1 overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1 border-b border-white/4",children:s.jsx("span",{className:"text-[9px] font-bold text-gray-600 uppercase tracking-widest",children:"Control Feed"})}),s.jsxs("div",{className:"px-2 py-1 space-y-px overflow-y-auto max-h-[100px] scrollbar-hide font-mono",children:[S.map(M=>{const P=kE[M.action]??pv,E=jE[M.action]??"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(P,{size:10,className:`${E} shrink-0`}),s.jsx("span",{className:`text-[10px] ${E} truncate flex-1`,children:M.label}),s.jsx("span",{className:"text-[9px] text-gray-700 shrink-0 tabular-nums",children:new Date(M.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]},M.id)}),s.jsx("div",{ref:A})]})]})]})]})]})})]})})}const v0="mustb_briefing_shown",SE=14*60*60*1e3,bu={CodeHealth:{label:"Kod Sağlığı",Icon:en,color:"#fb923c"},DepAudit:{label:"Bağımlılık Denetimi",Icon:Qs,color:"#a78bfa"},LogAnalysis:{label:"Log Analizi",Icon:nn,color:"#38bdf8"},LTMGap:{label:"Bellek Boşluğu",Icon:Zt,color:"#34d399"},WorkspaceDiff:{label:"Değişiklik Özeti",Icon:ov,color:"#fbbf24"}};function CE(e){const t=Object.keys(bu).find(n=>e.toLowerCase().includes(n.toLowerCase()));return t?bu[t]:{label:e,Icon:mn,color:"#fb923c"}}function EE(e){const t=new Set(["NightShift-Insights","nightshift-insights","nightshift","night-shift"]);return e.find(n=>!t.has(n))??"General"}function b0(e){if(!e)return"—";const t=Math.round(e/1e3);return t<60?`${t} sn`:`${Math.floor(t/60)} dk ${t%60} sn`}function _E(e){const t=Date.now()-e,n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n} saat ${r} dk önce`:r>0?`${r} dk önce`:"Az önce"}const TE={hidden:{opacity:0},show:{opacity:1,transition:{duration:.4}},exit:{opacity:0,transition:{duration:.35}}},PE={hidden:{opacity:0,y:32,scale:.97},show:{opacity:1,y:0,scale:1,transition:{type:"spring",stiffness:260,damping:26}},exit:{opacity:0,y:20,scale:.97,transition:{duration:.25}}},AE={hidden:{},show:{transition:{staggerChildren:.11,delayChildren:.45}}},ME={hidden:{opacity:0,x:24},show:{opacity:1,x:0,transition:{type:"spring",stiffness:300,damping:28}}};function zE(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState([]),[o,l]=u.useState(!0),c=u.useRef(!1);u.useEffect(()=>{c.current||(c.current=!0,(async()=>{try{const h=await U("/api/automation/nightowl/status");if(!h.ok)return;const p=await h.json();if(!p.lastShiftTs||Date.now()-p.lastShiftTs>SE||localStorage.getItem(v0)===String(p.lastShiftTs)||p.totalFindings===0)return;const f=await U("/api/memory/ltm/search?q=NightShift-Insights&limit=15&category=semantic"),b=(f.ok?await f.json():{results:[]}).results.filter(y=>y.tags.some(v=>v.toLowerCase().includes("nightshift"))).slice(0,8).map(y=>({task:EE(y.tags),summary:y.content.replace(/\n/g," ").slice(0,180)}));r(p),i(b),l(!1),t(!0),localStorage.setItem(v0,String(p.lastShiftTs))}catch{}})())},[]);const d=()=>t(!1);return s.jsx(ae,{children:e&&s.jsx(V.div,{variants:TE,initial:"hidden",animate:"show",exit:"exit",className:"fixed inset-0 z-[400] flex items-center justify-center px-4",style:{background:"rgba(4,1,0,0.82)",backdropFilter:"blur(8px)"},onClick:h=>{h.target===h.currentTarget&&d()},children:s.jsxs(V.div,{variants:PE,initial:"hidden",animate:"show",exit:"exit",className:"relative w-full max-w-[620px] max-h-[88vh] flex flex-col rounded-3xl overflow-hidden",style:{background:"rgba(14,6,1,0.92)",border:"1px solid rgba(249,115,22,0.22)",backdropFilter:"blur(32px)",boxShadow:"0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsx("button",{onClick:d,className:"absolute top-4 right-4 z-10 w-7 h-7 rounded-full flex items-center justify-center text-white/25 hover:text-white/70 hover:bg-white/8 transition-all",children:s.jsx(ze,{size:14})}),s.jsxs("div",{className:"flex-shrink-0 px-8 pt-8 pb-6",style:{borderBottom:"1px solid rgba(249,115,22,0.10)"},children:[s.jsxs(V.div,{initial:{opacity:0,y:-12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.5},className:"flex items-start gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)",boxShadow:"0 0 24px rgba(249,115,22,0.15)"},children:s.jsx(Si,{size:22,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[11px] font-semibold text-orange-400/60 tracking-widest uppercase mb-1",children:"Sabah Raporu"}),s.jsx("h2",{className:"text-[22px] font-black text-white/90 leading-tight tracking-tight",children:"Gece Vardiyası Tamamlandı"}),(n==null?void 0:n.lastShiftTs)&&s.jsxs("p",{className:"text-[12px] text-white/35 mt-1",children:[_E(n.lastShiftTs)," · ",b0(n.lastShiftMs)," sürdü"]})]})]}),n&&s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"flex items-center gap-4 mt-5",children:[{label:"Bulgu",value:String(n.totalFindings)},{label:"Görev",value:String(Object.keys(bu).length)},{label:"Süre",value:b0(n.lastShiftMs)}].map(h=>s.jsxs("div",{className:"flex-1 rounded-xl px-3 py-2.5 text-center",style:{background:"rgba(249,115,22,0.06)",border:"1px solid rgba(249,115,22,0.12)"},children:[s.jsx("p",{className:"text-[18px] font-black text-orange-400",children:h.value}),s.jsx("p",{className:"text-[10px] text-white/30 font-medium mt-0.5",children:h.label})]},h.label))})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-5 space-y-2.5",style:{scrollbarWidth:"none"},children:[o&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"flex gap-1.5",children:[0,1,2].map(h=>s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-400/40 animate-bounce",style:{animationDelay:`${h*.15}s`}},h))})}),!o&&a.length===0&&s.jsx("p",{className:"text-center text-[13px] text-white/30 py-10",children:"Kayıtlı bulgu bulunamadı."}),!o&&a.length>0&&s.jsx(V.div,{variants:AE,initial:"hidden",animate:"show",className:"space-y-2.5",children:a.map((h,p)=>{const f=CE(h.task),m=f.Icon;return s.jsx(V.div,{variants:ME,children:s.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-2xl",style:{background:"rgba(255,255,255,0.03)",border:`1px solid ${f.color}22`},children:[s.jsx("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:`${f.color}15`,border:`1px solid ${f.color}30`},children:s.jsx(m,{size:14,style:{color:f.color}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-bold mb-1 tracking-wide",style:{color:f.color},children:f.label}),s.jsx("p",{className:"text-[12.5px] text-white/65 leading-relaxed",children:h.summary})]}),s.jsx(gn,{size:13,className:"text-white/15 flex-shrink-0 mt-1"})]})},p)})})]}),s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.6},className:"flex-shrink-0 px-8 py-5",style:{borderTop:"1px solid rgba(249,115,22,0.10)"},children:s.jsxs("button",{onClick:d,className:"w-full py-3 rounded-2xl flex items-center justify-center gap-2 font-bold text-[14px] transition-all active:scale-[0.98]",style:{background:"rgba(249,115,22,0.15)",border:"1px solid rgba(249,115,22,0.30)",color:"#fdba74"},onMouseEnter:h=>h.currentTarget.style.background="rgba(249,115,22,0.22)",onMouseLeave:h=>h.currentTarget.style.background="rgba(249,115,22,0.15)",children:[s.jsx(Ue,{size:15}),"Günün başlasın"]})})]})},"morning-briefing-overlay")})}const w0={CodeHealth:{label:"Kod Sağlığı",Icon:en,color:"#fb923c"},DepAudit:{label:"Bağımlılık",Icon:Qs,color:"#a78bfa"},LogAnalysis:{label:"Log Analizi",Icon:nn,color:"#38bdf8"},LTMGap:{label:"Bellek",Icon:Zt,color:"#34d399"},WorkspaceDiff:{label:"Değişiklikler",Icon:ov,color:"#fbbf24"}};function RE(e){const t=Object.keys(w0).find(n=>e.toLowerCase().includes(n.toLowerCase()));return t?w0[t]:{label:e,Icon:mn,color:"#fb923c"}}function LE(e){const t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}const OE={hidden:{opacity:0,x:24,scale:.96},show:{opacity:1,x:0,scale:1,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,x:24,scale:.96,transition:{duration:.22}}},IE={hidden:{opacity:0,y:-6},show:{opacity:1,y:0,transition:{duration:.22}}};function DE(){const[e,t]=u.useState("idle"),[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(!1),h=u.useRef(null),p=u.useRef(0),f=u.useCallback((b=2e4)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{l(!1),setTimeout(()=>d(!1),600)},b)},[]);if(u.useEffect(()=>{const b=pe();return b.on("nightOwlEvent",y=>{if(y.type==="shiftStart"){h.current&&clearTimeout(h.current),t("scanning"),r([]),i(null),d(!0),l(!0);return}if(y.type==="finding"){const v={id:`${++p.current}`,task:String(y.task??"General"),summary:String(y.summary??"").slice(0,120),ts:Number(y.ts??Date.now())};r(x=>[v,...x].slice(0,20));return}if(y.type==="shiftEnd"){t("done"),i({findingsCount:Number(y.findingsCount??0),durationMs:Number(y.durationMs??0),ts:Number(y.ts??Date.now())}),f(2e4);return}}),()=>{b.off("nightOwlEvent"),h.current&&clearTimeout(h.current)}},[f]),!c)return null;const m="#fb923c";return s.jsx(ae,{children:s.jsx(V.div,{variants:OE,initial:"hidden",animate:"show",exit:"exit",className:"fixed z-[130] flex flex-col",style:{top:"80px",right:"20px",width:"300px",maxHeight:"70vh",pointerEvents:"auto"},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden flex flex-col",style:{background:"rgba(10,4,1,0.90)",border:`1px solid ${m}28`,backdropFilter:"blur(24px)",boxShadow:"0 12px 40px rgba(0,0,0,0.60), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("button",{onClick:()=>{l(b=>!b),h.current&&clearTimeout(h.current)},className:"flex items-center justify-between px-4 py-3 w-full select-none",style:{borderBottom:o?`1px solid ${m}10`:"none"},children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[e==="scanning"?s.jsxs("span",{className:"relative flex-shrink-0",children:[s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-400"}),s.jsx("span",{className:"absolute inset-0 rounded-full bg-orange-400 animate-ping opacity-70"})]}):e==="done"?s.jsx(Fe,{size:13,className:"text-green-400 flex-shrink-0"}):s.jsx(Si,{size:13,className:"text-orange-300/50 flex-shrink-0"}),s.jsx("span",{className:"text-[12px] font-semibold text-white/75",children:e==="scanning"?"Gece Vardiyası":"Vardiya Logu"}),e==="scanning"&&s.jsx("span",{className:"text-[10px] text-orange-400/70 font-mono animate-pulse",children:"taranıyor…"}),e==="done"&&a&&s.jsxs("span",{className:"text-[10px] text-white/30 font-mono",children:[a.findingsCount," bulgu · ",LE(a.durationMs)]})]}),o?s.jsx(Bl,{size:12,className:"text-white/25"}):s.jsx(Xs,{size:12,className:"text-white/25"})]}),s.jsx(ae,{children:o&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22},className:"overflow-hidden",children:[s.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:"52vh",scrollbarWidth:"none"},children:[e==="scanning"&&n.length===0&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2",children:[s.jsx("div",{className:"flex gap-1",children:[0,1,2].map(b=>s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-400/50 animate-bounce",style:{animationDelay:`${b*.15}s`}},b))}),s.jsx("span",{className:"text-[11px] text-white/30",children:"Sistem analiz ediliyor…"})]}),s.jsx(ae,{initial:!1,children:n.map(b=>{const y=RE(b.task),v=y.Icon;return s.jsxs(V.div,{variants:IE,initial:"hidden",animate:"show",exit:{opacity:0,height:0},className:"flex items-start gap-3 px-4 py-3",style:{borderBottom:"1px solid rgba(255,255,255,0.04)"},children:[s.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:`${y.color}15`,border:`1px solid ${y.color}30`},children:s.jsx(v,{size:11,style:{color:y.color}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] font-bold mb-0.5",style:{color:y.color},children:y.label}),s.jsx("p",{className:"text-[11px] text-white/50 leading-snug line-clamp-3",children:b.summary})]})]},b.id)})}),e==="done"&&n.length===0&&s.jsx("p",{className:"text-center text-[12px] text-white/25 py-8",children:"Kayda değer bulgu yok."})]}),e==="done"&&a&&s.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",style:{borderTop:`1px solid ${m}10`},children:[s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(a.ts).toLocaleTimeString("tr-TR")}),s.jsx("span",{className:"text-[10px] text-green-400/70 font-semibold",children:"✓ Tamamlandı"})]})]},"log-body")})]})},"night-shift-log")})}const k0="mustb_boot_report",j0=14e3;function BE({value:e,max:t=10}){const n=Math.round(e/t*100),r=n>=70?"#22c55e":n>=40?"#f97316":"#ef4444";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden",style:{background:"rgba(255,255,255,0.08)"},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${n}%`,background:r}})}),s.jsx("span",{className:"text-[11px] font-mono",style:{color:r},children:e.toFixed(1)})]})}function FE(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),a=u.useCallback(()=>{t(!1),localStorage.removeItem(k0)},[]);return u.useEffect(()=>{if(localStorage.getItem(k0)!=="1")return;t(!0),U("/api/status").then(o=>o.ok?o.json():null).then(o=>{o&&r(o)}).catch(()=>{});const i=setTimeout(a,j0);return()=>clearTimeout(i)},[a]),s.jsx(ae,{children:e&&s.jsx(V.div,{initial:{opacity:0,scale:.96,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:16},transition:{duration:.28,ease:"easeOut"},className:"fixed inset-0 z-[500] flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)"},children:s.jsxs("div",{className:"relative w-full max-w-sm rounded-2xl overflow-hidden",style:{background:"rgba(14,6,2,0.92)",border:"1px solid rgba(234,88,12,0.30)",boxShadow:"0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(234,88,12,0.10)",backdropFilter:"blur(24px)"},children:[s.jsx("button",{onClick:a,className:"absolute top-3 right-3 text-white/25 hover:text-white/60 transition-colors z-10",children:s.jsx(ze,{size:14})}),s.jsxs("div",{className:"px-5 pt-5 pb-3 flex items-center gap-3",children:[s.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.25)"},children:s.jsx(Fe,{size:18,style:{color:"#22c55e"}})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:"System Ready"}),s.jsx("p",{className:"text-[11px] text-white/40",children:"Must-b initialised successfully"})]})]}),s.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.05)",margin:"0 20px"}}),s.jsxs("div",{className:"px-5 py-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-white/30 mb-1",children:"Agent"}),s.jsx("p",{className:"text-[12px] font-semibold text-white/80 truncate",children:(n==null?void 0:n.role)??"—"})]}),s.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-white/30 mb-1",children:"Model"}),s.jsx("p",{className:"text-[12px] font-semibold text-white/80 truncate",children:(n==null?void 0:n.model)??"—"})]})]}),s.jsxs("div",{className:"rounded-xl px-3 py-2.5 space-y-2",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(tn,{size:10})," CPU"]}),s.jsxs("span",{className:"text-[10px] font-mono text-white/50",children:[(n==null?void 0:n.cpuPct)??0,"%"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(M3,{size:10})," RAM"]}),s.jsxs("span",{className:"text-[10px] font-mono text-white/50",children:[((n==null?void 0:n.ramGb)??0).toFixed(2)," GB"]})]}),n&&s.jsxs("div",{className:"flex items-center justify-between pt-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(Ue,{size:10})," Score"]}),s.jsx(BE,{value:n.score})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-1",children:[s.jsx("span",{className:"text-[10px] text-white/30",children:"Dashboard port"}),s.jsxs("span",{className:"text-[11px] font-mono text-orange-400/70",children:[":",(n==null?void 0:n.port)??4309]})]})]}),s.jsx("div",{className:"px-5 pb-4",style:{borderTop:"1px solid rgba(255,255,255,0.05)",paddingTop:"12px"},children:s.jsx("button",{onClick:a,className:"w-full py-2 rounded-xl text-[12px] font-semibold transition-all",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.30)",color:"#fb923c"},children:"Open Dashboard"})}),s.jsx(V.div,{initial:{scaleX:1},animate:{scaleX:0},transition:{duration:j0/1e3,ease:"linear"},style:{position:"absolute",bottom:0,left:0,right:0,height:2,background:"rgba(234,88,12,0.50)",transformOrigin:"left"}})]})},"boot-report")})}function $E(e,t){if(t.includes("🛡")||t.toLowerCase().includes("ghostguard"))return"#fb923c";switch(e){case"thought":return"#22d3ee";case"planStart":return"#67e8f9";case"planGenerated":return"#a5f3fc";case"stepStart":return"#06b6d4";case"stepFinish":return t.includes("error")||t.includes("fail")?"#f87171":"#4ade80";case"finalAnswer":return"#86efac";case"planFinish":return t.includes("failed")||t.includes("error")?"#f87171":"#4ade80";case"error":return"#fb923c";case"memorySearch":return"#a78bfa";case"systemHealth":return"#fbbf24";default:return"#4b5563"}}function VE(e){switch(e){case"thought":return"◎";case"planStart":return"▶";case"planGenerated":return"◈";case"stepStart":return"→";case"stepFinish":return"✓";case"finalAnswer":return"◆";case"planFinish":return"■";case"error":return"⚠";case"memorySearch":return"⟳";case"systemHealth":return"🛡";default:return"·"}}function UE(e,t){var n,r;if(!t)return e;switch(e){case"thought":return String(t.message??t).slice(0,120);case"planStart":return`Goal: ${String(t.goal??"").slice(0,90)}`;case"planGenerated":return`Plan ready — ${Array.isArray(t.steps)?t.steps.length:"?"} steps`;case"stepStart":return String(((n=t.step)==null?void 0:n.description)??t.description??"Step starting…").slice(0,100);case"stepFinish":{const a=String(((r=t.step)==null?void 0:r.description)??t.description??"").slice(0,70),i=String(t.status??"");return`${a} [${i}]`}case"finalAnswer":return String(t.answer??"").slice(0,110);case"planFinish":return`${String(t.status??"")} — ${String(t.goal??"").slice(0,60)}`;case"error":return`Repair: ${String(t.action??"")} — ${String(t.reason??"")}`.slice(0,110);case"memorySearch":return t.active?"Searching memory…":"Memory search done";case"systemHealth":return`${String(t.level??"").toUpperCase()} — ${String(t.message??"")}`.slice(0,100);default:return JSON.stringify(t).slice(0,90)}}const N0=200;function HE(e){return new Date(e).toLocaleTimeString("en",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function WE(){const[e,t]=u.useState(!1),[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState(!0),c=u.useRef(null),d=u.useRef(0),h=u.useRef(0);u.useEffect(()=>{o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[n,o]);const p=u.useCallback((f,m)=>{const b=UE(f,m),y=$E(f,b);r(v=>{const x=[...v,{id:`t-${++d.current}`,type:f,text:b,color:y,ts:Date.now()}];return x.length>N0?x.slice(-N0):x})},[]);return u.useEffect(()=>{const f=pe(),m=y=>{p(y.type,y.payload)},b=y=>{i(y);const v=Date.now();(y.cpu>80||y.ram>85)&&v-h.current>1e4&&(h.current=v,p("systemHealth",{level:"warning",message:`🛡️ GhostGuard: CPU ${y.cpu}% / RAM ${y.ram}%`}))};return f.on("telemetry:stream",m),f.on("systemStats",b),()=>{f.off("telemetry:stream",m),f.off("systemStats",b)}},[p]),s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:!e&&s.jsxs(V.button,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.18},onClick:()=>t(!0),title:"Open telemetry",className:"fixed right-0 top-1/2 -translate-y-1/2 z-50 flex flex-col items-center justify-center gap-1 w-6 h-16 rounded-l-md border border-r-0 border-white/10 hover:border-cyan-500/40 hover:bg-cyan-400/5 transition-all duration-200 group",style:{background:"#0c0d10"},children:[s.jsx(tv,{size:11,className:"text-cyan-500/50 group-hover:text-cyan-400 transition-colors"}),s.jsx("span",{className:"font-mono text-[7px] leading-none text-white/20 group-hover:text-cyan-400/60 transition-colors",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"},children:"TEL"})]},"fab")}),s.jsx("div",{className:`relative z-50 flex-shrink-0 flex flex-col transition-[width] duration-300 overflow-hidden${e?" border-l border-white/5":""}`,style:{background:"#0c0d10",width:e?288:0},children:s.jsx(ae,{children:e&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex flex-col flex-1 min-h-0 overflow-hidden",style:{width:288},children:[s.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-500"})]}),s.jsx("span",{className:"font-mono text-[9px] font-bold text-cyan-400 tracking-[0.2em] uppercase",children:"Live"}),s.jsxs("span",{className:"font-mono text-[9px] text-white/15",children:[n.length," events"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:`font-mono text-[9px] ${a.cpu>80?"text-orange-400":"text-white/25"}`,children:["CPU ",a.cpu,"%"]}),s.jsxs("span",{className:`font-mono text-[9px] ${a.ram>85?"text-orange-400":"text-white/25"}`,children:["RAM ",a.ram,"%"]})]}),s.jsx("button",{onClick:()=>r([]),title:"Clear log",className:"text-white/15 hover:text-white/40 transition-colors",children:s.jsx(ys,{size:10})}),s.jsx("button",{onClick:()=>t(!1),title:"Collapse telemetry",className:"text-white/15 hover:text-orange-400/70 transition-colors",children:s.jsx(gn,{size:10})})]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto scrollbar-hide px-2 py-1",onMouseEnter:()=>l(!1),onMouseLeave:()=>l(!0),children:n.length===0?s.jsx("div",{className:"flex items-center justify-center h-12 font-mono text-[10px] text-white/10",children:"awaiting events…"}):s.jsx(ae,{initial:!1,children:n.map(f=>s.jsxs(V.div,{initial:{opacity:0,x:6},animate:{opacity:1,x:0},transition:{duration:.12},className:"flex items-start gap-1.5 py-[2px] group",children:[s.jsx("span",{className:"font-mono text-[8px] text-white/10 shrink-0 mt-[2px] group-hover:text-white/20 transition-colors",children:HE(f.ts)}),s.jsxs("span",{className:"font-mono text-[10px] leading-[1.45] break-all",style:{color:f.color},children:[VE(f.type)," ",f.text]})]},f.id))})})]},"panel")})})]})}function S0(){return u.useEffect(()=>{pe()},[]),s.jsxs("div",{className:"flex flex-col h-[calc(100vh-72px)] overflow-hidden",children:[s.jsx(vE,{}),s.jsx(NE,{}),s.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[s.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:s.jsx(yE,{})}),s.jsx(WE,{})]}),s.jsx(FE,{}),s.jsx(zE,{}),s.jsx(DE,{})]})}function Ei(){const[e,t]=u.useState(!1),[n,r]=u.useState(!0),a=u.useRef(!0),i=u.useCallback(async()=>{try{const o=await U("/api/gateway/status",{},{retries:1,retryDelay:500});if(!a.current)return;const l=await o.json().catch(()=>({}));t(!!(l!=null&&l.online))}catch{a.current&&t(!1)}finally{a.current&&r(!1)}},[]);return u.useEffect(()=>{a.current=!0,i();const o=setInterval(i,15e3),l=()=>{i()},c=()=>{i()},d=()=>{a.current&&t(!1)};try{pe()}catch{}return window.addEventListener("mustb:connected",l),window.addEventListener("mustb:reconnected",c),window.addEventListener("mustb:disconnected",d),()=>{a.current=!1,clearInterval(o),window.removeEventListener("mustb:connected",l),window.removeEventListener("mustb:reconnected",c),window.removeEventListener("mustb:disconnected",d)}},[i]),{online:e,loading:n}}function C0({connected:e,configured:t}){return e?s.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}):t?s.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-400 flex-shrink-0"}):s.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-600 flex-shrink-0"})}function KE(){const{online:e}=Ei(),[t,n]=u.useState(null),[r,a]=u.useState([]),[i,o]=u.useState(null),[l,c]=u.useState(null),[d,h]=u.useState(!0);u.useEffect(()=>{(async()=>{var x;h(!0);try{const w=await(await U("/api/gateway/channels")).json();n(w),(x=w.channelOrder)!=null&&x.length&&o(w.channelOrder[0])}catch{n({offline:!0,channelOrder:[],channelLabels:{},channelAccounts:{}})}finally{h(!1)}})()},[e]),u.useEffect(()=>{t!=null&&t.offline&&U("/api/channels").then(v=>v.json()).then(a).catch(()=>a([]))},[t==null?void 0:t.offline]);const p=async(v,x)=>{c(`${v}-${x}`);try{await U(`/api/gateway/channels/${v}/logout`,{method:"POST",body:JSON.stringify({accountId:x})});const g=await U("/api/gateway/channels");n(await g.json())}catch{}finally{c(null)}};if(d)return s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(ge,{size:18,className:"animate-spin text-orange-400"}),s.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Kanallar yükleniyor…"})]});if(t!=null&&t.offline)return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20",children:[s.jsx(vs,{size:14,className:"text-orange-400 flex-shrink-0"}),s.jsx("p",{className:"text-[12px] text-orange-300",children:"Must-b gateway çevrimdışı — yerel kanallar gösteriliyor."})]}),r.length===0?s.jsx("p",{className:"text-center text-sm text-gray-600 py-6",children:"Yapılandırılmış kanal yok."}):s.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.map(v=>s.jsxs("div",{className:"px-3 py-2.5 rounded-xl bg-white/3 border border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(C0,{configured:v.configured,connected:!1}),s.jsx("span",{className:"text-[13px] font-semibold text-gray-200",children:v.name}),v.configured&&s.jsx("span",{className:"ml-auto text-[9px] font-bold px-1.5 py-0.5 rounded-md bg-orange-500/10 border border-orange-500/20 text-orange-400",children:"Yapılandırıldı"})]}),s.jsx("p",{className:"text-[11px] text-gray-500 line-clamp-2",children:v.description})]},v.id))})]});const f=(t==null?void 0:t.channelOrder)??[],m=(t==null?void 0:t.channelLabels)??{},b=(t==null?void 0:t.channelAccounts)??{};if(f.length===0)return s.jsx("p",{className:"text-center text-sm text-gray-600 py-8",children:"Yapılandırılmış kanal bulunamadı."});const y=i?b[i]??[]:[];return s.jsxs("div",{className:"flex gap-4 min-h-[320px]",children:[s.jsx("div",{className:"w-48 flex-shrink-0 space-y-1",children:f.map(v=>{const x=b[v]??[],g=x.some(j=>j.connected),w=x.some(j=>j.configured);return s.jsx("button",{onClick:()=>o(v),className:`w-full text-left px-3 py-2 rounded-xl border transition-all ${i===v?"bg-orange-500/12 border-orange-500/30":"bg-white/3 border-white/6 hover:bg-white/5 hover:border-white/12"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(C0,{connected:g,configured:w}),s.jsx("span",{className:"text-[12px] font-semibold text-gray-200 truncate",children:m[v]??v}),x.length>0&&s.jsx("span",{className:"ml-auto text-[10px] font-bold text-gray-500",children:x.length})]})},v)})}),s.jsx("div",{className:"flex-1 min-w-0",children:i?y.length===0?s.jsxs("div",{className:"px-4 py-4 rounded-xl bg-white/3 border border-white/6",children:[s.jsx("p",{className:"text-[13px] font-semibold text-gray-300 mb-1",children:m[i]??i}),s.jsx("p",{className:"text-[12px] text-gray-500",children:"Henüz bağlı hesap yok."})]}):s.jsx("div",{className:"space-y-2",children:y.map(v=>s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/3 border border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.connected?s.jsx(Fe,{size:13,className:"text-green-400 flex-shrink-0"}):v.lastError?s.jsx(av,{size:13,className:"text-red-400 flex-shrink-0"}):s.jsx(Ws,{size:13,className:"text-orange-400 flex-shrink-0"}),s.jsx("span",{className:"text-[13px] font-semibold text-gray-200 truncate",children:v.name??v.accountId}),s.jsxs("button",{onClick:()=>p(i,v.accountId),disabled:l===`${i}-${v.accountId}`,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/8 border border-red-500/20 text-red-400 text-[10px] font-semibold hover:bg-red-500/15 transition-all disabled:opacity-40",children:[s.jsx(ip,{size:9}),"Logout"]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0",children:"Status"}),s.jsx("span",{className:`text-[11px] font-semibold ${v.connected?"text-green-400":"text-gray-500"}`,children:v.connected?"Connected":"Disconnected"})]}),v.lastConnectedAt&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0",children:"Last seen"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:new Date(v.lastConnectedAt).toLocaleString()})]}),v.lastError&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0 pt-0.5",children:"Error"}),s.jsx("span",{className:"text-[11px] text-red-400 break-all",children:v.lastError})]})]})]},v.accountId))}):s.jsx("p",{className:"text-sm text-gray-600 pt-4",children:"Bir kanal seçin."})})]})}function GE(e){return e===0?"Free":e<1?`$${e.toFixed(3)}/1M`:`$${e.toFixed(2)}/1M`}function qE(e){return e?e>=1e3?`${(e/1e3).toFixed(0)}M`:`${e}k`:"—"}const E0={free:{label:"Free",icon:s.jsx(j3,{size:11}),color:"#22c55e",bg:"rgba(34,197,94,0.12)"},balanced:{label:"Balanced",icon:s.jsx(V3,{size:11}),color:"#60a5fa",bg:"rgba(96,165,250,0.12)"},power:{label:"Power",icon:s.jsx(Ue,{size:11}),color:"#f59e0b",bg:"rgba(245,158,11,0.12)"}};function YE({currentModel:e,onSelect:t,className:n}){const[r,a]=u.useState(null),[i,o]=u.useState(!0),[l,c]=u.useState(null),[d,h]=u.useState("free"),[p,f]=u.useState(""),m=u.useRef(null),b=(x=!1)=>{o(!0),c(null),fetch(`/api/providers/openrouter/models${x?"?refresh=1":""}`).then(g=>g.ok?g.json():Promise.reject(new Error(`HTTP ${g.status}`))).then(g=>{if(a(g),e){const w=g.free.some(j=>j.id===e)?"free":g.balanced.some(j=>j.id===e)?"balanced":g.power.some(j=>j.id===e)?"power":"free";h(w)}o(!1)}).catch(g=>{c(g.message),o(!1)})};u.useEffect(()=>{b()},[]),u.useEffect(()=>{m.current&&m.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[d,r]);const y=(r==null?void 0:r[d])??[],v=p?y.filter(x=>x.name.toLowerCase().includes(p.toLowerCase())||x.id.toLowerCase().includes(p.toLowerCase())):y;return s.jsxs("div",{className:`flex flex-col rounded-xl overflow-hidden ${n??""}`,style:{background:"rgba(12,5,2,0.85)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 pt-3 pb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-400 uppercase tracking-widest",children:"OpenRouter Models"}),s.jsx("button",{onClick:()=>b(!0),className:"text-gray-600 hover:text-orange-400 transition-colors p-1 rounded",title:"Refresh catalog",disabled:i,children:s.jsx(ge,{size:11,className:i?"animate-spin":""})})]}),s.jsx("div",{className:"flex gap-1 px-3 pb-2",children:["free","balanced","power"].map(x=>{var k;const g=E0[x],w=((k=r==null?void 0:r.totals)==null?void 0:k[x])??0,j=d===x;return s.jsxs("button",{onClick:()=>h(x),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-semibold transition-all",style:{background:j?g.bg:"transparent",color:j?g.color:"#6b7280",border:`1px solid ${j?g.color+"40":"transparent"}`},children:[g.icon,g.label,w>0&&s.jsx("span",{className:"text-[9px] font-bold opacity-60",children:w})]},x)})}),s.jsx("div",{className:"px-3 pb-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(fn,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),s.jsx("input",{value:p,onChange:x=>f(x.target.value),placeholder:"Search models…",className:"w-full pl-7 pr-3 py-1.5 rounded-lg text-[11px] text-gray-300 placeholder-gray-600 outline-none",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"}})]})}),s.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:"320px"},children:[i&&s.jsxs("div",{className:"py-8 text-center text-[11px] text-gray-600",children:[s.jsx(ge,{size:14,className:"animate-spin mx-auto mb-2"}),"Fetching live catalog…"]}),!i&&l&&s.jsxs("div",{className:"py-6 px-4 text-center text-[11px] text-red-400",children:[l,s.jsx("br",{}),s.jsx("button",{onClick:()=>b(!0),className:"mt-2 underline text-orange-400 hover:text-orange-300",children:"Retry"})]}),!i&&!l&&v.length===0&&s.jsx("div",{className:"py-8 text-center text-[11px] text-gray-600",children:"No models found."}),!i&&!l&&v.map(x=>{const g=x.id===e,w=E0[x.tier];return s.jsx("button",{ref:g?m:void 0,onClick:()=>t(x.id),className:"w-full text-left px-3 py-2 transition-all",style:{background:g?"rgba(234,88,12,0.10)":"transparent",borderLeft:g?"2px solid #ea580c":"2px solid transparent"},children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`text-[12px] font-semibold truncate ${g?"text-orange-300":"text-gray-300"}`,children:x.name}),x.hasVision&&s.jsx(Us,{size:9,className:"text-purple-400 flex-shrink-0",title:"Vision / multimodal"})]}),s.jsx("span",{className:"text-[9px] text-gray-600 font-mono truncate block",children:x.id}),x.description&&s.jsx("span",{className:"text-[10px] text-gray-600 line-clamp-1 mt-0.5",children:x.description})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[s.jsx("span",{className:"text-[9px] font-bold",style:{color:w.color},children:GE(x.costPer1M)}),s.jsxs("span",{className:"text-[9px] text-gray-600",children:[qE(x.contextK)," ctx"]})]})]})},x.id)})]}),r&&s.jsx("div",{className:"px-3 py-1.5 border-t",style:{borderColor:"rgba(255,255,255,0.04)"},children:s.jsxs("span",{className:"text-[9px] text-gray-700 font-mono",children:["Catalog cached · ",new Date(r.fetchedAt).toLocaleTimeString()]})})]})}const $c=[{code:"en",label:"English",flag:"🇬🇧",native:"English"},{code:"tr",label:"Turkish",flag:"🇹🇷",native:"Türkçe"},{code:"de",label:"German",flag:"🇩🇪",native:"Deutsch"},{code:"fr",label:"French",flag:"🇫🇷",native:"Français"},{code:"es",label:"Spanish",flag:"🇪🇸",native:"Español"},{code:"pt",label:"Portuguese (Brazil)",flag:"🇧🇷",native:"Português"},{code:"ja",label:"Japanese",flag:"🇯🇵",native:"日本語"},{code:"zh",label:"Chinese (Simplified)",flag:"🇨🇳",native:"简体中文"}];function XE(){const{locale:e,setLocale:t}=yt(),[n,r]=u.useState(!1),a=u.useRef(null),i=$c.find(o=>o.code===e)??$c[0];return u.useEffect(()=>{if(!n)return;const o=l=>{l.key==="Escape"&&r(!1)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),s.jsxs("div",{ref:a,className:"relative",children:[s.jsxs("button",{onClick:()=>r(o=>!o),"aria-label":"Switch language",className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-full border text-[12px] font-semibold transition-all select-none ${n?"bg-orange-500/15 border-orange-400/30 text-orange-700":"text-black/65 border-transparent hover:text-black hover:bg-black/6"}`,children:[s.jsx(_3,{size:12,className:"text-orange-400 shrink-0"}),s.jsx("span",{children:i.flag}),s.jsx("span",{className:"tracking-wide",children:i.code.toUpperCase()})]}),s.jsx(ae,{children:n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>r(!1)}),s.jsxs(V.div,{initial:{opacity:0,y:-6,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.96},transition:{duration:.13,ease:"easeOut"},className:"absolute right-0 top-full mt-2 z-20 w-52 bg-[#100806]/96 backdrop-blur-2xl border border-orange-500/15 rounded-xl shadow-2xl shadow-black/60 overflow-hidden max-h-72 overflow-y-auto",children:[s.jsx("div",{className:"px-3 py-2 border-b border-white/6",children:s.jsx("p",{className:"text-[9px] font-bold text-gray-600 uppercase tracking-widest",children:"Language"})}),$c.map(o=>{const l=e===o.code;return s.jsxs("button",{onClick:()=>{t(o.code),r(!1)},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[12px] font-medium transition-colors ${l?"bg-orange-500/12 text-orange-400":"text-gray-300 hover:bg-white/5 hover:text-white"}`,children:[s.jsx("span",{className:"text-base leading-none",children:o.flag}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsx("p",{className:"leading-none",children:o.native}),!l&&s.jsx("p",{className:"text-[10px] text-gray-600 mt-0.5",children:o.label})]}),l&&s.jsx(it,{size:12,className:"text-orange-400 shrink-0"})]},o.code)})]})]})})]})}const _0={frontier:"⚡ Frontier",gateway:"🌐 Gateway",fast:"🚀 Fast",local:"💻 Local",open:"🔓 Open Source",specialist:"🎯 Specialist",regional:"🌏 Regional",enterprise:"🏢 Enterprise",custom:"⚙️ Custom"},T0=["frontier","gateway","fast","local","open","specialist","regional","enterprise","custom"];function Ov({tag:e}){return s.jsx("span",{className:"px-1.5 py-0.5 rounded-md bg-white/5 border border-white/8 text-[9px] text-gray-400 font-medium",children:e})}function QE({p:e,active:t,onClick:n}){return s.jsx("button",{onClick:n,className:`w-full text-left px-3 py-2.5 rounded-xl border transition-all ${t?"bg-orange-500/12 border-orange-500/30":"bg-white/3 border-white/6 hover:bg-white/5 hover:border-white/12"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:`text-[13px] font-semibold leading-tight truncate ${t?"text-orange-300":"text-gray-200"}`,children:e.label}),s.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5 leading-snug line-clamp-2",children:e.description}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:e.tags.slice(0,3).map(r=>s.jsx(Ov,{tag:r},r))})]}),t&&s.jsx(gn,{size:13,className:"text-orange-400 shrink-0 mt-1"})]})})}function JE(){const{t:e}=yt(),t=e.panels.settings,[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState([]),[c,d]=u.useState(!0),[h,p]=u.useState(null),[f,m]=u.useState("all"),[b,y]=u.useState(""),[v,x]=u.useState(null),[g,w]=u.useState(""),[j,k]=u.useState(""),[S,C]=u.useState(!1),[A,N]=u.useState(!1),[_,L]=u.useState(!1),[B,z]=u.useState(null),[$,R]=u.useState(null),[M,P]=u.useState(!!window.__MUSTB_NEED_API_KEY),[E,T]=u.useState(null),[O,G]=u.useState({}),[D,K]=u.useState("providers"),F=u.useRef(null),Q=u.useRef(!1);u.useEffect(()=>{U("/api/setup/providers").then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.providers&&r(Z.providers)}).catch(()=>{}),U("/api/setup/status").then(Z=>Z.ok?Z.json():null).then(Z=>{Z&&i(Z)}).catch(()=>{}),U("/api/ollama/models").then(Z=>Z.ok?Z.json():null).then(Z=>{var xe;Z?(d(Z.running!==!1),Z.running===!1?p((xe=Z.error)!=null&&xe.includes("ECONNREFUSED")?"Ollama kapalı.":Z.error||"Ollama kapalı."):p(null),Z.models&&l(Z.models)):(d(!1),p("Ollama kapalı."))}).catch(()=>{d(!1),p("Ollama kapalı.")});const ee=()=>{P(!0),window.__MUSTB_NEED_API_KEY=!0};return window.addEventListener("mustb:401",ee),()=>window.removeEventListener("mustb:401",ee)},[]),u.useEffect(()=>{const ee=pe(),Z=xe=>{if(!xe||!xe.model)return;const Zs=xe.model,Re=typeof xe.percent=="number"?xe.percent:0,er=xe.status||"",yn=xe.error||"";G(ct=>({...ct,[Zs]:{percent:Re,status:er,error:yn}})),(er==="success"||er==="error")&&(T(null),U("/api/ollama/models").then(ct=>ct.ok?ct.json():null).then(ct=>{var Ti;ct?(d(ct.running!==!1),ct.running===!1?p((Ti=ct.error)!=null&&Ti.includes("ECONNREFUSED")?"Ollama kapalı.":ct.error||"Ollama kapalı."):p(null),ct.models&&l(ct.models)):(d(!1),p("Ollama kapalı."))}).catch(()=>{d(!1),p("Ollama kapalı.")}))};return ee.on("ollama_pull_progress",Z),()=>{ee.off("ollama_pull_progress",Z)}},[]),u.useEffect(()=>{if(Q.current||!(a!=null&&a.activeProvider)||!n.length)return;const ee=n.find(Z=>Z.id===a.activeProvider);ee&&(Q.current=!0,x(ee),w(a.activeModel??ee.defaultModel))},[n,a]);const q=b.toLowerCase(),X=n.filter(ee=>!(f!=="all"&&ee.category!==f||q&&!ee.label.toLowerCase().includes(q)&&!ee.description.toLowerCase().includes(q))),le={};for(const ee of X)le[ee.category]||(le[ee.category]=[]),le[ee.category].push(ee);const H=async()=>{if(v){N(!0),z(null);try{const Z=await(await U("/api/setup/test-key",{method:"POST",body:JSON.stringify({provider:v.id,apiKey:j||void 0,model:g||void 0})})).json();z({ok:Z.ok,msg:Z.message??(Z.ok?"Connection successful":"Connection failed")})}catch{z({ok:!1,msg:"Gateway unreachable"})}N(!1)}},se=async()=>{if(!(!v||!v.envKeyIsUrl&&!j.trim())){L(!0),R(null);try{const Z=await U("/api/setup/update-key",{method:"POST",body:JSON.stringify({provider:v.id,apiKey:j||void 0,model:g||void 0})});if(Z.ok){R("Saved successfully."),k(""),window.__MUSTB_NEED_API_KEY=!1,P(!1);const xe=await U("/api/setup/status");xe.ok&&i(await xe.json())}else{const xe=await Z.json();R(xe.error??"Failed to save.")}}catch{R("Gateway unreachable.")}L(!1),setTimeout(()=>R(null),6e3)}},ce=async ee=>{T(ee),G(Z=>({...Z,[ee]:{percent:0,status:"Starting..."}}));try{if(!(await U("/api/ollama/pull",{method:"POST",body:JSON.stringify({modelName:ee})})).ok)throw new Error("İndirme isteği başarısız.")}catch(Z){G(xe=>({...xe,[ee]:{percent:0,status:"error",error:Z.message||"Bağlantı hatası"}})),T(null)}},oe=(v==null?void 0:v.envKeyIsUrl)??!1,de=(v==null?void 0:v.id)==="ollama",Et=(v==null?void 0:v.id)==="openrouter",bs=T0.filter(ee=>n.some(Z=>Z.category===ee)),ra=a?a.score>=70?"text-green-400":a.score>=40?"text-amber-400":"text-red-400":"text-gray-400";return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden font-sans",children:[s.jsxs("div",{className:"shrink-0 flex items-center justify-between px-5 py-3 border-b border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center",children:s.jsx(Ci,{size:15,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[14px] font-bold text-white leading-tight",children:t.title}),s.jsxs("p",{className:"text-[10px] text-gray-400 leading-tight",children:[a!=null&&a.configured?`Active · ${a.provider??"unknown"}`:"Not configured",a!=null&&a.mode?` · ${a.mode}`:""]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(XE,{}),a&&s.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-white/4 border border-white/8",children:[s.jsx(tn,{size:11,className:ra}),s.jsxs("span",{className:`text-[11px] font-semibold ${ra}`,children:["HW ",a.score]}),s.jsxs("span",{className:"text-[10px] text-gray-400",children:["· ",a.tier]})]})]})]}),M&&s.jsxs("div",{className:"shrink-0 mx-4 mt-3 flex items-start gap-2.5 px-3.5 py-2.5 rounded-xl bg-red-500/10 border border-red-500/25 text-red-300",children:[s.jsx(Ws,{size:14,className:"shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold",children:"API key missing or invalid"}),s.jsx("p",{className:"text-[10px] text-red-400/70 mt-0.5",children:"A request returned 401 Unauthorized. Select a provider and update your key below."})]})]}),s.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-5 pt-3 pb-0",children:[s.jsxs("button",{onClick:()=>K("providers"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${D==="providers"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-400 hover:text-gray-300 hover:border-white/12"}`,children:[s.jsx(tn,{size:11})," LLM Providers"]}),s.jsxs("button",{onClick:()=>K("channels"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${D==="channels"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-400 hover:text-gray-300 hover:border-white/12"}`,children:[s.jsx(Co,{size:11})," Kanallar"]})]}),D==="channels"&&s.jsx("div",{className:"flex-1 overflow-y-auto p-5",children:s.jsx(KE,{})}),D==="providers"&&s.jsxs("div",{className:"flex flex-1 min-h-0 gap-0",children:[s.jsxs("div",{className:"w-[52%] flex flex-col border-r border-white/6 min-h-0",children:[s.jsxs("div",{className:"shrink-0 px-4 pt-3 pb-2 space-y-2.5",children:[s.jsxs("div",{className:"relative",children:[s.jsx(fn,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),s.jsx("input",{ref:F,type:"text",value:b,onChange:ee=>y(ee.target.value),placeholder:t.searchPlaceholder,className:"w-full bg-white/4 border border-white/8 rounded-xl pl-8 pr-3 py-2 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("button",{onClick:()=>m("all"),className:`px-2 py-0.5 rounded-lg text-[10px] font-semibold border transition-all ${f==="all"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/4 border-white/8 text-gray-400 hover:text-gray-300"}`,children:t.allProviders}),bs.map(ee=>s.jsx("button",{onClick:()=>m(ee),className:`px-2 py-0.5 rounded-lg text-[10px] font-semibold border transition-all ${f===ee?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/4 border-white/8 text-gray-400 hover:text-gray-300"}`,children:_0[ee]},ee))]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-4",children:[n.length===0&&s.jsxs("div",{className:"flex items-center gap-2 py-6 text-gray-400 text-[12px]",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading providers…"]}),T0.filter(ee=>{var Z;return(Z=le[ee])==null?void 0:Z.length}).map(ee=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mb-1.5 px-1",children:_0[ee]}),s.jsx("div",{className:"space-y-1.5",children:le[ee].map(Z=>s.jsx(QE,{p:Z,active:(v==null?void 0:v.id)===Z.id,onClick:()=>{x(Z),w(Z.defaultModel),z(null),k("")}},Z.id))})]},ee)),n.length>0&&X.length===0&&s.jsxs("p",{className:"text-[12px] text-gray-400 py-4 text-center",children:['No providers match "',b,'"']})]})]}),s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto",children:v?s.jsxs("div",{className:"p-5 space-y-5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-[16px] font-bold text-white",children:v.label}),s.jsx("p",{className:"text-[12px] text-gray-400 mt-0.5 leading-snug",children:v.description}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:v.tags.map(ee=>s.jsx(Ov,{tag:ee},ee))})]}),s.jsxs("a",{href:v.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white transition-colors",children:["Docs ",s.jsx(Kr,{size:10})]})]}),de&&(()=>{const ee=o,Z=Array.isArray(ee)?ee:[];return c?Z.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Recommended Models for Your Hardware"}),s.jsx("div",{className:"space-y-1.5",children:Z==null?void 0:Z.map(xe=>{const Zs=xe.fit==="recommended"?"text-green-400 border-green-500/20 bg-green-500/6":xe.fit==="marginal"?"text-amber-400 border-amber-500/20 bg-amber-500/6":"text-red-400 border-red-500/20 bg-red-500/6",Re=O[xe.id];return s.jsxs("div",{className:"space-y-2 rounded-xl bg-white/3 border border-white/6 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-200 truncate",children:xe.label}),s.jsxs("p",{className:"text-[10px] text-gray-400",children:[xe.sizeGb," GB"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-md border ${Zs}`,children:xe.fit}),s.jsxs("button",{onClick:()=>{w(xe.id),ce(xe.id)},disabled:E!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[10px] font-semibold hover:bg-orange-500/15 transition-all disabled:opacity-40",children:[E===xe.id?s.jsx(ne,{size:10,className:"animate-spin text-orange-400"}):s.jsx(Os,{size:10}),E===xe.id?"Pulling…":"Pull"]})]})]}),Re&&s.jsxs("div",{className:"space-y-1.5 pt-1.5 border-t border-white/5",children:[Re.status!=="success"&&Re.status!=="error"&&s.jsx("div",{className:"w-full bg-zinc-950 border border-zinc-800 rounded-full h-2 overflow-hidden relative shadow-inner",children:s.jsx("div",{className:"bg-gradient-to-r from-orange-500 to-amber-500 h-full rounded-full transition-all duration-300 relative shadow-[0_0_6px_rgba(249,115,22,0.3)]",style:{width:`${Re.percent}%`}})}),s.jsxs("p",{className:`text-[9px] font-medium leading-normal ${Re.status==="success"?"text-emerald-400":Re.status==="error"?"text-red-400":"text-zinc-400"}`,children:[Re.status==="success"&&"✓ ",Re.status==="error"&&"✗ ",Re.status==="success"?"Model başarıyla indirildi!":Re.status==="error"?Re.error||"İndirme başarısız.":`İndiriliyor: %${Re.percent} (${Re.status})`]})]})]},xe.id)})})]}):s.jsx("div",{className:"bg-white/3 border border-white/6 rounded-xl p-4 text-center py-6",children:s.jsx("p",{className:"text-xs text-zinc-500 font-semibold",children:"Önerilen model bulunamadı."})}):s.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-4 text-red-400 text-xs flex items-start gap-2.5 backdrop-blur-md shadow-lg shadow-red-500/5",children:[s.jsx(AlertCircle,{size:14,className:"shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-bold",children:h||"Ollama kapalı."}),s.jsx("p",{className:"mt-0.5 opacity-90",children:"Ollama servisi yanıt vermiyor. Arka planda çalıştığından emin olun."})]})]})})(),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[oe?s.jsx(U3,{size:9}):s.jsx(rp,{size:9}),oe?t.baseUrl:t.apiKey]}),de&&!oe?s.jsx("div",{className:"px-3.5 py-2.5 rounded-xl bg-green-500/6 border border-green-500/15 text-green-400 text-[12px]",children:"Ollama runs locally — no API key required. Just make sure Ollama is running."}):s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:S||oe?"text":"password",value:j,onChange:ee=>{k(ee.target.value),z(null)},placeholder:v.placeholder,className:"w-full bg-white/4 border border-white/10 rounded-xl px-4 py-2.5 pr-10 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"}),!oe&&s.jsx("button",{onClick:()=>C(ee=>!ee),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-300 transition-colors",children:S?s.jsx(np,{size:13}):s.jsx(Us,{size:13})})]}),s.jsx("p",{className:"text-[10px] text-gray-400 px-1",children:oe?`Stored in .env as ${v.envKey}. Default: ${v.placeholder}`:`Stored locally in .env as ${v.envKey} — never sent to external servers.`}),(a==null?void 0:a.activeProvider)===v.id&&a.maskedKey&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-green-500/8 border border-green-500/15 text-green-400 text-[11px]",children:[s.jsx(Fe,{size:11,className:"shrink-0"}),"Active key: ",s.jsx("span",{className:"font-mono",children:a.maskedKey})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[s.jsx(Ue,{size:9}),t.model]}),Et?s.jsx(YE,{currentModel:g,onSelect:w,className:"rounded-xl border border-white/10 bg-white/3"}):s.jsx("select",{value:g,onChange:ee=>w(ee.target.value),className:"w-full bg-white/4 border border-white/10 rounded-xl px-3 py-2.5 text-[12px] text-white outline-none focus:border-orange-500/40 transition-colors appearance-none",children:v.latestModels.map(ee=>s.jsx("option",{value:ee,className:"bg-[#1a0c06]",children:ee},ee))})]}),s.jsxs("div",{className:"flex items-center gap-2.5 pt-1",children:[!de&&s.jsxs("button",{onClick:H,disabled:A||!j&&!(a!=null&&a.configured),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-white/5 border border-white/10 text-[12px] text-gray-300 font-medium hover:bg-white/8 hover:text-white transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:A?"animate-spin":""}),A?t.testing:t.testConnection]}),s.jsxs("button",{onClick:se,disabled:_||!j.trim()&&!oe&&!de,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-orange-600 hover:bg-orange-500 text-white text-[12px] font-semibold transition-all disabled:opacity-40 shadow-lg shadow-orange-500/20",children:[s.jsx(mv,{size:12,className:_?"animate-spin":""}),_?t.saving:t.save]})]}),B&&s.jsxs("div",{className:`flex items-start gap-2 px-3.5 py-2.5 rounded-xl border text-[12px] ${B.ok?"bg-green-500/8 border-green-500/20 text-green-300":"bg-red-500/8 border-red-500/20 text-red-300"}`,children:[B.ok?s.jsx(Fe,{size:13,className:"shrink-0 mt-0.5"}):s.jsx(Ws,{size:13,className:"shrink-0 mt-0.5"}),B.msg]}),$&&s.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20 text-orange-300 text-[12px]",children:[s.jsx(Fe,{size:13,className:"shrink-0"}),$]}),de&&s.jsxs("div",{className:"pt-1 space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[s.jsx(S3,{size:9}),"Custom Base URL (optional)"]}),s.jsx("input",{type:"text",value:j,onChange:ee=>k(ee.target.value),placeholder:"http://localhost:11434",className:"w-full bg-white/4 border border-white/10 rounded-xl px-4 py-2.5 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"}),s.jsx("p",{className:"text-[10px] text-gray-400 px-1",children:"Leave blank to use the default http://localhost:11434"})]})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-8",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-orange-500/8 border border-orange-500/15 flex items-center justify-center",children:s.jsx(Ge,{size:20,className:"text-orange-500/50"})}),s.jsx("p",{className:"text-[13px] text-gray-400",children:"Select a provider from the left to configure your API key"})]})})]})]})}function ZE(e){if(!e)return"—";const t=Date.now()-e;return t<6e4?`${Math.floor(t/1e3)}s önce`:t<36e5?`${Math.floor(t/6e4)}dk önce`:`${Math.floor(t/36e5)}sa önce`}function e_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState("all"),l=async()=>{a(!0);try{const p=await(await U("/api/gateway/sessions?limit=50&includeDerivedTitles=true&includeLastMessage=true")).json(),f=Array.isArray(p)?p:Array.isArray(p==null?void 0:p.sessions)?p.sessions:[];n(f)}catch{n([])}finally{a(!1)}};u.useEffect(()=>{l()},[e]);const c=h=>!!h.runningAtMs&&Date.now()-h.runningAtMs<12e4,d=t.filter(h=>i==="running"?c(h):i==="idle"?!c(h):!0);return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(Ge,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Aktif Oturumlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," oturum"]})]})]}),s.jsxs("button",{onClick:l,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""}),"Yenile"]})]}),!e&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20",children:[s.jsx(vs,{size:13,className:"text-orange-400 flex-shrink-0"}),s.jsx("p",{className:"text-[12px] text-orange-300",children:"Gateway çevrimdışı — oturum verisi alınamıyor."})]}),s.jsx("div",{className:"flex gap-1.5",children:["all","running","idle"].map(h=>s.jsx("button",{onClick:()=>o(h),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${i===h?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:h==="all"?"Tümü":h==="running"?"Çalışıyor":"Boşta"},h))}),r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):d.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(Hs,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Aktif oturum bulunamadı.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"space-y-2",children:d.map(h=>{const p=c(h);return s.jsx("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6 hover:border-white/10 transition-all",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex-shrink-0",children:p?s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-400 animate-pulse"}):s.jsx("span",{className:"block w-2 h-2 rounded-full bg-gray-700"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-[13px] font-semibold text-gray-200 truncate",children:h.derivedTitle??h.label??h.key.slice(0,20)+"…"}),h.agentId&&s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-600 flex-shrink-0",children:[s.jsx(tn,{size:9}),h.agentId]})]}),h.lastMessage&&s.jsx("p",{className:"text-[11px] text-gray-500 truncate mb-1",children:h.lastMessage}),s.jsxs("div",{className:"flex items-center gap-3",children:[h.messageCount!==void 0&&s.jsxs("span",{className:"text-[10px] text-gray-600",children:[h.messageCount," mesaj"]}),s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-600",children:[s.jsx(Lt,{size:9}),ZE(h.lastActivityAt)]})]})]})]})},h.key)})})]})}function t_(e){if(!e||typeof e!="object")return String(e??"—");const t=e;return t.type==="every"&&t.intervalMs?`Her ${Math.round(t.intervalMs/6e4)} dakika`:t.type==="at"&&t.time?`Her gün ${t.time}`:t.type==="cron"&&t.expression?`Cron: ${t.expression}`:JSON.stringify(e).slice(0,40)}function n_(e){if(!e)return"—";const t=e-Date.now();return t<0?"Geçti":t<6e4?`${Math.floor(t/1e3)}s sonra`:t<36e5?`${Math.floor(t/6e4)}dk sonra`:`${Math.floor(t/36e5)}sa sonra`}function s_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState("all"),[l,c]=u.useState(null),[d,h]=u.useState(null),p=async()=>{a(!0);try{const g=await(await U("/api/gateway/automations?enabled=all&limit=50")).json();n(Array.isArray(g==null?void 0:g.jobs)?g.jobs:Array.isArray(g)?g:[])}catch{n([])}finally{a(!1)}};u.useEffect(()=>{p()},[e]);const f=async x=>{try{await U(`/api/gateway/automations/${x.id}`,{method:"PATCH",body:JSON.stringify({patch:{enabled:!x.enabled}})}),n(g=>g.map(w=>w.id===x.id?{...w,enabled:!w.enabled}:w))}catch{}},m=async x=>{c(x);try{await U(`/api/gateway/automations/${x}/run`,{method:"POST"}),await p()}catch{}finally{c(null)}},b=async x=>{if(window.confirm("Bu otomasyon silinsin mi?")){h(x);try{await U(`/api/gateway/automations/${x}`,{method:"DELETE"}),n(g=>g.filter(w=>w.id!==x))}catch{}finally{h(null)}}},y=t.filter(x=>i==="enabled"?x.enabled:i==="disabled"?!x.enabled:!0),v=x=>x==="ok"?s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-green-400",children:[s.jsx(Fe,{size:9})," Başarılı"]}):x==="error"?s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[s.jsx(av,{size:9})," Hata"]}):s.jsx("span",{className:"text-[10px] text-gray-600",children:"—"});return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(Ue,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Otomasyonlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," zamanlanmış görev"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!e&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] bg-red-500/8 border border-red-500/20 text-red-400",children:[s.jsx(vs,{size:10})," Çevrimdışı"]}),s.jsxs("button",{onClick:p,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""})," Yenile"]})]})]}),s.jsx("div",{className:"flex gap-1.5",children:["all","enabled","disabled"].map(x=>s.jsx("button",{onClick:()=>o(x),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${i===x?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:x==="all"?"Tümü":x==="enabled"?"Aktif":"Pasif"},x))}),r?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(Ue,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Otomasyon bulunamadı.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"space-y-2",children:y.map(x=>{var g,w;return s.jsx("div",{className:`px-4 py-3 rounded-xl border transition-all ${x.enabled?"bg-white/[0.025] border-white/6":"bg-white/[0.01] border-white/4"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>f(x),disabled:!e,className:"mt-0.5 text-gray-500 hover:text-orange-400 transition-colors disabled:opacity-40",title:x.enabled?"Devre dışı bırak":"Etkinleştir",children:x.enabled?s.jsx(Y3,{size:18,className:"text-orange-400"}):s.jsx(q3,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:`text-[13px] font-semibold truncate ${x.enabled?"text-gray-200":"text-gray-500"}`,children:x.name??x.id}),v((g=x.state)==null?void 0:g.lastRunStatus)]}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-gray-500",children:[s.jsx(Lt,{size:9})," ",t_(x.schedule)]}),((w=x.state)==null?void 0:w.nextRunAtMs)&&s.jsx("span",{className:"text-[11px] text-gray-600",children:n_(x.state.nextRunAtMs)})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsxs("button",{onClick:()=>m(x.id),disabled:!e||l===x.id,className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-orange-500/8 border border-orange-500/20 text-orange-400 text-[10px] font-semibold hover:bg-orange-500/15 transition-all disabled:opacity-40",children:[l===x.id?s.jsx(ge,{size:9,className:"animate-spin"}):s.jsx(gs,{size:9}),"Çalıştır"]}),s.jsxs("button",{onClick:()=>b(x.id),disabled:!e||d===x.id,className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/8 border border-red-500/20 text-red-400 text-[10px] font-semibold hover:bg-red-500/15 transition-all disabled:opacity-40",children:[d===x.id?s.jsx(ge,{size:9,className:"animate-spin"}):s.jsx(ys,{size:9}),"Sil"]})]})]})},x.id)})})]})}function r_(e){var t;return(t=e.presence)!=null&&t.ts?Date.now()-e.presence.ts<6e4:!1}function a_({platform:e}){const t=(e??"").toLowerCase();return t.includes("ios")||t.includes("iphone")?s.jsx(c0,{size:14,className:"text-gray-400"}):t.includes("android")?s.jsx(c0,{size:14,className:"text-green-500"}):t.includes("mac")||t.includes("darwin")?s.jsx(l3,{size:14,className:"text-gray-300"}):t.includes("win")?s.jsx(op,{size:14,className:"text-blue-400"}):s.jsx(dv,{size:14,className:"text-gray-500"})}function i_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState(null),[l,c]=u.useState(""),d=async()=>{a(!0);try{const f=await(await U("/api/gateway/clients")).json();n(Array.isArray(f==null?void 0:f.nodes)?f.nodes:Array.isArray(f)?f:[])}catch{n([])}finally{a(!1)}};u.useEffect(()=>{d()},[e]);const h=async p=>{if(!l.trim()){o(null);return}try{await U(`/api/gateway/clients/${p}/rename`,{method:"POST",body:JSON.stringify({displayName:l.trim()})}),n(f=>f.map(m=>m.nodeId===p?{...m,displayName:l.trim()}:m))}catch{}finally{o(null)}};return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(pu,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Bağlı Nodlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," cihaz"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!e&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] bg-red-500/8 border border-red-500/20 text-red-400",children:[s.jsx(vs,{size:10})," Çevrimdışı"]}),s.jsxs("button",{onClick:d,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""})," Yenile"]})]})]}),r?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):t.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(pu,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Bağlı node yok.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"grid grid-cols-2 gap-3",children:t.map(p=>s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6 hover:border-white/10 transition-all",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[s.jsx(a_,{platform:p.platform}),s.jsx("div",{className:"flex-1 min-w-0",children:i===p.nodeId?s.jsx("input",{autoFocus:!0,value:l,onChange:f=>c(f.target.value),onBlur:()=>h(p.nodeId),onKeyDown:f=>{f.key==="Enter"&&h(p.nodeId),f.key==="Escape"&&o(null)},className:"w-full bg-white/6 border border-orange-500/30 rounded-lg px-2 py-0.5 text-[13px] text-white outline-none"}):s.jsx("p",{className:"text-[13px] font-semibold text-gray-200 truncate cursor-text",onDoubleClick:()=>{o(p.nodeId),c(p.displayName??"")},title:"Çift tıklayarak düzenle",children:p.displayName??p.nodeId})}),s.jsx("span",{className:`flex-shrink-0 w-2 h-2 rounded-full mt-1 ${r_(p)?"bg-green-400 animate-pulse":"bg-gray-700"}`})]}),s.jsxs("div",{className:"space-y-1",children:[p.platform&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-16",children:"Platform"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:p.platform})]}),p.version&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-16",children:"Versiyon"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:p.version})]}),(p.caps??[]).length>0&&s.jsxs("div",{className:"flex items-center gap-1 flex-wrap mt-1",children:[(p.caps??[]).slice(0,3).map(f=>s.jsx("span",{className:"px-1.5 py-0.5 rounded-md bg-orange-500/8 border border-orange-500/15 text-[9px] text-orange-400 font-medium",children:f},f)),(p.caps??[]).length>3&&s.jsxs("span",{className:"text-[9px] text-gray-600",children:["+",(p.caps??[]).length-3]})]})]})]},p.nodeId))})]})}function o_({online:e}){var d;const[t,n]=u.useState({}),[r,a]=u.useState(!0),i=u.useRef(0),o=u.useRef(null),l=async(h=0)=>{try{const f=await(await U(`/api/gateway/logs?cursor=${h}&limit=200`)).json();h===0?(n(f),i.current=f.cursor??0):(n(m=>({...f,lines:[...m.lines??[],...f.lines??[]]})),i.current=f.cursor??i.current)}catch{}finally{a(!1)}};u.useEffect(()=>{l(0)},[e]),u.useEffect(()=>{const h=setInterval(()=>l(i.current),1e4);return()=>clearInterval(h)},[e]),u.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[(d=t.lines)==null?void 0:d.length]);const c=h=>h.includes("error")||h.includes("ERROR")?"text-red-400":h.includes("warn")||h.includes("WARN")?"text-amber-400":h.includes("info")||h.includes("INFO")?"text-green-400":"text-gray-400";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("p",{className:"text-[11px] text-gray-600",children:[(t.lines??[]).length," satır"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>navigator.clipboard.writeText((t.lines??[]).join(`
|
|
750
|
+
`)}`:"⏹ Durduruldu.");return{...$,status:"done",content:R}})),x.current=null},disabled:j||A}),s.jsx("p",{className:"text-center text-[11px] text-white/20 mt-2 select-none",children:e.chat.disclaimer})]})]})]})}function vE(){const[e,t]=u.useState(!1);return u.useEffect(()=>{const n=pe();return n.on("agentUpdate",r=>{r.type==="SCREEN_CAPTURE_START"&&t(!0),(r.type==="SCREEN_CAPTURED"||r.type==="SCREEN_CAPTURE_END")&&setTimeout(()=>t(!1),700)}),()=>{n.off("agentUpdate")}},[]),s.jsx(ae,{children:e&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},className:"fixed inset-0 z-[9999] pointer-events-none",children:[s.jsxs("div",{className:"absolute inset-0",children:[s.jsx("div",{className:"absolute top-0 left-0 w-12 h-12 border-t-2 border-l-2 border-orange-500/70"}),s.jsx("div",{className:"absolute top-0 right-0 w-12 h-12 border-t-2 border-r-2 border-orange-500/70"}),s.jsx("div",{className:"absolute bottom-0 left-0 w-12 h-12 border-b-2 border-l-2 border-orange-500/70"}),s.jsx("div",{className:"absolute bottom-0 right-0 w-12 h-12 border-b-2 border-r-2 border-orange-500/70"})]}),s.jsx(V.div,{className:"absolute left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-orange-500/60 to-transparent",animate:{top:["0%","100%"]},transition:{duration:1.4,repeat:1/0,ease:"linear"}}),s.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2",children:s.jsxs(V.div,{initial:{y:-10,opacity:0},animate:{y:0,opacity:1},className:"flex items-center gap-2 px-4 py-2 bg-black/80 border border-orange-500/30 rounded-full shadow-[0_0_20px_rgba(234,88,12,0.3)] backdrop-blur-xl",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-orange-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-orange-500"})]}),s.jsx(ui,{size:12,className:"text-orange-400 animate-spin"}),s.jsx("span",{className:"text-orange-300 text-xs font-semibold tracking-wide",children:"Scanning screen…"})]})})]},"scan-overlay")})}const no={button:"rgba(234,88,12,0.7)",input:"rgba(59,130,246,0.7)",image:"rgba(168,85,247,0.6)",unknown:"rgba(255,255,255,0.3)"},bE={browse:Ge,write:nn,think:Zt,exec:Mn},wE={running:"bg-orange-500/8 border border-orange-500/20 text-orange-300",done:"bg-green-500/5 border border-green-500/10 text-gray-500",queued:"bg-white/2 border border-white/5 text-gray-600"},kE={mouseMove:L3,mouseClick:pv,typeText:E3,visionClick:Us},jE={mouseMove:"text-gray-500",mouseClick:"text-orange-400",typeText:"text-blue-400",visionClick:"text-purple-400"};function NE(){const{t:e}=yt(),[t,n]=u.useState(!1),[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useRef(null),[h,p]=u.useState(null),[f,m]=u.useState(!1),[b,y]=u.useState(()=>new Array(3).fill(null)),[v,x]=u.useState(0),[g,w]=u.useState([]),[j,k]=u.useState(null),[S,C]=u.useState([]),A=u.useRef(null),[N,_]=u.useState(!1),[L,B]=u.useState(!1);u.useEffect(()=>{if(!r||!d.current)return;const z=d.current,P=z.getContext("2d");if(!P)return;const E=new Image;E.onload=()=>{var T;if(z.width=E.width,z.height=E.height,P.drawImage(E,0,0),(T=r.elements)!=null&&T.length)for(const O of r.elements)P.strokeStyle=no[O.type]??no.unknown,P.lineWidth=Math.max(2,Math.round(E.width/400)),P.strokeRect(O.x,O.y,O.width,O.height),P.fillStyle=no[O.type]??no.unknown,P.font=`${Math.max(10,Math.round(E.width/120))}px monospace`,P.fillText(O.type,O.x+4,O.y+14)},E.src=`data:image/png;base64,${r.base64}`},[r]),u.useEffect(()=>{const z=pe(),P=E=>{if(E.type==="SCREEN_CAPTURE_START"&&n(!0),E.type==="SCREEN_CAPTURED"&&(n(!1),a({base64:E.base64,width:E.width,height:E.height,source:E.source,elements:E.elements}),_(!1),B(!1)),E.type==="workflowStart"&&(k(E.goal??null),w(E.steps??[]),_(!1),B(!1)),E.type==="workflowStep"&&E.step){const T=E.step;w(O=>O.map(G=>G.id===T.id?T:G))}if(E.type==="workflowDone"&&setTimeout(()=>{w([]),k(null)},2500),E.type==="shadowFrame"&&typeof E.slot!="number"&&(p(E.base64),m(!0),_(!1)),E.type==="shadowToggle"&&typeof E.slot!="number"&&(m(E.enabled),E.enabled||p(null)),E.type==="ghostFrame"){const T=typeof E.slot=="number"?E.slot:-1;T>=0&&T<=2&&typeof E.base64=="string"&&(y(O=>{const G=[...O];return G[T]=E.base64,G}),_(!1))}if(E.type==="ghostSlot"){const T=typeof E.slot=="number"?E.slot:-1;T>=0&&T<=2&&x(T)}if(E.type==="shadowToggle"&&typeof E.slot=="number"){const T=E.slot;T>=0&&T<=2&&!E.enabled&&y(O=>{const G=[...O];return G[T]=null,G})}if(E.type==="inputAction"){const T={id:`${Date.now()}-${Math.random()}`,action:E.action??"mouseClick",label:E.label??"",timestamp:E.timestamp??Date.now()};C(O=>[...O.slice(-11),T]),_(!1),B(!1)}};return z.on("agentUpdate",P),()=>{z.off("agentUpdate",P)}},[]),u.useEffect(()=>{var z;(z=A.current)==null||z.scrollIntoView({behavior:"smooth"})},[S]);const M=async()=>{if(!t){try{const z=await U("/api/system/vision-guidance");if(z.ok){const P=await z.json();P.warn&&P.message&&o(P.message)}}catch{}await U("/api/system/screenshot",{method:"POST",body:JSON.stringify({detect:!0})}).catch(()=>{})}},$=b.some(z=>z!==null);return!(r||g.length>0||S.length>0||t||f||$)||L?null:s.jsx(ae,{children:s.jsxs(V.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.22},className:"mx-4 mb-3 bg-[#0a0d16] border border-orange-500/12 rounded-2xl overflow-hidden shadow-xl shadow-orange-500/4 shrink-0",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-500 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-orange-400 uppercase tracking-widest",children:"War Room"}),r&&s.jsxs("span",{className:"text-[10px] text-gray-600 font-mono",children:[r.width,"×",r.height]}),f&&s.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/25 px-2 py-0.5 rounded-full",children:[s.jsx(Zi,{size:9,className:"animate-pulse"}),"Shadow Active"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:M,disabled:t,className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-all ${t?"text-orange-400 bg-orange-500/10 animate-pulse cursor-not-allowed":"text-gray-600 hover:text-orange-400 hover:bg-orange-500/8 border border-white/5"}`,children:[s.jsx(ui,{size:10}),t?"Scanning…":"Capture"]}),r&&s.jsx("button",{onClick:()=>c(z=>!z),className:"text-gray-700 hover:text-gray-400 transition-colors",title:l?"Collapse preview":"Expand preview",children:l?s.jsx(np,{size:12}):s.jsx(Us,{size:12})}),s.jsx("button",{onClick:()=>_(z=>!z),className:"text-gray-700 hover:text-gray-400 transition-colors",title:N?"Expand war room":"Collapse war room",children:N?s.jsx(Xs,{size:12}):s.jsx(Bl,{size:12})}),s.jsx("button",{onClick:()=>B(!0),className:"text-gray-700 hover:text-red-400 transition-colors",title:"Dismiss war room",children:s.jsx(ze,{size:12})})]})]}),s.jsx(ae,{children:!N&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:[i&&s.jsxs("div",{className:"px-4 py-2 bg-amber-500/8 border-b border-amber-500/15 flex items-start justify-between gap-2",children:[s.jsx("p",{className:"text-[11px] text-amber-400 leading-relaxed flex-1",children:i}),s.jsx("button",{onClick:()=>o(null),className:"text-[10px] text-amber-600 hover:text-amber-400 shrink-0",children:"Dismiss"})]}),s.jsxs("div",{className:"flex gap-0 divide-x divide-white/5",children:[s.jsx("div",{className:"w-1/2 shrink-0",children:$&&b[v]?s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"flex border-b border-white/5",children:[0,1,2].map(z=>b[z]!==null&&s.jsxs("button",{onClick:()=>x(z),className:`flex items-center gap-0.5 px-2 py-1 text-[9px] font-bold transition-colors ${v===z?"text-purple-400 border-b-2 border-purple-500":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Zi,{size:7})," G",z+1]},z))}),s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[110px]"}`,children:[s.jsx("img",{src:`data:image/jpeg;base64,${b[v]}`,alt:`Ghost ${v+1}`,className:"w-full object-contain"}),s.jsxs("div",{className:"absolute top-1.5 left-1.5 flex items-center gap-1 px-2 py-0.5 bg-black/75 rounded-lg text-[9px] font-bold text-purple-400 border border-purple-500/30",children:[s.jsx(Zi,{size:8,className:"animate-pulse"})," G",v+1]}),s.jsx("div",{className:"absolute bottom-1.5 right-1.5 px-1.5 py-0.5 bg-black/70 rounded text-[8px] font-mono text-purple-300 border border-purple-500/20",children:"LIVE"})]})]}):f&&h?s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[120px]"}`,children:[s.jsx("img",{src:`data:image/jpeg;base64,${h}`,alt:"Shadow browser",className:"w-full object-contain"}),s.jsxs("div",{className:"absolute top-1.5 left-1.5 flex items-center gap-1 px-2 py-0.5 bg-black/75 rounded-lg text-[9px] font-bold text-purple-400 border border-purple-500/30",children:[s.jsx(Zi,{size:8,className:"animate-pulse"})," SHADOW"]}),s.jsx("div",{className:"absolute bottom-1.5 right-1.5 px-1.5 py-0.5 bg-black/70 rounded text-[8px] font-mono text-purple-300 border border-purple-500/20",children:"LIVE"})]}):r?s.jsxs("div",{className:`relative overflow-hidden transition-all duration-300 ${l?"max-h-[300px]":"max-h-[120px]"}`,children:[s.jsx("canvas",{ref:d,className:"w-full object-contain",style:{imageRendering:"auto"}}),r.elements&&r.elements.length>0&&s.jsxs("div",{className:"absolute bottom-1.5 right-1.5 px-2 py-0.5 bg-black/70 rounded text-[9px] font-mono text-orange-400 border border-orange-500/20",children:[r.elements.length," elements"]})]}):t?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-orange-400 text-xs animate-pulse",children:[s.jsx(ui,{size:13,className:"animate-spin"})," Scanning…"]}):s.jsx("div",{className:"flex items-center justify-center py-8 text-gray-700 text-[11px]",children:"No capture yet"})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[g.length>0&&s.jsxs("div",{className:"border-b border-white/5",children:[j&&s.jsx("div",{className:"px-3 py-1.5 border-b border-white/4 bg-white/[0.01]",children:s.jsxs("p",{className:"text-[10px] text-gray-500 truncate",children:[e.workflow.goal,": ",s.jsx("span",{className:"text-gray-300",children:j})]})}),s.jsx("div",{className:"p-2 space-y-1 max-h-[100px] overflow-y-auto scrollbar-hide",children:g.map(z=>{const P=bE[z.type]??Zt;return s.jsxs("div",{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-xl text-[11px] font-medium ${wE[z.status]}`,children:[z.status==="running"?s.jsx(ne,{size:11,className:"animate-spin text-orange-400 shrink-0"}):z.status==="done"?s.jsx(Fe,{size:11,className:"text-green-500 shrink-0"}):s.jsx(P,{size:11,className:"text-gray-600 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:z.label})]},z.id)})})]}),S.length>0&&s.jsxs("div",{className:"flex-1 overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1 border-b border-white/4",children:s.jsx("span",{className:"text-[9px] font-bold text-gray-600 uppercase tracking-widest",children:"Control Feed"})}),s.jsxs("div",{className:"px-2 py-1 space-y-px overflow-y-auto max-h-[100px] scrollbar-hide font-mono",children:[S.map(z=>{const P=kE[z.action]??pv,E=jE[z.action]??"text-gray-500";return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(P,{size:10,className:`${E} shrink-0`}),s.jsx("span",{className:`text-[10px] ${E} truncate flex-1`,children:z.label}),s.jsx("span",{className:"text-[9px] text-gray-700 shrink-0 tabular-nums",children:new Date(z.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]},z.id)}),s.jsx("div",{ref:A})]})]})]})]})]})})]})})}const v0="mustb_briefing_shown",SE=14*60*60*1e3,bu={CodeHealth:{label:"Kod Sağlığı",Icon:en,color:"#fb923c"},DepAudit:{label:"Bağımlılık Denetimi",Icon:Qs,color:"#a78bfa"},LogAnalysis:{label:"Log Analizi",Icon:nn,color:"#38bdf8"},LTMGap:{label:"Bellek Boşluğu",Icon:Zt,color:"#34d399"},WorkspaceDiff:{label:"Değişiklik Özeti",Icon:ov,color:"#fbbf24"}};function CE(e){const t=Object.keys(bu).find(n=>e.toLowerCase().includes(n.toLowerCase()));return t?bu[t]:{label:e,Icon:mn,color:"#fb923c"}}function EE(e){const t=new Set(["NightShift-Insights","nightshift-insights","nightshift","night-shift"]);return e.find(n=>!t.has(n))??"General"}function b0(e){if(!e)return"—";const t=Math.round(e/1e3);return t<60?`${t} sn`:`${Math.floor(t/60)} dk ${t%60} sn`}function _E(e){const t=Date.now()-e,n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n} saat ${r} dk önce`:r>0?`${r} dk önce`:"Az önce"}const TE={hidden:{opacity:0},show:{opacity:1,transition:{duration:.4}},exit:{opacity:0,transition:{duration:.35}}},PE={hidden:{opacity:0,y:32,scale:.97},show:{opacity:1,y:0,scale:1,transition:{type:"spring",stiffness:260,damping:26}},exit:{opacity:0,y:20,scale:.97,transition:{duration:.25}}},AE={hidden:{},show:{transition:{staggerChildren:.11,delayChildren:.45}}},ME={hidden:{opacity:0,x:24},show:{opacity:1,x:0,transition:{type:"spring",stiffness:300,damping:28}}};function zE(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState([]),[o,l]=u.useState(!0),c=u.useRef(!1);u.useEffect(()=>{c.current||(c.current=!0,(async()=>{try{const h=await U("/api/automation/nightowl/status");if(!h.ok)return;const p=await h.json();if(!p.lastShiftTs||Date.now()-p.lastShiftTs>SE||localStorage.getItem(v0)===String(p.lastShiftTs)||p.totalFindings===0)return;const f=await U("/api/memory/ltm/search?q=NightShift-Insights&limit=15&category=semantic"),b=(f.ok?await f.json():{results:[]}).results.filter(y=>y.tags.some(v=>v.toLowerCase().includes("nightshift"))).slice(0,8).map(y=>({task:EE(y.tags),summary:y.content.replace(/\n/g," ").slice(0,180)}));r(p),i(b),l(!1),t(!0),localStorage.setItem(v0,String(p.lastShiftTs))}catch{}})())},[]);const d=()=>t(!1);return s.jsx(ae,{children:e&&s.jsx(V.div,{variants:TE,initial:"hidden",animate:"show",exit:"exit",className:"fixed inset-0 z-[400] flex items-center justify-center px-4",style:{background:"rgba(4,1,0,0.82)",backdropFilter:"blur(8px)"},onClick:h=>{h.target===h.currentTarget&&d()},children:s.jsxs(V.div,{variants:PE,initial:"hidden",animate:"show",exit:"exit",className:"relative w-full max-w-[620px] max-h-[88vh] flex flex-col rounded-3xl overflow-hidden",style:{background:"rgba(14,6,1,0.92)",border:"1px solid rgba(249,115,22,0.22)",backdropFilter:"blur(32px)",boxShadow:"0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsx("button",{onClick:d,className:"absolute top-4 right-4 z-10 w-7 h-7 rounded-full flex items-center justify-center text-white/25 hover:text-white/70 hover:bg-white/8 transition-all",children:s.jsx(ze,{size:14})}),s.jsxs("div",{className:"flex-shrink-0 px-8 pt-8 pb-6",style:{borderBottom:"1px solid rgba(249,115,22,0.10)"},children:[s.jsxs(V.div,{initial:{opacity:0,y:-12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.5},className:"flex items-start gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)",boxShadow:"0 0 24px rgba(249,115,22,0.15)"},children:s.jsx(Si,{size:22,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[11px] font-semibold text-orange-400/60 tracking-widest uppercase mb-1",children:"Sabah Raporu"}),s.jsx("h2",{className:"text-[22px] font-black text-white/90 leading-tight tracking-tight",children:"Gece Vardiyası Tamamlandı"}),(n==null?void 0:n.lastShiftTs)&&s.jsxs("p",{className:"text-[12px] text-white/35 mt-1",children:[_E(n.lastShiftTs)," · ",b0(n.lastShiftMs)," sürdü"]})]})]}),n&&s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"flex items-center gap-4 mt-5",children:[{label:"Bulgu",value:String(n.totalFindings)},{label:"Görev",value:String(Object.keys(bu).length)},{label:"Süre",value:b0(n.lastShiftMs)}].map(h=>s.jsxs("div",{className:"flex-1 rounded-xl px-3 py-2.5 text-center",style:{background:"rgba(249,115,22,0.06)",border:"1px solid rgba(249,115,22,0.12)"},children:[s.jsx("p",{className:"text-[18px] font-black text-orange-400",children:h.value}),s.jsx("p",{className:"text-[10px] text-white/30 font-medium mt-0.5",children:h.label})]},h.label))})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-8 py-5 space-y-2.5",style:{scrollbarWidth:"none"},children:[o&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"flex gap-1.5",children:[0,1,2].map(h=>s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-400/40 animate-bounce",style:{animationDelay:`${h*.15}s`}},h))})}),!o&&a.length===0&&s.jsx("p",{className:"text-center text-[13px] text-white/30 py-10",children:"Kayıtlı bulgu bulunamadı."}),!o&&a.length>0&&s.jsx(V.div,{variants:AE,initial:"hidden",animate:"show",className:"space-y-2.5",children:a.map((h,p)=>{const f=CE(h.task),m=f.Icon;return s.jsx(V.div,{variants:ME,children:s.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-2xl",style:{background:"rgba(255,255,255,0.03)",border:`1px solid ${f.color}22`},children:[s.jsx("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:`${f.color}15`,border:`1px solid ${f.color}30`},children:s.jsx(m,{size:14,style:{color:f.color}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-bold mb-1 tracking-wide",style:{color:f.color},children:f.label}),s.jsx("p",{className:"text-[12.5px] text-white/65 leading-relaxed",children:h.summary})]}),s.jsx(gn,{size:13,className:"text-white/15 flex-shrink-0 mt-1"})]})},p)})})]}),s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.6},className:"flex-shrink-0 px-8 py-5",style:{borderTop:"1px solid rgba(249,115,22,0.10)"},children:s.jsxs("button",{onClick:d,className:"w-full py-3 rounded-2xl flex items-center justify-center gap-2 font-bold text-[14px] transition-all active:scale-[0.98]",style:{background:"rgba(249,115,22,0.15)",border:"1px solid rgba(249,115,22,0.30)",color:"#fdba74"},onMouseEnter:h=>h.currentTarget.style.background="rgba(249,115,22,0.22)",onMouseLeave:h=>h.currentTarget.style.background="rgba(249,115,22,0.15)",children:[s.jsx(Ue,{size:15}),"Günün başlasın"]})})]})},"morning-briefing-overlay")})}const w0={CodeHealth:{label:"Kod Sağlığı",Icon:en,color:"#fb923c"},DepAudit:{label:"Bağımlılık",Icon:Qs,color:"#a78bfa"},LogAnalysis:{label:"Log Analizi",Icon:nn,color:"#38bdf8"},LTMGap:{label:"Bellek",Icon:Zt,color:"#34d399"},WorkspaceDiff:{label:"Değişiklikler",Icon:ov,color:"#fbbf24"}};function RE(e){const t=Object.keys(w0).find(n=>e.toLowerCase().includes(n.toLowerCase()));return t?w0[t]:{label:e,Icon:mn,color:"#fb923c"}}function LE(e){const t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}const OE={hidden:{opacity:0,x:24,scale:.96},show:{opacity:1,x:0,scale:1,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,x:24,scale:.96,transition:{duration:.22}}},IE={hidden:{opacity:0,y:-6},show:{opacity:1,y:0,transition:{duration:.22}}};function DE(){const[e,t]=u.useState("idle"),[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(!1),h=u.useRef(null),p=u.useRef(0),f=u.useCallback((b=2e4)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{l(!1),setTimeout(()=>d(!1),600)},b)},[]);if(u.useEffect(()=>{const b=pe();return b.on("nightOwlEvent",y=>{if(y.type==="shiftStart"){h.current&&clearTimeout(h.current),t("scanning"),r([]),i(null),d(!0),l(!0);return}if(y.type==="finding"){const v={id:`${++p.current}`,task:String(y.task??"General"),summary:String(y.summary??"").slice(0,120),ts:Number(y.ts??Date.now())};r(x=>[v,...x].slice(0,20));return}if(y.type==="shiftEnd"){t("done"),i({findingsCount:Number(y.findingsCount??0),durationMs:Number(y.durationMs??0),ts:Number(y.ts??Date.now())}),f(2e4);return}}),()=>{b.off("nightOwlEvent"),h.current&&clearTimeout(h.current)}},[f]),!c)return null;const m="#fb923c";return s.jsx(ae,{children:s.jsx(V.div,{variants:OE,initial:"hidden",animate:"show",exit:"exit",className:"fixed z-[130] flex flex-col",style:{top:"80px",right:"20px",width:"300px",maxHeight:"70vh",pointerEvents:"auto"},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden flex flex-col",style:{background:"rgba(10,4,1,0.90)",border:`1px solid ${m}28`,backdropFilter:"blur(24px)",boxShadow:"0 12px 40px rgba(0,0,0,0.60), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("button",{onClick:()=>{l(b=>!b),h.current&&clearTimeout(h.current)},className:"flex items-center justify-between px-4 py-3 w-full select-none",style:{borderBottom:o?`1px solid ${m}10`:"none"},children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[e==="scanning"?s.jsxs("span",{className:"relative flex-shrink-0",children:[s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-400"}),s.jsx("span",{className:"absolute inset-0 rounded-full bg-orange-400 animate-ping opacity-70"})]}):e==="done"?s.jsx(Fe,{size:13,className:"text-green-400 flex-shrink-0"}):s.jsx(Si,{size:13,className:"text-orange-300/50 flex-shrink-0"}),s.jsx("span",{className:"text-[12px] font-semibold text-white/75",children:e==="scanning"?"Gece Vardiyası":"Vardiya Logu"}),e==="scanning"&&s.jsx("span",{className:"text-[10px] text-orange-400/70 font-mono animate-pulse",children:"taranıyor…"}),e==="done"&&a&&s.jsxs("span",{className:"text-[10px] text-white/30 font-mono",children:[a.findingsCount," bulgu · ",LE(a.durationMs)]})]}),o?s.jsx(Bl,{size:12,className:"text-white/25"}):s.jsx(Xs,{size:12,className:"text-white/25"})]}),s.jsx(ae,{children:o&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22},className:"overflow-hidden",children:[s.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:"52vh",scrollbarWidth:"none"},children:[e==="scanning"&&n.length===0&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2",children:[s.jsx("div",{className:"flex gap-1",children:[0,1,2].map(b=>s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-orange-400/50 animate-bounce",style:{animationDelay:`${b*.15}s`}},b))}),s.jsx("span",{className:"text-[11px] text-white/30",children:"Sistem analiz ediliyor…"})]}),s.jsx(ae,{initial:!1,children:n.map(b=>{const y=RE(b.task),v=y.Icon;return s.jsxs(V.div,{variants:IE,initial:"hidden",animate:"show",exit:{opacity:0,height:0},className:"flex items-start gap-3 px-4 py-3",style:{borderBottom:"1px solid rgba(255,255,255,0.04)"},children:[s.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:`${y.color}15`,border:`1px solid ${y.color}30`},children:s.jsx(v,{size:11,style:{color:y.color}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[10px] font-bold mb-0.5",style:{color:y.color},children:y.label}),s.jsx("p",{className:"text-[11px] text-white/50 leading-snug line-clamp-3",children:b.summary})]})]},b.id)})}),e==="done"&&n.length===0&&s.jsx("p",{className:"text-center text-[12px] text-white/25 py-8",children:"Kayda değer bulgu yok."})]}),e==="done"&&a&&s.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",style:{borderTop:`1px solid ${m}10`},children:[s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(a.ts).toLocaleTimeString("tr-TR")}),s.jsx("span",{className:"text-[10px] text-green-400/70 font-semibold",children:"✓ Tamamlandı"})]})]},"log-body")})]})},"night-shift-log")})}const k0="mustb_boot_report",j0=14e3;function BE({value:e,max:t=10}){const n=Math.round(e/t*100),r=n>=70?"#22c55e":n>=40?"#f97316":"#ef4444";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden",style:{background:"rgba(255,255,255,0.08)"},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${n}%`,background:r}})}),s.jsx("span",{className:"text-[11px] font-mono",style:{color:r},children:e.toFixed(1)})]})}function FE(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),a=u.useCallback(()=>{t(!1),localStorage.removeItem(k0)},[]);return u.useEffect(()=>{if(localStorage.getItem(k0)!=="1")return;t(!0),U("/api/status").then(o=>o.ok?o.json():null).then(o=>{o&&r(o)}).catch(()=>{});const i=setTimeout(a,j0);return()=>clearTimeout(i)},[a]),s.jsx(ae,{children:e&&s.jsx(V.div,{initial:{opacity:0,scale:.96,y:16},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:16},transition:{duration:.28,ease:"easeOut"},className:"fixed inset-0 z-[500] flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)"},children:s.jsxs("div",{className:"relative w-full max-w-sm rounded-2xl overflow-hidden",style:{background:"rgba(14,6,2,0.92)",border:"1px solid rgba(234,88,12,0.30)",boxShadow:"0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(234,88,12,0.10)",backdropFilter:"blur(24px)"},children:[s.jsx("button",{onClick:a,className:"absolute top-3 right-3 text-white/25 hover:text-white/60 transition-colors z-10",children:s.jsx(ze,{size:14})}),s.jsxs("div",{className:"px-5 pt-5 pb-3 flex items-center gap-3",children:[s.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.25)"},children:s.jsx(Fe,{size:18,style:{color:"#22c55e"}})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:"System Ready"}),s.jsx("p",{className:"text-[11px] text-white/40",children:"Must-b initialised successfully"})]})]}),s.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.05)",margin:"0 20px"}}),s.jsxs("div",{className:"px-5 py-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-white/30 mb-1",children:"Agent"}),s.jsx("p",{className:"text-[12px] font-semibold text-white/80 truncate",children:(n==null?void 0:n.role)??"—"})]}),s.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-white/30 mb-1",children:"Model"}),s.jsx("p",{className:"text-[12px] font-semibold text-white/80 truncate",children:(n==null?void 0:n.model)??"—"})]})]}),s.jsxs("div",{className:"rounded-xl px-3 py-2.5 space-y-2",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(tn,{size:10})," CPU"]}),s.jsxs("span",{className:"text-[10px] font-mono text-white/50",children:[(n==null?void 0:n.cpuPct)??0,"%"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(M3,{size:10})," RAM"]}),s.jsxs("span",{className:"text-[10px] font-mono text-white/50",children:[((n==null?void 0:n.ramGb)??0).toFixed(2)," GB"]})]}),n&&s.jsxs("div",{className:"flex items-center justify-between pt-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold text-white/40",children:[s.jsx(Ue,{size:10})," Score"]}),s.jsx(BE,{value:n.score})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-1",children:[s.jsx("span",{className:"text-[10px] text-white/30",children:"Dashboard port"}),s.jsxs("span",{className:"text-[11px] font-mono text-orange-400/70",children:[":",(n==null?void 0:n.port)??4309]})]})]}),s.jsx("div",{className:"px-5 pb-4",style:{borderTop:"1px solid rgba(255,255,255,0.05)",paddingTop:"12px"},children:s.jsx("button",{onClick:a,className:"w-full py-2 rounded-xl text-[12px] font-semibold transition-all",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.30)",color:"#fb923c"},children:"Open Dashboard"})}),s.jsx(V.div,{initial:{scaleX:1},animate:{scaleX:0},transition:{duration:j0/1e3,ease:"linear"},style:{position:"absolute",bottom:0,left:0,right:0,height:2,background:"rgba(234,88,12,0.50)",transformOrigin:"left"}})]})},"boot-report")})}function $E(e,t){if(t.includes("🛡")||t.toLowerCase().includes("ghostguard"))return"#fb923c";switch(e){case"thought":return"#22d3ee";case"planStart":return"#67e8f9";case"planGenerated":return"#a5f3fc";case"stepStart":return"#06b6d4";case"stepFinish":return t.includes("error")||t.includes("fail")?"#f87171":"#4ade80";case"finalAnswer":return"#86efac";case"planFinish":return t.includes("failed")||t.includes("error")?"#f87171":"#4ade80";case"error":return"#fb923c";case"memorySearch":return"#a78bfa";case"systemHealth":return"#fbbf24";default:return"#4b5563"}}function VE(e){switch(e){case"thought":return"◎";case"planStart":return"▶";case"planGenerated":return"◈";case"stepStart":return"→";case"stepFinish":return"✓";case"finalAnswer":return"◆";case"planFinish":return"■";case"error":return"⚠";case"memorySearch":return"⟳";case"systemHealth":return"🛡";default:return"·"}}function UE(e,t){var n,r;if(!t)return e;switch(e){case"thought":return String(t.message??t).slice(0,120);case"planStart":return`Goal: ${String(t.goal??"").slice(0,90)}`;case"planGenerated":return`Plan ready — ${Array.isArray(t.steps)?t.steps.length:"?"} steps`;case"stepStart":return String(((n=t.step)==null?void 0:n.description)??t.description??"Step starting…").slice(0,100);case"stepFinish":{const a=String(((r=t.step)==null?void 0:r.description)??t.description??"").slice(0,70),i=String(t.status??"");return`${a} [${i}]`}case"finalAnswer":return String(t.answer??"").slice(0,110);case"planFinish":return`${String(t.status??"")} — ${String(t.goal??"").slice(0,60)}`;case"error":return`Repair: ${String(t.action??"")} — ${String(t.reason??"")}`.slice(0,110);case"memorySearch":return t.active?"Searching memory…":"Memory search done";case"systemHealth":return`${String(t.level??"").toUpperCase()} — ${String(t.message??"")}`.slice(0,100);default:return JSON.stringify(t).slice(0,90)}}const N0=200;function HE(e){return new Date(e).toLocaleTimeString("en",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function WE(){const[e,t]=u.useState(!1),[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState(!0),c=u.useRef(null),d=u.useRef(0),h=u.useRef(0);u.useEffect(()=>{o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[n,o]);const p=u.useCallback((f,m)=>{const b=UE(f,m),y=$E(f,b);r(v=>{const x=[...v,{id:`t-${++d.current}`,type:f,text:b,color:y,ts:Date.now()}];return x.length>N0?x.slice(-N0):x})},[]);return u.useEffect(()=>{const f=pe(),m=y=>{p(y.type,y.payload)},b=y=>{i(y);const v=Date.now();(y.cpu>80||y.ram>85)&&v-h.current>1e4&&(h.current=v,p("systemHealth",{level:"warning",message:`🛡️ GhostGuard: CPU ${y.cpu}% / RAM ${y.ram}%`}))};return f.on("telemetry:stream",m),f.on("systemStats",b),()=>{f.off("telemetry:stream",m),f.off("systemStats",b)}},[p]),s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:!e&&s.jsxs(V.button,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.18},onClick:()=>t(!0),title:"Open telemetry",className:"fixed right-0 top-1/2 -translate-y-1/2 z-50 flex flex-col items-center justify-center gap-1 w-6 h-16 rounded-l-md border border-r-0 border-white/10 hover:border-cyan-500/40 hover:bg-cyan-400/5 transition-all duration-200 group",style:{background:"#0c0d10"},children:[s.jsx(tv,{size:11,className:"text-cyan-500/50 group-hover:text-cyan-400 transition-colors"}),s.jsx("span",{className:"font-mono text-[7px] leading-none text-white/20 group-hover:text-cyan-400/60 transition-colors",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"},children:"TEL"})]},"fab")}),s.jsx("div",{className:`relative z-50 flex-shrink-0 flex flex-col transition-[width] duration-300 overflow-hidden${e?" border-l border-white/5":""}`,style:{background:"#0c0d10",width:e?288:0},children:s.jsx(ae,{children:e&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex flex-col flex-1 min-h-0 overflow-hidden",style:{width:288},children:[s.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-500"})]}),s.jsx("span",{className:"font-mono text-[9px] font-bold text-cyan-400 tracking-[0.2em] uppercase",children:"Live"}),s.jsxs("span",{className:"font-mono text-[9px] text-white/15",children:[n.length," events"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[a&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:`font-mono text-[9px] ${a.cpu>80?"text-orange-400":"text-white/25"}`,children:["CPU ",a.cpu,"%"]}),s.jsxs("span",{className:`font-mono text-[9px] ${a.ram>85?"text-orange-400":"text-white/25"}`,children:["RAM ",a.ram,"%"]})]}),s.jsx("button",{onClick:()=>r([]),title:"Clear log",className:"text-white/15 hover:text-white/40 transition-colors",children:s.jsx(ys,{size:10})}),s.jsx("button",{onClick:()=>t(!1),title:"Collapse telemetry",className:"text-white/15 hover:text-orange-400/70 transition-colors",children:s.jsx(gn,{size:10})})]})]}),s.jsx("div",{ref:c,className:"flex-1 overflow-y-auto scrollbar-hide px-2 py-1",onMouseEnter:()=>l(!1),onMouseLeave:()=>l(!0),children:n.length===0?s.jsx("div",{className:"flex items-center justify-center h-12 font-mono text-[10px] text-white/10",children:"awaiting events…"}):s.jsx(ae,{initial:!1,children:n.map(f=>s.jsxs(V.div,{initial:{opacity:0,x:6},animate:{opacity:1,x:0},transition:{duration:.12},className:"flex items-start gap-1.5 py-[2px] group",children:[s.jsx("span",{className:"font-mono text-[8px] text-white/10 shrink-0 mt-[2px] group-hover:text-white/20 transition-colors",children:HE(f.ts)}),s.jsxs("span",{className:"font-mono text-[10px] leading-[1.45] break-all",style:{color:f.color},children:[VE(f.type)," ",f.text]})]},f.id))})})]},"panel")})})]})}function S0(){return u.useEffect(()=>{pe()},[]),s.jsxs("div",{className:"flex flex-col h-[calc(100vh-72px)] overflow-hidden",children:[s.jsx(vE,{}),s.jsx(NE,{}),s.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[s.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:s.jsx(yE,{})}),s.jsx(WE,{})]}),s.jsx(FE,{}),s.jsx(zE,{}),s.jsx(DE,{})]})}function Ei(){const[e,t]=u.useState(!1),[n,r]=u.useState(!0),a=u.useRef(!0),i=u.useCallback(async()=>{try{const o=await U("/api/gateway/status",{},{retries:1,retryDelay:500});if(!a.current)return;const l=await o.json().catch(()=>({}));t(!!(l!=null&&l.online))}catch{a.current&&t(!1)}finally{a.current&&r(!1)}},[]);return u.useEffect(()=>{a.current=!0,i();const o=setInterval(i,15e3),l=()=>{i()},c=()=>{i()},d=()=>{a.current&&t(!1)};try{pe()}catch{}return window.addEventListener("mustb:connected",l),window.addEventListener("mustb:reconnected",c),window.addEventListener("mustb:disconnected",d),()=>{a.current=!1,clearInterval(o),window.removeEventListener("mustb:connected",l),window.removeEventListener("mustb:reconnected",c),window.removeEventListener("mustb:disconnected",d)}},[i]),{online:e,loading:n}}function C0({connected:e,configured:t}){return e?s.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}):t?s.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-400 flex-shrink-0"}):s.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-600 flex-shrink-0"})}function KE(){const{online:e}=Ei(),[t,n]=u.useState(null),[r,a]=u.useState([]),[i,o]=u.useState(null),[l,c]=u.useState(null),[d,h]=u.useState(!0);u.useEffect(()=>{(async()=>{var x;h(!0);try{const w=await(await U("/api/gateway/channels")).json();n(w),(x=w.channelOrder)!=null&&x.length&&o(w.channelOrder[0])}catch{n({offline:!0,channelOrder:[],channelLabels:{},channelAccounts:{}})}finally{h(!1)}})()},[e]),u.useEffect(()=>{t!=null&&t.offline&&U("/api/channels").then(v=>v.json()).then(a).catch(()=>a([]))},[t==null?void 0:t.offline]);const p=async(v,x)=>{c(`${v}-${x}`);try{await U(`/api/gateway/channels/${v}/logout`,{method:"POST",body:JSON.stringify({accountId:x})});const g=await U("/api/gateway/channels");n(await g.json())}catch{}finally{c(null)}};if(d)return s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(ge,{size:18,className:"animate-spin text-orange-400"}),s.jsx("span",{className:"ml-2 text-sm text-gray-500",children:"Kanallar yükleniyor…"})]});if(t!=null&&t.offline)return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20",children:[s.jsx(vs,{size:14,className:"text-orange-400 flex-shrink-0"}),s.jsx("p",{className:"text-[12px] text-orange-300",children:"Must-b gateway çevrimdışı — yerel kanallar gösteriliyor."})]}),r.length===0?s.jsx("p",{className:"text-center text-sm text-gray-600 py-6",children:"Yapılandırılmış kanal yok."}):s.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.map(v=>s.jsxs("div",{className:"px-3 py-2.5 rounded-xl bg-white/3 border border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(C0,{configured:v.configured,connected:!1}),s.jsx("span",{className:"text-[13px] font-semibold text-gray-200",children:v.name}),v.configured&&s.jsx("span",{className:"ml-auto text-[9px] font-bold px-1.5 py-0.5 rounded-md bg-orange-500/10 border border-orange-500/20 text-orange-400",children:"Yapılandırıldı"})]}),s.jsx("p",{className:"text-[11px] text-gray-500 line-clamp-2",children:v.description})]},v.id))})]});const f=(t==null?void 0:t.channelOrder)??[],m=(t==null?void 0:t.channelLabels)??{},b=(t==null?void 0:t.channelAccounts)??{};if(f.length===0)return s.jsx("p",{className:"text-center text-sm text-gray-600 py-8",children:"Yapılandırılmış kanal bulunamadı."});const y=i?b[i]??[]:[];return s.jsxs("div",{className:"flex gap-4 min-h-[320px]",children:[s.jsx("div",{className:"w-48 flex-shrink-0 space-y-1",children:f.map(v=>{const x=b[v]??[],g=x.some(j=>j.connected),w=x.some(j=>j.configured);return s.jsx("button",{onClick:()=>o(v),className:`w-full text-left px-3 py-2 rounded-xl border transition-all ${i===v?"bg-orange-500/12 border-orange-500/30":"bg-white/3 border-white/6 hover:bg-white/5 hover:border-white/12"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(C0,{connected:g,configured:w}),s.jsx("span",{className:"text-[12px] font-semibold text-gray-200 truncate",children:m[v]??v}),x.length>0&&s.jsx("span",{className:"ml-auto text-[10px] font-bold text-gray-500",children:x.length})]})},v)})}),s.jsx("div",{className:"flex-1 min-w-0",children:i?y.length===0?s.jsxs("div",{className:"px-4 py-4 rounded-xl bg-white/3 border border-white/6",children:[s.jsx("p",{className:"text-[13px] font-semibold text-gray-300 mb-1",children:m[i]??i}),s.jsx("p",{className:"text-[12px] text-gray-500",children:"Henüz bağlı hesap yok."})]}):s.jsx("div",{className:"space-y-2",children:y.map(v=>s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/3 border border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.connected?s.jsx(Fe,{size:13,className:"text-green-400 flex-shrink-0"}):v.lastError?s.jsx(av,{size:13,className:"text-red-400 flex-shrink-0"}):s.jsx(Ws,{size:13,className:"text-orange-400 flex-shrink-0"}),s.jsx("span",{className:"text-[13px] font-semibold text-gray-200 truncate",children:v.name??v.accountId}),s.jsxs("button",{onClick:()=>p(i,v.accountId),disabled:l===`${i}-${v.accountId}`,className:"ml-auto flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/8 border border-red-500/20 text-red-400 text-[10px] font-semibold hover:bg-red-500/15 transition-all disabled:opacity-40",children:[s.jsx(ip,{size:9}),"Logout"]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0",children:"Status"}),s.jsx("span",{className:`text-[11px] font-semibold ${v.connected?"text-green-400":"text-gray-500"}`,children:v.connected?"Connected":"Disconnected"})]}),v.lastConnectedAt&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0",children:"Last seen"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:new Date(v.lastConnectedAt).toLocaleString()})]}),v.lastError&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-20 flex-shrink-0 pt-0.5",children:"Error"}),s.jsx("span",{className:"text-[11px] text-red-400 break-all",children:v.lastError})]})]})]},v.accountId))}):s.jsx("p",{className:"text-sm text-gray-600 pt-4",children:"Bir kanal seçin."})})]})}function GE(e){return e===0?"Free":e<1?`$${e.toFixed(3)}/1M`:`$${e.toFixed(2)}/1M`}function qE(e){return e?e>=1e3?`${(e/1e3).toFixed(0)}M`:`${e}k`:"—"}const E0={free:{label:"Free",icon:s.jsx(j3,{size:11}),color:"#22c55e",bg:"rgba(34,197,94,0.12)"},balanced:{label:"Balanced",icon:s.jsx(V3,{size:11}),color:"#60a5fa",bg:"rgba(96,165,250,0.12)"},power:{label:"Power",icon:s.jsx(Ue,{size:11}),color:"#f59e0b",bg:"rgba(245,158,11,0.12)"}};function YE({currentModel:e,onSelect:t,className:n}){const[r,a]=u.useState(null),[i,o]=u.useState(!0),[l,c]=u.useState(null),[d,h]=u.useState("free"),[p,f]=u.useState(""),m=u.useRef(null),b=(x=!1)=>{o(!0),c(null),fetch(`/api/providers/openrouter/models${x?"?refresh=1":""}`).then(g=>g.ok?g.json():Promise.reject(new Error(`HTTP ${g.status}`))).then(g=>{if(a(g),e){const w=g.free.some(j=>j.id===e)?"free":g.balanced.some(j=>j.id===e)?"balanced":g.power.some(j=>j.id===e)?"power":"free";h(w)}o(!1)}).catch(g=>{c(g.message),o(!1)})};u.useEffect(()=>{b()},[]),u.useEffect(()=>{m.current&&m.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[d,r]);const y=(r==null?void 0:r[d])??[],v=p?y.filter(x=>x.name.toLowerCase().includes(p.toLowerCase())||x.id.toLowerCase().includes(p.toLowerCase())):y;return s.jsxs("div",{className:`flex flex-col rounded-xl overflow-hidden ${n??""}`,style:{background:"rgba(12,5,2,0.85)",border:"1px solid rgba(255,255,255,0.07)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 pt-3 pb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-400 uppercase tracking-widest",children:"OpenRouter Models"}),s.jsx("button",{onClick:()=>b(!0),className:"text-gray-600 hover:text-orange-400 transition-colors p-1 rounded",title:"Refresh catalog",disabled:i,children:s.jsx(ge,{size:11,className:i?"animate-spin":""})})]}),s.jsx("div",{className:"flex gap-1 px-3 pb-2",children:["free","balanced","power"].map(x=>{var k;const g=E0[x],w=((k=r==null?void 0:r.totals)==null?void 0:k[x])??0,j=d===x;return s.jsxs("button",{onClick:()=>h(x),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-semibold transition-all",style:{background:j?g.bg:"transparent",color:j?g.color:"#6b7280",border:`1px solid ${j?g.color+"40":"transparent"}`},children:[g.icon,g.label,w>0&&s.jsx("span",{className:"text-[9px] font-bold opacity-60",children:w})]},x)})}),s.jsx("div",{className:"px-3 pb-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(fn,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),s.jsx("input",{value:p,onChange:x=>f(x.target.value),placeholder:"Search models…",className:"w-full pl-7 pr-3 py-1.5 rounded-lg text-[11px] text-gray-300 placeholder-gray-600 outline-none",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.07)"}})]})}),s.jsxs("div",{className:"overflow-y-auto",style:{maxHeight:"320px"},children:[i&&s.jsxs("div",{className:"py-8 text-center text-[11px] text-gray-600",children:[s.jsx(ge,{size:14,className:"animate-spin mx-auto mb-2"}),"Fetching live catalog…"]}),!i&&l&&s.jsxs("div",{className:"py-6 px-4 text-center text-[11px] text-red-400",children:[l,s.jsx("br",{}),s.jsx("button",{onClick:()=>b(!0),className:"mt-2 underline text-orange-400 hover:text-orange-300",children:"Retry"})]}),!i&&!l&&v.length===0&&s.jsx("div",{className:"py-8 text-center text-[11px] text-gray-600",children:"No models found."}),!i&&!l&&v.map(x=>{const g=x.id===e,w=E0[x.tier];return s.jsx("button",{ref:g?m:void 0,onClick:()=>t(x.id),className:"w-full text-left px-3 py-2 transition-all",style:{background:g?"rgba(234,88,12,0.10)":"transparent",borderLeft:g?"2px solid #ea580c":"2px solid transparent"},children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:`text-[12px] font-semibold truncate ${g?"text-orange-300":"text-gray-300"}`,children:x.name}),x.hasVision&&s.jsx(Us,{size:9,className:"text-purple-400 flex-shrink-0",title:"Vision / multimodal"})]}),s.jsx("span",{className:"text-[9px] text-gray-600 font-mono truncate block",children:x.id}),x.description&&s.jsx("span",{className:"text-[10px] text-gray-600 line-clamp-1 mt-0.5",children:x.description})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[s.jsx("span",{className:"text-[9px] font-bold",style:{color:w.color},children:GE(x.costPer1M)}),s.jsxs("span",{className:"text-[9px] text-gray-600",children:[qE(x.contextK)," ctx"]})]})]})},x.id)})]}),r&&s.jsx("div",{className:"px-3 py-1.5 border-t",style:{borderColor:"rgba(255,255,255,0.04)"},children:s.jsxs("span",{className:"text-[9px] text-gray-700 font-mono",children:["Catalog cached · ",new Date(r.fetchedAt).toLocaleTimeString()]})})]})}const $c=[{code:"en",label:"English",flag:"🇬🇧",native:"English"},{code:"tr",label:"Turkish",flag:"🇹🇷",native:"Türkçe"},{code:"de",label:"German",flag:"🇩🇪",native:"Deutsch"},{code:"fr",label:"French",flag:"🇫🇷",native:"Français"},{code:"es",label:"Spanish",flag:"🇪🇸",native:"Español"},{code:"pt",label:"Portuguese (Brazil)",flag:"🇧🇷",native:"Português"},{code:"ja",label:"Japanese",flag:"🇯🇵",native:"日本語"},{code:"zh",label:"Chinese (Simplified)",flag:"🇨🇳",native:"简体中文"}];function XE(){const{locale:e,setLocale:t}=yt(),[n,r]=u.useState(!1),a=u.useRef(null),i=$c.find(o=>o.code===e)??$c[0];return u.useEffect(()=>{if(!n)return;const o=l=>{l.key==="Escape"&&r(!1)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]),s.jsxs("div",{ref:a,className:"relative",children:[s.jsxs("button",{onClick:()=>r(o=>!o),"aria-label":"Switch language",className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-full border text-[12px] font-semibold transition-all select-none ${n?"bg-orange-500/15 border-orange-400/30 text-orange-700":"text-black/65 border-transparent hover:text-black hover:bg-black/6"}`,children:[s.jsx(_3,{size:12,className:"text-orange-400 shrink-0"}),s.jsx("span",{children:i.flag}),s.jsx("span",{className:"tracking-wide",children:i.code.toUpperCase()})]}),s.jsx(ae,{children:n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>r(!1)}),s.jsxs(V.div,{initial:{opacity:0,y:-6,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.96},transition:{duration:.13,ease:"easeOut"},className:"absolute right-0 top-full mt-2 z-20 w-52 bg-[#100806]/96 backdrop-blur-2xl border border-orange-500/15 rounded-xl shadow-2xl shadow-black/60 overflow-hidden max-h-72 overflow-y-auto",children:[s.jsx("div",{className:"px-3 py-2 border-b border-white/6",children:s.jsx("p",{className:"text-[9px] font-bold text-gray-600 uppercase tracking-widest",children:"Language"})}),$c.map(o=>{const l=e===o.code;return s.jsxs("button",{onClick:()=>{t(o.code),r(!1)},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[12px] font-medium transition-colors ${l?"bg-orange-500/12 text-orange-400":"text-gray-300 hover:bg-white/5 hover:text-white"}`,children:[s.jsx("span",{className:"text-base leading-none",children:o.flag}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsx("p",{className:"leading-none",children:o.native}),!l&&s.jsx("p",{className:"text-[10px] text-gray-600 mt-0.5",children:o.label})]}),l&&s.jsx(it,{size:12,className:"text-orange-400 shrink-0"})]},o.code)})]})]})})]})}const _0={frontier:"⚡ Frontier",gateway:"🌐 Gateway",fast:"🚀 Fast",local:"💻 Local",open:"🔓 Open Source",specialist:"🎯 Specialist",regional:"🌏 Regional",enterprise:"🏢 Enterprise",custom:"⚙️ Custom"},T0=["frontier","gateway","fast","local","open","specialist","regional","enterprise","custom"];function Ov({tag:e}){return s.jsx("span",{className:"px-1.5 py-0.5 rounded-md bg-white/5 border border-white/8 text-[9px] text-gray-400 font-medium",children:e})}function QE({p:e,active:t,onClick:n}){return s.jsx("button",{onClick:n,className:`w-full text-left px-3 py-2.5 rounded-xl border transition-all ${t?"bg-orange-500/12 border-orange-500/30":"bg-white/3 border-white/6 hover:bg-white/5 hover:border-white/12"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:`text-[13px] font-semibold leading-tight truncate ${t?"text-orange-300":"text-gray-200"}`,children:e.label}),s.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5 leading-snug line-clamp-2",children:e.description}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:e.tags.slice(0,3).map(r=>s.jsx(Ov,{tag:r},r))})]}),t&&s.jsx(gn,{size:13,className:"text-orange-400 shrink-0 mt-1"})]})})}function JE(){const{t:e}=yt(),t=e.panels.settings,[n,r]=u.useState([]),[a,i]=u.useState(null),[o,l]=u.useState([]),[c,d]=u.useState(!0),[h,p]=u.useState(null),[f,m]=u.useState("all"),[b,y]=u.useState(""),[v,x]=u.useState(null),[g,w]=u.useState(""),[j,k]=u.useState(""),[S,C]=u.useState(!1),[A,N]=u.useState(!1),[_,L]=u.useState(!1),[B,M]=u.useState(null),[$,R]=u.useState(null),[z,P]=u.useState(!!window.__MUSTB_NEED_API_KEY),[E,T]=u.useState(null),[O,G]=u.useState({}),[D,K]=u.useState("providers"),F=u.useRef(null),Q=u.useRef(!1);u.useEffect(()=>{U("/api/setup/providers").then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.providers&&r(Z.providers)}).catch(()=>{}),U("/api/setup/status").then(Z=>Z.ok?Z.json():null).then(Z=>{Z&&i(Z)}).catch(()=>{}),U("/api/ollama/models").then(Z=>Z.ok?Z.json():null).then(Z=>{var xe;Z?(d(Z.running!==!1),Z.running===!1?p((xe=Z.error)!=null&&xe.includes("ECONNREFUSED")?"Ollama kapalı.":Z.error||"Ollama kapalı."):p(null),Z.models&&l(Z.models)):(d(!1),p("Ollama kapalı."))}).catch(()=>{d(!1),p("Ollama kapalı.")});const ee=()=>{P(!0),window.__MUSTB_NEED_API_KEY=!0};return window.addEventListener("mustb:401",ee),()=>window.removeEventListener("mustb:401",ee)},[]),u.useEffect(()=>{const ee=pe(),Z=xe=>{if(!xe||!xe.model)return;const Zs=xe.model,Re=typeof xe.percent=="number"?xe.percent:0,er=xe.status||"",yn=xe.error||"";G(ct=>({...ct,[Zs]:{percent:Re,status:er,error:yn}})),(er==="success"||er==="error")&&(T(null),U("/api/ollama/models").then(ct=>ct.ok?ct.json():null).then(ct=>{var Ti;ct?(d(ct.running!==!1),ct.running===!1?p((Ti=ct.error)!=null&&Ti.includes("ECONNREFUSED")?"Ollama kapalı.":ct.error||"Ollama kapalı."):p(null),ct.models&&l(ct.models)):(d(!1),p("Ollama kapalı."))}).catch(()=>{d(!1),p("Ollama kapalı.")}))};return ee.on("ollama_pull_progress",Z),()=>{ee.off("ollama_pull_progress",Z)}},[]),u.useEffect(()=>{if(Q.current||!(a!=null&&a.activeProvider)||!n.length)return;const ee=n.find(Z=>Z.id===a.activeProvider);ee&&(Q.current=!0,x(ee),w(a.activeModel??ee.defaultModel))},[n,a]);const q=b.toLowerCase(),X=n.filter(ee=>!(f!=="all"&&ee.category!==f||q&&!ee.label.toLowerCase().includes(q)&&!ee.description.toLowerCase().includes(q))),le={};for(const ee of X)le[ee.category]||(le[ee.category]=[]),le[ee.category].push(ee);const H=async()=>{if(v){N(!0),M(null);try{const Z=await(await U("/api/setup/test-key",{method:"POST",body:JSON.stringify({provider:v.id,apiKey:j||void 0,model:g||void 0})})).json();M({ok:Z.ok,msg:Z.message??(Z.ok?"Connection successful":"Connection failed")})}catch{M({ok:!1,msg:"Gateway unreachable"})}N(!1)}},se=async()=>{if(!(!v||!v.envKeyIsUrl&&!j.trim())){L(!0),R(null);try{const Z=await U("/api/setup/update-key",{method:"POST",body:JSON.stringify({provider:v.id,apiKey:j||void 0,model:g||void 0})});if(Z.ok){R("Saved successfully."),k(""),window.__MUSTB_NEED_API_KEY=!1,P(!1);const xe=await U("/api/setup/status");xe.ok&&i(await xe.json())}else{const xe=await Z.json();R(xe.error??"Failed to save.")}}catch{R("Gateway unreachable.")}L(!1),setTimeout(()=>R(null),6e3)}},ce=async ee=>{T(ee),G(Z=>({...Z,[ee]:{percent:0,status:"Starting..."}}));try{if(!(await U("/api/ollama/pull",{method:"POST",body:JSON.stringify({modelName:ee})})).ok)throw new Error("İndirme isteği başarısız.")}catch(Z){G(xe=>({...xe,[ee]:{percent:0,status:"error",error:Z.message||"Bağlantı hatası"}})),T(null)}},oe=(v==null?void 0:v.envKeyIsUrl)??!1,de=(v==null?void 0:v.id)==="ollama",Et=(v==null?void 0:v.id)==="openrouter",bs=T0.filter(ee=>n.some(Z=>Z.category===ee)),ra=a?a.score>=70?"text-green-400":a.score>=40?"text-amber-400":"text-red-400":"text-gray-400";return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden font-sans",children:[s.jsxs("div",{className:"shrink-0 flex items-center justify-between px-5 py-3 border-b border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center",children:s.jsx(Ci,{size:15,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[14px] font-bold text-white leading-tight",children:t.title}),s.jsxs("p",{className:"text-[10px] text-gray-400 leading-tight",children:[a!=null&&a.configured?`Active · ${a.provider??"unknown"}`:"Not configured",a!=null&&a.mode?` · ${a.mode}`:""]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(XE,{}),a&&s.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-white/4 border border-white/8",children:[s.jsx(tn,{size:11,className:ra}),s.jsxs("span",{className:`text-[11px] font-semibold ${ra}`,children:["HW ",a.score]}),s.jsxs("span",{className:"text-[10px] text-gray-400",children:["· ",a.tier]})]})]})]}),z&&s.jsxs("div",{className:"shrink-0 mx-4 mt-3 flex items-start gap-2.5 px-3.5 py-2.5 rounded-xl bg-red-500/10 border border-red-500/25 text-red-300",children:[s.jsx(Ws,{size:14,className:"shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold",children:"API key missing or invalid"}),s.jsx("p",{className:"text-[10px] text-red-400/70 mt-0.5",children:"A request returned 401 Unauthorized. Select a provider and update your key below."})]})]}),s.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-5 pt-3 pb-0",children:[s.jsxs("button",{onClick:()=>K("providers"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${D==="providers"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-400 hover:text-gray-300 hover:border-white/12"}`,children:[s.jsx(tn,{size:11})," LLM Providers"]}),s.jsxs("button",{onClick:()=>K("channels"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${D==="channels"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-400 hover:text-gray-300 hover:border-white/12"}`,children:[s.jsx(Co,{size:11})," Kanallar"]})]}),D==="channels"&&s.jsx("div",{className:"flex-1 overflow-y-auto p-5",children:s.jsx(KE,{})}),D==="providers"&&s.jsxs("div",{className:"flex flex-1 min-h-0 gap-0",children:[s.jsxs("div",{className:"w-[52%] flex flex-col border-r border-white/6 min-h-0",children:[s.jsxs("div",{className:"shrink-0 px-4 pt-3 pb-2 space-y-2.5",children:[s.jsxs("div",{className:"relative",children:[s.jsx(fn,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),s.jsx("input",{ref:F,type:"text",value:b,onChange:ee=>y(ee.target.value),placeholder:t.searchPlaceholder,className:"w-full bg-white/4 border border-white/8 rounded-xl pl-8 pr-3 py-2 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("button",{onClick:()=>m("all"),className:`px-2 py-0.5 rounded-lg text-[10px] font-semibold border transition-all ${f==="all"?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/4 border-white/8 text-gray-400 hover:text-gray-300"}`,children:t.allProviders}),bs.map(ee=>s.jsx("button",{onClick:()=>m(ee),className:`px-2 py-0.5 rounded-lg text-[10px] font-semibold border transition-all ${f===ee?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/4 border-white/8 text-gray-400 hover:text-gray-300"}`,children:_0[ee]},ee))]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-4",children:[n.length===0&&s.jsxs("div",{className:"flex items-center gap-2 py-6 text-gray-400 text-[12px]",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading providers…"]}),T0.filter(ee=>{var Z;return(Z=le[ee])==null?void 0:Z.length}).map(ee=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[9px] font-bold text-gray-400 uppercase tracking-widest mb-1.5 px-1",children:_0[ee]}),s.jsx("div",{className:"space-y-1.5",children:le[ee].map(Z=>s.jsx(QE,{p:Z,active:(v==null?void 0:v.id)===Z.id,onClick:()=>{x(Z),w(Z.defaultModel),M(null),k("")}},Z.id))})]},ee)),n.length>0&&X.length===0&&s.jsxs("p",{className:"text-[12px] text-gray-400 py-4 text-center",children:['No providers match "',b,'"']})]})]}),s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-y-auto",children:v?s.jsxs("div",{className:"p-5 space-y-5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-[16px] font-bold text-white",children:v.label}),s.jsx("p",{className:"text-[12px] text-gray-400 mt-0.5 leading-snug",children:v.description}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:v.tags.map(ee=>s.jsx(Ov,{tag:ee},ee))})]}),s.jsxs("a",{href:v.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white transition-colors",children:["Docs ",s.jsx(Kr,{size:10})]})]}),de&&(()=>{const ee=o,Z=Array.isArray(ee)?ee:[];return c?Z.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:"Recommended Models for Your Hardware"}),s.jsx("div",{className:"space-y-1.5",children:Z==null?void 0:Z.map(xe=>{const Zs=xe.fit==="recommended"?"text-green-400 border-green-500/20 bg-green-500/6":xe.fit==="marginal"?"text-amber-400 border-amber-500/20 bg-amber-500/6":"text-red-400 border-red-500/20 bg-red-500/6",Re=O[xe.id];return s.jsxs("div",{className:"space-y-2 rounded-xl bg-white/3 border border-white/6 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-200 truncate",children:xe.label}),s.jsxs("p",{className:"text-[10px] text-gray-400",children:[xe.sizeGb," GB"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-md border ${Zs}`,children:xe.fit}),s.jsxs("button",{onClick:()=>{w(xe.id),ce(xe.id)},disabled:E!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[10px] font-semibold hover:bg-orange-500/15 transition-all disabled:opacity-40",children:[E===xe.id?s.jsx(ne,{size:10,className:"animate-spin text-orange-400"}):s.jsx(Os,{size:10}),E===xe.id?"Pulling…":"Pull"]})]})]}),Re&&s.jsxs("div",{className:"space-y-1.5 pt-1.5 border-t border-white/5",children:[Re.status!=="success"&&Re.status!=="error"&&s.jsx("div",{className:"w-full bg-zinc-950 border border-zinc-800 rounded-full h-2 overflow-hidden relative shadow-inner",children:s.jsx("div",{className:"bg-gradient-to-r from-orange-500 to-amber-500 h-full rounded-full transition-all duration-300 relative shadow-[0_0_6px_rgba(249,115,22,0.3)]",style:{width:`${Re.percent}%`}})}),s.jsxs("p",{className:`text-[9px] font-medium leading-normal ${Re.status==="success"?"text-emerald-400":Re.status==="error"?"text-red-400":"text-zinc-400"}`,children:[Re.status==="success"&&"✓ ",Re.status==="error"&&"✗ ",Re.status==="success"?"Model başarıyla indirildi!":Re.status==="error"?Re.error||"İndirme başarısız.":`İndiriliyor: %${Re.percent} (${Re.status})`]})]})]},xe.id)})})]}):s.jsx("div",{className:"bg-white/3 border border-white/6 rounded-xl p-4 text-center py-6",children:s.jsx("p",{className:"text-xs text-zinc-500 font-semibold",children:"Önerilen model bulunamadı."})}):s.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-4 text-red-400 text-xs flex items-start gap-2.5 backdrop-blur-md shadow-lg shadow-red-500/5",children:[s.jsx(AlertCircle,{size:14,className:"shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-bold",children:h||"Ollama kapalı."}),s.jsx("p",{className:"mt-0.5 opacity-90",children:"Ollama servisi yanıt vermiyor. Arka planda çalıştığından emin olun."})]})]})})(),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[oe?s.jsx(U3,{size:9}):s.jsx(rp,{size:9}),oe?t.baseUrl:t.apiKey]}),de&&!oe?s.jsx("div",{className:"px-3.5 py-2.5 rounded-xl bg-green-500/6 border border-green-500/15 text-green-400 text-[12px]",children:"Ollama runs locally — no API key required. Just make sure Ollama is running."}):s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:S||oe?"text":"password",value:j,onChange:ee=>{k(ee.target.value),M(null)},placeholder:v.placeholder,className:"w-full bg-white/4 border border-white/10 rounded-xl px-4 py-2.5 pr-10 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"}),!oe&&s.jsx("button",{onClick:()=>C(ee=>!ee),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-300 transition-colors",children:S?s.jsx(np,{size:13}):s.jsx(Us,{size:13})})]}),s.jsx("p",{className:"text-[10px] text-gray-400 px-1",children:oe?`Stored in .env as ${v.envKey}. Default: ${v.placeholder}`:`Stored locally in .env as ${v.envKey} — never sent to external servers.`}),(a==null?void 0:a.activeProvider)===v.id&&a.maskedKey&&s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-green-500/8 border border-green-500/15 text-green-400 text-[11px]",children:[s.jsx(Fe,{size:11,className:"shrink-0"}),"Active key: ",s.jsx("span",{className:"font-mono",children:a.maskedKey})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[s.jsx(Ue,{size:9}),t.model]}),Et?s.jsx(YE,{currentModel:g,onSelect:w,className:"rounded-xl border border-white/10 bg-white/3"}):s.jsx("select",{value:g,onChange:ee=>w(ee.target.value),className:"w-full bg-white/4 border border-white/10 rounded-xl px-3 py-2.5 text-[12px] text-white outline-none focus:border-orange-500/40 transition-colors appearance-none",children:v.latestModels.map(ee=>s.jsx("option",{value:ee,className:"bg-[#1a0c06]",children:ee},ee))})]}),s.jsxs("div",{className:"flex items-center gap-2.5 pt-1",children:[!de&&s.jsxs("button",{onClick:H,disabled:A||!j&&!(a!=null&&a.configured),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-white/5 border border-white/10 text-[12px] text-gray-300 font-medium hover:bg-white/8 hover:text-white transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:A?"animate-spin":""}),A?t.testing:t.testConnection]}),s.jsxs("button",{onClick:se,disabled:_||!j.trim()&&!oe&&!de,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl bg-orange-600 hover:bg-orange-500 text-white text-[12px] font-semibold transition-all disabled:opacity-40 shadow-lg shadow-orange-500/20",children:[s.jsx(mv,{size:12,className:_?"animate-spin":""}),_?t.saving:t.save]})]}),B&&s.jsxs("div",{className:`flex items-start gap-2 px-3.5 py-2.5 rounded-xl border text-[12px] ${B.ok?"bg-green-500/8 border-green-500/20 text-green-300":"bg-red-500/8 border-red-500/20 text-red-300"}`,children:[B.ok?s.jsx(Fe,{size:13,className:"shrink-0 mt-0.5"}):s.jsx(Ws,{size:13,className:"shrink-0 mt-0.5"}),B.msg]}),$&&s.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20 text-orange-300 text-[12px]",children:[s.jsx(Fe,{size:13,className:"shrink-0"}),$]}),de&&s.jsxs("div",{className:"pt-1 space-y-1.5",children:[s.jsxs("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest flex items-center gap-1.5",children:[s.jsx(S3,{size:9}),"Custom Base URL (optional)"]}),s.jsx("input",{type:"text",value:j,onChange:ee=>k(ee.target.value),placeholder:"http://localhost:11434",className:"w-full bg-white/4 border border-white/10 rounded-xl px-4 py-2.5 text-[12px] text-white placeholder:text-gray-400 outline-none focus:border-orange-500/40 transition-colors"}),s.jsx("p",{className:"text-[10px] text-gray-400 px-1",children:"Leave blank to use the default http://localhost:11434"})]})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-center px-8",children:[s.jsx("div",{className:"w-12 h-12 rounded-2xl bg-orange-500/8 border border-orange-500/15 flex items-center justify-center",children:s.jsx(Ge,{size:20,className:"text-orange-500/50"})}),s.jsx("p",{className:"text-[13px] text-gray-400",children:"Select a provider from the left to configure your API key"})]})})]})]})}function ZE(e){if(!e)return"—";const t=Date.now()-e;return t<6e4?`${Math.floor(t/1e3)}s önce`:t<36e5?`${Math.floor(t/6e4)}dk önce`:`${Math.floor(t/36e5)}sa önce`}function e_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState("all"),l=async()=>{a(!0);try{const p=await(await U("/api/gateway/sessions?limit=50&includeDerivedTitles=true&includeLastMessage=true")).json(),f=Array.isArray(p)?p:Array.isArray(p==null?void 0:p.sessions)?p.sessions:[];n(f)}catch{n([])}finally{a(!1)}};u.useEffect(()=>{l()},[e]);const c=h=>!!h.runningAtMs&&Date.now()-h.runningAtMs<12e4,d=t.filter(h=>i==="running"?c(h):i==="idle"?!c(h):!0);return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(Ge,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Aktif Oturumlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," oturum"]})]})]}),s.jsxs("button",{onClick:l,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""}),"Yenile"]})]}),!e&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-orange-500/8 border border-orange-500/20",children:[s.jsx(vs,{size:13,className:"text-orange-400 flex-shrink-0"}),s.jsx("p",{className:"text-[12px] text-orange-300",children:"Gateway çevrimdışı — oturum verisi alınamıyor."})]}),s.jsx("div",{className:"flex gap-1.5",children:["all","running","idle"].map(h=>s.jsx("button",{onClick:()=>o(h),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${i===h?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:h==="all"?"Tümü":h==="running"?"Çalışıyor":"Boşta"},h))}),r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):d.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(Hs,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Aktif oturum bulunamadı.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"space-y-2",children:d.map(h=>{const p=c(h);return s.jsx("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6 hover:border-white/10 transition-all",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex-shrink-0",children:p?s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-400 animate-pulse"}):s.jsx("span",{className:"block w-2 h-2 rounded-full bg-gray-700"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-[13px] font-semibold text-gray-200 truncate",children:h.derivedTitle??h.label??h.key.slice(0,20)+"…"}),h.agentId&&s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-600 flex-shrink-0",children:[s.jsx(tn,{size:9}),h.agentId]})]}),h.lastMessage&&s.jsx("p",{className:"text-[11px] text-gray-500 truncate mb-1",children:h.lastMessage}),s.jsxs("div",{className:"flex items-center gap-3",children:[h.messageCount!==void 0&&s.jsxs("span",{className:"text-[10px] text-gray-600",children:[h.messageCount," mesaj"]}),s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-600",children:[s.jsx(Lt,{size:9}),ZE(h.lastActivityAt)]})]})]})]})},h.key)})})]})}function t_(e){if(!e||typeof e!="object")return String(e??"—");const t=e;return t.type==="every"&&t.intervalMs?`Her ${Math.round(t.intervalMs/6e4)} dakika`:t.type==="at"&&t.time?`Her gün ${t.time}`:t.type==="cron"&&t.expression?`Cron: ${t.expression}`:JSON.stringify(e).slice(0,40)}function n_(e){if(!e)return"—";const t=e-Date.now();return t<0?"Geçti":t<6e4?`${Math.floor(t/1e3)}s sonra`:t<36e5?`${Math.floor(t/6e4)}dk sonra`:`${Math.floor(t/36e5)}sa sonra`}function s_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState("all"),[l,c]=u.useState(null),[d,h]=u.useState(null),p=async()=>{a(!0);try{const g=await(await U("/api/gateway/automations?enabled=all&limit=50")).json();n(Array.isArray(g==null?void 0:g.jobs)?g.jobs:Array.isArray(g)?g:[])}catch{n([])}finally{a(!1)}};u.useEffect(()=>{p()},[e]);const f=async x=>{try{await U(`/api/gateway/automations/${x.id}`,{method:"PATCH",body:JSON.stringify({patch:{enabled:!x.enabled}})}),n(g=>g.map(w=>w.id===x.id?{...w,enabled:!w.enabled}:w))}catch{}},m=async x=>{c(x);try{await U(`/api/gateway/automations/${x}/run`,{method:"POST"}),await p()}catch{}finally{c(null)}},b=async x=>{if(window.confirm("Bu otomasyon silinsin mi?")){h(x);try{await U(`/api/gateway/automations/${x}`,{method:"DELETE"}),n(g=>g.filter(w=>w.id!==x))}catch{}finally{h(null)}}},y=t.filter(x=>i==="enabled"?x.enabled:i==="disabled"?!x.enabled:!0),v=x=>x==="ok"?s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-green-400",children:[s.jsx(Fe,{size:9})," Başarılı"]}):x==="error"?s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-red-400",children:[s.jsx(av,{size:9})," Hata"]}):s.jsx("span",{className:"text-[10px] text-gray-600",children:"—"});return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(Ue,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Otomasyonlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," zamanlanmış görev"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!e&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] bg-red-500/8 border border-red-500/20 text-red-400",children:[s.jsx(vs,{size:10})," Çevrimdışı"]}),s.jsxs("button",{onClick:p,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""})," Yenile"]})]})]}),s.jsx("div",{className:"flex gap-1.5",children:["all","enabled","disabled"].map(x=>s.jsx("button",{onClick:()=>o(x),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${i===x?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:x==="all"?"Tümü":x==="enabled"?"Aktif":"Pasif"},x))}),r?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(Ue,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Otomasyon bulunamadı.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"space-y-2",children:y.map(x=>{var g,w;return s.jsx("div",{className:`px-4 py-3 rounded-xl border transition-all ${x.enabled?"bg-white/[0.025] border-white/6":"bg-white/[0.01] border-white/4"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>f(x),disabled:!e,className:"mt-0.5 text-gray-500 hover:text-orange-400 transition-colors disabled:opacity-40",title:x.enabled?"Devre dışı bırak":"Etkinleştir",children:x.enabled?s.jsx(Y3,{size:18,className:"text-orange-400"}):s.jsx(q3,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:`text-[13px] font-semibold truncate ${x.enabled?"text-gray-200":"text-gray-500"}`,children:x.name??x.id}),v((g=x.state)==null?void 0:g.lastRunStatus)]}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-gray-500",children:[s.jsx(Lt,{size:9})," ",t_(x.schedule)]}),((w=x.state)==null?void 0:w.nextRunAtMs)&&s.jsx("span",{className:"text-[11px] text-gray-600",children:n_(x.state.nextRunAtMs)})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsxs("button",{onClick:()=>m(x.id),disabled:!e||l===x.id,className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-orange-500/8 border border-orange-500/20 text-orange-400 text-[10px] font-semibold hover:bg-orange-500/15 transition-all disabled:opacity-40",children:[l===x.id?s.jsx(ge,{size:9,className:"animate-spin"}):s.jsx(gs,{size:9}),"Çalıştır"]}),s.jsxs("button",{onClick:()=>b(x.id),disabled:!e||d===x.id,className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/8 border border-red-500/20 text-red-400 text-[10px] font-semibold hover:bg-red-500/15 transition-all disabled:opacity-40",children:[d===x.id?s.jsx(ge,{size:9,className:"animate-spin"}):s.jsx(ys,{size:9}),"Sil"]})]})]})},x.id)})})]})}function r_(e){var t;return(t=e.presence)!=null&&t.ts?Date.now()-e.presence.ts<6e4:!1}function a_({platform:e}){const t=(e??"").toLowerCase();return t.includes("ios")||t.includes("iphone")?s.jsx(c0,{size:14,className:"text-gray-400"}):t.includes("android")?s.jsx(c0,{size:14,className:"text-green-500"}):t.includes("mac")||t.includes("darwin")?s.jsx(l3,{size:14,className:"text-gray-300"}):t.includes("win")?s.jsx(op,{size:14,className:"text-blue-400"}):s.jsx(dv,{size:14,className:"text-gray-500"})}function i_(){const{online:e}=Ei(),[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState(null),[l,c]=u.useState(""),d=async()=>{a(!0);try{const f=await(await U("/api/gateway/clients")).json();n(Array.isArray(f==null?void 0:f.nodes)?f.nodes:Array.isArray(f)?f:[])}catch{n([])}finally{a(!1)}};u.useEffect(()=>{d()},[e]);const h=async p=>{if(!l.trim()){o(null);return}try{await U(`/api/gateway/clients/${p}/rename`,{method:"POST",body:JSON.stringify({displayName:l.trim()})}),n(f=>f.map(m=>m.nodeId===p?{...m,displayName:l.trim()}:m))}catch{}finally{o(null)}};return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(pu,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Bağlı Nodlar"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:[t.length," cihaz"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!e&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] bg-red-500/8 border border-red-500/20 text-red-400",children:[s.jsx(vs,{size:10})," Çevrimdışı"]}),s.jsxs("button",{onClick:d,disabled:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-[11px] text-gray-400 hover:text-white hover:border-white/16 transition-all disabled:opacity-40",children:[s.jsx(ge,{size:12,className:r?"animate-spin":""})," Yenile"]})]})]}),r?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):t.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[s.jsx(pu,{size:32,className:"text-gray-700"}),s.jsx("p",{className:"text-sm text-gray-600",children:e?"Bağlı node yok.":"Gateway çevrimdışı."})]}):s.jsx("div",{className:"grid grid-cols-2 gap-3",children:t.map(p=>s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6 hover:border-white/10 transition-all",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[s.jsx(a_,{platform:p.platform}),s.jsx("div",{className:"flex-1 min-w-0",children:i===p.nodeId?s.jsx("input",{autoFocus:!0,value:l,onChange:f=>c(f.target.value),onBlur:()=>h(p.nodeId),onKeyDown:f=>{f.key==="Enter"&&h(p.nodeId),f.key==="Escape"&&o(null)},className:"w-full bg-white/6 border border-orange-500/30 rounded-lg px-2 py-0.5 text-[13px] text-white outline-none"}):s.jsx("p",{className:"text-[13px] font-semibold text-gray-200 truncate cursor-text",onDoubleClick:()=>{o(p.nodeId),c(p.displayName??"")},title:"Çift tıklayarak düzenle",children:p.displayName??p.nodeId})}),s.jsx("span",{className:`flex-shrink-0 w-2 h-2 rounded-full mt-1 ${r_(p)?"bg-green-400 animate-pulse":"bg-gray-700"}`})]}),s.jsxs("div",{className:"space-y-1",children:[p.platform&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-16",children:"Platform"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:p.platform})]}),p.version&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 w-16",children:"Versiyon"}),s.jsx("span",{className:"text-[11px] text-gray-400",children:p.version})]}),(p.caps??[]).length>0&&s.jsxs("div",{className:"flex items-center gap-1 flex-wrap mt-1",children:[(p.caps??[]).slice(0,3).map(f=>s.jsx("span",{className:"px-1.5 py-0.5 rounded-md bg-orange-500/8 border border-orange-500/15 text-[9px] text-orange-400 font-medium",children:f},f)),(p.caps??[]).length>3&&s.jsxs("span",{className:"text-[9px] text-gray-600",children:["+",(p.caps??[]).length-3]})]})]})]},p.nodeId))})]})}function o_({online:e}){var d;const[t,n]=u.useState({}),[r,a]=u.useState(!0),i=u.useRef(0),o=u.useRef(null),l=async(h=0)=>{try{const f=await(await U(`/api/gateway/logs?cursor=${h}&limit=200`)).json();h===0?(n(f),i.current=f.cursor??0):(n(m=>({...f,lines:[...m.lines??[],...f.lines??[]]})),i.current=f.cursor??i.current)}catch{}finally{a(!1)}};u.useEffect(()=>{l(0)},[e]),u.useEffect(()=>{const h=setInterval(()=>l(i.current),1e4);return()=>clearInterval(h)},[e]),u.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[(d=t.lines)==null?void 0:d.length]);const c=h=>h.includes("error")||h.includes("ERROR")?"text-red-400":h.includes("warn")||h.includes("WARN")?"text-amber-400":h.includes("info")||h.includes("INFO")?"text-green-400":"text-gray-400";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("p",{className:"text-[11px] text-gray-600",children:[(t.lines??[]).length," satır"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>navigator.clipboard.writeText((t.lines??[]).join(`
|
|
751
751
|
`)),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/8 text-[10px] text-gray-400 hover:text-white transition-all",children:[s.jsx(Vs,{size:10})," Kopyala"]}),s.jsxs("button",{onClick:()=>{i.current=0,l(0)},className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/8 text-[10px] text-gray-400 hover:text-white transition-all",children:[s.jsx(ge,{size:10})," Sıfırla"]})]})]}),s.jsx("div",{ref:o,className:"h-96 overflow-y-auto rounded-xl bg-black/40 border border-white/6 p-3 font-mono text-[11px] space-y-0.5",children:r?s.jsx("p",{className:"text-gray-600",children:"Yükleniyor…"}):!e||t.offline?s.jsx("p",{className:"text-orange-500",children:"Gateway çevrimdışı — log verisi alınamıyor."}):(t.lines??[]).length===0?s.jsx("p",{className:"text-gray-600",children:"Henüz log yok."}):(t.lines??[]).map((h,p)=>s.jsx("p",{className:`whitespace-pre-wrap break-all leading-5 ${c(h)}`,children:h},p))})]})}function l_({online:e}){var l,c;const[t,n]=u.useState({}),[r,a]=u.useState(!0);u.useEffect(()=>{a(!0),U("/api/gateway/usage/cost").then(d=>d.json()).then(n).catch(()=>n({})).finally(()=>a(!1))},[e]);const i=t.daily??[],o=Math.max(1,...i.map(d=>d.tokens??0));return s.jsxs("div",{className:"space-y-4",children:[(!e||t.offline)&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-orange-500/8 border border-orange-500/20",children:[s.jsx(vs,{size:12,className:"text-orange-400"}),s.jsx("p",{className:"text-[11px] text-orange-300",children:"Gateway çevrimdışı."})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6",children:[s.jsx("p",{className:"text-[10px] text-gray-600 mb-1 uppercase tracking-widest",children:"Toplam Token"}),s.jsx("p",{className:"text-xl font-bold text-white",children:r?"—":(((l=t.total)==null?void 0:l.tokens)??0).toLocaleString()})]}),s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6",children:[s.jsxs("p",{className:"text-[10px] text-gray-600 mb-1 uppercase tracking-widest flex items-center gap-1",children:[s.jsx(b3,{size:8})," Tahmini Maliyet"]}),s.jsx("p",{className:"text-xl font-bold text-orange-400",children:r?"—":`$${(((c=t.total)==null?void 0:c.cost)??0).toFixed(4)}`})]})]}),(t.providers??[]).length>0&&s.jsxs("div",{className:"rounded-xl bg-white/[0.02] border border-white/6 overflow-hidden",children:[s.jsxs("div",{className:"grid grid-cols-4 px-4 py-2 border-b border-white/6 text-[10px] font-bold text-gray-600 uppercase tracking-widest",children:[s.jsx("span",{children:"Provider"}),s.jsx("span",{className:"text-right",children:"Giriş"}),s.jsx("span",{className:"text-right",children:"Çıkış"}),s.jsx("span",{className:"text-right",children:"Maliyet"})]}),(t.providers??[]).map((d,h)=>s.jsxs("div",{className:"grid grid-cols-4 px-4 py-2 border-b border-white/4 last:border-0 text-[12px]",children:[s.jsx("span",{className:"text-gray-300 font-medium truncate",children:d.provider}),s.jsx("span",{className:"text-right text-gray-500",children:(d.inputTokens??0).toLocaleString()}),s.jsx("span",{className:"text-right text-gray-500",children:(d.outputTokens??0).toLocaleString()}),s.jsxs("span",{className:"text-right text-orange-400",children:["$",(d.cost??0).toFixed(4)]})]},h))]}),i.length>0&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"text-[10px] text-gray-600 uppercase tracking-widest",children:"Günlük Kullanım"}),s.jsx("div",{className:"flex items-end gap-1 h-16 px-1",children:i.slice(-14).map((d,h)=>{var f;const p=Math.max(2,Math.round((d.tokens??0)/o*56));return s.jsxs("div",{className:"flex-1 flex flex-col items-center gap-0.5",children:[s.jsx("div",{style:{height:p},className:"w-full rounded-sm bg-orange-500/40 hover:bg-orange-500/60 transition-all",title:`${d.date}: ${(d.tokens??0).toLocaleString()} token`}),s.jsx("span",{className:"text-[8px] text-gray-700 truncate w-full text-center",children:(f=d.date)==null?void 0:f.slice(5)})]},h)})})]})]})}function c_({online:e}){const[t,n]=u.useState([]),[r,a]=u.useState(!0);return u.useEffect(()=>{a(!0),U("/api/gateway/sessions/usage?limit=30").then(i=>i.json()).then(i=>n(Array.isArray(i)?i:(i==null?void 0:i.sessions)??[])).catch(()=>n([])).finally(()=>a(!1))},[e]),s.jsxs("div",{className:"rounded-xl bg-white/[0.02] border border-white/6 overflow-hidden",children:[s.jsxs("div",{className:"grid grid-cols-4 px-4 py-2 border-b border-white/6 text-[10px] font-bold text-gray-600 uppercase tracking-widest",children:[s.jsx("span",{className:"col-span-2",children:"Oturum"}),s.jsx("span",{className:"text-right",children:"Token"}),s.jsx("span",{className:"text-right",children:"Maliyet"})]}),r?s.jsx("div",{className:"flex justify-center py-6",children:s.jsx(ge,{size:14,className:"animate-spin text-orange-400"})}):t.length===0?s.jsx("p",{className:"text-center text-sm text-gray-600 py-6",children:e?"Oturum bulunamadı.":"Gateway çevrimdışı."}):t.map((i,o)=>{var l;return s.jsxs("div",{className:"grid grid-cols-4 px-4 py-2 border-b border-white/4 last:border-0 text-[12px]",children:[s.jsx("span",{className:"col-span-2 text-gray-300 truncate font-mono text-[10px]",children:((l=i.key)==null?void 0:l.slice(0,28))??"—"}),s.jsx("span",{className:"text-right text-gray-500",children:(i.tokens??0).toLocaleString()}),s.jsxs("span",{className:"text-right text-orange-400",children:["$",(i.cost??0).toFixed(4)]})]},o)})]})}function d_(){const{online:e}=Ei(),[t,n]=u.useState("logs");return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(m3,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Loglar & Aktivite"}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"Must-b gateway log, kullanım ve oturum istatistikleri"})]}),!e&&s.jsxs("span",{className:"ml-auto flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] bg-red-500/8 border border-red-500/20 text-red-400",children:[s.jsx(vs,{size:10})," Çevrimdışı"]})]}),s.jsx("div",{className:"flex gap-1.5",children:["logs","usage","sessions"].map(r=>s.jsx("button",{onClick:()=>n(r),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${t===r?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:r==="logs"?"Loglar":r==="usage"?"Kullanım":"Oturumlar"},r))}),t==="logs"&&s.jsx(o_,{online:e}),t==="usage"&&s.jsx(l_,{online:e}),t==="sessions"&&s.jsx(c_,{online:e})]})}function u_(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState("all"),[o,l]=u.useState(new Set);u.useEffect(()=>{r(!0),U("/api/tools").then(h=>h.json()).then(h=>{const p=Array.isArray(h==null?void 0:h.groups)?h.groups:[];t(p),l(new Set(p.slice(0,3).map(f=>f.id)))}).catch(()=>t([])).finally(()=>r(!1))},[]);const c=e.map(h=>({...h,tools:(h.tools??[]).filter(p=>a==="core"?p.source!=="plugin":a==="plugin"?p.source==="plugin":!0)})).filter(h=>h.tools.length>0),d=h=>{l(p=>{const f=new Set(p);return f.has(h)?f.delete(h):f.add(h),f})};return s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"flex gap-1.5",children:["all","core","plugin"].map(h=>s.jsx("button",{onClick:()=>i(h),className:`px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${a===h?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:h==="all"?"All":h==="core"?"Core":"Plugin"},h))}),n?s.jsx("div",{className:"flex justify-center py-10",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):c.length===0?s.jsx("p",{className:"text-center text-sm text-gray-600 py-8",children:"No tools found."}):s.jsx("div",{className:"space-y-2",children:c.map(h=>{var p;return s.jsxs("div",{className:"rounded-xl bg-white/[0.02] border border-white/6 overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(h.id),className:"w-full flex items-center justify-between px-4 py-2.5 hover:bg-white/3 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(up,{size:12,className:"text-orange-400"}),s.jsx("span",{className:"text-[12px] font-semibold text-gray-300",children:h.label??h.id}),s.jsxs("span",{className:"text-[10px] text-gray-600",children:[((p=h.tools)==null?void 0:p.length)??0," tools"]})]}),o.has(h.id)?s.jsx(Xs,{size:12,className:"text-gray-600"}):s.jsx(gn,{size:12,className:"text-gray-600"})]}),o.has(h.id)&&s.jsx("div",{className:"border-t border-white/5 divide-y divide-white/4",children:(h.tools??[]).map((f,m)=>s.jsxs("div",{className:"px-4 py-2 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-300",children:f.label??f.name}),f.description&&s.jsx("p",{className:"text-[11px] text-gray-600 line-clamp-1",children:f.description})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-md border ${f.source==="plugin"?"bg-blue-500/8 border-blue-500/20 text-blue-400":"bg-orange-500/8 border-orange-500/20 text-orange-400"}`,children:f.source==="plugin"?"plugin":"core"})})]},m))})]},h.id)})})]})}function h_(){const[e,t]=u.useState([]),[n,r]=u.useState(!0);return u.useEffect(()=>{r(!0),U("/api/agents").then(a=>a.json()).then(a=>t(Array.isArray(a==null?void 0:a.agents)?a.agents:[])).catch(()=>t([])).finally(()=>r(!1))},[]),n?s.jsx("div",{className:"flex justify-center py-10",children:s.jsx(ge,{size:18,className:"animate-spin text-orange-400"})}):e.length===0?s.jsx("p",{className:"text-center text-sm text-gray-600 py-8",children:"No agents found."}):s.jsx("div",{className:"grid grid-cols-2 gap-3",children:e.map(a=>s.jsxs("div",{className:"px-4 py-3 rounded-xl bg-white/[0.025] border border-white/6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-xl",children:a.emoji??"🤖"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[13px] font-semibold text-gray-200 truncate",children:a.name??a.id})}),a.isDefault&&s.jsx("span",{className:"text-[9px] font-bold px-1.5 py-0.5 rounded-md bg-orange-500/12 border border-orange-500/25 text-orange-400",children:"Default"})]}),a.description&&s.jsx("p",{className:"text-[11px] text-gray-500 line-clamp-2",children:a.description})]},a.id))})}function p_(){const[e,t]=u.useState("tools");return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(Qs,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Skills & Plugins"}),s.jsx("p",{className:"text-[11px] text-gray-500",children:"Must-b tool catalog and agent management"})]})]}),s.jsx("div",{className:"flex gap-1.5",children:["tools","agents"].map(n=>s.jsxs("button",{onClick:()=>t(n),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold border transition-all ${e===n?"bg-orange-500/15 border-orange-500/30 text-orange-300":"bg-white/3 border-white/6 text-gray-500 hover:text-gray-300 hover:border-white/12"}`,children:[n==="tools"?s.jsx(up,{size:11}):s.jsx(Wr,{size:11}),n==="tools"?"Tools":"Agents"]},n))}),e==="tools"&&s.jsx(u_,{}),e==="agents"&&s.jsx(h_,{})]})}const P0=[{key:"all",label:"Tümü",icon:Ni,test:()=>!0},{key:"nightowl",label:"NightOwl Bulguları",icon:Si,test:e=>e.tags.some(t=>/nightshift|nightowl/i.test(t))},{key:"preferences",label:"Kullanıcı Tercihleri",icon:hi,test:e=>e.category==="semantic"&&!e.tags.some(t=>/project|workspace|nightshift|nightowl/i.test(t))},{key:"architecture",label:"Proje Mimarisi",icon:uv,test:e=>e.tags.some(t=>/project|workspace|context|summary/i.test(t))},{key:"episodic",label:"Episodik",icon:Lt,test:e=>e.category==="episodic"},{key:"semantic",label:"Semantik",icon:Zt,test:e=>e.category==="semantic"}],f_={episodic:{border:"rgba(249,115,22,0.30)",bg:"rgba(249,115,22,0.08)",dot:"#f97316",label:"Episodik"},semantic:{border:"rgba(99,102,241,0.30)",bg:"rgba(99,102,241,0.08)",dot:"#6366f1",label:"Semantik"}};function m_(e){const n=(Date.now()-new Date(e+"Z").getTime())/1e3,r=n/60,a=r/60,i=a/24;return n<60?{label:"az önce",tier:"fresh"}:r<60?{label:`${Math.floor(r)}d önce`,tier:"fresh"}:a<24?{label:`${Math.floor(a)}s önce`,tier:"recent"}:i<7?{label:`${Math.floor(i)}g önce`,tier:"recent"}:i<30?{label:`${Math.floor(i/7)}h önce`,tier:"old"}:{label:`${Math.floor(i/30)}ay önce`,tier:"ancient"}}const x_={fresh:"#34d399",recent:"#f97316",old:"#a78bfa",ancient:"#6b7280"};function A0(e,t){return t.trim()?e.split(new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi")).map((r,a)=>r.toLowerCase()===t.toLowerCase()?s.jsx("mark",{className:"bg-orange-500/30 text-orange-300 rounded px-0.5",children:r},a):r):e}function g_({entry:e,query:t,index:n,onDelete:r}){const[a,i]=u.useState(!1),[o,l]=u.useState(!1),c=m_(e.createdAt),d=f_[e.category],h=e.content.slice(0,180),p=e.content.length>180,f=async m=>{m.stopPropagation(),l(!0);try{(await U(`/api/memory/ltm/delete/${e.id}`,{method:"DELETE"})).ok?(r(e.id),te.success("Kayıt silindi.")):te.error("Silinemedi.")}catch{te.error("Bağlantı hatası.")}l(!1)};return s.jsxs(V.div,{layout:!0,initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,scale:.97},transition:{delay:Math.min(n*.03,.3),duration:.25},className:"rounded-2xl overflow-hidden cursor-pointer group",style:{background:"rgba(10,4,1,0.78)",border:`1px solid ${d.border}`,backdropFilter:"blur(20px)",boxShadow:`0 4px 24px rgba(0,0,0,0.45), 0 0 0 1px ${d.bg}, inset 0 1px 0 rgba(255,255,255,0.03)`},onClick:()=>i(m=>!m),children:[s.jsxs("div",{className:"flex items-start gap-3 px-4 pt-3.5 pb-2.5",style:{borderBottom:`1px solid ${d.bg}`},children:[s.jsx("span",{className:"mt-0.5 w-2 h-2 rounded-full flex-shrink-0",style:{background:d.dot,boxShadow:`0 0 6px ${d.dot}`}}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed break-words",children:A0(a?e.content:h+(p?"…":""),t)})}),p&&s.jsx(V.span,{animate:{rotate:a?90:0},transition:{duration:.18},className:"flex-shrink-0 text-white/20",children:s.jsx(gn,{size:14})}),s.jsx("button",{onClick:f,disabled:o,className:"flex-shrink-0 p-1 rounded-lg opacity-0 group-hover:opacity-100 text-white/25 hover:text-red-400 hover:bg-red-500/12 transition-all disabled:opacity-30",title:"Bu kaydı sil",children:s.jsx(ys,{size:13})})]}),s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] font-semibold tracking-widest uppercase px-2 py-0.5 rounded-full",style:{color:d.dot,background:d.bg,border:`1px solid ${d.border}`},children:d.label}),e.tags.slice(0,3).map(m=>s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-white/35 px-1.5 py-0.5 rounded-md",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[s.jsx(gv,{size:8,className:"opacity-60"}),m]},m)),s.jsx("span",{className:"flex-1"}),s.jsxs("span",{className:"flex items-center gap-1 text-[10px] font-medium",style:{color:x_[c.tier]},title:e.createdAt,children:[s.jsx(Lt,{size:9}),c.label]})]})]})}function y_({entries:e}){const t=e.filter(i=>i.category==="episodic").length,n=e.filter(i=>i.category==="semantic").length,r=e.filter(i=>i.tags.some(o=>/nightshift|nightowl/i.test(o))).length,a=[{label:`${e.length} toplam`,color:"#f97316"},{label:`${t} episodik`,color:"#f97316"},{label:`${n} semantik`,color:"#6366f1"},{label:`${r} NightOwl`,color:"#a78bfa"}];return s.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:a.map(i=>s.jsx("span",{className:"text-[11px] font-semibold px-2.5 py-1 rounded-full",style:{color:i.color,background:`${i.color}14`,border:`1px solid ${i.color}30`},children:i.label},i.label))})}function v_({onConfirm:e,onCancel:t}){return s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 p-4",children:s.jsxs(V.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},className:"rounded-2xl p-6 w-full max-w-sm shadow-2xl",style:{background:"rgba(18,8,2,0.97)",border:"1px solid rgba(249,115,22,0.25)"},children:[s.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.25)"},children:s.jsx(Ws,{size:18,className:"text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-[15px] font-bold text-white/90",children:"Tüm Hafızayı Temizle"}),s.jsx("p",{className:"text-[11px] text-white/35",children:"Bu işlem geri alınamaz"})]}),s.jsx("button",{onClick:t,className:"ml-auto p-1.5 rounded-lg text-white/30 hover:text-white/60 hover:bg-white/6 transition-all",children:s.jsx(ze,{size:15})})]}),s.jsx("p",{className:"text-[13px] text-white/50 mb-5 leading-relaxed",children:"Tüm episodik ve semantik hafıza kayıtları kalıcı olarak silinecek. Bu işlem geri alınamaz."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 px-4 py-2.5 rounded-xl bg-white/8 hover:bg-white/12 text-white/70 text-[13px] font-medium transition-colors",children:"İptal"}),s.jsx("button",{onClick:e,className:"flex-1 px-4 py-2.5 rounded-xl bg-red-600/80 hover:bg-red-600 text-white text-[13px] font-semibold transition-colors border border-red-500/30",children:"Tümünü Sil"})]})]})})}function b_(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState(""),[o,l]=u.useState("all"),[c,d]=u.useState(!1),[h,p]=u.useState(!1),f=u.useCallback(async()=>{r(!0);try{const v=await U("/api/memory/ltm/explore?category=all&limit=200");if(v.ok){const x=await v.json();t(x.entries??[])}}catch{}r(!1)},[]);u.useEffect(()=>{f()},[f]);const m=v=>{t(x=>x.filter(g=>g.id!==v))},b=async()=>{p(!0);try{const v=await U("/api/memory/ltm/clear-all",{method:"DELETE"});if(v.ok){const x=await v.json();t([]),te.success(`${x.deleted??0} kayıt temizlendi.`)}else te.error("Temizleme başarısız.")}catch{te.error("Bağlantı hatası.")}p(!1),d(!1)},y=u.useMemo(()=>{var g;const v=((g=P0.find(w=>w.key===o))==null?void 0:g.test)??(()=>!0),x=a.trim().toLowerCase();return e.filter(v).filter(w=>!x||w.content.toLowerCase().includes(x)||w.tags.some(j=>j.includes(x)))},[e,o,a]);return s.jsxs("div",{className:"h-[calc(100vh-72px)] overflow-y-auto px-6 py-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.28)",boxShadow:"0 0 16px rgba(249,115,22,0.12)"},children:s.jsx(Zt,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[15px] font-bold text-white/90 tracking-tight",children:"Hafıza Tüneli"}),s.jsx("p",{className:"text-[11px] text-white/35",children:"Long-Term Memory Explorer — semantik & episodik"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>d(!0),disabled:h||e.length===0,className:"flex items-center gap-1.5 text-[11px] font-semibold px-3 py-1.5 rounded-lg transition-all border border-red-500/20 text-red-400/70 hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 disabled:cursor-not-allowed",style:{background:"rgba(239,68,68,0.04)"},children:[s.jsx(ys,{size:11}),"Tüm Hafızayı Temizle"]}),s.jsxs("button",{onClick:()=>void f(),disabled:n,className:"flex items-center gap-1.5 text-[11px] text-white/40 hover:text-white/70 transition-colors px-3 py-1.5 rounded-lg",style:{border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.03)"},children:[s.jsx(ge,{size:11,className:n?"animate-spin":""}),"Yenile"]})]})]}),!n&&s.jsx(y_,{entries:e}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-xl px-3 py-2.5",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(12px)"},children:[s.jsx(fn,{size:13,className:"text-white/30 flex-shrink-0"}),s.jsx("input",{type:"text",value:a,onChange:v=>i(v.target.value),placeholder:"Hafızada ara…",className:"flex-1 bg-transparent text-[13px] text-white/80 placeholder:text-white/25 outline-none"}),a&&s.jsx("button",{onClick:()=>i(""),className:"text-white/25 hover:text-white/60 text-xs",children:"✕"})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(k3,{size:11,className:"text-white/25"}),P0.map(v=>{const x=v.icon,g=o===v.key,w=e.filter(v.test).length;return s.jsxs("button",{onClick:()=>l(v.key),className:"flex items-center gap-1.5 text-[11px] font-medium px-2.5 py-1 rounded-full transition-all",style:{background:g?"rgba(249,115,22,0.16)":"rgba(255,255,255,0.04)",border:g?"1px solid rgba(249,115,22,0.40)":"1px solid rgba(255,255,255,0.08)",color:g?"#fb923c":"rgba(255,255,255,0.45)"},children:[s.jsx(x,{size:10}),v.label,s.jsxs("span",{style:{opacity:.6},children:["(",w,")"]})]},v.key)})]})]}),n?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-24",children:[s.jsx(V.div,{animate:{rotate:360},transition:{repeat:1/0,duration:1.5,ease:"linear"},children:s.jsx(Zt,{size:28,className:"text-orange-500/50"})}),s.jsx("p",{className:"text-[12px] text-white/30",children:"Hafıza taranıyor…"})]}):y.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-24",children:[s.jsx(mn,{size:28,className:"text-white/15"}),s.jsx("p",{className:"text-[13px] text-white/30",children:e.length===0?"Henüz hafıza yok. İlk konuşmadan sonra dolmaya başlar.":"Filtrene uyan kayıt yok."})]}):s.jsxs("div",{className:"space-y-3 pb-8",children:[s.jsxs("p",{className:"text-[11px] text-white/25",children:[y.length," kayıt gösteriliyor",a&&s.jsxs(s.Fragment,{children:[" · ",s.jsxs("span",{className:"text-orange-400/60",children:['"',a,'"']})," araması"]})]}),s.jsx(ae,{mode:"popLayout",children:y.map((v,x)=>s.jsx(g_,{entry:v,query:a,index:x,onDelete:m},v.id))})]}),s.jsx(ae,{children:c&&s.jsx(v_,{onConfirm:b,onCancel:()=>d(!1)})})]})}const so=`# Must-b Zihni
|
|
752
752
|
Burada senin hakkında öğrendiğim bilgiler yer alır.
|
|
753
753
|
|
|
@@ -792,7 +792,7 @@ Burada senin hakkında öğrendiğim bilgiler yer alır.
|
|
|
792
792
|
color: rgba(251,146,60,0.9);
|
|
793
793
|
margin-left: auto;
|
|
794
794
|
}
|
|
795
|
-
`}),s.jsx("div",{className:"max-w-full",dangerouslySetInnerHTML:{__html:f}})]})]})]})]})}const N_=[{id:"terminal",label:"Terminal",desc:"Kabuk komutları çalıştır",Icon:Mn,color:"text-green-400",bg:"bg-green-500/10",border:"border-green-500/20"},{id:"browser",label:"Browser",desc:"Playwright ile tam web otomasyonu",Icon:Ge,color:"text-blue-400",bg:"bg-blue-500/10",border:"border-blue-500/20"},{id:"web-search",label:"Web Search",desc:"Çoklu sağlayıcıyla gerçek zamanlı arama",Icon:fn,color:"text-cyan-400",bg:"bg-cyan-500/10",border:"border-cyan-500/20"},{id:"file-manager",label:"Files",desc:"Dosya oku, yaz ve yönet",Icon:Ln,color:"text-yellow-400",bg:"bg-yellow-500/10",border:"border-yellow-500/20"},{id:"image-gen",label:"Görsel Üret",desc:"AI ile görsel üret",Icon:fv,color:"text-pink-400",bg:"bg-pink-500/10",border:"border-pink-500/20"},{id:"code",label:"Kod Analizi",desc:"Kod yaz, analiz et ve hata ayıkla",Icon:en,color:"text-purple-400",bg:"bg-purple-500/10",border:"border-purple-500/20"},{id:"memory",label:"Bellek",desc:"Semantik hafıza arama & kayıt",Icon:Zt,color:"text-orange-400",bg:"bg-orange-500/10",border:"border-orange-500/20"},{id:"vision",label:"Görme",desc:"Ekran ve görsel algı",Icon:uu,color:"text-emerald-400",bg:"bg-emerald-500/10",border:"border-emerald-500/20"},{id:"screen-sense",label:"Ekranı Gör",desc:"Kullanıcı ekranını yakala ve analiz et",Icon:op,color:"text-indigo-400",bg:"bg-indigo-500/10",border:"border-indigo-500/20"},{id:"gateway",label:"Gateway",desc:"Sistem arası ve A2A iletişim",Icon:ul,color:"text-teal-400",bg:"bg-teal-500/10",border:"border-teal-500/20"},{id:"messages",label:"Mesajlar",desc:"Ajan-arası mesaj gönder & al",Icon:Hs,color:"text-rose-400",bg:"bg-rose-500/10",border:"border-rose-500/20"},{id:"git",label:"Git",desc:"Commit, branch, diff, push/pull",Icon:lv,color:"text-amber-400",bg:"bg-amber-500/10",border:"border-amber-500/20"}];function S_(){const[e,t]=u.useState("tools"),[n,r]=u.useState([]),[a,i]=u.useState([]),[o,l]=u.useState({}),[c,d]=u.useState(!1),[h,p]=u.useState(""),f=u.useCallback(async()=>{d(!0);try{const j=await U("/api/skills/list");if(j.ok){const k=await j.json();r(Array.isArray(k)?k:[])}}catch{}d(!1)},[]),m=u.useCallback(async()=>{d(!0);try{const j=await U("/api/skills/catalog");if(j.ok){const k=await j.json(),S=Array.isArray(k)?k:k.skills??[];i(S)}}catch{}d(!1)},[]);u.useEffect(()=>{e==="saved"&&f(),e==="catalog"&&m()},[e,f,m]);const b=async j=>{l(k=>({...k,[j.id]:"running"}));try{const k=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:j.id})});l(S=>({...S,[j.id]:k.ok?"done":"error"})),te[k.ok?"success":"error"](k.ok?`"${j.name}" çalıştırıldı`:"Çalıştırma başarısız"),setTimeout(()=>l(S=>({...S,[j.id]:"idle"})),2500)}catch{l(k=>({...k,[j.id]:"error"}))}},y=async j=>{try{await U(`/api/skills/${j}`,{method:"DELETE"}),r(k=>k.filter(S=>S.id!==j)),te.success("Beceri silindi.")}catch{te.error("Silinemedi.")}},v=async(j,k)=>{l(S=>({...S,[j]:"running"}));try{const S=await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:j,goal:`${k} becerisini çalıştır`})});l(C=>({...C,[j]:S.ok?"done":"error"})),S.ok&&te.success(`"${k}" yapay zekanın araç kutusuna eklendi ve aktif edildi`),setTimeout(()=>l(C=>({...C,[j]:"idle"})),2500)}catch{l(S=>({...S,[j]:"error"}))}},x=N_.filter(j=>j.label.toLowerCase().includes(h.toLowerCase())||j.desc.toLowerCase().includes(h.toLowerCase())),g=n.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.goal.toLowerCase().includes(h.toLowerCase())),w=a.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.description.toLowerCase().includes(h.toLowerCase())||(j.pluginName??"").toLowerCase().includes(h.toLowerCase()));return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsx("div",{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl flex items-center justify-center shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)"},children:s.jsx(Ue,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Beceriler & Araçlar"}),s.jsx("p",{className:"text-[12px] text-white/35 mt-0.5",children:"Must-b'nin bilişsel yetenekleri"})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(fn,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-white/25"}),s.jsx("input",{value:h,onChange:j=>p(j.target.value),placeholder:"Ara…",className:"w-full bg-white/5 border border-white/8 rounded-xl py-2 pl-8 pr-3 text-[13px] text-white/75 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20"})]}),s.jsx("div",{className:"flex rounded-xl overflow-hidden border border-white/8",children:[{key:"tools",label:"Dahili Araçlar"},{key:"saved",label:"Kaydedilen"},{key:"catalog",label:"Katalog"}].map(({key:j,label:k})=>s.jsx("button",{onClick:()=>t(j),className:`px-4 py-2 text-[12px] font-semibold transition-all ${e===j?"bg-orange-500/20 text-orange-300":"text-white/40 hover:text-white/70 hover:bg-white/5"}`,children:k},j))})]}),e==="tools"&&s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:x.map(({id:j,label:k,desc:S,Icon:C,color:A,bg:N,border:_})=>s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18},className:`rounded-2xl p-4 flex gap-3 items-start border ${_}`,style:{background:"rgba(13,7,3,0.6)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${N} border ${_}`,children:s.jsx(C,{size:16,className:A})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight",children:k}),s.jsx("p",{className:"text-[11px] text-white/40 mt-0.5 leading-tight",children:S})]}),s.jsx("div",{className:"shrink-0 mt-1",children:s.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md bg-green-500/12 border border-green-500/20 text-green-400",children:"Aktif"})})]},j))}),e==="saved"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("p",{className:"text-[11px] text-white/30",children:[n.length," kaydedilmiş beceri"]}),s.jsx("button",{onClick:f,className:"p-1.5 text-white/30 hover:text-white/70 rounded-lg hover:bg-white/6 transition-all",children:s.jsx(ge,{size:13})})]}),c?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(ne,{size:20,className:"animate-spin text-orange-500/50"})}):g.length===0?s.jsx("div",{className:"text-center py-16 text-white/20 text-[13px]",children:h?"Eşleşen beceri bulunamadı.":"Henüz kaydedilmiş beceri yok."}):s.jsx("div",{className:"space-y-2",children:g.map(j=>{const k=o[j.id]??"idle";return s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 border border-orange-500/10",style:{background:"rgba(13,7,3,0.6)",backdropFilter:"blur(12px)"},children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0 mt-0.5",children:s.jsx(Dl,{size:14,className:"text-orange-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:j.name}),s.jsx("p",{className:"text-[11px] text-white/40 truncate mt-0.5",children:j.goal}),s.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-white/25",children:[s.jsx(rv,{size:9})," ",j.runCount," çalıştırma"]}),s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-white/25",children:[s.jsx(Lt,{size:9})," ",new Date(j.savedAt).toLocaleDateString("tr-TR")]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx("button",{onClick:()=>b(j),disabled:k==="running",className:`w-8 h-8 rounded-xl flex items-center justify-center transition-all border ${k==="done"?"bg-green-500/15 border-green-500/25 text-green-400":k==="error"?"bg-red-500/15 border-red-500/25 text-red-400":k==="running"?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/5 border-white/10 text-white/50 hover:bg-orange-500/15 hover:border-orange-500/25 hover:text-orange-300"}`,children:k==="running"?s.jsx(ne,{size:13,className:"animate-spin"}):k==="done"?s.jsx(Fe,{size:13}):k==="error"?s.jsx(Ke,{size:13}):s.jsx(gs,{size:13})}),s.jsx("button",{onClick:()=>y(j.id),className:"w-8 h-8 rounded-xl flex items-center justify-center border border-white/8 text-white/25 hover:bg-red-500/12 hover:border-red-500/20 hover:text-red-400 transition-all",children:s.jsx(ys,{size:13})})]})]}),(j.tags??[]).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 mt-2 ml-11",children:(j.tags??[]).map(S=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/5 border border-white/8 text-white/35",children:S},S))})]},j.id)})})]}),e==="catalog"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("p",{className:"text-[11px] text-white/30",children:[a.length," beceri"]}),s.jsx("button",{onClick:m,className:"p-1.5 text-white/30 hover:text-white/70 rounded-lg hover:bg-white/6 transition-all",children:s.jsx(ge,{size:13})})]}),c?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(ne,{size:20,className:"animate-spin text-orange-500/50"})}):w.length===0?s.jsx("div",{className:"text-center py-16 text-white/20 text-[13px]",children:h?"Eşleşen beceri bulunamadı.":"Katalog boş."}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:w.map(j=>{var S;const k=o[j.id]??"idle";return s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 border border-white/8 flex gap-3",style:{background:"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:"text-[22px] shrink-0",children:j.emoji??"⚡"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:j.name}),s.jsx("p",{className:"text-[11px] text-white/40 mt-0.5 leading-tight line-clamp-2",children:j.description}),j.pluginName&&s.jsx("p",{className:"text-[10px] text-white/20 mt-1",children:j.pluginName}),(((S=j.requires)==null?void 0:S.bins)??[]).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:(j.requires.bins??[]).map(C=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-orange-500/8 border border-orange-500/15 text-orange-400/70",children:C},C))})]}),s.jsx("button",{onClick:()=>v(j.id,j.name),disabled:k==="running",className:`w-8 h-8 rounded-xl flex items-center justify-center shrink-0 transition-all border mt-0.5 ${k==="done"?"bg-green-500/15 border-green-500/25 text-green-400":k==="error"?"bg-red-500/15 border-red-500/25 text-red-400":k==="running"?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/5 border-white/10 text-white/50 hover:bg-orange-500/15 hover:border-orange-500/25 hover:text-orange-300"}`,children:k==="running"?s.jsx(ne,{size:13,className:"animate-spin"}):k==="done"?s.jsx(Fe,{size:13}):k==="error"?s.jsx(Ke,{size:13}):s.jsx(tn,{size:13})})]},j.id)})})]})]})}const C_={node:en,python:wn,api:na,cli:Mn,web:Ge,database:Ni,cloud:iv,agent:Wr};function E_(e,t){const n=e.toLowerCase();return n.includes("api")||n.includes("webhook")?na:n.includes("db")||n.includes("database")||n.includes("sql")?Ni:n.includes("cloud")||n.includes("s3")||n.includes("gcs")?iv:n.includes("agent")||n.includes("bot")?Wr:n.includes("web")||n.includes("http")?Ge:C_[t]??Qs}function __(e){const t=new Map;for(const n of e){if(!n.pluginName)continue;const r=t.get(n.pluginName);r?r.skillCount+=1:t.set(n.pluginName,{name:n.pluginName,emoji:n.emoji??"🔧",skillCount:1})}return Array.from(t.values()).sort((n,r)=>n.name.localeCompare(r.name))}function T_(){const[e,t]=u.useState([]),[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(""),[f,m]=u.useState(""),[b,y]=u.useState("node"),[v,x]=u.useState(""),[g,w]=u.useState(!1),j=u.useCallback(async()=>{i(!0);try{const[N,_]=await Promise.all([U("/api/plugins/list"),U("/api/skills/catalog")]);if(N.ok){const L=await N.json();t(Array.isArray(L)?L:[])}if(_.ok){const L=await _.json(),B=Array.isArray(L)?L:L.skills??[];r(__(B))}}catch{}i(!1)},[]);u.useEffect(()=>{j()},[j]);const k=async N=>{l(N.name);try{const _=N.running?"/api/plugins/stop":"/api/plugins/run";(await U(_,{method:"POST",body:JSON.stringify({name:N.name})})).ok?(t(B=>(Array.isArray(B)?B:[]).map(z=>z.name===N.name?{...z,running:!z.running}:z)),te.success(N.running?`"${N.name}" durduruldu`:`"${N.name}" başlatıldı`)):te.error("İşlem başarısız.")}catch{te.error("Bağlantı hatası.")}l(null)},S=async N=>{if(N.preventDefault(),!(!h.trim()||!f.trim())){w(!0);try{const _=await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:h,goal:f,lang:b,context:v})});if(_.ok){const L=await _.json();te.success(`"${L.name??h}" eklentisi oluşturuldu!`),p(""),m(""),x(""),d(!1),j()}else{const L=await _.json().catch(()=>({}));te.error(L.error??"Oluşturma başarısız.")}}catch{te.error("Gateway bağlantı hatası.")}w(!1)}},C=Array.isArray(e)?e:[],A=C.filter(N=>N.running).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl flex items-center justify-center shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)"},children:s.jsx(qr,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Eklentiler"}),s.jsxs("p",{className:"text-[12px] text-white/35 mt-0.5",children:[C.length," özel eklenti · ",A," çalışıyor"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:j,className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all",children:s.jsx(ge,{size:14})}),s.jsxs("button",{onClick:()=>d(N=>!N),className:`flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-[12px] font-semibold transition-all border ${c?"bg-orange-500/20 border-orange-500/30 text-orange-300":"bg-white/6 border-white/10 text-white/60 hover:bg-orange-500/12 hover:border-orange-500/20 hover:text-orange-300"}`,children:[c?s.jsx(ze,{size:13}):s.jsx(Fl,{size:13}),c?"Kapat":"Yeni Eklenti"]})]})]}),s.jsx(ae,{children:c&&s.jsx(V.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-8,height:0},transition:{duration:.2},className:"overflow-hidden mb-5",children:s.jsxs("form",{onSubmit:S,className:"rounded-2xl p-5 border border-orange-500/20",style:{background:"rgba(13,7,3,0.7)",backdropFilter:"blur(16px)"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(Ue,{size:14,className:"text-orange-400"}),s.jsx("h3",{className:"text-[13px] font-bold text-white/90",children:"Yeni Eklenti Oluştur"})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Ad"}),s.jsx("input",{value:h,onChange:N=>p(N.target.value),placeholder:"my-plugin",required:!0,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Dil"}),s.jsx("div",{className:"flex rounded-xl overflow-hidden border border-white/8",children:["node","python"].map(N=>s.jsxs("button",{type:"button",onClick:()=>y(N),className:`flex-1 py-2 text-[12px] font-semibold transition-all flex items-center justify-center gap-1.5 ${b===N?"bg-orange-500/20 text-orange-300":"text-white/40 hover:text-white/70 hover:bg-white/5"}`,children:[N==="node"?s.jsx(en,{size:12}):s.jsx(wn,{size:12}),N==="node"?"Node.js":"Python"]},N))})]})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Hedef / Açıklama"}),s.jsx("textarea",{value:f,onChange:N=>m(N.target.value),placeholder:"Bu eklenti ne yapmalı?",required:!0,rows:2,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20 resize-none"})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Bağlam (isteğe bağlı)"}),s.jsx("textarea",{value:v,onChange:N=>x(N.target.value),placeholder:"API anahtarları, URL'ler, ek bağlam…",rows:2,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20 resize-none"})]}),s.jsxs("button",{type:"submit",disabled:g||!h.trim()||!f.trim(),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl bg-orange-600/20 border border-orange-500/30 text-orange-300 text-[13px] font-semibold hover:bg-orange-600/30 transition-all disabled:opacity-40",children:[g?s.jsx(ne,{size:13,className:"animate-spin"}):s.jsx(tn,{size:13}),g?"Oluşturuluyor…":"Oluştur"]})]})})}),n.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/25 mb-3",children:"Yüklü Beceri Paketleri"}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:n.map(N=>s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 flex gap-3 items-center border border-white/8",style:{background:"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:"text-[22px] shrink-0",children:N.emoji}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight truncate",children:N.name}),s.jsxs("p",{className:"text-[10px] text-white/30 mt-0.5",children:[N.skillCount," beceri"]})]}),s.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md bg-green-500/12 border border-green-500/20 text-green-400 shrink-0",children:"Yüklü"})]},N.name))})]}),a?s.jsx("div",{className:"flex justify-center py-20",children:s.jsx(ne,{size:22,className:"animate-spin text-orange-500/50"})}):C.length===0?s.jsxs("div",{className:"rounded-2xl border border-white/8 p-8 text-center",style:{background:"rgba(13,7,3,0.4)"},children:[s.jsx(qr,{size:28,className:"text-white/15 mx-auto mb-3"}),s.jsx("p",{className:"text-[13px] text-white/30 font-medium",children:"Henüz özel eklenti yok"}),s.jsx("p",{className:"text-[12px] text-white/20 mt-1",children:'Yukarıdaki "Yeni Eklenti" ile kendi konektörünü oluştur.'})]}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:C.map(N=>{const _=o===N.name,L=E_(N.name,N.lang),B=N.lang==="node"?en:wn;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:`rounded-2xl p-4 border transition-all ${N.running?"border-orange-500/25":"border-white/8 hover:border-white/14"}`,style:{background:N.running?"rgba(249,115,22,0.06)":"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${N.running?"bg-orange-500/15 border border-orange-500/25":"bg-white/6 border border-white/10"}`,children:s.jsx(L,{size:16,className:N.running?"text-orange-400":"text-white/50"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight truncate max-w-[120px]",children:N.name}),s.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[s.jsx(B,{size:9,className:N.lang==="node"?"text-green-400/60":"text-blue-400/60"}),s.jsx("span",{className:`text-[9px] font-semibold ${N.lang==="node"?"text-green-400/60":"text-blue-400/60"}`,children:N.lang==="node"?"Node.js":"Python"})]})]})]}),s.jsx("span",{className:`text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md border ${N.running?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/5 border-white/10 text-white/30"}`,children:N.running?"Çalışıyor":"Durdu"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] text-white/25",children:new Date(N.createdAt).toLocaleDateString("tr-TR")}),s.jsxs("button",{onClick:()=>k(N),disabled:_,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all border ${N.running?"bg-red-500/12 border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-orange-500/12 border-orange-500/20 text-orange-400 hover:bg-orange-500/20"} disabled:opacity-40`,children:[_?s.jsx(ne,{size:11,className:"animate-spin"}):N.running?s.jsx($l,{size:11}):s.jsx(gs,{size:11}),N.running?"Durdur":"Başlat"]})]})]},N.name)})})]})}function P_(){return new URLSearchParams(window.location.search).get("token")??""}function A_(){const[e,t]=u.useState("connecting"),[n,r]=u.useState([]),[a,i]=u.useState([]),[o,l]=u.useState("idle"),[c,d]=u.useState(null),[h,p]=u.useState(""),f=u.useRef(null),m=u.useRef(null),b=u.useRef([]),y=P_();u.useEffect(()=>{if(!y){t("denied");return}const k=Ba(`${window.location.origin}/mobile`,{query:{token:y},transports:["websocket","polling"]});return f.current=k,k.on("connect",()=>t("connected")),k.on("disconnect",()=>t("disconnected")),k.on("authError",()=>{t("denied"),k.disconnect()}),k.on("agentUpdate",S=>{const{type:C}=S;if(C==="planStart"&&r([]),C==="stepStart"){const A=S.step;r(N=>[...N,{id:`${Date.now()}-${Math.random()}`,description:(A==null?void 0:A.description)??"Working…",status:"running"}])}C==="stepFinish"&&r(A=>{const N=[...A],_=N.findLastIndex(L=>L.status==="running");return _>=0&&(N[_]={...N[_],status:S.status==="error"?"error":"done"}),N}),C==="skillRunStart"&&S.skillId&&d(S.skillId),C==="planFinish"&&d(null)}),()=>{k.disconnect()}},[y]);const v=u.useCallback(async()=>{try{const k=await fetch("/api/skills/list",{headers:{Authorization:`Bearer ${y}`}});if(k.ok){const S=await k.json();i(S.skills??[])}}catch{}},[y]);u.useEffect(()=>{v()},[v]);const x=async()=>{try{const k=await navigator.mediaDevices.getUserMedia({audio:!0}),S=new MediaRecorder(k,{mimeType:"audio/webm"});b.current=[],S.ondataavailable=C=>{C.data.size>0&&b.current.push(C.data)},S.onstop=()=>{k.getTracks().forEach(C=>C.stop()),w()},S.start(),m.current=S,l("recording")}catch{l("idle")}},g=()=>{var k;(k=m.current)==null||k.stop(),l("sending")},w=async()=>{const k=new Blob(b.current,{type:"audio/webm"}),S=new FormData;S.append("audio",k,"voice.webm");try{const C=await fetch("/api/voice/transcribe",{method:"POST",headers:{Authorization:`Bearer ${y}`},body:S});if(C.ok){const{text:A}=await C.json();p(A),await fetch("/api/goal",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({goal:A})})}}catch{}l("idle")},j=async k=>{if(!c){d(k.id);try{await fetch("/api/skills/run",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({id:k.id})})}catch{d(null)}}};return!y||e==="denied"?s.jsxs("div",{className:"min-h-screen bg-[#02040a] flex flex-col items-center justify-center gap-4 text-center px-8",children:[s.jsx(Ke,{size:40,className:"text-red-400"}),s.jsx("p",{className:"text-white font-bold text-xl",children:"Access Denied"}),s.jsxs("p",{className:"text-gray-500 text-sm",children:["This link is invalid or has expired.",s.jsx("br",{}),"Generate a new QR code from your desktop."]})]}):s.jsxs("div",{className:"min-h-screen bg-[#02040a] text-white flex flex-col pb-8",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("img",{src:"/logo.png",alt:"Must-b",className:"w-8 h-8 object-contain"}),s.jsx("span",{className:"font-bold text-base",children:"Must-b"}),s.jsx("span",{className:"text-[10px] text-orange-400 font-medium bg-orange-400/10 border border-orange-400/20 px-2 py-0.5 rounded-full",children:"Companion"})]}),s.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:e==="connected"?s.jsxs(s.Fragment,{children:[s.jsx(Eo,{size:13,className:"text-green-400"}),s.jsx("span",{className:"text-green-400",children:"Connected"})]}):e==="connecting"?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:13,className:"animate-spin text-orange-400"}),s.jsx("span",{className:"text-orange-400",children:"Connecting…"})]}):s.jsxs(s.Fragment,{children:[s.jsx(vs,{size:13,className:"text-gray-600"}),s.jsx("span",{className:"text-gray-500",children:"Offline"})]})})]}),s.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-6 border-b border-white/5",children:[s.jsx("p",{className:"text-[11px] text-gray-500 font-medium uppercase tracking-widest mb-6",children:"Voice Command"}),s.jsxs(V.button,{onPointerDown:x,onPointerUp:g,onPointerLeave:o==="recording"?g:void 0,disabled:o==="sending"||e!=="connected",whileTap:{scale:.93},className:`relative w-28 h-28 rounded-full flex items-center justify-center transition-all select-none ${o==="recording"?"bg-red-500/20 border-2 border-red-500 shadow-[0_0_40px_rgba(239,68,68,0.4)]":o==="sending"?"bg-orange-500/10 border-2 border-orange-500/30":"bg-orange-500/10 border-2 border-orange-500/40 hover:bg-orange-500/20 active:scale-95"} disabled:opacity-40`,children:[o==="sending"?s.jsx(ne,{size:36,className:"text-orange-400 animate-spin"}):o==="recording"?s.jsx(hv,{size:36,className:"text-red-400"}):s.jsx(Gr,{size:36,className:"text-orange-400"}),o==="recording"&&s.jsx(V.span,{className:"absolute inset-0 rounded-full border-2 border-red-500",animate:{scale:[1,1.3,1],opacity:[.8,0,.8]},transition:{duration:1.4,repeat:1/0}})]}),s.jsx("p",{className:"text-[12px] text-gray-600 mt-4",children:o==="recording"?"Listening… release to send":"Hold to speak"}),h&&s.jsxs("p",{className:"text-[11px] text-orange-300 mt-3 text-center max-w-xs",children:['"',h,'"']})]}),s.jsxs("div",{className:"px-5 pt-6 pb-4 border-b border-white/5",children:[s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase tracking-widest mb-3",children:"Live Workflow"}),s.jsx(ae,{children:n.length===0?s.jsx("p",{className:"text-[12px] text-gray-700 text-center py-4",children:"No active workflow"}):s.jsx("div",{className:"space-y-2",children:n.slice(-6).map(k=>s.jsxs(V.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:`flex items-start gap-2.5 p-3 rounded-xl border text-[12px] ${k.status==="running"?"bg-orange-500/8 border-orange-500/20":k.status==="error"?"bg-red-500/8 border-red-500/15":"bg-white/3 border-white/5"}`,children:[k.status==="running"&&s.jsx(ne,{size:12,className:"animate-spin text-orange-400 mt-0.5 shrink-0"}),k.status==="done"&&s.jsx(Fe,{size:12,className:"text-green-400 mt-0.5 shrink-0"}),k.status==="error"&&s.jsx(Ke,{size:12,className:"text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{className:k.status==="running"?"text-orange-300":k.status==="error"?"text-red-300":"text-gray-400",children:k.description})]},k.id))})})]}),s.jsxs("div",{className:"px-5 pt-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase tracking-widest",children:"My Skills"}),s.jsx("button",{onClick:v,className:"text-gray-600 hover:text-gray-400 transition-colors",children:s.jsx(ge,{size:12})})]}),a.length===0?s.jsx("p",{className:"text-[12px] text-gray-700 text-center py-6",children:"No skills saved yet"}):s.jsx("div",{className:"space-y-2.5",children:a.map(k=>{const S=c===k.id;return s.jsxs(V.div,{layout:!0,className:`flex items-center gap-3 p-3.5 rounded-2xl border transition-all ${S?"bg-orange-500/10 border-orange-500/25":"bg-[#0c0f18] border-white/6"}`,children:[s.jsx(Ue,{size:14,className:"text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"font-semibold text-[13px] text-white truncate",children:k.name}),s.jsxs("p",{className:"text-[10px] text-gray-600 mt-0.5",children:[k.runCount,"× run"]})]}),s.jsxs("button",{onClick:()=>j(k),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${S?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":"bg-orange-500/10 border border-orange-500/20 text-orange-400 hover:bg-orange-500/20 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:[S?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(gs,{size:11}),S?"Running":"Run"]})]},k.id)})})]})]})}function M_(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState(null);return u.useEffect(()=>{U("/api/workspace/files").then(o=>o.ok?o.json():Promise.reject(`HTTP ${o.status}`)).then(o=>{const l=Array.isArray(o==null?void 0:o.files)?o.files:[];t(l.map(c=>({name:c.name,path:c.rel,size:c.size,modified:c.mtime})))}).catch(o=>i(String(o))).finally(()=>r(!1))},[]),s.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx(Ln,{size:20,className:"text-orange-400"}),s.jsx("h1",{className:"text-lg font-bold text-white",children:"Files"})]}),n&&s.jsxs("div",{className:"flex items-center gap-2 text-gray-400 text-sm",children:[s.jsx(ne,{size:14,className:"animate-spin"}),"Loading files…"]}),a&&s.jsxs("p",{className:"text-red-400 text-sm",children:["Failed to load files: ",a]}),!n&&!a&&e.length===0&&s.jsx("p",{className:"text-gray-500 text-sm",children:"No files found in workspace."}),!n&&e.length>0&&s.jsx("div",{className:"space-y-1",children:e.map(o=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-lg hover:bg-white/5 transition-colors",children:[s.jsx(nn,{size:14,className:"text-gray-400 shrink-0"}),s.jsx("span",{className:"text-[13px] text-gray-200 flex-1 truncate",children:o.name}),o.size!==void 0&&s.jsxs("span",{className:"text-[11px] text-gray-500",children:[(o.size/1024).toFixed(1)," KB"]})]},o.path))})]})}const z_=[{value:"all",label:"Tüm Veriler",icon:s.jsx(Ge,{size:13})},{value:"text",label:"Sadece Metin",icon:s.jsx(nn,{size:13})},{value:"links",label:"Sadece Linkler",icon:s.jsx(na,{size:13})},{value:"images",label:"Sadece Görseller",icon:s.jsx(sp,{size:13})}];function R_(e){return e==="text"?s.jsx(nn,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}):e==="link"?s.jsx(na,{size:13,className:"text-blue-400 shrink-0 mt-0.5"}):s.jsx(sp,{size:13,className:"text-purple-400 shrink-0 mt-0.5"})}function L_(e){return e==="text"?"Metin":e==="link"?"Link":"Görsel"}function O_(){const[e,t]=u.useState(""),[n,r]=u.useState("all"),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(new Set),[f,m]=u.useState(!1),[b,y]=u.useState(!1),[v,x]=u.useState(""),[g,w]=u.useState(""),[j,k]=u.useState(!1),[S,C]=u.useState(""),[A,N]=u.useState([]),[_,L]=u.useState(null),[B,z]=u.useState(!1),$=u.useRef(null);u.useEffect(()=>{U("/api/memory/save-path").then(F=>F.json()).then(F=>{F.ok&&F.path&&(x(F.path),w(F.path))}).catch(()=>{})},[]);const R=(c??[]).filter(F=>n==="all"?!0:F.type===(n==="links"?"link":n==="images"?"image":"text")),M=F=>{p(Q=>{const q=new Set(Q);return q.has(F)?q.delete(F):q.add(F),q})},P=()=>{h.size===R.length?p(new Set):p(new Set(R.map(F=>F.id)))},E=async()=>{const F=e.trim();if(F){i(!0),l(null),d(null),p(new Set),y(!1);try{const Q=await U("/api/browser/scrape",{method:"POST",body:JSON.stringify({url:F,mode:n})}),q=await Q.json();if(!Q.ok||!q.ok)l(q.error??`Sunucu hatası: ${Q.status}`);else{const X=q.items??[];d(X),p(new Set(X.map(le=>le.id)))}}catch{l("Ağ bağlantısı kurulamadı. Backend çalışıyor mu?")}finally{i(!1)}}},T=async()=>{const F=(c??[]).filter(Q=>h.has(Q.id));if(F.length!==0){m(!0);try{const Q=await U("/api/memory/import",{method:"POST",body:JSON.stringify({entries:F.map(q=>({type:q.type,content:q.content,source:e}))})});if(Q.ok){const q=await Q.json();q.savedTo&&x(q.savedTo.replace(/[\\/][^\\/]+$/,""))}y(!0)}catch{}finally{m(!1)}}},O=()=>{C(v),L(null),N([]),k(!0)},G=()=>{k(!1),C(v),N([]),L(null)},D=F=>{C(F),L(null),$.current&&clearTimeout($.current),$.current=setTimeout(async()=>{try{const Q=F.replace(/[/\\][^/\\]*$/,"")||F,X=await(await U(`/api/fs/list-dirs?path=${encodeURIComponent(Q)}`)).json();X.ok&&N((X.dirs??[]).filter(le=>le.toLowerCase().startsWith(F.toLowerCase())))}catch{}},250)},K=async()=>{if(!S.trim()){G();return}z(!0),L(null);try{const Q=await(await U("/api/memory/save-path",{method:"POST",body:JSON.stringify({path:S.trim()})})).json();Q.ok&&Q.path?(x(Q.path),w(Q.path),k(!1),N([])):(L(Q.error??"Geçersiz dizin. Önceki yol geri yüklendi."),x(g),C(g))}catch{L("Bağlantı hatası. Önceki yol korunuyor."),x(g),C(g)}finally{z(!1)}};return s.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-10",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.3)"},children:s.jsx(Ge,{size:18,className:"text-orange-400 animate-pulse"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[17px] font-bold text-white/90 leading-tight",children:"Tarayıcı Otomasyonu"}),s.jsx("p",{className:"text-[12px] text-white/40",children:"Web sayfalarını tara, analiz et ve verileri belleğine kaydet"})]})]}),s.jsxs("div",{className:"rounded-xl px-5 py-4 mb-5",style:{background:"rgba(249,115,22,0.05)",border:"1px solid rgba(249,115,22,0.15)"},children:[s.jsx("p",{className:"text-[13px] font-semibold text-white/80 mb-3 leading-snug",children:"Must-b Otonom Tarayıcı ile internetin gücünü belleğinize katın:"}),s.jsx("ol",{className:"space-y-1.5",children:["Hedef URL'yi girin.","Çıkarmak istediğiniz veri türünü seçin (Metin, Link veya Görsel).","Başlat butonuna basarak Must-b'nin siteyi analiz etmesini bekleyin.","Sonuçları inceleyin ve kalıcı hafızaya kaydetmek istediklerinizi seçin."].map((F,Q)=>s.jsxs("li",{className:"flex items-start gap-2.5 text-[13px] text-white/80 leading-relaxed",children:[s.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-black shrink-0 mt-0.5",style:{background:"rgba(249,115,22,0.25)",color:"#fb923c"},children:Q+1}),F]},Q))}),s.jsxs("p",{className:"mt-3 text-[11px] text-orange-400/70 flex items-start gap-1.5 leading-relaxed",children:[s.jsx("span",{className:"shrink-0 mt-0.5",children:"🔒"}),s.jsxs("span",{children:[s.jsx("strong",{className:"text-orange-400/90",children:"Güvenlik Notu:"})," ","Tüm işlemler yerel Playwright motorunda gerçekleşir, verileriniz üçüncü taraflara asla iletilmez."]})]})]}),s.jsxs("div",{className:"rounded-2xl p-5 mb-4",style:{background:"rgba(13,7,3,0.80)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px rgba(0,0,0,0.45)"},children:[s.jsx("label",{className:"block text-[11px] font-bold text-white/40 uppercase tracking-widest mb-2",children:"Hedef URL"}),s.jsxs("div",{className:"flex gap-2 mb-5",children:[s.jsx("input",{type:"url",value:e,onChange:F=>t(F.target.value),onKeyDown:F=>F.key==="Enter"&&!a&&E(),placeholder:"https://example.com",className:"flex-1 px-4 py-2.5 rounded-xl text-[13px] text-white/85 placeholder-white/20 outline-none transition-all",style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)"},onFocus:F=>F.currentTarget.style.borderColor="rgba(249,115,22,0.55)",onBlur:F=>F.currentTarget.style.borderColor="rgba(255,255,255,0.12)"}),s.jsxs("button",{onClick:E,disabled:a||!e.trim(),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-semibold transition-all disabled:opacity-40",style:{background:a||!e.trim()?"rgba(249,115,22,0.25)":"rgba(249,115,22,0.85)",color:"#fff",border:"1px solid rgba(249,115,22,0.4)"},children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Kr,{size:14}),a?"Taranıyor…":"Başlat"]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[11px] font-bold text-white/40 uppercase tracking-widest mb-2.5",children:"Çıkarma Modu"}),s.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:z_.map(F=>s.jsxs("button",{onClick:()=>r(F.value),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-[12px] font-medium transition-all",style:{background:n===F.value?"rgba(249,115,22,0.18)":"rgba(255,255,255,0.04)",border:n===F.value?"1px solid rgba(249,115,22,0.45)":"1px solid rgba(255,255,255,0.08)",color:n===F.value?"#fb923c":"rgba(255,255,255,0.45)"},children:[F.icon,F.label]},F.value))})]}),a&&s.jsxs("div",{className:"mt-5 flex items-center gap-3 px-4 py-3 rounded-xl",style:{background:"rgba(249,115,22,0.08)",border:"1px solid rgba(249,115,22,0.2)"},children:[s.jsx(ne,{size:15,className:"animate-spin text-orange-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-orange-300",children:"Sayfa taranıyor…"}),s.jsx("p",{className:"text-[11px] text-white/35 mt-0.5",children:"Playwright sayfayı açıyor ve içerik çıkarılıyor"})]})]}),o&&s.jsxs("div",{className:"mt-5 flex items-start gap-3 px-4 py-3 rounded-xl",style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)"},children:[s.jsx(Ke,{size:15,className:"text-red-400 shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-red-300",children:"Hata oluştu"}),s.jsx("p",{className:"text-[11px] text-red-400/70 mt-0.5",children:o})]})]})]}),c!==null&&R.length>0&&s.jsxs("div",{className:"rounded-2xl p-5",style:{background:"rgba(13,7,3,0.75)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px rgba(0,0,0,0.40)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/85",children:"Çıkarılan Veriler"}),s.jsxs("p",{className:"text-[11px] text-white/35 mt-0.5",children:[R.length," öğe bulundu · ",h.size," seçili"]})]}),s.jsxs("button",{onClick:P,className:"text-[11px] font-medium text-orange-400/80 hover:text-orange-400 transition-colors flex items-center gap-1",children:[s.jsx(gn,{size:12}),h.size===R.length?"Seçimi Kaldır":"Tümünü Seç"]})]}),["text","link","image"].map(F=>{const Q=R.filter(q=>q.type===F);return Q.length===0?null:s.jsxs("div",{className:"mb-4 last:mb-0",children:[s.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/25 mb-1.5 px-1",children:[L_(F)," (",Q.length,")"]}),s.jsx("div",{className:"space-y-1",children:Q.map(q=>s.jsxs("label",{className:"flex items-start gap-3 px-3 py-2.5 rounded-lg cursor-pointer transition-all",style:{background:h.has(q.id)?"rgba(249,115,22,0.08)":"rgba(255,255,255,0.03)",border:h.has(q.id)?"1px solid rgba(249,115,22,0.22)":"1px solid rgba(255,255,255,0.06)"},children:[s.jsx("div",{className:"w-4 h-4 rounded flex items-center justify-center shrink-0 mt-0.5 transition-all",style:{background:h.has(q.id)?"rgba(249,115,22,0.8)":"rgba(255,255,255,0.08)",border:h.has(q.id)?"1px solid rgba(249,115,22,0.9)":"1px solid rgba(255,255,255,0.18)"},onClick:()=>M(q.id),children:h.has(q.id)&&s.jsx(it,{size:10,className:"text-white"})}),R_(q.type),s.jsx("span",{className:"text-[12px] text-white/65 leading-relaxed break-all",children:q.content})]},q.id))})]},F)}),s.jsxs("div",{className:"mt-5 pt-4 border-t border-white/8",children:[b?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-2.5 rounded-xl text-[13px] font-semibold",style:{background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.25)",color:"#4ade80"},children:[s.jsx(it,{size:14}),h.size," öğe belleğe kaydedildi"]}):s.jsx("button",{onClick:T,disabled:f||h.size===0,className:"w-full flex items-center justify-center gap-2 py-2.5 rounded-xl text-[13px] font-semibold transition-all disabled:opacity-40",style:{background:"rgba(249,115,22,0.18)",border:"1px solid rgba(249,115,22,0.35)",color:"#fb923c"},children:f?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:14,className:"animate-spin"})," Kaydediliyor…"]}):s.jsxs(s.Fragment,{children:[s.jsx(sv,{size:14})," Seçilenleri Belleğe Kaydet (",h.size,")"]})}),v&&s.jsxs("div",{className:"mt-3 rounded-xl px-4 py-3",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.09)"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(Ln,{size:12,className:"text-white/35 shrink-0"}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30",children:"Kaydedilen Konum"})]}),j?s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{autoFocus:!0,value:S,onChange:F=>D(F.target.value),onKeyDown:F=>{F.key==="Enter"&&K(),F.key==="Escape"&&G()},placeholder:"Dizin yolu girin…",className:"flex-1 px-3 py-1.5 rounded-lg text-[12px] text-white/80 placeholder-white/20 outline-none",style:{background:"rgba(255,255,255,0.07)",border:"1px solid rgba(249,115,22,0.45)"}}),s.jsx("button",{onClick:K,disabled:B,className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold transition-all disabled:opacity-40",style:{background:"rgba(249,115,22,0.75)",color:"#fff"},children:B?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(it,{size:11})}),s.jsx("button",{onClick:G,className:"px-2.5 py-1.5 rounded-lg transition-all",style:{background:"rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.4)"},children:s.jsx(ze,{size:11})})]}),A.length>0&&s.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 rounded-xl overflow-hidden z-50",style:{background:"rgba(20,12,5,0.97)",border:"1px solid rgba(249,115,22,0.3)",boxShadow:"0 8px 24px rgba(0,0,0,0.6)"},children:A.map(F=>s.jsx("button",{onClick:()=>{C(F),N([])},className:"w-full text-left px-4 py-2 text-[11px] text-white/70 hover:bg-orange-500/10 hover:text-orange-300 transition-colors truncate",children:F},F))}),_&&s.jsxs("p",{className:"mt-1.5 text-[11px] text-red-400 flex items-center gap-1",children:[s.jsx(Ke,{size:10}),_]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"flex-1 text-[12px] text-white/55 font-mono leading-relaxed break-all",children:v}),s.jsxs("button",{onClick:O,className:"shrink-0 flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-all hover:text-orange-400",style:{background:"rgba(249,115,22,0.1)",border:"1px solid rgba(249,115,22,0.2)",color:"rgba(251,146,60,0.7)"},children:[s.jsx(hu,{size:10}),"Düzenle"]})]})]})]})]}),c!==null&&R.length===0&&s.jsx("div",{className:"text-center py-10 text-[13px] text-white/25",children:"Bu modda çıkarılacak veri bulunamadı."})]})}function I_(e){return e.replace(/hey\s+must\s*-?\s*be\b/gi,"Hey Must-b").replace(/hey\s+mustbe\b/gi,"Hey Must-b").replace(/hey\s+most\s+be\b/gi,"Hey Must-b").replace(/hey\s+must\s+b\b/gi,"Hey Must-b").replace(/hey\s+must\s+bee\b/gi,"Hey Must-b").replace(/hay\s+mas+bi\b/gi,"Hey Must-b").replace(/hey\s+mas+bi\b/gi,"Hey Must-b").replace(/hey\s+mast\s*b[ei]?\b/gi,"Hey Must-b").replace(/hey\s+m[au]s[t]?\s*b[ei]?\b/gi,"Hey Must-b").replace(/hey\s+must\s*b[eiy]+\b/gi,"Hey Must-b").replace(/hey\s+moos+\s*b[ei]?\b/gi,"Hey Must-b")}function D_(e){const t=window.speechSynthesis.getVoices(),n=e.toLowerCase();return t.find(r=>r.name.toLowerCase().includes("google")&&r.lang.toLowerCase().startsWith(n))||t.find(r=>r.lang.toLowerCase().startsWith(n)&&!r.localService)||t.find(r=>r.lang.toLowerCase().startsWith(n))||null}function B_(){const e=gt(),{t,locale:n}=yt(),[r,a]=u.useState("wake-listening"),[i,o]=u.useState("Must-b"),[l,c]=u.useState(""),[d,h]=u.useState(""),p=u.useRef(null),f=u.useRef(!1),m=u.useRef(""),b=u.useRef(null),y=u.useRef("wake-listening");u.useEffect(()=>{y.current=r},[r]),u.useEffect(()=>{U("/api/identity").then(S=>S.json()).then(S=>{S.name&&o(S.name)}).catch(()=>{})},[]);const v=u.useCallback(S=>{if(!window.speechSynthesis)return;window.speechSynthesis.cancel();const C=new SpeechSynthesisUtterance(S),A=n==="tr"?"tr-TR":n==="de"?"de-DE":n==="fr"?"fr-FR":n==="es"?"es-ES":n==="ja"?"ja-JP":n==="zh"?"zh-CN":n==="pt"?"pt-PT":"en-US";C.lang=A,C.rate=1.05,C.pitch=1;const N=()=>{const _=D_(A.split("-")[0]);_&&(C.voice=_)};N(),!C.voice&&window.speechSynthesis.onvoiceschanged!==void 0&&(window.speechSynthesis.onvoiceschanged=N),C.onend=()=>{a("wake-listening"),h(""),c("")},C.onerror=()=>a("wake-listening"),a("speaking"),window.speechSynthesis.speak(C)},[n]),x=u.useCallback(async S=>{if(!S.trim()){a("wake-listening");return}a("thinking"),c(S);try{const A=await(await U("/api/goal",{method:"POST",body:JSON.stringify({goal:S,voice:!0})})).json(),N=A.result??A.reply??A.response??A.output??"Done.";h(N),v(N)}catch{a("wake-listening")}},[v]),g=u.useCallback(()=>{const S=window.SpeechRecognition||window.webkitSpeechRecognition;if(!S||!f.current)return;const C=new S;C.continuous=!0,C.interimResults=!0,C.lang=n==="tr"?"tr-TR":"en-US",C.onresult=A=>{var B,z;let N="";for(let $=A.resultIndex;$<A.results.length;$++)N+=A.results[$][0].transcript;const _=I_(N),L=y.current;if(c(_),L==="wake-listening"){const $=`hey ${i}`.toLowerCase();if(_.toLowerCase().includes($)){const R=((B=_.toLowerCase().split($)[1])==null?void 0:B.trim())??"";m.current=R,a("cmd-listening"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(m.current.trim()&&y.current==="cmd-listening"){const M=m.current;m.current="",x(M)}},1800)}}else if(L==="cmd-listening"){const $=`hey ${i}`.toLowerCase(),R=_.toLowerCase().includes($)?((z=_.toLowerCase().split($)[1])==null?void 0:z.trim())??_:_;m.current=R,b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(m.current.trim()&&y.current==="cmd-listening"){const M=m.current;m.current="",x(M)}},2200)}},C.onend=()=>{const A=y.current;f.current&&A!=="thinking"&&A!=="speaking"?setTimeout(g,200):f.current||(a("off"),p.current=null)},C.onerror=A=>{A.error!=="no-speech"&&a("wake-listening"),f.current&&A.error!=="not-allowed"&&setTimeout(g,600)},p.current=C;try{C.start()}catch{}},[i,n,x]),w=()=>{var S,C;r!=="off"?(f.current=!1,(S=p.current)==null||S.stop(),(C=window.speechSynthesis)==null||C.cancel(),b.current&&clearTimeout(b.current),a("off"),c("")):(f.current=!0,a("wake-listening"),g())};u.useEffect(()=>(f.current=!0,a("wake-listening"),g(),()=>{var S,C;f.current=!1,(S=p.current)==null||S.stop(),(C=window.speechSynthesis)==null||C.cancel(),b.current&&clearTimeout(b.current)}),[]);const j=r==="wake-listening"||r==="cmd-listening",k=r==="off";return s.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center overflow-hidden",style:{background:"radial-gradient(ellipse at 50% 45%, rgba(249,115,22,0.22) 0%, #060301 55%)"},children:[s.jsxs("button",{onClick:()=>e("/app"),className:"absolute top-20 left-6 flex items-center gap-2 px-3 py-2 rounded-xl text-white/40 hover:text-white/80 hover:bg-white/8 transition-all text-[13px] font-medium z-10",children:[s.jsx(d3,{size:15}),s.jsx("span",{children:t.voice.back})]}),s.jsx("p",{className:"absolute top-6 text-[12px] font-bold text-white/25 tracking-[0.18em] uppercase select-none",children:t.voice.title}),[200,290,380].map((S,C)=>s.jsx(V.div,{className:"absolute rounded-full",style:{width:S,height:S,border:`1px solid rgba(249,115,22,${.12-C*.03})`},animate:j?{opacity:[.4,.7,.4],scale:[1,1.04,1]}:{opacity:.2,scale:1},transition:{duration:2.2+C*.6,repeat:1/0,ease:"easeInOut",delay:C*.4}},S)),s.jsx(V.button,{onClick:w,className:"relative w-36 h-36 rounded-full flex items-center justify-center cursor-pointer select-none mb-10",style:{background:j?"radial-gradient(circle at 38% 32%, rgba(249,115,22,0.92), rgba(160,55,8,0.75))":"radial-gradient(circle at 38% 32%, rgba(249,115,22,0.38), rgba(22,10,3,0.88))",border:`1px solid rgba(249,115,22,${j?.5:.28})`,boxShadow:j?"0 0 70px rgba(249,115,22,0.55), 0 0 140px rgba(249,115,22,0.18), inset 0 1px 0 rgba(255,255,255,0.12)":"0 0 30px rgba(249,115,22,0.12), inset 0 1px 0 rgba(255,255,255,0.05)"},animate:j?{scale:[1,1.06,1]}:{scale:1},transition:{duration:1.6,repeat:j?1/0:0,ease:"easeInOut"},whileHover:{scale:1.04},whileTap:{scale:.95},children:r==="thinking"?s.jsx(V.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-10 h-10 rounded-full border-2 border-orange-500/30 border-t-orange-400"}):r==="speaking"?s.jsx(V.span,{animate:{scale:[.9,1.1,.9]},transition:{duration:.7,repeat:1/0,ease:"easeInOut"},className:"text-4xl",children:"🔊"}):r==="cmd-listening"?s.jsx(V.span,{animate:{opacity:[.6,1,.6]},transition:{duration:.5,repeat:1/0},children:s.jsx(Gr,{size:38,className:"text-white/95"})}):k?s.jsx(Gr,{size:38,className:"text-orange-300/90"}):s.jsx(hv,{size:38,className:"text-white/90"})}),s.jsx(ae,{mode:"wait",children:s.jsxs(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"flex flex-col items-center gap-3 px-6 text-center",children:[r==="thinking"&&s.jsx("p",{className:"text-[17px] font-medium text-white/65",children:t.voice.thinking}),r==="speaking"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-orange-300",children:t.voice.speakingHint}),d&&s.jsxs("p",{className:"text-[12px] text-white/35 italic max-w-sm line-clamp-3",children:["“",d.slice(0,140),d.length>140?"…":"","”"]})]}),r==="cmd-listening"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-white/75",children:t.voice.cmdHint}),l&&s.jsxs("p",{className:"text-[13px] text-white/40 italic max-w-sm",children:["“",l,"”"]})]}),r==="wake-listening"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-white/65",children:t.voice.wakeHint}),l&&s.jsxs("p",{className:"text-[13px] text-white/35 italic max-w-sm",children:["“",l,"”"]}),s.jsx("p",{className:"text-[11px] text-white/25",children:t.voice.stopHint})]}),r==="off"&&s.jsx("p",{className:"text-[17px] font-medium text-white/40",children:t.voice.tapHint}),j&&s.jsx("div",{className:"flex items-center gap-1 mt-1",children:[0,1,2,3,4].map(S=>s.jsx(V.div,{className:"w-0.5 rounded-full bg-orange-500/60",animate:{height:["6px","18px","6px"]},transition:{duration:.8,repeat:1/0,delay:S*.12,ease:"easeInOut"}},S))})]},r)})]})}function F_({id:e,size:t=16}){const n="shrink-0";switch(e){case"telegram":return s.jsx(cp,{size:t,className:n});case"whatsapp":return s.jsx(Co,{size:t,className:n});case"discord":return s.jsx(l0,{size:t,className:n});case"slack":return s.jsx(l0,{size:t,className:n});case"signal":return s.jsx(dp,{size:t,className:n});case"imessage":case"bluebubbles":return s.jsx(Hs,{size:t,className:n});case"line":return s.jsx(Hs,{size:t,className:n});case"msteams":return s.jsx(pu,{size:t,className:n});case"matrix":case"mattermost":case"irc":case"nextcloud-talk":return s.jsx(ul,{size:t,className:n});case"voice-call":case"talk-voice":case"phone-control":return s.jsx(F3,{size:t,className:n});case"twitch":return s.jsx(X3,{size:t,className:n});case"nostr":return s.jsx(lp,{size:t,className:n});case"googlechat":return s.jsx(Co,{size:t,className:n});case"feishu":return s.jsx(f3,{size:t,className:n});case"tlon":return s.jsx(Ge,{size:t,className:n});case"zalo":case"zalouser":return s.jsx(Co,{size:t,className:n});case"synology-chat":return s.jsx(ap,{size:t,className:n});case"lobster":return s.jsx(Gr,{size:t,className:n});case"memory-lancedb":case"memory-core":return s.jsx(Ni,{size:t,className:n});case"ollama":case"sglang":case"vllm":case"copilot-proxy":return s.jsx(tn,{size:t,className:n});case"open-prose":return s.jsx(Dl,{size:t,className:n});default:return s.jsx($3,{size:t,className:n})}}function $_({ext:e}){var n,r,a;return e.active?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-green-500/10 border-green-500/25 text-green-400",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Active"]}):((n=e.loadError)==null?void 0:n.includes("Cannot find module"))||((r=e.loadError)==null?void 0:r.includes("MODULE_NOT_FOUND"))||((a=e.loadError)==null?void 0:a.includes("ERR_MODULE_NOT_FOUND"))?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-white/4 border-white/10 text-gray-500",children:[s.jsx(O3,{size:9,className:"shrink-0"}),"Missing Deps"]}):e.loadError?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-amber-500/8 border-amber-500/20 text-amber-500",children:[s.jsx(Ke,{size:9,className:"shrink-0"}),"Error"]}):s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-white/4 border-white/10 text-gray-500",children:[s.jsx(Lt,{size:9,className:"shrink-0"}),"Deferred"]})}function V_({ext:e}){var a;const t=((a=e.channel)==null?void 0:a.label)??e.id,n=e.active?"text-orange-400":"text-white/30",r=e.active?"border-orange-500/20 hover:border-orange-500/35":"border-white/6 hover:border-white/10";return s.jsxs("div",{className:`group relative flex flex-col gap-3 p-4 rounded-2xl bg-white/[0.025] border transition-all ${r}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.active?"bg-orange-500/12 border border-orange-500/20":"bg-white/4 border border-white/8"}`,children:s.jsx("span",{className:n,children:s.jsx(F_,{id:e.id,size:16})})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[13px] font-semibold text-white/85 truncate leading-tight",children:t}),s.jsxs("p",{className:"text-[10px] text-gray-600 mt-0.5 font-mono",children:["v",e.version]})]})]}),s.jsx($_,{ext:e})]}),e.description&&s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-2",children:e.description}),!e.active&&e.loadError&&!e.loadError.includes("Cannot find module")&&s.jsx("p",{className:"text-[10px] text-amber-600/80 font-mono truncate border-t border-white/5 pt-2",children:e.loadError.slice(0,80)})]})}function R0({title:e,items:t}){if(t.length===0)return null;const n=t.filter(r=>r.active).length;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-[11px] font-bold text-white/40 uppercase tracking-widest",children:e}),s.jsxs("span",{className:"text-[10px] text-gray-600",children:[t.length," total"]}),n>0&&s.jsxs("span",{className:"text-[10px] text-green-500 font-semibold",children:[n," active"]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(r=>s.jsx(V_,{ext:r},r.id))})]})}function U_(){return s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Array.from({length:9}).map((e,t)=>s.jsx("div",{className:"h-[100px] rounded-2xl bg-white/[0.025] border border-white/6 animate-pulse"},t))})}function H_(){const[e,t]=u.useState(null),[n,r]=u.useState(!0),[a,i]=u.useState(null),o=u.useCallback(async()=>{r(!0),i(null);try{const p=await U("/api/extensions");if(!p.ok)throw new Error(`HTTP ${p.status}`);t(await p.json())}catch(p){i(String(p))}finally{r(!1)}},[]);u.useEffect(()=>{o()},[o]);const l=(e==null?void 0:e.extensions.filter(p=>p.channel!==null).sort((p,f)=>{var m,b;return(((m=p.channel)==null?void 0:m.order)??99)-(((b=f.channel)==null?void 0:b.order)??99)}))??[],c=(e==null?void 0:e.extensions.filter(p=>p.channel===null))??[],d=(e==null?void 0:e.loaded)??0,h=(e==null?void 0:e.catalogSize)??0;return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(lp,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Channels & Extensions"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:["Phase B — ",h," extensions discovered"]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-white/[0.025] border border-white/8",children:[d>0?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:13,className:"text-green-400 shrink-0"}),s.jsxs("span",{className:"text-[11px] font-semibold text-green-400",children:[d," active"]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Lt,{size:13,className:"text-gray-500 shrink-0"}),s.jsx("span",{className:"text-[11px] font-semibold text-gray-500",children:"0 active"})]}),s.jsx("span",{className:"text-white/15",children:"·"}),s.jsxs("span",{className:"text-[11px] text-gray-600",children:[h-d," deferred"]})]}),s.jsxs("button",{onClick:o,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-gray-400 hover:text-white/80 hover:bg-white/6 hover:border-white/12 transition-all text-[11px] font-medium disabled:opacity-40",children:[s.jsx(ge,{size:12,className:n?"animate-spin":""}),"Refresh"]})]})]}),!n&&e&&d===0&&s.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl bg-amber-500/5 border border-amber-500/15",children:[s.jsx(Ke,{size:15,className:"text-amber-500 shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-amber-400",children:"Extensions deferred — dependencies not installed"}),s.jsxs("p",{className:"text-[11px] text-amber-600/80 mt-0.5",children:["Channel extensions require their SDK packages (e.g. ",s.jsx("code",{className:"font-mono",children:"must-b/plugin-sdk/*"}),") and memory-lancedb requires ",s.jsx("code",{className:"font-mono",children:"@lancedb/lancedb"}),". The ExtensionLoader catalog is ready — install dependencies to activate extensions at next boot."]})]})]}),n&&!e&&s.jsx(U_,{}),a&&s.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-xl bg-red-500/8 border border-red-500/15",children:[s.jsx(Ke,{size:15,className:"text-red-400 shrink-0"}),s.jsx("p",{className:"text-[12px] text-red-400",children:a})]}),e&&s.jsxs("div",{className:"space-y-8",children:[s.jsx(R0,{title:"Messaging Channels",items:l}),s.jsx(R0,{title:"System Plugins",items:c})]})]})}function is(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function L0(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gp(...e){return t=>{let n=!1;const r=e.map(a=>{const i=L0(a,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():L0(e[a],null)}}}}function Js(...e){return u.useCallback(gp(...e),e)}function W_(e,t){const n=u.createContext(t),r=i=>{const{children:o,...l}=i,c=u.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:o})};r.displayName=e+"Provider";function a(i){const o=u.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,a]}function K_(e,t=[]){let n=[];function r(i,o){const l=u.createContext(o),c=n.length;n=[...n,o];const d=p=>{var x;const{scope:f,children:m,...b}=p,y=((x=f==null?void 0:f[e])==null?void 0:x[c])||l,v=u.useMemo(()=>b,Object.values(b));return s.jsx(y.Provider,{value:v,children:m})};d.displayName=i+"Provider";function h(p,f){var y;const m=((y=f==null?void 0:f[e])==null?void 0:y[c])||l,b=u.useContext(m);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[d,h]}const a=()=>{const i=n.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[r,G_(a,...t)]}function G_(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(i)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var pi=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},q_=Eu[" useId ".trim().toString()]||(()=>{}),Y_=0;function Vc(e){const[t,n]=u.useState(q_());return pi(()=>{n(r=>r??String(Y_++))},[e]),e||(t?`radix-${t}`:"")}var X_=Eu[" useInsertionEffect ".trim().toString()]||pi;function Q_({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,i,o]=J_({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,r])}const d=u.useCallback(h=>{var p;if(l){const f=Z_(h)?h(e):h;f!==e&&((p=o.current)==null||p.call(o,f))}else i(h)},[l,e,i,o]);return[c,d]}function J_({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),a=u.useRef(n),i=u.useRef(t);return X_(()=>{i.current=t},[t]),u.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function Z_(e){return typeof e=="function"}function eT(e){const t=tT(e),n=u.forwardRef((r,a)=>{const{children:i,...o}=r,l=u.Children.toArray(i),c=l.find(sT);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return s.jsx(t,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function tT(e){const t=u.forwardRef((n,r)=>{const{children:a,...i}=n;if(u.isValidElement(a)){const o=aT(a),l=rT(i,a.props);return a.type!==u.Fragment&&(l.ref=r?gp(r,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var nT=Symbol("radix.slottable");function sT(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nT}function rT(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function aT(e){var r,a;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var iT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],On=iT.reduce((e,t)=>{const n=eT(`Primitive.${t}`),r=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function oT(e,t){e&&yh.flushSync(()=>e.dispatchEvent(t))}function fi(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e);u.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var cT="DismissableLayer",wu="dismissableLayer.update",dT="dismissableLayer.pointerDownOutside",uT="dismissableLayer.focusOutside",O0,Iv=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Dv=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=u.useContext(Iv),[h,p]=u.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=u.useState({}),b=Js(t,C=>p(C)),y=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(v),g=h?y.indexOf(h):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,j=g>=x,k=fT(C=>{const A=C.target,N=[...d.branches].some(_=>_.contains(A));!j||N||(a==null||a(C),o==null||o(C),C.defaultPrevented||l==null||l())},f),S=mT(C=>{const A=C.target;[...d.branches].some(_=>_.contains(A))||(i==null||i(C),o==null||o(C),C.defaultPrevented||l==null||l())},f);return lT(C=>{g===d.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},f),u.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(O0=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),I0(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=O0)}},[h,f,n,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),I0())},[h,d]),u.useEffect(()=>{const C=()=>m({});return document.addEventListener(wu,C),()=>document.removeEventListener(wu,C)},[]),s.jsx(On.div,{...c,ref:b,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:is(e.onFocusCapture,S.onFocusCapture),onBlurCapture:is(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:is(e.onPointerDownCapture,k.onPointerDownCapture)})});Dv.displayName=cT;var hT="DismissableLayerBranch",pT=u.forwardRef((e,t)=>{const n=u.useContext(Iv),r=u.useRef(null),a=Js(t,r);return u.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(On.div,{...e,ref:a})});pT.displayName=hT;function fT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e),r=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){Bv(dT,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e),r=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!r.current&&Bv(uT,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function I0(){const e=new CustomEvent(wu);document.dispatchEvent(e)}function Bv(e,t,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?oT(a,i):a.dispatchEvent(i)}var Uc="focusScope.autoFocusOnMount",Hc="focusScope.autoFocusOnUnmount",D0={bubbles:!1,cancelable:!0},xT="FocusScope",Fv=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=fi(a),h=fi(i),p=u.useRef(null),f=Js(t,y=>c(y)),m=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let y=function(w){if(m.paused||!l)return;const j=w.target;l.contains(j)?p.current=j:Vn(p.current,{select:!0})},v=function(w){if(m.paused||!l)return;const j=w.relatedTarget;j!==null&&(l.contains(j)||Vn(p.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Vn(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",v);const g=new MutationObserver(x);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",v),g.disconnect()}}},[r,l,m.paused]),u.useEffect(()=>{if(l){F0.add(m);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(Uc,D0);l.addEventListener(Uc,d),l.dispatchEvent(x),x.defaultPrevented||(gT(kT($v(l)),{select:!0}),document.activeElement===y&&Vn(l))}return()=>{l.removeEventListener(Uc,d),setTimeout(()=>{const x=new CustomEvent(Hc,D0);l.addEventListener(Hc,h),l.dispatchEvent(x),x.defaultPrevented||Vn(y??document.body,{select:!0}),l.removeEventListener(Hc,h),F0.remove(m)},0)}}},[l,d,h,m]);const b=u.useCallback(y=>{if(!n&&!r||m.paused)return;const v=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,x=document.activeElement;if(v&&x){const g=y.currentTarget,[w,j]=yT(g);w&&j?!y.shiftKey&&x===j?(y.preventDefault(),n&&Vn(w,{select:!0})):y.shiftKey&&x===w&&(y.preventDefault(),n&&Vn(j,{select:!0})):x===g&&y.preventDefault()}},[n,r,m.paused]);return s.jsx(On.div,{tabIndex:-1,...o,ref:f,onKeyDown:b})});Fv.displayName=xT;function gT(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Vn(r,{select:t}),document.activeElement!==n)return}function yT(e){const t=$v(e),n=B0(t,e),r=B0(t.reverse(),e);return[n,r]}function $v(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function B0(e,t){for(const n of e)if(!vT(n,{upTo:t}))return n}function vT(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bT(e){return e instanceof HTMLInputElement&&"select"in e}function Vn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bT(e)&&t&&e.select()}}var F0=wT();function wT(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=$0(e,t),e.unshift(t)},remove(t){var n;e=$0(e,t),(n=e[0])==null||n.resume()}}}function $0(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function kT(e){return e.filter(t=>t.tagName!=="A")}var jT="Portal",Vv=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[a,i]=u.useState(!1);pi(()=>i(!0),[]);const o=n||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?py.createPortal(s.jsx(On.div,{...r,ref:t}),o):null});Vv.displayName=jT;function NT(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var Hl=e=>{const{present:t,children:n}=e,r=ST(t),a=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),i=Js(r.ref,CT(a));return typeof n=="function"||r.isPresent?u.cloneElement(a,{ref:i}):null};Hl.displayName="Presence";function ST(e){const[t,n]=u.useState(),r=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=NT(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=ro(r.current);i.current=l==="mounted"?d:"none"},[l]),pi(()=>{const d=r.current,h=a.current;if(h!==e){const f=i.current,m=ro(d);e?c("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(h&&f!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),pi(()=>{if(t){let d;const h=t.ownerDocument.defaultView??window,p=m=>{const y=ro(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&y&&(c("ANIMATION_END"),!a.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},f=m=>{m.target===t&&(i.current=ro(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{h.clearTimeout(d),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function ro(e){return(e==null?void 0:e.animationName)||"none"}function CT(e){var r,a;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Wc=0;function ET(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??V0()),document.body.insertAdjacentElement("beforeend",e[1]??V0()),Wc++,()=>{Wc===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Wc--}},[])}function V0(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ln=function(){return ln=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},ln.apply(this,arguments)};function Uv(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function _T(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,i;r<a;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Ao="right-scroll-bar-position",Mo="width-before-scroll-bar",TT="with-scroll-bars-hidden",PT="--removed-body-scroll-bar-size";function Kc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function AT(e,t){var n=u.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var MT=typeof window<"u"?u.useLayoutEffect:u.useEffect,U0=new WeakMap;function zT(e,t){var n=AT(null,function(r){return e.forEach(function(a){return Kc(a,r)})});return MT(function(){var r=U0.get(n);if(r){var a=new Set(r),i=new Set(e),o=n.current;a.forEach(function(l){i.has(l)||Kc(l,null)}),i.forEach(function(l){a.has(l)||Kc(l,o)})}U0.set(n,e)},[e]),n}function RT(e){return e}function LT(e,t){t===void 0&&(t=RT);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var o=t(i,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(i),o=n}var c=function(){var h=o;o=[],h.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(h){o.push(h),d()},filter:function(h){return o=o.filter(h),n}}}};return a}function OT(e){e===void 0&&(e={});var t=LT(null);return t.options=ln({async:!0,ssr:!1},e),t}var Hv=function(e){var t=e.sideCar,n=Uv(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,ln({},n))};Hv.isSideCarExport=!0;function IT(e,t){return e.useMedium(t),Hv}var Wv=OT(),Gc=function(){},Wl=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:Gc,onWheelCapture:Gc,onTouchMoveCapture:Gc}),a=r[0],i=r[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,f=e.sideCar,m=e.noRelative,b=e.noIsolation,y=e.inert,v=e.allowPinchZoom,x=e.as,g=x===void 0?"div":x,w=e.gapMode,j=Uv(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=zT([n,t]),C=ln(ln({},j),a);return u.createElement(u.Fragment,null,h&&u.createElement(k,{sideCar:Wv,removeScrollBar:d,shards:p,noRelative:m,noIsolation:b,inert:y,setCallbacks:i,allowPinchZoom:!!v,lockRef:n,gapMode:w}),o?u.cloneElement(u.Children.only(l),ln(ln({},C),{ref:S})):u.createElement(g,ln({},C,{className:c,ref:S}),l))});Wl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Wl.classNames={fullWidth:Mo,zeroRight:Ao};var DT=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function BT(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DT();return t&&e.setAttribute("nonce",t),e}function FT(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $T(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var VT=function(){var e=0,t=null;return{add:function(n){e==0&&(t=BT())&&(FT(t,n),$T(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},UT=function(){var e=VT();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Kv=function(){var e=UT(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},HT={left:0,top:0,right:0,gap:0},qc=function(e){return parseInt(e||"",10)||0},WT=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[qc(n),qc(r),qc(a)]},KT=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return HT;var t=WT(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},GT=Kv(),Rr="data-scroll-locked",qT=function(e,t,n,r){var a=e.left,i=e.top,o=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
795
|
+
`}),s.jsx("div",{className:"max-w-full",dangerouslySetInnerHTML:{__html:f}})]})]})]})]})}const N_=[{id:"terminal",label:"Terminal",desc:"Kabuk komutları çalıştır",Icon:Mn,color:"text-green-400",bg:"bg-green-500/10",border:"border-green-500/20"},{id:"browser",label:"Browser",desc:"Playwright ile tam web otomasyonu",Icon:Ge,color:"text-blue-400",bg:"bg-blue-500/10",border:"border-blue-500/20"},{id:"web-search",label:"Web Search",desc:"Çoklu sağlayıcıyla gerçek zamanlı arama",Icon:fn,color:"text-cyan-400",bg:"bg-cyan-500/10",border:"border-cyan-500/20"},{id:"file-manager",label:"Files",desc:"Dosya oku, yaz ve yönet",Icon:Ln,color:"text-yellow-400",bg:"bg-yellow-500/10",border:"border-yellow-500/20"},{id:"image-gen",label:"Görsel Üret",desc:"AI ile görsel üret",Icon:fv,color:"text-pink-400",bg:"bg-pink-500/10",border:"border-pink-500/20"},{id:"code",label:"Kod Analizi",desc:"Kod yaz, analiz et ve hata ayıkla",Icon:en,color:"text-purple-400",bg:"bg-purple-500/10",border:"border-purple-500/20"},{id:"memory",label:"Bellek",desc:"Semantik hafıza arama & kayıt",Icon:Zt,color:"text-orange-400",bg:"bg-orange-500/10",border:"border-orange-500/20"},{id:"vision",label:"Görme",desc:"Ekran ve görsel algı",Icon:uu,color:"text-emerald-400",bg:"bg-emerald-500/10",border:"border-emerald-500/20"},{id:"screen-sense",label:"Ekranı Gör",desc:"Kullanıcı ekranını yakala ve analiz et",Icon:op,color:"text-indigo-400",bg:"bg-indigo-500/10",border:"border-indigo-500/20"},{id:"gateway",label:"Gateway",desc:"Sistem arası ve A2A iletişim",Icon:ul,color:"text-teal-400",bg:"bg-teal-500/10",border:"border-teal-500/20"},{id:"messages",label:"Mesajlar",desc:"Ajan-arası mesaj gönder & al",Icon:Hs,color:"text-rose-400",bg:"bg-rose-500/10",border:"border-rose-500/20"},{id:"git",label:"Git",desc:"Commit, branch, diff, push/pull",Icon:lv,color:"text-amber-400",bg:"bg-amber-500/10",border:"border-amber-500/20"}];function S_(){const[e,t]=u.useState("tools"),[n,r]=u.useState([]),[a,i]=u.useState([]),[o,l]=u.useState({}),[c,d]=u.useState(!1),[h,p]=u.useState(""),f=u.useCallback(async()=>{d(!0);try{const j=await U("/api/skills/list");if(j.ok){const k=await j.json();r(Array.isArray(k)?k:[])}}catch{}d(!1)},[]),m=u.useCallback(async()=>{d(!0);try{const j=await U("/api/skills/catalog");if(j.ok){const k=await j.json(),S=Array.isArray(k)?k:k.skills??[];i(S)}}catch{}d(!1)},[]);u.useEffect(()=>{e==="saved"&&f(),e==="catalog"&&m()},[e,f,m]);const b=async j=>{l(k=>({...k,[j.id]:"running"}));try{const k=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:j.id})});l(S=>({...S,[j.id]:k.ok?"done":"error"})),te[k.ok?"success":"error"](k.ok?`"${j.name}" çalıştırıldı`:"Çalıştırma başarısız"),setTimeout(()=>l(S=>({...S,[j.id]:"idle"})),2500)}catch{l(k=>({...k,[j.id]:"error"}))}},y=async j=>{try{await U(`/api/skills/${j}`,{method:"DELETE"}),r(k=>k.filter(S=>S.id!==j)),te.success("Beceri silindi.")}catch{te.error("Silinemedi.")}},v=async(j,k)=>{l(S=>({...S,[j]:"running"}));try{const S=await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:j,goal:`${k} becerisini çalıştır`})});l(C=>({...C,[j]:S.ok?"done":"error"})),S.ok&&te.success(`"${k}" yapay zekanın araç kutusuna eklendi ve aktif edildi`),setTimeout(()=>l(C=>({...C,[j]:"idle"})),2500)}catch{l(S=>({...S,[j]:"error"}))}},x=N_.filter(j=>j.label.toLowerCase().includes(h.toLowerCase())||j.desc.toLowerCase().includes(h.toLowerCase())),g=n.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.goal.toLowerCase().includes(h.toLowerCase())),w=a.filter(j=>j.name.toLowerCase().includes(h.toLowerCase())||j.description.toLowerCase().includes(h.toLowerCase())||(j.pluginName??"").toLowerCase().includes(h.toLowerCase()));return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsx("div",{className:"mb-6",children:s.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl flex items-center justify-center shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)"},children:s.jsx(Ue,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Beceriler & Araçlar"}),s.jsx("p",{className:"text-[12px] text-white/35 mt-0.5",children:"Must-b'nin bilişsel yetenekleri"})]})]})}),s.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(fn,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-white/25"}),s.jsx("input",{value:h,onChange:j=>p(j.target.value),placeholder:"Ara…",className:"w-full bg-white/5 border border-white/8 rounded-xl py-2 pl-8 pr-3 text-[13px] text-white/75 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20"})]}),s.jsx("div",{className:"flex rounded-xl overflow-hidden border border-white/8",children:[{key:"tools",label:"Dahili Araçlar"},{key:"saved",label:"Kaydedilen"},{key:"catalog",label:"Katalog"}].map(({key:j,label:k})=>s.jsx("button",{onClick:()=>t(j),className:`px-4 py-2 text-[12px] font-semibold transition-all ${e===j?"bg-orange-500/20 text-orange-300":"text-white/40 hover:text-white/70 hover:bg-white/5"}`,children:k},j))})]}),e==="tools"&&s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:x.map(({id:j,label:k,desc:S,Icon:C,color:A,bg:N,border:_})=>s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.18},className:`rounded-2xl p-4 flex gap-3 items-start border ${_}`,style:{background:"rgba(13,7,3,0.6)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${N} border ${_}`,children:s.jsx(C,{size:16,className:A})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight",children:k}),s.jsx("p",{className:"text-[11px] text-white/40 mt-0.5 leading-tight",children:S})]}),s.jsx("div",{className:"shrink-0 mt-1",children:s.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md bg-green-500/12 border border-green-500/20 text-green-400",children:"Aktif"})})]},j))}),e==="saved"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("p",{className:"text-[11px] text-white/30",children:[n.length," kaydedilmiş beceri"]}),s.jsx("button",{onClick:f,className:"p-1.5 text-white/30 hover:text-white/70 rounded-lg hover:bg-white/6 transition-all",children:s.jsx(ge,{size:13})})]}),c?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(ne,{size:20,className:"animate-spin text-orange-500/50"})}):g.length===0?s.jsx("div",{className:"text-center py-16 text-white/20 text-[13px]",children:h?"Eşleşen beceri bulunamadı.":"Henüz kaydedilmiş beceri yok."}):s.jsx("div",{className:"space-y-2",children:g.map(j=>{const k=o[j.id]??"idle";return s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 border border-orange-500/10",style:{background:"rgba(13,7,3,0.6)",backdropFilter:"blur(12px)"},children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0 mt-0.5",children:s.jsx(Dl,{size:14,className:"text-orange-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:j.name}),s.jsx("p",{className:"text-[11px] text-white/40 truncate mt-0.5",children:j.goal}),s.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-white/25",children:[s.jsx(rv,{size:9})," ",j.runCount," çalıştırma"]}),s.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-white/25",children:[s.jsx(Lt,{size:9})," ",new Date(j.savedAt).toLocaleDateString("tr-TR")]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx("button",{onClick:()=>b(j),disabled:k==="running",className:`w-8 h-8 rounded-xl flex items-center justify-center transition-all border ${k==="done"?"bg-green-500/15 border-green-500/25 text-green-400":k==="error"?"bg-red-500/15 border-red-500/25 text-red-400":k==="running"?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/5 border-white/10 text-white/50 hover:bg-orange-500/15 hover:border-orange-500/25 hover:text-orange-300"}`,children:k==="running"?s.jsx(ne,{size:13,className:"animate-spin"}):k==="done"?s.jsx(Fe,{size:13}):k==="error"?s.jsx(Ke,{size:13}):s.jsx(gs,{size:13})}),s.jsx("button",{onClick:()=>y(j.id),className:"w-8 h-8 rounded-xl flex items-center justify-center border border-white/8 text-white/25 hover:bg-red-500/12 hover:border-red-500/20 hover:text-red-400 transition-all",children:s.jsx(ys,{size:13})})]})]}),(j.tags??[]).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 mt-2 ml-11",children:(j.tags??[]).map(S=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/5 border border-white/8 text-white/35",children:S},S))})]},j.id)})})]}),e==="catalog"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("p",{className:"text-[11px] text-white/30",children:[a.length," beceri"]}),s.jsx("button",{onClick:m,className:"p-1.5 text-white/30 hover:text-white/70 rounded-lg hover:bg-white/6 transition-all",children:s.jsx(ge,{size:13})})]}),c?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(ne,{size:20,className:"animate-spin text-orange-500/50"})}):w.length===0?s.jsx("div",{className:"text-center py-16 text-white/20 text-[13px]",children:h?"Eşleşen beceri bulunamadı.":"Katalog boş."}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:w.map(j=>{var S;const k=o[j.id]??"idle";return s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 border border-white/8 flex gap-3",style:{background:"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:"text-[22px] shrink-0",children:j.emoji??"⚡"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90",children:j.name}),s.jsx("p",{className:"text-[11px] text-white/40 mt-0.5 leading-tight line-clamp-2",children:j.description}),j.pluginName&&s.jsx("p",{className:"text-[10px] text-white/20 mt-1",children:j.pluginName}),(((S=j.requires)==null?void 0:S.bins)??[]).length>0&&s.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:(j.requires.bins??[]).map(C=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-orange-500/8 border border-orange-500/15 text-orange-400/70",children:C},C))})]}),s.jsx("button",{onClick:()=>v(j.id,j.name),disabled:k==="running",className:`w-8 h-8 rounded-xl flex items-center justify-center shrink-0 transition-all border mt-0.5 ${k==="done"?"bg-green-500/15 border-green-500/25 text-green-400":k==="error"?"bg-red-500/15 border-red-500/25 text-red-400":k==="running"?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/5 border-white/10 text-white/50 hover:bg-orange-500/15 hover:border-orange-500/25 hover:text-orange-300"}`,children:k==="running"?s.jsx(ne,{size:13,className:"animate-spin"}):k==="done"?s.jsx(Fe,{size:13}):k==="error"?s.jsx(Ke,{size:13}):s.jsx(tn,{size:13})})]},j.id)})})]})]})}const C_={node:en,python:wn,api:na,cli:Mn,web:Ge,database:Ni,cloud:iv,agent:Wr};function E_(e,t){const n=e.toLowerCase();return n.includes("api")||n.includes("webhook")?na:n.includes("db")||n.includes("database")||n.includes("sql")?Ni:n.includes("cloud")||n.includes("s3")||n.includes("gcs")?iv:n.includes("agent")||n.includes("bot")?Wr:n.includes("web")||n.includes("http")?Ge:C_[t]??Qs}function __(e){const t=new Map;for(const n of e){if(!n.pluginName)continue;const r=t.get(n.pluginName);r?r.skillCount+=1:t.set(n.pluginName,{name:n.pluginName,emoji:n.emoji??"🔧",skillCount:1})}return Array.from(t.values()).sort((n,r)=>n.name.localeCompare(r.name))}function T_(){const[e,t]=u.useState([]),[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(""),[f,m]=u.useState(""),[b,y]=u.useState("node"),[v,x]=u.useState(""),[g,w]=u.useState(!1),j=u.useCallback(async()=>{i(!0);try{const[N,_]=await Promise.all([U("/api/plugins/list"),U("/api/skills/catalog")]);if(N.ok){const L=await N.json();t(Array.isArray(L)?L:[])}if(_.ok){const L=await _.json(),B=Array.isArray(L)?L:L.skills??[];r(__(B))}}catch{}i(!1)},[]);u.useEffect(()=>{j()},[j]);const k=async N=>{l(N.name);try{const _=N.running?"/api/plugins/stop":"/api/plugins/run";(await U(_,{method:"POST",body:JSON.stringify({name:N.name})})).ok?(t(B=>(Array.isArray(B)?B:[]).map(M=>M.name===N.name?{...M,running:!M.running}:M)),te.success(N.running?`"${N.name}" durduruldu`:`"${N.name}" başlatıldı`)):te.error("İşlem başarısız.")}catch{te.error("Bağlantı hatası.")}l(null)},S=async N=>{if(N.preventDefault(),!(!h.trim()||!f.trim())){w(!0);try{const _=await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:h,goal:f,lang:b,context:v})});if(_.ok){const L=await _.json();te.success(`"${L.name??h}" eklentisi oluşturuldu!`),p(""),m(""),x(""),d(!1),j()}else{const L=await _.json().catch(()=>({}));te.error(L.error??"Oluşturma başarısız.")}}catch{te.error("Gateway bağlantı hatası.")}w(!1)}},C=Array.isArray(e)?e:[],A=C.filter(N=>N.running).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl flex items-center justify-center shrink-0",style:{background:"rgba(249,115,22,0.12)",border:"1px solid rgba(249,115,22,0.25)"},children:s.jsx(qr,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Eklentiler"}),s.jsxs("p",{className:"text-[12px] text-white/35 mt-0.5",children:[C.length," özel eklenti · ",A," çalışıyor"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:j,className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all",children:s.jsx(ge,{size:14})}),s.jsxs("button",{onClick:()=>d(N=>!N),className:`flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-[12px] font-semibold transition-all border ${c?"bg-orange-500/20 border-orange-500/30 text-orange-300":"bg-white/6 border-white/10 text-white/60 hover:bg-orange-500/12 hover:border-orange-500/20 hover:text-orange-300"}`,children:[c?s.jsx(ze,{size:13}):s.jsx(Fl,{size:13}),c?"Kapat":"Yeni Eklenti"]})]})]}),s.jsx(ae,{children:c&&s.jsx(V.div,{initial:{opacity:0,y:-10,height:0},animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-8,height:0},transition:{duration:.2},className:"overflow-hidden mb-5",children:s.jsxs("form",{onSubmit:S,className:"rounded-2xl p-5 border border-orange-500/20",style:{background:"rgba(13,7,3,0.7)",backdropFilter:"blur(16px)"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(Ue,{size:14,className:"text-orange-400"}),s.jsx("h3",{className:"text-[13px] font-bold text-white/90",children:"Yeni Eklenti Oluştur"})]}),s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Ad"}),s.jsx("input",{value:h,onChange:N=>p(N.target.value),placeholder:"my-plugin",required:!0,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Dil"}),s.jsx("div",{className:"flex rounded-xl overflow-hidden border border-white/8",children:["node","python"].map(N=>s.jsxs("button",{type:"button",onClick:()=>y(N),className:`flex-1 py-2 text-[12px] font-semibold transition-all flex items-center justify-center gap-1.5 ${b===N?"bg-orange-500/20 text-orange-300":"text-white/40 hover:text-white/70 hover:bg-white/5"}`,children:[N==="node"?s.jsx(en,{size:12}):s.jsx(wn,{size:12}),N==="node"?"Node.js":"Python"]},N))})]})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Hedef / Açıklama"}),s.jsx("textarea",{value:f,onChange:N=>m(N.target.value),placeholder:"Bu eklenti ne yapmalı?",required:!0,rows:2,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20 resize-none"})]}),s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"block text-[10px] font-bold text-white/35 uppercase tracking-wider mb-1",children:"Bağlam (isteğe bağlı)"}),s.jsx("textarea",{value:v,onChange:N=>x(N.target.value),placeholder:"API anahtarları, URL'ler, ek bağlam…",rows:2,className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-[13px] text-white/80 outline-none focus:border-orange-500/40 transition-colors placeholder-white/20 resize-none"})]}),s.jsxs("button",{type:"submit",disabled:g||!h.trim()||!f.trim(),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl bg-orange-600/20 border border-orange-500/30 text-orange-300 text-[13px] font-semibold hover:bg-orange-600/30 transition-all disabled:opacity-40",children:[g?s.jsx(ne,{size:13,className:"animate-spin"}):s.jsx(tn,{size:13}),g?"Oluşturuluyor…":"Oluştur"]})]})})}),n.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/25 mb-3",children:"Yüklü Beceri Paketleri"}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:n.map(N=>s.jsxs(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"rounded-2xl p-4 flex gap-3 items-center border border-white/8",style:{background:"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsx("div",{className:"text-[22px] shrink-0",children:N.emoji}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight truncate",children:N.name}),s.jsxs("p",{className:"text-[10px] text-white/30 mt-0.5",children:[N.skillCount," beceri"]})]}),s.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md bg-green-500/12 border border-green-500/20 text-green-400 shrink-0",children:"Yüklü"})]},N.name))})]}),a?s.jsx("div",{className:"flex justify-center py-20",children:s.jsx(ne,{size:22,className:"animate-spin text-orange-500/50"})}):C.length===0?s.jsxs("div",{className:"rounded-2xl border border-white/8 p-8 text-center",style:{background:"rgba(13,7,3,0.4)"},children:[s.jsx(qr,{size:28,className:"text-white/15 mx-auto mb-3"}),s.jsx("p",{className:"text-[13px] text-white/30 font-medium",children:"Henüz özel eklenti yok"}),s.jsx("p",{className:"text-[12px] text-white/20 mt-1",children:'Yukarıdaki "Yeni Eklenti" ile kendi konektörünü oluştur.'})]}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:C.map(N=>{const _=o===N.name,L=E_(N.name,N.lang),B=N.lang==="node"?en:wn;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:`rounded-2xl p-4 border transition-all ${N.running?"border-orange-500/25":"border-white/8 hover:border-white/14"}`,style:{background:N.running?"rgba(249,115,22,0.06)":"rgba(13,7,3,0.55)",backdropFilter:"blur(12px)"},children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${N.running?"bg-orange-500/15 border border-orange-500/25":"bg-white/6 border border-white/10"}`,children:s.jsx(L,{size:16,className:N.running?"text-orange-400":"text-white/50"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/90 leading-tight truncate max-w-[120px]",children:N.name}),s.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[s.jsx(B,{size:9,className:N.lang==="node"?"text-green-400/60":"text-blue-400/60"}),s.jsx("span",{className:`text-[9px] font-semibold ${N.lang==="node"?"text-green-400/60":"text-blue-400/60"}`,children:N.lang==="node"?"Node.js":"Python"})]})]})]}),s.jsx("span",{className:`text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md border ${N.running?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/5 border-white/10 text-white/30"}`,children:N.running?"Çalışıyor":"Durdu"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] text-white/25",children:new Date(N.createdAt).toLocaleDateString("tr-TR")}),s.jsxs("button",{onClick:()=>k(N),disabled:_,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all border ${N.running?"bg-red-500/12 border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-orange-500/12 border-orange-500/20 text-orange-400 hover:bg-orange-500/20"} disabled:opacity-40`,children:[_?s.jsx(ne,{size:11,className:"animate-spin"}):N.running?s.jsx($l,{size:11}):s.jsx(gs,{size:11}),N.running?"Durdur":"Başlat"]})]})]},N.name)})})]})}function P_(){return new URLSearchParams(window.location.search).get("token")??""}function A_(){const[e,t]=u.useState("connecting"),[n,r]=u.useState([]),[a,i]=u.useState([]),[o,l]=u.useState("idle"),[c,d]=u.useState(null),[h,p]=u.useState(""),f=u.useRef(null),m=u.useRef(null),b=u.useRef([]),y=P_();u.useEffect(()=>{if(!y){t("denied");return}const k=Ba(`${window.location.origin}/mobile`,{query:{token:y},transports:["websocket","polling"]});return f.current=k,k.on("connect",()=>t("connected")),k.on("disconnect",()=>t("disconnected")),k.on("authError",()=>{t("denied"),k.disconnect()}),k.on("agentUpdate",S=>{const{type:C}=S;if(C==="planStart"&&r([]),C==="stepStart"){const A=S.step;r(N=>[...N,{id:`${Date.now()}-${Math.random()}`,description:(A==null?void 0:A.description)??"Working…",status:"running"}])}C==="stepFinish"&&r(A=>{const N=[...A],_=N.findLastIndex(L=>L.status==="running");return _>=0&&(N[_]={...N[_],status:S.status==="error"?"error":"done"}),N}),C==="skillRunStart"&&S.skillId&&d(S.skillId),C==="planFinish"&&d(null)}),()=>{k.disconnect()}},[y]);const v=u.useCallback(async()=>{try{const k=await fetch("/api/skills/list",{headers:{Authorization:`Bearer ${y}`}});if(k.ok){const S=await k.json();i(S.skills??[])}}catch{}},[y]);u.useEffect(()=>{v()},[v]);const x=async()=>{try{const k=await navigator.mediaDevices.getUserMedia({audio:!0}),S=new MediaRecorder(k,{mimeType:"audio/webm"});b.current=[],S.ondataavailable=C=>{C.data.size>0&&b.current.push(C.data)},S.onstop=()=>{k.getTracks().forEach(C=>C.stop()),w()},S.start(),m.current=S,l("recording")}catch{l("idle")}},g=()=>{var k;(k=m.current)==null||k.stop(),l("sending")},w=async()=>{const k=new Blob(b.current,{type:"audio/webm"}),S=new FormData;S.append("audio",k,"voice.webm");try{const C=await fetch("/api/voice/transcribe",{method:"POST",headers:{Authorization:`Bearer ${y}`},body:S});if(C.ok){const{text:A}=await C.json();p(A),await fetch("/api/goal",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({goal:A})})}}catch{}l("idle")},j=async k=>{if(!c){d(k.id);try{await fetch("/api/skills/run",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({id:k.id})})}catch{d(null)}}};return!y||e==="denied"?s.jsxs("div",{className:"min-h-screen bg-[#02040a] flex flex-col items-center justify-center gap-4 text-center px-8",children:[s.jsx(Ke,{size:40,className:"text-red-400"}),s.jsx("p",{className:"text-white font-bold text-xl",children:"Access Denied"}),s.jsxs("p",{className:"text-gray-500 text-sm",children:["This link is invalid or has expired.",s.jsx("br",{}),"Generate a new QR code from your desktop."]})]}):s.jsxs("div",{className:"min-h-screen bg-[#02040a] text-white flex flex-col pb-8",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("img",{src:"/logo.png",alt:"Must-b",className:"w-8 h-8 object-contain"}),s.jsx("span",{className:"font-bold text-base",children:"Must-b"}),s.jsx("span",{className:"text-[10px] text-orange-400 font-medium bg-orange-400/10 border border-orange-400/20 px-2 py-0.5 rounded-full",children:"Companion"})]}),s.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:e==="connected"?s.jsxs(s.Fragment,{children:[s.jsx(Eo,{size:13,className:"text-green-400"}),s.jsx("span",{className:"text-green-400",children:"Connected"})]}):e==="connecting"?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:13,className:"animate-spin text-orange-400"}),s.jsx("span",{className:"text-orange-400",children:"Connecting…"})]}):s.jsxs(s.Fragment,{children:[s.jsx(vs,{size:13,className:"text-gray-600"}),s.jsx("span",{className:"text-gray-500",children:"Offline"})]})})]}),s.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-6 border-b border-white/5",children:[s.jsx("p",{className:"text-[11px] text-gray-500 font-medium uppercase tracking-widest mb-6",children:"Voice Command"}),s.jsxs(V.button,{onPointerDown:x,onPointerUp:g,onPointerLeave:o==="recording"?g:void 0,disabled:o==="sending"||e!=="connected",whileTap:{scale:.93},className:`relative w-28 h-28 rounded-full flex items-center justify-center transition-all select-none ${o==="recording"?"bg-red-500/20 border-2 border-red-500 shadow-[0_0_40px_rgba(239,68,68,0.4)]":o==="sending"?"bg-orange-500/10 border-2 border-orange-500/30":"bg-orange-500/10 border-2 border-orange-500/40 hover:bg-orange-500/20 active:scale-95"} disabled:opacity-40`,children:[o==="sending"?s.jsx(ne,{size:36,className:"text-orange-400 animate-spin"}):o==="recording"?s.jsx(hv,{size:36,className:"text-red-400"}):s.jsx(Gr,{size:36,className:"text-orange-400"}),o==="recording"&&s.jsx(V.span,{className:"absolute inset-0 rounded-full border-2 border-red-500",animate:{scale:[1,1.3,1],opacity:[.8,0,.8]},transition:{duration:1.4,repeat:1/0}})]}),s.jsx("p",{className:"text-[12px] text-gray-600 mt-4",children:o==="recording"?"Listening… release to send":"Hold to speak"}),h&&s.jsxs("p",{className:"text-[11px] text-orange-300 mt-3 text-center max-w-xs",children:['"',h,'"']})]}),s.jsxs("div",{className:"px-5 pt-6 pb-4 border-b border-white/5",children:[s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase tracking-widest mb-3",children:"Live Workflow"}),s.jsx(ae,{children:n.length===0?s.jsx("p",{className:"text-[12px] text-gray-700 text-center py-4",children:"No active workflow"}):s.jsx("div",{className:"space-y-2",children:n.slice(-6).map(k=>s.jsxs(V.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:`flex items-start gap-2.5 p-3 rounded-xl border text-[12px] ${k.status==="running"?"bg-orange-500/8 border-orange-500/20":k.status==="error"?"bg-red-500/8 border-red-500/15":"bg-white/3 border-white/5"}`,children:[k.status==="running"&&s.jsx(ne,{size:12,className:"animate-spin text-orange-400 mt-0.5 shrink-0"}),k.status==="done"&&s.jsx(Fe,{size:12,className:"text-green-400 mt-0.5 shrink-0"}),k.status==="error"&&s.jsx(Ke,{size:12,className:"text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{className:k.status==="running"?"text-orange-300":k.status==="error"?"text-red-300":"text-gray-400",children:k.description})]},k.id))})})]}),s.jsxs("div",{className:"px-5 pt-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-[10px] text-gray-500 font-bold uppercase tracking-widest",children:"My Skills"}),s.jsx("button",{onClick:v,className:"text-gray-600 hover:text-gray-400 transition-colors",children:s.jsx(ge,{size:12})})]}),a.length===0?s.jsx("p",{className:"text-[12px] text-gray-700 text-center py-6",children:"No skills saved yet"}):s.jsx("div",{className:"space-y-2.5",children:a.map(k=>{const S=c===k.id;return s.jsxs(V.div,{layout:!0,className:`flex items-center gap-3 p-3.5 rounded-2xl border transition-all ${S?"bg-orange-500/10 border-orange-500/25":"bg-[#0c0f18] border-white/6"}`,children:[s.jsx(Ue,{size:14,className:"text-orange-400 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"font-semibold text-[13px] text-white truncate",children:k.name}),s.jsxs("p",{className:"text-[10px] text-gray-600 mt-0.5",children:[k.runCount,"× run"]})]}),s.jsxs("button",{onClick:()=>j(k),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${S?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":"bg-orange-500/10 border border-orange-500/20 text-orange-400 hover:bg-orange-500/20 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:[S?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(gs,{size:11}),S?"Running":"Run"]})]},k.id)})})]})]})}function M_(){const[e,t]=u.useState([]),[n,r]=u.useState(!0),[a,i]=u.useState(null);return u.useEffect(()=>{U("/api/workspace/files").then(o=>o.ok?o.json():Promise.reject(`HTTP ${o.status}`)).then(o=>{const l=Array.isArray(o==null?void 0:o.files)?o.files:[];t(l.map(c=>({name:c.name,path:c.rel,size:c.size,modified:c.mtime})))}).catch(o=>i(String(o))).finally(()=>r(!1))},[]),s.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx(Ln,{size:20,className:"text-orange-400"}),s.jsx("h1",{className:"text-lg font-bold text-white",children:"Files"})]}),n&&s.jsxs("div",{className:"flex items-center gap-2 text-gray-400 text-sm",children:[s.jsx(ne,{size:14,className:"animate-spin"}),"Loading files…"]}),a&&s.jsxs("p",{className:"text-red-400 text-sm",children:["Failed to load files: ",a]}),!n&&!a&&e.length===0&&s.jsx("p",{className:"text-gray-500 text-sm",children:"No files found in workspace."}),!n&&e.length>0&&s.jsx("div",{className:"space-y-1",children:e.map(o=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-lg hover:bg-white/5 transition-colors",children:[s.jsx(nn,{size:14,className:"text-gray-400 shrink-0"}),s.jsx("span",{className:"text-[13px] text-gray-200 flex-1 truncate",children:o.name}),o.size!==void 0&&s.jsxs("span",{className:"text-[11px] text-gray-500",children:[(o.size/1024).toFixed(1)," KB"]})]},o.path))})]})}const z_=[{value:"all",label:"Tüm Veriler",icon:s.jsx(Ge,{size:13})},{value:"text",label:"Sadece Metin",icon:s.jsx(nn,{size:13})},{value:"links",label:"Sadece Linkler",icon:s.jsx(na,{size:13})},{value:"images",label:"Sadece Görseller",icon:s.jsx(sp,{size:13})}];function R_(e){return e==="text"?s.jsx(nn,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}):e==="link"?s.jsx(na,{size:13,className:"text-blue-400 shrink-0 mt-0.5"}):s.jsx(sp,{size:13,className:"text-purple-400 shrink-0 mt-0.5"})}function L_(e){return e==="text"?"Metin":e==="link"?"Link":"Görsel"}function O_(){const[e,t]=u.useState(""),[n,r]=u.useState("all"),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(new Set),[f,m]=u.useState(!1),[b,y]=u.useState(!1),[v,x]=u.useState(""),[g,w]=u.useState(""),[j,k]=u.useState(!1),[S,C]=u.useState(""),[A,N]=u.useState([]),[_,L]=u.useState(null),[B,M]=u.useState(!1),$=u.useRef(null);u.useEffect(()=>{U("/api/memory/save-path").then(F=>F.json()).then(F=>{F.ok&&F.path&&(x(F.path),w(F.path))}).catch(()=>{})},[]);const R=(c??[]).filter(F=>n==="all"?!0:F.type===(n==="links"?"link":n==="images"?"image":"text")),z=F=>{p(Q=>{const q=new Set(Q);return q.has(F)?q.delete(F):q.add(F),q})},P=()=>{h.size===R.length?p(new Set):p(new Set(R.map(F=>F.id)))},E=async()=>{const F=e.trim();if(F){i(!0),l(null),d(null),p(new Set),y(!1);try{const Q=await U("/api/browser/scrape",{method:"POST",body:JSON.stringify({url:F,mode:n})}),q=await Q.json();if(!Q.ok||!q.ok)l(q.error??`Sunucu hatası: ${Q.status}`);else{const X=q.items??[];d(X),p(new Set(X.map(le=>le.id)))}}catch{l("Ağ bağlantısı kurulamadı. Backend çalışıyor mu?")}finally{i(!1)}}},T=async()=>{const F=(c??[]).filter(Q=>h.has(Q.id));if(F.length!==0){m(!0);try{const Q=await U("/api/memory/import",{method:"POST",body:JSON.stringify({entries:F.map(q=>({type:q.type,content:q.content,source:e}))})});if(Q.ok){const q=await Q.json();q.savedTo&&x(q.savedTo.replace(/[\\/][^\\/]+$/,""))}y(!0)}catch{}finally{m(!1)}}},O=()=>{C(v),L(null),N([]),k(!0)},G=()=>{k(!1),C(v),N([]),L(null)},D=F=>{C(F),L(null),$.current&&clearTimeout($.current),$.current=setTimeout(async()=>{try{const Q=F.replace(/[/\\][^/\\]*$/,"")||F,X=await(await U(`/api/fs/list-dirs?path=${encodeURIComponent(Q)}`)).json();X.ok&&N((X.dirs??[]).filter(le=>le.toLowerCase().startsWith(F.toLowerCase())))}catch{}},250)},K=async()=>{if(!S.trim()){G();return}M(!0),L(null);try{const Q=await(await U("/api/memory/save-path",{method:"POST",body:JSON.stringify({path:S.trim()})})).json();Q.ok&&Q.path?(x(Q.path),w(Q.path),k(!1),N([])):(L(Q.error??"Geçersiz dizin. Önceki yol geri yüklendi."),x(g),C(g))}catch{L("Bağlantı hatası. Önceki yol korunuyor."),x(g),C(g)}finally{M(!1)}};return s.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-10",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"rgba(234,88,12,0.15)",border:"1px solid rgba(234,88,12,0.3)"},children:s.jsx(Ge,{size:18,className:"text-orange-400 animate-pulse"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[17px] font-bold text-white/90 leading-tight",children:"Tarayıcı Otomasyonu"}),s.jsx("p",{className:"text-[12px] text-white/40",children:"Web sayfalarını tara, analiz et ve verileri belleğine kaydet"})]})]}),s.jsxs("div",{className:"rounded-xl px-5 py-4 mb-5",style:{background:"rgba(249,115,22,0.05)",border:"1px solid rgba(249,115,22,0.15)"},children:[s.jsx("p",{className:"text-[13px] font-semibold text-white/80 mb-3 leading-snug",children:"Must-b Otonom Tarayıcı ile internetin gücünü belleğinize katın:"}),s.jsx("ol",{className:"space-y-1.5",children:["Hedef URL'yi girin.","Çıkarmak istediğiniz veri türünü seçin (Metin, Link veya Görsel).","Başlat butonuna basarak Must-b'nin siteyi analiz etmesini bekleyin.","Sonuçları inceleyin ve kalıcı hafızaya kaydetmek istediklerinizi seçin."].map((F,Q)=>s.jsxs("li",{className:"flex items-start gap-2.5 text-[13px] text-white/80 leading-relaxed",children:[s.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-black shrink-0 mt-0.5",style:{background:"rgba(249,115,22,0.25)",color:"#fb923c"},children:Q+1}),F]},Q))}),s.jsxs("p",{className:"mt-3 text-[11px] text-orange-400/70 flex items-start gap-1.5 leading-relaxed",children:[s.jsx("span",{className:"shrink-0 mt-0.5",children:"🔒"}),s.jsxs("span",{children:[s.jsx("strong",{className:"text-orange-400/90",children:"Güvenlik Notu:"})," ","Tüm işlemler yerel Playwright motorunda gerçekleşir, verileriniz üçüncü taraflara asla iletilmez."]})]})]}),s.jsxs("div",{className:"rounded-2xl p-5 mb-4",style:{background:"rgba(13,7,3,0.80)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px rgba(0,0,0,0.45)"},children:[s.jsx("label",{className:"block text-[11px] font-bold text-white/40 uppercase tracking-widest mb-2",children:"Hedef URL"}),s.jsxs("div",{className:"flex gap-2 mb-5",children:[s.jsx("input",{type:"url",value:e,onChange:F=>t(F.target.value),onKeyDown:F=>F.key==="Enter"&&!a&&E(),placeholder:"https://example.com",className:"flex-1 px-4 py-2.5 rounded-xl text-[13px] text-white/85 placeholder-white/20 outline-none transition-all",style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)"},onFocus:F=>F.currentTarget.style.borderColor="rgba(249,115,22,0.55)",onBlur:F=>F.currentTarget.style.borderColor="rgba(255,255,255,0.12)"}),s.jsxs("button",{onClick:E,disabled:a||!e.trim(),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-semibold transition-all disabled:opacity-40",style:{background:a||!e.trim()?"rgba(249,115,22,0.25)":"rgba(249,115,22,0.85)",color:"#fff",border:"1px solid rgba(249,115,22,0.4)"},children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Kr,{size:14}),a?"Taranıyor…":"Başlat"]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[11px] font-bold text-white/40 uppercase tracking-widest mb-2.5",children:"Çıkarma Modu"}),s.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:z_.map(F=>s.jsxs("button",{onClick:()=>r(F.value),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-[12px] font-medium transition-all",style:{background:n===F.value?"rgba(249,115,22,0.18)":"rgba(255,255,255,0.04)",border:n===F.value?"1px solid rgba(249,115,22,0.45)":"1px solid rgba(255,255,255,0.08)",color:n===F.value?"#fb923c":"rgba(255,255,255,0.45)"},children:[F.icon,F.label]},F.value))})]}),a&&s.jsxs("div",{className:"mt-5 flex items-center gap-3 px-4 py-3 rounded-xl",style:{background:"rgba(249,115,22,0.08)",border:"1px solid rgba(249,115,22,0.2)"},children:[s.jsx(ne,{size:15,className:"animate-spin text-orange-400 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-orange-300",children:"Sayfa taranıyor…"}),s.jsx("p",{className:"text-[11px] text-white/35 mt-0.5",children:"Playwright sayfayı açıyor ve içerik çıkarılıyor"})]})]}),o&&s.jsxs("div",{className:"mt-5 flex items-start gap-3 px-4 py-3 rounded-xl",style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)"},children:[s.jsx(Ke,{size:15,className:"text-red-400 shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-red-300",children:"Hata oluştu"}),s.jsx("p",{className:"text-[11px] text-red-400/70 mt-0.5",children:o})]})]})]}),c!==null&&R.length>0&&s.jsxs("div",{className:"rounded-2xl p-5",style:{background:"rgba(13,7,3,0.75)",border:"1px solid rgba(255,255,255,0.10)",backdropFilter:"blur(20px)",boxShadow:"0 8px 40px rgba(0,0,0,0.40)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[13px] font-bold text-white/85",children:"Çıkarılan Veriler"}),s.jsxs("p",{className:"text-[11px] text-white/35 mt-0.5",children:[R.length," öğe bulundu · ",h.size," seçili"]})]}),s.jsxs("button",{onClick:P,className:"text-[11px] font-medium text-orange-400/80 hover:text-orange-400 transition-colors flex items-center gap-1",children:[s.jsx(gn,{size:12}),h.size===R.length?"Seçimi Kaldır":"Tümünü Seç"]})]}),["text","link","image"].map(F=>{const Q=R.filter(q=>q.type===F);return Q.length===0?null:s.jsxs("div",{className:"mb-4 last:mb-0",children:[s.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/25 mb-1.5 px-1",children:[L_(F)," (",Q.length,")"]}),s.jsx("div",{className:"space-y-1",children:Q.map(q=>s.jsxs("label",{className:"flex items-start gap-3 px-3 py-2.5 rounded-lg cursor-pointer transition-all",style:{background:h.has(q.id)?"rgba(249,115,22,0.08)":"rgba(255,255,255,0.03)",border:h.has(q.id)?"1px solid rgba(249,115,22,0.22)":"1px solid rgba(255,255,255,0.06)"},children:[s.jsx("div",{className:"w-4 h-4 rounded flex items-center justify-center shrink-0 mt-0.5 transition-all",style:{background:h.has(q.id)?"rgba(249,115,22,0.8)":"rgba(255,255,255,0.08)",border:h.has(q.id)?"1px solid rgba(249,115,22,0.9)":"1px solid rgba(255,255,255,0.18)"},onClick:()=>z(q.id),children:h.has(q.id)&&s.jsx(it,{size:10,className:"text-white"})}),R_(q.type),s.jsx("span",{className:"text-[12px] text-white/65 leading-relaxed break-all",children:q.content})]},q.id))})]},F)}),s.jsxs("div",{className:"mt-5 pt-4 border-t border-white/8",children:[b?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-2.5 rounded-xl text-[13px] font-semibold",style:{background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.25)",color:"#4ade80"},children:[s.jsx(it,{size:14}),h.size," öğe belleğe kaydedildi"]}):s.jsx("button",{onClick:T,disabled:f||h.size===0,className:"w-full flex items-center justify-center gap-2 py-2.5 rounded-xl text-[13px] font-semibold transition-all disabled:opacity-40",style:{background:"rgba(249,115,22,0.18)",border:"1px solid rgba(249,115,22,0.35)",color:"#fb923c"},children:f?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:14,className:"animate-spin"})," Kaydediliyor…"]}):s.jsxs(s.Fragment,{children:[s.jsx(sv,{size:14})," Seçilenleri Belleğe Kaydet (",h.size,")"]})}),v&&s.jsxs("div",{className:"mt-3 rounded-xl px-4 py-3",style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.09)"},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx(Ln,{size:12,className:"text-white/35 shrink-0"}),s.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30",children:"Kaydedilen Konum"})]}),j?s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{autoFocus:!0,value:S,onChange:F=>D(F.target.value),onKeyDown:F=>{F.key==="Enter"&&K(),F.key==="Escape"&&G()},placeholder:"Dizin yolu girin…",className:"flex-1 px-3 py-1.5 rounded-lg text-[12px] text-white/80 placeholder-white/20 outline-none",style:{background:"rgba(255,255,255,0.07)",border:"1px solid rgba(249,115,22,0.45)"}}),s.jsx("button",{onClick:K,disabled:B,className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold transition-all disabled:opacity-40",style:{background:"rgba(249,115,22,0.75)",color:"#fff"},children:B?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(it,{size:11})}),s.jsx("button",{onClick:G,className:"px-2.5 py-1.5 rounded-lg transition-all",style:{background:"rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.4)"},children:s.jsx(ze,{size:11})})]}),A.length>0&&s.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 rounded-xl overflow-hidden z-50",style:{background:"rgba(20,12,5,0.97)",border:"1px solid rgba(249,115,22,0.3)",boxShadow:"0 8px 24px rgba(0,0,0,0.6)"},children:A.map(F=>s.jsx("button",{onClick:()=>{C(F),N([])},className:"w-full text-left px-4 py-2 text-[11px] text-white/70 hover:bg-orange-500/10 hover:text-orange-300 transition-colors truncate",children:F},F))}),_&&s.jsxs("p",{className:"mt-1.5 text-[11px] text-red-400 flex items-center gap-1",children:[s.jsx(Ke,{size:10}),_]})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"flex-1 text-[12px] text-white/55 font-mono leading-relaxed break-all",children:v}),s.jsxs("button",{onClick:O,className:"shrink-0 flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-all hover:text-orange-400",style:{background:"rgba(249,115,22,0.1)",border:"1px solid rgba(249,115,22,0.2)",color:"rgba(251,146,60,0.7)"},children:[s.jsx(hu,{size:10}),"Düzenle"]})]})]})]})]}),c!==null&&R.length===0&&s.jsx("div",{className:"text-center py-10 text-[13px] text-white/25",children:"Bu modda çıkarılacak veri bulunamadı."})]})}function I_(e){return e.replace(/hey\s+must\s*-?\s*be\b/gi,"Hey Must-b").replace(/hey\s+mustbe\b/gi,"Hey Must-b").replace(/hey\s+most\s+be\b/gi,"Hey Must-b").replace(/hey\s+must\s+b\b/gi,"Hey Must-b").replace(/hey\s+must\s+bee\b/gi,"Hey Must-b").replace(/hay\s+mas+bi\b/gi,"Hey Must-b").replace(/hey\s+mas+bi\b/gi,"Hey Must-b").replace(/hey\s+mast\s*b[ei]?\b/gi,"Hey Must-b").replace(/hey\s+m[au]s[t]?\s*b[ei]?\b/gi,"Hey Must-b").replace(/hey\s+must\s*b[eiy]+\b/gi,"Hey Must-b").replace(/hey\s+moos+\s*b[ei]?\b/gi,"Hey Must-b")}function D_(e){const t=window.speechSynthesis.getVoices(),n=e.toLowerCase();return t.find(r=>r.name.toLowerCase().includes("google")&&r.lang.toLowerCase().startsWith(n))||t.find(r=>r.lang.toLowerCase().startsWith(n)&&!r.localService)||t.find(r=>r.lang.toLowerCase().startsWith(n))||null}function B_(){const e=gt(),{t,locale:n}=yt(),[r,a]=u.useState("wake-listening"),[i,o]=u.useState("Must-b"),[l,c]=u.useState(""),[d,h]=u.useState(""),p=u.useRef(null),f=u.useRef(!1),m=u.useRef(""),b=u.useRef(null),y=u.useRef("wake-listening");u.useEffect(()=>{y.current=r},[r]),u.useEffect(()=>{U("/api/identity").then(S=>S.json()).then(S=>{S.name&&o(S.name)}).catch(()=>{})},[]);const v=u.useCallback(S=>{if(!window.speechSynthesis)return;window.speechSynthesis.cancel();const C=new SpeechSynthesisUtterance(S),A=n==="tr"?"tr-TR":n==="de"?"de-DE":n==="fr"?"fr-FR":n==="es"?"es-ES":n==="ja"?"ja-JP":n==="zh"?"zh-CN":n==="pt"?"pt-PT":"en-US";C.lang=A,C.rate=1.05,C.pitch=1;const N=()=>{const _=D_(A.split("-")[0]);_&&(C.voice=_)};N(),!C.voice&&window.speechSynthesis.onvoiceschanged!==void 0&&(window.speechSynthesis.onvoiceschanged=N),C.onend=()=>{a("wake-listening"),h(""),c("")},C.onerror=()=>a("wake-listening"),a("speaking"),window.speechSynthesis.speak(C)},[n]),x=u.useCallback(async S=>{if(!S.trim()){a("wake-listening");return}a("thinking"),c(S);try{const A=await(await U("/api/goal",{method:"POST",body:JSON.stringify({goal:S,voice:!0})})).json(),N=A.result??A.reply??A.response??A.output??"Done.";h(N),v(N)}catch{a("wake-listening")}},[v]),g=u.useCallback(()=>{const S=window.SpeechRecognition||window.webkitSpeechRecognition;if(!S||!f.current)return;const C=new S;C.continuous=!0,C.interimResults=!0,C.lang=n==="tr"?"tr-TR":"en-US",C.onresult=A=>{var B,M;let N="";for(let $=A.resultIndex;$<A.results.length;$++)N+=A.results[$][0].transcript;const _=I_(N),L=y.current;if(c(_),L==="wake-listening"){const $=`hey ${i}`.toLowerCase();if(_.toLowerCase().includes($)){const R=((B=_.toLowerCase().split($)[1])==null?void 0:B.trim())??"";m.current=R,a("cmd-listening"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(m.current.trim()&&y.current==="cmd-listening"){const z=m.current;m.current="",x(z)}},1800)}}else if(L==="cmd-listening"){const $=`hey ${i}`.toLowerCase(),R=_.toLowerCase().includes($)?((M=_.toLowerCase().split($)[1])==null?void 0:M.trim())??_:_;m.current=R,b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(m.current.trim()&&y.current==="cmd-listening"){const z=m.current;m.current="",x(z)}},2200)}},C.onend=()=>{const A=y.current;f.current&&A!=="thinking"&&A!=="speaking"?setTimeout(g,200):f.current||(a("off"),p.current=null)},C.onerror=A=>{A.error!=="no-speech"&&a("wake-listening"),f.current&&A.error!=="not-allowed"&&setTimeout(g,600)},p.current=C;try{C.start()}catch{}},[i,n,x]),w=()=>{var S,C;r!=="off"?(f.current=!1,(S=p.current)==null||S.stop(),(C=window.speechSynthesis)==null||C.cancel(),b.current&&clearTimeout(b.current),a("off"),c("")):(f.current=!0,a("wake-listening"),g())};u.useEffect(()=>(f.current=!0,a("wake-listening"),g(),()=>{var S,C;f.current=!1,(S=p.current)==null||S.stop(),(C=window.speechSynthesis)==null||C.cancel(),b.current&&clearTimeout(b.current)}),[]);const j=r==="wake-listening"||r==="cmd-listening",k=r==="off";return s.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center overflow-hidden",style:{background:"radial-gradient(ellipse at 50% 45%, rgba(249,115,22,0.22) 0%, #060301 55%)"},children:[s.jsxs("button",{onClick:()=>e("/app"),className:"absolute top-20 left-6 flex items-center gap-2 px-3 py-2 rounded-xl text-white/40 hover:text-white/80 hover:bg-white/8 transition-all text-[13px] font-medium z-10",children:[s.jsx(d3,{size:15}),s.jsx("span",{children:t.voice.back})]}),s.jsx("p",{className:"absolute top-6 text-[12px] font-bold text-white/25 tracking-[0.18em] uppercase select-none",children:t.voice.title}),[200,290,380].map((S,C)=>s.jsx(V.div,{className:"absolute rounded-full",style:{width:S,height:S,border:`1px solid rgba(249,115,22,${.12-C*.03})`},animate:j?{opacity:[.4,.7,.4],scale:[1,1.04,1]}:{opacity:.2,scale:1},transition:{duration:2.2+C*.6,repeat:1/0,ease:"easeInOut",delay:C*.4}},S)),s.jsx(V.button,{onClick:w,className:"relative w-36 h-36 rounded-full flex items-center justify-center cursor-pointer select-none mb-10",style:{background:j?"radial-gradient(circle at 38% 32%, rgba(249,115,22,0.92), rgba(160,55,8,0.75))":"radial-gradient(circle at 38% 32%, rgba(249,115,22,0.38), rgba(22,10,3,0.88))",border:`1px solid rgba(249,115,22,${j?.5:.28})`,boxShadow:j?"0 0 70px rgba(249,115,22,0.55), 0 0 140px rgba(249,115,22,0.18), inset 0 1px 0 rgba(255,255,255,0.12)":"0 0 30px rgba(249,115,22,0.12), inset 0 1px 0 rgba(255,255,255,0.05)"},animate:j?{scale:[1,1.06,1]}:{scale:1},transition:{duration:1.6,repeat:j?1/0:0,ease:"easeInOut"},whileHover:{scale:1.04},whileTap:{scale:.95},children:r==="thinking"?s.jsx(V.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"w-10 h-10 rounded-full border-2 border-orange-500/30 border-t-orange-400"}):r==="speaking"?s.jsx(V.span,{animate:{scale:[.9,1.1,.9]},transition:{duration:.7,repeat:1/0,ease:"easeInOut"},className:"text-4xl",children:"🔊"}):r==="cmd-listening"?s.jsx(V.span,{animate:{opacity:[.6,1,.6]},transition:{duration:.5,repeat:1/0},children:s.jsx(Gr,{size:38,className:"text-white/95"})}):k?s.jsx(Gr,{size:38,className:"text-orange-300/90"}):s.jsx(hv,{size:38,className:"text-white/90"})}),s.jsx(ae,{mode:"wait",children:s.jsxs(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},className:"flex flex-col items-center gap-3 px-6 text-center",children:[r==="thinking"&&s.jsx("p",{className:"text-[17px] font-medium text-white/65",children:t.voice.thinking}),r==="speaking"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-orange-300",children:t.voice.speakingHint}),d&&s.jsxs("p",{className:"text-[12px] text-white/35 italic max-w-sm line-clamp-3",children:["“",d.slice(0,140),d.length>140?"…":"","”"]})]}),r==="cmd-listening"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-white/75",children:t.voice.cmdHint}),l&&s.jsxs("p",{className:"text-[13px] text-white/40 italic max-w-sm",children:["“",l,"”"]})]}),r==="wake-listening"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[17px] font-medium text-white/65",children:t.voice.wakeHint}),l&&s.jsxs("p",{className:"text-[13px] text-white/35 italic max-w-sm",children:["“",l,"”"]}),s.jsx("p",{className:"text-[11px] text-white/25",children:t.voice.stopHint})]}),r==="off"&&s.jsx("p",{className:"text-[17px] font-medium text-white/40",children:t.voice.tapHint}),j&&s.jsx("div",{className:"flex items-center gap-1 mt-1",children:[0,1,2,3,4].map(S=>s.jsx(V.div,{className:"w-0.5 rounded-full bg-orange-500/60",animate:{height:["6px","18px","6px"]},transition:{duration:.8,repeat:1/0,delay:S*.12,ease:"easeInOut"}},S))})]},r)})]})}function F_({id:e,size:t=16}){const n="shrink-0";switch(e){case"telegram":return s.jsx(cp,{size:t,className:n});case"whatsapp":return s.jsx(Co,{size:t,className:n});case"discord":return s.jsx(l0,{size:t,className:n});case"slack":return s.jsx(l0,{size:t,className:n});case"signal":return s.jsx(dp,{size:t,className:n});case"imessage":case"bluebubbles":return s.jsx(Hs,{size:t,className:n});case"line":return s.jsx(Hs,{size:t,className:n});case"msteams":return s.jsx(pu,{size:t,className:n});case"matrix":case"mattermost":case"irc":case"nextcloud-talk":return s.jsx(ul,{size:t,className:n});case"voice-call":case"talk-voice":case"phone-control":return s.jsx(F3,{size:t,className:n});case"twitch":return s.jsx(X3,{size:t,className:n});case"nostr":return s.jsx(lp,{size:t,className:n});case"googlechat":return s.jsx(Co,{size:t,className:n});case"feishu":return s.jsx(f3,{size:t,className:n});case"tlon":return s.jsx(Ge,{size:t,className:n});case"zalo":case"zalouser":return s.jsx(Co,{size:t,className:n});case"synology-chat":return s.jsx(ap,{size:t,className:n});case"lobster":return s.jsx(Gr,{size:t,className:n});case"memory-lancedb":case"memory-core":return s.jsx(Ni,{size:t,className:n});case"ollama":case"sglang":case"vllm":case"copilot-proxy":return s.jsx(tn,{size:t,className:n});case"open-prose":return s.jsx(Dl,{size:t,className:n});default:return s.jsx($3,{size:t,className:n})}}function $_({ext:e}){var n,r,a;return e.active?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-green-500/10 border-green-500/25 text-green-400",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Active"]}):((n=e.loadError)==null?void 0:n.includes("Cannot find module"))||((r=e.loadError)==null?void 0:r.includes("MODULE_NOT_FOUND"))||((a=e.loadError)==null?void 0:a.includes("ERR_MODULE_NOT_FOUND"))?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-white/4 border-white/10 text-gray-500",children:[s.jsx(O3,{size:9,className:"shrink-0"}),"Missing Deps"]}):e.loadError?s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-amber-500/8 border-amber-500/20 text-amber-500",children:[s.jsx(Ke,{size:9,className:"shrink-0"}),"Error"]}):s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border bg-white/4 border-white/10 text-gray-500",children:[s.jsx(Lt,{size:9,className:"shrink-0"}),"Deferred"]})}function V_({ext:e}){var a;const t=((a=e.channel)==null?void 0:a.label)??e.id,n=e.active?"text-orange-400":"text-white/30",r=e.active?"border-orange-500/20 hover:border-orange-500/35":"border-white/6 hover:border-white/10";return s.jsxs("div",{className:`group relative flex flex-col gap-3 p-4 rounded-2xl bg-white/[0.025] border transition-all ${r}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:`w-9 h-9 rounded-xl flex items-center justify-center shrink-0 ${e.active?"bg-orange-500/12 border border-orange-500/20":"bg-white/4 border border-white/8"}`,children:s.jsx("span",{className:n,children:s.jsx(F_,{id:e.id,size:16})})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-[13px] font-semibold text-white/85 truncate leading-tight",children:t}),s.jsxs("p",{className:"text-[10px] text-gray-600 mt-0.5 font-mono",children:["v",e.version]})]})]}),s.jsx($_,{ext:e})]}),e.description&&s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-2",children:e.description}),!e.active&&e.loadError&&!e.loadError.includes("Cannot find module")&&s.jsx("p",{className:"text-[10px] text-amber-600/80 font-mono truncate border-t border-white/5 pt-2",children:e.loadError.slice(0,80)})]})}function R0({title:e,items:t}){if(t.length===0)return null;const n=t.filter(r=>r.active).length;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-[11px] font-bold text-white/40 uppercase tracking-widest",children:e}),s.jsxs("span",{className:"text-[10px] text-gray-600",children:[t.length," total"]}),n>0&&s.jsxs("span",{className:"text-[10px] text-green-500 font-semibold",children:[n," active"]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:t.map(r=>s.jsx(V_,{ext:r},r.id))})]})}function U_(){return s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Array.from({length:9}).map((e,t)=>s.jsx("div",{className:"h-[100px] rounded-2xl bg-white/[0.025] border border-white/6 animate-pulse"},t))})}function H_(){const[e,t]=u.useState(null),[n,r]=u.useState(!0),[a,i]=u.useState(null),o=u.useCallback(async()=>{r(!0),i(null);try{const p=await U("/api/extensions");if(!p.ok)throw new Error(`HTTP ${p.status}`);t(await p.json())}catch(p){i(String(p))}finally{r(!1)}},[]);u.useEffect(()=>{o()},[o]);const l=(e==null?void 0:e.extensions.filter(p=>p.channel!==null).sort((p,f)=>{var m,b;return(((m=p.channel)==null?void 0:m.order)??99)-(((b=f.channel)==null?void 0:b.order)??99)}))??[],c=(e==null?void 0:e.extensions.filter(p=>p.channel===null))??[],d=(e==null?void 0:e.loaded)??0,h=(e==null?void 0:e.catalogSize)??0;return s.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-xl bg-orange-500/15 border border-orange-500/25 flex items-center justify-center",children:s.jsx(lp,{size:16,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-white",children:"Channels & Extensions"}),s.jsxs("p",{className:"text-[11px] text-gray-500",children:["Phase B — ",h," extensions discovered"]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-white/[0.025] border border-white/8",children:[d>0?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:13,className:"text-green-400 shrink-0"}),s.jsxs("span",{className:"text-[11px] font-semibold text-green-400",children:[d," active"]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Lt,{size:13,className:"text-gray-500 shrink-0"}),s.jsx("span",{className:"text-[11px] font-semibold text-gray-500",children:"0 active"})]}),s.jsx("span",{className:"text-white/15",children:"·"}),s.jsxs("span",{className:"text-[11px] text-gray-600",children:[h-d," deferred"]})]}),s.jsxs("button",{onClick:o,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-white/4 border border-white/8 text-gray-400 hover:text-white/80 hover:bg-white/6 hover:border-white/12 transition-all text-[11px] font-medium disabled:opacity-40",children:[s.jsx(ge,{size:12,className:n?"animate-spin":""}),"Refresh"]})]})]}),!n&&e&&d===0&&s.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl bg-amber-500/5 border border-amber-500/15",children:[s.jsx(Ke,{size:15,className:"text-amber-500 shrink-0 mt-0.5"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[12px] font-semibold text-amber-400",children:"Extensions deferred — dependencies not installed"}),s.jsxs("p",{className:"text-[11px] text-amber-600/80 mt-0.5",children:["Channel extensions require their SDK packages (e.g. ",s.jsx("code",{className:"font-mono",children:"must-b/plugin-sdk/*"}),") and memory-lancedb requires ",s.jsx("code",{className:"font-mono",children:"@lancedb/lancedb"}),". The ExtensionLoader catalog is ready — install dependencies to activate extensions at next boot."]})]})]}),n&&!e&&s.jsx(U_,{}),a&&s.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-xl bg-red-500/8 border border-red-500/15",children:[s.jsx(Ke,{size:15,className:"text-red-400 shrink-0"}),s.jsx("p",{className:"text-[12px] text-red-400",children:a})]}),e&&s.jsxs("div",{className:"space-y-8",children:[s.jsx(R0,{title:"Messaging Channels",items:l}),s.jsx(R0,{title:"System Plugins",items:c})]})]})}function is(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function L0(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gp(...e){return t=>{let n=!1;const r=e.map(a=>{const i=L0(a,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():L0(e[a],null)}}}}function Js(...e){return u.useCallback(gp(...e),e)}function W_(e,t){const n=u.createContext(t),r=i=>{const{children:o,...l}=i,c=u.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:o})};r.displayName=e+"Provider";function a(i){const o=u.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,a]}function K_(e,t=[]){let n=[];function r(i,o){const l=u.createContext(o),c=n.length;n=[...n,o];const d=p=>{var x;const{scope:f,children:m,...b}=p,y=((x=f==null?void 0:f[e])==null?void 0:x[c])||l,v=u.useMemo(()=>b,Object.values(b));return s.jsx(y.Provider,{value:v,children:m})};d.displayName=i+"Provider";function h(p,f){var y;const m=((y=f==null?void 0:f[e])==null?void 0:y[c])||l,b=u.useContext(m);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[d,h]}const a=()=>{const i=n.map(o=>u.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[r,G_(a,...t)]}function G_(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(i)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var pi=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},q_=Eu[" useId ".trim().toString()]||(()=>{}),Y_=0;function Vc(e){const[t,n]=u.useState(q_());return pi(()=>{n(r=>r??String(Y_++))},[e]),e||(t?`radix-${t}`:"")}var X_=Eu[" useInsertionEffect ".trim().toString()]||pi;function Q_({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,i,o]=J_({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,r])}const d=u.useCallback(h=>{var p;if(l){const f=Z_(h)?h(e):h;f!==e&&((p=o.current)==null||p.call(o,f))}else i(h)},[l,e,i,o]);return[c,d]}function J_({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),a=u.useRef(n),i=u.useRef(t);return X_(()=>{i.current=t},[t]),u.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function Z_(e){return typeof e=="function"}function eT(e){const t=tT(e),n=u.forwardRef((r,a)=>{const{children:i,...o}=r,l=u.Children.toArray(i),c=l.find(sT);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return s.jsx(t,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function tT(e){const t=u.forwardRef((n,r)=>{const{children:a,...i}=n;if(u.isValidElement(a)){const o=aT(a),l=rT(i,a.props);return a.type!==u.Fragment&&(l.ref=r?gp(r,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var nT=Symbol("radix.slottable");function sT(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nT}function rT(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function aT(e){var r,a;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var iT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],On=iT.reduce((e,t)=>{const n=eT(`Primitive.${t}`),r=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function oT(e,t){e&&yh.flushSync(()=>e.dispatchEvent(t))}function fi(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e);u.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var cT="DismissableLayer",wu="dismissableLayer.update",dT="dismissableLayer.pointerDownOutside",uT="dismissableLayer.focusOutside",O0,Iv=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Dv=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=u.useContext(Iv),[h,p]=u.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=u.useState({}),b=Js(t,C=>p(C)),y=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(v),g=h?y.indexOf(h):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,j=g>=x,k=fT(C=>{const A=C.target,N=[...d.branches].some(_=>_.contains(A));!j||N||(a==null||a(C),o==null||o(C),C.defaultPrevented||l==null||l())},f),S=mT(C=>{const A=C.target;[...d.branches].some(_=>_.contains(A))||(i==null||i(C),o==null||o(C),C.defaultPrevented||l==null||l())},f);return lT(C=>{g===d.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},f),u.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(O0=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),I0(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=O0)}},[h,f,n,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),I0())},[h,d]),u.useEffect(()=>{const C=()=>m({});return document.addEventListener(wu,C),()=>document.removeEventListener(wu,C)},[]),s.jsx(On.div,{...c,ref:b,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:is(e.onFocusCapture,S.onFocusCapture),onBlurCapture:is(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:is(e.onPointerDownCapture,k.onPointerDownCapture)})});Dv.displayName=cT;var hT="DismissableLayerBranch",pT=u.forwardRef((e,t)=>{const n=u.useContext(Iv),r=u.useRef(null),a=Js(t,r);return u.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(On.div,{...e,ref:a})});pT.displayName=hT;function fT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e),r=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){Bv(dT,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mT(e,t=globalThis==null?void 0:globalThis.document){const n=fi(e),r=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!r.current&&Bv(uT,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function I0(){const e=new CustomEvent(wu);document.dispatchEvent(e)}function Bv(e,t,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?oT(a,i):a.dispatchEvent(i)}var Uc="focusScope.autoFocusOnMount",Hc="focusScope.autoFocusOnUnmount",D0={bubbles:!1,cancelable:!0},xT="FocusScope",Fv=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=fi(a),h=fi(i),p=u.useRef(null),f=Js(t,y=>c(y)),m=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let y=function(w){if(m.paused||!l)return;const j=w.target;l.contains(j)?p.current=j:Vn(p.current,{select:!0})},v=function(w){if(m.paused||!l)return;const j=w.relatedTarget;j!==null&&(l.contains(j)||Vn(p.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Vn(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",v);const g=new MutationObserver(x);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",v),g.disconnect()}}},[r,l,m.paused]),u.useEffect(()=>{if(l){F0.add(m);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(Uc,D0);l.addEventListener(Uc,d),l.dispatchEvent(x),x.defaultPrevented||(gT(kT($v(l)),{select:!0}),document.activeElement===y&&Vn(l))}return()=>{l.removeEventListener(Uc,d),setTimeout(()=>{const x=new CustomEvent(Hc,D0);l.addEventListener(Hc,h),l.dispatchEvent(x),x.defaultPrevented||Vn(y??document.body,{select:!0}),l.removeEventListener(Hc,h),F0.remove(m)},0)}}},[l,d,h,m]);const b=u.useCallback(y=>{if(!n&&!r||m.paused)return;const v=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,x=document.activeElement;if(v&&x){const g=y.currentTarget,[w,j]=yT(g);w&&j?!y.shiftKey&&x===j?(y.preventDefault(),n&&Vn(w,{select:!0})):y.shiftKey&&x===w&&(y.preventDefault(),n&&Vn(j,{select:!0})):x===g&&y.preventDefault()}},[n,r,m.paused]);return s.jsx(On.div,{tabIndex:-1,...o,ref:f,onKeyDown:b})});Fv.displayName=xT;function gT(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Vn(r,{select:t}),document.activeElement!==n)return}function yT(e){const t=$v(e),n=B0(t,e),r=B0(t.reverse(),e);return[n,r]}function $v(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function B0(e,t){for(const n of e)if(!vT(n,{upTo:t}))return n}function vT(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bT(e){return e instanceof HTMLInputElement&&"select"in e}function Vn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bT(e)&&t&&e.select()}}var F0=wT();function wT(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=$0(e,t),e.unshift(t)},remove(t){var n;e=$0(e,t),(n=e[0])==null||n.resume()}}}function $0(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function kT(e){return e.filter(t=>t.tagName!=="A")}var jT="Portal",Vv=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[a,i]=u.useState(!1);pi(()=>i(!0),[]);const o=n||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?py.createPortal(s.jsx(On.div,{...r,ref:t}),o):null});Vv.displayName=jT;function NT(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var Hl=e=>{const{present:t,children:n}=e,r=ST(t),a=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),i=Js(r.ref,CT(a));return typeof n=="function"||r.isPresent?u.cloneElement(a,{ref:i}):null};Hl.displayName="Presence";function ST(e){const[t,n]=u.useState(),r=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=NT(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=ro(r.current);i.current=l==="mounted"?d:"none"},[l]),pi(()=>{const d=r.current,h=a.current;if(h!==e){const f=i.current,m=ro(d);e?c("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(h&&f!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),pi(()=>{if(t){let d;const h=t.ownerDocument.defaultView??window,p=m=>{const y=ro(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&y&&(c("ANIMATION_END"),!a.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},f=m=>{m.target===t&&(i.current=ro(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{h.clearTimeout(d),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function ro(e){return(e==null?void 0:e.animationName)||"none"}function CT(e){var r,a;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Wc=0;function ET(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??V0()),document.body.insertAdjacentElement("beforeend",e[1]??V0()),Wc++,()=>{Wc===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Wc--}},[])}function V0(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ln=function(){return ln=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},ln.apply(this,arguments)};function Uv(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function _T(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,i;r<a;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Ao="right-scroll-bar-position",Mo="width-before-scroll-bar",TT="with-scroll-bars-hidden",PT="--removed-body-scroll-bar-size";function Kc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function AT(e,t){var n=u.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var MT=typeof window<"u"?u.useLayoutEffect:u.useEffect,U0=new WeakMap;function zT(e,t){var n=AT(null,function(r){return e.forEach(function(a){return Kc(a,r)})});return MT(function(){var r=U0.get(n);if(r){var a=new Set(r),i=new Set(e),o=n.current;a.forEach(function(l){i.has(l)||Kc(l,null)}),i.forEach(function(l){a.has(l)||Kc(l,o)})}U0.set(n,e)},[e]),n}function RT(e){return e}function LT(e,t){t===void 0&&(t=RT);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var o=t(i,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(i),o=n}var c=function(){var h=o;o=[],h.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(h){o.push(h),d()},filter:function(h){return o=o.filter(h),n}}}};return a}function OT(e){e===void 0&&(e={});var t=LT(null);return t.options=ln({async:!0,ssr:!1},e),t}var Hv=function(e){var t=e.sideCar,n=Uv(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,ln({},n))};Hv.isSideCarExport=!0;function IT(e,t){return e.useMedium(t),Hv}var Wv=OT(),Gc=function(){},Wl=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:Gc,onWheelCapture:Gc,onTouchMoveCapture:Gc}),a=r[0],i=r[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,f=e.sideCar,m=e.noRelative,b=e.noIsolation,y=e.inert,v=e.allowPinchZoom,x=e.as,g=x===void 0?"div":x,w=e.gapMode,j=Uv(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=zT([n,t]),C=ln(ln({},j),a);return u.createElement(u.Fragment,null,h&&u.createElement(k,{sideCar:Wv,removeScrollBar:d,shards:p,noRelative:m,noIsolation:b,inert:y,setCallbacks:i,allowPinchZoom:!!v,lockRef:n,gapMode:w}),o?u.cloneElement(u.Children.only(l),ln(ln({},C),{ref:S})):u.createElement(g,ln({},C,{className:c,ref:S}),l))});Wl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Wl.classNames={fullWidth:Mo,zeroRight:Ao};var DT=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function BT(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DT();return t&&e.setAttribute("nonce",t),e}function FT(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $T(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var VT=function(){var e=0,t=null;return{add:function(n){e==0&&(t=BT())&&(FT(t,n),$T(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},UT=function(){var e=VT();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Kv=function(){var e=UT(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},HT={left:0,top:0,right:0,gap:0},qc=function(e){return parseInt(e||"",10)||0},WT=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[qc(n),qc(r),qc(a)]},KT=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return HT;var t=WT(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},GT=Kv(),Rr="data-scroll-locked",qT=function(e,t,n,r){var a=e.left,i=e.top,o=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
796
796
|
.`.concat(TT,` {
|
|
797
797
|
overflow: hidden `).concat(r,`;
|
|
798
798
|
padding-right: `).concat(l,"px ").concat(r,`;
|
|
@@ -836,7 +836,7 @@ Burada senin hakkında öğrendiğim bilgiler yer alır.
|
|
|
836
836
|
|
|
837
837
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
838
838
|
|
|
839
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},_P="DialogDescriptionWarning",TP=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hb(_P).contentName}}.`;return u.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},pb=Zv,fb=nb,mb=sb,xb=rb,gb=ib,yb=lb,pl=db;const q0=e=>{let t;const n=new Set,r=(d,h)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=h??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,f))}},a=()=>t,l={setState:r,getState:a,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,a,l);return l},PP=e=>e?q0(e):q0,AP=e=>e;function MP(e,t=AP){const n=Y.useSyncExternalStore(e.subscribe,Y.useCallback(()=>t(e.getState()),[e,t]),Y.useCallback(()=>t(e.getInitialState()),[e,t]));return Y.useDebugValue(n),n}const Y0=e=>{const t=PP(e),n=r=>MP(t,r);return Object.assign(n,t),n},zP=e=>e?Y0(e):Y0,_i=zP(e=>{let t=!1,n=null,r=null,a=!1,i=null,o=[];try{t=localStorage.getItem("mustb_trader_installed")==="true",n=localStorage.getItem("mustb_trader_template");const l=localStorage.getItem("mustb_trader_accounts");if(l&&(o=JSON.parse(l)),r=localStorage.getItem("mustb_trader_exchange"),a=localStorage.getItem("mustb_trader_testnet")==="true",i=localStorage.getItem("mustb_trader_account_type"),o.length===0&&r)o=[{id:r.toLowerCase().trim(),name:r,type:i||"crypto",isTestnet:a}],localStorage.setItem("mustb_trader_accounts",JSON.stringify(o));else if(o.length>0&&!r){const c=o[0];r=c.name,i=c.type,a=c.isTestnet,localStorage.setItem("mustb_trader_exchange",c.name),localStorage.setItem("mustb_trader_account_type",c.type),localStorage.setItem("mustb_trader_testnet",String(c.isTestnet))}}catch{}return{isTradingPackageInstalled:t,selectedTemplate:n,accounts:o,connectedExchange:r,isTestnet:a,accountType:i,setTradingPackageInstalled:l=>{e({isTradingPackageInstalled:l});try{localStorage.setItem("mustb_trader_installed",String(l))}catch{}},setSelectedTemplate:l=>{e({selectedTemplate:l});try{l?localStorage.setItem("mustb_trader_template",l):localStorage.removeItem("mustb_trader_template")}catch{}},setConnectedExchange:l=>{e({connectedExchange:l});try{l?localStorage.setItem("mustb_trader_exchange",l):localStorage.removeItem("mustb_trader_exchange")}catch{}},setTestnet:l=>{e({isTestnet:l});try{localStorage.setItem("mustb_trader_testnet",String(l))}catch{}},setAccountType:l=>{e({accountType:l});try{l?localStorage.setItem("mustb_trader_account_type",l):localStorage.removeItem("mustb_trader_account_type")}catch{}},addAccount:l=>{e(c=>{const h=c.accounts.some(f=>f.id===l.id)?c.accounts.map(f=>f.id===l.id?l:f):[...c.accounts,l];try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(h))}catch{}const p=h[0];if(p){try{localStorage.setItem("mustb_trader_exchange",p.name),localStorage.setItem("mustb_trader_account_type",p.type),localStorage.setItem("mustb_trader_testnet",String(p.isTestnet))}catch{}return{accounts:h,connectedExchange:p.name,accountType:p.type,isTestnet:p.isTestnet}}return{accounts:h}})},removeAccount:l=>{e(c=>{const d=c.accounts.filter(p=>p.id!==l);try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(d))}catch{}const h=d[0];if(h){try{localStorage.setItem("mustb_trader_exchange",h.name),localStorage.setItem("mustb_trader_account_type",h.type),localStorage.setItem("mustb_trader_testnet",String(h.isTestnet))}catch{}return{accounts:d,connectedExchange:h.name,accountType:h.type,isTestnet:h.isTestnet}}else{try{localStorage.removeItem("mustb_trader_exchange"),localStorage.removeItem("mustb_trader_account_type"),localStorage.removeItem("mustb_trader_testnet")}catch{}return{accounts:[],connectedExchange:null,accountType:null,isTestnet:!1}}})}}}),RP={Messaging:{icon:"💬",accent:"text-blue-300",border:"border-blue-500/20",bg:"bg-blue-500/10",iconBg:"bg-blue-500/10"},Finance:{icon:"📈",accent:"text-emerald-300",border:"border-emerald-500/20",bg:"bg-emerald-500/10",iconBg:"bg-emerald-500/10"},System:{icon:"⚙️",accent:"text-orange-300",border:"border-orange-500/20",bg:"bg-orange-500/10",iconBg:"bg-orange-500/10"}};function LP(e){return RP[e]??{icon:"🔌",accent:"text-white/60",border:"border-white/10",bg:"bg-white/5",iconBg:"bg-white/5"}}function OP({name:e}){return s.jsx("span",{className:"inline-block px-2 py-0.5 rounded-md text-[10px] font-mono bg-white/5 text-white/40 border border-white/8",children:e})}function IP({pack:e,installing:t,installLog:n,onInstall:r,onConfigure:a}){const[i,o]=u.useState(!1),l=LP(e.category),c=e.extensions.length===0;return s.jsxs("div",{className:"flex flex-col bg-white/5 border border-white/8 rounded-2xl p-5 gap-3 hover:bg-white/[0.07] hover:border-white/12 transition-all duration-200",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-xl ${l.iconBg} flex items-center justify-center text-[24px] shrink-0 select-none border ${l.border}`,children:l.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:e.name}),e.installed&&s.jsx(Ms,{size:14,className:"text-emerald-400 shrink-0"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l.accent}`,children:e.category}),!c&&s.jsxs("span",{className:"text-[10px] text-white/30",children:[e.extensions.length," extension",e.extensions.length!==1?"s":""]}),c&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-md bg-yellow-500/10 text-yellow-400 border border-yellow-500/20 font-medium",children:"Coming Soon"})]})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed",children:e.description}),s.jsx("p",{className:"text-[11px] font-mono text-white/25",children:e.npmPackage}),e.extensions.length>0&&s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>o(d=>!d),className:"flex items-center gap-1 text-[11px] text-white/30 hover:text-white/60 transition-colors mb-2",children:[i?s.jsx(Bl,{size:12}):s.jsx(Xs,{size:12}),i?"Hide":"Show"," included extensions"]}),i&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.extensions.map(d=>s.jsx(OP,{name:d},d))})]}),t&&n&&s.jsx("pre",{className:"text-[10px] text-white/40 bg-black/40 rounded-xl p-2.5 max-h-[72px] overflow-y-auto font-mono whitespace-pre-wrap break-all border border-white/6",children:n}),s.jsx("div",{className:"mt-auto pt-1",children:c?s.jsx("div",{className:"w-full py-2 rounded-xl text-[12px] font-medium text-center bg-white/4 text-white/25 border border-white/8 cursor-default select-none",children:"Not yet available"}):e.installed?s.jsx("button",{onClick:a,className:"w-full py-2 rounded-xl text-[12px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/15 hover:border-emerald-500/30 transition-colors",children:"Installed — Configure Keys"}):s.jsx("button",{onClick:r,disabled:t,className:`w-full flex items-center justify-center gap-2 py-2 rounded-xl text-[12px] font-semibold ${l.bg} ${l.accent} border ${l.border} hover:brightness-125 disabled:opacity-50 disabled:cursor-not-allowed transition-all`,children:t?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:13,className:"animate-spin shrink-0"}),s.jsx("span",{children:"Installing…"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qs,{size:13,className:"shrink-0"}),s.jsx("span",{children:"Install Pack"})]})})})]})}function DP({pack:e,onClose:t}){const[n,r]=u.useState({}),[a,i]=u.useState(!1);u.useEffect(()=>{e&&r({})},[e]);const o=async()=>{if(e){i(!0);try{if(!(await U("/api/store/configure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:n})})).ok)throw new Error("Configure request failed");te.success(`${e.name} configured — keys saved to .env`),t()}catch(c){te.error(c instanceof Error?c.message:"Configure failed")}finally{i(!1)}}},l={};for(const c of(e==null?void 0:e.requiredKeys)??[]){const d=c.forExtension??"general";(l[d]??(l[d]=[])).push(c)}return s.jsx(pb,{open:!!e,onOpenChange:c=>{c||t()},children:s.jsxs(fb,{children:[s.jsx(mb,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(xb,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs(gb,{className:"text-white/90 font-semibold text-[15px]",children:["Configure ",e==null?void 0:e.name]}),s.jsx(pl,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(ze,{size:15})})]}),s.jsxs(yb,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Fill in the keys for the extensions you want to use. Leave others blank — they can be added later. Keys are saved to your local"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:".env"})," file."]}),s.jsx("div",{className:"space-y-5",children:Object.entries(l).map(([c,d])=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30 mb-2.5",children:c}),s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:h.label}),h.hint&&s.jsx("p",{className:"text-[11px] text-white/35 mb-1.5",children:h.hint}),s.jsx("input",{type:"password",autoComplete:"off",value:n[h.env]??"",onChange:p=>r(f=>({...f,[h.env]:p.target.value})),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-orange-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:`Enter ${h.label}`})]},h.env))})]},c))}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:o,disabled:a,className:"flex-1 flex items-center justify-center gap-2 bg-orange-500/20 hover:bg-orange-500/30 border border-orange-500/30 hover:border-orange-500/50 disabled:opacity-60 text-orange-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Ms,{size:14}),"Save & Activate"]}),s.jsx(pl,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"Skip"})]})]})]})})}function BP({isOpen:e,onClose:t,onSuccess:n}){const[r,a]=u.useState(""),[i,o]=u.useState(!1);u.useEffect(()=>{e&&a("")},[e]);const l=async()=>{if(!r||r.trim().length<10){te.error("Lütfen geçerli bir Web3 cüzdan gizli anahtarı (Private Key) girin.");return}o(!0);try{const c=await U("/api/web3/vault",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({walletPrivateKey:r.trim()})}),d=await c.json();if(!c.ok||!d.ok)throw new Error(d.error||"Web3 cüzdan anahtarı kaydedilemedi.");te.success("Polymarket AI Oracle başarıyla kuruldu ve anahtarınız ~/.must-b/ klasöründe şifrelendi!"),n(),t()}catch(c){te.error(c instanceof Error?c.message:"Kurulum başarısız oldu.")}finally{o(!1)}};return s.jsx(pb,{open:e,onOpenChange:c=>{c||t()},children:s.jsxs(fb,{children:[s.jsx(mb,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(xb,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx(gb,{className:"text-white/90 font-semibold text-[15px]",children:"Polymarket AI Oracle Kurulumu"}),s.jsx(pl,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(ze,{size:15})})]}),s.jsxs(yb,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Polymarket tahmin piyasalarında otomatik işlem yapabilmek için Polygon uyumlu Web3 cüzdanınızın gizli anahtarını (Private Key) girmeniz gerekmektedir. Gizli anahtarınız, yerel diskte ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:"~/.must-b/"})," dizininde AES-256 ile son derece güvenli bir şekilde şifrelenir ve asla dışarı aktarılmaz."]}),s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:"Web3 Cüzdan Gizli Anahtarı (Private Key)"}),s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:c=>a(c.target.value),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-purple-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:"0x..."})]})}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:l,disabled:i,className:"flex-1 flex items-center justify-center gap-2 bg-purple-500/20 hover:bg-purple-500/30 border border-purple-500/30 hover:border-purple-500/50 disabled:opacity-60 text-purple-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[i?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Ms,{size:14}),"Kaydet ve Aktifleştir"]}),s.jsx(pl,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"İptal"})]})]})]})})}const FP=12e4;function $P(){const{isTradingPackageInstalled:e,setTradingPackageInstalled:t}=_i(),[n,r]=u.useState([]),[a,i]=u.useState(!0),[o,l]=u.useState(null),[c,d]=u.useState({}),[h,p]=u.useState(null),f=u.useRef(null),[m,b]=u.useState(!1),[y,v]=u.useState(!1),x=u.useCallback(async()=>{try{const k=await U("/api/web3/vault");if(k.ok){const S=await k.json();b(S.configured)}}catch{}},[]),g=u.useCallback(async()=>{i(!0);try{const k=await U("/api/store/extensions");k.ok&&r(await k.json())}catch{}finally{i(!1)}},[]);u.useEffect(()=>{g(),x()},[g,x]);const w=u.useCallback(async k=>{var A;(A=f.current)==null||A.abort();const S=new AbortController;f.current=S,l(k.id),d(N=>({...N,[k.id]:""}));const C=setTimeout(()=>{S.abort()},FP);try{const N=await U("/api/store/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:k.id}),signal:S.signal},{retries:1,retryDelay:0});if(!N.body)throw new Error("No response stream");const _=N.body.getReader(),L=new TextDecoder;let B="";for(;;){const{done:z,value:$}=await _.read();if(z)break;const R=L.decode($,{stream:!0});B+=R,d(M=>({...M,[k.id]:B}))}B.includes("__MUSTB_INSTALL_OK__")?(te.success(`${k.name} installed!`),r(z=>z.map($=>$.id===k.id?{...$,installed:!0}:$)),k.requiredKeys.length>0&&p(k)):B.includes("__MUSTB_INSTALL_FAILED__")?te.error(`${k.name} installation failed — check the log above.`):te.error(`${k.name} installation failed.`)}catch(N){N.name==="AbortError"?te.error(`Install timed out — is ${k.npmPackage} published to npm?`):te.error(N instanceof Error?N.message:"Install failed")}finally{clearTimeout(C),l(null)}},[]),j=n.filter(k=>k.installed).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0",children:s.jsx(xv,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Extension Store"}),j>0&&s.jsxs("span",{className:"text-[11px] text-emerald-400/80 font-medium",children:[j," pack",j!==1?"s":""," installed"]})]})]}),s.jsxs("p",{className:"text-white/40 text-[13px] leading-relaxed max-w-2xl mt-1",children:["Extensions are grouped into themed packs."," ","Install one pack to get all its integrations — fetched directly from npm into"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/5 px-1.5 py-0.5 rounded text-[11px] border border-white/8",children:"~/.must-b/extensions/"})]})]}),s.jsx("button",{onClick:g,title:"Refresh",className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all shrink-0",children:s.jsx(ge,{size:15})})]}),s.jsxs("div",{className:"mb-8 px-3 py-2.5 rounded-xl bg-white/5 border border-white/8 flex items-center gap-3",children:[s.jsx("code",{className:"text-[11px] font-mono text-white/30 shrink-0",children:"CLI:"}),s.jsxs("code",{className:"text-[12px] font-mono text-white/50",children:[s.jsx("span",{className:"text-orange-400",children:"must-b ext list"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install channels"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install system"})]})]}),a?s.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[s.jsx(ne,{size:22,className:"animate-spin text-orange-400"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"Loading extension store…"})]}):n.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[s.jsx(Qs,{size:28,className:"text-white/20"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"No packs available — backend may not be running."}),s.jsx("button",{onClick:g,className:"mt-1 px-4 py-2 rounded-xl bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[12px] font-medium hover:bg-orange-500/20 transition-colors",children:"Retry"})]}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#131d27]/70 to-[#0c0f18]/70 border border-emerald-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-emerald-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Premium Algorithmic Package"}),s.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Borsa & Otomasyon Paketi"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Binance, OKX ve Bitget borsaları ile doğrudan bütünleşik, gelişmiş RSI ve Grid trading bot arayüzünü içerir."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsx("p",{className:`text-xs font-bold ${e?"text-emerald-400":"text-gray-400"}`,children:e?"Kuruldu / Installed":"Kurulmadı / Available"})]}),s.jsx("button",{onClick:()=>{t(!0),te.success("Borsa & Botlar paketi başarıyla kuruldu!")},disabled:e,className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${e?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 cursor-default":"bg-emerald-600 text-white hover:bg-emerald-500 shadow-emerald-500/10"}`,children:e?"Kuruldu":"Paketi Kur"})]})]}),s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#1c1a2e]/70 to-[#0e0c18]/70 border border-purple-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-purple-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Web3 & Prediction Markets"}),s.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-purple-400 animate-pulse":"bg-purple-800"}`})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Polymarket AI Oracle"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Polymarket tahmin piyasalarında otomatik işlem yapmayı sağlayan, yapay zeka destekli oracle ve işlem modülü."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsx("p",{className:`text-xs font-bold ${m?"text-purple-400":"text-gray-400"}`,children:m?"Kuruldu / Configured":"Kurulmadı / Available"})]}),s.jsx("button",{onClick:()=>v(!0),className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${m?"bg-purple-500/10 text-purple-400 border border-purple-500/20 hover:bg-purple-500/20 cursor-pointer":"bg-purple-600 text-white hover:bg-purple-500 shadow-purple-500/10"}`,children:m?"Yapılandır":"Kur / Configure"})]})]}),n.map(k=>s.jsx(IP,{pack:k,installing:o===k.id,installLog:c[k.id]??"",onInstall:()=>w(k),onConfigure:()=>p(k)},k.id))]}),s.jsxs("p",{className:"text-center text-white/20 text-[11px] mt-12",children:["Packs are built with"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"npm run build:packs"})," ","and published to npm. Run"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"must-b ext list"})," ","for the CLI interface."]}),s.jsx(DP,{pack:h,onClose:()=>p(null)}),s.jsx(BP,{isOpen:y,onClose:()=>v(!1),onSuccess:x})]})}const VP=[{id:"grid-trading",name:"Grid Trading Bot",desc:"Grid strategy for sideways markets."},{id:"rsi-scalper",name:"RSI Scalper Dashboard",desc:"Fast scalping layout based on RSI crossovers."},{id:"arbitrage",name:"Cross-Exchange Arbitrage",desc:"Arbitrage monitoring dashboard."},{id:"dca-accumulator",name:"DCA Accumulator",desc:"Dollar-cost averaging dashboard."},{id:"portfolio-rebalance",name:"Portfolio Auto-Rebalancer",desc:"Dynamic asset weights management layout."}];function UP(){const e=gt(),{selectedTemplate:t,setSelectedTemplate:n}=_i(),r=(a,i)=>{n(a),te.success(`Şablon seçildi: ${i}`),e("/app/trader/connect")};return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"mb-10 text-center sm:text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center sm:justify-start mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(I3,{size:18,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Kontrol Paneli Şablonları"}),s.jsx("p",{className:"text-[11px] text-emerald-400/80 font-medium mt-1",children:"Lütfen bir işlem arayüzü şablonu seçin"})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed max-w-xl mt-2",children:"İşlem botlarınızın ve portföyünüzün performansını izlemek için optimize edilmiş minimal şablon yapıları."})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:VP.map(a=>s.jsxs("div",{className:`flex flex-col bg-white/3 border rounded-2xl p-4 gap-4 hover:bg-white/5 hover:border-white/20 transition-all duration-200 justify-between ${t===a.id?"border-emerald-500/50":"border-white/8"}`,children:[s.jsxs("div",{className:"space-y-2 bg-black/40 border border-white/6 rounded-xl p-3 h-[140px] flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-8 h-2.5 rounded bg-white/10"}),s.jsx("div",{className:"w-3 h-3 rounded-full bg-white/10"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 flex flex-col justify-center",children:[s.jsx("div",{className:"w-full h-4 rounded bg-white/5 border border-white/8"}),s.jsx("div",{className:"w-3/4 h-2.5 rounded bg-white/5"}),s.jsx("div",{className:"w-1/2 h-2 rounded bg-white/5"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-6 h-3 rounded bg-white/10"}),s.jsx("div",{className:"w-8 h-3 rounded bg-white/10"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-sm leading-snug mt-2",children:a.name}),s.jsx("p",{className:"text-white/35 text-[11px] leading-relaxed mt-1",children:a.desc})]}),s.jsx("button",{onClick:()=>r(a.id,a.name),className:`w-full flex items-center justify-center gap-1.5 py-2 mt-4 rounded-xl text-[11px] font-bold border transition-all ${t===a.id?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-white/5 text-white/60 border-white/10 hover:border-white/25"}`,children:t===a.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:12}),s.jsx("span",{children:"Seçildi"})]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{size:12}),s.jsx("span",{children:"Şablonu Kaydet"})]})})]})]},a.id))})]})}function HP(){const e=gt(),{setConnectedExchange:t,setTestnet:n,setAccountType:r,addAccount:a}=_i(),[i,o]=u.useState("crypto"),[l,c]=u.useState("binance"),[d,h]=u.useState(""),[p,f]=u.useState(""),[m,b]=u.useState(""),[y,v]=u.useState("FBS"),[x,g]=u.useState(""),[w,j]=u.useState("FBS-Real"),[k,S]=u.useState(""),[C,A]=u.useState(!1),[N,_]=u.useState(!1),L=async B=>{if(B.preventDefault(),i==="crypto"){if(!d.trim()||!p.trim()){te.error("API Anahtarı ve Secret alanları boş bırakılamaz.");return}if(l==="okx"&&!m.trim()){te.error("OKX bağlantısı için API parolası (Passphrase) gereklidir.");return}}else{if(!y.trim()||!x.trim()||!m.trim()||!w.trim()){te.error("Broker, Login, Şifre ve Sunucu alanları boş bırakılamaz.");return}if(!k.trim()){te.error("MetaApi Token alanı boş bırakılamaz. MetaApi Cloud hesabınızdan token alın.");return}}_(!0);const z=i==="crypto"?l.toUpperCase():y,$=te.loading(`${z} ${C?"(Testnet) ":""}bağlantısı doğrulanıyor...`);try{const R=i==="crypto"?{accountType:"crypto",exchangeId:l,apiKey:d.trim(),secret:p.trim(),password:m.trim()||void 0,isTestnet:C}:{accountType:"tradfi",broker:y.trim(),login:x.trim(),password:m.trim(),server:w.trim(),apiKey:k.trim(),isTestnet:C},M=await fetch("/api/trader/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),P=await M.json();if(!M.ok)throw new Error(P.error||"Bağlantı doğrulanamadı.");te.success(`${z} ${C?"(Testnet) ":""}başarıyla bağlandı!`,{id:$});const E=i==="crypto"?l==="binance"?"Binance":l==="okx"?"OKX":"Bitget":y;t(E),n(C),r(i);const T=i==="crypto"?l.toLowerCase():y.toLowerCase();a({id:T,name:E,type:i,isTestnet:C}),e("/app/trader/dashboard")}catch(R){te.error(R.message||"Bağlantı hatası oluştu.",{id:$})}finally{_(!1)}};return s.jsxs("div",{className:"min-h-[80vh] flex items-center justify-center px-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-emerald-500/10 rounded-full blur-[120px] pointer-events-none"}),s.jsx("div",{className:"absolute bottom-1/4 left-1/3 w-[300px] h-[300px] bg-amber-500/5 rounded-full blur-[100px] pointer-events-none"}),s.jsxs("div",{className:"w-full max-w-lg bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-3xl p-8 shadow-2xl backdrop-blur-md relative z-10",children:[s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shadow-lg shadow-emerald-500/5",children:s.jsx(dp,{size:26,className:"text-emerald-400"})})}),s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Güvenli İşlem Bağlantısı"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 max-w-xs mx-auto leading-relaxed",children:"API anahtarlarınızı veya aracı kurum bilgilerinizi kullanarak bağlantı kurun ve otomatik işlemleri başlatın."})]}),s.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-2xl p-4 mb-6 flex items-start gap-3",children:[s.jsx(Ws,{size:18,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h4",{className:"text-xs font-semibold text-amber-300",children:"Önemli Güvenlik Uyarısı"}),s.jsxs("p",{className:"text-[11px] text-amber-200/90 leading-relaxed",children:["API anahtarlarınızda veya kurum hesap yetkilerinizde ",s.jsx("strong",{children:"PARA ÇEKME (Withdraw)"})," yetkisinin KAPALI olduğundan emin olun. Verileriniz cihazınızda şifrelenerek saklanır, buluta gönderilmez."]})]})]}),s.jsxs("form",{onSubmit:L,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Hesap Tipi"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 bg-zinc-950/40 p-1 border border-zinc-800 rounded-xl",children:[s.jsx("button",{type:"button",onClick:()=>o("crypto"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="crypto"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Kripto Borsası"}),s.jsx("button",{type:"button",onClick:()=>o("tradfi"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="tradfi"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Aracı Kurum (TradFi)"})]})]}),s.jsxs("div",{className:"bg-zinc-950/40 border border-zinc-800 rounded-xl p-3.5 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-[12px] font-semibold text-white block",children:"Demo Modu (Testnet)"}),s.jsx("span",{className:"text-[10px] text-zinc-500 mt-0.5 block leading-tight",children:"Gerçek para riske atmadan, sanal bakiye ile stratejilerinizi test edin."})]}),s.jsx("button",{type:"button",onClick:()=>A(!C),disabled:N,className:`w-10 h-6 shrink-0 rounded-full p-1 transition-all duration-300 relative outline-none ${C?"bg-amber-500":"bg-zinc-800"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow-md transform transition-all duration-300 ${C?"translate-x-4":"translate-x-0"}`})})]}),i==="crypto"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Borsa Seçimi"}),s.jsxs("select",{value:l,onChange:B=>{c(B.target.value),b("")},disabled:N,className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl px-4 py-3 text-sm text-white font-medium outline-none transition-all disabled:opacity-50",children:[s.jsx("option",{value:"binance",children:"Binance"}),s.jsx("option",{value:"okx",children:"OKX"}),s.jsx("option",{value:"bitget",children:"Bitget"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Key (Erişim Anahtarı)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(rp,{size:16})}),s.jsx("input",{type:"text",value:d,onChange:B=>h(B.target.value),disabled:N,placeholder:"Örn: 4bc8f9a2e37...",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Secret (Gizli Anahtar)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(ap,{size:16})}),s.jsx("input",{type:"password",value:p,onChange:B=>f(B.target.value),disabled:N,placeholder:"••••••••••••••••••••••••••••••••",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Parolası / Passphrase"}),s.jsx("span",{className:"text-[9px] text-zinc-500 font-medium tracking-wide block uppercase",children:l==="okx"?"OKX için Zorunlu":"Opsiyonel"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(cv,{size:16})}),s.jsx("input",{type:"password",value:m,onChange:B=>b(B.target.value),disabled:N,placeholder:l==="okx"?"OKX API Parolası":"Gerekirse şifre / parola",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:l==="okx"})]})]})]}):s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-500/10 bg-gradient-to-br from-zinc-900/60 via-zinc-950/80 to-[#0c0f18]/90 backdrop-blur-xl p-6 flex flex-col items-center gap-4 my-2",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/5 via-transparent to-cyan-500/5 pointer-events-none"}),s.jsx("div",{className:"absolute -top-10 -right-10 w-32 h-32 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"absolute -bottom-10 -left-10 w-28 h-28 bg-cyan-500/8 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"relative z-10 w-14 h-14 rounded-2xl bg-gradient-to-br from-emerald-500/20 to-cyan-500/10 border border-emerald-500/20 flex items-center justify-center shadow-xl shadow-emerald-500/5 mt-2",children:s.jsx("svg",{className:"w-7 h-7 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.955 11.955 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.249-8.25-3.286Z"})})}),s.jsxs("div",{className:"relative z-10 flex items-center gap-1.5 bg-emerald-500/10 border border-emerald-500/20 rounded-full px-3 py-1",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-emerald-400 uppercase tracking-widest",children:"Çok Yakında"})]}),s.jsxs("div",{className:"relative z-10 text-center space-y-2 pb-2",children:[s.jsx("h3",{className:"text-sm font-bold text-white",children:"Yerel MetaTrader 4/5 Entegrasyonu"}),s.jsx("p",{className:"text-[11px] text-zinc-400 leading-relaxed max-w-[260px]",children:"Doğrudan aracı kurum bağlantısı ile MT4/MT5 hesaplarınızı Must-b yapay zeka motoruna bağlayın."})]}),s.jsx("ul",{className:"relative z-10 space-y-2 w-full text-[11px] text-zinc-500 pb-1",children:["FBS, IC Markets, Pepperstone desteği","Gerçek zamanlı Lot execution","Uyuyan Dev AI stratejisi entegrasyonu"].map(B=>s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-4 h-4 rounded-full border border-emerald-500/20 bg-emerald-500/5 flex items-center justify-center shrink-0",children:s.jsx("div",{className:"w-1 h-1 rounded-full bg-emerald-500/60"})}),B]},B))})]}),s.jsx("button",{type:"submit",disabled:N||i==="tradfi",className:`w-full flex items-center justify-center gap-2.5 py-3.5 px-6 mt-6 rounded-xl font-bold text-sm text-white transition-all relative overflow-hidden shadow-lg ${i==="tradfi"?"bg-zinc-800 opacity-50 cursor-not-allowed shadow-none":"bg-emerald-600 hover:bg-emerald-500 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed shadow-emerald-500/10"}`,children:N?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:16,className:"animate-spin text-white"}),s.jsx("span",{children:"Doğrulanıyor..."})]}):i==="tradfi"?s.jsx("span",{children:"Çok Yakında"}):s.jsx("span",{children:"Güvenli Bağlantı Kur"})})]}),s.jsx("p",{className:"text-[10px] text-zinc-600 mt-6 text-center leading-relaxed",children:"Must-b.os, API anahtarlarınızı tamamen yerel cihazınızda AES-256 algoritmasıyla şifreler."})]})]})}function WP(){const e=gt(),{accounts:t,removeAccount:n,connectedExchange:r,selectedTemplate:a}=_i(),[i,o]=u.useState(""),[l,c]=u.useState([{id:"rsi-scalper",name:"RSI Scalper AI",desc:"Fast scalping crossovers",active:!1},{id:"grid-trader",name:"Grid Trader AI",desc:"Sideways market grid",active:!1},{id:"macd-reversal",name:"MACD Reversal AI",desc:"Trend reversal detector",active:!1}]),[d,h]=u.useState(!0),[p,f]=u.useState(null),[m,b]=u.useState([]),[y,v]=u.useState({}),[x,g]=u.useState({"rsi-scalper":3e5,"grid-trader":3e5,"macd-reversal":3e5});u.useEffect(()=>{t&&t.length>0&&!i&&o(t[0].id)},[t,i]),u.useEffect(()=>{!r&&(!t||t.length===0)&&e("/app/trader/connect")},[r,t]);const w=async N=>{var L;const _=N||i||t&&((L=t[0])==null?void 0:L.id)||"";if(!_){h(!1);return}try{const B=`/api/trader/balance?exchangeId=${_}`,z=`/api/trader/history?exchangeId=${_}`,[$,R,M]=await Promise.all([fetch(B),fetch(z),fetch("/api/bot/status")]);if($.ok){const P=await $.json();f(P)}else f(null);if(R.ok){const P=await R.json();b(P.trades||[])}else b([]);if(M.ok){const P=await M.json();P.active&&(v(P.active),c(E=>E.map(T=>({...T,active:P.active[T.id]!==void 0}))),g(E=>{const T={...E};for(const O in P.active)T[O]=P.active[O];return T}))}}catch{te.error("Borsa verileri yüklenemedi.")}finally{h(!1)}};u.useEffect(()=>{i&&w(i)},[i]);const j=async(N,_,L)=>{const B=!L,z=x[N]||3e5,$=te.loading(B?`${_} başlatılıyor...`:`${_} durduruluyor...`);try{if(B){if(!(await fetch("/api/bot/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:N,pair:"BTC/USDT",intervalMs:z})})).ok)throw new Error("Bot başlatılamadı.");v(M=>({...M,[N]:z})),c(M=>M.map(P=>P.id===N?{...P,active:!0}:P)),te.success(`${_} başarıyla başlatıldı!`,{id:$})}else{if(!(await fetch("/api/bot/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:N})})).ok)throw new Error("Bot durdurulamadı.");v(M=>{const P={...M};return delete P[N],P}),c(M=>M.map(P=>P.id===N?{...P,active:!1}:P)),te.error(`${_} durduruldu.`,{id:$})}}catch(R){te.error(R.message||"İşlem başarısız.",{id:$})}},k=async(N,_)=>{if(window.confirm(`${_} bağlantısını kesmek ve hesabı kaldırmak istediğinize emin misiniz?`))try{const L=await fetch("/api/trader/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({exchangeId:N})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Bağlantı kesilemedi.")}n(N),te.success(`${_} başarıyla kaldırıldı.`);const B=t.filter(z=>z.id!==N);B.length>0?o(B[0].id):e("/app/trader/connect")}catch(L){te.error(L.message||"Bir hata oluştu.")}},S=N=>{const _=t.find(z=>z.id===i),L=_?_.name:r,B=L==="Binance"?"https://www.binance.com":L==="OKX"?"https://www.okx.com":"https://www.bitget.com";te.info("Yasal işlemler için ilgili borsaya yönlendiriliyorsunuz..."),setTimeout(()=>{window.open(B,"_blank")},800)};if(d)return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{className:"space-y-2 animate-pulse",children:[s.jsx("div",{className:"h-6 w-48 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-4 w-32 bg-white/5 rounded-lg"})]}),s.jsxs("div",{className:"flex items-center gap-2 animate-pulse",children:[s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 animate-pulse",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-32 bg-white/5 rounded-xl"})]})]})]});const C=t.find(N=>N.id===i),A=(C==null?void 0:C.type)==="tradfi";return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Trader Dashboard"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1 flex items-center gap-1.5",children:["Aktif Hesap: ",s.jsx("span",{className:"text-emerald-400 font-semibold",children:(p==null?void 0:p.exchange)||(C==null?void 0:C.name)||r||"Bağlı Değil"})," · ","Şablon: ",s.jsx("span",{className:"text-cyan-400 font-semibold",children:a||"Varsayılan"})]})]}),!A&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>S(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-500 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Yatır"}),s.jsx(Kr,{size:12})]}),s.jsxs("button",{onClick:()=>S(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-white/5 border border-white/8 hover:bg-white/8 hover:border-white/12 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Çek"}),s.jsx(Kr,{size:12})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px] relative overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Toplam Varlık / Total Balance"}),s.jsxs("div",{className:"flex items-center gap-2",children:[((p==null?void 0:p.isTestnet)||(C==null?void 0:C.isTestnet))&&s.jsx("span",{className:"px-2 py-0.5 rounded bg-amber-500/10 border border-amber-500/25 text-amber-400 font-bold uppercase tracking-wider text-[8px] animate-pulse",children:"DEMO ACTIVE"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-white/90 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.total.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Son güncelleme: Az önce"})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Kullanılabilir Bakiye / Free Balance"}),s.jsx(yv,{size:14,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-emerald-400 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.free.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsxs("p",{className:"text-[10px] text-emerald-500/80 font-semibold mt-1 flex items-center gap-0.5",children:[s.jsx(nv,{size:10})," Bloke / Used: ",p?p.used.toFixed(2):"0.00"," ",p==null?void 0:p.displayAsset]})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-5 flex flex-col justify-between h-[130px] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/5 pb-2 mb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Bağlı Hesaplar"}),s.jsx("button",{onClick:()=>e("/app/trader/connect"),className:"text-[10px] font-bold text-emerald-400 hover:text-emerald-300 hover:underline",children:"+ Yeni Ekle"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 pr-1 scrollbar-thin",children:[t&&t.map(N=>s.jsxs("div",{onClick:()=>o(N.id),className:`flex items-center justify-between p-1.5 rounded-lg border cursor-pointer transition-all ${i===N.id?"bg-emerald-500/10 border-emerald-500/30 text-white font-bold":"bg-white/3 border-white/5 text-zinc-400 hover:bg-white/5 hover:text-white"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i===N.id?"bg-emerald-400":"bg-zinc-600"}`}),s.jsxs("span",{className:"text-[11px] truncate",children:[N.name," ",N.isTestnet?"(Demo)":""]})]}),s.jsx("button",{onClick:_=>{_.stopPropagation(),k(N.id,N.name)},className:"text-[9px] font-semibold text-red-400 hover:text-red-300 hover:underline px-1 py-0.5 rounded hover:bg-red-500/10 transition-all shrink-0",children:"Kaldır"})]},N.id)),(!t||t.length===0)&&s.jsx("p",{className:"text-[10px] text-zinc-500 italic text-center py-2",children:"Bağlı hesap bulunamadı."})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(Wr,{size:16,className:"text-emerald-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"Aktif Robotlar / Bots"})]}),s.jsx("div",{className:"space-y-3",children:l.map(N=>s.jsxs("div",{className:`p-3.5 rounded-xl border flex flex-col gap-3 transition-all ${N.active?"bg-emerald-500/5 border-emerald-500/25":"bg-white/3 border-white/6"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[N.active&&s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse shrink-0"}),s.jsxs("div",{className:"truncate",children:[s.jsx("p",{className:"text-xs font-bold text-white/90",children:N.name}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5 truncate",children:N.desc})]})]}),s.jsx("button",{onClick:()=>j(N.id,N.name,N.active),className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 transition-all ${N.active?"bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20"}`,children:N.active?s.jsx($l,{size:10,fill:"currentColor"}):s.jsx(gs,{size:10,fill:"currentColor"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2.5 border-t border-white/5",children:[s.jsx("span",{className:"text-[9px] text-zinc-500 font-bold uppercase tracking-wider",children:"Periyot / Interval"}),s.jsxs("select",{value:x[N.id]||3e5,onChange:_=>{const L=parseInt(_.target.value);g(B=>({...B,[N.id]:L}))},disabled:N.active,className:"bg-zinc-950 border border-zinc-800 text-[10px] text-zinc-300 font-semibold rounded-lg px-2 py-1 focus:outline-none focus:border-emerald-500/40 cursor-pointer disabled:opacity-40",children:[s.jsx("option",{value:6e4,children:"1 Dakika"}),s.jsx("option",{value:3e5,children:"5 Dakika"}),s.jsx("option",{value:9e5,children:"15 Dakika"}),s.jsx("option",{value:36e5,children:"1 Saat"})]})]})]},N.id))})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(C3,{size:16,className:"text-cyan-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"İşlem Geçmişi / Trade History"})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs text-gray-400",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-white/5 text-gray-600 font-bold uppercase tracking-wider text-[10px]",children:[s.jsx("th",{className:"py-2.5",children:"Parite / Pair"}),s.jsx("th",{className:"py-2.5",children:"Yön / Side"}),s.jsx("th",{className:"py-2.5",children:"Tarih / Date"}),s.jsx("th",{className:"py-2.5 text-right",children:"Miktar / Amount"})]})}),s.jsx("tbody",{className:"divide-y divide-white/5 font-mono text-[11px]",children:m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"py-6 text-center text-zinc-600 italic",children:"İşlem geçmişi bulunamadı."})}):m.map(N=>{const _=String(N.side).toUpperCase()==="BUY",L=new Date(N.datetime).toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})+" "+new Date(N.datetime).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});return s.jsxs("tr",{className:"hover:bg-white/2 transition-colors",children:[s.jsx("td",{className:"py-3 font-semibold text-white/80",children:N.symbol}),s.jsx("td",{className:"py-3",children:s.jsx("span",{className:`px-1.5 py-0.5 rounded-md font-bold text-[9px] ${_?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:N.side.toUpperCase()})}),s.jsx("td",{className:"py-3 text-gray-500",children:L}),s.jsxs("td",{className:`py-3 text-right font-bold ${_?"text-emerald-400":"text-red-400"}`,children:[_?"+":"-",N.amount.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})]})]},N.id)})})]})})]})]})]})}function X0(e){return e>=90?"#ef4444":e>=70?"#f97316":"#22c55e"}function ma(e){return e==="critical"?"#ef4444":e==="warning"?"#f97316":"#60a5fa"}function KP(){const{t:e,locale:t}=yt(),n=e.systemHealth,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useCallback(()=>o(null),[]);u.useEffect(()=>{window.dispatchEvent(new CustomEvent("mustb:safeMode",{detail:{active:(r==null?void 0:r.safeMode)??!1}}))},[r==null?void 0:r.safeMode]),u.useEffect(()=>{const f=pe();return f.on("systemStats",m=>a(m)),f.on("systemHealth",m=>{if(o(m),c(!0),m.level!=="critical"){const b=m.level==="info"?6e3:12e3;setTimeout(()=>o(null),b)}}),()=>{f.off("systemStats"),f.off("systemHealth")}},[]);const h=(r==null?void 0:r.cpu)??0,p=(r==null?void 0:r.ram)??0;return s.jsxs("div",{className:"relative flex items-center",children:[s.jsxs("button",{onClick:()=>i&&c(f=>!f),className:"flex items-center gap-1.5 select-none transition-all rounded-md",style:{cursor:i?"pointer":"default"},title:i?i.message:n.title,children:[i?s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 animate-pulse",style:{background:ma(i.level)}}):s.jsx(tn,{size:12,className:"text-orange-400/70"}),r&&s.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"CPU"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${h}%`,background:X0(h)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[h,"%"]}),s.jsx("span",{className:"w-px h-3 bg-white/10"}),s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"RAM"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${p}%`,background:X0(p)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[p,"%"]}),r.liteMode&&!r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-orange-500/20 text-orange-400 ml-0.5",children:n.lite}),r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-red-500/20 text-red-400 ml-0.5",children:n.safe})]}),!r&&s.jsx("span",{className:"text-[10px] font-semibold hidden sm:inline text-white/35",children:n.title})]}),s.jsx(ae,{children:l&&i&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.2,ease:"easeOut"},className:"absolute top-full right-0 mt-2 w-72 z-[200] rounded-2xl overflow-hidden",style:{background:"rgba(20,8,2,0.88)",border:`1px solid ${ma(i.level)}44`,backdropFilter:"blur(20px)",boxShadow:`0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-start justify-between px-4 pt-3 pb-2",style:{borderBottom:`1px solid ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ws,{size:13,style:{color:ma(i.level)}}),s.jsxs("span",{className:"text-[12px] font-bold text-white/90 capitalize",children:[n[i.level]??i.level," — ",n.kinds[i.kind]??i.kind]})]}),s.jsx("button",{onClick:d,className:"text-white/30 hover:text-white/70 transition-colors",children:s.jsx(ze,{size:13})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:n.alerts[i.kind]??i.message}),s.jsx("p",{className:"text-[11px] text-white/45 leading-relaxed italic",children:n.recommendations[i.kind]??i.recommendation})]}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(i.ts).toLocaleTimeString()})})]},"health-popover")})]})}function GP(e){return`${Math.round(e*100)}%`}const Q0={skill:{label:"Skill",icon:Ue,color:"text-orange-400"},conversation:{label:"Conversation",icon:Hs,color:"text-blue-400"},workspace:{label:"Workspace",icon:Ln,color:"text-green-400"},custom:{label:"Custom",icon:nn,color:"text-gray-400"}};function qP(){const{t:e}=yt(),t=e.panels.memory,[n,r]=u.useState(""),[a,i]=u.useState([]),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(null),[f,m]=u.useState(null),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useCallback(async k=>{const S=k.trim();if(S){d(!0),i([]);try{const C=await U(`/api/memory/search?q=${encodeURIComponent(S)}&limit=10`);if(C.ok){const A=await C.json();i(A.results??[])}}catch{}d(!1)}},[]),g=k=>{k.key==="Enter"&&x(n)},w=u.useCallback(async()=>{try{const k=await U("/api/memory/stats");k.ok&&l(await k.json())}catch{}},[]),j=async k=>{p(k),m(null);try{const S=k==="clear"?await U("/api/memory/clear-index",{method:"DELETE"}):await U(`/api/memory/index-${k}`,{method:"POST"});if(S.ok){const C=await S.json(),A=k==="clear"?t.indexCleared:`${t.indexed} ${C.indexed??0} ${k==="skills"?t.skills:t.files}`;m({ok:!0,msg:A}),w(),k==="clear"&&i([])}else m({ok:!1,msg:t.opFailed})}catch{m({ok:!1,msg:t.reqError})}p(null),setTimeout(()=>m(null),4e3)};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zt,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),o&&s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[o.items.toLocaleString()," ",t.vectors]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>{y(k=>!k),o||w()},className:`text-gray-600 hover:text-gray-400 transition-colors ${b?"text-orange-400":""}`,title:t.indexControls,children:s.jsx(K3,{size:13})}),s.jsx("button",{onClick:w,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refreshStats,children:s.jsx(ge,{size:13})})]})]}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:[s.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 uppercase tracking-widest font-bold shrink-0",children:t.indexLabel}),["skills","workspace"].map(k=>s.jsxs("button",{onClick:()=>j(k),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/6 text-[11px] text-gray-400 hover:text-gray-200 hover:bg-white/8 transition-all disabled:opacity-40 capitalize",children:[h===k?s.jsx(ne,{size:10,className:"animate-spin"}):k==="skills"?s.jsx(Ue,{size:10}):s.jsx(Ln,{size:10}),k]},k)),s.jsxs("button",{onClick:()=>j("clear"),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-red-500/8 border border-red-500/15 text-[11px] text-red-400 hover:bg-red-500/15 transition-all disabled:opacity-40 ml-auto",children:[h==="clear"?s.jsx(ne,{size:10,className:"animate-spin"}):s.jsx(ys,{size:10}),t.clearIndex]})]}),s.jsx(ae,{children:f&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 pb-3 text-[11px] font-medium ${f.ok?"text-green-400":"text-red-400"}`,children:[f.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),f.msg]})})]})}),s.jsxs("div",{className:"px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-white/4 border border-white/8 focus-within:border-orange-500/30 transition-colors",children:[s.jsx(fn,{size:13,className:"text-gray-600 shrink-0"}),s.jsx("input",{ref:v,value:n,onChange:k=>r(k.target.value),onKeyDown:g,placeholder:t.searchPlaceholder,className:"flex-1 bg-transparent text-[13px] text-gray-200 outline-none placeholder-gray-700"}),c?s.jsx(ne,{size:13,className:"text-orange-400 animate-spin shrink-0"}):s.jsx("button",{onClick:()=>x(n),disabled:!n.trim(),className:"text-[10px] px-2 py-0.5 rounded-lg bg-orange-500/12 text-orange-400 font-semibold hover:bg-orange-500/22 border border-orange-500/20 transition-all disabled:opacity-30",children:"⌘↵"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 mt-1.5 ml-1",children:t.searchHint})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:[a.length===0&&!c&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Zt,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:n.trim()?t.emptyNoResults:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1 max-w-xs leading-relaxed",children:n.trim()?t.emptyNoResultsHint:t.emptyHint})]}),a.map((k,S)=>{const C=Q0[k.metadata.source]??Q0.custom,A=C.icon;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:S*.04},className:"rounded-2xl border border-white/6 bg-[#0c0f18] p-4 hover:border-white/12 transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(A,{size:11,className:`${C.color} shrink-0`}),s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:k.metadata.title})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full border ${k.score>=.85?"bg-green-500/10 border-green-500/20 text-green-400":k.score>=.65?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/4 border-white/6 text-gray-500"}`,children:GP(k.score)}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-white/4 border border-white/6 font-medium ${C.color}`,children:C.label})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-3 mb-2",children:k.text}),k.metadata.tags&&k.metadata.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:k.metadata.tags.map((N,_)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:N},_))}),s.jsx("div",{className:"mt-2 h-0.5 bg-white/4 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-orange-600 to-amber-400",style:{width:`${k.score*100}%`}})})]},S)})]})]})}const YP={node:en,python:wn},XP={node:"text-green-400",python:"text-blue-400"};function QP(){const{t:e}=yt(),t=e.panels.plugins,[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),[f,m]=u.useState(""),[b,y]=u.useState(""),[v,x]=u.useState("node"),[g,w]=u.useState(""),[j,k]=u.useState(!1),S=(_,L)=>{d({ok:_,msg:L}),setTimeout(()=>d(null),4e3)},C=u.useCallback(async()=>{i(!0);try{const _=await U("/api/plugins/list");if(_.ok){const L=await _.json();r(L.plugins??[])}}catch{}i(!1)},[]);u.useEffect(()=>{C()},[C]);const A=async(_,L)=>{l(_);try{(await U(L?"/api/plugins/stop":"/api/plugins/run",{method:"POST",body:JSON.stringify({name:_})})).ok?(S(!0,L?`${_} stopped`:`${_} launched`),await C()):S(!1,t.opFailed)}catch{S(!1,t.reqError)}l(null)},N=async()=>{if(!(!f.trim()||!b.trim())){k(!0);try{(await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:f.trim(),goal:b.trim(),lang:v,context:g.trim()||void 0})})).ok?(S(!0,`Plugin "${f}" created`),m(""),y(""),w(""),p(!1),await C()):S(!1,t.buildFailed)}catch{S(!1,t.reqError)}k(!1)}};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[n.length," ",t.installed]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:C,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refresh,children:s.jsx(ge,{size:13,className:a?"animate-spin":""})}),s.jsxs("button",{onClick:()=>p(_=>!_),className:`flex items-center gap-1 text-[10px] px-2.5 py-1 rounded-lg border font-semibold transition-all ${h?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500 hover:text-gray-300"}`,children:[s.jsx(Fl,{size:10}),t.newPlugin]})]})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 py-2 text-[11px] font-medium shrink-0 ${c.ok?"text-green-400":"text-red-400"}`,children:[c.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),c.msg]})}),s.jsx(ae,{children:h&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:s.jsxs("div",{className:"px-6 py-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:t.buildTitle}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("input",{value:f,onChange:_=>m(_.target.value),placeholder:t.namePlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:b,onChange:_=>y(_.target.value),placeholder:t.goalPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:g,onChange:_=>w(_.target.value),placeholder:t.contextPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("div",{className:"flex gap-2",children:["node","python"].map(_=>s.jsx("button",{onClick:()=>x(_),className:`flex-1 py-1.5 rounded-lg border text-[11px] font-semibold transition-all capitalize ${v===_?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500"}`,children:_},_))}),s.jsxs("button",{onClick:N,disabled:j||!f.trim()||!b.trim(),className:"flex items-center justify-center gap-1.5 py-2 rounded-lg bg-orange-500/12 border border-orange-500/20 text-orange-400 text-[11px] font-bold hover:bg-orange-500/20 transition-all disabled:opacity-40",children:[j?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(Ue,{size:11}),t.generatePlugin]})]})]})})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-2",children:[n.length===0&&!a&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(qr,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1",children:t.emptyHint})]}),n.map((_,L)=>{const B=YP[_.lang]??en,z=o===_.name;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:L*.04},className:`flex items-center gap-3 p-3 rounded-2xl border transition-all ${_.running?"bg-green-500/5 border-green-500/15 hover:border-green-500/25":"bg-[#0c0f18] border-white/6 hover:border-white/12"}`,children:[s.jsx(B,{size:13,className:XP[_.lang]??"text-gray-400"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:_.name}),s.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:_.filename})]}),_.running&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-green-500/12 border border-green-500/20 text-green-400 font-bold",children:t.running}),s.jsxs("button",{disabled:z,onClick:()=>A(_.name,_.running),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-[10px] font-bold transition-all disabled:opacity-40 ${_.running?"bg-red-500/8 border-red-500/15 text-red-400 hover:bg-red-500/15":"bg-green-500/8 border-green-500/15 text-green-400 hover:bg-green-500/15"}`,children:[z?s.jsx(ne,{size:10,className:"animate-spin"}):_.running?s.jsx($l,{size:10}):s.jsx(gs,{size:10}),_.running?t.stop:t.run]})]},_.name)})]})]})}function JP(e){if(!e)return"Never";try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function ZP(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function e6({skill:e}){const[t,n]=u.useState(!1),[r,a]=u.useState(!1),[i,o]=u.useState(""),[l,c]=u.useState(!1),d=async()=>{if(!l){c(!0);return}if(i.trim()){n(!0);try{await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:e.id,params:{goal:i.trim(),_autoRun:!0}})}),a(!0),c(!1),o(""),setTimeout(()=>a(!1),3e3)}catch{}n(!1)}},h=(e.requires.bins??[]).length>0,p=(e.requires.config??[]).length>0;return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-white/6 bg-[#0c0f18] hover:border-white/12 transition-all",children:s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base leading-none mt-0.5 shrink-0",children:e.emoji??"⚡"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[12px] font-bold text-gray-200 truncate capitalize",children:e.name})}),e.hasScripts&&s.jsx(Mn,{size:10,className:"text-gray-700 shrink-0 mt-0.5"})]}),s.jsx("p",{className:"text-[10px] text-gray-500 leading-relaxed line-clamp-2 mb-2 ml-6",children:e.description}),(h||p)&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-2 ml-6",children:[(e.requires.bins??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-500/8 border border-blue-500/15 text-blue-400 font-mono",children:["bin:",f]},f)),(e.requires.config??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-purple-500/8 border border-purple-500/15 text-purple-400 font-mono",children:["cfg:",f]},f))]}),s.jsx(ae,{children:l&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden mb-2",children:s.jsx("input",{autoFocus:!0,value:i,onChange:f=>o(f.target.value),onKeyDown:f=>{f.key==="Enter"&&d(),f.key==="Escape"&&(c(!1),o(""))},placeholder:`Goal for ${e.name}…`,className:"w-full px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/10 text-[11px] text-gray-200 placeholder-gray-700 outline-none focus:border-orange-500/30 transition-colors"})})}),s.jsxs("div",{className:"flex items-center justify-end gap-1 ml-6",children:[l&&s.jsx("button",{onClick:()=>{c(!1),o("")},className:"text-[10px] px-2 py-1 rounded-lg bg-white/4 text-gray-600 hover:text-gray-400 transition-colors",children:"Cancel"}),s.jsx("button",{onClick:d,disabled:t||l&&!i.trim(),className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold border transition-all disabled:opacity-40 ${r?"bg-green-500/10 border-green-500/20 text-green-400":"bg-orange-500/8 border-orange-500/15 text-orange-400 hover:bg-orange-500/15"}`,children:t?s.jsx(ne,{size:9,className:"animate-spin"}):r?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:9})," Sent"]}):l?s.jsxs(s.Fragment,{children:[s.jsx(gn,{size:9})," Run"]}):s.jsxs(s.Fragment,{children:[s.jsx(H3,{size:9})," Use"]})})]})]})})}function t6(){const{t:e}=yt(),t=e.panels.skills,[n,r]=u.useState("saved"),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState("idle"),[f,m]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState([]),[g,w]=u.useState(!1),[j,k]=u.useState(""),S=u.useCallback(async()=>{l(!0);try{const L=await U("/api/skills/list");if(L.ok){const B=await L.json();i(B.skills??[])}}catch{}l(!1)},[]),C=u.useCallback(async()=>{w(!0);try{const L=await U("/api/skills/catalog");if(L.ok){const B=await L.json();x(B.skills??[])}}catch{}w(!1)},[]);u.useEffect(()=>{S()},[S]),u.useEffect(()=>{n==="library"&&v.length===0&&C()},[n,v.length,C]),u.useEffect(()=>{const L=pe(),B=z=>{z.type==="skillRunStart"&&z.skillId&&(d(z.skillId),p("running")),z.type==="planFinish"&&(p("done"),d(null),S(),setTimeout(()=>p("idle"),2500))};return L.on("agentUpdate",B),()=>{L.off("agentUpdate",B)}},[S]);const A=async L=>{if(!c){d(L.id),p("running");try{const B=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:L.id})});if(!B.ok)throw new Error(`HTTP ${B.status}`)}catch{p("error"),d(null),setTimeout(()=>p("idle"),3e3)}}},N=async L=>{m(L);try{await U(`/api/skills/${L}`,{method:"DELETE"}),i(B=>B.filter(z=>z.id!==L))}catch{}m(null),y(null)},_=j.trim()?v.filter(L=>L.name.toLowerCase().includes(j.toLowerCase())||L.description.toLowerCase().includes(j.toLowerCase())):v;return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dl,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-white/4 rounded-lg p-0.5",children:[s.jsxs("button",{onClick:()=>r("saved"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="saved"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Ue,{size:9}),"Saved",a.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:a.length})]}),s.jsxs("button",{onClick:()=>r("library"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="library"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Lc,{size:9}),"Library",v.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:v.length})]})]}),s.jsx("button",{onClick:n==="saved"?S:C,disabled:n==="saved"?o:g,className:"text-gray-600 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:13,className:(n==="saved"?o:g)?"animate-spin":""})})]}),n==="saved"&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:h!=="idle"&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:`px-6 py-2 border-b flex items-center gap-2 text-xs font-medium ${h==="running"?"bg-orange-500/8 border-orange-500/15 text-orange-400":h==="done"?"bg-green-500/8 border-green-500/15 text-green-400":"bg-red-500/8 border-red-500/15 text-red-400"}`,children:[h==="running"&&s.jsx(ne,{size:12,className:"animate-spin"}),h==="done"&&s.jsx(Fe,{size:12}),h==="error"&&s.jsx(Ke,{size:12}),h==="running"?t.runningStatus:h==="done"?t.completedStatus:t.failedStatus]})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:o&&a.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2",children:[s.jsx(ne,{size:13,className:"animate-spin"})," ",t.loading]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Ue,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsxs("p",{className:"text-xs text-gray-700 mt-1 max-w-xs",children:[t.emptyHint," ",s.jsx("span",{className:"text-orange-400 font-medium",children:t.saveAsSkill})," ",t.emptyHint2]}),s.jsxs("button",{onClick:()=>r("library"),className:"mt-4 flex items-center gap-1.5 text-[11px] text-orange-400 hover:text-orange-300 transition-colors",children:[s.jsx(Lc,{size:11})," Browse skill library"]})]}):a.map((L,B)=>{const z=c===L.id&&h==="running",$=c===L.id&&h==="done",R=f===L.id;return s.jsx(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:B*.04},className:`rounded-2xl border bg-[#0c0f18] transition-all ${z?"border-orange-500/30 shadow-[0_0_12px_rgba(234,88,12,0.12)]":$?"border-green-500/20":"border-white/6 hover:border-white/12"}`,children:s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ue,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}),s.jsx("p",{className:"text-[13px] font-bold text-white truncate",children:L.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-600 shrink-0 font-mono",children:[s.jsx(rv,{size:9}),L.runCount,"×"]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed mb-2 line-clamp-2",children:L.goal}),L.steps.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[L.steps.slice(0,4).map((M,P)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:M.tool??"step"},P)),L.steps.length>4&&s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:["+",L.steps.length-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-700",children:[s.jsx(Lt,{size:9}),s.jsx("span",{children:ZP(L.savedAt)}),L.lastRunAt&&s.jsxs("span",{className:"text-gray-800",children:["· ",t.lastRun," ",JP(L.lastRunAt)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[b===L.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] text-red-400",children:t.deleteConfirm}),s.jsx("button",{onClick:()=>N(L.id),disabled:R,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-colors",children:R?"…":t.yes}),s.jsx("button",{onClick:()=>y(null),className:"text-[10px] px-2 py-0.5 rounded bg-white/5 text-gray-500 hover:bg-white/8",children:t.no})]}):s.jsx("button",{onClick:()=>y(L.id),className:"p-1.5 rounded-lg text-gray-700 hover:text-red-400 hover:bg-red-500/8 transition-all",title:"Delete skill",children:s.jsx(ys,{size:12})}),s.jsx("button",{onClick:()=>A(L),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${z?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":$?"bg-green-500/12 text-green-400 border border-green-500/20":"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 hover:border-orange-500/35 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:z?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:11,className:"animate-spin"})," ",t.runningBtn]}):$?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:11})," ",t.doneBtn]}):s.jsxs(s.Fragment,{children:[s.jsx(gs,{size:11})," ",t.runBtn]})})]})]})]})},L.id)})})]}),n==="library"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2.5 border-b border-white/5 shrink-0",children:s.jsx("input",{value:j,onChange:L=>k(L.target.value),placeholder:"Search skills…",className:"w-full px-3 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-300 placeholder-gray-700 outline-none focus:border-orange-500/25 transition-colors"})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-3 grid grid-cols-1 gap-2",children:g&&v.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2 col-span-1",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading skill library…"]}):_.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center col-span-1",children:[s.jsx(Lc,{size:36,className:"text-gray-700 mb-3"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:"No skills found"}),j&&s.jsx("button",{onClick:()=>k(""),className:"mt-2 text-[11px] text-orange-400 hover:text-orange-300",children:"Clear filter"})]}):_.map((L,B)=>s.jsx(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:Math.min(B*.02,.4)},children:s.jsx(e6,{skill:L})},L.id))}),v.length>0&&s.jsx("div",{className:"px-4 py-2 border-t border-white/5 shrink-0 flex items-center gap-1.5",children:s.jsxs("span",{className:"text-[10px] text-gray-700 font-mono",children:[_.length," / ",v.length," skills"]})})]})]})}const n6={html:o0,htm:o0,json:wn,js:wn,ts:wn,tsx:wn,jsx:wn};function s6(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function r6(e){try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function a6(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,t=>{let n="color:#86efac";return/^"/.test(t)&&(n=/:$/.test(t)?"color:#93c5fd":"color:#fca5a5"),/true|false/.test(t)&&(n="color:#f97316"),/null/.test(t)&&(n="color:#6b7280"),`<span style="${n}">${t}</span>`})}function i6(){const[e,t]=u.useState([]),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useCallback(async()=>{p(!0);try{const v=await U("/api/workspace/files");if(v.ok){const x=await v.json();t(x.files??[])}}catch{}p(!1)},[]);u.useEffect(()=>{f()},[f]);const m=async v=>{r(v),i(null),d(null),l(!0);try{const x=await U(`/api/workspace/file?p=${encodeURIComponent(v.rel)}`);if(!x.ok)throw new Error(`HTTP ${x.status}`);const g=await x.json();i(g.content+(g.truncated?`
|
|
839
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},_P="DialogDescriptionWarning",TP=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hb(_P).contentName}}.`;return u.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},pb=Zv,fb=nb,mb=sb,xb=rb,gb=ib,yb=lb,pl=db;const q0=e=>{let t;const n=new Set,r=(d,h)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=h??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,f))}},a=()=>t,l={setState:r,getState:a,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,a,l);return l},PP=e=>e?q0(e):q0,AP=e=>e;function MP(e,t=AP){const n=Y.useSyncExternalStore(e.subscribe,Y.useCallback(()=>t(e.getState()),[e,t]),Y.useCallback(()=>t(e.getInitialState()),[e,t]));return Y.useDebugValue(n),n}const Y0=e=>{const t=PP(e),n=r=>MP(t,r);return Object.assign(n,t),n},zP=e=>e?Y0(e):Y0,_i=zP(e=>{let t=!1,n=null,r=null,a=!1,i=null,o=[];try{t=localStorage.getItem("mustb_trader_installed")==="true",n=localStorage.getItem("mustb_trader_template");const l=localStorage.getItem("mustb_trader_accounts");if(l&&(o=JSON.parse(l)),r=localStorage.getItem("mustb_trader_exchange"),a=localStorage.getItem("mustb_trader_testnet")==="true",i=localStorage.getItem("mustb_trader_account_type"),o.length===0&&r)o=[{id:r.toLowerCase().trim(),name:r,type:i||"crypto",isTestnet:a}],localStorage.setItem("mustb_trader_accounts",JSON.stringify(o));else if(o.length>0&&!r){const c=o[0];r=c.name,i=c.type,a=c.isTestnet,localStorage.setItem("mustb_trader_exchange",c.name),localStorage.setItem("mustb_trader_account_type",c.type),localStorage.setItem("mustb_trader_testnet",String(c.isTestnet))}}catch{}return{isTradingPackageInstalled:t,selectedTemplate:n,accounts:o,connectedExchange:r,isTestnet:a,accountType:i,setTradingPackageInstalled:l=>{e({isTradingPackageInstalled:l});try{localStorage.setItem("mustb_trader_installed",String(l))}catch{}},setSelectedTemplate:l=>{e({selectedTemplate:l});try{l?localStorage.setItem("mustb_trader_template",l):localStorage.removeItem("mustb_trader_template")}catch{}},setConnectedExchange:l=>{e({connectedExchange:l});try{l?localStorage.setItem("mustb_trader_exchange",l):localStorage.removeItem("mustb_trader_exchange")}catch{}},setTestnet:l=>{e({isTestnet:l});try{localStorage.setItem("mustb_trader_testnet",String(l))}catch{}},setAccountType:l=>{e({accountType:l});try{l?localStorage.setItem("mustb_trader_account_type",l):localStorage.removeItem("mustb_trader_account_type")}catch{}},addAccount:l=>{e(c=>{const h=c.accounts.some(f=>f.id===l.id)?c.accounts.map(f=>f.id===l.id?l:f):[...c.accounts,l];try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(h))}catch{}const p=h[0];if(p){try{localStorage.setItem("mustb_trader_exchange",p.name),localStorage.setItem("mustb_trader_account_type",p.type),localStorage.setItem("mustb_trader_testnet",String(p.isTestnet))}catch{}return{accounts:h,connectedExchange:p.name,accountType:p.type,isTestnet:p.isTestnet}}return{accounts:h}})},removeAccount:l=>{e(c=>{const d=c.accounts.filter(p=>p.id!==l);try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(d))}catch{}const h=d[0];if(h){try{localStorage.setItem("mustb_trader_exchange",h.name),localStorage.setItem("mustb_trader_account_type",h.type),localStorage.setItem("mustb_trader_testnet",String(h.isTestnet))}catch{}return{accounts:d,connectedExchange:h.name,accountType:h.type,isTestnet:h.isTestnet}}else{try{localStorage.removeItem("mustb_trader_exchange"),localStorage.removeItem("mustb_trader_account_type"),localStorage.removeItem("mustb_trader_testnet")}catch{}return{accounts:[],connectedExchange:null,accountType:null,isTestnet:!1}}})}}}),RP={Messaging:{icon:"💬",accent:"text-blue-300",border:"border-blue-500/20",bg:"bg-blue-500/10",iconBg:"bg-blue-500/10"},Finance:{icon:"📈",accent:"text-emerald-300",border:"border-emerald-500/20",bg:"bg-emerald-500/10",iconBg:"bg-emerald-500/10"},System:{icon:"⚙️",accent:"text-orange-300",border:"border-orange-500/20",bg:"bg-orange-500/10",iconBg:"bg-orange-500/10"}};function LP(e){return RP[e]??{icon:"🔌",accent:"text-white/60",border:"border-white/10",bg:"bg-white/5",iconBg:"bg-white/5"}}function OP({name:e}){return s.jsx("span",{className:"inline-block px-2 py-0.5 rounded-md text-[10px] font-mono bg-white/5 text-white/40 border border-white/8",children:e})}function IP({pack:e,installing:t,installLog:n,onInstall:r,onConfigure:a}){const[i,o]=u.useState(!1),l=LP(e.category),c=e.extensions.length===0;return s.jsxs("div",{className:"flex flex-col bg-white/5 border border-white/8 rounded-2xl p-5 gap-3 hover:bg-white/[0.07] hover:border-white/12 transition-all duration-200",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-xl ${l.iconBg} flex items-center justify-center text-[24px] shrink-0 select-none border ${l.border}`,children:l.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:e.name}),e.installed?s.jsx(Ms,{size:14,className:"text-emerald-400 shrink-0"},"check-installed"):null]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l.accent}`,children:e.category}),!c&&s.jsxs("span",{className:"text-[10px] text-white/30",children:[e.extensions.length," extension",e.extensions.length!==1?"s":""]}),c&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-md bg-yellow-500/10 text-yellow-400 border border-yellow-500/20 font-medium",children:"Coming Soon"})]})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed",children:e.description}),s.jsx("p",{className:"text-[11px] font-mono text-white/25",children:e.npmPackage}),e.extensions.length>0&&s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>o(d=>!d),className:"flex items-center gap-1 text-[11px] text-white/30 hover:text-white/60 transition-colors mb-2",children:[i?s.jsx(Bl,{size:12}):s.jsx(Xs,{size:12}),i?"Hide":"Show"," included extensions"]}),i&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.extensions.map(d=>s.jsx(OP,{name:d},d))},"exts-chips")]},"exts-wrapper"),t&&n?s.jsx("pre",{className:"text-[10px] text-white/40 bg-black/40 rounded-xl p-2.5 max-h-[72px] overflow-y-auto font-mono whitespace-pre-wrap break-all border border-white/6",children:n},"install-log-stream"):null,s.jsx("div",{className:"mt-auto pt-1",children:c?s.jsx("div",{className:"w-full py-2 rounded-xl text-[12px] font-medium text-center bg-white/4 text-white/25 border border-white/8 cursor-default select-none",children:"Not yet available"},"pack-placeholder"):e.installed?s.jsx("button",{onClick:a,className:"w-full py-2 rounded-xl text-[12px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/15 hover:border-emerald-500/30 transition-colors",children:"Installed — Configure Keys"},"pack-configure-btn"):s.jsx("button",{onClick:r,disabled:t,className:`w-full flex items-center justify-center gap-2 py-2 rounded-xl text-[12px] font-semibold ${l.bg} ${l.accent} border ${l.border} hover:brightness-125 disabled:opacity-50 disabled:cursor-not-allowed transition-all`,children:t?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ne,{size:13,className:"animate-spin shrink-0"}),s.jsx("span",{children:"Installing…"})]},"installing-span"):s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Qs,{size:13,className:"shrink-0"}),s.jsx("span",{children:"Install Pack"})]},"install-span")},"pack-install-btn")})]})}function DP({pack:e,onClose:t}){const[n,r]=u.useState({}),[a,i]=u.useState(!1);u.useEffect(()=>{e&&r({})},[e]);const o=async()=>{if(e){i(!0);try{if(!(await U("/api/store/configure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:n})})).ok)throw new Error("Configure request failed");te.success(`${e.name} configured — keys saved to .env`),t()}catch(c){te.error(c instanceof Error?c.message:"Configure failed")}finally{i(!1)}}},l={};for(const c of(e==null?void 0:e.requiredKeys)??[]){const d=c.forExtension??"general";(l[d]??(l[d]=[])).push(c)}return s.jsx(pb,{open:!!e,onOpenChange:c=>{c||t()},children:s.jsxs(fb,{children:[s.jsx(mb,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(xb,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs(gb,{className:"text-white/90 font-semibold text-[15px]",children:["Configure ",e==null?void 0:e.name]}),s.jsx(pl,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(ze,{size:15})})]}),s.jsxs(yb,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Fill in the keys for the extensions you want to use. Leave others blank — they can be added later. Keys are saved to your local"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:".env"})," file."]}),s.jsx("div",{className:"space-y-5",children:Object.entries(l).map(([c,d])=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30 mb-2.5",children:c}),s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:h.label}),h.hint&&s.jsx("p",{className:"text-[11px] text-white/35 mb-1.5",children:h.hint}),s.jsx("input",{type:"password",autoComplete:"off",value:n[h.env]??"",onChange:p=>r(f=>({...f,[h.env]:p.target.value})),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-orange-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:`Enter ${h.label}`})]},h.env))})]},c))}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:o,disabled:a,className:"flex-1 flex items-center justify-center gap-2 bg-orange-500/20 hover:bg-orange-500/30 border border-orange-500/30 hover:border-orange-500/50 disabled:opacity-60 text-orange-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Ms,{size:14}),"Save & Activate"]}),s.jsx(pl,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"Skip"})]})]})]})})}function BP({isOpen:e,onClose:t,onSuccess:n}){const[r,a]=u.useState(""),[i,o]=u.useState(!1);u.useEffect(()=>{e&&a("")},[e]);const l=async()=>{if(!r||r.trim().length<10){te.error("Lütfen geçerli bir Web3 cüzdan gizli anahtarı (Private Key) girin.");return}o(!0);try{const c=await U("/api/web3/vault",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({walletPrivateKey:r.trim()})}),d=await c.json();if(!c.ok||!d.ok)throw new Error(d.error||"Web3 cüzdan anahtarı kaydedilemedi.");te.success("Polymarket AI Oracle başarıyla kuruldu ve anahtarınız ~/.must-b/ klasöründe şifrelendi!"),n(),t()}catch(c){te.error(c instanceof Error?c.message:"Kurulum başarısız oldu.")}finally{o(!1)}};return s.jsx(pb,{open:e,onOpenChange:c=>{c||t()},children:s.jsxs(fb,{children:[s.jsx(mb,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(xb,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx(gb,{className:"text-white/90 font-semibold text-[15px]",children:"Polymarket AI Oracle Kurulumu"}),s.jsx(pl,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(ze,{size:15})})]}),s.jsxs(yb,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Polymarket tahmin piyasalarında otomatik işlem yapabilmek için Polygon uyumlu Web3 cüzdanınızın gizli anahtarını (Private Key) girmeniz gerekmektedir. Gizli anahtarınız, yerel diskte ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:"~/.must-b/"})," dizininde AES-256 ile son derece güvenli bir şekilde şifrelenir ve asla dışarı aktarılmaz."]}),s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:"Web3 Cüzdan Gizli Anahtarı (Private Key)"}),s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:c=>a(c.target.value),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-purple-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:"0x..."})]})}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:l,disabled:i,className:"flex-1 flex items-center justify-center gap-2 bg-purple-500/20 hover:bg-purple-500/30 border border-purple-500/30 hover:border-purple-500/50 disabled:opacity-60 text-purple-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[i?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Ms,{size:14}),"Kaydet ve Aktifleştir"]}),s.jsx(pl,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"İptal"})]})]})]})})}const FP=12e4;function $P(){const{isTradingPackageInstalled:e,setTradingPackageInstalled:t}=_i(),[n,r]=u.useState([]),[a,i]=u.useState(!0),[o,l]=u.useState(null),[c,d]=u.useState({}),[h,p]=u.useState(null),f=u.useRef(null),[m,b]=u.useState(!1),[y,v]=u.useState(!1),x=u.useCallback(async()=>{try{const k=await U("/api/web3/vault");if(k.ok){const S=await k.json();b(S.configured)}}catch{}},[]),g=u.useCallback(async()=>{i(!0);try{const k=await U("/api/store/extensions");k.ok&&r(await k.json())}catch{}finally{i(!1)}},[]);u.useEffect(()=>{g(),x()},[g,x]);const w=u.useCallback(async k=>{var A;(A=f.current)==null||A.abort();const S=new AbortController;f.current=S,l(k.id),d(N=>({...N,[k.id]:""}));const C=setTimeout(()=>{S.abort()},FP);try{const N=await U("/api/store/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:k.id}),signal:S.signal},{retries:1,retryDelay:0});if(!N.body)throw new Error("No response stream");const _=N.body.getReader(),L=new TextDecoder;let B="";for(;;){const{done:M,value:$}=await _.read();if(M)break;const R=L.decode($,{stream:!0});B+=R,d(z=>({...z,[k.id]:B}))}if(B.includes("__MUSTB_INSTALL_OK__")){te.success(`${k.name} installed!`);try{r(M=>M.map($=>$.id===k.id?{...$,installed:!0}:$)),k.requiredKeys.length>0&&p(k)}catch(M){console.error("Defensive UI update error caught:",M)}}else B.includes("__MUSTB_INSTALL_FAILED__")?te.error(`${k.name} installation failed — check the log above.`):te.error(`${k.name} installation failed.`)}catch(N){N.name==="AbortError"?te.error(`Install timed out — is ${k.npmPackage} published to npm?`):te.error(N instanceof Error?N.message:"Install failed")}finally{clearTimeout(C),l(null)}},[]),j=n.filter(k=>k.installed).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0",children:s.jsx(xv,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Extension Store"}),j>0&&s.jsxs("span",{className:"text-[11px] text-emerald-400/80 font-medium",children:[j," pack",j!==1?"s":""," installed"]})]})]}),s.jsxs("p",{className:"text-white/40 text-[13px] leading-relaxed max-w-2xl mt-1",children:["Extensions are grouped into themed packs."," ","Install one pack to get all its integrations — fetched directly from npm into"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/5 px-1.5 py-0.5 rounded text-[11px] border border-white/8",children:"~/.must-b/extensions/"})]})]}),s.jsx("button",{onClick:g,title:"Refresh",className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all shrink-0",children:s.jsx(ge,{size:15})})]}),s.jsxs("div",{className:"mb-8 px-3 py-2.5 rounded-xl bg-white/5 border border-white/8 flex items-center gap-3",children:[s.jsx("code",{className:"text-[11px] font-mono text-white/30 shrink-0",children:"CLI:"}),s.jsxs("code",{className:"text-[12px] font-mono text-white/50",children:[s.jsx("span",{className:"text-orange-400",children:"must-b ext list"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install channels"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install system"})]})]}),a?s.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[s.jsx(ne,{size:22,className:"animate-spin text-orange-400"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"Loading extension store…"})]},"loading-div"):n.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[s.jsx(Qs,{size:28,className:"text-white/20"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"No packs available — backend may not be running."}),s.jsx("button",{onClick:g,className:"mt-1 px-4 py-2 rounded-xl bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[12px] font-medium hover:bg-orange-500/20 transition-colors",children:"Retry"})]},"empty-div"):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#131d27]/70 to-[#0c0f18]/70 border border-emerald-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-emerald-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Premium Algorithmic Package"}),s.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Borsa & Otomasyon Paketi"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Binance, OKX ve Bitget borsaları ile doğrudan bütünleşik, gelişmiş RSI ve Grid trading bot arayüzünü içerir."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsx("p",{className:`text-xs font-bold ${e?"text-emerald-400":"text-gray-400"}`,children:e?"Kuruldu / Installed":"Kurulmadı / Available"})]}),s.jsx("button",{onClick:()=>{t(!0),te.success("Borsa & Botlar paketi başarıyla kuruldu!")},disabled:e,className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${e?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 cursor-default":"bg-emerald-600 text-white hover:bg-emerald-500 shadow-emerald-500/10"}`,children:e?"Kuruldu":"Paketi Kur"})]})]}),s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#1c1a2e]/70 to-[#0e0c18]/70 border border-purple-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-purple-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Web3 & Prediction Markets"}),s.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-purple-400 animate-pulse":"bg-purple-800"}`})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Polymarket AI Oracle"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Polymarket tahmin piyasalarında otomatik işlem yapmayı sağlayan, yapay zeka destekli oracle ve işlem modülü."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsx("p",{className:`text-xs font-bold ${m?"text-purple-400":"text-gray-400"}`,children:m?"Kuruldu / Configured":"Kurulmadı / Available"})]}),s.jsx("button",{onClick:()=>v(!0),className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${m?"bg-purple-500/10 text-purple-400 border border-purple-500/20 hover:bg-purple-500/20 cursor-pointer":"bg-purple-600 text-white hover:bg-purple-500 shadow-purple-500/10"}`,children:m?"Yapılandır":"Kur / Configure"})]})]}),n.map(k=>s.jsx(IP,{pack:k,installing:o===k.id,installLog:c[k.id]??"",onInstall:()=>w(k),onConfigure:()=>p(k)},k.id))]},"grid-div"),s.jsxs("p",{className:"text-center text-white/20 text-[11px] mt-12",children:["Packs are built with"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"npm run build:packs"})," ","and published to npm. Run"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"must-b ext list"})," ","for the CLI interface."]}),s.jsx(DP,{pack:h,onClose:()=>p(null)}),s.jsx(BP,{isOpen:y,onClose:()=>v(!1),onSuccess:x})]})}const VP=[{id:"grid-trading",name:"Grid Trading Bot",desc:"Grid strategy for sideways markets."},{id:"rsi-scalper",name:"RSI Scalper Dashboard",desc:"Fast scalping layout based on RSI crossovers."},{id:"arbitrage",name:"Cross-Exchange Arbitrage",desc:"Arbitrage monitoring dashboard."},{id:"dca-accumulator",name:"DCA Accumulator",desc:"Dollar-cost averaging dashboard."},{id:"portfolio-rebalance",name:"Portfolio Auto-Rebalancer",desc:"Dynamic asset weights management layout."}];function UP(){const e=gt(),{selectedTemplate:t,setSelectedTemplate:n}=_i(),r=(a,i)=>{n(a),te.success(`Şablon seçildi: ${i}`),e("/app/trader/connect")};return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"mb-10 text-center sm:text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center sm:justify-start mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(I3,{size:18,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Kontrol Paneli Şablonları"}),s.jsx("p",{className:"text-[11px] text-emerald-400/80 font-medium mt-1",children:"Lütfen bir işlem arayüzü şablonu seçin"})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed max-w-xl mt-2",children:"İşlem botlarınızın ve portföyünüzün performansını izlemek için optimize edilmiş minimal şablon yapıları."})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:VP.map(a=>s.jsxs("div",{className:`flex flex-col bg-white/3 border rounded-2xl p-4 gap-4 hover:bg-white/5 hover:border-white/20 transition-all duration-200 justify-between ${t===a.id?"border-emerald-500/50":"border-white/8"}`,children:[s.jsxs("div",{className:"space-y-2 bg-black/40 border border-white/6 rounded-xl p-3 h-[140px] flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-8 h-2.5 rounded bg-white/10"}),s.jsx("div",{className:"w-3 h-3 rounded-full bg-white/10"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 flex flex-col justify-center",children:[s.jsx("div",{className:"w-full h-4 rounded bg-white/5 border border-white/8"}),s.jsx("div",{className:"w-3/4 h-2.5 rounded bg-white/5"}),s.jsx("div",{className:"w-1/2 h-2 rounded bg-white/5"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-6 h-3 rounded bg-white/10"}),s.jsx("div",{className:"w-8 h-3 rounded bg-white/10"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-sm leading-snug mt-2",children:a.name}),s.jsx("p",{className:"text-white/35 text-[11px] leading-relaxed mt-1",children:a.desc})]}),s.jsx("button",{onClick:()=>r(a.id,a.name),className:`w-full flex items-center justify-center gap-1.5 py-2 mt-4 rounded-xl text-[11px] font-bold border transition-all ${t===a.id?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-white/5 text-white/60 border-white/10 hover:border-white/25"}`,children:t===a.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:12}),s.jsx("span",{children:"Seçildi"})]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{size:12}),s.jsx("span",{children:"Şablonu Kaydet"})]})})]})]},a.id))})]})}function HP(){const e=gt(),{setConnectedExchange:t,setTestnet:n,setAccountType:r,addAccount:a}=_i(),[i,o]=u.useState("crypto"),[l,c]=u.useState("binance"),[d,h]=u.useState(""),[p,f]=u.useState(""),[m,b]=u.useState(""),[y,v]=u.useState("FBS"),[x,g]=u.useState(""),[w,j]=u.useState("FBS-Real"),[k,S]=u.useState(""),[C,A]=u.useState(!1),[N,_]=u.useState(!1),L=async B=>{if(B.preventDefault(),i==="crypto"){if(!d.trim()||!p.trim()){te.error("API Anahtarı ve Secret alanları boş bırakılamaz.");return}if(l==="okx"&&!m.trim()){te.error("OKX bağlantısı için API parolası (Passphrase) gereklidir.");return}}else{if(!y.trim()||!x.trim()||!m.trim()||!w.trim()){te.error("Broker, Login, Şifre ve Sunucu alanları boş bırakılamaz.");return}if(!k.trim()){te.error("MetaApi Token alanı boş bırakılamaz. MetaApi Cloud hesabınızdan token alın.");return}}_(!0);const M=i==="crypto"?l.toUpperCase():y,$=te.loading(`${M} ${C?"(Testnet) ":""}bağlantısı doğrulanıyor...`);try{const R=i==="crypto"?{accountType:"crypto",exchangeId:l,apiKey:d.trim(),secret:p.trim(),password:m.trim()||void 0,isTestnet:C}:{accountType:"tradfi",broker:y.trim(),login:x.trim(),password:m.trim(),server:w.trim(),apiKey:k.trim(),isTestnet:C},z=await fetch("/api/trader/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),P=await z.json();if(!z.ok)throw new Error(P.error||"Bağlantı doğrulanamadı.");te.success(`${M} ${C?"(Testnet) ":""}başarıyla bağlandı!`,{id:$});const E=i==="crypto"?l==="binance"?"Binance":l==="okx"?"OKX":"Bitget":y;t(E),n(C),r(i);const T=i==="crypto"?l.toLowerCase():y.toLowerCase();a({id:T,name:E,type:i,isTestnet:C}),e("/app/trader/dashboard")}catch(R){te.error(R.message||"Bağlantı hatası oluştu.",{id:$})}finally{_(!1)}};return s.jsxs("div",{className:"min-h-[80vh] flex items-center justify-center px-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-emerald-500/10 rounded-full blur-[120px] pointer-events-none"}),s.jsx("div",{className:"absolute bottom-1/4 left-1/3 w-[300px] h-[300px] bg-amber-500/5 rounded-full blur-[100px] pointer-events-none"}),s.jsxs("div",{className:"w-full max-w-lg bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-3xl p-8 shadow-2xl backdrop-blur-md relative z-10",children:[s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shadow-lg shadow-emerald-500/5",children:s.jsx(dp,{size:26,className:"text-emerald-400"})})}),s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Güvenli İşlem Bağlantısı"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 max-w-xs mx-auto leading-relaxed",children:"API anahtarlarınızı veya aracı kurum bilgilerinizi kullanarak bağlantı kurun ve otomatik işlemleri başlatın."})]}),s.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-2xl p-4 mb-6 flex items-start gap-3",children:[s.jsx(Ws,{size:18,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h4",{className:"text-xs font-semibold text-amber-300",children:"Önemli Güvenlik Uyarısı"}),s.jsxs("p",{className:"text-[11px] text-amber-200/90 leading-relaxed",children:["API anahtarlarınızda veya kurum hesap yetkilerinizde ",s.jsx("strong",{children:"PARA ÇEKME (Withdraw)"})," yetkisinin KAPALI olduğundan emin olun. Verileriniz cihazınızda şifrelenerek saklanır, buluta gönderilmez."]})]})]}),s.jsxs("form",{onSubmit:L,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Hesap Tipi"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 bg-zinc-950/40 p-1 border border-zinc-800 rounded-xl",children:[s.jsx("button",{type:"button",onClick:()=>o("crypto"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="crypto"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Kripto Borsası"}),s.jsx("button",{type:"button",onClick:()=>o("tradfi"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="tradfi"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Aracı Kurum (TradFi)"})]})]}),s.jsxs("div",{className:"bg-zinc-950/40 border border-zinc-800 rounded-xl p-3.5 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-[12px] font-semibold text-white block",children:"Demo Modu (Testnet)"}),s.jsx("span",{className:"text-[10px] text-zinc-500 mt-0.5 block leading-tight",children:"Gerçek para riske atmadan, sanal bakiye ile stratejilerinizi test edin."})]}),s.jsx("button",{type:"button",onClick:()=>A(!C),disabled:N,className:`w-10 h-6 shrink-0 rounded-full p-1 transition-all duration-300 relative outline-none ${C?"bg-amber-500":"bg-zinc-800"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow-md transform transition-all duration-300 ${C?"translate-x-4":"translate-x-0"}`})})]}),i==="crypto"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Borsa Seçimi"}),s.jsxs("select",{value:l,onChange:B=>{c(B.target.value),b("")},disabled:N,className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl px-4 py-3 text-sm text-white font-medium outline-none transition-all disabled:opacity-50",children:[s.jsx("option",{value:"binance",children:"Binance"}),s.jsx("option",{value:"okx",children:"OKX"}),s.jsx("option",{value:"bitget",children:"Bitget"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Key (Erişim Anahtarı)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(rp,{size:16})}),s.jsx("input",{type:"text",value:d,onChange:B=>h(B.target.value),disabled:N,placeholder:"Örn: 4bc8f9a2e37...",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Secret (Gizli Anahtar)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(ap,{size:16})}),s.jsx("input",{type:"password",value:p,onChange:B=>f(B.target.value),disabled:N,placeholder:"••••••••••••••••••••••••••••••••",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Parolası / Passphrase"}),s.jsx("span",{className:"text-[9px] text-zinc-500 font-medium tracking-wide block uppercase",children:l==="okx"?"OKX için Zorunlu":"Opsiyonel"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(cv,{size:16})}),s.jsx("input",{type:"password",value:m,onChange:B=>b(B.target.value),disabled:N,placeholder:l==="okx"?"OKX API Parolası":"Gerekirse şifre / parola",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:l==="okx"})]})]})]}):s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-500/10 bg-gradient-to-br from-zinc-900/60 via-zinc-950/80 to-[#0c0f18]/90 backdrop-blur-xl p-6 flex flex-col items-center gap-4 my-2",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/5 via-transparent to-cyan-500/5 pointer-events-none"}),s.jsx("div",{className:"absolute -top-10 -right-10 w-32 h-32 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"absolute -bottom-10 -left-10 w-28 h-28 bg-cyan-500/8 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"relative z-10 w-14 h-14 rounded-2xl bg-gradient-to-br from-emerald-500/20 to-cyan-500/10 border border-emerald-500/20 flex items-center justify-center shadow-xl shadow-emerald-500/5 mt-2",children:s.jsx("svg",{className:"w-7 h-7 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.955 11.955 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.249-8.25-3.286Z"})})}),s.jsxs("div",{className:"relative z-10 flex items-center gap-1.5 bg-emerald-500/10 border border-emerald-500/20 rounded-full px-3 py-1",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-emerald-400 uppercase tracking-widest",children:"Çok Yakında"})]}),s.jsxs("div",{className:"relative z-10 text-center space-y-2 pb-2",children:[s.jsx("h3",{className:"text-sm font-bold text-white",children:"Yerel MetaTrader 4/5 Entegrasyonu"}),s.jsx("p",{className:"text-[11px] text-zinc-400 leading-relaxed max-w-[260px]",children:"Doğrudan aracı kurum bağlantısı ile MT4/MT5 hesaplarınızı Must-b yapay zeka motoruna bağlayın."})]}),s.jsx("ul",{className:"relative z-10 space-y-2 w-full text-[11px] text-zinc-500 pb-1",children:["FBS, IC Markets, Pepperstone desteği","Gerçek zamanlı Lot execution","Uyuyan Dev AI stratejisi entegrasyonu"].map(B=>s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-4 h-4 rounded-full border border-emerald-500/20 bg-emerald-500/5 flex items-center justify-center shrink-0",children:s.jsx("div",{className:"w-1 h-1 rounded-full bg-emerald-500/60"})}),B]},B))})]}),s.jsx("button",{type:"submit",disabled:N||i==="tradfi",className:`w-full flex items-center justify-center gap-2.5 py-3.5 px-6 mt-6 rounded-xl font-bold text-sm text-white transition-all relative overflow-hidden shadow-lg ${i==="tradfi"?"bg-zinc-800 opacity-50 cursor-not-allowed shadow-none":"bg-emerald-600 hover:bg-emerald-500 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed shadow-emerald-500/10"}`,children:N?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:16,className:"animate-spin text-white"}),s.jsx("span",{children:"Doğrulanıyor..."})]}):i==="tradfi"?s.jsx("span",{children:"Çok Yakında"}):s.jsx("span",{children:"Güvenli Bağlantı Kur"})})]}),s.jsx("p",{className:"text-[10px] text-zinc-600 mt-6 text-center leading-relaxed",children:"Must-b.os, API anahtarlarınızı tamamen yerel cihazınızda AES-256 algoritmasıyla şifreler."})]})]})}function WP(){const e=gt(),{accounts:t,removeAccount:n,connectedExchange:r,selectedTemplate:a}=_i(),[i,o]=u.useState(""),[l,c]=u.useState([{id:"rsi-scalper",name:"RSI Scalper AI",desc:"Fast scalping crossovers",active:!1},{id:"grid-trader",name:"Grid Trader AI",desc:"Sideways market grid",active:!1},{id:"macd-reversal",name:"MACD Reversal AI",desc:"Trend reversal detector",active:!1}]),[d,h]=u.useState(!0),[p,f]=u.useState(null),[m,b]=u.useState([]),[y,v]=u.useState({}),[x,g]=u.useState({"rsi-scalper":3e5,"grid-trader":3e5,"macd-reversal":3e5});u.useEffect(()=>{t&&t.length>0&&!i&&o(t[0].id)},[t,i]),u.useEffect(()=>{!r&&(!t||t.length===0)&&e("/app/trader/connect")},[r,t]);const w=async N=>{var L;const _=N||i||t&&((L=t[0])==null?void 0:L.id)||"";if(!_){h(!1);return}try{const B=`/api/trader/balance?exchangeId=${_}`,M=`/api/trader/history?exchangeId=${_}`,[$,R,z]=await Promise.all([fetch(B),fetch(M),fetch("/api/bot/status")]);if($.ok){const P=await $.json();f(P)}else f(null);if(R.ok){const P=await R.json();b(P.trades||[])}else b([]);if(z.ok){const P=await z.json();P.active&&(v(P.active),c(E=>E.map(T=>({...T,active:P.active[T.id]!==void 0}))),g(E=>{const T={...E};for(const O in P.active)T[O]=P.active[O];return T}))}}catch{te.error("Borsa verileri yüklenemedi.")}finally{h(!1)}};u.useEffect(()=>{i&&w(i)},[i]);const j=async(N,_,L)=>{const B=!L,M=x[N]||3e5,$=te.loading(B?`${_} başlatılıyor...`:`${_} durduruluyor...`);try{if(B){if(!(await fetch("/api/bot/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:N,pair:"BTC/USDT",intervalMs:M})})).ok)throw new Error("Bot başlatılamadı.");v(z=>({...z,[N]:M})),c(z=>z.map(P=>P.id===N?{...P,active:!0}:P)),te.success(`${_} başarıyla başlatıldı!`,{id:$})}else{if(!(await fetch("/api/bot/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:N})})).ok)throw new Error("Bot durdurulamadı.");v(z=>{const P={...z};return delete P[N],P}),c(z=>z.map(P=>P.id===N?{...P,active:!1}:P)),te.error(`${_} durduruldu.`,{id:$})}}catch(R){te.error(R.message||"İşlem başarısız.",{id:$})}},k=async(N,_)=>{if(window.confirm(`${_} bağlantısını kesmek ve hesabı kaldırmak istediğinize emin misiniz?`))try{const L=await fetch("/api/trader/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({exchangeId:N})});if(!L.ok){const M=await L.json().catch(()=>({}));throw new Error(M.error||"Bağlantı kesilemedi.")}n(N),te.success(`${_} başarıyla kaldırıldı.`);const B=t.filter(M=>M.id!==N);B.length>0?o(B[0].id):e("/app/trader/connect")}catch(L){te.error(L.message||"Bir hata oluştu.")}},S=N=>{const _=t.find(M=>M.id===i),L=_?_.name:r,B=L==="Binance"?"https://www.binance.com":L==="OKX"?"https://www.okx.com":"https://www.bitget.com";te.info("Yasal işlemler için ilgili borsaya yönlendiriliyorsunuz..."),setTimeout(()=>{window.open(B,"_blank")},800)};if(d)return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{className:"space-y-2 animate-pulse",children:[s.jsx("div",{className:"h-6 w-48 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-4 w-32 bg-white/5 rounded-lg"})]}),s.jsxs("div",{className:"flex items-center gap-2 animate-pulse",children:[s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 animate-pulse",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-32 bg-white/5 rounded-xl"})]})]})]});const C=t.find(N=>N.id===i),A=(C==null?void 0:C.type)==="tradfi";return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Trader Dashboard"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1 flex items-center gap-1.5",children:["Aktif Hesap: ",s.jsx("span",{className:"text-emerald-400 font-semibold",children:(p==null?void 0:p.exchange)||(C==null?void 0:C.name)||r||"Bağlı Değil"})," · ","Şablon: ",s.jsx("span",{className:"text-cyan-400 font-semibold",children:a||"Varsayılan"})]})]}),!A&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>S(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-500 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Yatır"}),s.jsx(Kr,{size:12})]}),s.jsxs("button",{onClick:()=>S(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-white/5 border border-white/8 hover:bg-white/8 hover:border-white/12 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Çek"}),s.jsx(Kr,{size:12})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px] relative overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Toplam Varlık / Total Balance"}),s.jsxs("div",{className:"flex items-center gap-2",children:[((p==null?void 0:p.isTestnet)||(C==null?void 0:C.isTestnet))&&s.jsx("span",{className:"px-2 py-0.5 rounded bg-amber-500/10 border border-amber-500/25 text-amber-400 font-bold uppercase tracking-wider text-[8px] animate-pulse",children:"DEMO ACTIVE"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-white/90 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.total.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Son güncelleme: Az önce"})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Kullanılabilir Bakiye / Free Balance"}),s.jsx(yv,{size:14,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-emerald-400 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.free.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsxs("p",{className:"text-[10px] text-emerald-500/80 font-semibold mt-1 flex items-center gap-0.5",children:[s.jsx(nv,{size:10})," Bloke / Used: ",p?p.used.toFixed(2):"0.00"," ",p==null?void 0:p.displayAsset]})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-5 flex flex-col justify-between h-[130px] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/5 pb-2 mb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Bağlı Hesaplar"}),s.jsx("button",{onClick:()=>e("/app/trader/connect"),className:"text-[10px] font-bold text-emerald-400 hover:text-emerald-300 hover:underline",children:"+ Yeni Ekle"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 pr-1 scrollbar-thin",children:[t&&t.map(N=>s.jsxs("div",{onClick:()=>o(N.id),className:`flex items-center justify-between p-1.5 rounded-lg border cursor-pointer transition-all ${i===N.id?"bg-emerald-500/10 border-emerald-500/30 text-white font-bold":"bg-white/3 border-white/5 text-zinc-400 hover:bg-white/5 hover:text-white"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i===N.id?"bg-emerald-400":"bg-zinc-600"}`}),s.jsxs("span",{className:"text-[11px] truncate",children:[N.name," ",N.isTestnet?"(Demo)":""]})]}),s.jsx("button",{onClick:_=>{_.stopPropagation(),k(N.id,N.name)},className:"text-[9px] font-semibold text-red-400 hover:text-red-300 hover:underline px-1 py-0.5 rounded hover:bg-red-500/10 transition-all shrink-0",children:"Kaldır"})]},N.id)),(!t||t.length===0)&&s.jsx("p",{className:"text-[10px] text-zinc-500 italic text-center py-2",children:"Bağlı hesap bulunamadı."})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(Wr,{size:16,className:"text-emerald-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"Aktif Robotlar / Bots"})]}),s.jsx("div",{className:"space-y-3",children:l.map(N=>s.jsxs("div",{className:`p-3.5 rounded-xl border flex flex-col gap-3 transition-all ${N.active?"bg-emerald-500/5 border-emerald-500/25":"bg-white/3 border-white/6"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[N.active&&s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse shrink-0"}),s.jsxs("div",{className:"truncate",children:[s.jsx("p",{className:"text-xs font-bold text-white/90",children:N.name}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5 truncate",children:N.desc})]})]}),s.jsx("button",{onClick:()=>j(N.id,N.name,N.active),className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 transition-all ${N.active?"bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20"}`,children:N.active?s.jsx($l,{size:10,fill:"currentColor"}):s.jsx(gs,{size:10,fill:"currentColor"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2.5 border-t border-white/5",children:[s.jsx("span",{className:"text-[9px] text-zinc-500 font-bold uppercase tracking-wider",children:"Periyot / Interval"}),s.jsxs("select",{value:x[N.id]||3e5,onChange:_=>{const L=parseInt(_.target.value);g(B=>({...B,[N.id]:L}))},disabled:N.active,className:"bg-zinc-950 border border-zinc-800 text-[10px] text-zinc-300 font-semibold rounded-lg px-2 py-1 focus:outline-none focus:border-emerald-500/40 cursor-pointer disabled:opacity-40",children:[s.jsx("option",{value:6e4,children:"1 Dakika"}),s.jsx("option",{value:3e5,children:"5 Dakika"}),s.jsx("option",{value:9e5,children:"15 Dakika"}),s.jsx("option",{value:36e5,children:"1 Saat"})]})]})]},N.id))})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(C3,{size:16,className:"text-cyan-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"İşlem Geçmişi / Trade History"})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs text-gray-400",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-white/5 text-gray-600 font-bold uppercase tracking-wider text-[10px]",children:[s.jsx("th",{className:"py-2.5",children:"Parite / Pair"}),s.jsx("th",{className:"py-2.5",children:"Yön / Side"}),s.jsx("th",{className:"py-2.5",children:"Tarih / Date"}),s.jsx("th",{className:"py-2.5 text-right",children:"Miktar / Amount"})]})}),s.jsx("tbody",{className:"divide-y divide-white/5 font-mono text-[11px]",children:m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"py-6 text-center text-zinc-600 italic",children:"İşlem geçmişi bulunamadı."})}):m.map(N=>{const _=String(N.side).toUpperCase()==="BUY",L=new Date(N.datetime).toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})+" "+new Date(N.datetime).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});return s.jsxs("tr",{className:"hover:bg-white/2 transition-colors",children:[s.jsx("td",{className:"py-3 font-semibold text-white/80",children:N.symbol}),s.jsx("td",{className:"py-3",children:s.jsx("span",{className:`px-1.5 py-0.5 rounded-md font-bold text-[9px] ${_?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:N.side.toUpperCase()})}),s.jsx("td",{className:"py-3 text-gray-500",children:L}),s.jsxs("td",{className:`py-3 text-right font-bold ${_?"text-emerald-400":"text-red-400"}`,children:[_?"+":"-",N.amount.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})]})]},N.id)})})]})})]})]})]})}function X0(e){return e>=90?"#ef4444":e>=70?"#f97316":"#22c55e"}function ma(e){return e==="critical"?"#ef4444":e==="warning"?"#f97316":"#60a5fa"}function KP(){const{t:e,locale:t}=yt(),n=e.systemHealth,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useCallback(()=>o(null),[]);u.useEffect(()=>{window.dispatchEvent(new CustomEvent("mustb:safeMode",{detail:{active:(r==null?void 0:r.safeMode)??!1}}))},[r==null?void 0:r.safeMode]),u.useEffect(()=>{const f=pe();return f.on("systemStats",m=>a(m)),f.on("systemHealth",m=>{if(o(m),c(!0),m.level!=="critical"){const b=m.level==="info"?6e3:12e3;setTimeout(()=>o(null),b)}}),()=>{f.off("systemStats"),f.off("systemHealth")}},[]);const h=(r==null?void 0:r.cpu)??0,p=(r==null?void 0:r.ram)??0;return s.jsxs("div",{className:"relative flex items-center",children:[s.jsxs("button",{onClick:()=>i&&c(f=>!f),className:"flex items-center gap-1.5 select-none transition-all rounded-md",style:{cursor:i?"pointer":"default"},title:i?i.message:n.title,children:[i?s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 animate-pulse",style:{background:ma(i.level)}}):s.jsx(tn,{size:12,className:"text-orange-400/70"}),r&&s.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"CPU"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${h}%`,background:X0(h)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[h,"%"]}),s.jsx("span",{className:"w-px h-3 bg-white/10"}),s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"RAM"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${p}%`,background:X0(p)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[p,"%"]}),r.liteMode&&!r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-orange-500/20 text-orange-400 ml-0.5",children:n.lite}),r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-red-500/20 text-red-400 ml-0.5",children:n.safe})]}),!r&&s.jsx("span",{className:"text-[10px] font-semibold hidden sm:inline text-white/35",children:n.title})]}),s.jsx(ae,{children:l&&i&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.2,ease:"easeOut"},className:"absolute top-full right-0 mt-2 w-72 z-[200] rounded-2xl overflow-hidden",style:{background:"rgba(20,8,2,0.88)",border:`1px solid ${ma(i.level)}44`,backdropFilter:"blur(20px)",boxShadow:`0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-start justify-between px-4 pt-3 pb-2",style:{borderBottom:`1px solid ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ws,{size:13,style:{color:ma(i.level)}}),s.jsxs("span",{className:"text-[12px] font-bold text-white/90 capitalize",children:[n[i.level]??i.level," — ",n.kinds[i.kind]??i.kind]})]}),s.jsx("button",{onClick:d,className:"text-white/30 hover:text-white/70 transition-colors",children:s.jsx(ze,{size:13})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:n.alerts[i.kind]??i.message}),s.jsx("p",{className:"text-[11px] text-white/45 leading-relaxed italic",children:n.recommendations[i.kind]??i.recommendation})]}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(i.ts).toLocaleTimeString()})})]},"health-popover")})]})}function GP(e){return`${Math.round(e*100)}%`}const Q0={skill:{label:"Skill",icon:Ue,color:"text-orange-400"},conversation:{label:"Conversation",icon:Hs,color:"text-blue-400"},workspace:{label:"Workspace",icon:Ln,color:"text-green-400"},custom:{label:"Custom",icon:nn,color:"text-gray-400"}};function qP(){const{t:e}=yt(),t=e.panels.memory,[n,r]=u.useState(""),[a,i]=u.useState([]),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(null),[f,m]=u.useState(null),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useCallback(async k=>{const S=k.trim();if(S){d(!0),i([]);try{const C=await U(`/api/memory/search?q=${encodeURIComponent(S)}&limit=10`);if(C.ok){const A=await C.json();i(A.results??[])}}catch{}d(!1)}},[]),g=k=>{k.key==="Enter"&&x(n)},w=u.useCallback(async()=>{try{const k=await U("/api/memory/stats");k.ok&&l(await k.json())}catch{}},[]),j=async k=>{p(k),m(null);try{const S=k==="clear"?await U("/api/memory/clear-index",{method:"DELETE"}):await U(`/api/memory/index-${k}`,{method:"POST"});if(S.ok){const C=await S.json(),A=k==="clear"?t.indexCleared:`${t.indexed} ${C.indexed??0} ${k==="skills"?t.skills:t.files}`;m({ok:!0,msg:A}),w(),k==="clear"&&i([])}else m({ok:!1,msg:t.opFailed})}catch{m({ok:!1,msg:t.reqError})}p(null),setTimeout(()=>m(null),4e3)};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zt,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),o&&s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[o.items.toLocaleString()," ",t.vectors]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>{y(k=>!k),o||w()},className:`text-gray-600 hover:text-gray-400 transition-colors ${b?"text-orange-400":""}`,title:t.indexControls,children:s.jsx(K3,{size:13})}),s.jsx("button",{onClick:w,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refreshStats,children:s.jsx(ge,{size:13})})]})]}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:[s.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 uppercase tracking-widest font-bold shrink-0",children:t.indexLabel}),["skills","workspace"].map(k=>s.jsxs("button",{onClick:()=>j(k),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/6 text-[11px] text-gray-400 hover:text-gray-200 hover:bg-white/8 transition-all disabled:opacity-40 capitalize",children:[h===k?s.jsx(ne,{size:10,className:"animate-spin"}):k==="skills"?s.jsx(Ue,{size:10}):s.jsx(Ln,{size:10}),k]},k)),s.jsxs("button",{onClick:()=>j("clear"),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-red-500/8 border border-red-500/15 text-[11px] text-red-400 hover:bg-red-500/15 transition-all disabled:opacity-40 ml-auto",children:[h==="clear"?s.jsx(ne,{size:10,className:"animate-spin"}):s.jsx(ys,{size:10}),t.clearIndex]})]}),s.jsx(ae,{children:f&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 pb-3 text-[11px] font-medium ${f.ok?"text-green-400":"text-red-400"}`,children:[f.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),f.msg]})})]})}),s.jsxs("div",{className:"px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-white/4 border border-white/8 focus-within:border-orange-500/30 transition-colors",children:[s.jsx(fn,{size:13,className:"text-gray-600 shrink-0"}),s.jsx("input",{ref:v,value:n,onChange:k=>r(k.target.value),onKeyDown:g,placeholder:t.searchPlaceholder,className:"flex-1 bg-transparent text-[13px] text-gray-200 outline-none placeholder-gray-700"}),c?s.jsx(ne,{size:13,className:"text-orange-400 animate-spin shrink-0"}):s.jsx("button",{onClick:()=>x(n),disabled:!n.trim(),className:"text-[10px] px-2 py-0.5 rounded-lg bg-orange-500/12 text-orange-400 font-semibold hover:bg-orange-500/22 border border-orange-500/20 transition-all disabled:opacity-30",children:"⌘↵"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 mt-1.5 ml-1",children:t.searchHint})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:[a.length===0&&!c&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Zt,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:n.trim()?t.emptyNoResults:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1 max-w-xs leading-relaxed",children:n.trim()?t.emptyNoResultsHint:t.emptyHint})]}),a.map((k,S)=>{const C=Q0[k.metadata.source]??Q0.custom,A=C.icon;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:S*.04},className:"rounded-2xl border border-white/6 bg-[#0c0f18] p-4 hover:border-white/12 transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(A,{size:11,className:`${C.color} shrink-0`}),s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:k.metadata.title})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full border ${k.score>=.85?"bg-green-500/10 border-green-500/20 text-green-400":k.score>=.65?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/4 border-white/6 text-gray-500"}`,children:GP(k.score)}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-white/4 border border-white/6 font-medium ${C.color}`,children:C.label})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-3 mb-2",children:k.text}),k.metadata.tags&&k.metadata.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:k.metadata.tags.map((N,_)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:N},_))}),s.jsx("div",{className:"mt-2 h-0.5 bg-white/4 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-orange-600 to-amber-400",style:{width:`${k.score*100}%`}})})]},S)})]})]})}const YP={node:en,python:wn},XP={node:"text-green-400",python:"text-blue-400"};function QP(){const{t:e}=yt(),t=e.panels.plugins,[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),[f,m]=u.useState(""),[b,y]=u.useState(""),[v,x]=u.useState("node"),[g,w]=u.useState(""),[j,k]=u.useState(!1),S=(_,L)=>{d({ok:_,msg:L}),setTimeout(()=>d(null),4e3)},C=u.useCallback(async()=>{i(!0);try{const _=await U("/api/plugins/list");if(_.ok){const L=await _.json();r(L.plugins??[])}}catch{}i(!1)},[]);u.useEffect(()=>{C()},[C]);const A=async(_,L)=>{l(_);try{(await U(L?"/api/plugins/stop":"/api/plugins/run",{method:"POST",body:JSON.stringify({name:_})})).ok?(S(!0,L?`${_} stopped`:`${_} launched`),await C()):S(!1,t.opFailed)}catch{S(!1,t.reqError)}l(null)},N=async()=>{if(!(!f.trim()||!b.trim())){k(!0);try{(await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:f.trim(),goal:b.trim(),lang:v,context:g.trim()||void 0})})).ok?(S(!0,`Plugin "${f}" created`),m(""),y(""),w(""),p(!1),await C()):S(!1,t.buildFailed)}catch{S(!1,t.reqError)}k(!1)}};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[n.length," ",t.installed]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:C,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refresh,children:s.jsx(ge,{size:13,className:a?"animate-spin":""})}),s.jsxs("button",{onClick:()=>p(_=>!_),className:`flex items-center gap-1 text-[10px] px-2.5 py-1 rounded-lg border font-semibold transition-all ${h?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500 hover:text-gray-300"}`,children:[s.jsx(Fl,{size:10}),t.newPlugin]})]})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 py-2 text-[11px] font-medium shrink-0 ${c.ok?"text-green-400":"text-red-400"}`,children:[c.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),c.msg]})}),s.jsx(ae,{children:h&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:s.jsxs("div",{className:"px-6 py-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:t.buildTitle}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("input",{value:f,onChange:_=>m(_.target.value),placeholder:t.namePlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:b,onChange:_=>y(_.target.value),placeholder:t.goalPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:g,onChange:_=>w(_.target.value),placeholder:t.contextPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("div",{className:"flex gap-2",children:["node","python"].map(_=>s.jsx("button",{onClick:()=>x(_),className:`flex-1 py-1.5 rounded-lg border text-[11px] font-semibold transition-all capitalize ${v===_?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500"}`,children:_},_))}),s.jsxs("button",{onClick:N,disabled:j||!f.trim()||!b.trim(),className:"flex items-center justify-center gap-1.5 py-2 rounded-lg bg-orange-500/12 border border-orange-500/20 text-orange-400 text-[11px] font-bold hover:bg-orange-500/20 transition-all disabled:opacity-40",children:[j?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(Ue,{size:11}),t.generatePlugin]})]})]})})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-2",children:[n.length===0&&!a&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(qr,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1",children:t.emptyHint})]}),n.map((_,L)=>{const B=YP[_.lang]??en,M=o===_.name;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:L*.04},className:`flex items-center gap-3 p-3 rounded-2xl border transition-all ${_.running?"bg-green-500/5 border-green-500/15 hover:border-green-500/25":"bg-[#0c0f18] border-white/6 hover:border-white/12"}`,children:[s.jsx(B,{size:13,className:XP[_.lang]??"text-gray-400"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:_.name}),s.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:_.filename})]}),_.running&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-green-500/12 border border-green-500/20 text-green-400 font-bold",children:t.running}),s.jsxs("button",{disabled:M,onClick:()=>A(_.name,_.running),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-[10px] font-bold transition-all disabled:opacity-40 ${_.running?"bg-red-500/8 border-red-500/15 text-red-400 hover:bg-red-500/15":"bg-green-500/8 border-green-500/15 text-green-400 hover:bg-green-500/15"}`,children:[M?s.jsx(ne,{size:10,className:"animate-spin"}):_.running?s.jsx($l,{size:10}):s.jsx(gs,{size:10}),_.running?t.stop:t.run]})]},_.name)})]})]})}function JP(e){if(!e)return"Never";try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function ZP(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function e6({skill:e}){const[t,n]=u.useState(!1),[r,a]=u.useState(!1),[i,o]=u.useState(""),[l,c]=u.useState(!1),d=async()=>{if(!l){c(!0);return}if(i.trim()){n(!0);try{await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:e.id,params:{goal:i.trim(),_autoRun:!0}})}),a(!0),c(!1),o(""),setTimeout(()=>a(!1),3e3)}catch{}n(!1)}},h=(e.requires.bins??[]).length>0,p=(e.requires.config??[]).length>0;return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-white/6 bg-[#0c0f18] hover:border-white/12 transition-all",children:s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base leading-none mt-0.5 shrink-0",children:e.emoji??"⚡"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[12px] font-bold text-gray-200 truncate capitalize",children:e.name})}),e.hasScripts&&s.jsx(Mn,{size:10,className:"text-gray-700 shrink-0 mt-0.5"})]}),s.jsx("p",{className:"text-[10px] text-gray-500 leading-relaxed line-clamp-2 mb-2 ml-6",children:e.description}),(h||p)&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-2 ml-6",children:[(e.requires.bins??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-500/8 border border-blue-500/15 text-blue-400 font-mono",children:["bin:",f]},f)),(e.requires.config??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-purple-500/8 border border-purple-500/15 text-purple-400 font-mono",children:["cfg:",f]},f))]}),s.jsx(ae,{children:l&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden mb-2",children:s.jsx("input",{autoFocus:!0,value:i,onChange:f=>o(f.target.value),onKeyDown:f=>{f.key==="Enter"&&d(),f.key==="Escape"&&(c(!1),o(""))},placeholder:`Goal for ${e.name}…`,className:"w-full px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/10 text-[11px] text-gray-200 placeholder-gray-700 outline-none focus:border-orange-500/30 transition-colors"})})}),s.jsxs("div",{className:"flex items-center justify-end gap-1 ml-6",children:[l&&s.jsx("button",{onClick:()=>{c(!1),o("")},className:"text-[10px] px-2 py-1 rounded-lg bg-white/4 text-gray-600 hover:text-gray-400 transition-colors",children:"Cancel"}),s.jsx("button",{onClick:d,disabled:t||l&&!i.trim(),className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold border transition-all disabled:opacity-40 ${r?"bg-green-500/10 border-green-500/20 text-green-400":"bg-orange-500/8 border-orange-500/15 text-orange-400 hover:bg-orange-500/15"}`,children:t?s.jsx(ne,{size:9,className:"animate-spin"}):r?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:9})," Sent"]}):l?s.jsxs(s.Fragment,{children:[s.jsx(gn,{size:9})," Run"]}):s.jsxs(s.Fragment,{children:[s.jsx(H3,{size:9})," Use"]})})]})]})})}function t6(){const{t:e}=yt(),t=e.panels.skills,[n,r]=u.useState("saved"),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState("idle"),[f,m]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState([]),[g,w]=u.useState(!1),[j,k]=u.useState(""),S=u.useCallback(async()=>{l(!0);try{const L=await U("/api/skills/list");if(L.ok){const B=await L.json();i(B.skills??[])}}catch{}l(!1)},[]),C=u.useCallback(async()=>{w(!0);try{const L=await U("/api/skills/catalog");if(L.ok){const B=await L.json();x(B.skills??[])}}catch{}w(!1)},[]);u.useEffect(()=>{S()},[S]),u.useEffect(()=>{n==="library"&&v.length===0&&C()},[n,v.length,C]),u.useEffect(()=>{const L=pe(),B=M=>{M.type==="skillRunStart"&&M.skillId&&(d(M.skillId),p("running")),M.type==="planFinish"&&(p("done"),d(null),S(),setTimeout(()=>p("idle"),2500))};return L.on("agentUpdate",B),()=>{L.off("agentUpdate",B)}},[S]);const A=async L=>{if(!c){d(L.id),p("running");try{const B=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:L.id})});if(!B.ok)throw new Error(`HTTP ${B.status}`)}catch{p("error"),d(null),setTimeout(()=>p("idle"),3e3)}}},N=async L=>{m(L);try{await U(`/api/skills/${L}`,{method:"DELETE"}),i(B=>B.filter(M=>M.id!==L))}catch{}m(null),y(null)},_=j.trim()?v.filter(L=>L.name.toLowerCase().includes(j.toLowerCase())||L.description.toLowerCase().includes(j.toLowerCase())):v;return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dl,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-white/4 rounded-lg p-0.5",children:[s.jsxs("button",{onClick:()=>r("saved"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="saved"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Ue,{size:9}),"Saved",a.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:a.length})]}),s.jsxs("button",{onClick:()=>r("library"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="library"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Lc,{size:9}),"Library",v.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:v.length})]})]}),s.jsx("button",{onClick:n==="saved"?S:C,disabled:n==="saved"?o:g,className:"text-gray-600 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:13,className:(n==="saved"?o:g)?"animate-spin":""})})]}),n==="saved"&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:h!=="idle"&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:`px-6 py-2 border-b flex items-center gap-2 text-xs font-medium ${h==="running"?"bg-orange-500/8 border-orange-500/15 text-orange-400":h==="done"?"bg-green-500/8 border-green-500/15 text-green-400":"bg-red-500/8 border-red-500/15 text-red-400"}`,children:[h==="running"&&s.jsx(ne,{size:12,className:"animate-spin"}),h==="done"&&s.jsx(Fe,{size:12}),h==="error"&&s.jsx(Ke,{size:12}),h==="running"?t.runningStatus:h==="done"?t.completedStatus:t.failedStatus]})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:o&&a.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2",children:[s.jsx(ne,{size:13,className:"animate-spin"})," ",t.loading]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Ue,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsxs("p",{className:"text-xs text-gray-700 mt-1 max-w-xs",children:[t.emptyHint," ",s.jsx("span",{className:"text-orange-400 font-medium",children:t.saveAsSkill})," ",t.emptyHint2]}),s.jsxs("button",{onClick:()=>r("library"),className:"mt-4 flex items-center gap-1.5 text-[11px] text-orange-400 hover:text-orange-300 transition-colors",children:[s.jsx(Lc,{size:11})," Browse skill library"]})]}):a.map((L,B)=>{const M=c===L.id&&h==="running",$=c===L.id&&h==="done",R=f===L.id;return s.jsx(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:B*.04},className:`rounded-2xl border bg-[#0c0f18] transition-all ${M?"border-orange-500/30 shadow-[0_0_12px_rgba(234,88,12,0.12)]":$?"border-green-500/20":"border-white/6 hover:border-white/12"}`,children:s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ue,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}),s.jsx("p",{className:"text-[13px] font-bold text-white truncate",children:L.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-600 shrink-0 font-mono",children:[s.jsx(rv,{size:9}),L.runCount,"×"]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed mb-2 line-clamp-2",children:L.goal}),L.steps.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[L.steps.slice(0,4).map((z,P)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:z.tool??"step"},P)),L.steps.length>4&&s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:["+",L.steps.length-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-700",children:[s.jsx(Lt,{size:9}),s.jsx("span",{children:ZP(L.savedAt)}),L.lastRunAt&&s.jsxs("span",{className:"text-gray-800",children:["· ",t.lastRun," ",JP(L.lastRunAt)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[b===L.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] text-red-400",children:t.deleteConfirm}),s.jsx("button",{onClick:()=>N(L.id),disabled:R,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-colors",children:R?"…":t.yes}),s.jsx("button",{onClick:()=>y(null),className:"text-[10px] px-2 py-0.5 rounded bg-white/5 text-gray-500 hover:bg-white/8",children:t.no})]}):s.jsx("button",{onClick:()=>y(L.id),className:"p-1.5 rounded-lg text-gray-700 hover:text-red-400 hover:bg-red-500/8 transition-all",title:"Delete skill",children:s.jsx(ys,{size:12})}),s.jsx("button",{onClick:()=>A(L),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${M?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":$?"bg-green-500/12 text-green-400 border border-green-500/20":"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 hover:border-orange-500/35 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:M?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:11,className:"animate-spin"})," ",t.runningBtn]}):$?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:11})," ",t.doneBtn]}):s.jsxs(s.Fragment,{children:[s.jsx(gs,{size:11})," ",t.runBtn]})})]})]})]})},L.id)})})]}),n==="library"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2.5 border-b border-white/5 shrink-0",children:s.jsx("input",{value:j,onChange:L=>k(L.target.value),placeholder:"Search skills…",className:"w-full px-3 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-300 placeholder-gray-700 outline-none focus:border-orange-500/25 transition-colors"})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-3 grid grid-cols-1 gap-2",children:g&&v.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2 col-span-1",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading skill library…"]}):_.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center col-span-1",children:[s.jsx(Lc,{size:36,className:"text-gray-700 mb-3"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:"No skills found"}),j&&s.jsx("button",{onClick:()=>k(""),className:"mt-2 text-[11px] text-orange-400 hover:text-orange-300",children:"Clear filter"})]}):_.map((L,B)=>s.jsx(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:Math.min(B*.02,.4)},children:s.jsx(e6,{skill:L})},L.id))}),v.length>0&&s.jsx("div",{className:"px-4 py-2 border-t border-white/5 shrink-0 flex items-center gap-1.5",children:s.jsxs("span",{className:"text-[10px] text-gray-700 font-mono",children:[_.length," / ",v.length," skills"]})})]})]})}const n6={html:o0,htm:o0,json:wn,js:wn,ts:wn,tsx:wn,jsx:wn};function s6(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function r6(e){try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function a6(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,t=>{let n="color:#86efac";return/^"/.test(t)&&(n=/:$/.test(t)?"color:#93c5fd":"color:#fca5a5"),/true|false/.test(t)&&(n="color:#f97316"),/null/.test(t)&&(n="color:#6b7280"),`<span style="${n}">${t}</span>`})}function i6(){const[e,t]=u.useState([]),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useCallback(async()=>{p(!0);try{const v=await U("/api/workspace/files");if(v.ok){const x=await v.json();t(x.files??[])}}catch{}p(!1)},[]);u.useEffect(()=>{f()},[f]);const m=async v=>{r(v),i(null),d(null),l(!0);try{const x=await U(`/api/workspace/file?p=${encodeURIComponent(v.rel)}`);if(!x.ok)throw new Error(`HTTP ${x.status}`);const g=await x.json();i(g.content+(g.truncated?`
|
|
840
840
|
|
|
841
841
|
[… file truncated at 1.5 MB …]`:""))}catch(x){d(x instanceof Error?x.message:"Failed to load file")}l(!1)},b=v=>{const x=n6[v]??nn;return s.jsx(x,{size:12,className:"shrink-0 text-gray-500"})},y=()=>{if(o)return s.jsxs("div",{className:"flex items-center justify-center h-full text-gray-600 text-xs gap-2",children:[s.jsx(ge,{size:14,className:"animate-spin"})," Loading…"]});if(c)return s.jsxs("div",{className:"flex items-center justify-center h-full gap-2 text-red-400 text-xs",children:[s.jsx(Ke,{size:14})," ",c]});if(!a)return s.jsx("div",{className:"flex items-center justify-center h-full text-gray-700 text-xs",children:"Select a file to preview"});const v=(n==null?void 0:n.ext)??"";if(v==="html"||v==="htm")return s.jsx("iframe",{srcDoc:a,sandbox:"allow-scripts",className:"w-full h-full border-0 bg-white",title:"workspace-preview"});const x=v==="json"?a6(a):a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return s.jsx("pre",{className:"w-full h-full overflow-auto p-4 text-[11px] font-mono text-gray-300 leading-relaxed whitespace-pre-wrap break-words bg-transparent",dangerouslySetInnerHTML:{__html:x}})};return s.jsxs("div",{className:"flex h-full overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"w-52 shrink-0 border-r border-white/5 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:[s.jsx(Ln,{size:11,className:"text-orange-400"}),"Workspace"]}),s.jsx("button",{onClick:f,disabled:h,className:"text-gray-700 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:11,className:h?"animate-spin":""})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto py-1 scrollbar-hide",children:e.length===0?s.jsx("p",{className:"text-[10px] text-gray-700 text-center py-6",children:"No files in workspace yet"}):e.map(v=>s.jsxs("button",{onClick:()=>m(v),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors group ${(n==null?void 0:n.rel)===v.rel?"bg-orange-500/10 text-orange-300":"text-gray-500 hover:text-gray-300 hover:bg-white/3"}`,children:[b(v.ext),s.jsx("span",{className:"text-[11px] truncate flex-1",children:v.name}),s.jsx(gn,{size:10,className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity ${(n==null?void 0:n.rel)===v.rel?"opacity-100 text-orange-400":""}`})]},v.rel))})]}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5 bg-white/[0.015] shrink-0",children:[s.jsx(ae,{mode:"wait",children:n?s.jsxs(V.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},exit:{opacity:0},className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-[11px] font-mono text-gray-400 truncate",children:n.rel}),s.jsxs("span",{className:"text-[9px] text-gray-700 shrink-0",children:[s6(n.size)," · ",r6(n.mtime)]})]},n.rel):s.jsx("span",{className:"text-[11px] text-gray-700",children:"No file selected"})}),n&&(n.ext==="html"||n.ext==="htm")&&s.jsx("button",{onClick:()=>window.open(`/api/workspace/file?p=${encodeURIComponent(n.rel)}&raw=1`,"_blank"),className:"text-gray-600 hover:text-gray-300 transition-colors shrink-0 ml-2",title:"Open in new tab",children:s.jsx(Kr,{size:12})})]}),s.jsx("div",{className:"flex-1 overflow-hidden relative",children:y()})]})]})}const co={button:"rgba(234,88,12,0.7)",input:"rgba(59,130,246,0.7)",image:"rgba(168,85,247,0.6)",unknown:"rgba(255,255,255,0.3)"};function o6(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{if(!n||!c.current)return;const h=c.current,p=h.getContext("2d");if(!p)return;const f=new Image;f.onload=()=>{var m;if(h.width=f.width,h.height=f.height,p.drawImage(f,0,0),(m=n.elements)!=null&&m.length)for(const b of n.elements)p.strokeStyle=co[b.type]??co.unknown,p.lineWidth=Math.max(2,Math.round(f.width/400)),p.strokeRect(b.x,b.y,b.width,b.height),p.fillStyle=co[b.type]??co.unknown,p.font=`${Math.max(10,Math.round(f.width/120))}px monospace`,p.fillText(b.type,b.x+4,b.y+14)},f.src=`data:image/png;base64,${n.base64}`},[n]),u.useEffect(()=>{const h=pe();return h.on("agentUpdate",p=>{p.type==="SCREEN_CAPTURE_START"?t(!0):p.type==="SCREEN_CAPTURED"&&(t(!1),r({base64:p.base64,width:p.width,height:p.height,source:p.source,elements:p.elements}))}),()=>{h.off("agentUpdate")}},[]);const d=async()=>{if(!e){try{const h=await U("/api/system/vision-guidance");if(h.ok){const p=await h.json();p.warn&&p.message&&i(p.message)}}catch{}await U("/api/system/screenshot",{method:"POST",body:JSON.stringify({detect:!0})}).catch(()=>{})}};return s.jsxs("div",{className:"border border-white/5 rounded-2xl bg-[#0a0d16]/60 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Us,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-xs font-bold text-gray-400 tracking-widest uppercase",children:"Live Sight"}),n&&s.jsxs("span",{className:"text-[10px] text-gray-600 font-mono",children:[n.width,"×",n.height," · ",n.source]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[n&&s.jsx("button",{onClick:()=>l(h=>!h),className:"text-gray-600 hover:text-gray-300 transition-colors",title:o?"Collapse":"Expand",children:o?s.jsx(np,{size:13}):s.jsx(Us,{size:13})}),s.jsxs("button",{onClick:d,disabled:e,className:`flex items-center gap-1.5 px-3 py-1 rounded-lg text-xs font-medium transition-all ${e?"text-orange-400 bg-orange-500/10 animate-pulse cursor-not-allowed":"text-gray-500 hover:text-orange-400 hover:bg-orange-500/10 border border-white/5"}`,children:[s.jsx(ui,{size:11}),e?"Scanning…":"Capture"]})]})]}),s.jsx(ae,{children:a&&s.jsxs(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"px-4 py-3 bg-amber-500/8 border-b border-amber-500/15",children:[s.jsx("p",{className:"text-[11px] text-amber-400 leading-relaxed",children:a}),s.jsx("button",{onClick:()=>i(null),className:"text-[10px] text-amber-600 hover:text-amber-400 mt-1 transition-colors",children:"Dismiss"})]})}),s.jsx(ae,{children:n&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},className:`relative overflow-hidden transition-all duration-300 ${o?"max-h-[500px]":"max-h-[140px]"}`,children:[s.jsx("canvas",{ref:c,className:"w-full object-contain",style:{imageRendering:"auto"}}),n.elements&&n.elements.length>0&&s.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-0.5 bg-black/70 rounded-md text-[10px] font-mono text-orange-400 border border-orange-500/20",children:[n.elements.length," elements"]})]})}),!n&&!e&&s.jsx("div",{className:"flex items-center justify-center py-8 text-gray-700 text-xs",children:"Press Capture to see what Must-b sees"}),e&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-orange-400 text-xs animate-pulse",children:[s.jsx(ui,{size:14,className:"animate-spin"}),"Scanning screen…"]})]})}const l6=4,J0=1e4;function c6(){const[e,t]=u.useState([]),n=u.useId(),r=u.useCallback(a=>{t(i=>i.filter(o=>o.id!==a))},[]);return u.useEffect(()=>{const a=pe();return a.on("projectInsight",i=>{const o={id:`${n}-${i.ts}-${Math.random().toString(36).slice(2,7)}`,message:i.message,filePath:i.filePath,ts:i.ts};t(l=>[o,...l].slice(0,l6)),setTimeout(()=>r(o.id),J0)}),()=>{a.off("projectInsight")}},[r,n]),e.length===0?null:s.jsx("div",{className:"fixed bottom-6 right-5 z-[150] flex flex-col gap-2.5 items-end",style:{maxWidth:"340px",pointerEvents:"none"},children:s.jsx(ae,{mode:"popLayout",children:e.map((a,i)=>s.jsx(V.div,{layout:!0,initial:{opacity:0,x:60,scale:.94},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:60,scale:.92},transition:{type:"spring",stiffness:340,damping:28},style:{pointerEvents:"auto",opacity:i===0?1:1-i*.12},className:"w-full",children:s.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"rgba(15,6,1,0.82)",border:"1px solid rgba(249,115,22,0.28)",backdropFilter:"blur(24px)",boxShadow:"0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 pt-3 pb-2",style:{borderBottom:"1px solid rgba(249,115,22,0.12)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"rgba(249,115,22,0.18)",border:"1px solid rgba(249,115,22,0.30)"},children:s.jsx(mn,{size:10,className:"text-orange-400"})}),s.jsx("span",{className:"text-[11px] font-semibold text-orange-300/80 tracking-wide uppercase",children:"Must-b fısıldıyor"})]}),s.jsx("button",{onClick:()=>r(a.id),className:"text-white/25 hover:text-white/60 transition-colors",children:s.jsx(ze,{size:12})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:a.message}),a.filePath&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(nn,{size:10,className:"text-white/25 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-white/35 truncate",children:a.filePath.replace(/\\/g,"/")})]})]}),s.jsx("div",{className:"h-px w-full",style:{background:"rgba(249,115,22,0.10)"},children:s.jsx(V.div,{className:"h-full",style:{background:"rgba(249,115,22,0.45)"},initial:{width:"100%"},animate:{width:"0%"},transition:{duration:J0/1e3,ease:"linear"}})})]})},a.id))})})}const d6=6e3,u6=/https?:\/\/[^\s"'>)]+/,h6=new Set(["browser_navigate","browser_click","browser_type","browser_scroll","browser_wait","browser_perceive","browser_extract","browser_snapshot","browser_screenshot","web_fetch","web-fetch","web-search"]);function p6(e){const t=e.match(u6);return t?t[0].replace(/[.,;)]+$/,""):null}function f6(e,t=52){try{const n=new URL(e),r=n.hostname.replace(/^www\./,""),a=n.pathname.length>1?n.pathname:"",i=r+a;return i.length>t?i.slice(0,t-1)+"…":i}catch{return e.length>t?e.slice(0,t-1)+"…":e}}function m6(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useRef(null),m=u.useRef(!1),b=u.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{r(!1),t(null),l(null),d(null),m.current=!1},d6)},[]);return u.useEffect(()=>{const y=pe(),v=x=>{if(x.type==="shadowFrame"&&typeof x.slot!="number"||x.type==="ghostFrame"){const g=x.base64;if(!g)return;t(g),p(!1),m.current||(m.current=!0,r(!0),i(!1)),b();return}if(x.type==="shadowToggle"){!x.enabled&&typeof x.slot!="number"?(r(!1),t(null),l(null),d(null),m.current=!1,f.current&&clearTimeout(f.current)):x.enabled&&typeof x.slot!="number"&&(p(!0),r(!0),i(!1),m.current=!0);return}if(x.type==="ghostNav"){const g=x.url;g&&g!=="about:blank"&&l(g);return}if(x.type==="stepStart"){const g=x.step,w=(g==null?void 0:g.description)??"",j=(g==null?void 0:g.tool)??"";if(h6.has(j)||/navigate|click|type|browse|fetch|search/i.test(w)){const k=w.length>72?w.slice(0,71)+"…":w;d(k);const S=p6(w);S&&l(S)}return}if(x.type==="stepFinish"){d(null);return}if(x.type==="planFinish"){d(null),b();return}};return y.on("agentUpdate",v),()=>{y.off("agentUpdate",v),f.current&&clearTimeout(f.current)}},[b]),s.jsx(ae,{children:n&&s.jsx(V.div,{initial:{opacity:0,y:24,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.92},transition:{type:"spring",stiffness:340,damping:30},className:"fixed bottom-6 left-5 z-[140] flex flex-col",style:{width:a?"auto":"320px",pointerEvents:"auto"},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden flex flex-col",style:{background:"rgba(10,4,1,0.88)",border:"1px solid rgba(249,115,22,0.28)",backdropFilter:"blur(24px) saturate(180%)",boxShadow:"0 12px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 select-none flex-shrink-0",style:{borderBottom:a?"none":"1px solid rgba(249,115,22,0.12)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"relative flex-shrink-0",children:[s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-500"}),s.jsx("span",{className:"absolute inset-0 rounded-full bg-orange-500 animate-ping opacity-60"})]}),s.jsx(Ge,{size:11,className:"text-orange-400/70"}),s.jsx("span",{className:"text-[11px] font-semibold text-white/70 tracking-wide",children:"Live Browser"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>i(y=>!y),className:"w-5 h-5 rounded-full flex items-center justify-center text-white/25 hover:text-white/60 hover:bg-white/8 transition-all",title:a?"Expand":"Minimize",children:a?s.jsx(A3,{size:10}):s.jsx(R3,{size:10})}),s.jsx("button",{onClick:()=>{r(!1),m.current=!1},className:"w-5 h-5 rounded-full flex items-center justify-center text-white/25 hover:text-white/60 hover:bg-white/8 transition-all",title:"Close",children:s.jsx(ze,{size:10})})]})]}),s.jsx(ae,{children:!a&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22},className:"overflow-hidden",children:[s.jsxs("div",{className:"relative w-full overflow-hidden",style:{aspectRatio:"16 / 10",background:"#08030100"},children:[h&&!e?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx(ne,{size:20,className:"text-orange-400/50 animate-spin"})}):e?s.jsx("img",{src:`data:image/jpeg;base64,${e}`,alt:"Browser preview",className:"w-full h-full object-cover",style:{imageRendering:"auto"}}):s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",children:[s.jsx(Ge,{size:22,className:"text-orange-400/20"}),s.jsx("span",{className:"text-[11px] text-white/20",children:"Browser waiting…"})]}),e&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 4px)"}})]}),o&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderTop:"1px solid rgba(249,115,22,0.10)"},children:[s.jsx(Ge,{size:9,className:"text-orange-400/40 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-white/40 truncate flex-1",children:f6(o)})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.18},className:"px-3 py-2 flex items-start gap-2",style:{borderTop:"1px solid rgba(249,115,22,0.08)"},children:[s.jsx("div",{className:"flex items-center gap-0.5 mt-1 flex-shrink-0",children:[0,1,2].map(y=>s.jsx("span",{className:"block w-1 h-1 rounded-full bg-orange-400/60 animate-bounce",style:{animationDelay:`${y*.15}s`}},y))}),s.jsx("p",{className:"text-[10.5px] text-white/50 leading-snug line-clamp-2",children:c})]},"action-bar")})]},"pip-content")})]})},"live-browser-pip")})}function x6({url:e}){const[t,n]=u.useState(!1),r=u.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return s.jsxs("button",{onClick:r,title:"Copy login URL to clipboard",className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-semibold
|
|
842
842
|
transition-all duration-150 shrink-0
|
|
@@ -934,7 +934,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
934
934
|
disabled:opacity-50 disabled:cursor-not-allowed`,children:[s.jsx("span",{className:`w-5 h-5 flex items-center justify-center rounded-lg
|
|
935
935
|
bg-white/5 text-white/28 group-hover:text-red-400
|
|
936
936
|
group-hover:bg-red-500/10 transition-all shrink-0`,children:s.jsx(ip,{size:12})}),s.jsx("span",{className:`text-[12px] font-medium text-white/45
|
|
937
|
-
group-hover:text-red-400 transition-colors`,children:i?"Signing out…":"Sign Out"})]})]}),s.jsx("div",{className:"px-4 py-2 border-t border-white/[0.05]",children:s.jsx("p",{className:"text-[8.5px] text-white/14 text-center",children:"must-b.com · Secure connection"})})]},"profile-panel")})]})]})}const w6=4,k6=3e3;function j6(){return s.jsxs(V.div,{className:"fixed inset-0 z-[200] pointer-events-none flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[s.jsx("div",{className:"absolute inset-0 bg-black/35"}),Array.from({length:w6}).map((e,t)=>s.jsx(V.span,{className:"absolute rounded-full",style:{border:"1.5px solid rgba(249,115,22,0.70)",boxShadow:"0 0 20px rgba(249,115,22,0.25)"},initial:{width:64,height:64,opacity:.9,scale:1},animate:{width:64+t*0,height:64+t*0,scale:[1,3.5+t*1.2],opacity:[.8,0]},transition:{duration:1.8,delay:t*.22,ease:"easeOut",repeat:1/0,repeatDelay:.1}},t)),s.jsx(V.div,{className:"relative z-10 w-16 h-16 rounded-full flex items-center justify-center",style:{background:"rgba(249,115,22,0.18)",border:"1.5px solid rgba(249,115,22,0.55)",backdropFilter:"blur(16px)",boxShadow:"0 0 32px rgba(249,115,22,0.35), 0 0 64px rgba(249,115,22,0.15)"},animate:{scale:[1,1.06,1]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"},children:s.jsx(Gr,{size:26,className:"text-orange-400"})}),s.jsx(V.p,{className:"absolute text-[12px] font-semibold text-orange-300/80 tracking-widest uppercase",style:{top:"calc(50% + 52px)"},initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:.15,duration:.3},children:"Dinliyorum…"})]})}function N6(){const[e,t]=u.useState(!1),n=u.useRef(null),r=u.useCallback(()=>{t(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>t(!1),k6)},[]);return u.useEffect(()=>(window.addEventListener("mustb:wake",r),()=>{window.removeEventListener("mustb:wake",r),n.current&&clearTimeout(n.current)}),[r]),s.jsx(ae,{children:e&&s.jsx(j6,{},"wake-aura")})}const S6={browser_navigate:"navigate",web_search:"search",http_request:"request"},C6=20,E6=5e3;function _6(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.slice(0,30)}}function T6(e){try{return new URL(e).pathname.slice(0,40)||"/"}catch{return""}}function P6(e){return e==="search"?s.jsx(fn,{size:10}):e==="request"?s.jsx(na,{size:10}):s.jsx(Ge,{size:10})}function vb(e){return e==="search"?"#a78bfa":e==="request"?"#94a3b8":"#38bdf8"}function A6({domain:e,kind:t}){var a;const n=((a=e[0])==null?void 0:a.toUpperCase())??"?",r=vb(t);return s.jsx("span",{className:"w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0 text-[10px] font-black",style:{background:`${r}18`,border:`1px solid ${r}30`,color:r},children:n})}function M6({entry:e,isLatest:t}){var i;const n=vb(e.kind),r=e.domain??"",a=e.query??(e.url?T6(e.url):"");return s.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",style:{borderLeft:t?`2px solid ${n}`:"2px solid transparent",background:t?`${n}08`:"transparent"},children:[s.jsx(A6,{domain:r||"?",kind:e.kind}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-semibold text-white/80 truncate leading-tight",children:r||((i=e.query)==null?void 0:i.slice(0,30))||"—"}),a&&s.jsx("p",{className:"text-[9px] text-white/35 truncate font-mono mt-0.5",children:a})]}),s.jsx("span",{style:{color:n,opacity:.6},className:"flex-shrink-0",children:P6(e.kind)}),s.jsx("span",{className:"text-[9px] text-white/20 font-mono flex-shrink-0",children:new Date(e.ts).toLocaleTimeString("tr-TR",{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})}function z6(){const[e,t]=u.useState([]),[n,r]=u.useState(!1),[a,i]=u.useState(!1),[o,l]=u.useState(!1),c=u.useRef(null),d=u.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(!1),t([]),l(!1)},E6)},[]);return u.useEffect(()=>{const h=pe(),p=f=>{const{type:m}=f;if(m==="planStart"){c.current&&clearTimeout(c.current),l(!0);return}if(m==="planFinish"){l(!1),t(b=>b.map(y=>({...y,done:!0}))),d();return}if(m==="stepStart"&&f.step){const b=f.step,y=b.tool?S6[b.tool]:void 0;if(!y)return;const v=b.parameters??{},x=String(v.url??v.endpoint??"").trim(),g=String(v.query??"").trim();if(!x&&!g)return;const w={id:`v-${Date.now()}-${Math.random().toString(36).slice(2,5)}`,kind:y,url:x||void 0,query:g||void 0,domain:x?_6(x):void 0,ts:Date.now(),done:!1};t(j=>[w,...j].slice(0,C6)),r(!0),i(!1)}};return h.on("agentUpdate",p),()=>{h.off("agentUpdate",p),c.current&&clearTimeout(c.current)}},[d]),!n||e.length===0?null:s.jsx(V.div,{className:"fixed right-4 z-[120] w-[300px]",style:{top:"88px"},initial:{opacity:0,x:20,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:16,scale:.96},transition:{type:"spring",stiffness:360,damping:30},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"rgba(5,3,1,0.88)",border:"1px solid rgba(56,189,248,0.22)",backdropFilter:"blur(24px)",boxShadow:"0 8px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(56,189,248,0.06), inset 0 1px 0 rgba(255,255,255,0.03)"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer select-none",style:{borderBottom:a?"none":"1px solid rgba(255,255,255,0.06)"},onClick:()=>i(h=>!h),children:[s.jsx(P3,{size:11,className:"text-sky-400/70 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] font-bold text-white/60 flex-1 tracking-wide uppercase",children:"Gezi Haritası"}),o&&s.jsxs("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(V.span,{className:"w-1.5 h-1.5 rounded-full bg-sky-400",animate:{opacity:[1,.3,1]},transition:{duration:1,repeat:1/0}}),s.jsx("span",{className:"text-[10px] text-sky-400/70 font-medium",children:"taranıyor"})]}),s.jsx("span",{className:"text-[10px] text-white/25 flex-shrink-0 font-mono ml-1",children:e.length}),s.jsx("button",{onClick:h=>{h.stopPropagation(),r(!1),t([])},className:"text-white/20 hover:text-white/50 transition-colors flex-shrink-0 ml-1",children:s.jsx(ze,{size:10})}),s.jsx("span",{className:"text-white/20 flex-shrink-0",children:a?s.jsx(Bl,{size:10}):s.jsx(Xs,{size:10})})]}),s.jsx(ae,{children:!a&&s.jsxs(V.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.18},className:"overflow-hidden",children:[s.jsx("div",{className:"overflow-y-auto divide-y divide-white/4",style:{maxHeight:"260px"},children:s.jsx(ae,{mode:"popLayout",children:e.map((h,p)=>s.jsx(V.div,{layout:!0,initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:-8},transition:{duration:.15},children:s.jsx(M6,{entry:h,isLatest:p===0&&o})},h.id))})}),s.jsx("div",{className:"px-3 py-1.5 flex items-center justify-between",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:s.jsxs("span",{className:"text-[9px] text-white/20 font-mono",children:[e.filter(h=>h.kind==="navigate").length," gezinti ·"," ",e.filter(h=>h.kind==="search").length," arama ·"," ",e.filter(h=>h.kind==="request").length," istek"]})})]})})]})})}function R6(e){if(!e.created_at)return"Older";const t=new Date,n=new Date(e.created_at),r=(t.getTime()-n.getTime())/864e5;return r<1&&t.getDate()===n.getDate()?"Today":r<2&&t.getDate()-n.getDate()===1?"Yesterday":r<7?"Last 7 Days":"Older"}const L6=["Today","Yesterday","Last 7 Days","Older"],O6="flex items-center gap-2.5 px-2.5 py-2 rounded-lg transition-all text-[13px] font-medium mb-0.5 w-full text-left",I6="bg-orange-500/15 text-orange-300 border border-orange-500/25",D6="text-white/80 hover:text-white/95 hover:bg-white/6";function B6(e){return ht(O6,e?I6:D6)}function F6(e){return e?"text-orange-400 shrink-0":"text-white/70 shrink-0"}function $6({onClose:e}){const{isTradingPackageInstalled:t,selectedTemplate:n,connectedExchange:r}=_i(),{t:a}=yt(),i=ms(),o=gt(),l=i.pathname,[c,d]=u.useState([]),[h,p]=u.useState(null),[f,m]=u.useState(""),[b,y]=u.useState(null),[v,x]=u.useState(null),[g,w]=u.useState(""),[j,k]=u.useState(""),[S,C]=u.useState(!1),[A,N]=u.useState([]),[_,L]=u.useState("Oto-Server"),[B,z]=u.useState(""),[$,R]=u.useState(!1),[M,P]=u.useState(!1),[E,T]=u.useState("");u.useEffect(()=>{const H=pe(),se=ce=>{ce&&(N(ce.servers||[]),L(ce.activeMode||"Oto-Server"),z(ce.activeNode||""))};return H.on("server:status",se),H.emit("server:request_status"),()=>{H.off("server:status",se)}},[]);const O=H=>{if(R(!1),H==="Oto-Server"){pe().emit("server:select","Oto-Server");return}const se=A.find(ce=>ce.name===H);se&&se.signal==="Low"?(T(H),P(!0)):pe().emit("server:select",H)},G=()=>{E&&(pe().emit("server:select",E),T("")),P(!1)},D=()=>{pe().emit("server:select","Oto-Server"),T(""),P(!1)},K=u.useCallback(async()=>{try{const H=await U("/api/chats");if(!H.ok)return;const se=await H.json();d(se);const ce=new Set([...se.map(oe=>oe.id),"default"]);for(let oe=localStorage.length-1;oe>=0;oe--){const de=localStorage.key(oe);de!=null&&de.startsWith("mustb_chat_turns_")&&!ce.has(de.slice(17))&&localStorage.removeItem(de)}}catch{}},[]);u.useEffect(()=>{K();const H=setInterval(K,1e4);return()=>clearInterval(H)},[K]),u.useEffect(()=>{const H=se=>{const{id:ce,title:oe}=se.detail;d(de=>de.map(Et=>Et.id===ce?{...Et,title:oe}:Et))};return window.addEventListener("mustb:chat-renamed",H),()=>window.removeEventListener("mustb:chat-renamed",H)},[]),u.useEffect(()=>{U("/api/setup/status").then(H=>H.ok?H.json():null).then(H=>{H&&(w(H.activeProvider??""),k(H.activeModel??""))}).catch(()=>{}),fetch("/api/auth/user-status").then(H=>H.json()).then(H=>C(!!H.authenticated)).catch(()=>{})},[]);const F=async()=>{try{const H=await U("/api/chats",{method:"POST",body:JSON.stringify({title:"New Chat"})});if(!H.ok){te.error("Failed to create chat.");return}const se=await H.json();d(ce=>[se,...ce]),o(`/app?chat=${se.id}`),e()}catch{te.error("Gateway unreachable.")}},Q=async()=>{if(b){try{await U(`/api/chats/${b}`,{method:"DELETE"}),d(H=>H.filter(se=>se.id!==b)),te.success("Chat deleted."),l.includes(b)&&o("/app")}catch{te.error("Failed to delete chat.")}y(null)}},q=async H=>{x(null);try{await U(`/api/chats/${H}`,{method:"PATCH",body:JSON.stringify({archived:!0})}),d(se=>se.filter(ce=>ce.id!==H)),te.success("Chat archived.")}catch{te.error("Failed to archive chat.")}},X=async()=>{if(!h||!f.trim()){p(null);return}try{await U(`/api/chats/${h}`,{method:"PATCH",body:JSON.stringify({title:f})}),d(H=>H.map(se=>se.id===h?{...se,title:f}:se)),te.success("Chat renamed.")}catch{te.error("Failed to rename chat.")}p(null)},le=[{to:"/app/browser",icon:s.jsx(Ge,{size:14}),label:a.nav.browser},{to:"/app/automations",icon:s.jsx(J3,{size:14}),label:a.nav.workflows},{to:"/app/skills",icon:s.jsx(Ue,{size:14}),label:a.nav.skills},{to:"/app/plugins",icon:s.jsx(qr,{size:14}),label:a.nav.plugins},{to:"/app/store",icon:s.jsx(xv,{size:14}),label:"Store"}];if(t){const H=n?r?"/app/trader/dashboard":"/app/trader/connect":"/app/trader/onboarding";le.push({to:H,icon:s.jsx(yv,{size:14,className:"text-emerald-400 animate-pulse"}),label:"Borsa & Botlar"})}return le.push({to:"/app/channels",icon:s.jsx(lp,{size:14}),label:a.nav.channels},{to:"/app/files",icon:s.jsx(Ln,{size:14}),label:a.nav.files},{to:"/app/memory",icon:s.jsx(Ni,{size:14}),label:a.nav.memory,exact:!0},{to:"/app/settings",icon:s.jsx(Ci,{size:14}),label:a.nav.settings,exact:!0},{to:"/app/settings?tab=api-keys",icon:s.jsx(cv,{size:14}),label:a.nav.apiKeys}),s.jsxs("aside",{className:"w-[280px] h-full bg-[#0d0703] border-r border-orange-500/10 flex flex-col overflow-hidden",children:[s.jsx("div",{className:"flex items-center h-[60px] pl-14 pr-4 shrink-0",children:s.jsxs(Ra,{to:"/app",onClick:e,className:"flex items-center gap-2.5 hover:opacity-80 transition-opacity",children:[s.jsxs("div",{className:"relative w-7 h-7 shrink-0",children:[s.jsx("div",{className:"absolute inset-0 bg-orange-500 rounded-full blur-sm opacity-40"}),s.jsx("img",{src:"/logo.png",alt:"Must-b",className:"w-full h-full object-contain relative z-10"})]}),s.jsx("span",{className:"text-[18px] font-black tracking-tight text-white/90 leading-none select-none",children:"Must-b"})]})}),s.jsx("p",{className:"text-[10px] font-bold text-white/30 uppercase tracking-widest px-3 mb-2",children:"Sohbet"}),s.jsx("div",{className:"px-3 pb-3 shrink-0",children:s.jsxs("button",{onClick:F,className:"flex items-center justify-center gap-2 w-full px-3 py-1.5 rounded-lg border border-orange-500/20 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20 hover:border-orange-500/30 transition-all text-[12px] font-medium",children:[s.jsx(Fl,{size:14}),a.sidebar.newChat]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide px-2 pb-4",onClick:()=>v&&x(null),children:[(()=>{const H={Today:[],Yesterday:[],"Last 7 Days":[],Older:[]};for(const se of c)H[R6(se)].push(se);return L6.map(se=>{const ce=H[se];return ce.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"px-2 mt-3 mb-1 text-[9.5px] font-bold text-white/20 uppercase tracking-widest",children:se}),s.jsx("div",{className:"space-y-0.5",children:ce.map(oe=>s.jsx("div",{className:"group relative",children:h===oe.id?s.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-orange-500/10 rounded-lg border border-orange-500/25",children:[s.jsx("input",{value:f,onChange:de=>m(de.target.value),className:"flex-1 bg-transparent text-[13px] text-white/80 outline-none min-w-0",autoFocus:!0,onKeyDown:de=>{de.key==="Enter"&&X(),de.key==="Escape"&&p(null)}}),s.jsx("button",{onClick:X,className:"p-1 text-green-400 hover:bg-green-400/10 rounded transition-colors",children:s.jsx(it,{size:12})}),s.jsx("button",{onClick:()=>p(null),className:"p-1 text-red-400 hover:bg-red-400/10 rounded transition-colors",children:s.jsx(ze,{size:12})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Ra,{to:`/app?chat=${oe.id}`,onClick:e,className:ht("flex items-center gap-2.5 px-2.5 py-2 rounded-lg transition-all text-[13px] font-medium pr-8",l.includes(oe.id)?"bg-orange-500/15 text-orange-300 border border-orange-500/25":"text-white/55 hover:text-white/85 hover:bg-white/6"),children:[s.jsx(Hs,{size:13,className:l.includes(oe.id)?"text-orange-400 shrink-0":"text-white/30 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:oe.title})]}),s.jsx("button",{onClick:de=>{de.preventDefault(),de.stopPropagation(),x(v===oe.id?null:oe.id)},className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded text-white/25 hover:text-white/70 hover:bg-white/8 opacity-0 group-hover:opacity-100 transition-all",children:s.jsx(w3,{size:14})}),v===oe.id&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[150px] rounded-xl py-1 overflow-hidden",style:{background:"rgba(16,6,2,0.97)",border:"1px solid rgba(249,115,22,0.15)",backdropFilter:"blur(20px)"},onClick:de=>de.stopPropagation(),children:[s.jsxs("button",{onClick:()=>{x(null),p(oe.id),m(oe.title)},className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-white/60 hover:bg-white/5 transition-colors",children:[s.jsx(B3,{size:12,className:"text-white/35 shrink-0"})," Rename"]}),s.jsxs("button",{onClick:()=>q(oe.id),className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-white/60 hover:bg-white/5 transition-colors",children:[s.jsx(c3,{size:12,className:"text-white/35 shrink-0"})," Archive"]}),s.jsx("hr",{className:"my-1 border-white/8"}),s.jsxs("button",{onClick:de=>{de.preventDefault(),de.stopPropagation(),x(null),y(oe.id)},className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-red-400 hover:bg-red-500/10 transition-colors",children:[s.jsx(ys,{size:12,className:"shrink-0"})," Delete"]})]})]})},oe.id))})]},se)})})(),s.jsx("hr",{className:"my-3 border-white/10"}),le.map(({to:H,icon:se,label:ce,exact:oe})=>{const de=H.split("?")[0],Et=oe?l===de:l.startsWith(de);return s.jsxs(Ra,{to:H,onClick:e,className:B6(Et),children:[s.jsx("span",{className:F6(Et),children:se}),ce]},H)})]}),s.jsxs("div",{className:"border-t border-orange-500/10 p-3 shrink-0",children:[s.jsxs("div",{className:"relative mb-2 shrink-0",children:[$&&s.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-1 z-50 rounded-xl py-1 overflow-hidden backdrop-blur-md transition-all duration-300 shadow-2xl animate-in fade-in slide-in-from-bottom-2",style:{background:"rgba(16, 6, 2, 0.96)",border:"1px solid rgba(249, 115, 22, 0.2)"},children:[s.jsx("p",{className:"px-3 py-1.5 text-[9px] font-bold text-white/30 uppercase tracking-widest border-b border-white/5",children:"Sunucu Seçimi"}),s.jsxs("div",{className:"max-h-[180px] overflow-y-auto scrollbar-hide py-1",children:[s.jsxs("button",{onClick:()=>O("Oto-Server"),className:ht("flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-left transition-colors",_==="Oto-Server"?"bg-orange-500/10 text-orange-400 font-bold":"text-white/70 hover:bg-white/5"),children:[s.jsx(Eo,{size:13,className:ht("shrink-0",_==="Oto-Server"?"text-orange-400":"text-white/40")}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{children:"Oto-Server"}),B&&s.jsxs("span",{className:"text-[9px] text-white/30 font-normal italic",children:["(",B,")"]})]})})]}),s.jsx("hr",{className:"my-1 border-white/5"}),A.map(H=>{const se=_===H.name,ce=H.signal==="Full"?"text-emerald-400":H.signal==="Medium"?"text-amber-500":"text-red-500";return s.jsxs("button",{onClick:()=>O(H.name),className:ht("flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-left transition-colors",se?"bg-orange-500/10 text-orange-400 font-bold":"text-white/70 hover:bg-white/5"),children:[s.jsx(Eo,{size:13,className:ht("shrink-0",ce)}),s.jsx("div",{className:"flex-grow",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{children:H.name}),s.jsxs("span",{className:"text-[9px] text-white/30",children:[H.latency,"ms"]})]})})]},H.name)})]})]}),(()=>{const H=A.find(oe=>oe.name===B),se=(H==null?void 0:H.signal)??"Full",ce=se==="Full"?"text-emerald-400":se==="Medium"?"text-amber-500":"text-red-500";return s.jsxs("button",{onClick:()=>R(!$),className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-xl text-left bg-white/[0.03] border border-white/[0.08] hover:bg-white/[0.06] hover:border-white/[0.12] transition-all select-none group",children:[s.jsx(Eo,{size:13,className:ht("shrink-0 group-hover:scale-110 transition-transform",ce)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[9px] text-white/30 font-bold uppercase tracking-[0.2em] mb-0.5 leading-none",children:"Sunucu"}),s.jsx("p",{className:"text-white/80 text-[11px] font-bold truncate leading-none",children:_==="Oto-Server"?`Oto-Server (${B||"..."})`:_})]}),s.jsx(Xs,{size:12,className:"shrink-0 text-white/30 group-hover:text-white/55 transition-colors"})]})})()]}),j&&s.jsxs("div",{className:"mb-2 px-1",children:[s.jsx("p",{className:"text-[9px] text-white/25 font-bold uppercase tracking-[0.2em] mb-0.5",children:"Active Model"}),s.jsx("p",{className:"text-orange-400 text-[11px] font-bold truncate",children:j}),g&&s.jsx("p",{className:"text-white/30 text-[10px] capitalize",children:g})]}),S&&s.jsxs("button",{onClick:async()=>{try{await fetch("/api/auth/signout",{method:"POST"})}catch{}e(),o("/app"),window.location.reload()},className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-white/30 hover:text-red-400 hover:bg-red-500/10 transition-all text-xs font-medium",children:[s.jsx(ip,{size:13}),a.sidebar.logout]}),s.jsxs("p",{className:"mt-2 text-[10px] text-white/20 px-1",children:[a.sidebar.poweredBy," ",s.jsx("span",{className:"text-orange-500/70 font-semibold",children:"Auto Step"})]})]}),b&&s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",children:s.jsxs("div",{className:"rounded-2xl p-6 w-full max-w-sm shadow-2xl",style:{background:"rgba(16,6,2,0.97)",border:"1px solid rgba(249,115,22,0.18)"},children:[s.jsx("h3",{className:"text-lg font-bold text-white/90 mb-2",children:a.sidebar.deleteChat}),s.jsx("p",{className:"text-white/45 text-sm mb-6",children:a.sidebar.deleteConfirm}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>y(null),className:"flex-1 px-4 py-2 rounded-xl bg-white/8 hover:bg-white/12 text-white/70 text-sm font-medium transition-colors",children:a.sidebar.cancel}),s.jsx("button",{onClick:Q,className:"flex-1 px-4 py-2 rounded-xl bg-red-600 hover:bg-red-500 text-white text-sm font-medium transition-colors",children:a.sidebar.delete})]})]})}),M&&s.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm animate-in fade-in",children:s.jsxs("div",{className:"rounded-2xl p-6 w-full max-w-sm shadow-2xl border border-red-500/30 animate-in zoom-in-95 duration-200",style:{background:"rgba(18, 9, 7, 0.98)"},children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2.5 rounded-xl bg-red-500/15 border border-red-500/20 text-red-500",children:s.jsx(vs,{size:18,className:"animate-pulse"})}),s.jsx("h3",{className:"text-base font-bold text-white/90",children:"Yüksek Trafik Uyarısı"})]}),s.jsx("p",{className:"text-white/60 text-[13px] leading-relaxed mb-6",children:"Bu sunucu şu an çok yoğun. Lütfen sunucuyu değiştirin veya Oto-Server moduna alın."}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:D,className:"flex-1 px-4 py-2 rounded-xl bg-orange-500 hover:bg-orange-600 text-white text-xs font-semibold shadow-lg shadow-orange-500/20 active:scale-[0.98] transition-all",children:"Oto-Server Moduna Al"}),s.jsx("button",{onClick:G,className:"flex-1 px-4 py-2 rounded-xl bg-white/5 hover:bg-white/10 text-white/80 text-xs font-medium border border-white/10 active:scale-[0.98] transition-all",children:"Yoksay"})]})]})})]})}function be(e){window.dispatchEvent(new CustomEvent("mustb:invoke-skill",{detail:{skill:e}})),setTimeout(()=>{var t;return(t=document.querySelector("textarea"))==null?void 0:t.focus()},80)}function V6({panel:e,title:t,onClose:n}){return u.useEffect(()=>{const r=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),s.jsxs(ae,{children:[s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-40 bg-black/55 backdrop-blur-[3px]",onClick:n},"stage-backdrop"),s.jsxs(V.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{type:"spring",stiffness:380,damping:32},className:`fixed z-50 top-[72px] left-1/2 -translate-x-1/2
|
|
937
|
+
group-hover:text-red-400 transition-colors`,children:i?"Signing out…":"Sign Out"})]})]}),s.jsx("div",{className:"px-4 py-2 border-t border-white/[0.05]",children:s.jsx("p",{className:"text-[8.5px] text-white/14 text-center",children:"must-b.com · Secure connection"})})]},"profile-panel")})]})]})}const w6=4,k6=3e3;function j6(){return s.jsxs(V.div,{className:"fixed inset-0 z-[200] pointer-events-none flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:[s.jsx("div",{className:"absolute inset-0 bg-black/35"}),Array.from({length:w6}).map((e,t)=>s.jsx(V.span,{className:"absolute rounded-full",style:{border:"1.5px solid rgba(249,115,22,0.70)",boxShadow:"0 0 20px rgba(249,115,22,0.25)"},initial:{width:64,height:64,opacity:.9,scale:1},animate:{width:64+t*0,height:64+t*0,scale:[1,3.5+t*1.2],opacity:[.8,0]},transition:{duration:1.8,delay:t*.22,ease:"easeOut",repeat:1/0,repeatDelay:.1}},t)),s.jsx(V.div,{className:"relative z-10 w-16 h-16 rounded-full flex items-center justify-center",style:{background:"rgba(249,115,22,0.18)",border:"1.5px solid rgba(249,115,22,0.55)",backdropFilter:"blur(16px)",boxShadow:"0 0 32px rgba(249,115,22,0.35), 0 0 64px rgba(249,115,22,0.15)"},animate:{scale:[1,1.06,1]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"},children:s.jsx(Gr,{size:26,className:"text-orange-400"})}),s.jsx(V.p,{className:"absolute text-[12px] font-semibold text-orange-300/80 tracking-widest uppercase",style:{top:"calc(50% + 52px)"},initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:.15,duration:.3},children:"Dinliyorum…"})]})}function N6(){const[e,t]=u.useState(!1),n=u.useRef(null),r=u.useCallback(()=>{t(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>t(!1),k6)},[]);return u.useEffect(()=>(window.addEventListener("mustb:wake",r),()=>{window.removeEventListener("mustb:wake",r),n.current&&clearTimeout(n.current)}),[r]),s.jsx(ae,{children:e&&s.jsx(j6,{},"wake-aura")})}const S6={browser_navigate:"navigate",web_search:"search",http_request:"request"},C6=20,E6=5e3;function _6(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.slice(0,30)}}function T6(e){try{return new URL(e).pathname.slice(0,40)||"/"}catch{return""}}function P6(e){return e==="search"?s.jsx(fn,{size:10}):e==="request"?s.jsx(na,{size:10}):s.jsx(Ge,{size:10})}function vb(e){return e==="search"?"#a78bfa":e==="request"?"#94a3b8":"#38bdf8"}function A6({domain:e,kind:t}){var a;const n=((a=e[0])==null?void 0:a.toUpperCase())??"?",r=vb(t);return s.jsx("span",{className:"w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0 text-[10px] font-black",style:{background:`${r}18`,border:`1px solid ${r}30`,color:r},children:n})}function M6({entry:e,isLatest:t}){var i;const n=vb(e.kind),r=e.domain??"",a=e.query??(e.url?T6(e.url):"");return s.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",style:{borderLeft:t?`2px solid ${n}`:"2px solid transparent",background:t?`${n}08`:"transparent"},children:[s.jsx(A6,{domain:r||"?",kind:e.kind}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[11px] font-semibold text-white/80 truncate leading-tight",children:r||((i=e.query)==null?void 0:i.slice(0,30))||"—"}),a&&s.jsx("p",{className:"text-[9px] text-white/35 truncate font-mono mt-0.5",children:a})]}),s.jsx("span",{style:{color:n,opacity:.6},className:"flex-shrink-0",children:P6(e.kind)}),s.jsx("span",{className:"text-[9px] text-white/20 font-mono flex-shrink-0",children:new Date(e.ts).toLocaleTimeString("tr-TR",{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]})}function z6(){const[e,t]=u.useState([]),[n,r]=u.useState(!1),[a,i]=u.useState(!1),[o,l]=u.useState(!1),c=u.useRef(null),d=u.useCallback(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(!1),t([]),l(!1)},E6)},[]);return u.useEffect(()=>{const h=pe(),p=f=>{const{type:m}=f;if(m==="planStart"){c.current&&clearTimeout(c.current),l(!0);return}if(m==="planFinish"){l(!1),t(b=>b.map(y=>({...y,done:!0}))),d();return}if(m==="stepStart"&&f.step){const b=f.step,y=b.tool?S6[b.tool]:void 0;if(!y)return;const v=b.parameters??{},x=String(v.url??v.endpoint??"").trim(),g=String(v.query??"").trim();if(!x&&!g)return;const w={id:`v-${Date.now()}-${Math.random().toString(36).slice(2,5)}`,kind:y,url:x||void 0,query:g||void 0,domain:x?_6(x):void 0,ts:Date.now(),done:!1};t(j=>[w,...j].slice(0,C6)),r(!0),i(!1)}};return h.on("agentUpdate",p),()=>{h.off("agentUpdate",p),c.current&&clearTimeout(c.current)}},[d]),!n||e.length===0?null:s.jsx(V.div,{className:"fixed right-4 z-[120] w-[300px]",style:{top:"88px"},initial:{opacity:0,x:20,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:16,scale:.96},transition:{type:"spring",stiffness:360,damping:30},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"rgba(5,3,1,0.88)",border:"1px solid rgba(56,189,248,0.22)",backdropFilter:"blur(24px)",boxShadow:"0 8px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(56,189,248,0.06), inset 0 1px 0 rgba(255,255,255,0.03)"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer select-none",style:{borderBottom:a?"none":"1px solid rgba(255,255,255,0.06)"},onClick:()=>i(h=>!h),children:[s.jsx(P3,{size:11,className:"text-sky-400/70 flex-shrink-0"}),s.jsx("span",{className:"text-[11px] font-bold text-white/60 flex-1 tracking-wide uppercase",children:"Gezi Haritası"}),o&&s.jsxs("span",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(V.span,{className:"w-1.5 h-1.5 rounded-full bg-sky-400",animate:{opacity:[1,.3,1]},transition:{duration:1,repeat:1/0}}),s.jsx("span",{className:"text-[10px] text-sky-400/70 font-medium",children:"taranıyor"})]}),s.jsx("span",{className:"text-[10px] text-white/25 flex-shrink-0 font-mono ml-1",children:e.length}),s.jsx("button",{onClick:h=>{h.stopPropagation(),r(!1),t([])},className:"text-white/20 hover:text-white/50 transition-colors flex-shrink-0 ml-1",children:s.jsx(ze,{size:10})}),s.jsx("span",{className:"text-white/20 flex-shrink-0",children:a?s.jsx(Bl,{size:10}):s.jsx(Xs,{size:10})})]}),s.jsx(ae,{children:!a&&s.jsxs(V.div,{initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{duration:.18},className:"overflow-hidden",children:[s.jsx("div",{className:"overflow-y-auto divide-y divide-white/4",style:{maxHeight:"260px"},children:s.jsx(ae,{mode:"popLayout",children:e.map((h,p)=>s.jsx(V.div,{layout:!0,initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:-8},transition:{duration:.15},children:s.jsx(M6,{entry:h,isLatest:p===0&&o})},h.id))})}),s.jsx("div",{className:"px-3 py-1.5 flex items-center justify-between",style:{borderTop:"1px solid rgba(255,255,255,0.04)"},children:s.jsxs("span",{className:"text-[9px] text-white/20 font-mono",children:[e.filter(h=>h.kind==="navigate").length," gezinti ·"," ",e.filter(h=>h.kind==="search").length," arama ·"," ",e.filter(h=>h.kind==="request").length," istek"]})})]})})]})})}function R6(e){if(!e.created_at)return"Older";const t=new Date,n=new Date(e.created_at),r=(t.getTime()-n.getTime())/864e5;return r<1&&t.getDate()===n.getDate()?"Today":r<2&&t.getDate()-n.getDate()===1?"Yesterday":r<7?"Last 7 Days":"Older"}const L6=["Today","Yesterday","Last 7 Days","Older"],O6="flex items-center gap-2.5 px-2.5 py-2 rounded-lg transition-all text-[13px] font-medium mb-0.5 w-full text-left",I6="bg-orange-500/15 text-orange-300 border border-orange-500/25",D6="text-white/80 hover:text-white/95 hover:bg-white/6";function B6(e){return ht(O6,e?I6:D6)}function F6(e){return e?"text-orange-400 shrink-0":"text-white/70 shrink-0"}function $6({onClose:e}){const{isTradingPackageInstalled:t,selectedTemplate:n,connectedExchange:r}=_i(),{t:a}=yt(),i=ms(),o=gt(),l=i.pathname,[c,d]=u.useState([]),[h,p]=u.useState(null),[f,m]=u.useState(""),[b,y]=u.useState(null),[v,x]=u.useState(null),[g,w]=u.useState(""),[j,k]=u.useState(""),[S,C]=u.useState(!1),[A,N]=u.useState([]),[_,L]=u.useState("Oto-Server"),[B,M]=u.useState(""),[$,R]=u.useState(!1),[z,P]=u.useState(!1),[E,T]=u.useState("");u.useEffect(()=>{const H=pe(),se=ce=>{ce&&(N(ce.servers||[]),L(ce.activeMode||"Oto-Server"),M(ce.activeNode||""))};return H.on("server:status",se),H.emit("server:request_status"),()=>{H.off("server:status",se)}},[]);const O=H=>{if(R(!1),H==="Oto-Server"){pe().emit("server:select","Oto-Server");return}const se=A.find(ce=>ce.name===H);se&&se.signal==="Low"?(T(H),P(!0)):pe().emit("server:select",H)},G=()=>{E&&(pe().emit("server:select",E),T("")),P(!1)},D=()=>{pe().emit("server:select","Oto-Server"),T(""),P(!1)},K=u.useCallback(async()=>{try{const H=await U("/api/chats");if(!H.ok)return;const se=await H.json();d(se);const ce=new Set([...se.map(oe=>oe.id),"default"]);for(let oe=localStorage.length-1;oe>=0;oe--){const de=localStorage.key(oe);de!=null&&de.startsWith("mustb_chat_turns_")&&!ce.has(de.slice(17))&&localStorage.removeItem(de)}}catch{}},[]);u.useEffect(()=>{K();const H=setInterval(K,1e4);return()=>clearInterval(H)},[K]),u.useEffect(()=>{const H=se=>{const{id:ce,title:oe}=se.detail;d(de=>de.map(Et=>Et.id===ce?{...Et,title:oe}:Et))};return window.addEventListener("mustb:chat-renamed",H),()=>window.removeEventListener("mustb:chat-renamed",H)},[]),u.useEffect(()=>{U("/api/setup/status").then(H=>H.ok?H.json():null).then(H=>{H&&(w(H.activeProvider??""),k(H.activeModel??""))}).catch(()=>{}),fetch("/api/auth/user-status").then(H=>H.json()).then(H=>C(!!H.authenticated)).catch(()=>{})},[]);const F=async()=>{try{const H=await U("/api/chats",{method:"POST",body:JSON.stringify({title:"New Chat"})});if(!H.ok){te.error("Failed to create chat.");return}const se=await H.json();d(ce=>[se,...ce]),o(`/app?chat=${se.id}`),e()}catch{te.error("Gateway unreachable.")}},Q=async()=>{if(b){try{await U(`/api/chats/${b}`,{method:"DELETE"}),d(H=>H.filter(se=>se.id!==b)),te.success("Chat deleted."),l.includes(b)&&o("/app")}catch{te.error("Failed to delete chat.")}y(null)}},q=async H=>{x(null);try{await U(`/api/chats/${H}`,{method:"PATCH",body:JSON.stringify({archived:!0})}),d(se=>se.filter(ce=>ce.id!==H)),te.success("Chat archived.")}catch{te.error("Failed to archive chat.")}},X=async()=>{if(!h||!f.trim()){p(null);return}try{await U(`/api/chats/${h}`,{method:"PATCH",body:JSON.stringify({title:f})}),d(H=>H.map(se=>se.id===h?{...se,title:f}:se)),te.success("Chat renamed.")}catch{te.error("Failed to rename chat.")}p(null)},le=[{to:"/app/browser",icon:s.jsx(Ge,{size:14}),label:a.nav.browser},{to:"/app/automations",icon:s.jsx(J3,{size:14}),label:a.nav.workflows},{to:"/app/skills",icon:s.jsx(Ue,{size:14}),label:a.nav.skills},{to:"/app/plugins",icon:s.jsx(qr,{size:14}),label:a.nav.plugins},{to:"/app/store",icon:s.jsx(xv,{size:14}),label:"Store"}];if(t){const H=n?r?"/app/trader/dashboard":"/app/trader/connect":"/app/trader/onboarding";le.push({to:H,icon:s.jsx(yv,{size:14,className:"text-emerald-400 animate-pulse"}),label:"Borsa & Botlar"})}return le.push({to:"/app/channels",icon:s.jsx(lp,{size:14}),label:a.nav.channels},{to:"/app/files",icon:s.jsx(Ln,{size:14}),label:a.nav.files},{to:"/app/memory",icon:s.jsx(Ni,{size:14}),label:a.nav.memory,exact:!0},{to:"/app/settings",icon:s.jsx(Ci,{size:14}),label:a.nav.settings,exact:!0},{to:"/app/settings?tab=api-keys",icon:s.jsx(cv,{size:14}),label:a.nav.apiKeys}),s.jsxs("aside",{className:"w-[280px] h-full bg-[#0d0703] border-r border-orange-500/10 flex flex-col overflow-hidden",children:[s.jsx("div",{className:"flex items-center h-[60px] pl-14 pr-4 shrink-0",children:s.jsxs(Ra,{to:"/app",onClick:e,className:"flex items-center gap-2.5 hover:opacity-80 transition-opacity",children:[s.jsxs("div",{className:"relative w-7 h-7 shrink-0",children:[s.jsx("div",{className:"absolute inset-0 bg-orange-500 rounded-full blur-sm opacity-40"}),s.jsx("img",{src:"/logo.png",alt:"Must-b",className:"w-full h-full object-contain relative z-10"})]}),s.jsx("span",{className:"text-[18px] font-black tracking-tight text-white/90 leading-none select-none",children:"Must-b"})]})}),s.jsx("p",{className:"text-[10px] font-bold text-white/30 uppercase tracking-widest px-3 mb-2",children:"Sohbet"}),s.jsx("div",{className:"px-3 pb-3 shrink-0",children:s.jsxs("button",{onClick:F,className:"flex items-center justify-center gap-2 w-full px-3 py-1.5 rounded-lg border border-orange-500/20 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20 hover:border-orange-500/30 transition-all text-[12px] font-medium",children:[s.jsx(Fl,{size:14}),a.sidebar.newChat]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide px-2 pb-4",onClick:()=>v&&x(null),children:[(()=>{const H={Today:[],Yesterday:[],"Last 7 Days":[],Older:[]};for(const se of c)H[R6(se)].push(se);return L6.map(se=>{const ce=H[se];return ce.length===0?null:s.jsxs("div",{children:[s.jsx("p",{className:"px-2 mt-3 mb-1 text-[9.5px] font-bold text-white/20 uppercase tracking-widest",children:se}),s.jsx("div",{className:"space-y-0.5",children:ce.map(oe=>s.jsx("div",{className:"group relative",children:h===oe.id?s.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 bg-orange-500/10 rounded-lg border border-orange-500/25",children:[s.jsx("input",{value:f,onChange:de=>m(de.target.value),className:"flex-1 bg-transparent text-[13px] text-white/80 outline-none min-w-0",autoFocus:!0,onKeyDown:de=>{de.key==="Enter"&&X(),de.key==="Escape"&&p(null)}}),s.jsx("button",{onClick:X,className:"p-1 text-green-400 hover:bg-green-400/10 rounded transition-colors",children:s.jsx(it,{size:12})}),s.jsx("button",{onClick:()=>p(null),className:"p-1 text-red-400 hover:bg-red-400/10 rounded transition-colors",children:s.jsx(ze,{size:12})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Ra,{to:`/app?chat=${oe.id}`,onClick:e,className:ht("flex items-center gap-2.5 px-2.5 py-2 rounded-lg transition-all text-[13px] font-medium pr-8",l.includes(oe.id)?"bg-orange-500/15 text-orange-300 border border-orange-500/25":"text-white/55 hover:text-white/85 hover:bg-white/6"),children:[s.jsx(Hs,{size:13,className:l.includes(oe.id)?"text-orange-400 shrink-0":"text-white/30 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:oe.title})]}),s.jsx("button",{onClick:de=>{de.preventDefault(),de.stopPropagation(),x(v===oe.id?null:oe.id)},className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded text-white/25 hover:text-white/70 hover:bg-white/8 opacity-0 group-hover:opacity-100 transition-all",children:s.jsx(w3,{size:14})}),v===oe.id&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[150px] rounded-xl py-1 overflow-hidden",style:{background:"rgba(16,6,2,0.97)",border:"1px solid rgba(249,115,22,0.15)",backdropFilter:"blur(20px)"},onClick:de=>de.stopPropagation(),children:[s.jsxs("button",{onClick:()=>{x(null),p(oe.id),m(oe.title)},className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-white/60 hover:bg-white/5 transition-colors",children:[s.jsx(B3,{size:12,className:"text-white/35 shrink-0"})," Rename"]}),s.jsxs("button",{onClick:()=>q(oe.id),className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-white/60 hover:bg-white/5 transition-colors",children:[s.jsx(c3,{size:12,className:"text-white/35 shrink-0"})," Archive"]}),s.jsx("hr",{className:"my-1 border-white/8"}),s.jsxs("button",{onClick:de=>{de.preventDefault(),de.stopPropagation(),x(null),y(oe.id)},className:"flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-red-400 hover:bg-red-500/10 transition-colors",children:[s.jsx(ys,{size:12,className:"shrink-0"})," Delete"]})]})]})},oe.id))})]},se)})})(),s.jsx("hr",{className:"my-3 border-white/10"}),le.map(({to:H,icon:se,label:ce,exact:oe})=>{const de=H.split("?")[0],Et=oe?l===de:l.startsWith(de);return s.jsxs(Ra,{to:H,onClick:e,className:B6(Et),children:[s.jsx("span",{className:F6(Et),children:se}),ce]},H)})]}),s.jsxs("div",{className:"border-t border-orange-500/10 p-3 shrink-0",children:[s.jsxs("div",{className:"relative mb-2 shrink-0",children:[$&&s.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-1 z-50 rounded-xl py-1 overflow-hidden backdrop-blur-md transition-all duration-300 shadow-2xl animate-in fade-in slide-in-from-bottom-2",style:{background:"rgba(16, 6, 2, 0.96)",border:"1px solid rgba(249, 115, 22, 0.2)"},children:[s.jsx("p",{className:"px-3 py-1.5 text-[9px] font-bold text-white/30 uppercase tracking-widest border-b border-white/5",children:"Sunucu Seçimi"}),s.jsxs("div",{className:"max-h-[180px] overflow-y-auto scrollbar-hide py-1",children:[s.jsxs("button",{onClick:()=>O("Oto-Server"),className:ht("flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-left transition-colors",_==="Oto-Server"?"bg-orange-500/10 text-orange-400 font-bold":"text-white/70 hover:bg-white/5"),children:[s.jsx(Eo,{size:13,className:ht("shrink-0",_==="Oto-Server"?"text-orange-400":"text-white/40")}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{children:"Oto-Server"}),B&&s.jsxs("span",{className:"text-[9px] text-white/30 font-normal italic",children:["(",B,")"]})]})})]}),s.jsx("hr",{className:"my-1 border-white/5"}),A.map(H=>{const se=_===H.name,ce=H.signal==="Full"?"text-emerald-400":H.signal==="Medium"?"text-amber-500":"text-red-500";return s.jsxs("button",{onClick:()=>O(H.name),className:ht("flex items-center gap-2.5 w-full px-3 py-2 text-[12px] text-left transition-colors",se?"bg-orange-500/10 text-orange-400 font-bold":"text-white/70 hover:bg-white/5"),children:[s.jsx(Eo,{size:13,className:ht("shrink-0",ce)}),s.jsx("div",{className:"flex-grow",children:s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{children:H.name}),s.jsxs("span",{className:"text-[9px] text-white/30",children:[H.latency,"ms"]})]})})]},H.name)})]})]}),(()=>{const H=A.find(oe=>oe.name===B),se=(H==null?void 0:H.signal)??"Full",ce=se==="Full"?"text-emerald-400":se==="Medium"?"text-amber-500":"text-red-500";return s.jsxs("button",{onClick:()=>R(!$),className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-xl text-left bg-white/[0.03] border border-white/[0.08] hover:bg-white/[0.06] hover:border-white/[0.12] transition-all select-none group",children:[s.jsx(Eo,{size:13,className:ht("shrink-0 group-hover:scale-110 transition-transform",ce)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[9px] text-white/30 font-bold uppercase tracking-[0.2em] mb-0.5 leading-none",children:"Sunucu"}),s.jsx("p",{className:"text-white/80 text-[11px] font-bold truncate leading-none",children:_==="Oto-Server"?`Oto-Server (${B||"..."})`:_})]}),s.jsx(Xs,{size:12,className:"shrink-0 text-white/30 group-hover:text-white/55 transition-colors"})]})})()]}),j&&s.jsxs("div",{className:"mb-2 px-1",children:[s.jsx("p",{className:"text-[9px] text-white/25 font-bold uppercase tracking-[0.2em] mb-0.5",children:"Active Model"}),s.jsx("p",{className:"text-orange-400 text-[11px] font-bold truncate",children:j}),g&&s.jsx("p",{className:"text-white/30 text-[10px] capitalize",children:g})]}),S&&s.jsxs("button",{onClick:async()=>{try{await fetch("/api/auth/signout",{method:"POST"})}catch{}e(),o("/app"),window.location.reload()},className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-white/30 hover:text-red-400 hover:bg-red-500/10 transition-all text-xs font-medium",children:[s.jsx(ip,{size:13}),a.sidebar.logout]}),s.jsxs("p",{className:"mt-2 text-[10px] text-white/20 px-1",children:[a.sidebar.poweredBy," ",s.jsx("span",{className:"text-orange-500/70 font-semibold",children:"Auto Step"})]})]}),b&&s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",children:s.jsxs("div",{className:"rounded-2xl p-6 w-full max-w-sm shadow-2xl",style:{background:"rgba(16,6,2,0.97)",border:"1px solid rgba(249,115,22,0.18)"},children:[s.jsx("h3",{className:"text-lg font-bold text-white/90 mb-2",children:a.sidebar.deleteChat}),s.jsx("p",{className:"text-white/45 text-sm mb-6",children:a.sidebar.deleteConfirm}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>y(null),className:"flex-1 px-4 py-2 rounded-xl bg-white/8 hover:bg-white/12 text-white/70 text-sm font-medium transition-colors",children:a.sidebar.cancel}),s.jsx("button",{onClick:Q,className:"flex-1 px-4 py-2 rounded-xl bg-red-600 hover:bg-red-500 text-white text-sm font-medium transition-colors",children:a.sidebar.delete})]})]})}),z&&s.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm animate-in fade-in",children:s.jsxs("div",{className:"rounded-2xl p-6 w-full max-w-sm shadow-2xl border border-red-500/30 animate-in zoom-in-95 duration-200",style:{background:"rgba(18, 9, 7, 0.98)"},children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2.5 rounded-xl bg-red-500/15 border border-red-500/20 text-red-500",children:s.jsx(vs,{size:18,className:"animate-pulse"})}),s.jsx("h3",{className:"text-base font-bold text-white/90",children:"Yüksek Trafik Uyarısı"})]}),s.jsx("p",{className:"text-white/60 text-[13px] leading-relaxed mb-6",children:"Bu sunucu şu an çok yoğun. Lütfen sunucuyu değiştirin veya Oto-Server moduna alın."}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:D,className:"flex-1 px-4 py-2 rounded-xl bg-orange-500 hover:bg-orange-600 text-white text-xs font-semibold shadow-lg shadow-orange-500/20 active:scale-[0.98] transition-all",children:"Oto-Server Moduna Al"}),s.jsx("button",{onClick:G,className:"flex-1 px-4 py-2 rounded-xl bg-white/5 hover:bg-white/10 text-white/80 text-xs font-medium border border-white/10 active:scale-[0.98] transition-all",children:"Yoksay"})]})]})})]})}function be(e){window.dispatchEvent(new CustomEvent("mustb:invoke-skill",{detail:{skill:e}})),setTimeout(()=>{var t;return(t=document.querySelector("textarea"))==null?void 0:t.focus()},80)}function V6({panel:e,title:t,onClose:n}){return u.useEffect(()=>{const r=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),s.jsxs(ae,{children:[s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-40 bg-black/55 backdrop-blur-[3px]",onClick:n},"stage-backdrop"),s.jsxs(V.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:12},transition:{type:"spring",stiffness:380,damping:32},className:`fixed z-50 top-[72px] left-1/2 -translate-x-1/2
|
|
938
938
|
w-full max-w-2xl max-h-[calc(100vh-92px)]
|
|
939
939
|
glass-panel rounded-3xl overflow-hidden flex flex-col
|
|
940
940
|
shadow-[0_24px_80px_rgba(0,0,0,0.7),0_0_0_1px_rgba(249,115,22,0.18)]`,onClick:r=>r.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-orange-500/12 shrink-0",children:[s.jsx("span",{className:"text-[13px] font-bold text-white/80",children:t}),s.jsx("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-full hover:bg-white/8 text-white/40 hover:text-white/70 transition-colors",children:s.jsx(ze,{size:14})})]}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[e==="memory"&&s.jsx(qP,{}),e==="plugins"&&s.jsx(QP,{}),e==="skills"&&s.jsx(t6,{}),e==="workspace"&&s.jsx(i6,{}),e==="livesight"&&s.jsx(o6,{})]})]},"stage-card")]})}function U6(){const{t:e}=yt(),t=ms(),n=gt(),[r,a]=u.useState(!1),[i,o]=u.useState(""),[l,c]=u.useState(null),[d,h]=u.useState(!1);u.useEffect(()=>{const b=y=>{h(y.detail.active)};return window.addEventListener("mustb:safeMode",b),()=>window.removeEventListener("mustb:safeMode",b)},[]),u.useEffect(()=>{a(!1)},[t.pathname]),t.pathname,u.useCallback(b=>o(y=>y===b?"":b),[]),u.useCallback(b=>{c(b),o("")},[]);const p=u.useCallback(()=>c(null),[]),f=e.dock;f.cat_webTools,f.skill_webSearch,f.desc_webSearch,f.skill_webFetch,f.desc_webFetch,f.skill_browserControl,f.desc_browserControl,f.cat_fileMedia,f.skill_pdfReader,f.desc_pdfReader,f.skill_imageAnalysis,f.desc_imageAnalysis,f.skill_imageGeneration,f.desc_imageGeneration,f.skill_tts,f.desc_tts,f.cat_aiAgents,f.skills,f.skill_spawnAgent,f.desc_spawnAgent,f.skill_agentSessions,f.desc_agentSessions,f.skill_canvas,f.desc_canvas,f.skill_git,f.desc_git,f.cat_systemTools,f.skill_gateway,f.desc_gateway,f.skill_fileManager,f.desc_fileManager,f.skill_cron,f.desc_cron,f.skill_messages,f.desc_messages,f.cat_knowledgeBase,f.mem_browse,f.desc_memBrowse,f.mem_search,f.desc_memSearch,f.mem_add,f.desc_memAdd,f.cat_personalOrg,f.mem_contacts,f.desc_contacts,f.mem_calendar,f.desc_calendar,f.cat_pluginManager,f.plug_marketplace,f.desc_marketplace,f.plug_installed,f.desc_installed,f.plug_mcp,f.desc_mcp,f.cat_developer,f.plug_bundleMcp,f.desc_bundleMcp,f.plug_cliCmds,f.desc_cliCmds,f.cat_automation,f.wf_automations,f.desc_automations,f.wf_scheduled,f.desc_scheduled,f.wf_commands,f.desc_commands,f.cat_advanced,f.wf_nodes,f.desc_nodes,f.wf_multiAgent,f.desc_multiAgent;const m={memory:f.memory,plugins:f.plugins,skills:f.skills,workspace:f.files,livesight:"Visual Audit"};return s.jsx(Uj,{reducedMotion:d?"always":"never",children:s.jsxs("div",{className:"relative min-h-screen overflow-x-hidden font-sans bg-transparent",children:[l&&s.jsx(V6,{panel:l,title:m[l],onClose:p}),s.jsx("div",{className:"fixed top-[14px] left-4 z-40 overflow-hidden",children:s.jsx("button",{onClick:()=>a(b=>!b),"aria-label":"Toggle sidebar",className:"p-2 rounded-full text-white/45 hover:text-white/90 hover:bg-white/8 transition-all leading-none",style:{backdropFilter:"blur(8px)",fontSize:0},children:s.jsx(z3,{size:17,"aria-hidden":"true",focusable:"false"})})}),s.jsxs("header",{className:"fixed top-0 inset-x-0 z-50 h-16 flex items-center justify-between px-6 pointer-events-none",children:[s.jsx("div",{}),s.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 pointer-events-auto",children:[s.jsxs(Ra,{to:"/app/voice",className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[12px] font-medium transition-all select-none ${t.pathname==="/app/voice"?"bg-orange-500/20 text-orange-300 border border-orange-500/30":"text-white/45 hover:text-white/85 hover:bg-white/8"}`,title:e.nav.voice,children:[s.jsx(p3,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:e.nav.voice})]}),s.jsx(V.div,{initial:{opacity:0,x:12},animate:{opacity:1,x:0},transition:{duration:.4,delay:.15},className:"flex items-center gap-1 px-2 py-1.5 rounded-full",style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.09)"},children:s.jsx(KP,{})}),s.jsx(b6,{})]})]}),s.jsx(ae,{children:r&&s.jsx(V.div,{initial:{x:-280},animate:{x:0},exit:{x:-280},transition:{type:"spring",stiffness:340,damping:34},className:"fixed top-0 left-0 bottom-0 z-30 w-[280px]",children:s.jsx($6,{onClose:()=>a(!1)})},"sidebar-panel")}),s.jsx("main",{className:"relative min-h-screen pt-16 transition-[margin] duration-300 bg-transparent",style:{marginLeft:r?280:0},children:s.jsx(Wk,{})}),s.jsx(c6,{}),s.jsx(m6,{}),s.jsx(N6,{}),s.jsx(z6,{})]})})}const H6=[{decision:"duplicate",label:"Create New Agent",sublabel:"Keep both — cloud data is copied to a separate folder",icon:N3,accent:"border-blue-500/30 bg-blue-500/8 hover:border-blue-500/50 text-blue-400"},{decision:"restore",label:"Use Cloud (Overwrite)",sublabel:"Cloud wins — local memory is replaced with cloud version",icon:g3,accent:"border-orange-500/30 bg-orange-500/8 hover:border-orange-500/50 text-orange-400"},{decision:"upload",label:"Keep Mine",sublabel:"Local wins — cloud memory is overwritten with local data",icon:W3,accent:"border-green-500/30 bg-green-500/8 hover:border-green-500/50 text-green-400"}];function W6(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1);u.useEffect(()=>{const c=pe(),d=h=>{h.type==="CONFLICT_DETECTED"&&(t({localAgentName:h.localAgentName??null,cloudAgentName:h.cloudAgentName??null,localMtime:h.localMtime??null,cloudTimestamp:h.cloudTimestamp??null}),i(!1)),h.type==="syncResolveFinish"&&(i(!0),setTimeout(()=>{t(null),i(!1)},1800))};return c.on("agentUpdate",d),()=>{c.off("agentUpdate",d)}},[]);const o=async c=>{if(!n){r(!0);try{await fetch("/api/setup/sync-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:c})})}catch{}r(!1)}},l=c=>{if(!c)return"—";try{return new Date(c).toLocaleString("en-US",{dateStyle:"medium",timeStyle:"short"})}catch{return c}};return s.jsx(ae,{children:e&&s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/70 backdrop-blur-sm px-4",children:s.jsxs(V.div,{initial:{opacity:0,y:24,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:24,scale:.95},transition:{duration:.25},className:"w-full max-w-md bg-[#0c0f18] border border-white/10 rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 px-6 py-5 border-b border-white/8 bg-amber-500/5",children:[s.jsx("div",{className:"w-9 h-9 rounded-full bg-amber-500/15 flex items-center justify-center flex-shrink-0",children:s.jsx(Ws,{size:18,className:"text-amber-400"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-white font-bold text-base",children:"Memory Conflict Detected"}),s.jsx("p",{className:"text-gray-500 text-xs mt-0.5",children:"Two agent identities found — action required"})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 px-6 pt-5 pb-2",children:[s.jsxs("div",{className:"rounded-xl border border-white/8 bg-white/3 px-4 py-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-1",children:"Local Agent"}),s.jsx("p",{className:"text-white font-bold text-sm",children:e.localAgentName??"—"}),s.jsx("p",{className:"text-gray-600 text-[10px] mt-1",children:l(e.localMtime)})]}),s.jsxs("div",{className:"rounded-xl border border-orange-500/20 bg-orange-500/5 px-4 py-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-orange-400/60 uppercase tracking-widest mb-1",children:"Cloud Agent"}),s.jsx("p",{className:"text-orange-300 font-bold text-sm",children:e.cloudAgentName??"—"}),s.jsx("p",{className:"text-orange-400/40 text-[10px] mt-1",children:l(e.cloudTimestamp)})]})]}),s.jsx("div",{className:"px-6 py-4 space-y-2",children:a?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-green-400 text-sm font-semibold",children:[s.jsx("span",{className:"w-4 h-4 rounded-full border-2 border-green-400 flex items-center justify-center text-[10px]",children:"✓"}),"Conflict resolved"]}):H6.map(c=>{const d=c.icon;return s.jsxs("button",{onClick:()=>o(c.decision),disabled:n,className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl border transition-all text-left disabled:opacity-50 disabled:cursor-not-allowed ${c.accent}`,children:[n?s.jsx(ne,{size:16,className:"animate-spin flex-shrink-0"}):s.jsx(d,{size:16,className:"flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold text-sm text-white",children:c.label}),s.jsx("p",{className:"text-[11px] text-gray-500 mt-0.5",children:c.sublabel})]})]},c.decision)})}),s.jsx("div",{className:"px-6 pb-5 pt-1",children:s.jsx("p",{className:"text-[10px] text-gray-700 text-center",children:'This action cannot be undone · If unsure, choose "Create New Agent" first'})})]})})})}function K6(){const[e,t]=u.useState(null);u.useEffect(()=>{const r=pe(),a=i=>{t(i)};return r.on("upsell_required",a),()=>{r.off("upsell_required",a)}},[]);const n=async()=>{try{await fetch("/api/upsell/open",{method:"POST"})}catch{}window.open("https://must-b.com/pricing","_blank"),t(null)};return s.jsx(ae,{children:e&&s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/80 backdrop-blur-sm px-4",children:s.jsxs(V.div,{initial:{opacity:0,y:24,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:24,scale:.95},transition:{duration:.25},className:"w-full max-w-md bg-gradient-to-b from-[#161327] to-[#0c0f18] border border-violet-500/20 rounded-2xl shadow-2xl overflow-hidden relative",children:[s.jsx("button",{onClick:()=>t(null),className:"absolute top-4 right-4 text-gray-500 hover:text-white/85 transition-colors",children:s.jsx(ze,{size:18})}),s.jsxs("div",{className:"flex flex-col items-center text-center px-6 pt-8 pb-4",children:[s.jsx("div",{className:"w-14 h-14 rounded-full bg-gradient-to-tr from-violet-500 to-amber-500 flex items-center justify-center shadow-lg shadow-violet-500/20 mb-4 animate-pulse",children:s.jsx(Ue,{size:24,className:"text-white fill-white"})}),s.jsxs("h2",{className:"text-white font-extrabold text-xl tracking-tight",children:["Upgrade to Must-b ",e.recommendedPlan]}),s.jsx("p",{className:"text-violet-400 text-xs font-semibold tracking-wider uppercase mt-1",children:"Unlock Premium Architecture"})]}),s.jsx("div",{className:"px-6 py-4 text-center",children:s.jsx("p",{className:"text-gray-300 text-sm leading-relaxed bg-white/5 border border-white/8 rounded-xl px-4 py-4",children:e.message})}),s.jsxs("div",{className:"px-6 py-2",children:[s.jsx("div",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest mb-3 text-center",children:"Included in your upgrade:"}),s.jsx("ul",{className:"text-xs text-gray-400 space-y-2 max-w-xs mx-auto text-left",children:e.recommendedPlan==="Pro"?s.jsxs(s.Fragment,{children:[s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-amber-400 font-bold",children:"✓"})," Unlimited LLM Tokens (No BYOK Limits)"]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-amber-400 font-bold",children:"✓"})," Full Access to Claude 3.7 & GPT-4o"]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-amber-400 font-bold",children:"✓"})," Priority OS-Level Executor Queue"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-violet-400 font-bold",children:"✓"})," Sınırsız Çoklu Ajan (Swarm) Desteği"]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-violet-400 font-bold",children:"✓"})," Gelişmiş Paralel İş Parçacığı Planlama"]}),s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-violet-400 font-bold",children:"✓"})," Özelleştirilmiş PM ve QA Ajan Rolleri"]})]})})]}),s.jsxs("div",{className:"px-6 pt-6 pb-8 space-y-2",children:[s.jsxs("button",{onClick:n,className:"w-full flex items-center justify-center gap-2 py-3 px-4 rounded-xl font-bold text-sm text-white bg-gradient-to-r from-violet-600 to-amber-600 hover:from-violet-500 hover:to-amber-500 active:scale-[0.98] transition-all shadow-lg shadow-violet-600/30",children:[s.jsx("span",{children:"Yükselt / Upgrade Now"}),s.jsx(nv,{size:16})]}),s.jsx("button",{onClick:()=>t(null),className:"w-full py-2.5 px-4 rounded-xl text-xs font-semibold text-gray-500 hover:text-gray-300 transition-colors",children:"Belki Daha Sonra / Maybe Later"})]})]})})})}function G6(){const[e,t]=u.useState(null),[n,r]=u.useState(null),[a,i]=u.useState(!1);u.useEffect(()=>{const c=pe(),d=p=>{t(p),r(null),i(!1)},h=p=>{r(p),p.status==="pulling"?i(!0):p.status==="success"?(i(!1),setTimeout(()=>{t(null),r(null)},3e3)):i(!1)};return c.on("local_llm_offer",d),c.on("local_llm_status",h),()=>{c.off("local_llm_offer",d),c.off("local_llm_status",h)}},[]);const o=()=>{a||(i(!0),pe().emit("local_llm_accept"))},l=()=>{a||(pe().emit("local_llm_cancel"),t(null))};return s.jsx(ae,{children:e&&s.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/80 backdrop-blur-sm px-4",children:s.jsxs(V.div,{initial:{opacity:0,y:24,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:24,scale:.95},transition:{duration:.25},className:"w-full max-w-md bg-gradient-to-b from-[#131d27] to-[#0c0f18] border border-emerald-500/20 rounded-2xl shadow-2xl overflow-hidden relative",children:[!a&&s.jsx("button",{onClick:l,className:"absolute top-4 right-4 text-gray-500 hover:text-white/85 transition-colors",children:s.jsx(ze,{size:18})}),s.jsxs("div",{className:"flex flex-col items-center text-center px-6 pt-8 pb-4",children:[s.jsx("div",{className:"w-14 h-14 rounded-full bg-gradient-to-tr from-emerald-500 to-cyan-500 flex items-center justify-center shadow-lg shadow-emerald-500/20 mb-4",children:s.jsx(tn,{size:24,className:"text-white"})}),s.jsx("h2",{className:"text-white font-extrabold text-xl tracking-tight",children:"Yerel Çevrimdışı Model Önerisi"}),s.jsx("p",{className:"text-emerald-400 text-xs font-semibold tracking-wider uppercase mt-1",children:"Air-Gapped LLM Engine Active"})]}),s.jsx("div",{className:"px-6 py-2",children:s.jsxs("div",{className:"flex items-center justify-center gap-6 bg-white/5 border border-white/8 rounded-xl px-4 py-3 max-w-xs mx-auto",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-xs text-gray-500 font-medium",children:"Toplam RAM"}),s.jsxs("div",{className:"text-sm font-bold text-white mt-0.5",children:[e.ramGb," GB"]})]}),s.jsx("div",{className:"h-6 w-px bg-white/10"}),s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-xs text-gray-500 font-medium",children:"CPU Çekirdek"}),s.jsxs("div",{className:"text-sm font-bold text-white mt-0.5",children:[e.cores," Core"]})]}),s.jsx("div",{className:"h-6 w-px bg-white/10"}),s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"text-xs text-gray-500 font-medium",children:"Donanım"}),s.jsxs("div",{className:"text-xs font-bold text-emerald-400 mt-1 flex items-center gap-0.5",children:[s.jsx(dp,{size:12})," UYGUN"]})]})]})}),s.jsx("div",{className:"px-6 py-4 text-center",children:n?n.status==="pulling"?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[s.jsx(ne,{size:28,className:"animate-spin text-emerald-400"}),s.jsx("p",{className:"text-gray-300 text-sm font-medium animate-pulse",children:"Çevrimdışı model indiriliyor (llama3.2)... Lütfen bekleyin."})]}):n.status==="success"?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-emerald-400",children:[s.jsx("span",{className:"w-8 h-8 rounded-full border-2 border-emerald-400 flex items-center justify-center text-sm font-bold",children:"✓"}),s.jsx("p",{className:"text-sm font-bold",children:"Model başarıyla kuruldu ve aktif edildi! Akış devam ediyor."})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 py-3 text-rose-400",children:[s.jsx(Ke,{size:28}),s.jsxs("p",{className:"text-xs font-medium max-w-xs leading-relaxed",children:["Kurulum hatası: ",n.message]})]}):s.jsx("p",{className:"text-gray-300 text-sm leading-relaxed",children:"İnternet bağlantısı kurulamadı. Ancak güçlü donanımınız sayesinde yerel zeka modellerini çalıştırabilirsiniz. Çevrimdışı çalışabilmek için hafif yerel modeli indirmek ister misiniz?"})}),!n||n.status==="error"?s.jsxs("div",{className:"px-6 pt-4 pb-8 space-y-2",children:[s.jsxs("button",{onClick:o,disabled:a,className:"w-full flex items-center justify-center gap-2 py-3 px-4 rounded-xl font-bold text-sm text-white bg-gradient-to-r from-emerald-600 to-cyan-600 hover:from-emerald-500 hover:to-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all shadow-lg shadow-emerald-600/30 active:scale-[0.98]",children:[a?s.jsx(ne,{size:16,className:"animate-spin"}):s.jsx(Os,{size:16}),s.jsx("span",{children:"İndir ve Kur / Install Model"})]}),s.jsx("button",{onClick:l,disabled:a,className:"w-full py-2.5 px-4 rounded-xl text-xs font-semibold text-gray-500 hover:text-gray-300 transition-colors disabled:opacity-50",children:"İptal / Cancel"})]}):s.jsx("div",{className:"h-8"})]})})})}const q6="1.73.3";function Y6(){const[e,t]=u.useState("idle"),[n,r]=u.useState(null),[a,i]=u.useState(""),[o,l]=u.useState(""),c=u.useRef(!1),d=u.useCallback(async()=>{var m,b;t("checking"),i("");try{const y=await U("/api/system/version");if(!y.ok)throw new Error(`Server returned ${y.status}`);const x=await y.json(),g=(x==null?void 0:x.current)??((m=x==null?void 0:x.data)==null?void 0:m.current),w=(x==null?void 0:x.latest)??((b=x==null?void 0:x.data)==null?void 0:b.latest);if(!g||!w)throw new Error("Version endpoint returned incomplete data");r({current:g,latest:w}),X6(w,g)>0?t("update-available"):(t("up-to-date"),setTimeout(()=>t("idle"),3e3))}catch(y){i((y==null?void 0:y.message)??"Check failed"),t("error"),setTimeout(()=>{t("idle"),i("")},4e3)}},[]);u.useEffect(()=>{if(e!=="restarting")return;const m=setTimeout(()=>window.close(),1e4),b=setInterval(async()=>{try{(await fetch("/api/system/health",{credentials:"include"})).ok&&(clearInterval(b),clearTimeout(m),c.current=!0,t("done"),window.close())}catch{}},3e3);return()=>{clearInterval(b),clearTimeout(m)}},[e]),u.useEffect(()=>{d()},[d]),u.useEffect(()=>{const b=setInterval(()=>{t(y=>((y==="idle"||y==="up-to-date")&&d(),y))},288e5);return()=>clearInterval(b)},[d]);const h=u.useCallback(async()=>{t("downloading"),l("");try{const m=await fetch("/api/system/update",{method:"POST",credentials:"include"});if(!m.body)throw new Error("No response body");const b=m.body.getReader(),y=new TextDecoder;let v="";for(;;){const{done:x,value:g}=await b.read();if(x)break;const w=y.decode(g);v+=w,l(j=>j+w)}v.includes("__MUSTB_SHUTTING_DOWN__")?t("restarting"):v.includes("❌")?(i("Install failed — see log above"),t("error"),setTimeout(()=>{t("idle"),i("")},5e3)):t("done")}catch(m){i((m==null?void 0:m.message)??"Update failed"),t("error")}},[]),p=u.useCallback(async()=>{t("restarting");try{await U("/api/system/restart",{method:"POST"})}catch{}const m=pe();let b=0;const y=setInterval(()=>{b++,m.connected&&(clearInterval(y),window.location.reload()),b>60&&clearInterval(y)},500)},[]),f=(n==null?void 0:n.current)??q6;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"fixed bottom-4 right-4 z-40 flex flex-col items-end gap-2",children:[!["update-available","downloading","done","restarting"].includes(e)&&s.jsxs("button",{onClick:e==="idle"||e==="up-to-date"||e==="error"?d:void 0,disabled:["checking","downloading","restarting"].includes(e),title:"Check for updates",className:ht("flex items-center gap-2","py-2 px-4 rounded-full shadow-2xl","text-xs font-medium","transition-all duration-200",e==="update-available"?"bg-red-900/90 backdrop-blur-md border border-red-500/50 text-white hover:bg-red-800 hover:border-red-400/60":e==="error"?"bg-amber-900/90 backdrop-blur-md border border-amber-500/60 text-white hover:bg-amber-800 hover:border-amber-400/70":"bg-gray-900/90 backdrop-blur-md border border-gray-700/50 text-gray-300 hover:bg-gray-800 hover:border-gray-600/60 hover:text-white",["checking","downloading","restarting"].includes(e)&&"cursor-wait opacity-80"),children:[e==="checking"&&s.jsx(ne,{size:13,className:"animate-spin text-orange-400 shrink-0"}),e==="update-available"&&s.jsx(Os,{size:13,className:"text-red-300 shrink-0"}),e==="up-to-date"&&s.jsx(Ms,{size:13,className:"text-emerald-400 shrink-0"}),e==="downloading"&&s.jsx(ne,{size:13,className:"animate-spin text-orange-400 shrink-0"}),e==="done"&&s.jsx(Ms,{size:13,className:"text-emerald-400 shrink-0"}),e==="restarting"&&s.jsx(ne,{size:13,className:"animate-spin text-orange-400 shrink-0"}),e==="error"&&s.jsx(Ke,{size:13,className:"text-amber-300 shrink-0"}),e==="idle"&&s.jsx(ge,{size:13,className:"text-gray-500 shrink-0"}),s.jsxs("span",{className:"tabular-nums",children:[s.jsx("span",{children:"Must-b v"}),s.jsx("span",{children:f})]}),e==="checking"&&s.jsx("span",{className:"text-orange-400/80",children:"Checking…"}),e==="up-to-date"&&s.jsx("span",{className:"text-emerald-400/80",children:"Up to date"}),e==="downloading"&&s.jsx("span",{className:"text-orange-400/80",children:"Installing…"}),e==="done"&&s.jsx("span",{className:"text-emerald-400/80",children:"Installed!"}),e==="restarting"&&s.jsx("span",{className:"text-orange-400/80",children:"Restarting…"}),e==="error"&&s.jsxs("span",{className:"text-amber-300/90 max-w-[140px] truncate",children:["Check failed",a?` — ${a}`:""]})]}),e==="update-available"&&n&&s.jsxs("div",{className:"flex flex-col gap-3 p-4 rounded-2xl bg-gray-900/95 border border-orange-500/30 backdrop-blur-md shadow-2xl w-60",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Os,{size:16,className:"text-orange-400 shrink-0"}),s.jsx("span",{className:"text-orange-300 font-semibold text-sm",children:"Update Available"})]}),s.jsxs("div",{className:"text-gray-400 text-xs leading-relaxed",children:[s.jsx("span",{children:"Version "}),s.jsx("span",{className:"font-mono text-white",children:n.latest}),s.jsx("span",{children:" is ready to install."})]}),s.jsxs("div",{className:"flex items-center justify-between text-[11px] text-gray-500",children:[s.jsxs("span",{children:["Current: ",s.jsx("span",{className:"font-mono",children:n.current})]}),s.jsxs("span",{children:["Latest: ",s.jsx("span",{className:"font-mono text-orange-300",children:n.latest})]})]}),s.jsxs("button",{onClick:h,className:"flex items-center justify-center gap-2 bg-orange-600 hover:bg-orange-500 active:scale-95 text-white rounded-xl py-2 text-xs font-semibold transition-all duration-150 shadow-lg shadow-orange-900/30",children:[s.jsx(Os,{size:13}),s.jsx("span",{children:"Download & Install"})]}),s.jsx("button",{onClick:()=>t("idle"),className:"text-center text-[11px] text-gray-600 hover:text-gray-400 transition-colors",children:s.jsx("span",{children:"Dismiss"})})]}),e==="downloading"&&s.jsxs("div",{className:"p-4 rounded-2xl bg-gray-900/95 border border-white/10 backdrop-blur-md shadow-2xl w-60",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-orange-300 mb-3",children:[s.jsx(ne,{size:13,className:"animate-spin shrink-0"}),s.jsx("span",{children:"Installing update…"})]}),s.jsx("pre",{className:"text-[10px] text-gray-400 max-h-24 overflow-y-auto whitespace-pre-wrap break-all font-mono bg-black/30 rounded-lg p-2",children:s.jsx("span",{children:o||"Connecting to npm registry…"})})]}),e==="done"&&!c.current&&s.jsxs("div",{className:"flex flex-col gap-3 p-4 rounded-2xl bg-gray-900/95 border border-emerald-500/30 backdrop-blur-md shadow-2xl w-60",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ms,{size:16,className:"text-emerald-400 shrink-0"}),s.jsx("span",{className:"text-emerald-300 font-semibold text-sm",children:"Update Installed!"})]}),s.jsx("p",{className:"text-gray-400 text-xs",children:s.jsx("span",{children:"Restart Must-b to apply the new version."})}),s.jsxs("button",{onClick:p,className:"flex items-center justify-center gap-2 bg-emerald-700 hover:bg-emerald-600 active:scale-95 text-white rounded-xl py-2 text-xs font-semibold transition-all duration-150",children:[s.jsx(ge,{size:13}),s.jsx("span",{children:"Restart Now"})]})]})]}),e==="done"&&c.current&&s.jsx("div",{className:"fixed inset-0 z-[9999] flex flex-col items-center justify-center bg-black",children:s.jsxs("div",{className:"font-mono text-center px-8 max-w-xl w-full",children:[s.jsxs("div",{className:"flex items-center justify-center gap-2 mb-8",children:[s.jsx(Ms,{size:18,className:"text-green-400 shrink-0"}),s.jsx("span",{className:"text-green-400 text-xs tracking-widest uppercase",children:"must-b terminal"})]}),s.jsx("pre",{className:"text-green-400 text-sm leading-relaxed text-left inline-block",children:`╔══════════════════════════════════════════════════════╗
|