@chrishdx/llm-dev-server 1.2.5 → 1.2.8

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.
Files changed (32) hide show
  1. package/backend/dist/controllers/ConversationController.d.ts +1 -1
  2. package/backend/dist/controllers/ConversationController.js +5 -5
  3. package/backend/dist/controllers/ConversationController.js.map +1 -1
  4. package/backend/dist/controllers/JobController.d.ts +10 -0
  5. package/backend/dist/controllers/JobController.d.ts.map +1 -1
  6. package/backend/dist/controllers/JobController.js +72 -0
  7. package/backend/dist/controllers/JobController.js.map +1 -1
  8. package/backend/dist/index.js +2 -1
  9. package/backend/dist/index.js.map +1 -1
  10. package/backend/dist/routes/filesystem.routes.d.ts.map +1 -1
  11. package/backend/dist/routes/filesystem.routes.js +23 -3
  12. package/backend/dist/routes/filesystem.routes.js.map +1 -1
  13. package/backend/dist/routes/index.d.ts.map +1 -1
  14. package/backend/dist/routes/index.js +2 -0
  15. package/backend/dist/routes/index.js.map +1 -1
  16. package/backend/dist/routes/job.routes.d.ts.map +1 -1
  17. package/backend/dist/routes/job.routes.js +2 -0
  18. package/backend/dist/routes/job.routes.js.map +1 -1
  19. package/backend/dist/routes/provider.routes.d.ts +3 -0
  20. package/backend/dist/routes/provider.routes.d.ts.map +1 -0
  21. package/backend/dist/routes/provider.routes.js +131 -0
  22. package/backend/dist/routes/provider.routes.js.map +1 -0
  23. package/backend/dist/routes/webhooks.routes.d.ts.map +1 -1
  24. package/backend/dist/routes/webhooks.routes.js +19 -0
  25. package/backend/dist/routes/webhooks.routes.js.map +1 -1
  26. package/backend/dist/services/conversation/ConversationService.d.ts +5 -2
  27. package/backend/dist/services/conversation/ConversationService.d.ts.map +1 -1
  28. package/backend/dist/services/conversation/ConversationService.js +13 -5
  29. package/backend/dist/services/conversation/ConversationService.js.map +1 -1
  30. package/backend/public/assets/{index-4QnHnKel.js → index-DOfnm5H8.js} +1 -1
  31. package/backend/public/index.html +1 -1
  32. package/package.json +1 -1
@@ -201,4 +201,4 @@ export default theme;`}function X0(e){return typeof e=="number"?`${(e*100).toFix
201
201
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...o){const i=new this(n);return o.forEach(s=>i.set(s)),i}static accessor(n){const i=(this[t1]=this[t1]={accessors:{}}).accessors,s=this.prototype;function c(u){const p=Rl(u);i[p]||(dD(s,u),i[p]=!0)}return re.isArray(n)?n.forEach(c):c(n),this}};Gn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);re.reduceDescriptors(Gn.prototype,({value:e},n)=>{let o=n[0].toUpperCase()+n.slice(1);return{get:()=>e,set(i){this[o]=i}}});re.freezeMethods(Gn);function jh(e,n){const o=this||dc,i=n||o,s=Gn.from(i.headers);let c=i.data;return re.forEach(e,function(p){c=p.call(o,c,s.normalize(),n?n.status:void 0)}),s.normalize(),c}function kC(e){return!!(e&&e.__CANCEL__)}function ws(e,n,o){Ze.call(this,e??"canceled",Ze.ERR_CANCELED,n,o),this.name="CanceledError"}re.inherits(ws,Ze,{__CANCEL__:!0});function OC(e,n,o){const i=o.config.validateStatus;!o.status||!i||i(o.status)?e(o):n(new Ze("Request failed with status code "+o.status,[Ze.ERR_BAD_REQUEST,Ze.ERR_BAD_RESPONSE][Math.floor(o.status/100)-4],o.config,o.request,o))}function fD(e){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return n&&n[1]||""}function pD(e,n){e=e||10;const o=new Array(e),i=new Array(e);let s=0,c=0,u;return n=n!==void 0?n:1e3,function(m){const g=Date.now(),y=i[c];u||(u=g),o[s]=m,i[s]=g;let b=c,w=0;for(;b!==s;)w+=o[b++],b=b%e;if(s=(s+1)%e,s===c&&(c=(c+1)%e),g-u<n)return;const T=y&&g-y;return T?Math.round(w*1e3/T):void 0}}function hD(e,n){let o=0,i=1e3/n,s,c;const u=(g,y=Date.now())=>{o=y,s=null,c&&(clearTimeout(c),c=null),e(...g)};return[(...g)=>{const y=Date.now(),b=y-o;b>=i?u(g,y):(s=g,c||(c=setTimeout(()=>{c=null,u(s)},i-b)))},()=>s&&u(s)]}const ud=(e,n,o=3)=>{let i=0;const s=pD(50,250);return hD(c=>{const u=c.loaded,p=c.lengthComputable?c.total:void 0,m=u-i,g=s(m),y=u<=p;i=u;const b={loaded:u,total:p,progress:p?u/p:void 0,bytes:m,rate:g||void 0,estimated:g&&p&&y?(p-u)/g:void 0,event:c,lengthComputable:p!=null,[n?"download":"upload"]:!0};e(b)},o)},n1=(e,n)=>{const o=e!=null;return[i=>n[0]({lengthComputable:o,total:e,loaded:i}),n[1]]},r1=e=>(...n)=>re.asap(()=>e(...n)),mD=An.hasStandardBrowserEnv?((e,n)=>o=>(o=new URL(o,An.origin),e.protocol===o.protocol&&e.host===o.host&&(n||e.port===o.port)))(new URL(An.origin),An.navigator&&/(msie|trident)/i.test(An.navigator.userAgent)):()=>!0,gD=An.hasStandardBrowserEnv?{write(e,n,o,i,s,c,u){if(typeof document>"u")return;const p=[`${e}=${encodeURIComponent(n)}`];re.isNumber(o)&&p.push(`expires=${new Date(o).toUTCString()}`),re.isString(i)&&p.push(`path=${i}`),re.isString(s)&&p.push(`domain=${s}`),c===!0&&p.push("secure"),re.isString(u)&&p.push(`SameSite=${u}`),document.cookie=p.join("; ")},read(e){if(typeof document>"u")return null;const n=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return n?decodeURIComponent(n[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function yD(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function vD(e,n){return n?e.replace(/\/?\/$/,"")+"/"+n.replace(/^\/+/,""):e}function zC(e,n,o){let i=!yD(n);return e&&(i||o==!1)?vD(e,n):n}const o1=e=>e instanceof Gn?{...e}:e;function Ja(e,n){n=n||{};const o={};function i(g,y,b,w){return re.isPlainObject(g)&&re.isPlainObject(y)?re.merge.call({caseless:w},g,y):re.isPlainObject(y)?re.merge({},y):re.isArray(y)?y.slice():y}function s(g,y,b,w){if(re.isUndefined(y)){if(!re.isUndefined(g))return i(void 0,g,b,w)}else return i(g,y,b,w)}function c(g,y){if(!re.isUndefined(y))return i(void 0,y)}function u(g,y){if(re.isUndefined(y)){if(!re.isUndefined(g))return i(void 0,g)}else return i(void 0,y)}function p(g,y,b){if(b in n)return i(g,y);if(b in e)return i(void 0,g)}const m={url:c,method:c,data:c,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:p,headers:(g,y,b)=>s(o1(g),o1(y),b,!0)};return re.forEach(Object.keys({...e,...n}),function(y){const b=m[y]||s,w=b(e[y],n[y],y);re.isUndefined(w)&&b!==p||(o[y]=w)}),o}const BC=e=>{const n=Ja({},e);let{data:o,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:c,headers:u,auth:p}=n;if(n.headers=u=Gn.from(u),n.url=jC(zC(n.baseURL,n.url,n.allowAbsoluteUrls),e.params,e.paramsSerializer),p&&u.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?unescape(encodeURIComponent(p.password)):""))),re.isFormData(o)){if(An.hasStandardBrowserEnv||An.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(re.isFunction(o.getHeaders)){const m=o.getHeaders(),g=["content-type","content-length"];Object.entries(m).forEach(([y,b])=>{g.includes(y.toLowerCase())&&u.set(y,b)})}}if(An.hasStandardBrowserEnv&&(i&&re.isFunction(i)&&(i=i(n)),i||i!==!1&&mD(n.url))){const m=s&&c&&gD.read(c);m&&u.set(s,m)}return n},bD=typeof XMLHttpRequest<"u",xD=bD&&function(e){return new Promise(function(o,i){const s=BC(e);let c=s.data;const u=Gn.from(s.headers).normalize();let{responseType:p,onUploadProgress:m,onDownloadProgress:g}=s,y,b,w,T,x;function S(){T&&T(),x&&x(),s.cancelToken&&s.cancelToken.unsubscribe(y),s.signal&&s.signal.removeEventListener("abort",y)}let E=new XMLHttpRequest;E.open(s.method.toUpperCase(),s.url,!0),E.timeout=s.timeout;function A(){if(!E)return;const j=Gn.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders()),k={data:!p||p==="text"||p==="json"?E.responseText:E.response,status:E.status,statusText:E.statusText,headers:j,config:e,request:E};OC(function(L){o(L),S()},function(L){i(L),S()},k),E=null}"onloadend"in E?E.onloadend=A:E.onreadystatechange=function(){!E||E.readyState!==4||E.status===0&&!(E.responseURL&&E.responseURL.indexOf("file:")===0)||setTimeout(A)},E.onabort=function(){E&&(i(new Ze("Request aborted",Ze.ECONNABORTED,e,E)),E=null)},E.onerror=function(M){const k=M&&M.message?M.message:"Network Error",N=new Ze(k,Ze.ERR_NETWORK,e,E);N.event=M||null,i(N),E=null},E.ontimeout=function(){let M=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const k=s.transitional||AC;s.timeoutErrorMessage&&(M=s.timeoutErrorMessage),i(new Ze(M,k.clarifyTimeoutError?Ze.ETIMEDOUT:Ze.ECONNABORTED,e,E)),E=null},c===void 0&&u.setContentType(null),"setRequestHeader"in E&&re.forEach(u.toJSON(),function(M,k){E.setRequestHeader(k,M)}),re.isUndefined(s.withCredentials)||(E.withCredentials=!!s.withCredentials),p&&p!=="json"&&(E.responseType=s.responseType),g&&([w,x]=ud(g,!0),E.addEventListener("progress",w)),m&&E.upload&&([b,T]=ud(m),E.upload.addEventListener("progress",b),E.upload.addEventListener("loadend",T)),(s.cancelToken||s.signal)&&(y=j=>{E&&(i(!j||j.type?new ws(null,e,E):j),E.abort(),E=null)},s.cancelToken&&s.cancelToken.subscribe(y),s.signal&&(s.signal.aborted?y():s.signal.addEventListener("abort",y)));const O=fD(s.url);if(O&&An.protocols.indexOf(O)===-1){i(new Ze("Unsupported protocol "+O+":",Ze.ERR_BAD_REQUEST,e));return}E.send(c||null)})},SD=(e,n)=>{const{length:o}=e=e?e.filter(Boolean):[];if(n||o){let i=new AbortController,s;const c=function(g){if(!s){s=!0,p();const y=g instanceof Error?g:this.reason;i.abort(y instanceof Ze?y:new ws(y instanceof Error?y.message:y))}};let u=n&&setTimeout(()=>{u=null,c(new Ze(`timeout ${n} of ms exceeded`,Ze.ETIMEDOUT))},n);const p=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(g=>{g.unsubscribe?g.unsubscribe(c):g.removeEventListener("abort",c)}),e=null)};e.forEach(g=>g.addEventListener("abort",c));const{signal:m}=i;return m.unsubscribe=()=>re.asap(p),m}},CD=function*(e,n){let o=e.byteLength;if(o<n){yield e;return}let i=0,s;for(;i<o;)s=i+n,yield e.slice(i,s),i=s},wD=async function*(e,n){for await(const o of ED(e))yield*CD(o,n)},ED=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const n=e.getReader();try{for(;;){const{done:o,value:i}=await n.read();if(o)break;yield i}}finally{await n.cancel()}},a1=(e,n,o,i)=>{const s=wD(e,n);let c=0,u,p=m=>{u||(u=!0,i&&i(m))};return new ReadableStream({async pull(m){try{const{done:g,value:y}=await s.next();if(g){p(),m.close();return}let b=y.byteLength;if(o){let w=c+=b;o(w)}m.enqueue(new Uint8Array(y))}catch(g){throw p(g),g}},cancel(m){return p(m),s.return()}},{highWaterMark:2})},i1=64*1024,{isFunction:Uu}=re,TD=(({Request:e,Response:n})=>({Request:e,Response:n}))(re.global),{ReadableStream:s1,TextEncoder:l1}=re.global,c1=(e,...n)=>{try{return!!e(...n)}catch{return!1}},RD=e=>{e=re.merge.call({skipUndefined:!0},TD,e);const{fetch:n,Request:o,Response:i}=e,s=n?Uu(n):typeof fetch=="function",c=Uu(o),u=Uu(i);if(!s)return!1;const p=s&&Uu(s1),m=s&&(typeof l1=="function"?(x=>S=>x.encode(S))(new l1):async x=>new Uint8Array(await new o(x).arrayBuffer())),g=c&&p&&c1(()=>{let x=!1;const S=new o(An.origin,{body:new s1,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!S}),y=u&&p&&c1(()=>re.isReadableStream(new i("").body)),b={stream:y&&(x=>x.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!b[x]&&(b[x]=(S,E)=>{let A=S&&S[x];if(A)return A.call(S);throw new Ze(`Response type '${x}' is not supported`,Ze.ERR_NOT_SUPPORT,E)})});const w=async x=>{if(x==null)return 0;if(re.isBlob(x))return x.size;if(re.isSpecCompliantForm(x))return(await new o(An.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(re.isArrayBufferView(x)||re.isArrayBuffer(x))return x.byteLength;if(re.isURLSearchParams(x)&&(x=x+""),re.isString(x))return(await m(x)).byteLength},T=async(x,S)=>{const E=re.toFiniteNumber(x.getContentLength());return E??w(S)};return async x=>{let{url:S,method:E,data:A,signal:O,cancelToken:j,timeout:M,onDownloadProgress:k,onUploadProgress:N,responseType:L,headers:U,withCredentials:$="same-origin",fetchOptions:F}=BC(x),q=n||fetch;L=L?(L+"").toLowerCase():"text";let R=SD([O,j&&j.toAbortSignal()],M),_=null;const I=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let W;try{if(N&&g&&E!=="get"&&E!=="head"&&(W=await T(U,A))!==0){let D=new o(S,{method:"POST",body:A,duplex:"half"}),H;if(re.isFormData(A)&&(H=D.headers.get("content-type"))&&U.setContentType(H),D.body){const[Q,se]=n1(W,ud(r1(N)));A=a1(D.body,i1,Q,se)}}re.isString($)||($=$?"include":"omit");const B=c&&"credentials"in o.prototype,P={...F,signal:R,method:E.toUpperCase(),headers:U.normalize().toJSON(),body:A,duplex:"half",credentials:B?$:void 0};_=c&&new o(S,P);let X=await(c?q(_,F):q(S,P));const Z=y&&(L==="stream"||L==="response");if(y&&(k||Z&&I)){const D={};["status","statusText","headers"].forEach(me=>{D[me]=X[me]});const H=re.toFiniteNumber(X.headers.get("content-length")),[Q,se]=k&&n1(H,ud(r1(k),!0))||[];X=new i(a1(X.body,i1,Q,()=>{se&&se(),I&&I()}),D)}L=L||"text";let pe=await b[re.findKey(b,L)||"text"](X,x);return!Z&&I&&I(),await new Promise((D,H)=>{OC(D,H,{data:pe,headers:Gn.from(X.headers),status:X.status,statusText:X.statusText,config:x,request:_})})}catch(B){throw I&&I(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new Ze("Network Error",Ze.ERR_NETWORK,x,_),{cause:B.cause||B}):Ze.from(B,B&&B.code,x,_)}}},jD=new Map,NC=e=>{let n=e&&e.env||{};const{fetch:o,Request:i,Response:s}=n,c=[i,s,o];let u=c.length,p=u,m,g,y=jD;for(;p--;)m=c[p],g=y.get(m),g===void 0&&y.set(m,g=p?new Map:RD(n)),y=g;return g};NC();const cg={http:VN,xhr:xD,fetch:{get:NC}};re.forEach(cg,(e,n)=>{if(e){try{Object.defineProperty(e,"name",{value:n})}catch{}Object.defineProperty(e,"adapterName",{value:n})}});const u1=e=>`- ${e}`,AD=e=>re.isFunction(e)||e===null||e===!1;function MD(e,n){e=re.isArray(e)?e:[e];const{length:o}=e;let i,s;const c={};for(let u=0;u<o;u++){i=e[u];let p;if(s=i,!AD(i)&&(s=cg[(p=String(i)).toLowerCase()],s===void 0))throw new Ze(`Unknown adapter '${p}'`);if(s&&(re.isFunction(s)||(s=s.get(n))))break;c[p||"#"+u]=s}if(!s){const u=Object.entries(c).map(([m,g])=>`adapter ${m} `+(g===!1?"is not supported by the environment":"is not available in the build"));let p=o?u.length>1?`since :
202
202
  `+u.map(u1).join(`
203
203
  `):" "+u1(u[0]):"as no adapter specified";throw new Ze("There is no suitable adapter to dispatch the request "+p,"ERR_NOT_SUPPORT")}return s}const DC={getAdapter:MD,adapters:cg};function Ah(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ws(null,e)}function d1(e){return Ah(e),e.headers=Gn.from(e.headers),e.data=jh.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),DC.getAdapter(e.adapter||dc.adapter,e)(e).then(function(i){return Ah(e),i.data=jh.call(e,e.transformResponse,i),i.headers=Gn.from(i.headers),i},function(i){return kC(i)||(Ah(e),i&&i.response&&(i.response.data=jh.call(e,e.transformResponse,i.response),i.response.headers=Gn.from(i.response.headers))),Promise.reject(i)})}const LC="1.13.2",Hd={};["object","boolean","number","function","string","symbol"].forEach((e,n)=>{Hd[e]=function(i){return typeof i===e||"a"+(n<1?"n ":" ")+e}});const f1={};Hd.transitional=function(n,o,i){function s(c,u){return"[Axios v"+LC+"] Transitional option '"+c+"'"+u+(i?". "+i:"")}return(c,u,p)=>{if(n===!1)throw new Ze(s(u," has been removed"+(o?" in "+o:"")),Ze.ERR_DEPRECATED);return o&&!f1[u]&&(f1[u]=!0,console.warn(s(u," has been deprecated since v"+o+" and will be removed in the near future"))),n?n(c,u,p):!0}};Hd.spelling=function(n){return(o,i)=>(console.warn(`${i} is likely a misspelling of ${n}`),!0)};function kD(e,n,o){if(typeof e!="object")throw new Ze("options must be an object",Ze.ERR_BAD_OPTION_VALUE);const i=Object.keys(e);let s=i.length;for(;s-- >0;){const c=i[s],u=n[c];if(u){const p=e[c],m=p===void 0||u(p,c,e);if(m!==!0)throw new Ze("option "+c+" must be "+m,Ze.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new Ze("Unknown option "+c,Ze.ERR_BAD_OPTION)}}const Zu={assertOptions:kD,validators:Hd},Gr=Zu.validators;let Xa=class{constructor(n){this.defaults=n||{},this.interceptors={request:new e1,response:new e1}}async request(n,o){try{return await this._request(n,o)}catch(i){if(i instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const c=s.stack?s.stack.replace(/^.+\n/,""):"";try{i.stack?c&&!String(i.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(i.stack+=`
204
- `+c):i.stack=c}catch{}}throw i}}_request(n,o){typeof n=="string"?(o=o||{},o.url=n):o=n||{},o=Ja(this.defaults,o);const{transitional:i,paramsSerializer:s,headers:c}=o;i!==void 0&&Zu.assertOptions(i,{silentJSONParsing:Gr.transitional(Gr.boolean),forcedJSONParsing:Gr.transitional(Gr.boolean),clarifyTimeoutError:Gr.transitional(Gr.boolean)},!1),s!=null&&(re.isFunction(s)?o.paramsSerializer={serialize:s}:Zu.assertOptions(s,{encode:Gr.function,serialize:Gr.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),Zu.assertOptions(o,{baseUrl:Gr.spelling("baseURL"),withXsrfToken:Gr.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let u=c&&re.merge(c.common,c[o.method]);c&&re.forEach(["delete","get","head","post","put","patch","common"],x=>{delete c[x]}),o.headers=Gn.concat(u,c);const p=[];let m=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(o)===!1||(m=m&&S.synchronous,p.unshift(S.fulfilled,S.rejected))});const g=[];this.interceptors.response.forEach(function(S){g.push(S.fulfilled,S.rejected)});let y,b=0,w;if(!m){const x=[d1.bind(this),void 0];for(x.unshift(...p),x.push(...g),w=x.length,y=Promise.resolve(o);b<w;)y=y.then(x[b++],x[b++]);return y}w=p.length;let T=o;for(;b<w;){const x=p[b++],S=p[b++];try{T=x(T)}catch(E){S.call(this,E);break}}try{y=d1.call(this,T)}catch(x){return Promise.reject(x)}for(b=0,w=g.length;b<w;)y=y.then(g[b++],g[b++]);return y}getUri(n){n=Ja(this.defaults,n);const o=zC(n.baseURL,n.url,n.allowAbsoluteUrls);return jC(o,n.params,n.paramsSerializer)}};re.forEach(["delete","get","head","options"],function(n){Xa.prototype[n]=function(o,i){return this.request(Ja(i||{},{method:n,url:o,data:(i||{}).data}))}});re.forEach(["post","put","patch"],function(n){function o(i){return function(c,u,p){return this.request(Ja(p||{},{method:n,headers:i?{"Content-Type":"multipart/form-data"}:{},url:c,data:u}))}}Xa.prototype[n]=o(),Xa.prototype[n+"Form"]=o(!0)});let OD=class $C{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(c){o=c});const i=this;this.promise.then(s=>{if(!i._listeners)return;let c=i._listeners.length;for(;c-- >0;)i._listeners[c](s);i._listeners=null}),this.promise.then=s=>{let c;const u=new Promise(p=>{i.subscribe(p),c=p}).then(s);return u.cancel=function(){i.unsubscribe(c)},u},n(function(c,u,p){i.reason||(i.reason=new ws(c,u,p),o(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const o=this._listeners.indexOf(n);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const n=new AbortController,o=i=>{n.abort(i)};return this.subscribe(o),n.signal.unsubscribe=()=>this.unsubscribe(o),n.signal}static source(){let n;return{token:new $C(function(s){n=s}),cancel:n}}};function zD(e){return function(o){return e.apply(null,o)}}function BD(e){return re.isObject(e)&&e.isAxiosError===!0}const um={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(um).forEach(([e,n])=>{um[n]=e});function PC(e){const n=new Xa(e),o=mC(Xa.prototype.request,n);return re.extend(o,Xa.prototype,n,{allOwnKeys:!0}),re.extend(o,n,null,{allOwnKeys:!0}),o.create=function(s){return PC(Ja(e,s))},o}const nn=PC(dc);nn.Axios=Xa;nn.CanceledError=ws;nn.CancelToken=OD;nn.isCancel=kC;nn.VERSION=LC;nn.toFormData=Id;nn.AxiosError=Ze;nn.Cancel=nn.CanceledError;nn.all=function(n){return Promise.all(n)};nn.spread=zD;nn.isAxiosError=BD;nn.mergeConfig=Ja;nn.AxiosHeaders=Gn;nn.formToJSON=e=>MC(re.isHTMLForm(e)?new FormData(e):e);nn.getAdapter=DC.getAdapter;nn.HttpStatusCode=um;nn.default=nn;const{Axios:_L,AxiosError:IL,CanceledError:HL,isCancel:FL,CancelToken:VL,VERSION:qL,all:WL,Cancel:GL,isAxiosError:KL,spread:YL,toFormData:XL,AxiosHeaders:QL,HttpStatusCode:ZL,formToJSON:JL,getAdapter:e$,mergeConfig:t$}=nn,Ne=nn.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});Ne.interceptors.request.use(e=>{const n=localStorage.getItem("token");return n&&(e.headers.Authorization=`Bearer ${n}`),e});let UC=!1;const jl=e=>{UC=e};Ne.interceptors.response.use(e=>e,e=>(e.response?.status===401&&!UC&&localStorage.getItem("token")&&(localStorage.removeItem("token"),window.location.href="/login"),Promise.reject(e)));const Cn={login:e=>Ne.post("/auth/login",e),register:e=>Ne.post("/auth/register",e),me:()=>Ne.get("/auth/me"),changePassword:e=>Ne.put("/auth/password",e),claudeLoginStart:()=>Ne.post("/auth/claude/login/start",{}),claudeLoginComplete:e=>Ne.post("/auth/claude/login/complete",e),claudeStatus:()=>Ne.get("/auth/claude/status"),claudeLogout:()=>Ne.post("/auth/claude/logout"),codexLoginStart:()=>Ne.post("/auth/codex/login/start"),codexLoginPoll:e=>Ne.post("/auth/codex/login/poll",e),codexStatus:()=>Ne.get("/auth/codex/status"),codexLogout:()=>Ne.post("/auth/codex/logout"),geminiLoginStart:()=>Ne.post("/auth/gemini/login/start"),geminiLoginComplete:e=>Ne.post("/auth/gemini/login/complete",e),geminiStatus:()=>Ne.get("/auth/gemini/status"),geminiLogout:()=>Ne.post("/auth/gemini/logout")},Ka={create:e=>Ne.post("/jobs",e),list:e=>Ne.get("/jobs",{params:e}),get:(e,n)=>Ne.get(`/jobs/${e}`,{params:n?{includeConversations:"true"}:void 0}),update:(e,n)=>Ne.patch(`/jobs/${e}`,n),delete:e=>Ne.delete(`/jobs/${e}`),getStatus:e=>Ne.get(`/jobs/${e}/status`),cancel:e=>Ne.post(`/jobs/${e}/cancel`),getConversations:(e,n)=>Ne.get(`/jobs/${e}/conversations`,{params:n}),listFiles:e=>Ne.get(`/jobs/${e}/files`)},rs={getProviders:()=>Ne.get("/conversations/providers"),create:e=>Ne.post("/conversations",e),get:e=>Ne.get(`/conversations/${e}`),update:(e,n)=>Ne.patch(`/conversations/${e}`,n),getMessages:(e,n)=>Ne.get(`/conversations/${e}/messages`,{params:n}),sendMessage:(e,n)=>Ne.post(`/conversations/${e}/messages`,n),delete:e=>Ne.delete(`/conversations/${e}`)},dm={browse:e=>Ne.get("/filesystem/browse",{params:e?{path:e}:void 0}),getRoots:()=>Ne.get("/filesystem/roots"),mkdir:(e,n)=>Ne.post("/filesystem/mkdir",{parentPath:e,name:n}),getGitInfo:e=>Ne.get("/filesystem/git-info",{params:{path:e}})},Mh={list:()=>Ne.get("/keys"),create:e=>Ne.post("/keys",e),update:(e,n)=>Ne.patch(`/keys/${e}`,n),revoke:e=>Ne.delete(`/keys/${e}`),deletePermanent:e=>Ne.delete(`/keys/${e}/permanent`)},Wi={list:()=>Ne.get("/webhooks"),getEvents:()=>Ne.get("/webhooks/events"),create:e=>Ne.post("/webhooks",e),update:(e,n)=>Ne.patch(`/webhooks/${e}`,n),delete:e=>Ne.delete(`/webhooks/${e}`),regenerateSecret:e=>Ne.post(`/webhooks/${e}/regenerate-secret`),test:e=>Ne.post(`/webhooks/${e}/test`)},da={getVersion:()=>Ne.get("/system/version"),getInfo:()=>Ne.get("/system/info"),getUpdateLog:()=>Ne.get("/system/update-log"),clearUpdateLog:()=>Ne.delete("/system/update-log"),triggerUpdate:()=>Ne.post("/system/update"),triggerRestart:()=>Ne.post("/system/restart"),healthCheck:()=>Ne.get("/health"),waitForReconnect:async(e=30,n=2e3,o)=>{for(let i=1;i<=e;i++)try{return o?.(i,e),await da.healthCheck(),!0}catch{i<e&&await new Promise(s=>setTimeout(s,n))}return!1}},_C=v.createContext(void 0),fc=()=>{const e=v.useContext(_C);if(!e)throw new Error("useAuth must be used within AuthProvider");return e},ND=({children:e})=>{const[n,o]=v.useState(null),[i,s]=v.useState(localStorage.getItem("token")),[c,u]=v.useState(!0),[p,m]=v.useState(!1);v.useEffect(()=>{(async()=>{jl(!0);try{const T=(await Cn.me()).data;if(T.autheliaToken){localStorage.setItem("token",T.autheliaToken),s(T.autheliaToken),o(T.data),m(!0),u(!1),jl(!1);return}o(T.data),m(!i),u(!1),jl(!1);return}catch{if(!i){u(!1),jl(!1);return}}if(i)try{const w=await Cn.me();o(w.data.data)}catch{localStorage.removeItem("token"),s(null)}u(!1),jl(!1)})()},[i]);const g=async(b,w)=>{const T=await Cn.login({username:b,password:w}),{token:x,user:S}=T.data.data;localStorage.setItem("token",x),s(x),o(S),m(!1)},y=()=>{localStorage.removeItem("token"),s(null),o(null),m(!1)};return d.jsx(_C.Provider,{value:{user:n,token:i,loading:c,isAutheliaAuth:p,login:g,logout:y},children:e})},DD={loading:"Laden...",save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",create:"Erstellen",close:"Schließen",back:"Zurück",search:"Suchen",filter:"Filtern",refresh:"Aktualisieren",copy:"Kopieren",copied:"Kopiert!",yes:"Ja",no:"Nein",error:"Fehler",success:"Erfolg",warning:"Warnung",info:"Information",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",createdAt:"Erstellt am",updatedAt:"Aktualisiert am",noData:"Keine Daten vorhanden"},LD={login:"Anmelden",logout:"Abmelden",register:"Registrieren",username:"Benutzername",password:"Passwort",currentPassword:"Aktuelles Passwort",newPassword:"Neues Passwort",confirmPassword:"Passwort bestätigen",changePassword:"Passwort ändern",passwordChanged:"Passwort wurde erfolgreich geändert",passwordMinLength:"Mindestens 8 Zeichen",passwordMismatch:"Passwörter stimmen nicht überein",invalidCredentials:"Ungültige Anmeldedaten",loginFailed:"Anmeldung fehlgeschlagen",welcome:"Willkommen zurück",loginSubtitle:"Melden Sie sich an, um fortzufahren"},$D={dashboard:"Dashboard",jobs:"Jobs",providerAuth:"Provider-Authentifizierung",userManagement:"Benutzerverwaltung",apiKeys:"API-Schlüssel",webhooks:"Webhooks",profile:"Profil",system:"System"},PD={title:"Jobs",createJob:"Neuen Job erstellen",selectJob:"Wählen Sie einen Job aus",noJobs:"Keine Jobs vorhanden",jobName:"Job-Name",workingDirectory:"Arbeitsverzeichnis",systemPrompt:"System-Prompt",status:{pending:"Ausstehend",running:"Läuft",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"},statistics:"Statistiken",conversations:"Konversationen",messages:"Nachrichten",tokenUsage:"Token-Verbrauch",inputTokens:"Eingabe-Tokens",outputTokens:"Ausgabe-Tokens",totalTokens:"Gesamt-Tokens",deleteConfirm:"Möchten Sie diesen Job wirklich löschen?",cancelConfirm:"Möchten Sie diesen Job wirklich abbrechen?"},UD={title:"Konversationen",createConversation:"Neue Konversation",noConversations:"Keine Konversationen vorhanden",selectProvider:"Provider auswählen",model:"Modell",sendMessage:"Nachricht senden",typeMessage:"Nachricht eingeben...",streaming:"Streaming...",attachments:"Anhänge",addAttachment:"Anhang hinzufügen"},_D={title:"Provider-Authentifizierung",subtitle:"Verbinden Sie Ihre LLM-Provider",claude:{name:"Claude (Anthropic)",description:"Anthropics Claude für fortgeschrittene KI-Aufgaben"},codex:{name:"Codex (OpenAI)",description:"OpenAIs Codex für Code-Generierung"},gemini:{name:"Gemini (Google)",description:"Googles Gemini für vielseitige KI-Aufgaben"},connected:"Verbunden",notConnected:"Nicht verbunden",connect:"Verbinden",disconnect:"Trennen",expiresAt:"Läuft ab am",loginInstructions:"Anmeldeanleitung",codeInput:"Code eingeben",pasteCode:"Fügen Sie den erhaltenen Code hier ein",verifying:"Wird überprüft...",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen"},ID={title:"API-Schlüssel",subtitle:"Verwalten Sie Ihre API-Schlüssel für die programmierte Nutzung",createKey:"Neuen Schlüssel erstellen",keyName:"Schlüssel-Name",keyPrefix:"Schlüssel-Präfix",lastUsed:"Zuletzt verwendet",expiresAt:"Läuft ab am",neverUsed:"Noch nie verwendet",neverExpires:"Läuft nie ab",expired:"Abgelaufen",revoked:"Widerrufen",active:"Aktiv",revoke:"Widerrufen",revokeConfirm:"Möchten Sie diesen API-Schlüssel wirklich widerrufen?",newKeyCreated:"Neuer API-Schlüssel erstellt",copyWarning:"Kopieren Sie diesen Schlüssel jetzt! Er wird nur einmal angezeigt.",noKeys:"Keine API-Schlüssel vorhanden",expirationDate:"Ablaufdatum (optional)",expirationHelp:"Leer lassen für unbegrenzten Schlüssel"},HD={title:"Webhooks",subtitle:"Erhalten Sie Echtzeit-Benachrichtigungen über Events",createWebhook:"Neuen Webhook erstellen",webhookName:"Webhook-Name",webhookUrl:"Webhook-URL",events:"Events",active:"Aktiv",inactive:"Inaktiv",lastTriggered:"Zuletzt ausgelöst",failures:"Fehlversuche",regenerateSecret:"Secret neu generieren",testWebhook:"Webhook testen",noWebhooks:"Keine Webhooks vorhanden",selectEvents:"Wählen Sie die Events aus, die den Webhook auslösen sollen",eventDescriptions:{"job.created":"Job wurde erstellt","job.updated":"Job wurde aktualisiert","job.completed":"Job wurde abgeschlossen","job.failed":"Job ist fehlgeschlagen","job.cancelled":"Job wurde abgebrochen","conversation.created":"Konversation wurde erstellt","conversation.updated":"Konversation wurde aktualisiert","message.created":"Nachricht wurde erstellt","message.streaming":"Nachricht wird gestreamt","message.completed":"Nachricht ist vollständig","tool.called":"Tool wurde aufgerufen","tool.completed":"Tool-Aufruf abgeschlossen"}},FD={title:"Profil",subtitle:"Verwalten Sie Ihre Kontoeinstellungen",accountInfo:"Kontoinformationen",role:"Rolle",roleAdmin:"Administrator",roleUser:"Benutzer",security:"Sicherheit",changePasswordDesc:"Ändern Sie Ihr Passwort regelmäßig für mehr Sicherheit"},VD={title:"Benutzerverwaltung",subtitle:"Neue Benutzer erstellen (nur Admin)",createUser:"Benutzer erstellen",userCreated:'Benutzer "{username}" wurde erfolgreich erstellt',createFailed:"Benutzer konnte nicht erstellt werden"},qD={browse:"Durchsuchen",selectDirectory:"Verzeichnis auswählen",currentPath:"Aktueller Pfad",parentDirectory:"Übergeordnetes Verzeichnis",createFolder:"Neuen Ordner erstellen",folderName:"Ordnername"},WD={generic:"Ein Fehler ist aufgetreten",networkError:"Netzwerkfehler - bitte überprüfen Sie Ihre Verbindung",unauthorized:"Nicht autorisiert - bitte melden Sie sich erneut an",forbidden:"Zugriff verweigert",notFound:"Nicht gefunden",serverError:"Serverfehler - bitte versuchen Sie es später erneut"},GD={title:"System",subtitle:"Systemverwaltung und Updates",version:"Version",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",lastChecked:"Zuletzt geprüft",updateAvailable:"Update verfügbar",upToDate:"Aktuell",update:"Update installieren",restart:"Neustart",info:"Systeminformationen",uptime:"Laufzeit",memory:"Speicher",platform:"Plattform",updateLog:"Update-Log",clearLog:"Log löschen",confirmUpdate:"Update bestätigen",confirmUpdateText:"Möchten Sie das Update wirklich installieren? Der Server wird nach dem Update automatisch neu gestartet.",confirmRestart:"Neustart bestätigen",confirmRestartText:"Möchten Sie den Server wirklich neu starten? Alle aktiven Verbindungen werden kurzzeitig unterbrochen."},KD={common:DD,auth:LD,nav:$D,jobs:PD,conversations:UD,providers:_D,apiKeys:ID,webhooks:HD,profile:FD,users:VD,filesystem:qD,errors:WD,system:GD};function Y(e,n){const o=e.split(".");let i=KD;for(const s of o)if(i&&typeof i=="object"&&s in i)i=i[s];else return console.warn(`Translation missing for key: ${e}`),e;return typeof i!="string"?(console.warn(`Translation value is not a string for key: ${e}`),e):n?i.replace(/\{(\w+)\}/g,(s,c)=>n[c]?.toString()??`{${c}}`):i}function YD(){const{login:e}=fc(),[n,o]=v.useState(""),[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(!1),g=async y=>{y.preventDefault(),u(""),m(!0);try{await e(n,i)}catch(b){u(b.response?.data?.message||Y("auth.loginFailed"))}finally{m(!1)}};return d.jsx(YS,{maxWidth:"sm",sx:{mt:8},children:d.jsxs(Ft,{elevation:3,sx:{p:4},children:[d.jsx(ne,{variant:"h4",gutterBottom:!0,align:"center",children:"LLM Dev Server"}),d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("auth.welcome")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("auth.loginSubtitle")}),c&&d.jsx(zt,{severity:"error",sx:{mb:2},children:c}),d.jsxs("form",{onSubmit:g,children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.username"),value:n,onChange:y=>o(y.target.value),margin:"normal",required:!0,autoFocus:!0,autoComplete:"username"}),d.jsx(_t,{fullWidth:!0,label:Y("auth.password"),type:"password",value:i,onChange:y=>s(y.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),d.jsx(He,{type:"submit",variant:"contained",fullWidth:!0,sx:{mt:2},disabled:p,children:p?d.jsx(Et,{size:24}):Y("auth.login")})]}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mt:3,textAlign:"center"},children:"Kontaktieren Sie Ihren Administrator, um ein Konto zu erhalten"})]})})}const XD=Fe(d.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"})),hs=Fe(d.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"})),dd=Fe(d.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"})),QD=Fe(d.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"})),ZD=Fe(d.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),fm=Fe(d.jsx("path",{d:"M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2M6 9h12v2H6zm8 5H6v-2h8zm4-6H6V6h12z"})),IC=Fe(d.jsx("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})),JD=Fe(d.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"})),HC=Fe(d.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),eL=Fe(d.jsx("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"})),FC=Fe(d.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"})),tL=Fe(d.jsx("path",{d:"M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3z"})),Fd=Fe(d.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),nL=Fe(d.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"})),pc=Fe(d.jsx("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"})),rL=Fe(d.jsx("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"})),oL=Fe(d.jsx("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm7 7V3.5L18.5 9z"})),aL=Fe(d.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"})),iL=Fe(d.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"})),sL=Fe(d.jsx("path",{d:"M15 9H9v6h6zm-2 4h-2v-2h2zm8-2V9h-2V7c0-1.1-.9-2-2-2h-2V3h-2v2h-2V3H9v2H7c-1.1 0-2 .9-2 2v2H3v2h2v2H3v2h2v2c0 1.1.9 2 2 2h2v2h2v-2h2v2h2v-2h2c1.1 0 2-.9 2-2v-2h2v-2h-2v-2zm-4 6H7V7h10z"})),VC=Fe(d.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),lL=Fe(d.jsx("path",{d:"m23 12-2.44-2.78.34-3.68-3.61-.82-1.89-3.18L12 3 8.6 1.54 6.71 4.72l-3.61.81.34 3.68L1 12l2.44 2.78-.34 3.69 3.61.82 1.89 3.18L12 21l3.4 1.46 1.89-3.18 3.61-.82-.34-3.68zm-10 5h-2v-2h2zm0-4h-2V7h2z"})),qC=Fe(d.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"})),cL=Fe(d.jsx("path",{d:"M8 5v14l11-7z"})),Vd=Fe(d.jsx("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"})),uL=Fe(d.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"})),WC=Fe([d.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),d.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")]),dL=Fe(d.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"})),fL=Fe(d.jsx("path",{d:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"})),pL=Fe(d.jsx("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"})),p1=Fe(d.jsx("path",{d:"M17 1.01 7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99M17 19H7V5h10zm-1-6h-3V8h-2v5H8l4 4z"})),hL=Fe(d.jsx("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"})),mL=Fe(d.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"})),gL=Fe(d.jsx("path",{d:"M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"})),yL=Fe(d.jsx("path",{d:"M10 15h5.88c.27-.31.67-.5 1.12-.5.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5c-.44 0-.84-.19-1.12-.5H11.9c-.46 2.28-2.48 4-4.9 4-2.76 0-5-2.24-5-5 0-2.42 1.72-4.44 4-4.9v2.07c-1.16.41-2 1.53-2 2.83 0 1.65 1.35 3 3 3s3-1.35 3-3zm2.5-11c1.65 0 3 1.35 3 3h2c0-2.76-2.24-5-5-5s-5 2.24-5 5c0 1.43.6 2.71 1.55 3.62l-2.35 3.9c-.68.14-1.2.75-1.2 1.48 0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5c0-.16-.02-.31-.07-.45l3.38-5.63C10.49 9.61 9.5 8.42 9.5 7c0-1.65 1.35-3 3-3m4.5 9c-.64 0-1.23.2-1.72.54l-3.05-5.07C11.53 8.35 11 7.74 11 7c0-.83.67-1.5 1.5-1.5S14 6.17 14 7c0 .15-.02.29-.06.43l2.19 3.65c.28-.05.57-.08.87-.08 2.76 0 5 2.24 5 5s-2.24 5-5 5c-1.85 0-3.47-1.01-4.33-2.5h2.67c.48.32 1.05.5 1.66.5 1.65 0 3-1.35 3-3s-1.35-3-3-3"}));function vL(){const[e,n]=v.useState({}),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(null),[y,b]=v.useState(!1),[w,T]=v.useState(null),[x,S]=v.useState(null),[E,A]=v.useState(""),[O,j]=v.useState(!1),[M,k]=v.useState(null),[N,L]=v.useState("");v.useEffect(()=>{U();const P=new URLSearchParams(window.location.search),X=P.get("auth"),Z=P.get("status"),pe=P.get("message");X&&Z&&(Z==="success"?(p(`${X.charAt(0).toUpperCase()+X.slice(1)} ${Y("providers.loginSuccess")}!`),U()):Z==="error"&&c(pe||`${X.charAt(0).toUpperCase()+X.slice(1)} ${Y("providers.loginFailed")}`),window.history.replaceState({},"",window.location.pathname))},[]),v.useEffect(()=>{if(!m?.expiresAt)return;const P=setInterval(()=>{const X=Math.floor((m.expiresAt-Date.now())/1e3);X<=0?(T(0),b(!1),g(null),c("Codex-Authentifizierungscode abgelaufen. Bitte erneut versuchen."),clearInterval(P)):T(X)},1e3);return()=>clearInterval(P)},[m?.expiresAt]);const U=async()=>{try{const[P,X,Z]=await Promise.all([Cn.claudeStatus().catch(()=>null),Cn.codexStatus().catch(()=>null),Cn.geminiStatus().catch(()=>null)]);n({claude:P?.data.data,codex:X?.data.data,gemini:Z?.data.data})}catch(P){console.error("Failed to load provider statuses:",P)}finally{i(!1)}},$=async()=>{c("");try{const P=await Cn.claudeLoginStart(),{loginUrl:X,state:Z,redirectUri:pe}=P.data.data;X&&Z&&(S({loginUrl:X,state:Z,verificationUrl:pe||""}),window.open(X,"_blank","width=600,height=800"))}catch(P){c(P.response?.data?.message||"Claude-Anmeldung konnte nicht gestartet werden")}},F=async()=>{if(!x||!E.trim()){c("Bitte fügen Sie die Callback-URL oder den Autorisierungscode ein");return}c(""),j(!0);try{await Cn.claudeLoginComplete({code:E.trim(),state:x.state}),S(null),A(""),p("Claude-Authentifizierung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Claude-Authentifizierung fehlgeschlagen")}finally{j(!1)}},q=async()=>{c(""),p("");try{const P=await Cn.codexLoginStart(),{verificationUrl:X,userCode:Z,deviceAuthId:pe,intervalSeconds:D,expiresIn:H}=P.data.data;if(!X||!Z||!pe){c("Fehlende erforderliche Daten für die Codex-Authentifizierung");return}const Q=H?Date.now()+H*1e3:void 0;g({userCode:Z,verificationUrl:X,deviceAuthId:pe,expiresAt:Q}),Q&&T(Math.floor((Q-Date.now())/1e3));const se=Math.max((D||5)*1e3,5e3);b(!0);let me=0;const fe=60,ye=setInterval(async()=>{if(me++,me>fe){clearInterval(ye),b(!1),g(null),c("Codex-Authentifizierung zeitüberschreitung. Bitte erneut versuchen.");return}try{await Cn.codexLoginPoll({deviceAuthId:pe,userCode:Z}),clearInterval(ye),b(!1),g(null),p("Codex-Authentifizierung erfolgreich!"),await U()}catch(ze){(ze.response?.data?.error||ze.response?.data?.message||"").includes("not yet approved")||(clearInterval(ye),b(!1),c("Codex-Authentifizierung fehlgeschlagen"))}},se)}catch(P){c(P.response?.data?.message||"Codex-Anmeldung konnte nicht gestartet werden")}},R=async()=>{c("");try{const P=await Cn.geminiLoginStart(),{loginUrl:X,state:Z,verificationUrl:pe}=P.data.data;X&&Z&&(k({loginUrl:X,state:Z,verificationUrl:pe||""}),window.open(X,"_blank","width=600,height=800"))}catch(P){c(P.response?.data?.message||"Gemini-Anmeldung konnte nicht gestartet werden")}},_=async()=>{if(!M||!N.trim()){c("Bitte geben Sie den Autorisierungscode ein");return}c("");try{await Cn.geminiLoginComplete({code:N.trim(),state:M.state}),k(null),L(""),p("Gemini-Authentifizierung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Gemini-Authentifizierung fehlgeschlagen")}},I=async()=>{if(confirm("Möchten Sie sich wirklich von Claude abmelden?")){c("");try{await Cn.claudeLogout(),p("Claude-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Claude-Abmeldung fehlgeschlagen")}}},W=async()=>{if(confirm("Möchten Sie sich wirklich von Codex abmelden?")){c("");try{await Cn.codexLogout(),p("Codex-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Codex-Abmeldung fehlgeschlagen")}}},B=async()=>{if(confirm("Möchten Sie sich wirklich von Gemini abmelden?")){c("");try{await Cn.geminiLogout(),p("Gemini-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Gemini-Abmeldung fehlgeschlagen")}}};return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("providers.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("providers.subtitle")}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),u&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>p(""),children:u}),d.jsxs(Zi,{container:!0,spacing:3,children:[d.jsx(Zi,{item:!0,xs:12,md:4,children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.claude.name")}),e.claude?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.claude.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.claude.email]}),e.claude.expiresAt&&d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("providers.expiresAt"),": ",new Date(e.claude.expiresAt).toLocaleDateString("de-DE")]})]}):x?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"1. Ein neuer Tab mit Claude-Authentifizierung wurde geöffnet"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"2. Nach der Anmeldung kopieren Sie die GESAMTE URL aus der Callback-Seite"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"3. Fügen Sie die vollständige URL unten ein:"}),d.jsx(_t,{fullWidth:!0,size:"small",placeholder:"Callback-URL einfügen...",value:E,onChange:P=>A(P.target.value),sx:{mt:1}}),d.jsxs(ue,{sx:{mt:1,display:"flex",gap:1},children:[d.jsx(He,{variant:"contained",size:"small",onClick:F,disabled:!E.trim()||O,children:O?Y("providers.verifying"):"Bestätigen"}),d.jsx(He,{variant:"text",size:"small",onClick:()=>{S(null),A("")},children:Y("common.cancel")})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.claude.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!x&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.claude?.loggedIn?"outlined":"contained",onClick:$,sx:{flex:e.claude?.loggedIn?"1 1 auto":"1"},children:e.claude?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.claude?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:I,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})}),d.jsx(Zi,{item:!0,xs:12,md:4,children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.codex.name")}),e.codex?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.codex.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.codex.email]})]}):m?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsxs(ne,{variant:"body2",gutterBottom:!0,children:["1. Besuchen Sie: ",d.jsx("a",{href:m.verificationUrl,target:"_blank",rel:"noopener noreferrer",style:{wordBreak:"break-all"},children:m.verificationUrl})]}),d.jsxs(ne,{variant:"body2",gutterBottom:!0,children:["2. Geben Sie den Code ein: ",d.jsx("strong",{children:m.userCode})]}),w!==null&&d.jsxs(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:["Code läuft ab in: ",d.jsxs("strong",{children:[Math.floor(w/60),":",String(w%60).padStart(2,"0")]})]}),y&&d.jsxs(ue,{sx:{mt:1,display:"flex",alignItems:"center",gap:1},children:[d.jsx(Et,{size:16}),d.jsx(ne,{variant:"caption",children:"Warte auf Autorisierung..."})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.codex.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!m&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.codex?.loggedIn?"outlined":"contained",onClick:q,sx:{flex:e.codex?.loggedIn?"1 1 auto":"1"},children:e.codex?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.codex?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:W,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})}),d.jsx(Zi,{item:!0,xs:12,md:4,children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.gemini.name")}),e.gemini?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.gemini.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.gemini.email]})]}):M?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"1. Ein neuer Tab mit Google-Anmeldung wurde geöffnet"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"2. Nach der Anmeldung zeigt Google Ihnen einen Code an"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"3. Kopieren Sie den Code und fügen Sie ihn unten ein:"}),d.jsx(_t,{fullWidth:!0,size:"small",placeholder:"Autorisierungscode hier einfügen",value:N,onChange:P=>L(P.target.value),sx:{mt:1}}),d.jsxs(ue,{sx:{mt:1,display:"flex",gap:1},children:[d.jsx(He,{variant:"contained",size:"small",onClick:_,disabled:!N.trim(),children:"Bestätigen"}),d.jsx(He,{variant:"text",size:"small",onClick:()=>{k(null),L("")},children:Y("common.cancel")})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.gemini.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!M&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.gemini?.loggedIn?"outlined":"contained",onClick:R,sx:{flex:e.gemini?.loggedIn?"1 1 auto":"1"},children:e.gemini?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.gemini?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:B,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})})]}),d.jsxs(zt,{severity:"info",sx:{mt:3},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:d.jsx("strong",{children:"Hinweis zur Remote-Authentifizierung:"})}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Claude:"})," Verwendet manuellen Code-Flow - authentifizieren Sie sich in einem neuen Tab, dann fügen Sie die gesamte Callback-URL ein."]}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Codex:"})," Verwendet Device-Flow - besuchen Sie die URL und geben Sie den angezeigten Code ein."]}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Gemini:"})," Verwendet manuellen Code-Flow - authentifizieren Sie sich in einem neuen Tab, dann fügen Sie den von Google angezeigten Code ein."]})]})]})}function bL({onCreateJob:e}){const n=ya(),[o,i]=v.useState([]),[s,c]=v.useState(!0),[u,p]=v.useState(""),[m,g]=v.useState(null),[y,b]=v.useState(null);v.useEffect(()=>{w()},[]);const w=async()=>{c(!0);try{const j=await Ka.list({search:u||void 0});i(j.data.jobs)}catch(j){console.error("Failed to load jobs:",j)}finally{c(!1)}},T=()=>{w()},x=async j=>{try{await Ka.delete(j),await w()}catch(M){console.error("Failed to delete job:",M)}g(null),b(null)},S=(j,M)=>{j.stopPropagation(),g(j.currentTarget),b(M)},E=()=>{g(null),b(null)},A=j=>{switch(j){case"running":return"primary";case"completed":return"success";case"failed":return"error";case"cancelled":return"warning";default:return"default"}},O=j=>{switch(j){case"pending":return"Ausstehend";case"running":return"Läuft";case"completed":return"Abgeschlossen";case"failed":return"Fehlgeschlagen";case"cancelled":return"Abgebrochen";default:return j}};return d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",gap:2,mb:3,alignItems:"center"},children:[d.jsx(_t,{size:"small",placeholder:"Jobs durchsuchen...",value:u,onChange:j=>p(j.target.value),onKeyPress:j=>j.key==="Enter"&&T(),InputProps:{startAdornment:d.jsx(eg,{position:"start",children:d.jsx(dL,{})})},sx:{flexGrow:1,maxWidth:400}}),d.jsx(no,{title:"Aktualisieren",children:d.jsx("span",{children:d.jsx(Vt,{onClick:w,disabled:s,children:d.jsx(Vd,{})})})}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:e,children:"Neuer Job"})]}),s?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):o.length===0?d.jsxs(to,{sx:{p:4,textAlign:"center"},children:[d.jsx(ne,{color:"text.secondary",gutterBottom:!0,children:"Keine Jobs gefunden"}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Erstellen Sie einen neuen Job, um mit LLMs zu arbeiten."}),d.jsx(He,{variant:"outlined",startIcon:d.jsx(hs,{}),onClick:e,children:"Ersten Job erstellen"})]}):d.jsx(Zi,{container:!0,spacing:2,children:o.map(j=>d.jsx(Zi,{item:!0,xs:12,md:6,lg:4,children:d.jsxs(to,{sx:{cursor:"pointer",transition:"all 0.2s","&:hover":{transform:"translateY(-2px)",boxShadow:4}},onClick:()=>n(`/jobs/${j.id}`),children:[d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1},children:[d.jsx(ne,{variant:"h6",noWrap:!0,sx:{flex:1},children:j.name}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(Jt,{label:O(j.status),color:A(j.status),size:"small"}),d.jsx(Vt,{size:"small",onClick:M=>S(M,j.id),children:d.jsx(VC,{fontSize:"small"})})]})]}),j.description&&d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:1,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:j.description}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[d.jsx(pc,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",noWrap:!0,children:j.workingDirectory})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mt:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[d.jsx(fm,{fontSize:"small",color:"action"}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[j.conversationCount," Konversationen"]})]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[j.messageCount," Nachrichten"]})]})]}),d.jsx(Ku,{sx:{pt:0},children:d.jsxs(ne,{variant:"caption",color:"text.secondary",children:["Erstellt:"," ",new Date(j.createdAt).toLocaleDateString("de-DE")]})})]})},j.id))}),d.jsx(Ld,{anchorEl:m,open:!!m,onClose:E,children:d.jsxs(fa,{onClick:()=>y&&x(y),sx:{color:"error.main"},children:[d.jsx(Fd,{fontSize:"small",sx:{mr:1}}),"Löschen"]})})]})}function xL({conversations:e,onCreateConversation:n,onRefresh:o}){const i=ya(),c=Rr().pathname.split("/")[2],[u,p]=v.useState(null),[m,g]=v.useState(null),[y,b]=v.useState(!1),[w,T]=v.useState(!1),x=(k,N)=>{k.stopPropagation(),p(k.currentTarget),g(N)},S=()=>{p(null)},E=()=>{S(),b(!0)},A=async()=>{if(m){T(!0);try{await rs.delete(m),o(),b(!1),g(null)}catch(k){console.error("Failed to delete conversation:",k),alert("Fehler beim Löschen der Konversation")}finally{T(!1)}}},O=()=>{b(!1),g(null)},j=k=>{switch(k){case"claude":return{label:"Claude",color:"#D97706"};case"codex":return{label:"Codex",color:"#059669"};case"gemini":return{label:"Gemini",color:"#2563EB"};default:return{label:k,color:"#6B7280"}}},M=k=>{if(!k)return"Noch keine Nachrichten";const N=new Date(k),U=new Date().getTime()-N.getTime(),$=Math.floor(U/6e4),F=Math.floor($/60),q=Math.floor(F/24);return $<1?"Gerade eben":$<60?`vor ${$} Min.`:F<24?`vor ${F} Std.`:q<7?`vor ${q} Tagen`:N.toLocaleDateString("de-DE")};return e.length===0?d.jsxs(ue,{sx:{textAlign:"center",py:4},children:[d.jsx(fm,{sx:{fontSize:48,color:"text.secondary",mb:2}}),d.jsx(ne,{color:"text.secondary",gutterBottom:!0,children:"Noch keine Konversationen"}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Starten Sie eine neue Konversation mit einem LLM."}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:n,children:"Konversation starten"})]}):d.jsxs(ue,{children:[d.jsx(ue,{sx:{display:"flex",flexWrap:"wrap",gap:2,p:2},children:e.map(k=>{const N=j(k.provider);return d.jsxs(to,{sx:{width:{xs:"100%",sm:"calc(50% - 8px)",md:"calc(33.33% - 11px)"},minWidth:280,position:"relative"},children:[d.jsx(Vt,{size:"small",onClick:L=>x(L,k.id),sx:{position:"absolute",top:8,right:8,zIndex:1},children:d.jsx(VC,{fontSize:"small"})}),d.jsx(xO,{onClick:()=>i(`/jobs/${c}/conversations/${k.id}`),children:d.jsxs(No,{children:[d.jsx(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1},children:d.jsxs(ue,{sx:{flex:1,minWidth:0,pr:4},children:[d.jsx(ne,{variant:"subtitle1",noWrap:!0,children:k.title||`Konversation ${k.id.slice(0,8)}`}),d.jsx(Jt,{label:N.label,size:"small",sx:{backgroundColor:N.color,color:"white",mt:.5}})]})}),d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{mb:1},children:["Model: ",k.model]}),d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:2},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(fm,{fontSize:"small",color:"action"}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[k.messageCount," Nachrichten"]})]}),k.totalTokens&&d.jsxs(ne,{variant:"caption",color:"text.secondary",children:[k.totalTokens.toLocaleString("de-DE")," ","Tokens"]})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5,mt:1},children:[d.jsx(WC,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:M(k.lastMessageAt)})]}),!k.isActive&&d.jsx(Jt,{label:"Inaktiv",size:"small",color:"default",sx:{mt:1}})]})})]},k.id)})}),d.jsx(Ld,{anchorEl:u,open:!!u,onClose:S,children:d.jsxs(fa,{onClick:E,sx:{color:"error.main"},children:[d.jsx(Fd,{fontSize:"small",sx:{mr:1}}),"Löschen"]})}),d.jsxs(oo,{open:y,onClose:O,children:[d.jsx(so,{children:"Konversation löschen?"}),d.jsx(io,{children:d.jsx(em,{children:"Möchten Sie diese Konversation wirklich löschen? Alle Nachrichten gehen dabei verloren. Diese Aktion kann nicht rückgängig gemacht werden."})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:O,disabled:w,children:"Abbrechen"}),d.jsx(He,{onClick:A,color:"error",variant:"contained",disabled:w,children:w?"Wird gelöscht...":"Löschen"})]})]})]})}function SL({job:e,onRefresh:n}){const o=ya(),s=Rr().pathname.split("/"),c=s[s.length-1],[u,p]=v.useState(null),[m,g]=v.useState([]),[y,b]=v.useState(""),[w,T]=v.useState(!0),[x,S]=v.useState(!1),[E,A]=v.useState(null),O=v.useRef(null);v.useEffect(()=>{c&&(j(),M())},[c]),v.useEffect(()=>{k()},[m]);const j=async()=>{if(c)try{const q=await rs.get(c);p(q.data)}catch(q){console.error("Failed to load conversation:",q),A("Fehler beim Laden der Konversation")}},M=async()=>{if(c){T(!0),A(null);try{const q=await rs.getMessages(c,{limit:100});g(q.data.messages)}catch(q){console.error("Failed to load messages:",q),A("Fehler beim Laden der Nachrichten")}finally{T(!1)}}},k=()=>{O.current?.scrollIntoView({behavior:"smooth"})},N=async()=>{if(!y.trim()||x||!c||!u)return;const q=y.trim();b(""),S(!0),A(null);const R={id:`temp-${Date.now()}`,conversationId:c,role:"user",content:q,createdAt:new Date().toISOString()};g(_=>[..._,R]);try{const _=await rs.sendMessage(c,{content:q});g(I=>[...I.filter(B=>B.id!==R.id),_.data.userMessage,_.data.assistantMessage])}catch(_){console.error("Failed to send message:",_),A(_.response?.data?.error||"Fehler beim Senden der Nachricht"),g(I=>I.filter(W=>W.id!==R.id)),b(q)}finally{S(!1)}},L=q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),N())},U=q=>{switch(q){case"claude":return{label:"Claude",color:"#D97706"};case"codex":return{label:"Codex",color:"#059669"};case"gemini":return{label:"Gemini",color:"#2563EB"};default:return{label:q,color:"#6B7280"}}};if(w||!u)return d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})});if(E&&!u)return d.jsx(ue,{sx:{p:3},children:d.jsx(zt,{severity:"error",children:E})});const $=U(u.provider),F=q=>{const R=q.role==="user",_=q.role==="system";return q.role,d.jsx(ue,{sx:{display:"flex",justifyContent:R?"flex-end":"flex-start",mb:2},children:d.jsxs(Ft,{sx:{p:2,maxWidth:"80%",backgroundColor:R?"primary.dark":_?"grey.800":"grey.900",borderRadius:2},children:[!R&&d.jsxs(ne,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:[_?"System":$.label,q.model&&` (${q.model})`]}),d.jsx(ue,{sx:{"& p":{m:0,mb:1,"&:last-child":{mb:0}},"& pre":{m:0,mb:1,p:1.5,backgroundColor:"rgba(0,0,0,0.3)",borderRadius:1,overflow:"auto"},"& code":{backgroundColor:"rgba(0,0,0,0.3)",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"0.9em"},whiteSpace:"pre-wrap",wordBreak:"break-word"},children:d.jsx(ne,{component:"div",sx:{whiteSpace:"pre-wrap"},children:q.content})}),q.tokenUsage&&d.jsxs(ne,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:["Tokens: ",q.tokenUsage.total.toLocaleString("de-DE")]}),d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:new Date(q.createdAt).toLocaleTimeString("de-DE")})]})},q.id)};return d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",height:"calc(100vh - 200px)"},children:[d.jsx(Ft,{sx:{p:2,mb:2},children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2},children:[d.jsx(Vt,{onClick:()=>o(`/jobs/${e.id}`),children:d.jsx(dd,{})}),d.jsxs(ue,{sx:{flex:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(ne,{variant:"h6",children:u.title||`Konversation ${u.id.slice(0,8)}`}),d.jsx(Jt,{label:$.label,size:"small",sx:{backgroundColor:$.color,color:"white"}})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mt:.5},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:["Model: ",u.model]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[d.jsx(pc,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:e.workingDirectory})]})]})]}),d.jsxs(ue,{sx:{textAlign:"right"},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[m.length," Nachrichten"]}),u.totalTokens&&d.jsxs(ne,{variant:"caption",color:"text.secondary",children:[u.totalTokens.toLocaleString("de-DE")," Tokens"]})]})]})}),d.jsx(Ft,{sx:{flex:1,overflow:"auto",p:2,mb:2,backgroundColor:"background.default"},children:w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):E?d.jsx(zt,{severity:"error",children:E}):m.length===0?d.jsx(ue,{sx:{textAlign:"center",py:4},children:d.jsx(ne,{color:"text.secondary",children:"Noch keine Nachrichten. Starten Sie die Konversation!"})}):d.jsxs(d.Fragment,{children:[m.map(F),x&&d.jsx(ue,{sx:{display:"flex",justifyContent:"flex-start",mb:2},children:d.jsx(Ft,{sx:{p:2,backgroundColor:"grey.900"},children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(Et,{size:16}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[$.label," denkt nach..."]})]})})}),d.jsx("div",{ref:O})]})}),d.jsxs(Ft,{sx:{p:2},children:[E&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>A(null),children:E}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(_t,{fullWidth:!0,multiline:!0,maxRows:4,value:y,onChange:q=>b(q.target.value),onKeyPress:L,placeholder:"Nachricht eingeben... (Enter zum Senden, Shift+Enter für neue Zeile)",disabled:x,size:"small"}),d.jsx(no,{title:"Nachricht senden",children:d.jsx("span",{children:d.jsx(Vt,{color:"primary",onClick:N,disabled:!y.trim()||x,children:x?d.jsx(Et,{size:24}):d.jsx(fL,{})})})})]})]})]})}function h1(e){const{children:n,value:o,index:i,...s}=e;return d.jsx("div",{role:"tabpanel",hidden:o!==i,...s,children:o===i&&d.jsx(ue,{sx:{py:2},children:n})})}function CL({onCreateConversation:e,initialConversationId:n}){const o=Rr(),i=ya(),c=o.pathname.split("/")[2],[u,p]=v.useState(null),[m,g]=v.useState([]),[y,b]=v.useState(null),[w,T]=v.useState(!0),[x,S]=v.useState(0),[E,A]=v.useState(null);v.useEffect(()=>{c&&O()},[c]);const O=async()=>{if(c){T(!0),A(null);try{const[U,$,F]=await Promise.all([Ka.get(c),Ka.getStatus(c),Ka.getConversations(c)]);p(U.data),b($.data.statistics),g(F.data.conversations)}catch(U){console.error("Failed to load job data:",U),A("Fehler beim Laden der Job-Daten")}finally{T(!1)}}},j=async()=>{if(!(!u||!c))try{await Ka.cancel(c),await O()}catch(U){console.error("Failed to cancel job:",U)}},M=U=>{switch(U){case"running":return"primary";case"completed":return"success";case"failed":return"error";case"cancelled":return"warning";default:return"default"}},k=U=>{switch(U){case"pending":return"Ausstehend";case"running":return"Läuft";case"completed":return"Abgeschlossen";case"failed":return"Fehlgeschlagen";case"cancelled":return"Abgebrochen";default:return U}},N=U=>{switch(U){case"claude":return"#D97706";case"codex":return"#059669";case"gemini":return"#2563EB";default:return"#6B7280"}};return w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):E||!u?d.jsxs(ue,{children:[d.jsx(Vt,{onClick:()=>i("/jobs"),sx:{mb:2},children:d.jsx(dd,{})}),d.jsx(zt,{severity:"error",children:E||"Job nicht gefunden"})]}):o.pathname.includes("/conversations/")?w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):u?d.jsx(SL,{job:u,onRefresh:O}):d.jsxs(ue,{children:[d.jsx(Vt,{onClick:()=>i("/jobs"),sx:{mb:2},children:d.jsx(dd,{})}),d.jsx(zt,{severity:"error",children:"Job nicht gefunden"})]}):d.jsx(wL,{job:u,conversations:m,statistics:y,tabValue:x,setTabValue:S,onCreateConversation:e,loadJobData:O,handleCancelJob:j,getStatusLabel:k,getStatusColor:M,getProviderColor:N})}function wL({job:e,conversations:n,statistics:o,tabValue:i,setTabValue:s,onCreateConversation:c,loadJobData:u,handleCancelJob:p,getStatusLabel:m,getStatusColor:g,getProviderColor:y}){const b=ya();return d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mb:3},children:[d.jsx(Vt,{onClick:()=>b("/jobs"),children:d.jsx(dd,{})}),d.jsxs(ue,{sx:{flex:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2},children:[d.jsx(ne,{variant:"h5",children:e.name}),d.jsx(Jt,{label:m(e.status),color:g(e.status),size:"small"})]}),e.description&&d.jsx(ne,{variant:"body2",color:"text.secondary",children:e.description})]}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(no,{title:"Aktualisieren",children:d.jsx(Vt,{onClick:u,children:d.jsx(Vd,{})})}),e.status==="running"&&d.jsx(He,{variant:"outlined",color:"warning",startIcon:d.jsx(ZD,{}),onClick:p,children:"Abbrechen"}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:c,children:"Neue Konversation"})]})]}),d.jsxs(Ft,{sx:{p:2,mb:3},children:[d.jsxs(ue,{sx:{display:"flex",gap:4,flexWrap:"wrap"},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(pc,{color:"action"}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Arbeitsverzeichnis"}),d.jsx(ne,{variant:"body2",children:e.workingDirectory})]})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Erstellt"}),d.jsx(ne,{variant:"body2",children:new Date(e.createdAt).toLocaleString("de-DE")})]}),o&&d.jsxs(d.Fragment,{children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Konversationen"}),d.jsx(ne,{variant:"body2",children:o.conversationCount})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Nachrichten"}),d.jsx(ne,{variant:"body2",children:o.messageCount})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Tokens gesamt"}),d.jsx(ne,{variant:"body2",children:o.tokenUsage.total.toLocaleString("de-DE")})]})]})]}),o&&o.providerBreakdown.length>0&&d.jsxs(ue,{sx:{mt:2},children:[d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:"Provider-Verteilung"}),d.jsx(ue,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:o.providerBreakdown.map(w=>d.jsx(Jt,{label:`${w.provider}: ${w.conversationCount} Konv. / ${w.messageCount} Nachr.`,size:"small",sx:{backgroundColor:y(w.provider),color:"white"}},w.provider))})]})]}),d.jsxs(Ft,{children:[d.jsxs(hC,{value:i,onChange:(w,T)=>s(T),children:[d.jsx(im,{label:`Konversationen (${n.length})`}),d.jsx(im,{label:"System Prompt"})]}),d.jsx(h1,{value:i,index:0,children:d.jsx(xL,{conversations:n,onCreateConversation:c,onRefresh:u})}),d.jsx(h1,{value:i,index:1,children:d.jsx(ue,{sx:{p:2},children:e.systemPrompt?d.jsx(Ft,{variant:"outlined",sx:{p:2,backgroundColor:"grey.900",fontFamily:"monospace",whiteSpace:"pre-wrap"},children:e.systemPrompt}):d.jsx(ne,{color:"text.secondary",children:"Kein System Prompt definiert"})})})]})]})}function EL({open:e,onClose:n,onSelect:o,initialPath:i,title:s="Verzeichnis auswählen"}){const[c,u]=v.useState(!0),[p,m]=v.useState(null),[g,y]=v.useState(null),[b,w]=v.useState(null),[T,x]=v.useState(!1),[S,E]=v.useState(""),[A,O]=v.useState(!1);v.useEffect(()=>{e&&j(i)},[e,i]);const j=async R=>{u(!0),m(null);try{const _=await dm.browse(R);y(_.data),w(_.data.currentPath)}catch(_){console.error("Failed to browse directory:",_),m(_.response?.data?.error||"Fehler beim Laden des Verzeichnisses")}finally{u(!1)}},M=R=>{R.isDirectory&&R.isReadable&&j(R.path)},k=R=>{R.isDirectory&&R.isWritable&&(o(R.path),n())},N=()=>{g?.parentPath&&j(g.parentPath)},L=R=>{j(R)},U=()=>{b&&(o(b),n())},$=async()=>{if(!(!S.trim()||!g?.currentPath)){O(!0),m(null);try{const R=await dm.mkdir(g.currentPath,S.trim());E(""),x(!1),j(R.data.path)}catch(R){console.error("Failed to create folder:",R),m(R.response?.data?.error||"Fehler beim Erstellen des Ordners")}finally{O(!1)}}},F=R=>R===void 0?"":R<1024?`${R} B`:R<1024*1024?`${(R/1024).toFixed(1)} KB`:`${(R/(1024*1024)).toFixed(1)} MB`,q=R=>{const _=R.split("/").filter(Boolean),I=[];let W="";for(const B of _)W+="/"+B,I.push({name:B,path:W});return I};return d.jsxs(oo,{open:e,onClose:n,maxWidth:"md",fullWidth:!0,children:[d.jsx(so,{children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[d.jsx(ne,{variant:"h6",children:s}),d.jsx(no,{title:"Neuen Ordner erstellen",children:d.jsx(Vt,{onClick:()=>x(!T),color:"primary",children:d.jsx(tL,{})})})]})}),d.jsxs(io,{dividers:!0,children:[p&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>m(null),children:p}),g?.roots&&d.jsx(ue,{sx:{mb:2,display:"flex",gap:1,flexWrap:"wrap"},children:g.roots.map(R=>d.jsx(Jt,{icon:d.jsx(rL,{}),label:R.name,onClick:()=>L(R.path),variant:g.currentPath.startsWith(R.path)?"filled":"outlined",color:g.currentPath.startsWith(R.path)?"primary":"default"},R.path))}),g?.currentPath&&d.jsxs(ue,{sx:{mb:2,display:"flex",alignItems:"center",gap:1},children:[d.jsx(Vt,{size:"small",onClick:N,disabled:!g.parentPath,children:d.jsx(QD,{})}),d.jsx(oO,{maxItems:5,sx:{flex:1},children:q(g.currentPath).map((R,_,I)=>d.jsx(Oz,{component:"button",variant:"body2",onClick:()=>j(R.path),underline:_===I.length-1?"none":"hover",color:_===I.length-1?"text.primary":"inherit",sx:{cursor:"pointer"},children:R.name},R.path))})]}),T&&d.jsxs(ue,{sx:{mb:2,display:"flex",gap:1,alignItems:"center"},children:[d.jsx(_t,{size:"small",label:"Neuer Ordnername",value:S,onChange:R=>E(R.target.value),onKeyPress:R=>R.key==="Enter"&&$(),autoFocus:!0,sx:{flex:1}}),d.jsx(He,{variant:"contained",onClick:$,disabled:!S.trim()||A,size:"small",children:A?d.jsx(Et,{size:20}):"Erstellen"}),d.jsx(He,{variant:"outlined",onClick:()=>{x(!1),E("")},size:"small",children:"Abbrechen"})]}),d.jsx(Uo,{sx:{mb:1}}),c?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):d.jsx(nC,{dense:!0,sx:{maxHeight:400,overflow:"auto",bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:g?.entries.length===0?d.jsx(Kz,{children:d.jsx(Va,{primary:"Leeres Verzeichnis",secondary:"Dieses Verzeichnis enthält keine Einträge"})}):g?.entries.map(R=>d.jsxs(_z,{onClick:()=>M(R),onDoubleClick:()=>k(R),disabled:!R.isReadable,selected:b===R.path,children:[d.jsx(Yi,{children:R.isDirectory?d.jsx(pc,{color:R.isWritable?"primary":"disabled"}):d.jsx(oL,{color:"disabled"})}),d.jsx(Va,{primary:R.name,secondary:R.isDirectory?R.isWritable?"Ordner (beschreibbar)":"Ordner (nur lesen)":F(R.size)}),R.isDirectory&&R.isWritable&&d.jsx(no,{title:"Diesen Ordner auswählen",children:d.jsx(Vt,{size:"small",onClick:_=>{_.stopPropagation(),o(R.path),n()},color:"primary",children:d.jsx(IC,{})})})]},R.path))}),b&&d.jsxs(ue,{sx:{mt:2,p:1,bgcolor:"grey.900",borderRadius:1},children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Ausgewähltes Verzeichnis:"}),d.jsx(ne,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},children:b})]})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:n,children:"Abbrechen"}),d.jsx(He,{variant:"contained",onClick:U,disabled:!b,children:"Aktuelles Verzeichnis auswählen"})]})]})}function TL({open:e,onClose:n,onCreated:o}){const[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(""),[g,y]=v.useState(""),[b,w]=v.useState(!1),[T,x]=v.useState(null),[S,E]=v.useState(!1),A=async()=>{if(!p.trim()){x("Arbeitsverzeichnis ist erforderlich");return}w(!0),x(null);try{const M={workingDirectory:p.trim(),description:c.trim()||void 0,systemPrompt:g.trim()||void 0};i.trim()&&(M.name=i.trim());const k=await Ka.create(M);o(k.data),O()}catch(M){console.error("Failed to create job:",M),x(M.response?.data?.error||"Fehler beim Erstellen des Jobs")}finally{w(!1)}},O=()=>{s(""),u(""),m(""),y(""),x(null),n()},j=async M=>{m(M);try{const k=await dm.getGitInfo(M);k.data.isGitRepo&&k.data.repoName&&!i.trim()&&s(k.data.repoName)}catch(k){console.log("Could not fetch git info:",k)}};return d.jsxs(d.Fragment,{children:[d.jsxs(oo,{open:e,onClose:O,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:"Neuen Job erstellen"}),d.jsx(io,{children:d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[T&&d.jsx(zt,{severity:"error",children:T}),d.jsx(_t,{label:"Name",value:i,onChange:M=>s(M.target.value),fullWidth:!0,autoFocus:!0,placeholder:"z.B. Feature Implementierung (optional, wird aus Git-Repo erkannt)",helperText:"Leer lassen für automatische Erkennung aus Git-Repository"}),d.jsx(_t,{label:"Beschreibung",value:c,onChange:M=>u(M.target.value),fullWidth:!0,multiline:!0,rows:2,placeholder:"Optionale Beschreibung des Jobs"}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"subtitle2",gutterBottom:!0,children:"Arbeitsverzeichnis *"}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(_t,{value:p,onChange:M=>m(M.target.value),fullWidth:!0,required:!0,placeholder:"Verzeichnis auf dem Server auswählen...",size:"small",InputProps:{readOnly:!0,sx:{fontFamily:"monospace",fontSize:"0.9em"}}}),d.jsx(He,{variant:"outlined",onClick:()=>E(!0),startIcon:d.jsx(pc,{}),children:"Durchsuchen"})]}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Wählen Sie ein Verzeichnis auf dem Server für diesen Job aus"})]}),d.jsx(_t,{label:"System Prompt (optional)",value:g,onChange:M=>y(M.target.value),fullWidth:!0,multiline:!0,rows:4,placeholder:"Optionaler System Prompt, der für alle Konversationen dieses Jobs verwendet wird"})]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:O,disabled:b,children:"Abbrechen"}),d.jsx(He,{onClick:A,variant:"contained",disabled:b||!i.trim()||!p.trim(),children:b?d.jsx(Et,{size:24}):"Erstellen"})]})]}),d.jsx(EL,{open:S,onClose:()=>E(!1),onSelect:j,initialPath:p||void 0,title:"Arbeitsverzeichnis auswählen"})]})}const m1={claude:["claude-sonnet-4-20250514","claude-3-5-sonnet-20241022","claude-3-opus-20240229"],codex:["default","o4-mini","o3","codex"],gemini:["gemini-2.5-pro","gemini-2.0-flash","gemini-1.5-pro"]};function RL({open:e,jobId:n,onClose:o,onCreated:i}){const[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(""),[y,b]=v.useState(""),[w,T]=v.useState(!1),[x,S]=v.useState(!0),[E,A]=v.useState([]),[O,j]=v.useState(null);v.useEffect(()=>{e&&M()},[e]),v.useEffect(()=>{p(s&&m1[s][0]||"")},[s]);const M=async()=>{S(!0);try{const $=await rs.getProviders();A($.data.providers);const F=$.data.providers.find(q=>q.isAuthenticated);F&&c(F.provider)}catch($){console.error("Failed to load providers:",$),j("Fehler beim Laden der Provider")}finally{S(!1)}},k=async()=>{if(!s){j("Bitte wählen Sie einen Provider aus");return}T(!0),j(null);try{const $={jobId:n,provider:s,model:u||void 0,title:m.trim()||void 0,systemPrompt:y.trim()||void 0},F=await rs.create($);i(F.data.conversation),N()}catch($){console.error("Failed to create conversation:",$),j($.response?.data?.error||"Fehler beim Erstellen der Konversation")}finally{T(!1)}},N=()=>{c(""),p(""),g(""),b(""),j(null),o()},L=$=>{switch($){case"claude":return"Claude (Anthropic)";case"codex":return"Codex (OpenAI)";case"gemini":return"Gemini (Google)";default:return $}},U=$=>{switch($){case"claude":return"#D97706";case"codex":return"#059669";case"gemini":return"#2563EB";default:return"#6B7280"}};return d.jsxs(oo,{open:e,onClose:N,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:"Neue Konversation starten"}),d.jsx(io,{children:d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[O&&d.jsx(zt,{severity:"error",children:O}),x?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:2},children:d.jsx(Et,{})}):d.jsxs(d.Fragment,{children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"subtitle2",gutterBottom:!0,children:"LLM Provider auswählen"}),d.jsx(ue,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:E.map($=>d.jsx(Jt,{label:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[L($.provider),$.isAuthenticated?d.jsx(IC,{fontSize:"small",sx:{color:"success.main"}}):d.jsx(HC,{fontSize:"small",sx:{color:"error.main"}})]}),onClick:()=>$.isAuthenticated&&c($.provider),disabled:!$.isAuthenticated,variant:s===$.provider?"filled":"outlined",sx:{borderColor:U($.provider),backgroundColor:s===$.provider?U($.provider):"transparent",color:s===$.provider?"white":"inherit","&:hover":{backgroundColor:$.isAuthenticated?U($.provider):void 0,color:$.isAuthenticated?"white":void 0}}},$.provider))}),E.some($=>!$.isAuthenticated)&&d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{mt:.5,display:"block"},children:'Nicht authentifizierte Provider sind deaktiviert. Gehen Sie zu "Provider Authentifizierung" um sich anzumelden.'})]}),s&&d.jsxs(eC,{fullWidth:!0,children:[d.jsx(tC,{children:"Model"}),d.jsx(ag,{value:u,label:"Model",onChange:$=>p($.target.value),children:m1[s].map($=>d.jsx(fa,{value:$,children:$},$))})]}),d.jsx(_t,{label:"Titel (optional)",value:m,onChange:$=>g($.target.value),fullWidth:!0,placeholder:"z.B. Bug Fix Discussion"}),d.jsx(_t,{label:"System Prompt (optional)",value:y,onChange:$=>b($.target.value),fullWidth:!0,multiline:!0,rows:3,placeholder:"Optionaler System Prompt für diese Konversation",helperText:"Wenn leer, wird der System Prompt des Jobs verwendet"})]})]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:N,disabled:w,children:"Abbrechen"}),d.jsx(He,{onClick:k,variant:"contained",disabled:w||!s||x,children:w?d.jsx(Et,{size:24}):"Starten"})]})]})}function jL(){const[e,n]=v.useState([]),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(!1),[m,g]=v.useState(""),[y,b]=v.useState(""),[w,T]=v.useState(!1),[x,S]=v.useState(null),[E,A]=v.useState(!0),[O,j]=v.useState(!1),[M,k]=v.useState(!1),[N,L]=v.useState(null),[U,$]=v.useState(!1);v.useEffect(()=>{F()},[]);const F=async()=>{try{i(!0);const P=await Mh.list();n(P.data.data)}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{i(!1)}},q=async()=>{try{T(!0),c("");const P=await Mh.create({name:m,expiresAt:y||void 0});S(P.data.data.key),g(""),b(""),F()}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{T(!1)}},R=()=>{x&&(navigator.clipboard.writeText(x),j(!0),setTimeout(()=>j(!1),2e3))},_=()=>{p(!1),S(null),A(!0),j(!1)},I=async()=>{if(N)try{$(!0),await Mh.revoke(N.id),k(!1),L(null),F()}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{$(!1)}},W=P=>P?new Date(P).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",B=P=>P.revokedAt?d.jsx(Jt,{label:Y("apiKeys.revoked"),color:"error",size:"small"}):P.expiresAt&&new Date(P.expiresAt)<new Date?d.jsx(Jt,{label:Y("apiKeys.expired"),color:"warning",size:"small"}):d.jsx(Jt,{label:Y("apiKeys.active"),color:"success",size:"small"});return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("apiKeys.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("apiKeys.subtitle")})]}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:()=>p(!0),children:Y("apiKeys.createKey")})]}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),e.length===0?d.jsx(Ft,{sx:{p:4,textAlign:"center"},children:d.jsx(ne,{color:"text.secondary",children:Y("apiKeys.noKeys")})}):d.jsx(fC,{component:Ft,children:d.jsxs(uC,{children:[d.jsx(pC,{children:d.jsxs(cd,{children:[d.jsx(Mt,{children:Y("apiKeys.keyName")}),d.jsx(Mt,{children:Y("apiKeys.keyPrefix")}),d.jsx(Mt,{children:Y("common.status")}),d.jsx(Mt,{children:Y("apiKeys.lastUsed")}),d.jsx(Mt,{children:Y("apiKeys.expiresAt")}),d.jsx(Mt,{children:Y("common.createdAt")}),d.jsx(Mt,{align:"right",children:Y("common.actions")})]})}),d.jsx(dC,{children:e.map(P=>d.jsxs(cd,{children:[d.jsx(Mt,{children:d.jsx(ne,{sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.name})}),d.jsx(Mt,{children:d.jsxs(ne,{variant:"body2",sx:{fontFamily:"monospace"},children:[P.keyPrefix,"..."]})}),d.jsx(Mt,{children:B(P)}),d.jsx(Mt,{children:P.lastUsedAt?W(P.lastUsedAt):Y("apiKeys.neverUsed")}),d.jsx(Mt,{children:P.expiresAt?W(P.expiresAt):Y("apiKeys.neverExpires")}),d.jsx(Mt,{children:W(P.createdAt)}),d.jsx(Mt,{align:"right",children:P.isValid&&d.jsx(no,{title:Y("apiKeys.revoke"),children:d.jsx(Vt,{size:"small",color:"error",onClick:()=>{L(P),k(!0)},children:d.jsx(Fd,{})})})})]},P.id))})]})}),d.jsxs(oo,{open:u,onClose:_,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:Y(x?"apiKeys.newKeyCreated":"apiKeys.createKey")}),d.jsx(io,{children:x?d.jsxs(ue,{children:[d.jsx(zt,{severity:"warning",sx:{mb:2},children:Y("apiKeys.copyWarning")}),d.jsx(_t,{fullWidth:!0,value:x,type:E?"text":"password",InputProps:{readOnly:!0,sx:{fontFamily:"monospace"},endAdornment:d.jsxs(eg,{position:"end",children:[d.jsx(Vt,{onClick:()=>A(!E),children:E?d.jsx(mL,{}):d.jsx(hL,{})}),d.jsx(Vt,{onClick:R,color:O?"success":"default",children:d.jsx(FC,{})})]})}}),O&&d.jsx(ne,{variant:"caption",color:"success.main",sx:{mt:1,display:"block"},children:Y("common.copied")})]}):d.jsxs(ue,{sx:{pt:1},children:[d.jsx(_t,{fullWidth:!0,label:Y("apiKeys.keyName"),value:m,onChange:P=>g(P.target.value),margin:"normal",required:!0,autoFocus:!0}),d.jsx(_t,{fullWidth:!0,label:Y("apiKeys.expirationDate"),type:"datetime-local",value:y,onChange:P=>b(P.target.value),margin:"normal",InputLabelProps:{shrink:!0},helperText:Y("apiKeys.expirationHelp")})]})}),d.jsx(ao,{children:x?d.jsx(He,{onClick:_,children:Y("common.close")}):d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:_,children:Y("common.cancel")}),d.jsx(He,{variant:"contained",onClick:q,disabled:!m||w,children:w?d.jsx(Et,{size:24}):Y("common.create")})]})})]}),d.jsxs(oo,{open:M,onClose:()=>k(!1),children:[d.jsx(so,{children:Y("apiKeys.revoke")}),d.jsxs(io,{children:[d.jsx(ne,{children:Y("apiKeys.revokeConfirm")}),N&&d.jsxs(ne,{variant:"body2",sx:{mt:1,fontFamily:"monospace"},children:[N.name," (",N.keyPrefix,"...)"]})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>k(!1),children:Y("common.cancel")}),d.jsx(He,{variant:"contained",color:"error",onClick:I,disabled:U,children:U?d.jsx(Et,{size:24}):Y("apiKeys.revoke")})]})]})]})}const AL=["job.created","job.updated","job.completed","job.failed","job.cancelled","conversation.created","conversation.updated","message.created","message.streaming","message.completed","tool.called","tool.completed"];function ML(){const[e,n]=v.useState([]),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(!1),[y,b]=v.useState(""),[w,T]=v.useState(""),[x,S]=v.useState([]),[E,A]=v.useState(!1),[O,j]=v.useState(null),[M,k]=v.useState(!1),[N,L]=v.useState(!1),[U,$]=v.useState(null),[F,q]=v.useState(!1);v.useEffect(()=>{R()},[]);const R=async()=>{try{i(!0);const H=await Wi.list();n(H.data.data)}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{i(!1)}},_=async()=>{try{A(!0),c("");const H=await Wi.create({name:y,url:w,events:x});j(H.data.data.secret),R()}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{A(!1)}},I=()=>{O&&(navigator.clipboard.writeText(O),k(!0),setTimeout(()=>k(!1),2e3))},W=()=>{g(!1),j(null),b(""),T(""),S([]),k(!1)},B=async H=>{try{await Wi.update(H.id,{active:!H.active}),R()}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},P=async()=>{if(U)try{q(!0),await Wi.delete(U.id),L(!1),$(null),R()}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{q(!1)}},X=async H=>{try{await Wi.test(H.id),p("Test-Webhook wurde gesendet"),setTimeout(()=>p(""),3e3)}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},Z=async H=>{try{const Q=await Wi.regenerateSecret(H.id);j(Q.data.data.secret),p("Neues Secret generiert")}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},pe=H=>H?new Date(H).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",D=H=>{x.includes(H)?S(x.filter(Q=>Q!==H)):S([...x,H])};return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("webhooks.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("webhooks.subtitle")})]}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:()=>g(!0),children:Y("webhooks.createWebhook")})]}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),u&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>p(""),children:u}),e.length===0?d.jsx(Ft,{sx:{p:4,textAlign:"center"},children:d.jsx(ne,{color:"text.secondary",children:Y("webhooks.noWebhooks")})}):d.jsx(fC,{component:Ft,children:d.jsxs(uC,{children:[d.jsx(pC,{children:d.jsxs(cd,{children:[d.jsx(Mt,{children:Y("webhooks.webhookName")}),d.jsx(Mt,{children:Y("webhooks.webhookUrl")}),d.jsx(Mt,{children:Y("webhooks.events")}),d.jsx(Mt,{children:Y("common.status")}),d.jsx(Mt,{children:Y("webhooks.lastTriggered")}),d.jsx(Mt,{children:Y("webhooks.failures")}),d.jsx(Mt,{align:"right",children:Y("common.actions")})]})}),d.jsx(dC,{children:e.map(H=>d.jsxs(cd,{children:[d.jsx(Mt,{children:d.jsx(ne,{sx:{maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H.name})}),d.jsx(Mt,{children:d.jsx(ne,{variant:"body2",sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"0.8rem"},children:H.url})}),d.jsx(Mt,{children:d.jsxs(ue,{sx:{display:"flex",gap:.5,flexWrap:"wrap",maxWidth:200},children:[H.events.slice(0,3).map(Q=>d.jsx(Jt,{label:Q.split(".")[1],size:"small",variant:"outlined"},Q)),H.events.length>3&&d.jsx(Jt,{label:`+${H.events.length-3}`,size:"small",variant:"outlined"})]})}),d.jsx(Mt,{children:d.jsx(lB,{checked:H.active,onChange:()=>B(H),size:"small"})}),d.jsx(Mt,{children:pe(H.lastTriggeredAt)}),d.jsx(Mt,{children:H.failureCount>0?d.jsx(Jt,{label:H.failureCount,color:"error",size:"small"}):"0"}),d.jsxs(Mt,{align:"right",children:[d.jsx(no,{title:Y("webhooks.testWebhook"),children:d.jsx(Vt,{size:"small",onClick:()=>X(H),children:d.jsx(cL,{})})}),d.jsx(no,{title:Y("webhooks.regenerateSecret"),children:d.jsx(Vt,{size:"small",onClick:()=>Z(H),children:d.jsx(Vd,{})})}),d.jsx(no,{title:Y("common.delete"),children:d.jsx(Vt,{size:"small",color:"error",onClick:()=>{$(H),L(!0)},children:d.jsx(Fd,{})})})]})]},H.id))})]})}),d.jsxs(oo,{open:m,onClose:W,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:O?"Webhook erstellt":Y("webhooks.createWebhook")}),d.jsx(io,{children:O?d.jsxs(ue,{children:[d.jsx(zt,{severity:"warning",sx:{mb:2},children:Y("apiKeys.copyWarning")}),d.jsx(_t,{fullWidth:!0,label:"Webhook Secret",value:O,InputProps:{readOnly:!0,sx:{fontFamily:"monospace"},endAdornment:d.jsx(eg,{position:"end",children:d.jsx(Vt,{onClick:I,color:M?"success":"default",children:d.jsx(FC,{})})})}}),M&&d.jsx(ne,{variant:"caption",color:"success.main",sx:{mt:1,display:"block"},children:Y("common.copied")})]}):d.jsxs(ue,{sx:{pt:1},children:[d.jsx(_t,{fullWidth:!0,label:Y("webhooks.webhookName"),value:y,onChange:H=>b(H.target.value),margin:"normal",required:!0,autoFocus:!0}),d.jsx(_t,{fullWidth:!0,label:Y("webhooks.webhookUrl"),value:w,onChange:H=>T(H.target.value),margin:"normal",required:!0,placeholder:"https://example.com/webhook"}),d.jsx(ne,{variant:"subtitle2",sx:{mt:2,mb:1},children:Y("webhooks.selectEvents")}),d.jsx(Ft,{variant:"outlined",sx:{p:2,maxHeight:300,overflow:"auto"},children:d.jsx(X3,{children:AL.map(H=>d.jsx(W3,{control:d.jsx(_O,{checked:x.includes(H),onChange:()=>D(H),size:"small"}),label:d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",children:H}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:Y(`webhooks.eventDescriptions.${H}`)})]})},H))})})]})}),d.jsx(ao,{children:O?d.jsx(He,{onClick:W,children:Y("common.close")}):d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:W,children:Y("common.cancel")}),d.jsx(He,{variant:"contained",onClick:_,disabled:!y||!w||x.length===0||E,children:E?d.jsx(Et,{size:24}):Y("common.create")})]})})]}),d.jsxs(oo,{open:N,onClose:()=>L(!1),children:[d.jsx(so,{children:Y("common.delete")}),d.jsxs(io,{children:[d.jsx(ne,{children:"Möchten Sie diesen Webhook wirklich löschen?"}),U&&d.jsx(ne,{variant:"body2",sx:{mt:1,fontWeight:"bold"},children:U.name})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>L(!1),children:Y("common.cancel")}),d.jsx(He,{variant:"contained",color:"error",onClick:P,disabled:F,children:F?d.jsx(Et,{size:24}):Y("common.delete")})]})]})]})}function kL(){const{user:e}=fc(),[n,o]=v.useState(""),[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(!1),[g,y]=v.useState(""),[b,w]=v.useState(""),T=async x=>{if(x.preventDefault(),y(""),w(""),i!==c){y(Y("auth.passwordMismatch"));return}if(i.length<8){y(Y("auth.passwordMinLength"));return}try{m(!0),await Cn.changePassword({currentPassword:n,newPassword:i}),w(Y("auth.passwordChanged")),o(""),s(""),u("")}catch(S){y(S.response?.data?.message||Y("errors.generic"))}finally{m(!1)}};return d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("profile.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("profile.subtitle")}),d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:3},children:[d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(qC,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("profile.accountInfo")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("auth.username"),":"]}),d.jsx(ne,{variant:"body1",children:e?.username}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("profile.role"),":"]}),d.jsx(ne,{variant:"body1",children:e?.role==="admin"?Y("profile.roleAdmin"):Y("profile.roleUser")})]})]})}),d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(aL,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("auth.changePassword")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:Y("profile.changePasswordDesc")}),g&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>y(""),children:g}),b&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>w(""),children:b}),d.jsxs(ue,{component:"form",onSubmit:T,sx:{maxWidth:400},children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.currentPassword"),type:"password",value:n,onChange:x=>o(x.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),d.jsx(_t,{fullWidth:!0,label:Y("auth.newPassword"),type:"password",value:i,onChange:x=>s(x.target.value),margin:"normal",required:!0,autoComplete:"new-password",helperText:Y("auth.passwordMinLength")}),d.jsx(_t,{fullWidth:!0,label:Y("auth.confirmPassword"),type:"password",value:c,onChange:x=>u(x.target.value),margin:"normal",required:!0,autoComplete:"new-password",error:c!==""&&i!==c,helperText:c!==""&&i!==c?Y("auth.passwordMismatch"):""}),d.jsx(He,{type:"submit",variant:"contained",sx:{mt:2},disabled:p||!n||!i||!c,children:p?d.jsx(Et,{size:24}):Y("auth.changePassword")})]})]})})]})]})}function g1(e){const n=["B","KB","MB","GB","TB"];let o=0,i=e;for(;i>=1024&&o<n.length-1;)i/=1024,o++;return`${i.toFixed(1)} ${n[o]}`}function OL(e){const n=Math.floor(e/86400),o=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return n>0?`${n}d ${o}h ${i}m`:o>0?`${o}h ${i}m`:`${i}m`}function zL(){const[e,n]=v.useState(null),[o,i]=v.useState(null),[s,c]=v.useState(""),[u,p]=v.useState(!0),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[w,T]=v.useState(""),[x,S]=v.useState(!1),[E,A]=v.useState(!1),[O,j]=v.useState({open:!1,message:"",severity:"info"}),[M,k]=v.useState(!1),[N,L]=v.useState(0),U=v.useCallback(async()=>{try{p(!0),T("");const[_,I,W]=await Promise.all([da.getVersion(),da.getInfo(),da.getUpdateLog()]);n(_.data.data),i(I.data.data),c(W.data.data.log)}catch(_){T(_.response?.data?.message||Y("errors.generic"))}finally{p(!1)}},[]);v.useEffect(()=>{U()},[U]);const $=async()=>{S(!1),g(!0),T("");try{const I=(await da.triggerUpdate()).data.data;I.success?(j({open:!0,message:I.message,severity:"success"}),I.message.includes("neu gestartet")&&await q()):j({open:!0,message:I.message,severity:"error"})}catch(_){j({open:!0,message:_.response?.data?.message||Y("errors.generic"),severity:"error"})}finally{g(!1)}},F=async()=>{A(!1),b(!0),T("");try{const I=(await da.triggerRestart()).data.data;I.success?(j({open:!0,message:I.message,severity:"info"}),await q()):j({open:!0,message:I.message,severity:"error"})}catch{j({open:!0,message:"Server startet neu...",severity:"info"}),await q()}finally{b(!1)}},q=async()=>{k(!0),L(0),await new Promise(I=>setTimeout(I,1500));const _=await da.waitForReconnect(30,2e3,(I,W)=>{L(Math.round(I/W*100))});k(!1),L(0),_?(j({open:!0,message:"Server erfolgreich neu gestartet!",severity:"success"}),U()):j({open:!0,message:"Server antwortet nicht - bitte Seite manuell neu laden",severity:"error"})},R=async()=>{try{await da.clearUpdateLog(),c("Kein Update-Log vorhanden"),j({open:!0,message:"Update-Log gelöscht",severity:"success"})}catch(_){j({open:!0,message:_.response?.data?.message||Y("errors.generic"),severity:"error"})}};return u?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("system.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.subtitle")})]}),d.jsx(no,{title:Y("common.refresh"),children:d.jsx(Vt,{onClick:U,disabled:u,children:d.jsx(Vd,{})})})]}),w&&d.jsx(zt,{severity:"error",sx:{mb:2},children:w}),M&&d.jsxs(zt,{severity:"info",sx:{mb:2},icon:d.jsx(Et,{size:20}),children:["Verbinde zum Server... (",N,"%)",d.jsx(zx,{variant:"determinate",value:N,sx:{mt:1}})]}),d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:3},children:[d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(p1,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("system.version")}),e?.updateAvailable&&d.jsx(Jt,{icon:d.jsx(lL,{}),label:Y("system.updateAvailable"),color:"warning",size:"small"})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2,mb:3},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.currentVersion"),":"]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsxs(ne,{variant:"body1",fontWeight:"medium",children:["v",e?.current||"?"]}),!e?.updateAvailable&&d.jsx(Jt,{icon:d.jsx(JD,{}),label:Y("system.upToDate"),color:"success",size:"small"})]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.latestVersion"),":"]}),d.jsxs(ne,{variant:"body1",children:["v",e?.latest||"?"]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.lastChecked"),":"]}),d.jsx(ne,{variant:"body1",children:e?.lastChecked?new Date(e.lastChecked).toLocaleString("de-DE"):"-"})]}),d.jsxs(ue,{sx:{display:"flex",gap:2},children:[d.jsx(He,{variant:"contained",startIcon:m?d.jsx(Et,{size:20}):d.jsx(p1,{}),onClick:()=>S(!0),disabled:m||y||M||!e?.updateAvailable,children:Y("system.update")}),d.jsx(He,{variant:"outlined",startIcon:y?d.jsx(Et,{size:20}):d.jsx(uL,{}),onClick:()=>A(!0),disabled:m||y||M,children:Y("system.restart")})]})]})}),d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(eL,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("system.info")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:3},children:[d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[d.jsx(WC,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.uptime")})]}),d.jsx(ne,{variant:"h6",children:o?OL(o.uptime):"-"})]}),d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[d.jsx(sL,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.memory")})]}),d.jsx(ne,{variant:"h6",children:o?`${g1(o.memoryUsage.used)} / ${g1(o.memoryUsage.total)}`:"-"}),o&&d.jsx(zx,{variant:"determinate",value:o.memoryUsage.percentage,color:o.memoryUsage.percentage>80?"error":"primary",sx:{mt:1}})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Node.js"}),d.jsx(ne,{variant:"body1",children:o?.nodeVersion||"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:Y("system.platform")}),d.jsx(ne,{variant:"body1",children:o?`${o.platform} (${o.arch})`:"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Hostname"}),d.jsx(ne,{variant:"body1",children:o?.hostname||"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Process ID"}),d.jsx(ne,{variant:"body1",children:o?`${o.pid} (Parent: ${o.ppid})`:"-"})]})]})]})}),d.jsxs(a5,{children:[d.jsx(M5,{expandIcon:d.jsx(nL,{}),children:d.jsx(ne,{children:Y("system.updateLog")})}),d.jsxs(c5,{children:[d.jsx(ue,{sx:{bgcolor:"grey.900",p:2,borderRadius:1,fontFamily:"monospace",fontSize:"0.85rem",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflow:"auto"},children:s||"Kein Update-Log vorhanden"}),d.jsx(ue,{sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:d.jsx(He,{size:"small",onClick:R,children:Y("system.clearLog")})})]})]})]}),d.jsxs(oo,{open:x,onClose:()=>S(!1),children:[d.jsx(so,{children:Y("system.confirmUpdate")}),d.jsx(io,{children:d.jsxs(em,{children:[Y("system.confirmUpdateText"),d.jsx("br",{}),d.jsx("br",{}),d.jsxs("strong",{children:[Y("system.currentVersion"),":"]})," v",e?.current,d.jsx("br",{}),d.jsxs("strong",{children:[Y("system.latestVersion"),":"]})," v",e?.latest]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>S(!1),children:Y("common.cancel")}),d.jsx(He,{onClick:$,variant:"contained",color:"primary",children:Y("system.update")})]})]}),d.jsxs(oo,{open:E,onClose:()=>A(!1),children:[d.jsx(so,{children:Y("system.confirmRestart")}),d.jsx(io,{children:d.jsx(em,{children:Y("system.confirmRestartText")})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>A(!1),children:Y("common.cancel")}),d.jsx(He,{onClick:F,variant:"contained",color:"warning",children:Y("system.restart")})]})]}),d.jsx(Y6,{open:O.open,autoHideDuration:6e3,onClose:()=>j({...O,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:d.jsx(zt,{onClose:()=>j({...O,open:!1}),severity:O.severity,action:d.jsx(Vt,{size:"small",color:"inherit",onClick:()=>j({...O,open:!1}),children:d.jsx(HC,{fontSize:"small"})}),children:O.message})})]})}function Ia(e){const{children:n,value:o,index:i,...s}=e;return d.jsx("div",{role:"tabpanel",hidden:o!==i,...s,children:o===i&&d.jsx(ue,{sx:{py:3},children:n})})}function BL(){const{user:e,logout:n}=fc(),o=ya(),i=Rr(),[s,c]=v.useState(0),[u,p]=v.useState(null),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[w,T]=v.useState(0),[x,S]=v.useState(0),[E,A]=v.useState(null),[O,j]=v.useState(""),[M,k]=v.useState(""),[N,L]=v.useState(""),[U,$]=v.useState(""),[F,q]=v.useState(!1);v.useEffect(()=>{i.pathname==="/"||i.pathname===""?o("/jobs",{replace:!0}):i.pathname.startsWith("/jobs")?c(0):i.pathname.startsWith("/provider-auth")?c(1):i.pathname.startsWith("/admin/users")&&e?.role==="admin"?c(2):i.pathname.startsWith("/settings/api-keys")?c(e?.role==="admin"?3:2):i.pathname.startsWith("/settings/webhooks")?c(e?.role==="admin"?4:3):i.pathname.startsWith("/settings/profile")?c(e?.role==="admin"?5:4):i.pathname.startsWith("/settings/system")&&e?.role==="admin"?c(6):o("/jobs",{replace:!0})},[i.pathname,e?.role,o]);const R=Q=>{T(se=>se+1),o(`/jobs/${Q.id}`)},_=Q=>{A(Q.id),S(se=>se+1)},I=async Q=>{Q.preventDefault(),L(""),$(""),q(!0);try{await Cn.register({username:O,password:M}),$(Y("users.userCreated",{username:O})),j(""),k("")}catch(se){L(se.response?.data?.message||Y("users.createFailed"))}finally{q(!1)}},W=Q=>{p(Q.currentTarget)},B=()=>{p(null)},P=()=>{B(),o("/settings/profile")},X=()=>{B(),o("/settings/api-keys")},Z=()=>{B(),o("/settings/webhooks")},pe=()=>{B(),o("/settings/system")},D=()=>{B(),n()},H=[{label:Y("nav.jobs"),index:0},{label:Y("nav.providerAuth"),index:1},...e?.role==="admin"?[{label:Y("nav.userManagement"),index:2}]:[],{label:Y("nav.apiKeys"),index:e?.role==="admin"?3:2},{label:Y("nav.webhooks"),index:e?.role==="admin"?4:3},{label:Y("nav.profile"),index:e?.role==="admin"?5:4},...e?.role==="admin"?[{label:Y("nav.system"),index:6}]:[]];return d.jsxs(ue,{sx:{flexGrow:1,minHeight:"100vh",display:"flex",flexDirection:"column"},children:[d.jsx(u4,{position:"static",children:d.jsxs(BB,{children:[d.jsx(ne,{variant:"h6",component:"div",sx:{flexGrow:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"LLM Dev Server"}),d.jsx(Vt,{size:"large",color:"inherit",onClick:W,sx:{ml:1},children:d.jsx(XD,{})}),d.jsxs(Ld,{anchorEl:u,open:!!u,onClose:B,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[d.jsxs(ue,{sx:{px:2,py:1},children:[d.jsx(ne,{variant:"subtitle1",sx:{fontWeight:"bold"},children:e?.username}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:e?.role==="admin"?Y("profile.roleAdmin"):Y("profile.roleUser")})]}),d.jsx(Uo,{}),d.jsxs(fa,{onClick:P,children:[d.jsx(Yi,{children:d.jsx(qC,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.profile")})]}),d.jsxs(fa,{onClick:X,children:[d.jsx(Yi,{children:d.jsx(gL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.apiKeys")})]}),d.jsxs(fa,{onClick:Z,children:[d.jsx(Yi,{children:d.jsx(yL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.webhooks")})]}),e?.role==="admin"&&d.jsxs(fa,{onClick:pe,children:[d.jsx(Yi,{children:d.jsx(pL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.system")})]}),d.jsx(Uo,{}),d.jsxs(fa,{onClick:D,children:[d.jsx(Yi,{children:d.jsx(iL,{fontSize:"small"})}),d.jsx(Va,{children:Y("auth.logout")})]})]})]})}),d.jsx(YS,{maxWidth:"xl",sx:{mt:4,flex:1,pb:4},children:d.jsxs(Ft,{sx:{width:"100%",overflow:"hidden"},children:[d.jsx(hC,{value:s,onChange:(Q,se)=>{c(se),se===0?o("/jobs"):se===1?o("/provider-auth"):se===2&&e?.role==="admin"?o("/admin/users"):se===(e?.role==="admin"?3:2)?o("/settings/api-keys"):se===(e?.role==="admin"?4:3)?o("/settings/webhooks"):se===(e?.role==="admin"?5:4)?o("/settings/profile"):se===6&&e?.role==="admin"&&o("/settings/system")},"aria-label":"Dashboard Tabs",variant:"scrollable",scrollButtons:"auto",sx:{borderBottom:1,borderColor:"divider","& .MuiTab-root":{minWidth:"auto",px:3}},children:H.map(Q=>d.jsx(im,{label:Q.label},Q.index))}),d.jsx(Ia,{value:s,index:0,children:i.pathname==="/jobs"||i.pathname==="/jobs/"?d.jsx(bL,{onCreateJob:()=>g(!0)},`job-list-${w}`):i.pathname.startsWith("/jobs/")?d.jsx(CL,{onCreateConversation:()=>b(!0),initialConversationId:E||void 0},`job-detail-${x}`):null}),d.jsx(Ia,{value:s,index:1,children:d.jsx(vL,{})}),e?.role==="admin"&&d.jsxs(Ia,{value:s,index:2,children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("users.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("users.subtitle")}),N&&d.jsx(zt,{severity:"error",sx:{mb:2},children:N}),U&&d.jsx(zt,{severity:"success",sx:{mb:2},children:U}),d.jsxs(ue,{component:"form",onSubmit:I,sx:{maxWidth:400},children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.username"),value:O,onChange:Q=>j(Q.target.value),margin:"normal",required:!0}),d.jsx(_t,{fullWidth:!0,label:Y("auth.password"),type:"password",value:M,onChange:Q=>k(Q.target.value),margin:"normal",required:!0,helperText:Y("auth.passwordMinLength")}),d.jsx(He,{type:"submit",variant:"contained",sx:{mt:2},disabled:F,children:F?d.jsx(Et,{size:24}):Y("users.createUser")})]})]}),d.jsx(Ia,{value:s,index:e?.role==="admin"?3:2,children:d.jsx(jL,{})}),d.jsx(Ia,{value:s,index:e?.role==="admin"?4:3,children:d.jsx(ML,{})}),d.jsx(Ia,{value:s,index:e?.role==="admin"?5:4,children:d.jsx(kL,{})}),e?.role==="admin"&&d.jsx(Ia,{value:s,index:6,children:d.jsx(zL,{})})]})}),d.jsx(TL,{open:m,onClose:()=>g(!1),onCreated:R}),i.pathname.startsWith("/jobs/")&&i.pathname.split("/").length>=3&&d.jsx(RL,{open:y,jobId:i.pathname.split("/")[2],onClose:()=>b(!1),onCreated:_})]})}const NL=jd({palette:{mode:"dark"}});function DL({children:e}){const{user:n,loading:o}=fc();return o?d.jsx("div",{children:"Loading..."}):n?d.jsx(d.Fragment,{children:e}):d.jsx(zh,{to:"/login"})}function LL(){const{user:e}=fc();return d.jsxs(dT,{children:[d.jsx(_u,{path:"/login",element:e?d.jsx(zh,{to:"/jobs"}):d.jsx(YD,{})}),d.jsx(_u,{path:"/*",element:d.jsx(DL,{children:d.jsx(BL,{})})}),d.jsx(_u,{path:"*",element:d.jsx(zh,{to:"/jobs"})})]})}function $L(){return d.jsxs(kM,{theme:NL,children:[d.jsx(GO,{}),d.jsx(ND,{children:d.jsx(DT,{children:d.jsx(LL,{})})})]})}hE.createRoot(document.getElementById("root")).render(d.jsx(Dr.StrictMode,{children:d.jsx($L,{})}));
204
+ `+c):i.stack=c}catch{}}throw i}}_request(n,o){typeof n=="string"?(o=o||{},o.url=n):o=n||{},o=Ja(this.defaults,o);const{transitional:i,paramsSerializer:s,headers:c}=o;i!==void 0&&Zu.assertOptions(i,{silentJSONParsing:Gr.transitional(Gr.boolean),forcedJSONParsing:Gr.transitional(Gr.boolean),clarifyTimeoutError:Gr.transitional(Gr.boolean)},!1),s!=null&&(re.isFunction(s)?o.paramsSerializer={serialize:s}:Zu.assertOptions(s,{encode:Gr.function,serialize:Gr.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),Zu.assertOptions(o,{baseUrl:Gr.spelling("baseURL"),withXsrfToken:Gr.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let u=c&&re.merge(c.common,c[o.method]);c&&re.forEach(["delete","get","head","post","put","patch","common"],x=>{delete c[x]}),o.headers=Gn.concat(u,c);const p=[];let m=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(o)===!1||(m=m&&S.synchronous,p.unshift(S.fulfilled,S.rejected))});const g=[];this.interceptors.response.forEach(function(S){g.push(S.fulfilled,S.rejected)});let y,b=0,w;if(!m){const x=[d1.bind(this),void 0];for(x.unshift(...p),x.push(...g),w=x.length,y=Promise.resolve(o);b<w;)y=y.then(x[b++],x[b++]);return y}w=p.length;let T=o;for(;b<w;){const x=p[b++],S=p[b++];try{T=x(T)}catch(E){S.call(this,E);break}}try{y=d1.call(this,T)}catch(x){return Promise.reject(x)}for(b=0,w=g.length;b<w;)y=y.then(g[b++],g[b++]);return y}getUri(n){n=Ja(this.defaults,n);const o=zC(n.baseURL,n.url,n.allowAbsoluteUrls);return jC(o,n.params,n.paramsSerializer)}};re.forEach(["delete","get","head","options"],function(n){Xa.prototype[n]=function(o,i){return this.request(Ja(i||{},{method:n,url:o,data:(i||{}).data}))}});re.forEach(["post","put","patch"],function(n){function o(i){return function(c,u,p){return this.request(Ja(p||{},{method:n,headers:i?{"Content-Type":"multipart/form-data"}:{},url:c,data:u}))}}Xa.prototype[n]=o(),Xa.prototype[n+"Form"]=o(!0)});let OD=class $C{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(c){o=c});const i=this;this.promise.then(s=>{if(!i._listeners)return;let c=i._listeners.length;for(;c-- >0;)i._listeners[c](s);i._listeners=null}),this.promise.then=s=>{let c;const u=new Promise(p=>{i.subscribe(p),c=p}).then(s);return u.cancel=function(){i.unsubscribe(c)},u},n(function(c,u,p){i.reason||(i.reason=new ws(c,u,p),o(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const o=this._listeners.indexOf(n);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const n=new AbortController,o=i=>{n.abort(i)};return this.subscribe(o),n.signal.unsubscribe=()=>this.unsubscribe(o),n.signal}static source(){let n;return{token:new $C(function(s){n=s}),cancel:n}}};function zD(e){return function(o){return e.apply(null,o)}}function BD(e){return re.isObject(e)&&e.isAxiosError===!0}const um={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(um).forEach(([e,n])=>{um[n]=e});function PC(e){const n=new Xa(e),o=mC(Xa.prototype.request,n);return re.extend(o,Xa.prototype,n,{allOwnKeys:!0}),re.extend(o,n,null,{allOwnKeys:!0}),o.create=function(s){return PC(Ja(e,s))},o}const nn=PC(dc);nn.Axios=Xa;nn.CanceledError=ws;nn.CancelToken=OD;nn.isCancel=kC;nn.VERSION=LC;nn.toFormData=Id;nn.AxiosError=Ze;nn.Cancel=nn.CanceledError;nn.all=function(n){return Promise.all(n)};nn.spread=zD;nn.isAxiosError=BD;nn.mergeConfig=Ja;nn.AxiosHeaders=Gn;nn.formToJSON=e=>MC(re.isHTMLForm(e)?new FormData(e):e);nn.getAdapter=DC.getAdapter;nn.HttpStatusCode=um;nn.default=nn;const{Axios:_L,AxiosError:IL,CanceledError:HL,isCancel:FL,CancelToken:VL,VERSION:qL,all:WL,Cancel:GL,isAxiosError:KL,spread:YL,toFormData:XL,AxiosHeaders:QL,HttpStatusCode:ZL,formToJSON:JL,getAdapter:e$,mergeConfig:t$}=nn,Ne=nn.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});Ne.interceptors.request.use(e=>{const n=localStorage.getItem("token");return n&&(e.headers.Authorization=`Bearer ${n}`),e});let UC=!1;const jl=e=>{UC=e};Ne.interceptors.response.use(e=>e,e=>(e.response?.status===401&&!UC&&localStorage.getItem("token")&&(localStorage.removeItem("token"),window.location.href="/login"),Promise.reject(e)));const Cn={login:e=>Ne.post("/auth/login",e),register:e=>Ne.post("/auth/register",e),me:()=>Ne.get("/auth/me"),changePassword:e=>Ne.put("/auth/password",e),claudeLoginStart:()=>Ne.post("/auth/claude/login/start",{}),claudeLoginComplete:e=>Ne.post("/auth/claude/login/complete",e),claudeStatus:()=>Ne.get("/auth/claude/status"),claudeLogout:()=>Ne.post("/auth/claude/logout"),codexLoginStart:()=>Ne.post("/auth/codex/login/start"),codexLoginPoll:e=>Ne.post("/auth/codex/login/poll",e),codexStatus:()=>Ne.get("/auth/codex/status"),codexLogout:()=>Ne.post("/auth/codex/logout"),geminiLoginStart:()=>Ne.post("/auth/gemini/login/start"),geminiLoginComplete:e=>Ne.post("/auth/gemini/login/complete",e),geminiStatus:()=>Ne.get("/auth/gemini/status"),geminiLogout:()=>Ne.post("/auth/gemini/logout")},Ka={create:e=>Ne.post("/jobs",e),list:e=>Ne.get("/jobs",{params:e}),get:(e,n)=>Ne.get(`/jobs/${e}`,{params:n?{includeConversations:"true"}:void 0}),update:(e,n)=>Ne.patch(`/jobs/${e}`,n),delete:e=>Ne.delete(`/jobs/${e}`),getStatus:e=>Ne.get(`/jobs/${e}/status`),cancel:e=>Ne.post(`/jobs/${e}/cancel`),getConversations:(e,n)=>Ne.get(`/jobs/${e}/conversations`,{params:n}),listFiles:e=>Ne.get(`/jobs/${e}/files`)},rs={getProviders:()=>Ne.get("/conversations/providers"),create:e=>Ne.post("/conversations",e),get:e=>Ne.get(`/conversations/${e}`),update:(e,n)=>Ne.patch(`/conversations/${e}`,n),getMessages:(e,n)=>Ne.get(`/conversations/${e}/messages`,{params:n}),sendMessage:(e,n)=>Ne.post(`/conversations/${e}/messages`,n),delete:e=>Ne.delete(`/conversations/${e}`)},dm={browse:e=>Ne.get("/filesystem/browse",{params:e?{path:e}:void 0}),getRoots:()=>Ne.get("/filesystem/roots"),mkdir:(e,n)=>Ne.post("/filesystem/mkdir",{parentPath:e,name:n}),getGitInfo:e=>Ne.get("/filesystem/git-info",{params:{path:e}})},Mh={list:()=>Ne.get("/keys"),create:e=>Ne.post("/keys",e),update:(e,n)=>Ne.patch(`/keys/${e}`,n),revoke:e=>Ne.delete(`/keys/${e}`),deletePermanent:e=>Ne.delete(`/keys/${e}/permanent`)},Wi={list:()=>Ne.get("/webhooks"),getEvents:()=>Ne.get("/webhooks/events"),create:e=>Ne.post("/webhooks",e),update:(e,n)=>Ne.patch(`/webhooks/${e}`,n),delete:e=>Ne.delete(`/webhooks/${e}`),regenerateSecret:e=>Ne.post(`/webhooks/${e}/regenerate-secret`),test:e=>Ne.post(`/webhooks/${e}/test`)},da={getVersion:()=>Ne.get("/system/version"),getInfo:()=>Ne.get("/system/info"),getUpdateLog:()=>Ne.get("/system/update-log"),clearUpdateLog:()=>Ne.delete("/system/update-log"),triggerUpdate:()=>Ne.post("/system/update"),triggerRestart:()=>Ne.post("/system/restart"),healthCheck:()=>Ne.get("/health"),waitForReconnect:async(e=30,n=2e3,o)=>{for(let i=1;i<=e;i++)try{return o?.(i,e),await da.healthCheck(),!0}catch{i<e&&await new Promise(s=>setTimeout(s,n))}return!1}},_C=v.createContext(void 0),fc=()=>{const e=v.useContext(_C);if(!e)throw new Error("useAuth must be used within AuthProvider");return e},ND=({children:e})=>{const[n,o]=v.useState(null),[i,s]=v.useState(localStorage.getItem("token")),[c,u]=v.useState(!0),[p,m]=v.useState(!1);v.useEffect(()=>{(async()=>{jl(!0);try{const T=(await Cn.me()).data;if(T.autheliaToken){localStorage.setItem("token",T.autheliaToken),s(T.autheliaToken),o(T.data),m(!0),u(!1),jl(!1);return}o(T.data),m(!i),u(!1),jl(!1);return}catch{if(!i){u(!1),jl(!1);return}}if(i)try{const w=await Cn.me();o(w.data.data)}catch{localStorage.removeItem("token"),s(null)}u(!1),jl(!1)})()},[i]);const g=async(b,w)=>{const T=await Cn.login({username:b,password:w}),{token:x,user:S}=T.data.data;localStorage.setItem("token",x),s(x),o(S),m(!1)},y=()=>{localStorage.removeItem("token"),s(null),o(null),m(!1)};return d.jsx(_C.Provider,{value:{user:n,token:i,loading:c,isAutheliaAuth:p,login:g,logout:y},children:e})},DD={loading:"Laden...",save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",create:"Erstellen",close:"Schließen",back:"Zurück",search:"Suchen",filter:"Filtern",refresh:"Aktualisieren",copy:"Kopieren",copied:"Kopiert!",yes:"Ja",no:"Nein",error:"Fehler",success:"Erfolg",warning:"Warnung",info:"Information",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",createdAt:"Erstellt am",updatedAt:"Aktualisiert am",noData:"Keine Daten vorhanden"},LD={login:"Anmelden",logout:"Abmelden",register:"Registrieren",username:"Benutzername",password:"Passwort",currentPassword:"Aktuelles Passwort",newPassword:"Neues Passwort",confirmPassword:"Passwort bestätigen",changePassword:"Passwort ändern",passwordChanged:"Passwort wurde erfolgreich geändert",passwordMinLength:"Mindestens 8 Zeichen",passwordMismatch:"Passwörter stimmen nicht überein",invalidCredentials:"Ungültige Anmeldedaten",loginFailed:"Anmeldung fehlgeschlagen",welcome:"Willkommen zurück",loginSubtitle:"Melden Sie sich an, um fortzufahren"},$D={dashboard:"Dashboard",jobs:"Jobs",providerAuth:"Provider-Authentifizierung",userManagement:"Benutzerverwaltung",apiKeys:"API-Schlüssel",webhooks:"Webhooks",profile:"Profil",system:"System"},PD={title:"Jobs",createJob:"Neuen Job erstellen",selectJob:"Wählen Sie einen Job aus",noJobs:"Keine Jobs vorhanden",jobName:"Job-Name",workingDirectory:"Arbeitsverzeichnis",systemPrompt:"System-Prompt",status:{pending:"Ausstehend",running:"Läuft",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"},statistics:"Statistiken",conversations:"Konversationen",messages:"Nachrichten",tokenUsage:"Token-Verbrauch",inputTokens:"Eingabe-Tokens",outputTokens:"Ausgabe-Tokens",totalTokens:"Gesamt-Tokens",deleteConfirm:"Möchten Sie diesen Job wirklich löschen?",cancelConfirm:"Möchten Sie diesen Job wirklich abbrechen?"},UD={title:"Konversationen",createConversation:"Neue Konversation",noConversations:"Keine Konversationen vorhanden",selectProvider:"Provider auswählen",model:"Modell",sendMessage:"Nachricht senden",typeMessage:"Nachricht eingeben...",streaming:"Streaming...",attachments:"Anhänge",addAttachment:"Anhang hinzufügen"},_D={title:"Provider-Authentifizierung",subtitle:"Verbinden Sie Ihre LLM-Provider",claude:{name:"Claude (Anthropic)",description:"Anthropics Claude für fortgeschrittene KI-Aufgaben"},codex:{name:"Codex (OpenAI)",description:"OpenAIs Codex für Code-Generierung"},gemini:{name:"Gemini (Google)",description:"Googles Gemini für vielseitige KI-Aufgaben"},connected:"Verbunden",notConnected:"Nicht verbunden",connect:"Verbinden",disconnect:"Trennen",expiresAt:"Läuft ab am",loginInstructions:"Anmeldeanleitung",codeInput:"Code eingeben",pasteCode:"Fügen Sie den erhaltenen Code hier ein",verifying:"Wird überprüft...",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen"},ID={title:"API-Schlüssel",subtitle:"Verwalten Sie Ihre API-Schlüssel für die programmierte Nutzung",createKey:"Neuen Schlüssel erstellen",keyName:"Schlüssel-Name",keyPrefix:"Schlüssel-Präfix",lastUsed:"Zuletzt verwendet",expiresAt:"Läuft ab am",neverUsed:"Noch nie verwendet",neverExpires:"Läuft nie ab",expired:"Abgelaufen",revoked:"Widerrufen",active:"Aktiv",revoke:"Widerrufen",revokeConfirm:"Möchten Sie diesen API-Schlüssel wirklich widerrufen?",newKeyCreated:"Neuer API-Schlüssel erstellt",copyWarning:"Kopieren Sie diesen Schlüssel jetzt! Er wird nur einmal angezeigt.",noKeys:"Keine API-Schlüssel vorhanden",expirationDate:"Ablaufdatum (optional)",expirationHelp:"Leer lassen für unbegrenzten Schlüssel"},HD={title:"Webhooks",subtitle:"Erhalten Sie Echtzeit-Benachrichtigungen über Events",createWebhook:"Neuen Webhook erstellen",webhookName:"Webhook-Name",webhookUrl:"Webhook-URL",events:"Events",active:"Aktiv",inactive:"Inaktiv",lastTriggered:"Zuletzt ausgelöst",failures:"Fehlversuche",regenerateSecret:"Secret neu generieren",testWebhook:"Webhook testen",noWebhooks:"Keine Webhooks vorhanden",selectEvents:"Wählen Sie die Events aus, die den Webhook auslösen sollen",eventDescriptions:{"job.created":"Job wurde erstellt","job.updated":"Job wurde aktualisiert","job.completed":"Job wurde abgeschlossen","job.failed":"Job ist fehlgeschlagen","job.cancelled":"Job wurde abgebrochen","conversation.created":"Konversation wurde erstellt","conversation.updated":"Konversation wurde aktualisiert","message.created":"Nachricht wurde erstellt","message.streaming":"Nachricht wird gestreamt","message.completed":"Nachricht ist vollständig","tool.called":"Tool wurde aufgerufen","tool.completed":"Tool-Aufruf abgeschlossen"}},FD={title:"Profil",subtitle:"Verwalten Sie Ihre Kontoeinstellungen",accountInfo:"Kontoinformationen",role:"Rolle",roleAdmin:"Administrator",roleUser:"Benutzer",security:"Sicherheit",changePasswordDesc:"Ändern Sie Ihr Passwort regelmäßig für mehr Sicherheit"},VD={title:"Benutzerverwaltung",subtitle:"Neue Benutzer erstellen (nur Admin)",createUser:"Benutzer erstellen",userCreated:'Benutzer "{username}" wurde erfolgreich erstellt',createFailed:"Benutzer konnte nicht erstellt werden"},qD={browse:"Durchsuchen",selectDirectory:"Verzeichnis auswählen",currentPath:"Aktueller Pfad",parentDirectory:"Übergeordnetes Verzeichnis",createFolder:"Neuen Ordner erstellen",folderName:"Ordnername"},WD={generic:"Ein Fehler ist aufgetreten",networkError:"Netzwerkfehler - bitte überprüfen Sie Ihre Verbindung",unauthorized:"Nicht autorisiert - bitte melden Sie sich erneut an",forbidden:"Zugriff verweigert",notFound:"Nicht gefunden",serverError:"Serverfehler - bitte versuchen Sie es später erneut"},GD={title:"System",subtitle:"Systemverwaltung und Updates",version:"Version",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",lastChecked:"Zuletzt geprüft",updateAvailable:"Update verfügbar",upToDate:"Aktuell",update:"Update installieren",restart:"Neustart",info:"Systeminformationen",uptime:"Laufzeit",memory:"Speicher",platform:"Plattform",updateLog:"Update-Log",clearLog:"Log löschen",confirmUpdate:"Update bestätigen",confirmUpdateText:"Möchten Sie das Update wirklich installieren? Der Server wird nach dem Update automatisch neu gestartet.",confirmRestart:"Neustart bestätigen",confirmRestartText:"Möchten Sie den Server wirklich neu starten? Alle aktiven Verbindungen werden kurzzeitig unterbrochen."},KD={common:DD,auth:LD,nav:$D,jobs:PD,conversations:UD,providers:_D,apiKeys:ID,webhooks:HD,profile:FD,users:VD,filesystem:qD,errors:WD,system:GD};function Y(e,n){const o=e.split(".");let i=KD;for(const s of o)if(i&&typeof i=="object"&&s in i)i=i[s];else return console.warn(`Translation missing for key: ${e}`),e;return typeof i!="string"?(console.warn(`Translation value is not a string for key: ${e}`),e):n?i.replace(/\{(\w+)\}/g,(s,c)=>n[c]?.toString()??`{${c}}`):i}function YD(){const{login:e}=fc(),[n,o]=v.useState(""),[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(!1),g=async y=>{y.preventDefault(),u(""),m(!0);try{await e(n,i)}catch(b){u(b.response?.data?.message||Y("auth.loginFailed"))}finally{m(!1)}};return d.jsx(YS,{maxWidth:"sm",sx:{mt:8},children:d.jsxs(Ft,{elevation:3,sx:{p:4},children:[d.jsx(ne,{variant:"h4",gutterBottom:!0,align:"center",children:"LLM Dev Server"}),d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("auth.welcome")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("auth.loginSubtitle")}),c&&d.jsx(zt,{severity:"error",sx:{mb:2},children:c}),d.jsxs("form",{onSubmit:g,children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.username"),value:n,onChange:y=>o(y.target.value),margin:"normal",required:!0,autoFocus:!0,autoComplete:"username"}),d.jsx(_t,{fullWidth:!0,label:Y("auth.password"),type:"password",value:i,onChange:y=>s(y.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),d.jsx(He,{type:"submit",variant:"contained",fullWidth:!0,sx:{mt:2},disabled:p,children:p?d.jsx(Et,{size:24}):Y("auth.login")})]}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mt:3,textAlign:"center"},children:"Kontaktieren Sie Ihren Administrator, um ein Konto zu erhalten"})]})})}const XD=Fe(d.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"})),hs=Fe(d.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z"})),dd=Fe(d.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"})),QD=Fe(d.jsx("path",{d:"m4 12 1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8z"})),ZD=Fe(d.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),fm=Fe(d.jsx("path",{d:"M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2M6 9h12v2H6zm8 5H6v-2h8zm4-6H6V6h12z"})),IC=Fe(d.jsx("path",{d:"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})),JD=Fe(d.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"})),HC=Fe(d.jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),eL=Fe(d.jsx("path",{d:"M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2zM4 6h16v10H4z"})),FC=Fe(d.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"})),tL=Fe(d.jsx("path",{d:"M20 6h-8l-2-2H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2m-1 8h-3v3h-2v-3h-3v-2h3V9h2v3h3z"})),Fd=Fe(d.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"})),nL=Fe(d.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"})),pc=Fe(d.jsx("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"})),rL=Fe(d.jsx("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"})),oL=Fe(d.jsx("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm7 7V3.5L18.5 9z"})),aL=Fe(d.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"})),iL=Fe(d.jsx("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"})),sL=Fe(d.jsx("path",{d:"M15 9H9v6h6zm-2 4h-2v-2h2zm8-2V9h-2V7c0-1.1-.9-2-2-2h-2V3h-2v2h-2V3H9v2H7c-1.1 0-2 .9-2 2v2H3v2h2v2H3v2h2v2c0 1.1.9 2 2 2h2v2h2v-2h2v2h2v-2h2c1.1 0 2-.9 2-2v-2h2v-2h-2v-2zm-4 6H7V7h10z"})),VC=Fe(d.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),lL=Fe(d.jsx("path",{d:"m23 12-2.44-2.78.34-3.68-3.61-.82-1.89-3.18L12 3 8.6 1.54 6.71 4.72l-3.61.81.34 3.68L1 12l2.44 2.78-.34 3.69 3.61.82 1.89 3.18L12 21l3.4 1.46 1.89-3.18 3.61-.82-.34-3.68zm-10 5h-2v-2h2zm0-4h-2V7h2z"})),qC=Fe(d.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"})),cL=Fe(d.jsx("path",{d:"M8 5v14l11-7z"})),Vd=Fe(d.jsx("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"})),uL=Fe(d.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"})),WC=Fe([d.jsx("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),d.jsx("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")]),dL=Fe(d.jsx("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"})),fL=Fe(d.jsx("path",{d:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"})),pL=Fe(d.jsx("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"})),p1=Fe(d.jsx("path",{d:"M17 1.01 7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99M17 19H7V5h10zm-1-6h-3V8h-2v5H8l4 4z"})),hL=Fe(d.jsx("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"})),mL=Fe(d.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"})),gL=Fe(d.jsx("path",{d:"M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"})),yL=Fe(d.jsx("path",{d:"M10 15h5.88c.27-.31.67-.5 1.12-.5.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5c-.44 0-.84-.19-1.12-.5H11.9c-.46 2.28-2.48 4-4.9 4-2.76 0-5-2.24-5-5 0-2.42 1.72-4.44 4-4.9v2.07c-1.16.41-2 1.53-2 2.83 0 1.65 1.35 3 3 3s3-1.35 3-3zm2.5-11c1.65 0 3 1.35 3 3h2c0-2.76-2.24-5-5-5s-5 2.24-5 5c0 1.43.6 2.71 1.55 3.62l-2.35 3.9c-.68.14-1.2.75-1.2 1.48 0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5c0-.16-.02-.31-.07-.45l3.38-5.63C10.49 9.61 9.5 8.42 9.5 7c0-1.65 1.35-3 3-3m4.5 9c-.64 0-1.23.2-1.72.54l-3.05-5.07C11.53 8.35 11 7.74 11 7c0-.83.67-1.5 1.5-1.5S14 6.17 14 7c0 .15-.02.29-.06.43l2.19 3.65c.28-.05.57-.08.87-.08 2.76 0 5 2.24 5 5s-2.24 5-5 5c-1.85 0-3.47-1.01-4.33-2.5h2.67c.48.32 1.05.5 1.66.5 1.65 0 3-1.35 3-3s-1.35-3-3-3"}));function vL(){const[e,n]=v.useState({}),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(null),[y,b]=v.useState(!1),[w,T]=v.useState(null),[x,S]=v.useState(null),[E,A]=v.useState(""),[O,j]=v.useState(!1),[M,k]=v.useState(null),[N,L]=v.useState("");v.useEffect(()=>{U();const P=new URLSearchParams(window.location.search),X=P.get("auth"),Z=P.get("status"),pe=P.get("message");X&&Z&&(Z==="success"?(p(`${X.charAt(0).toUpperCase()+X.slice(1)} ${Y("providers.loginSuccess")}!`),U()):Z==="error"&&c(pe||`${X.charAt(0).toUpperCase()+X.slice(1)} ${Y("providers.loginFailed")}`),window.history.replaceState({},"",window.location.pathname))},[]),v.useEffect(()=>{if(!m?.expiresAt)return;const P=setInterval(()=>{const X=Math.floor((m.expiresAt-Date.now())/1e3);X<=0?(T(0),b(!1),g(null),c("Codex-Authentifizierungscode abgelaufen. Bitte erneut versuchen."),clearInterval(P)):T(X)},1e3);return()=>clearInterval(P)},[m?.expiresAt]);const U=async()=>{try{const[P,X,Z]=await Promise.all([Cn.claudeStatus().catch(()=>null),Cn.codexStatus().catch(()=>null),Cn.geminiStatus().catch(()=>null)]);n({claude:P?.data.data,codex:X?.data.data,gemini:Z?.data.data})}catch(P){console.error("Failed to load provider statuses:",P)}finally{i(!1)}},$=async()=>{c("");try{const P=await Cn.claudeLoginStart(),{loginUrl:X,state:Z,redirectUri:pe}=P.data.data;X&&Z&&(S({loginUrl:X,state:Z,verificationUrl:pe||""}),window.open(X,"_blank","width=600,height=800"))}catch(P){c(P.response?.data?.message||"Claude-Anmeldung konnte nicht gestartet werden")}},F=async()=>{if(!x||!E.trim()){c("Bitte fügen Sie die Callback-URL oder den Autorisierungscode ein");return}c(""),j(!0);try{await Cn.claudeLoginComplete({code:E.trim(),state:x.state}),S(null),A(""),p("Claude-Authentifizierung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Claude-Authentifizierung fehlgeschlagen")}finally{j(!1)}},q=async()=>{c(""),p("");try{const P=await Cn.codexLoginStart(),{verificationUrl:X,userCode:Z,deviceAuthId:pe,intervalSeconds:D,expiresIn:H}=P.data.data;if(!X||!Z||!pe){c("Fehlende erforderliche Daten für die Codex-Authentifizierung");return}const Q=H?Date.now()+H*1e3:void 0;g({userCode:Z,verificationUrl:X,deviceAuthId:pe,expiresAt:Q}),Q&&T(Math.floor((Q-Date.now())/1e3));const se=Math.max((D||5)*1e3,5e3);b(!0);let me=0;const fe=60,ye=setInterval(async()=>{if(me++,me>fe){clearInterval(ye),b(!1),g(null),c("Codex-Authentifizierung zeitüberschreitung. Bitte erneut versuchen.");return}try{await Cn.codexLoginPoll({deviceAuthId:pe,userCode:Z}),clearInterval(ye),b(!1),g(null),p("Codex-Authentifizierung erfolgreich!"),await U()}catch(ze){(ze.response?.data?.error||ze.response?.data?.message||"").includes("not yet approved")||(clearInterval(ye),b(!1),c("Codex-Authentifizierung fehlgeschlagen"))}},se)}catch(P){c(P.response?.data?.message||"Codex-Anmeldung konnte nicht gestartet werden")}},R=async()=>{c("");try{const P=await Cn.geminiLoginStart(),{loginUrl:X,state:Z,verificationUrl:pe}=P.data.data;X&&Z&&(k({loginUrl:X,state:Z,verificationUrl:pe||""}),window.open(X,"_blank","width=600,height=800"))}catch(P){c(P.response?.data?.message||"Gemini-Anmeldung konnte nicht gestartet werden")}},_=async()=>{if(!M||!N.trim()){c("Bitte geben Sie den Autorisierungscode ein");return}c("");try{await Cn.geminiLoginComplete({code:N.trim(),state:M.state}),k(null),L(""),p("Gemini-Authentifizierung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Gemini-Authentifizierung fehlgeschlagen")}},I=async()=>{if(confirm("Möchten Sie sich wirklich von Claude abmelden?")){c("");try{await Cn.claudeLogout(),p("Claude-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Claude-Abmeldung fehlgeschlagen")}}},W=async()=>{if(confirm("Möchten Sie sich wirklich von Codex abmelden?")){c("");try{await Cn.codexLogout(),p("Codex-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Codex-Abmeldung fehlgeschlagen")}}},B=async()=>{if(confirm("Möchten Sie sich wirklich von Gemini abmelden?")){c("");try{await Cn.geminiLogout(),p("Gemini-Abmeldung erfolgreich!"),await U()}catch(P){c(P.response?.data?.message||"Gemini-Abmeldung fehlgeschlagen")}}};return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("providers.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("providers.subtitle")}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),u&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>p(""),children:u}),d.jsxs(Zi,{container:!0,spacing:3,children:[d.jsx(Zi,{size:{xs:12,md:4},children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.claude.name")}),e.claude?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.claude.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.claude.email]}),e.claude.expiresAt&&d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("providers.expiresAt"),":"," ",new Date(e.claude.expiresAt).toLocaleDateString("de-DE")]})]}):x?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"1. Ein neuer Tab mit Claude-Authentifizierung wurde geöffnet"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"2. Nach der Anmeldung kopieren Sie die GESAMTE URL aus der Callback-Seite"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"3. Fügen Sie die vollständige URL unten ein:"}),d.jsx(_t,{fullWidth:!0,size:"small",placeholder:"Callback-URL einfügen...",value:E,onChange:P=>A(P.target.value),sx:{mt:1}}),d.jsxs(ue,{sx:{mt:1,display:"flex",gap:1},children:[d.jsx(He,{variant:"contained",size:"small",onClick:F,disabled:!E.trim()||O,children:O?Y("providers.verifying"):"Bestätigen"}),d.jsx(He,{variant:"text",size:"small",onClick:()=>{S(null),A("")},children:Y("common.cancel")})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.claude.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!x&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.claude?.loggedIn?"outlined":"contained",onClick:$,sx:{flex:e.claude?.loggedIn?"1 1 auto":"1"},children:e.claude?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.claude?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:I,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})}),d.jsx(Zi,{size:{xs:12,md:4},children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.codex.name")}),e.codex?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.codex.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.codex.email]})]}):m?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsxs(ne,{variant:"body2",gutterBottom:!0,children:["1. Besuchen Sie:"," ",d.jsx("a",{href:m.verificationUrl,target:"_blank",rel:"noopener noreferrer",style:{wordBreak:"break-all"},children:m.verificationUrl})]}),d.jsxs(ne,{variant:"body2",gutterBottom:!0,children:["2. Geben Sie den Code ein:"," ",d.jsx("strong",{children:m.userCode})]}),w!==null&&d.jsxs(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:["Code läuft ab in:"," ",d.jsxs("strong",{children:[Math.floor(w/60),":",String(w%60).padStart(2,"0")]})]}),y&&d.jsxs(ue,{sx:{mt:1,display:"flex",alignItems:"center",gap:1},children:[d.jsx(Et,{size:16}),d.jsx(ne,{variant:"caption",children:"Warte auf Autorisierung..."})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.codex.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!m&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.codex?.loggedIn?"outlined":"contained",onClick:q,sx:{flex:e.codex?.loggedIn?"1 1 auto":"1"},children:e.codex?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.codex?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:W,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})}),d.jsx(Zi,{size:{xs:12,md:4},children:d.jsxs(to,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[d.jsxs(No,{sx:{flex:1},children:[d.jsx(ne,{variant:"h6",gutterBottom:!0,sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Y("providers.gemini.name")}),e.gemini?.loggedIn?d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.connected"),color:"success",sx:{mb:1}}),e.gemini.email&&d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:["E-Mail: ",e.gemini.email]})]}):M?d.jsxs(zt,{severity:"info",sx:{"& .MuiAlert-message":{width:"100%"}},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"1. Ein neuer Tab mit Google-Anmeldung wurde geöffnet"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"2. Nach der Anmeldung zeigt Google Ihnen einen Code an"}),d.jsx(ne,{variant:"body2",gutterBottom:!0,children:"3. Kopieren Sie den Code und fügen Sie ihn unten ein:"}),d.jsx(_t,{fullWidth:!0,size:"small",placeholder:"Autorisierungscode hier einfügen",value:N,onChange:P=>L(P.target.value),sx:{mt:1}}),d.jsxs(ue,{sx:{mt:1,display:"flex",gap:1},children:[d.jsx(He,{variant:"contained",size:"small",onClick:_,disabled:!N.trim(),children:"Bestätigen"}),d.jsx(He,{variant:"text",size:"small",onClick:()=>{k(null),L("")},children:Y("common.cancel")})]})]}):d.jsxs(ue,{children:[d.jsx(Jt,{label:Y("providers.notConnected"),color:"default",sx:{mb:1}}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("providers.gemini.description")})]})]}),d.jsx(Ku,{sx:{gap:1,flexWrap:"wrap"},children:!M&&d.jsxs(d.Fragment,{children:[d.jsx(He,{variant:e.gemini?.loggedIn?"outlined":"contained",onClick:R,sx:{flex:e.gemini?.loggedIn?"1 1 auto":"1"},children:e.gemini?.loggedIn?"Neu verbinden":Y("providers.connect")}),e.gemini?.loggedIn&&d.jsx(He,{variant:"outlined",color:"error",onClick:B,sx:{flex:"1 1 auto"},children:"Abmelden"})]})})]})})]}),d.jsxs(zt,{severity:"info",sx:{mt:3},children:[d.jsx(ne,{variant:"body2",gutterBottom:!0,children:d.jsx("strong",{children:"Hinweis zur Remote-Authentifizierung:"})}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Claude:"})," Verwendet manuellen Code-Flow - authentifizieren Sie sich in einem neuen Tab, dann fügen Sie die gesamte Callback-URL ein."]}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Codex:"})," Verwendet Device-Flow - besuchen Sie die URL und geben Sie den angezeigten Code ein."]}),d.jsxs(ne,{variant:"body2",children:["• ",d.jsx("strong",{children:"Gemini:"})," Verwendet manuellen Code-Flow - authentifizieren Sie sich in einem neuen Tab, dann fügen Sie den von Google angezeigten Code ein."]})]})]})}function bL({onCreateJob:e}){const n=ya(),[o,i]=v.useState([]),[s,c]=v.useState(!0),[u,p]=v.useState(""),[m,g]=v.useState(null),[y,b]=v.useState(null);v.useEffect(()=>{w()},[]);const w=async()=>{c(!0);try{const j=await Ka.list({search:u||void 0});i(j.data.jobs)}catch(j){console.error("Failed to load jobs:",j)}finally{c(!1)}},T=()=>{w()},x=async j=>{try{await Ka.delete(j),await w()}catch(M){console.error("Failed to delete job:",M)}g(null),b(null)},S=(j,M)=>{j.stopPropagation(),g(j.currentTarget),b(M)},E=()=>{g(null),b(null)},A=j=>{switch(j){case"running":return"primary";case"completed":return"success";case"failed":return"error";case"cancelled":return"warning";default:return"default"}},O=j=>{switch(j){case"pending":return"Ausstehend";case"running":return"Läuft";case"completed":return"Abgeschlossen";case"failed":return"Fehlgeschlagen";case"cancelled":return"Abgebrochen";default:return j}};return d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",gap:2,mb:3,alignItems:"center"},children:[d.jsx(_t,{size:"small",placeholder:"Jobs durchsuchen...",value:u,onChange:j=>p(j.target.value),onKeyPress:j=>j.key==="Enter"&&T(),InputProps:{startAdornment:d.jsx(eg,{position:"start",children:d.jsx(dL,{})})},sx:{flexGrow:1,maxWidth:400}}),d.jsx(no,{title:"Aktualisieren",children:d.jsx("span",{children:d.jsx(Vt,{onClick:w,disabled:s,children:d.jsx(Vd,{})})})}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:e,children:"Neuer Job"})]}),s?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):o.length===0?d.jsxs(to,{sx:{p:4,textAlign:"center"},children:[d.jsx(ne,{color:"text.secondary",gutterBottom:!0,children:"Keine Jobs gefunden"}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Erstellen Sie einen neuen Job, um mit LLMs zu arbeiten."}),d.jsx(He,{variant:"outlined",startIcon:d.jsx(hs,{}),onClick:e,children:"Ersten Job erstellen"})]}):d.jsx(Zi,{container:!0,spacing:2,children:o.map(j=>d.jsx(Zi,{size:{xs:12,md:6,lg:4},children:d.jsxs(to,{sx:{cursor:"pointer",transition:"all 0.2s","&:hover":{transform:"translateY(-2px)",boxShadow:4}},onClick:()=>n(`/jobs/${j.id}`),children:[d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1},children:[d.jsx(ne,{variant:"h6",noWrap:!0,sx:{flex:1},children:j.name}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(Jt,{label:O(j.status),color:A(j.status),size:"small"}),d.jsx(Vt,{size:"small",onClick:M=>S(M,j.id),children:d.jsx(VC,{fontSize:"small"})})]})]}),j.description&&d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:1,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:j.description}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[d.jsx(pc,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",noWrap:!0,children:j.workingDirectory})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mt:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[d.jsx(fm,{fontSize:"small",color:"action"}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[j.conversationCount," Konversationen"]})]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[j.messageCount," Nachrichten"]})]})]}),d.jsx(Ku,{sx:{pt:0},children:d.jsxs(ne,{variant:"caption",color:"text.secondary",children:["Erstellt:"," ",new Date(j.createdAt).toLocaleDateString("de-DE")]})})]})},j.id))}),d.jsx(Ld,{anchorEl:m,open:!!m,onClose:E,children:d.jsxs(fa,{onClick:()=>y&&x(y),sx:{color:"error.main"},children:[d.jsx(Fd,{fontSize:"small",sx:{mr:1}}),"Löschen"]})})]})}function xL({conversations:e,onCreateConversation:n,onRefresh:o}){const i=ya(),c=Rr().pathname.split("/")[2],[u,p]=v.useState(null),[m,g]=v.useState(null),[y,b]=v.useState(!1),[w,T]=v.useState(!1),x=(k,N)=>{k.stopPropagation(),p(k.currentTarget),g(N)},S=()=>{p(null)},E=()=>{S(),b(!0)},A=async()=>{if(m){T(!0);try{await rs.delete(m),o(),b(!1),g(null)}catch(k){console.error("Failed to delete conversation:",k),alert("Fehler beim Löschen der Konversation")}finally{T(!1)}}},O=()=>{b(!1),g(null)},j=k=>{switch(k){case"claude":return{label:"Claude",color:"#D97706"};case"codex":return{label:"Codex",color:"#059669"};case"gemini":return{label:"Gemini",color:"#2563EB"};default:return{label:k,color:"#6B7280"}}},M=k=>{if(!k)return"Noch keine Nachrichten";const N=new Date(k),U=new Date().getTime()-N.getTime(),$=Math.floor(U/6e4),F=Math.floor($/60),q=Math.floor(F/24);return $<1?"Gerade eben":$<60?`vor ${$} Min.`:F<24?`vor ${F} Std.`:q<7?`vor ${q} Tagen`:N.toLocaleDateString("de-DE")};return e.length===0?d.jsxs(ue,{sx:{textAlign:"center",py:4},children:[d.jsx(fm,{sx:{fontSize:48,color:"text.secondary",mb:2}}),d.jsx(ne,{color:"text.secondary",gutterBottom:!0,children:"Noch keine Konversationen"}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Starten Sie eine neue Konversation mit einem LLM."}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:n,children:"Konversation starten"})]}):d.jsxs(ue,{children:[d.jsx(ue,{sx:{display:"flex",flexWrap:"wrap",gap:2,p:2},children:e.map(k=>{const N=j(k.provider);return d.jsxs(to,{sx:{width:{xs:"100%",sm:"calc(50% - 8px)",md:"calc(33.33% - 11px)"},minWidth:280,position:"relative"},children:[d.jsx(Vt,{size:"small",onClick:L=>x(L,k.id),sx:{position:"absolute",top:8,right:8,zIndex:1},children:d.jsx(VC,{fontSize:"small"})}),d.jsx(xO,{onClick:()=>i(`/jobs/${c}/conversations/${k.id}`),children:d.jsxs(No,{children:[d.jsx(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1},children:d.jsxs(ue,{sx:{flex:1,minWidth:0,pr:4},children:[d.jsx(ne,{variant:"subtitle1",noWrap:!0,children:k.title||`Konversation ${k.id.slice(0,8)}`}),d.jsx(Jt,{label:N.label,size:"small",sx:{backgroundColor:N.color,color:"white",mt:.5}})]})}),d.jsxs(ne,{variant:"body2",color:"text.secondary",sx:{mb:1},children:["Model: ",k.model]}),d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:2},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(fm,{fontSize:"small",color:"action"}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[k.messageCount," Nachrichten"]})]}),k.totalTokens&&d.jsxs(ne,{variant:"caption",color:"text.secondary",children:[k.totalTokens.toLocaleString("de-DE")," ","Tokens"]})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5,mt:1},children:[d.jsx(WC,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:M(k.lastMessageAt)})]}),!k.isActive&&d.jsx(Jt,{label:"Inaktiv",size:"small",color:"default",sx:{mt:1}})]})})]},k.id)})}),d.jsx(Ld,{anchorEl:u,open:!!u,onClose:S,children:d.jsxs(fa,{onClick:E,sx:{color:"error.main"},children:[d.jsx(Fd,{fontSize:"small",sx:{mr:1}}),"Löschen"]})}),d.jsxs(oo,{open:y,onClose:O,children:[d.jsx(so,{children:"Konversation löschen?"}),d.jsx(io,{children:d.jsx(em,{children:"Möchten Sie diese Konversation wirklich löschen? Alle Nachrichten gehen dabei verloren. Diese Aktion kann nicht rückgängig gemacht werden."})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:O,disabled:w,children:"Abbrechen"}),d.jsx(He,{onClick:A,color:"error",variant:"contained",disabled:w,children:w?"Wird gelöscht...":"Löschen"})]})]})]})}function SL({job:e,onRefresh:n}){const o=ya(),s=Rr().pathname.split("/"),c=s[s.length-1],[u,p]=v.useState(null),[m,g]=v.useState([]),[y,b]=v.useState(""),[w,T]=v.useState(!0),[x,S]=v.useState(!1),[E,A]=v.useState(null),O=v.useRef(null);v.useEffect(()=>{c&&(j(),M())},[c]),v.useEffect(()=>{k()},[m]);const j=async()=>{if(c)try{const q=await rs.get(c);p(q.data)}catch(q){console.error("Failed to load conversation:",q),A("Fehler beim Laden der Konversation")}},M=async()=>{if(c){T(!0),A(null);try{const q=await rs.getMessages(c,{limit:100});g(q.data.messages)}catch(q){console.error("Failed to load messages:",q),A("Fehler beim Laden der Nachrichten")}finally{T(!1)}}},k=()=>{O.current?.scrollIntoView({behavior:"smooth"})},N=async()=>{if(!y.trim()||x||!c||!u)return;const q=y.trim();b(""),S(!0),A(null);const R={id:`temp-${Date.now()}`,conversationId:c,role:"user",content:q,createdAt:new Date().toISOString()};g(_=>[..._,R]);try{const _=await rs.sendMessage(c,{content:q});g(I=>[...I.filter(B=>B.id!==R.id),_.data.userMessage,_.data.assistantMessage])}catch(_){console.error("Failed to send message:",_),A(_.response?.data?.error||"Fehler beim Senden der Nachricht"),g(I=>I.filter(W=>W.id!==R.id)),b(q)}finally{S(!1)}},L=q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),N())},U=q=>{switch(q){case"claude":return{label:"Claude",color:"#D97706"};case"codex":return{label:"Codex",color:"#059669"};case"gemini":return{label:"Gemini",color:"#2563EB"};default:return{label:q,color:"#6B7280"}}};if(w||!u)return d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})});if(E&&!u)return d.jsx(ue,{sx:{p:3},children:d.jsx(zt,{severity:"error",children:E})});const $=U(u.provider),F=q=>{const R=q.role==="user",_=q.role==="system";return q.role,d.jsx(ue,{sx:{display:"flex",justifyContent:R?"flex-end":"flex-start",mb:2},children:d.jsxs(Ft,{sx:{p:2,maxWidth:"80%",backgroundColor:R?"primary.dark":_?"grey.800":"grey.900",borderRadius:2},children:[!R&&d.jsxs(ne,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:[_?"System":$.label,q.model&&` (${q.model})`]}),d.jsx(ue,{sx:{"& p":{m:0,mb:1,"&:last-child":{mb:0}},"& pre":{m:0,mb:1,p:1.5,backgroundColor:"rgba(0,0,0,0.3)",borderRadius:1,overflow:"auto"},"& code":{backgroundColor:"rgba(0,0,0,0.3)",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"0.9em"},whiteSpace:"pre-wrap",wordBreak:"break-word"},children:d.jsx(ne,{component:"div",sx:{whiteSpace:"pre-wrap"},children:q.content})}),q.tokenUsage&&d.jsxs(ne,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:["Tokens: ",q.tokenUsage.total.toLocaleString("de-DE")]}),d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:new Date(q.createdAt).toLocaleTimeString("de-DE")})]})},q.id)};return d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",height:"calc(100vh - 200px)"},children:[d.jsx(Ft,{sx:{p:2,mb:2},children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2},children:[d.jsx(Vt,{onClick:()=>o(`/jobs/${e.id}`),children:d.jsx(dd,{})}),d.jsxs(ue,{sx:{flex:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(ne,{variant:"h6",children:u.title||`Konversation ${u.id.slice(0,8)}`}),d.jsx(Jt,{label:$.label,size:"small",sx:{backgroundColor:$.color,color:"white"}})]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mt:.5},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:["Model: ",u.model]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[d.jsx(pc,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:e.workingDirectory})]})]})]}),d.jsxs(ue,{sx:{textAlign:"right"},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[m.length," Nachrichten"]}),u.totalTokens&&d.jsxs(ne,{variant:"caption",color:"text.secondary",children:[u.totalTokens.toLocaleString("de-DE")," Tokens"]})]})]})}),d.jsx(Ft,{sx:{flex:1,overflow:"auto",p:2,mb:2,backgroundColor:"background.default"},children:w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):E?d.jsx(zt,{severity:"error",children:E}):m.length===0?d.jsx(ue,{sx:{textAlign:"center",py:4},children:d.jsx(ne,{color:"text.secondary",children:"Noch keine Nachrichten. Starten Sie die Konversation!"})}):d.jsxs(d.Fragment,{children:[m.map(F),x&&d.jsx(ue,{sx:{display:"flex",justifyContent:"flex-start",mb:2},children:d.jsx(Ft,{sx:{p:2,backgroundColor:"grey.900"},children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(Et,{size:16}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[$.label," denkt nach..."]})]})})}),d.jsx("div",{ref:O})]})}),d.jsxs(Ft,{sx:{p:2},children:[E&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>A(null),children:E}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(_t,{fullWidth:!0,multiline:!0,maxRows:4,value:y,onChange:q=>b(q.target.value),onKeyPress:L,placeholder:"Nachricht eingeben... (Enter zum Senden, Shift+Enter für neue Zeile)",disabled:x,size:"small"}),d.jsx(no,{title:"Nachricht senden",children:d.jsx("span",{children:d.jsx(Vt,{color:"primary",onClick:N,disabled:!y.trim()||x,children:x?d.jsx(Et,{size:24}):d.jsx(fL,{})})})})]})]})]})}function h1(e){const{children:n,value:o,index:i,...s}=e;return d.jsx("div",{role:"tabpanel",hidden:o!==i,...s,children:o===i&&d.jsx(ue,{sx:{py:2},children:n})})}function CL({onCreateConversation:e,initialConversationId:n}){const o=Rr(),i=ya(),c=o.pathname.split("/")[2],[u,p]=v.useState(null),[m,g]=v.useState([]),[y,b]=v.useState(null),[w,T]=v.useState(!0),[x,S]=v.useState(0),[E,A]=v.useState(null);v.useEffect(()=>{c&&O()},[c]);const O=async()=>{if(c){T(!0),A(null);try{const[U,$,F]=await Promise.all([Ka.get(c),Ka.getStatus(c),Ka.getConversations(c)]);p(U.data),b($.data.statistics),g(F.data.conversations)}catch(U){console.error("Failed to load job data:",U),A("Fehler beim Laden der Job-Daten")}finally{T(!1)}}},j=async()=>{if(!(!u||!c))try{await Ka.cancel(c),await O()}catch(U){console.error("Failed to cancel job:",U)}},M=U=>{switch(U){case"running":return"primary";case"completed":return"success";case"failed":return"error";case"cancelled":return"warning";default:return"default"}},k=U=>{switch(U){case"pending":return"Ausstehend";case"running":return"Läuft";case"completed":return"Abgeschlossen";case"failed":return"Fehlgeschlagen";case"cancelled":return"Abgebrochen";default:return U}},N=U=>{switch(U){case"claude":return"#D97706";case"codex":return"#059669";case"gemini":return"#2563EB";default:return"#6B7280"}};return w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):E||!u?d.jsxs(ue,{children:[d.jsx(Vt,{onClick:()=>i("/jobs"),sx:{mb:2},children:d.jsx(dd,{})}),d.jsx(zt,{severity:"error",children:E||"Job nicht gefunden"})]}):o.pathname.includes("/conversations/")?w?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):u?d.jsx(SL,{job:u,onRefresh:O}):d.jsxs(ue,{children:[d.jsx(Vt,{onClick:()=>i("/jobs"),sx:{mb:2},children:d.jsx(dd,{})}),d.jsx(zt,{severity:"error",children:"Job nicht gefunden"})]}):d.jsx(wL,{job:u,conversations:m,statistics:y,tabValue:x,setTabValue:S,onCreateConversation:e,loadJobData:O,handleCancelJob:j,getStatusLabel:k,getStatusColor:M,getProviderColor:N})}function wL({job:e,conversations:n,statistics:o,tabValue:i,setTabValue:s,onCreateConversation:c,loadJobData:u,handleCancelJob:p,getStatusLabel:m,getStatusColor:g,getProviderColor:y}){const b=ya();return d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2,mb:3},children:[d.jsx(Vt,{onClick:()=>b("/jobs"),children:d.jsx(dd,{})}),d.jsxs(ue,{sx:{flex:1},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:2},children:[d.jsx(ne,{variant:"h5",children:e.name}),d.jsx(Jt,{label:m(e.status),color:g(e.status),size:"small"})]}),e.description&&d.jsx(ne,{variant:"body2",color:"text.secondary",children:e.description})]}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(no,{title:"Aktualisieren",children:d.jsx(Vt,{onClick:u,children:d.jsx(Vd,{})})}),e.status==="running"&&d.jsx(He,{variant:"outlined",color:"warning",startIcon:d.jsx(ZD,{}),onClick:p,children:"Abbrechen"}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:c,children:"Neue Konversation"})]})]}),d.jsxs(Ft,{sx:{p:2,mb:3},children:[d.jsxs(ue,{sx:{display:"flex",gap:4,flexWrap:"wrap"},children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsx(pc,{color:"action"}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Arbeitsverzeichnis"}),d.jsx(ne,{variant:"body2",children:e.workingDirectory})]})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Erstellt"}),d.jsx(ne,{variant:"body2",children:new Date(e.createdAt).toLocaleString("de-DE")})]}),o&&d.jsxs(d.Fragment,{children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Konversationen"}),d.jsx(ne,{variant:"body2",children:o.conversationCount})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Nachrichten"}),d.jsx(ne,{variant:"body2",children:o.messageCount})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Tokens gesamt"}),d.jsx(ne,{variant:"body2",children:o.tokenUsage.total.toLocaleString("de-DE")})]})]})]}),o&&o.providerBreakdown.length>0&&d.jsxs(ue,{sx:{mt:2},children:[d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:"Provider-Verteilung"}),d.jsx(ue,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:o.providerBreakdown.map(w=>d.jsx(Jt,{label:`${w.provider}: ${w.conversationCount} Konv. / ${w.messageCount} Nachr.`,size:"small",sx:{backgroundColor:y(w.provider),color:"white"}},w.provider))})]})]}),d.jsxs(Ft,{children:[d.jsxs(hC,{value:i,onChange:(w,T)=>s(T),children:[d.jsx(im,{label:`Konversationen (${n.length})`}),d.jsx(im,{label:"System Prompt"})]}),d.jsx(h1,{value:i,index:0,children:d.jsx(xL,{conversations:n,onCreateConversation:c,onRefresh:u})}),d.jsx(h1,{value:i,index:1,children:d.jsx(ue,{sx:{p:2},children:e.systemPrompt?d.jsx(Ft,{variant:"outlined",sx:{p:2,backgroundColor:"grey.900",fontFamily:"monospace",whiteSpace:"pre-wrap"},children:e.systemPrompt}):d.jsx(ne,{color:"text.secondary",children:"Kein System Prompt definiert"})})})]})]})}function EL({open:e,onClose:n,onSelect:o,initialPath:i,title:s="Verzeichnis auswählen"}){const[c,u]=v.useState(!0),[p,m]=v.useState(null),[g,y]=v.useState(null),[b,w]=v.useState(null),[T,x]=v.useState(!1),[S,E]=v.useState(""),[A,O]=v.useState(!1);v.useEffect(()=>{e&&j(i)},[e,i]);const j=async R=>{u(!0),m(null);try{const _=await dm.browse(R);y(_.data),w(_.data.currentPath)}catch(_){console.error("Failed to browse directory:",_),m(_.response?.data?.error||"Fehler beim Laden des Verzeichnisses")}finally{u(!1)}},M=R=>{R.isDirectory&&R.isReadable&&j(R.path)},k=R=>{R.isDirectory&&R.isWritable&&(o(R.path),n())},N=()=>{g?.parentPath&&j(g.parentPath)},L=R=>{j(R)},U=()=>{b&&(o(b),n())},$=async()=>{if(!(!S.trim()||!g?.currentPath)){O(!0),m(null);try{const R=await dm.mkdir(g.currentPath,S.trim());E(""),x(!1),j(R.data.path)}catch(R){console.error("Failed to create folder:",R),m(R.response?.data?.error||"Fehler beim Erstellen des Ordners")}finally{O(!1)}}},F=R=>R===void 0?"":R<1024?`${R} B`:R<1024*1024?`${(R/1024).toFixed(1)} KB`:`${(R/(1024*1024)).toFixed(1)} MB`,q=R=>{const _=R.split("/").filter(Boolean),I=[];let W="";for(const B of _)W+="/"+B,I.push({name:B,path:W});return I};return d.jsxs(oo,{open:e,onClose:n,maxWidth:"md",fullWidth:!0,children:[d.jsx(so,{children:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[d.jsx(ne,{variant:"h6",children:s}),d.jsx(no,{title:"Neuen Ordner erstellen",children:d.jsx(Vt,{onClick:()=>x(!T),color:"primary",children:d.jsx(tL,{})})})]})}),d.jsxs(io,{dividers:!0,children:[p&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>m(null),children:p}),g?.roots&&d.jsx(ue,{sx:{mb:2,display:"flex",gap:1,flexWrap:"wrap"},children:g.roots.map(R=>d.jsx(Jt,{icon:d.jsx(rL,{}),label:R.name,onClick:()=>L(R.path),variant:g.currentPath.startsWith(R.path)?"filled":"outlined",color:g.currentPath.startsWith(R.path)?"primary":"default"},R.path))}),g?.currentPath&&d.jsxs(ue,{sx:{mb:2,display:"flex",alignItems:"center",gap:1},children:[d.jsx(Vt,{size:"small",onClick:N,disabled:!g.parentPath,children:d.jsx(QD,{})}),d.jsx(oO,{maxItems:5,sx:{flex:1},children:q(g.currentPath).map((R,_,I)=>d.jsx(Oz,{component:"button",variant:"body2",onClick:()=>j(R.path),underline:_===I.length-1?"none":"hover",color:_===I.length-1?"text.primary":"inherit",sx:{cursor:"pointer"},children:R.name},R.path))})]}),T&&d.jsxs(ue,{sx:{mb:2,display:"flex",gap:1,alignItems:"center"},children:[d.jsx(_t,{size:"small",label:"Neuer Ordnername",value:S,onChange:R=>E(R.target.value),onKeyPress:R=>R.key==="Enter"&&$(),autoFocus:!0,sx:{flex:1}}),d.jsx(He,{variant:"contained",onClick:$,disabled:!S.trim()||A,size:"small",children:A?d.jsx(Et,{size:20}):"Erstellen"}),d.jsx(He,{variant:"outlined",onClick:()=>{x(!1),E("")},size:"small",children:"Abbrechen"})]}),d.jsx(Uo,{sx:{mb:1}}),c?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):d.jsx(nC,{dense:!0,sx:{maxHeight:400,overflow:"auto",bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:g?.entries.length===0?d.jsx(Kz,{children:d.jsx(Va,{primary:"Leeres Verzeichnis",secondary:"Dieses Verzeichnis enthält keine Einträge"})}):g?.entries.map(R=>d.jsxs(_z,{onClick:()=>M(R),onDoubleClick:()=>k(R),disabled:!R.isReadable,selected:b===R.path,children:[d.jsx(Yi,{children:R.isDirectory?d.jsx(pc,{color:R.isWritable?"primary":"disabled"}):d.jsx(oL,{color:"disabled"})}),d.jsx(Va,{primary:R.name,secondary:R.isDirectory?R.isWritable?"Ordner (beschreibbar)":"Ordner (nur lesen)":F(R.size)}),R.isDirectory&&R.isWritable&&d.jsx(no,{title:"Diesen Ordner auswählen",children:d.jsx(Vt,{size:"small",onClick:_=>{_.stopPropagation(),o(R.path),n()},color:"primary",children:d.jsx(IC,{})})})]},R.path))}),b&&d.jsxs(ue,{sx:{mt:2,p:1,bgcolor:"grey.900",borderRadius:1},children:[d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Ausgewähltes Verzeichnis:"}),d.jsx(ne,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},children:b})]})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:n,children:"Abbrechen"}),d.jsx(He,{variant:"contained",onClick:U,disabled:!b,children:"Aktuelles Verzeichnis auswählen"})]})]})}function TL({open:e,onClose:n,onCreated:o}){const[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(""),[g,y]=v.useState(""),[b,w]=v.useState(!1),[T,x]=v.useState(null),[S,E]=v.useState(!1),A=async()=>{if(!p.trim()){x("Arbeitsverzeichnis ist erforderlich");return}w(!0),x(null);try{const M={workingDirectory:p.trim(),description:c.trim()||void 0,systemPrompt:g.trim()||void 0};i.trim()&&(M.name=i.trim());const k=await Ka.create(M);o(k.data),O()}catch(M){console.error("Failed to create job:",M),x(M.response?.data?.error||"Fehler beim Erstellen des Jobs")}finally{w(!1)}},O=()=>{s(""),u(""),m(""),y(""),x(null),n()},j=async M=>{m(M);try{const k=await dm.getGitInfo(M);k.data.isGitRepo&&k.data.repoName&&!i.trim()&&s(k.data.repoName)}catch(k){console.log("Could not fetch git info:",k)}};return d.jsxs(d.Fragment,{children:[d.jsxs(oo,{open:e,onClose:O,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:"Neuen Job erstellen"}),d.jsx(io,{children:d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[T&&d.jsx(zt,{severity:"error",children:T}),d.jsx(_t,{label:"Name",value:i,onChange:M=>s(M.target.value),fullWidth:!0,autoFocus:!0,placeholder:"z.B. Feature Implementierung (optional, wird aus Git-Repo erkannt)",helperText:"Leer lassen für automatische Erkennung aus Git-Repository"}),d.jsx(_t,{label:"Beschreibung",value:c,onChange:M=>u(M.target.value),fullWidth:!0,multiline:!0,rows:2,placeholder:"Optionale Beschreibung des Jobs"}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"subtitle2",gutterBottom:!0,children:"Arbeitsverzeichnis *"}),d.jsxs(ue,{sx:{display:"flex",gap:1},children:[d.jsx(_t,{value:p,onChange:M=>m(M.target.value),fullWidth:!0,required:!0,placeholder:"Verzeichnis auf dem Server auswählen...",size:"small",InputProps:{readOnly:!0,sx:{fontFamily:"monospace",fontSize:"0.9em"}}}),d.jsx(He,{variant:"outlined",onClick:()=>E(!0),startIcon:d.jsx(pc,{}),children:"Durchsuchen"})]}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:"Wählen Sie ein Verzeichnis auf dem Server für diesen Job aus"})]}),d.jsx(_t,{label:"System Prompt (optional)",value:g,onChange:M=>y(M.target.value),fullWidth:!0,multiline:!0,rows:4,placeholder:"Optionaler System Prompt, der für alle Konversationen dieses Jobs verwendet wird"})]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:O,disabled:b,children:"Abbrechen"}),d.jsx(He,{onClick:A,variant:"contained",disabled:b||!i.trim()||!p.trim(),children:b?d.jsx(Et,{size:24}):"Erstellen"})]})]}),d.jsx(EL,{open:S,onClose:()=>E(!1),onSelect:j,initialPath:p||void 0,title:"Arbeitsverzeichnis auswählen"})]})}const m1={claude:["claude-sonnet-4-20250514","claude-3-5-sonnet-20241022","claude-3-opus-20240229"],codex:["default","o4-mini","o3","codex"],gemini:["gemini-2.5-pro","gemini-2.0-flash","gemini-1.5-pro"]};function RL({open:e,jobId:n,onClose:o,onCreated:i}){const[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(""),[y,b]=v.useState(""),[w,T]=v.useState(!1),[x,S]=v.useState(!0),[E,A]=v.useState([]),[O,j]=v.useState(null);v.useEffect(()=>{e&&M()},[e]),v.useEffect(()=>{p(s&&m1[s][0]||"")},[s]);const M=async()=>{S(!0);try{const $=await rs.getProviders();A($.data.providers);const F=$.data.providers.find(q=>q.isAuthenticated);F&&c(F.provider)}catch($){console.error("Failed to load providers:",$),j("Fehler beim Laden der Provider")}finally{S(!1)}},k=async()=>{if(!s){j("Bitte wählen Sie einen Provider aus");return}T(!0),j(null);try{const $={jobId:n,provider:s,model:u||void 0,title:m.trim()||void 0,systemPrompt:y.trim()||void 0},F=await rs.create($);i(F.data.conversation),N()}catch($){console.error("Failed to create conversation:",$),j($.response?.data?.error||"Fehler beim Erstellen der Konversation")}finally{T(!1)}},N=()=>{c(""),p(""),g(""),b(""),j(null),o()},L=$=>{switch($){case"claude":return"Claude (Anthropic)";case"codex":return"Codex (OpenAI)";case"gemini":return"Gemini (Google)";default:return $}},U=$=>{switch($){case"claude":return"#D97706";case"codex":return"#059669";case"gemini":return"#2563EB";default:return"#6B7280"}};return d.jsxs(oo,{open:e,onClose:N,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:"Neue Konversation starten"}),d.jsx(io,{children:d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[O&&d.jsx(zt,{severity:"error",children:O}),x?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:2},children:d.jsx(Et,{})}):d.jsxs(d.Fragment,{children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"subtitle2",gutterBottom:!0,children:"LLM Provider auswählen"}),d.jsx(ue,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:E.map($=>d.jsx(Jt,{label:d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:.5},children:[L($.provider),$.isAuthenticated?d.jsx(IC,{fontSize:"small",sx:{color:"success.main"}}):d.jsx(HC,{fontSize:"small",sx:{color:"error.main"}})]}),onClick:()=>$.isAuthenticated&&c($.provider),disabled:!$.isAuthenticated,variant:s===$.provider?"filled":"outlined",sx:{borderColor:U($.provider),backgroundColor:s===$.provider?U($.provider):"transparent",color:s===$.provider?"white":"inherit","&:hover":{backgroundColor:$.isAuthenticated?U($.provider):void 0,color:$.isAuthenticated?"white":void 0}}},$.provider))}),E.some($=>!$.isAuthenticated)&&d.jsx(ne,{variant:"caption",color:"text.secondary",sx:{mt:.5,display:"block"},children:'Nicht authentifizierte Provider sind deaktiviert. Gehen Sie zu "Provider Authentifizierung" um sich anzumelden.'})]}),s&&d.jsxs(eC,{fullWidth:!0,children:[d.jsx(tC,{children:"Model"}),d.jsx(ag,{value:u,label:"Model",onChange:$=>p($.target.value),children:m1[s].map($=>d.jsx(fa,{value:$,children:$},$))})]}),d.jsx(_t,{label:"Titel (optional)",value:m,onChange:$=>g($.target.value),fullWidth:!0,placeholder:"z.B. Bug Fix Discussion"}),d.jsx(_t,{label:"System Prompt (optional)",value:y,onChange:$=>b($.target.value),fullWidth:!0,multiline:!0,rows:3,placeholder:"Optionaler System Prompt für diese Konversation",helperText:"Wenn leer, wird der System Prompt des Jobs verwendet"})]})]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:N,disabled:w,children:"Abbrechen"}),d.jsx(He,{onClick:k,variant:"contained",disabled:w||!s||x,children:w?d.jsx(Et,{size:24}):"Starten"})]})]})}function jL(){const[e,n]=v.useState([]),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(!1),[m,g]=v.useState(""),[y,b]=v.useState(""),[w,T]=v.useState(!1),[x,S]=v.useState(null),[E,A]=v.useState(!0),[O,j]=v.useState(!1),[M,k]=v.useState(!1),[N,L]=v.useState(null),[U,$]=v.useState(!1);v.useEffect(()=>{F()},[]);const F=async()=>{try{i(!0);const P=await Mh.list();n(P.data.data)}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{i(!1)}},q=async()=>{try{T(!0),c("");const P=await Mh.create({name:m,expiresAt:y||void 0});S(P.data.data.key),g(""),b(""),F()}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{T(!1)}},R=()=>{x&&(navigator.clipboard.writeText(x),j(!0),setTimeout(()=>j(!1),2e3))},_=()=>{p(!1),S(null),A(!0),j(!1)},I=async()=>{if(N)try{$(!0),await Mh.revoke(N.id),k(!1),L(null),F()}catch(P){c(P.response?.data?.message||Y("errors.generic"))}finally{$(!1)}},W=P=>P?new Date(P).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",B=P=>P.revokedAt?d.jsx(Jt,{label:Y("apiKeys.revoked"),color:"error",size:"small"}):P.expiresAt&&new Date(P.expiresAt)<new Date?d.jsx(Jt,{label:Y("apiKeys.expired"),color:"warning",size:"small"}):d.jsx(Jt,{label:Y("apiKeys.active"),color:"success",size:"small"});return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("apiKeys.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("apiKeys.subtitle")})]}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:()=>p(!0),children:Y("apiKeys.createKey")})]}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),e.length===0?d.jsx(Ft,{sx:{p:4,textAlign:"center"},children:d.jsx(ne,{color:"text.secondary",children:Y("apiKeys.noKeys")})}):d.jsx(fC,{component:Ft,children:d.jsxs(uC,{children:[d.jsx(pC,{children:d.jsxs(cd,{children:[d.jsx(Mt,{children:Y("apiKeys.keyName")}),d.jsx(Mt,{children:Y("apiKeys.keyPrefix")}),d.jsx(Mt,{children:Y("common.status")}),d.jsx(Mt,{children:Y("apiKeys.lastUsed")}),d.jsx(Mt,{children:Y("apiKeys.expiresAt")}),d.jsx(Mt,{children:Y("common.createdAt")}),d.jsx(Mt,{align:"right",children:Y("common.actions")})]})}),d.jsx(dC,{children:e.map(P=>d.jsxs(cd,{children:[d.jsx(Mt,{children:d.jsx(ne,{sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.name})}),d.jsx(Mt,{children:d.jsxs(ne,{variant:"body2",sx:{fontFamily:"monospace"},children:[P.keyPrefix,"..."]})}),d.jsx(Mt,{children:B(P)}),d.jsx(Mt,{children:P.lastUsedAt?W(P.lastUsedAt):Y("apiKeys.neverUsed")}),d.jsx(Mt,{children:P.expiresAt?W(P.expiresAt):Y("apiKeys.neverExpires")}),d.jsx(Mt,{children:W(P.createdAt)}),d.jsx(Mt,{align:"right",children:P.isValid&&d.jsx(no,{title:Y("apiKeys.revoke"),children:d.jsx(Vt,{size:"small",color:"error",onClick:()=>{L(P),k(!0)},children:d.jsx(Fd,{})})})})]},P.id))})]})}),d.jsxs(oo,{open:u,onClose:_,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:Y(x?"apiKeys.newKeyCreated":"apiKeys.createKey")}),d.jsx(io,{children:x?d.jsxs(ue,{children:[d.jsx(zt,{severity:"warning",sx:{mb:2},children:Y("apiKeys.copyWarning")}),d.jsx(_t,{fullWidth:!0,value:x,type:E?"text":"password",InputProps:{readOnly:!0,sx:{fontFamily:"monospace"},endAdornment:d.jsxs(eg,{position:"end",children:[d.jsx(Vt,{onClick:()=>A(!E),children:E?d.jsx(mL,{}):d.jsx(hL,{})}),d.jsx(Vt,{onClick:R,color:O?"success":"default",children:d.jsx(FC,{})})]})}}),O&&d.jsx(ne,{variant:"caption",color:"success.main",sx:{mt:1,display:"block"},children:Y("common.copied")})]}):d.jsxs(ue,{sx:{pt:1},children:[d.jsx(_t,{fullWidth:!0,label:Y("apiKeys.keyName"),value:m,onChange:P=>g(P.target.value),margin:"normal",required:!0,autoFocus:!0}),d.jsx(_t,{fullWidth:!0,label:Y("apiKeys.expirationDate"),type:"datetime-local",value:y,onChange:P=>b(P.target.value),margin:"normal",InputLabelProps:{shrink:!0},helperText:Y("apiKeys.expirationHelp")})]})}),d.jsx(ao,{children:x?d.jsx(He,{onClick:_,children:Y("common.close")}):d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:_,children:Y("common.cancel")}),d.jsx(He,{variant:"contained",onClick:q,disabled:!m||w,children:w?d.jsx(Et,{size:24}):Y("common.create")})]})})]}),d.jsxs(oo,{open:M,onClose:()=>k(!1),children:[d.jsx(so,{children:Y("apiKeys.revoke")}),d.jsxs(io,{children:[d.jsx(ne,{children:Y("apiKeys.revokeConfirm")}),N&&d.jsxs(ne,{variant:"body2",sx:{mt:1,fontFamily:"monospace"},children:[N.name," (",N.keyPrefix,"...)"]})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>k(!1),children:Y("common.cancel")}),d.jsx(He,{variant:"contained",color:"error",onClick:I,disabled:U,children:U?d.jsx(Et,{size:24}):Y("apiKeys.revoke")})]})]})]})}const AL=["job.created","job.updated","job.completed","job.failed","job.cancelled","conversation.created","conversation.updated","message.created","message.streaming","message.completed","tool.called","tool.completed"];function ML(){const[e,n]=v.useState([]),[o,i]=v.useState(!0),[s,c]=v.useState(""),[u,p]=v.useState(""),[m,g]=v.useState(!1),[y,b]=v.useState(""),[w,T]=v.useState(""),[x,S]=v.useState([]),[E,A]=v.useState(!1),[O,j]=v.useState(null),[M,k]=v.useState(!1),[N,L]=v.useState(!1),[U,$]=v.useState(null),[F,q]=v.useState(!1);v.useEffect(()=>{R()},[]);const R=async()=>{try{i(!0);const H=await Wi.list();n(H.data.data)}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{i(!1)}},_=async()=>{try{A(!0),c("");const H=await Wi.create({name:y,url:w,events:x});j(H.data.data.secret),R()}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{A(!1)}},I=()=>{O&&(navigator.clipboard.writeText(O),k(!0),setTimeout(()=>k(!1),2e3))},W=()=>{g(!1),j(null),b(""),T(""),S([]),k(!1)},B=async H=>{try{await Wi.update(H.id,{active:!H.active}),R()}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},P=async()=>{if(U)try{q(!0),await Wi.delete(U.id),L(!1),$(null),R()}catch(H){c(H.response?.data?.message||Y("errors.generic"))}finally{q(!1)}},X=async H=>{try{await Wi.test(H.id),p("Test-Webhook wurde gesendet"),setTimeout(()=>p(""),3e3)}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},Z=async H=>{try{const Q=await Wi.regenerateSecret(H.id);j(Q.data.data.secret),p("Neues Secret generiert")}catch(Q){c(Q.response?.data?.message||Y("errors.generic"))}},pe=H=>H?new Date(H).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-",D=H=>{x.includes(H)?S(x.filter(Q=>Q!==H)):S([...x,H])};return o?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",p:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("webhooks.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("webhooks.subtitle")})]}),d.jsx(He,{variant:"contained",startIcon:d.jsx(hs,{}),onClick:()=>g(!0),children:Y("webhooks.createWebhook")})]}),s&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>c(""),children:s}),u&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>p(""),children:u}),e.length===0?d.jsx(Ft,{sx:{p:4,textAlign:"center"},children:d.jsx(ne,{color:"text.secondary",children:Y("webhooks.noWebhooks")})}):d.jsx(fC,{component:Ft,children:d.jsxs(uC,{children:[d.jsx(pC,{children:d.jsxs(cd,{children:[d.jsx(Mt,{children:Y("webhooks.webhookName")}),d.jsx(Mt,{children:Y("webhooks.webhookUrl")}),d.jsx(Mt,{children:Y("webhooks.events")}),d.jsx(Mt,{children:Y("common.status")}),d.jsx(Mt,{children:Y("webhooks.lastTriggered")}),d.jsx(Mt,{children:Y("webhooks.failures")}),d.jsx(Mt,{align:"right",children:Y("common.actions")})]})}),d.jsx(dC,{children:e.map(H=>d.jsxs(cd,{children:[d.jsx(Mt,{children:d.jsx(ne,{sx:{maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:H.name})}),d.jsx(Mt,{children:d.jsx(ne,{variant:"body2",sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"0.8rem"},children:H.url})}),d.jsx(Mt,{children:d.jsxs(ue,{sx:{display:"flex",gap:.5,flexWrap:"wrap",maxWidth:200},children:[H.events.slice(0,3).map(Q=>d.jsx(Jt,{label:Q.split(".")[1],size:"small",variant:"outlined"},Q)),H.events.length>3&&d.jsx(Jt,{label:`+${H.events.length-3}`,size:"small",variant:"outlined"})]})}),d.jsx(Mt,{children:d.jsx(lB,{checked:H.active,onChange:()=>B(H),size:"small"})}),d.jsx(Mt,{children:pe(H.lastTriggeredAt)}),d.jsx(Mt,{children:H.failureCount>0?d.jsx(Jt,{label:H.failureCount,color:"error",size:"small"}):"0"}),d.jsxs(Mt,{align:"right",children:[d.jsx(no,{title:Y("webhooks.testWebhook"),children:d.jsx(Vt,{size:"small",onClick:()=>X(H),children:d.jsx(cL,{})})}),d.jsx(no,{title:Y("webhooks.regenerateSecret"),children:d.jsx(Vt,{size:"small",onClick:()=>Z(H),children:d.jsx(Vd,{})})}),d.jsx(no,{title:Y("common.delete"),children:d.jsx(Vt,{size:"small",color:"error",onClick:()=>{$(H),L(!0)},children:d.jsx(Fd,{})})})]})]},H.id))})]})}),d.jsxs(oo,{open:m,onClose:W,maxWidth:"sm",fullWidth:!0,children:[d.jsx(so,{children:O?"Webhook erstellt":Y("webhooks.createWebhook")}),d.jsx(io,{children:O?d.jsxs(ue,{children:[d.jsx(zt,{severity:"warning",sx:{mb:2},children:Y("apiKeys.copyWarning")}),d.jsx(_t,{fullWidth:!0,label:"Webhook Secret",value:O,InputProps:{readOnly:!0,sx:{fontFamily:"monospace"},endAdornment:d.jsx(eg,{position:"end",children:d.jsx(Vt,{onClick:I,color:M?"success":"default",children:d.jsx(FC,{})})})}}),M&&d.jsx(ne,{variant:"caption",color:"success.main",sx:{mt:1,display:"block"},children:Y("common.copied")})]}):d.jsxs(ue,{sx:{pt:1},children:[d.jsx(_t,{fullWidth:!0,label:Y("webhooks.webhookName"),value:y,onChange:H=>b(H.target.value),margin:"normal",required:!0,autoFocus:!0}),d.jsx(_t,{fullWidth:!0,label:Y("webhooks.webhookUrl"),value:w,onChange:H=>T(H.target.value),margin:"normal",required:!0,placeholder:"https://example.com/webhook"}),d.jsx(ne,{variant:"subtitle2",sx:{mt:2,mb:1},children:Y("webhooks.selectEvents")}),d.jsx(Ft,{variant:"outlined",sx:{p:2,maxHeight:300,overflow:"auto"},children:d.jsx(X3,{children:AL.map(H=>d.jsx(W3,{control:d.jsx(_O,{checked:x.includes(H),onChange:()=>D(H),size:"small"}),label:d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",children:H}),d.jsx(ne,{variant:"caption",color:"text.secondary",children:Y(`webhooks.eventDescriptions.${H}`)})]})},H))})})]})}),d.jsx(ao,{children:O?d.jsx(He,{onClick:W,children:Y("common.close")}):d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:W,children:Y("common.cancel")}),d.jsx(He,{variant:"contained",onClick:_,disabled:!y||!w||x.length===0||E,children:E?d.jsx(Et,{size:24}):Y("common.create")})]})})]}),d.jsxs(oo,{open:N,onClose:()=>L(!1),children:[d.jsx(so,{children:Y("common.delete")}),d.jsxs(io,{children:[d.jsx(ne,{children:"Möchten Sie diesen Webhook wirklich löschen?"}),U&&d.jsx(ne,{variant:"body2",sx:{mt:1,fontWeight:"bold"},children:U.name})]}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>L(!1),children:Y("common.cancel")}),d.jsx(He,{variant:"contained",color:"error",onClick:P,disabled:F,children:F?d.jsx(Et,{size:24}):Y("common.delete")})]})]})]})}function kL(){const{user:e}=fc(),[n,o]=v.useState(""),[i,s]=v.useState(""),[c,u]=v.useState(""),[p,m]=v.useState(!1),[g,y]=v.useState(""),[b,w]=v.useState(""),T=async x=>{if(x.preventDefault(),y(""),w(""),i!==c){y(Y("auth.passwordMismatch"));return}if(i.length<8){y(Y("auth.passwordMinLength"));return}try{m(!0),await Cn.changePassword({currentPassword:n,newPassword:i}),w(Y("auth.passwordChanged")),o(""),s(""),u("")}catch(S){y(S.response?.data?.message||Y("errors.generic"))}finally{m(!1)}};return d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("profile.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("profile.subtitle")}),d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:3},children:[d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(qC,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("profile.accountInfo")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("auth.username"),":"]}),d.jsx(ne,{variant:"body1",children:e?.username}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("profile.role"),":"]}),d.jsx(ne,{variant:"body1",children:e?.role==="admin"?Y("profile.roleAdmin"):Y("profile.roleUser")})]})]})}),d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(aL,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("auth.changePassword")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:2},children:Y("profile.changePasswordDesc")}),g&&d.jsx(zt,{severity:"error",sx:{mb:2},onClose:()=>y(""),children:g}),b&&d.jsx(zt,{severity:"success",sx:{mb:2},onClose:()=>w(""),children:b}),d.jsxs(ue,{component:"form",onSubmit:T,sx:{maxWidth:400},children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.currentPassword"),type:"password",value:n,onChange:x=>o(x.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),d.jsx(_t,{fullWidth:!0,label:Y("auth.newPassword"),type:"password",value:i,onChange:x=>s(x.target.value),margin:"normal",required:!0,autoComplete:"new-password",helperText:Y("auth.passwordMinLength")}),d.jsx(_t,{fullWidth:!0,label:Y("auth.confirmPassword"),type:"password",value:c,onChange:x=>u(x.target.value),margin:"normal",required:!0,autoComplete:"new-password",error:c!==""&&i!==c,helperText:c!==""&&i!==c?Y("auth.passwordMismatch"):""}),d.jsx(He,{type:"submit",variant:"contained",sx:{mt:2},disabled:p||!n||!i||!c,children:p?d.jsx(Et,{size:24}):Y("auth.changePassword")})]})]})})]})]})}function g1(e){const n=["B","KB","MB","GB","TB"];let o=0,i=e;for(;i>=1024&&o<n.length-1;)i/=1024,o++;return`${i.toFixed(1)} ${n[o]}`}function OL(e){const n=Math.floor(e/86400),o=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return n>0?`${n}d ${o}h ${i}m`:o>0?`${o}h ${i}m`:`${i}m`}function zL(){const[e,n]=v.useState(null),[o,i]=v.useState(null),[s,c]=v.useState(""),[u,p]=v.useState(!0),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[w,T]=v.useState(""),[x,S]=v.useState(!1),[E,A]=v.useState(!1),[O,j]=v.useState({open:!1,message:"",severity:"info"}),[M,k]=v.useState(!1),[N,L]=v.useState(0),U=v.useCallback(async()=>{try{p(!0),T("");const[_,I,W]=await Promise.all([da.getVersion(),da.getInfo(),da.getUpdateLog()]);n(_.data.data),i(I.data.data),c(W.data.data.log)}catch(_){T(_.response?.data?.message||Y("errors.generic"))}finally{p(!1)}},[]);v.useEffect(()=>{U()},[U]);const $=async()=>{S(!1),g(!0),T("");try{const I=(await da.triggerUpdate()).data.data;I.success?(j({open:!0,message:I.message,severity:"success"}),I.message.includes("neu gestartet")&&await q()):j({open:!0,message:I.message,severity:"error"})}catch(_){j({open:!0,message:_.response?.data?.message||Y("errors.generic"),severity:"error"})}finally{g(!1)}},F=async()=>{A(!1),b(!0),T("");try{const I=(await da.triggerRestart()).data.data;I.success?(j({open:!0,message:I.message,severity:"info"}),await q()):j({open:!0,message:I.message,severity:"error"})}catch{j({open:!0,message:"Server startet neu...",severity:"info"}),await q()}finally{b(!1)}},q=async()=>{k(!0),L(0),await new Promise(I=>setTimeout(I,1500));const _=await da.waitForReconnect(30,2e3,(I,W)=>{L(Math.round(I/W*100))});k(!1),L(0),_?(j({open:!0,message:"Server erfolgreich neu gestartet!",severity:"success"}),U()):j({open:!0,message:"Server antwortet nicht - bitte Seite manuell neu laden",severity:"error"})},R=async()=>{try{await da.clearUpdateLog(),c("Kein Update-Log vorhanden"),j({open:!0,message:"Update-Log gelöscht",severity:"success"})}catch(_){j({open:!0,message:_.response?.data?.message||Y("errors.generic"),severity:"error"})}};return u?d.jsx(ue,{sx:{display:"flex",justifyContent:"center",py:4},children:d.jsx(Et,{})}):d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[d.jsxs(ue,{children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("system.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.subtitle")})]}),d.jsx(no,{title:Y("common.refresh"),children:d.jsx(Vt,{onClick:U,disabled:u,children:d.jsx(Vd,{})})})]}),w&&d.jsx(zt,{severity:"error",sx:{mb:2},children:w}),M&&d.jsxs(zt,{severity:"info",sx:{mb:2},icon:d.jsx(Et,{size:20}),children:["Verbinde zum Server... (",N,"%)",d.jsx(zx,{variant:"determinate",value:N,sx:{mt:1}})]}),d.jsxs(ue,{sx:{display:"flex",flexDirection:"column",gap:3},children:[d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(p1,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("system.version")}),e?.updateAvailable&&d.jsx(Jt,{icon:d.jsx(lL,{}),label:Y("system.updateAvailable"),color:"warning",size:"small"})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2,mb:3},children:[d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.currentVersion"),":"]}),d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1},children:[d.jsxs(ne,{variant:"body1",fontWeight:"medium",children:["v",e?.current||"?"]}),!e?.updateAvailable&&d.jsx(Jt,{icon:d.jsx(JD,{}),label:Y("system.upToDate"),color:"success",size:"small"})]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.latestVersion"),":"]}),d.jsxs(ne,{variant:"body1",children:["v",e?.latest||"?"]}),d.jsxs(ne,{variant:"body2",color:"text.secondary",children:[Y("system.lastChecked"),":"]}),d.jsx(ne,{variant:"body1",children:e?.lastChecked?new Date(e.lastChecked).toLocaleString("de-DE"):"-"})]}),d.jsxs(ue,{sx:{display:"flex",gap:2},children:[d.jsx(He,{variant:"contained",startIcon:m?d.jsx(Et,{size:20}):d.jsx(p1,{}),onClick:()=>S(!0),disabled:m||y||M||!e?.updateAvailable,children:Y("system.update")}),d.jsx(He,{variant:"outlined",startIcon:y?d.jsx(Et,{size:20}):d.jsx(uL,{}),onClick:()=>A(!0),disabled:m||y||M,children:Y("system.restart")})]})]})}),d.jsx(to,{children:d.jsxs(No,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:2},children:[d.jsx(eL,{color:"primary"}),d.jsx(ne,{variant:"h6",children:Y("system.info")})]}),d.jsx(Uo,{sx:{mb:2}}),d.jsxs(ue,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:3},children:[d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[d.jsx(WC,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.uptime")})]}),d.jsx(ne,{variant:"h6",children:o?OL(o.uptime):"-"})]}),d.jsxs(ue,{children:[d.jsxs(ue,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[d.jsx(sL,{fontSize:"small",color:"action"}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:Y("system.memory")})]}),d.jsx(ne,{variant:"h6",children:o?`${g1(o.memoryUsage.used)} / ${g1(o.memoryUsage.total)}`:"-"}),o&&d.jsx(zx,{variant:"determinate",value:o.memoryUsage.percentage,color:o.memoryUsage.percentage>80?"error":"primary",sx:{mt:1}})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Node.js"}),d.jsx(ne,{variant:"body1",children:o?.nodeVersion||"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:Y("system.platform")}),d.jsx(ne,{variant:"body1",children:o?`${o.platform} (${o.arch})`:"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Hostname"}),d.jsx(ne,{variant:"body1",children:o?.hostname||"-"})]}),d.jsxs(ue,{children:[d.jsx(ne,{variant:"body2",color:"text.secondary",gutterBottom:!0,children:"Process ID"}),d.jsx(ne,{variant:"body1",children:o?`${o.pid} (Parent: ${o.ppid})`:"-"})]})]})]})}),d.jsxs(a5,{children:[d.jsx(M5,{expandIcon:d.jsx(nL,{}),children:d.jsx(ne,{children:Y("system.updateLog")})}),d.jsxs(c5,{children:[d.jsx(ue,{sx:{bgcolor:"grey.900",p:2,borderRadius:1,fontFamily:"monospace",fontSize:"0.85rem",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflow:"auto"},children:s||"Kein Update-Log vorhanden"}),d.jsx(ue,{sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:d.jsx(He,{size:"small",onClick:R,children:Y("system.clearLog")})})]})]})]}),d.jsxs(oo,{open:x,onClose:()=>S(!1),children:[d.jsx(so,{children:Y("system.confirmUpdate")}),d.jsx(io,{children:d.jsxs(em,{children:[Y("system.confirmUpdateText"),d.jsx("br",{}),d.jsx("br",{}),d.jsxs("strong",{children:[Y("system.currentVersion"),":"]})," v",e?.current,d.jsx("br",{}),d.jsxs("strong",{children:[Y("system.latestVersion"),":"]})," v",e?.latest]})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>S(!1),children:Y("common.cancel")}),d.jsx(He,{onClick:$,variant:"contained",color:"primary",children:Y("system.update")})]})]}),d.jsxs(oo,{open:E,onClose:()=>A(!1),children:[d.jsx(so,{children:Y("system.confirmRestart")}),d.jsx(io,{children:d.jsx(em,{children:Y("system.confirmRestartText")})}),d.jsxs(ao,{children:[d.jsx(He,{onClick:()=>A(!1),children:Y("common.cancel")}),d.jsx(He,{onClick:F,variant:"contained",color:"warning",children:Y("system.restart")})]})]}),d.jsx(Y6,{open:O.open,autoHideDuration:6e3,onClose:()=>j({...O,open:!1}),anchorOrigin:{vertical:"bottom",horizontal:"center"},children:d.jsx(zt,{onClose:()=>j({...O,open:!1}),severity:O.severity,action:d.jsx(Vt,{size:"small",color:"inherit",onClick:()=>j({...O,open:!1}),children:d.jsx(HC,{fontSize:"small"})}),children:O.message})})]})}function Ia(e){const{children:n,value:o,index:i,...s}=e;return d.jsx("div",{role:"tabpanel",hidden:o!==i,...s,children:o===i&&d.jsx(ue,{sx:{py:3},children:n})})}function BL(){const{user:e,logout:n}=fc(),o=ya(),i=Rr(),[s,c]=v.useState(0),[u,p]=v.useState(null),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[w,T]=v.useState(0),[x,S]=v.useState(0),[E,A]=v.useState(null),[O,j]=v.useState(""),[M,k]=v.useState(""),[N,L]=v.useState(""),[U,$]=v.useState(""),[F,q]=v.useState(!1);v.useEffect(()=>{i.pathname==="/"||i.pathname===""?o("/jobs",{replace:!0}):i.pathname.startsWith("/jobs")?c(0):i.pathname.startsWith("/provider-auth")?c(1):i.pathname.startsWith("/admin/users")&&e?.role==="admin"?c(2):i.pathname.startsWith("/settings/api-keys")?c(e?.role==="admin"?3:2):i.pathname.startsWith("/settings/webhooks")?c(e?.role==="admin"?4:3):i.pathname.startsWith("/settings/profile")?c(e?.role==="admin"?5:4):i.pathname.startsWith("/settings/system")&&e?.role==="admin"?c(6):o("/jobs",{replace:!0})},[i.pathname,e?.role,o]);const R=Q=>{T(se=>se+1),o(`/jobs/${Q.id}`)},_=Q=>{A(Q.id),S(se=>se+1)},I=async Q=>{Q.preventDefault(),L(""),$(""),q(!0);try{await Cn.register({username:O,password:M}),$(Y("users.userCreated",{username:O})),j(""),k("")}catch(se){L(se.response?.data?.message||Y("users.createFailed"))}finally{q(!1)}},W=Q=>{p(Q.currentTarget)},B=()=>{p(null)},P=()=>{B(),o("/settings/profile")},X=()=>{B(),o("/settings/api-keys")},Z=()=>{B(),o("/settings/webhooks")},pe=()=>{B(),o("/settings/system")},D=()=>{B(),n()},H=[{label:Y("nav.jobs"),index:0},{label:Y("nav.providerAuth"),index:1},...e?.role==="admin"?[{label:Y("nav.userManagement"),index:2}]:[],{label:Y("nav.apiKeys"),index:e?.role==="admin"?3:2},{label:Y("nav.webhooks"),index:e?.role==="admin"?4:3},{label:Y("nav.profile"),index:e?.role==="admin"?5:4},...e?.role==="admin"?[{label:Y("nav.system"),index:6}]:[]];return d.jsxs(ue,{sx:{flexGrow:1,minHeight:"100vh",display:"flex",flexDirection:"column"},children:[d.jsx(u4,{position:"static",children:d.jsxs(BB,{children:[d.jsx(ne,{variant:"h6",component:"div",sx:{flexGrow:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:"LLM Dev Server"}),d.jsx(Vt,{size:"large",color:"inherit",onClick:W,sx:{ml:1},children:d.jsx(XD,{})}),d.jsxs(Ld,{anchorEl:u,open:!!u,onClose:B,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[d.jsxs(ue,{sx:{px:2,py:1},children:[d.jsx(ne,{variant:"subtitle1",sx:{fontWeight:"bold"},children:e?.username}),d.jsx(ne,{variant:"body2",color:"text.secondary",children:e?.role==="admin"?Y("profile.roleAdmin"):Y("profile.roleUser")})]}),d.jsx(Uo,{}),d.jsxs(fa,{onClick:P,children:[d.jsx(Yi,{children:d.jsx(qC,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.profile")})]}),d.jsxs(fa,{onClick:X,children:[d.jsx(Yi,{children:d.jsx(gL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.apiKeys")})]}),d.jsxs(fa,{onClick:Z,children:[d.jsx(Yi,{children:d.jsx(yL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.webhooks")})]}),e?.role==="admin"&&d.jsxs(fa,{onClick:pe,children:[d.jsx(Yi,{children:d.jsx(pL,{fontSize:"small"})}),d.jsx(Va,{children:Y("nav.system")})]}),d.jsx(Uo,{}),d.jsxs(fa,{onClick:D,children:[d.jsx(Yi,{children:d.jsx(iL,{fontSize:"small"})}),d.jsx(Va,{children:Y("auth.logout")})]})]})]})}),d.jsx(YS,{maxWidth:"xl",sx:{mt:4,flex:1,pb:4},children:d.jsxs(Ft,{sx:{width:"100%",overflow:"hidden"},children:[d.jsx(hC,{value:s,onChange:(Q,se)=>{c(se),se===0?o("/jobs"):se===1?o("/provider-auth"):se===2&&e?.role==="admin"?o("/admin/users"):se===(e?.role==="admin"?3:2)?o("/settings/api-keys"):se===(e?.role==="admin"?4:3)?o("/settings/webhooks"):se===(e?.role==="admin"?5:4)?o("/settings/profile"):se===6&&e?.role==="admin"&&o("/settings/system")},"aria-label":"Dashboard Tabs",variant:"scrollable",scrollButtons:"auto",sx:{borderBottom:1,borderColor:"divider","& .MuiTab-root":{minWidth:"auto",px:3}},children:H.map(Q=>d.jsx(im,{label:Q.label},Q.index))}),d.jsx(Ia,{value:s,index:0,children:i.pathname==="/jobs"||i.pathname==="/jobs/"?d.jsx(bL,{onCreateJob:()=>g(!0)},`job-list-${w}`):i.pathname.startsWith("/jobs/")?d.jsx(CL,{onCreateConversation:()=>b(!0),initialConversationId:E||void 0},`job-detail-${x}`):null}),d.jsx(Ia,{value:s,index:1,children:d.jsx(vL,{})}),e?.role==="admin"&&d.jsxs(Ia,{value:s,index:2,children:[d.jsx(ne,{variant:"h5",gutterBottom:!0,children:Y("users.title")}),d.jsx(ne,{variant:"body2",color:"text.secondary",sx:{mb:3},children:Y("users.subtitle")}),N&&d.jsx(zt,{severity:"error",sx:{mb:2},children:N}),U&&d.jsx(zt,{severity:"success",sx:{mb:2},children:U}),d.jsxs(ue,{component:"form",onSubmit:I,sx:{maxWidth:400},children:[d.jsx(_t,{fullWidth:!0,label:Y("auth.username"),value:O,onChange:Q=>j(Q.target.value),margin:"normal",required:!0}),d.jsx(_t,{fullWidth:!0,label:Y("auth.password"),type:"password",value:M,onChange:Q=>k(Q.target.value),margin:"normal",required:!0,helperText:Y("auth.passwordMinLength")}),d.jsx(He,{type:"submit",variant:"contained",sx:{mt:2},disabled:F,children:F?d.jsx(Et,{size:24}):Y("users.createUser")})]})]}),d.jsx(Ia,{value:s,index:e?.role==="admin"?3:2,children:d.jsx(jL,{})}),d.jsx(Ia,{value:s,index:e?.role==="admin"?4:3,children:d.jsx(ML,{})}),d.jsx(Ia,{value:s,index:e?.role==="admin"?5:4,children:d.jsx(kL,{})}),e?.role==="admin"&&d.jsx(Ia,{value:s,index:6,children:d.jsx(zL,{})})]})}),d.jsx(TL,{open:m,onClose:()=>g(!1),onCreated:R}),i.pathname.startsWith("/jobs/")&&i.pathname.split("/").length>=3&&d.jsx(RL,{open:y,jobId:i.pathname.split("/")[2],onClose:()=>b(!1),onCreated:_})]})}const NL=jd({palette:{mode:"dark"}});function DL({children:e}){const{user:n,loading:o}=fc();return o?d.jsx("div",{children:"Loading..."}):n?d.jsx(d.Fragment,{children:e}):d.jsx(zh,{to:"/login"})}function LL(){const{user:e}=fc();return d.jsxs(dT,{children:[d.jsx(_u,{path:"/login",element:e?d.jsx(zh,{to:"/jobs"}):d.jsx(YD,{})}),d.jsx(_u,{path:"/*",element:d.jsx(DL,{children:d.jsx(BL,{})})}),d.jsx(_u,{path:"*",element:d.jsx(zh,{to:"/jobs"})})]})}function $L(){return d.jsxs(kM,{theme:NL,children:[d.jsx(GO,{}),d.jsx(ND,{children:d.jsx(DT,{children:d.jsx(LL,{})})})]})}hE.createRoot(document.getElementById("root")).render(d.jsx(Dr.StrictMode,{children:d.jsx($L,{})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>LLM Dev Server</title>
7
- <script type="module" crossorigin src="/assets/index-4QnHnKel.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-DOfnm5H8.js"></script>
8
8
  </head>
9
9
  <body>
10
10
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrishdx/llm-dev-server",
3
- "version": "1.2.5",
3
+ "version": "1.2.8",
4
4
  "description": "Multi-LLM Development Server (Claude, Codex, Gemini) - A unified interface for AI coding assistants",
5
5
  "private": false,
6
6
  "workspaces": [