PageSourceSearch

https://multiai.co/_next/static/chunks/43w711ed5xmpx.js

js multiai.co collected 2026-09-24 14:37:12 UTC 305,847 bytes, 3 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,112234,e=>{"use strict";let t=(0,e.i(456420).default)("folder-closed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);e.s(["FolderClosed",0,t],112234)},996085,e=>{"use strict";let t,s,n,r=Object.create(null);r.open="0",r.close="1",r.ping="2",r.pong="3",r.message="4",r.upgrade="5",r.noop="6";let a=Object.create(null);Object.keys(r).forEach(e=>{a[r[e]]=e});let i={type:"error",data:"parser error"},o="function"==typeof Blob||"u">typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),l="function"==typeof ArrayBuffer,d=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,c=({type:e,data:t},s,n)=>{if(o&&t instanceof Blob)if(s)return n(t);else return u(t,n);if(l&&(t instanceof ArrayBuffer||d(t)))if(s)return n(t);else return u(new Blob([t]),n);return n(r[e]+(t||""))},u=(e,t)=>{let s=new FileReader;return s.onload=function(){t("b"+(s.result.split(",")[1]||""))},s.readAsDataURL(e)};function h(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p="u"<typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<m.length;e++)p[m.charCodeAt(e)]=e;let x="function"==typeof ArrayBuffer,f=(e,t)=>{if("string"!=typeof e)return{type:"message",data:y(e,t)};let s=e.charAt(0);return"b"===s?{type:"message",data:g(e.substring(1),t)}:a[s]?e.length>1?{type:a[s],data:e.substring(1)}:{type:a[s]}:i},g=(e,t)=>x?y((e=>{let t=.75*e.length,s=e.length,n,r=0,a,i,o,l;"="===e[e.length-1]&&(t--,"="===e[e.length-2]&&t--);let d=new ArrayBuffer(t),c=new Uint8Array(d);for(n=0;n<s;n+=4)a=p[e.charCodeAt(n)],i=p[e.charCodeAt(n+1)],o=p[e.charCodeAt(n+2)],l=p[e.charCodeAt(n+3)],c[r++]=a<<2|i>>4,c[r++]=(15&i)<<4|o>>2,c[r++]=(3&o)<<6|63&l;return d})(e),t):{base64:!0,data:e},y=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer;function b(e){return e.reduce((e,t)=>e+t.length,0)}function j(e,t){if(e[0].length===t)return e.shift();let s=new Uint8Array(t),n=0;for(let r=0;r<t;r++)s[r]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),s}function v(e){if(e){var t=e;for(var s in v.prototype)t[s]=v.prototype[s];return t}}v.prototype.on=v.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},v.prototype.once=function(e,t){function s(){this.off(e,s),t.apply(this,arguments)}return s.fn=t,this.on(e,s),this},v.prototype.off=v.prototype.removeListener=v.prototype.removeAllListeners=v.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r<n.length;r++)if((s=n[r])===t||s.fn===t){n.splice(r,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},v.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),s=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(s){s=s.slice(0);for(var n=0,r=s.length;n<r;++n)s[n].apply(this,t)}return this},v.prototype.emitReserved=v.prototype.emit,v.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},v.prototype.hasListeners=function(e){return!!this.listeners(e).length};let w="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),k="u">typeof self?self:"u">typeof window?window:Function("return this")();function N(e,...t){return t.reduce((t,s)=>(e.hasOwnProperty(s)&&(t[s]=e[s]),t),{})}let S=k.setTimeout,C=k.clearTimeout;function E(e,t){t.useNativeTimers?(e.setTimeoutFn=S.bind(k),e.clearTimeoutFn=C.bind(k)):(e.setTimeoutFn=k.setTimeout.bind(k),e.clearTimeoutFn=k.clearTimeout.bind(k))}function T(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}
1class A extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class M extends v{constructor(e){super(),this.writable=!1,E(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new A(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return("opening"===this.readyState||"open"===this.readyState)&&(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=f(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return -1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){let t=function(e){let t="";for(let s in e)e.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(e[s]));return t}(e);return t.length?"?"+t:""}}class D extends M{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once("pollComplete",function(){--e||t()})),this.writable||(e++,this.once("drain",function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)};((e,t)=>{let s=e.split("\x1e"),n=[];for(let e=0;e<s.length;e++){let r=f(s[e],t);if(n.push(r),"error"===r.type)break}return n})(e,this.socket.binaryType).forEach(t),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){let e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){var t;let s,n,r;this.writable=!1,t=e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})},n=Array(s=e.length),r=0,e.forEach((e,a)=>{c(e,!1,e=>{n[a]=e,++r===s&&t(n.join("\x1e"))})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=T()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let _=!1;try{_="u">typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}let z=_;function P(){}class O extends D{constructor(e){if(super(e),"u">typeof location){const t="https:"===location.protocol;let s=location.port;s||(s=t?"443":"80"),this.xd="u">typeof location&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){let s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}class L extends v{constructor(e,t,s){super(),this.createRequest=e,E(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=void 0!==s.data?s.data:null,this._create()}_create(){var e;let t=N(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders)for(let e in s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0),this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&s.setRequestHeader(e,this._opts.extraHeaders[e])}catch(e){}if("POST"===this._method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{s.setRequestHeader("Accept","*/*")}catch(e){}null==(e=this._opts.cookieJar)||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var e;3===s.readyState&&(null==(e=this._opts.cookieJar)||e.parseCookies(s.getResponseHeader("set-cookie"))),4===s.readyState&&(200===s.status||1223===s.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof s.status?s.status:0)},0))},s.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}"u">typeof document&&(this._index=L.requestsCount++,L.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=P,e)try{this._xhr.abort()}catch(e){}"u">typeof document&&delete L.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}function I(){for(let e in L.requests)L.requests.hasOwnProperty(e)&&L.requests[e].abort()}L.requestsCount=0,L.requests={},"u">typeof document&&("function"==typeof attachEvent?attachEvent("onunload",I):"function"==typeof addEventListener&&addEventListener("onpagehide"in k?"pagehide":"unload",I,!1));let R=(n=$({xdomain:!1}))&&null!==n.responseType;function $(e){let t=e.xdomain;try{if("u">typeof XMLHttpRequest&&(!t||z))return new XMLHttpRequest}catch(e){}if(!t)try{return new k[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(e){}}let B="u">typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class F extends M{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,s=B?{}:N(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(e){return this.emitReserved("error",e)}
1this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let s=e[t],n=t===e.length-1;c(s,this.supportsBinary,e=>{try{this.doWrite(s,e)}catch(e){}n&&w(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=T()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}let U=k.WebSocket||k.MozWebSocket,H={websocket:class extends F{createSocket(e,t,s){return B?new U(e,t,s):t?new U(e,t):new U(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends M{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{var n,r;let a,u,m,p,x=(n=Number.MAX_SAFE_INTEGER,r=this.socket.binaryType,s||(s=new TextDecoder),a=[],u=0,m=-1,p=!1,new TransformStream({transform(e,t){for(a.push(e);;){if(0===u){if(1>b(a))break;let e=j(a,1);p=(128&e[0])==128,u=(m=127&e[0])<126?3:126===m?1:2}else if(1===u){if(2>b(a))break;let e=j(a,2);m=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),u=3}else if(2===u){if(8>b(a))break;let e=j(a,8),s=new DataView(e.buffer,e.byteOffset,e.length),n=s.getUint32(0);if(n>2097151){t.enqueue(i);break}m=0x100000000*n+s.getUint32(4),u=3}else{if(b(a)<m)break;let e=j(a,m);t.enqueue(f(p?e:s.decode(e),r)),u=0}if(0===m||m>n){t.enqueue(i);break}}}})),g=e.readable.pipeThrough(x).getReader(),y=new TransformStream({transform(e,s){var n;n=t=>{let n,r=t.length;if(r<126)new DataView((n=new Uint8Array(1)).buffer).setUint8(0,r);else if(r<65536){let e=new DataView((n=new Uint8Array(3)).buffer);e.setUint8(0,126),e.setUint16(1,r)}else{let e=new DataView((n=new Uint8Array(9)).buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(n[0]|=128),s.enqueue(n),s.enqueue(t)},o&&e.data instanceof Blob?e.data.arrayBuffer().then(h).then(n):l&&(e.data instanceof ArrayBuffer||d(e.data))?n(h(e.data)):c(e,!1,e=>{t||(t=new TextEncoder),n(t.encode(e))})}});y.readable.pipeTo(e.writable),this._writer=y.writable.getWriter();let v=()=>{g.read().then(({done:e,value:t})=>{e||(this.onPacket(t),v())}).catch(e=>{})};v();let w={type:"open"};this.query.sid&&(w.data=`{"sid":"${this.query.sid}"}`),this._writer.write(w).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let s=e[t],n=t===e.length-1;this._writer.write(s).then(()=>{n&&w(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null==(e=this._transport)||e.close()}},polling:class extends O{constructor(e){super(e);const t=e&&e.forceBase64;
1this.supportsBinary=R&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new L($,this.uri(),e)}}},q=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,K=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function W(e){var t,s;let n,r;if(e.length>8e3)throw"URI too long";let a=e,i=e.indexOf("["),o=e.indexOf("]");-1!=i&&-1!=o&&(e=e.substring(0,i)+e.substring(i,o).replace(/:/g,";")+e.substring(o,e.length));let l=q.exec(e||""),d={},c=14;for(;c--;)d[K[c]]=l[c]||"";return -1!=i&&-1!=o&&(d.source=a,d.host=d.host.substring(1,d.host.length-1).replace(/;/g,":"),d.authority=d.authority.replace("[","").replace("]","").replace(/;/g,":"),d.ipv6uri=!0),n=(t=d.path).replace(/\/{2,9}/g,"/").split("/"),("/"==t.slice(0,1)||0===t.length)&&n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),d.pathNames=n,s=d.query,r={},s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,s){t&&(r[t]=s)}),d.queryKey=r,d}let V="function"==typeof addEventListener&&"function"==typeof removeEventListener,J=[];V&&addEventListener("offline",()=>{J.forEach(e=>e())},!1);class Y extends v{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const s=W(e);t.hostname=s.host,t.secure="https"===s.protocol||"wss"===s.protocol,t.port=s.port,s.query&&(t.query=s.query)}else t.host&&(t.hostname=W(t.host).host);E(this,t),this.secure=null!=t.secure?t.secure:"u">typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("u">typeof location?location.hostname:"localhost"),this.port=t.port||("u">typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},s=e.split("&");for(let e=0,n=s.length;e<n;e++){let n=s[e].split("=");
1t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),V&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},J.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);let e=this.opts.rememberUpgrade&&Y.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",Y.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let t=Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let s=this.writeBuffer[t].data;if(s&&(e+="string"==typeof s?function(e){let t=0,s=0;for(let n=0,r=e.length;n<r;n++)(t=e.charCodeAt(n))<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(n++,s+=4);return s}(s):Math.ceil(1.33*(s.byteLength||s.size))),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,w(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof s&&(n=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;let r={type:e,data:t,options:s};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return("opening"===this.readyState||"open"===this.readyState)&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(Y.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),V&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=J.indexOf(this._offlineEventListener);-1!==e&&J.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}Y.protocol=4;class G extends Y{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),s=!1;Y.priorWebsocketSuccess=!1;let n=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!s)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Y.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{s||"closed"!==this.readyState&&(d(),this.setTransport(t),t.send([{type:"upgrade"}
1]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function r(){s||(s=!0,d(),t.close(),t=null)}let a=e=>{let s=Error("probe error: "+e);s.transport=t.name,r(),this.emitReserved("upgradeError",s)};function i(){a("transport closed")}function o(){a("socket closed")}function l(e){t&&e.name!==t.name&&r()}let d=()=>{t.removeListener("open",n),t.removeListener("error",a),t.removeListener("close",i),this.off("close",o),this.off("upgrading",l)};t.once("open",n),t.once("error",a),t.once("close",i),this.once("close",o),this.once("upgrading",l),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}}class X extends G{constructor(e,t={}){const s="object"==typeof e,n=s?{...e}:{...t};(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>H[e]).filter(e=>!!e)),super(s?n:e,n)}}X.protocol;let Q="function"==typeof ArrayBuffer,Z=Object.prototype.toString,ee="function"==typeof Blob||"u">typeof Blob&&"[object BlobConstructor]"===Z.call(Blob),et="function"==typeof File||"u">typeof File&&"[object FileConstructor]"===Z.call(File);function es(e){return Q&&(e instanceof ArrayBuffer||("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer))||ee&&e instanceof Blob||et&&e instanceof File}let en=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];(eu=eh||(eh={}))[eu.CONNECT=0]="CONNECT",eu[eu.DISCONNECT=1]="DISCONNECT",eu[eu.EVENT=2]="EVENT",eu[eu.ACK=3]="ACK",eu[eu.CONNECT_ERROR=4]="CONNECT_ERROR",eu[eu.BINARY_EVENT=5]="BINARY_EVENT",eu[eu.BINARY_ACK=6]="BINARY_ACK";class er extends v{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},"function"==typeof e?{reviver:e}:e)}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw Error("got plaintext data when reconstructing a packet");let s=(t=this.decodeString(e)).type===eh.BINARY_EVENT;s||t.type===eh.BINARY_ACK?(t.type=s?eh.EVENT:eh.ACK,this.reconstructor=new ea(t)):super.emitReserved("decoded",t)}else if(es(e)||e.base64)if(this.reconstructor)(t=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw Error("got binary data when not reconstructing a packet");else throw Error("Unknown type: "+e)}decodeString(e){let t=0,s={type:Number(e.charAt(0))};if(void 0===eh[s.type])throw Error("unknown packet type "+s.type);if(s.type===eh.BINARY_EVENT||s.type===eh.BINARY_ACK){let n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);let r=e.substring(n,t);if(r!=Number(r)||"-"!==e.charAt(t))throw Error("Illegal attachments");let a=Number(r);if(!ei(a)||a<1)throw Error("Illegal attachments");if(a>this.opts.maxAttachments)throw Error("too many attachments");s.attachments=a}if("/"===e.charAt(t+1)){let n=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);s.nsp=e.substring(n,t)}else s.nsp="/";let n=e.charAt(t+1);if(""!==n&&Number(n)==n){let n=t+1;for(;++t;){let s=e.charAt(t);if(null==s||Number(s)!=s){--t;break}if(t===e.length)break}s.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(er.isPayloadValid(s.type,n))s.data=n;else throw Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case eh.CONNECT:return eo(t);case eh.DISCONNECT:return void 0===t;case eh.CONNECT_ERROR:return"string"==typeof t||eo(t);case eh.EVENT:case eh.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===en.indexOf(t[0]));case eh.ACK:case eh.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ea{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t,s;let e=(t=this.reconPack,s=this.buffers,t.data=function e(t,s){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<s.length)return s[t.num];throw Error("illegal attachments")}if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=e(t[n],s);else if("object"==typeof t)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=e(t[n],s));return t}(t.data,s),delete t.attachments,t);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}let ei=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function eo(e){return"[object Object]"===Object.prototype.toString.call(e)}
1function el(e,t,s){return e.on(t,s),function(){e.off(t,s)}}e.s(["Decoder",0,er,"Encoder",0,class{constructor(e){this.replacer=e}encode(e){return(e.type===eh.EVENT||e.type===eh.ACK)&&function e(t,s){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let s=0,n=t.length;s<n;s++)if(e(t[s]))return!0;return!1}if(es(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1==arguments.length)return e(t.toJSON(),!0);for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e(t[s]))return!0;return!1}(e)?this.encodeAsBinary({type:e.type===eh.EVENT?eh.BINARY_EVENT:eh.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===eh.BINARY_EVENT||e.type===eh.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t,s,n=(t=[],s=e.data,e.data=function e(t,s,n){if(!t)return t;if(es(t)){let e={_placeholder:!0,num:s.length};return s.push(t),e}if(Array.isArray(t)){let n=Array(t.length);for(let r=0;r<t.length;r++)n[r]=e(t[r],s);return n}if("object"==typeof t&&!(t instanceof Date)){if(t.toJSON&&"function"==typeof t.toJSON&&!n)return e(t.toJSON(),s,!0);let r={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=e(t[n],s));return r}return t}(s,t),e.attachments=t.length,{packet:e,buffers:t}),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}},"PacketType",0,eh,"isPacketValid",0,function(e){var t;return"string"==typeof e.nsp&&(void 0===(t=e.id)||ei(t))&&function(e,t){switch(e){case eh.CONNECT:return void 0===t||eo(t);case eh.DISCONNECT:return void 0===t;case eh.EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===en.indexOf(t[0]));case eh.ACK:return Array.isArray(t);case eh.CONNECT_ERROR:return"string"==typeof t||eo(t);default:return!1}}(e.type,e.data)},"protocol",0,5],351890);let ed=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ec extends v{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[el(e,"open",this.onopen.bind(this)),el(e,"packet",this.onpacket.bind(this)),el(e,"error",this.onerror.bind(this)),el(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,n,r;if(ed.hasOwnProperty(e))throw Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let a={type:eh.EVENT,data:t};if(a.options={},a.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){let e=this.ids++,s=t.pop();this._registerAckCallback(e,s),a.id=e}let i=null==(n=null==(s=this.io.engine)?void 0:s.transport)?void 0:n.writable,o=this.connected&&!(null==(r=this.io.engine)?void 0:r._hasPingExpired());return this.flags.volatile&&!i||(o?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(e,t){var s;let n=null!=(s=this.flags.timeout)?s:this._opts.ackTimeout;if(void 0===n){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error("operation has timed out"))},n),a=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...t){return new Promise((s,n)=>{let r=(e,t)=>e?n(e):s(t);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());let s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...n)=>(this._queue[0],null!==e?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),s.pe
1nding=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;let t=this._queue[0];(!t.pending||e)&&(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:eh.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case eh.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case eh.EVENT:case eh.BINARY_EVENT:this.onevent(e);break;case eh.ACK:case eh.BINARY_ACK:this.onack(e);break;case eh.DISCONNECT:this.ondisconnect();break;case eh.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){let t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length)for(let t of this._anyListeners.slice())t.apply(this,e);super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,s=!1;return function(...n){s||(s=!0,t.packet({type:eh.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:eh.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s]){t.splice(s,1);break}}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s]){t.splice(s,1);break}}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length)for(let t of this._anyOutgoingListeners.slice())t.apply(this,e.data)}}var eu,eh,em=e.i(351890);function ep(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}ep.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=(1&Math.floor(10*t))==0?e-s:e+s}return 0|Math.min(e,this.max)},ep.prototype.reset=function(){this.attempts=0},ep.prototype.setMin=function(e){this.ms=e},ep.prototype.setMax=function(e){this.max=e},ep.prototype.setJitter=function(e){this.jitter=e};class ex extends v{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,E(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!=(s=t.randomizationFactor)?s:.5),this.backoff=new ep({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||em;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null==(t=this.backoff)||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null==(t=this.backoff)||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null==(t=this.backoff)||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new X(this.uri,this.opts);let t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;let n=el(t,"open",function(){s.onopen(),e&&e()}),r=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},a=el(t,"error",r);if(!1!==this._timeout){let e=this._timeout,s=this.setTimeoutFn(()=>{n(),r(Error("timeout")),t.close()},e);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}return this.subs.push(n),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;
1this.subs.push(el(e,"ping",this.onping.bind(this)),el(e,"data",this.ondata.bind(this)),el(e,"error",this.onerror.bind(this)),el(e,"close",this.onclose.bind(this)),el(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){w(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new ec(this,e,t),this.nsps[e]=s),s}_destroy(e){for(let e of Object.keys(this.nsps))if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),null==(s=this.engine)||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}let ef={};function eg(e,t){let s;"object"==typeof e&&(t=e,e=void 0);let n=function(e,t="",s){let n=e;s=s||"u">typeof location&&location,null==e&&(e=s.protocol+"//"+s.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?s.protocol+e:s.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==s?s.protocol+"//"+e:"https://"+e),n=W(e)),!n.port&&(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port+t,n.href=n.protocol+"://"+r+(s&&s.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=ef[a]&&i in ef[a].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?s=new ex(r,t):(ef[a]||(ef[a]=new ex(r,t)),s=ef[a]),n.query&&!t.query&&(t.query=n.queryKey),s.socket(n.path,t)}Object.assign(eg,{Manager:ex,Socket:ec,io:eg,connect:eg}),e.s(["io",0,eg],996085)},14358,e=>{"use strict";let t=(0,e.i(456420).default)("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);e.s(["CircleDollarSign",0,t],14358)},15439,e=>{"use strict";var t=e.i(843476),s=e.i(262633),n=e.i(689664),r=e.i(716327),a=e.i(755146),i=e.i(550831);e.s(["EffortSelect",0,function({model:e,value:o,onChange:l,variant:d="pill"}){let c=(0,i.supportedEfforts)(e);if(0===c.length)return null;let u=(0,i.normalizeEffort)(e,o),h="pill"===d?(0,t.jsxs)("button",{type:"button",title:`Thinking level for ${e.name}`,className:"inline-flex shrink-0 items-center gap-1.5 rounded-full border border-foreground
1/25 bg-muted px-3 py-1 text-[13px] font-medium text-foreground transition-all duration-200 active:scale-95",children:[(0,t.jsx)(s.Brain,{className:"size-3.5"}),i.EFFORT_SHORT[u],(0,t.jsx)(r.ChevronDown,{className:"size-3 opacity-60"})]}):(0,t.jsxs)("button",{type:"button",title:`Thinking level for ${e.name}`,onClick:e=>e.stopPropagation(),className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border/70 bg-background px-2 py-0.5 text-[11px] text-muted-foreground transition-all duration-200 hover:text-foreground active:scale-95",children:[(0,t.jsx)(s.Brain,{className:"size-3"}),i.EFFORT_SHORT[u]]});return(0,t.jsxs)(a.DropdownMenu,{children:[(0,t.jsx)(a.DropdownMenuTrigger,{render:h}),(0,t.jsxs)(a.DropdownMenuContent,{align:"start",className:"w-auto min-w-48",children:[(0,t.jsxs)("div",{className:"px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:[e.name," thinking"]}),c.map(e=>(0,t.jsxs)(a.DropdownMenuItem,{onClick:()=>l(e),className:"flex items-center justify-between gap-3",children:[i.EFFORT_LABEL[e],e===u&&(0,t.jsx)(n.Check,{className:"size-3.5"})]},e))]})]})}])},328623,e=>{"use strict";let t=(0,e.i(456420).default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}
1],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);e.s(["Sparkles",0,t],328623)},998936,885227,e=>{"use strict";var t=e.i(271645);async function s(e,t){try{let t=await e.json();if("string"==typeof t.error&&t.error)return Error(t.error)}catch{}return Error(t)}async function n(){let e=await fetch("/api/skills",{cache:"no-store"});if(!e.ok)throw await s(e,"Could not load skills");return await e.json()}async function r(e){let t=new FormData;t.append("file",e);let n=await fetch("/api/skills",{method:"POST",body:t});if(!n.ok)throw await s(n,"Could not add that skill");return(await n.json()).skill}async function a(e,t){let n=await fetch(`/api/skills/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:t})});if(!n.ok)throw await s(n,"Could not change that skill")}async function i(e){let t=await fetch(`/api/skills/${e}`,{method:"DELETE"});if(!t.ok)throw await s(t,"Could not remove that skill")}async function o(e){let t=await fetch(`/api/skills/${e}`,{cache:"no-store"});if(!t.ok)throw await s(t,"Could not open that skill");return await t.json()}async function l(e,t){let n=await fetch(`/api/skills/${e}?path=${encodeURIComponent(t)}`,{cache:"no-store"});if(!n.ok)throw await s(n,"Could not read that file");return await n.json()}async function d(e){let t=await fetch("/api/skills",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:e})});if(!t.ok)throw await s(t,"Could not change that setting")}e.s(["deleteSkillApi",0,i,"fetchSkillDetail",0,o,"fetchSkillFile",0,l,"fetchSkills",0,n,"setSkillEnabledApi",0,a,"setSkillsFeatureEnabledApi",0,d,"skillDownloadUrl",0,function(e){return`/api/skills/${e}/download`},"uploadSkillApi",0,r],885227),e.s(["useSkills",0,function({enabled:e}){let[s,o]=(0,t.useState)([]),[l,c]=(0,t.useState)(""),[u,h]=(0,t.useState)("member"),[m,p]=(0,t.useState)(0),[x,f]=(0,t.useState)(!1),[g,y]=(0,t.useState)(!1),[b,j]=(0,t.useState)(null),[v,w]=(0,t.useState)(0),k=(0,t.useCallback)(()=>w(e=>e+1),[]);async function N(e){let t=await r(e);return o(e=>[t,...e.filter(e=>e.id!==t.id)]),t}async function S(e,t){o(s=>s.map(s=>s.id===e?{...s,enabled:t}:s));try{await a(e,t)}catch(e){throw o(s),e}}async function C(e){f(e);try{await d(e)}catch(e){throw f(x),e}}async function E(e){o(t=>t.filter(t=>t.id!==e));try{await i(e)}catch(e){throw o(s),e}}return(0,t.useEffect)(()=>{if(!e)return;let t=!0;return n().then(e=>
1{t&&(o(e.skills),c(e.you),h(e.role),p(e.enabledMax),f(e.featureEnabled),j(null),y(!0))}).catch(e=>{t&&(j(e instanceof Error?e.message:"Could not load skills"),y(!0))}),()=>{t=!1}},[e,v]),{skills:s,you:l,role:u,enabledMax:m,enabledCount:s.filter(e=>e.enabled).length,featureEnabled:x,setFeatureEnabled:C,loading:e&&!g,error:b,reload:k,upload:N,setEnabled:S,remove:E}}],998936)},856423,e=>{"use strict";let t=(0,e.i(456420).default)("book-open",[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]);e.s(["BookOpen",0,t],856423)},801890,e=>{"use strict";class t extends Error{status;constructor(e,t){super(e),this.status=t,this.name="KnowledgeError"}}async function s(e){let s=await e.json().catch(()=>null);throw new t(s?.error??`Request failed (${e.status})`,e.status)}async function n(){let e=await fetch("/api/knowledge",{cache:"no-store"});e.ok||await s(e);let t=await e.json();return{sources:t.sources,enabled:!0===t.enabled}}async function r(e){let t=await fetch("/api/knowledge",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:e})});t.ok||await s(t)}async function a(e,t={}){let n=new FormData;n.append("file",e);let r=await fetch("/api/knowledge",{method:"POST",body:n,signal:t.signal});return r.ok||await s(r),(await r.json()).sources}async function i(e){let t=await fetch(`/api/knowledge/${e}`,{method:"DELETE"});t.ok||await s(t)}e.s(["KnowledgeError",0,t,"addSource",0,a,"fetchKnowledge",0,n,"removeSourceApi",0,i,"setKnowledgeEnabledApi",0,r])},226091,e=>{"use strict";let t=(0,e.i(456420).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);e.s(["FileText",0,t],226091)},725015,399847,490271,185915,695225,289868,e=>{"use strict";let t={png:{mimes:["image/png"],kind:"image"},jpg:{mimes:["image/jpeg"],kind:"image"},jpeg:{mimes:["image/jpeg"],kind:"image"},gif:{mimes:["image/gif"],kind:"image"},webp:{mimes:["image/webp"],kind:"image"},pdf:{mimes:["application/pdf"],kind:"pdf"},txt:{mimes:["text/plain"],kind:"text"},md:{mimes:["text/markdown","text/plain"],kind:"text"},markdown:{mimes:["text/markdown","text/plain"],kind:"text"},csv:{mimes:["text/csv","text/plain"],kind:"text"},tsv:{mimes:["text/tab-separated-values","text/plain"],kind:"text"},json:{mimes:["application/json","text/plain"],kind:"text"},xml:{mimes:["application/xml","text/xml","text/plain"],kind:"text"},yaml:{mimes:["text/yaml","application/yaml","text/plain"],kind:"text"},yml:{mimes:["text/yaml","application/yaml","text/plain"],kind:"text"},js:{mimes:["text/javascript","application/javascript","text/plain"],kind:"text"},ts:{mimes:["text/plain","application/typescript","video/mp2t"],kind:"text"},py:{mimes:["text/x-python","text/plain"],kind:"text"},html:{mimes:["text/html","text/plain"],kind:"text"},css:{mimes:["text/css","text/plain"],kind:"text"},sql:{mimes:["application/sql","text/plain"],kind:"text"},sh:{mimes:["application/x-sh","text/x-sh","text/plain"],kind:"text"},docx:{mimes:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],kind:"office"},xlsx:{mimes:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],kind:"office"},pptx:{mimes:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],kind:"office"}},s=new Set(["","application/octet-stream"]);function n(e){let t=e.lastIndexOf(".");return t<0||t===e.length-1?"":e.slice(t+1).toLowerCase()}e.s(["MAX_FILES_PER_REQUEST",0,10,"acceptAttribute",0,function(){return Object.keys(t).map(e=>`.${e}`).join(",")},"extensionOf",0,n,"validateFile",0,function(e){if(e.sizeBytes>0x1900000)return{ok:!1,status:413,reason:"File exceeds the 25 MB limit"};let r=n(e.filename),a=t[r];if(!a)return{ok:!1,status:415,reason:`.${r||"?"} files are not supported`};let i=e.mimeType.split(";")[0].trim().toLowerCase();return a.mimes.includes(i)||s.has(i)?{ok:!0,kind:a.kind,extension:r}:{ok:!1,status:415,reason:`Unexpected type "${i}" for a .${r} file`}}],725015);var r=e.i(843476),a=e.i(724983);e.s(["AlertCircle",()=>
1a.default],399847);var a=a,i=e.i(456420);let o=(0,i.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),l=(0,i.default)("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);var d=e.i(693819),c=e.i(226091);let u=(0,i.default)("file-type",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5",key:"qbrxap"}]]);var h=e.i(263676),m=e.i(987968);
1class p extends Error{status;constructor(e,t){super(e),this.status=t,this.name="UploadError"}}async function x(e){let t=await e.json().catch(()=>null);return new p(t?.error??`HTTP ${e.status}`,e.status)}async function f(e){let t=await fetch("/api/uploads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{filename:e.name,mimeType:e.type,sizeBytes:e.size}]})});if(!t.ok)throw await x(t);let s=await t.json(),n=s.attachments?.[0];if(!n)throw new p("Malformed staging response",500);return n}async function g(e,t,s){let n=new FormData;n.append("file",new File([e],t,{type:e.type})),s&&n.append("selection",JSON.stringify(s));let r=await fetch("/api/extract",{method:"POST",body:n});if(!r.ok)throw await x(r);return await r.json()}async function y(e){let t=await fetch(`/api/uploads/${e}/text`,{cache:"no-store"});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`HTTP ${t.status}`)}return await t.json()}function b(e){return`/api/uploads/${e}`}e.s(["UploadError",0,p,"attachmentUrl",0,b,"extractFileApi",0,g,"fetchAttachmentText",0,y,"stageFile",0,f],490271);var j=e.i(271645),v=e.i(689664);let w=(0,i.default)("square-scissors",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"8.5",cy:"8.5",r:"1.5",key:"cn5opk"}],["line",{x1:"9.56066",y1:"9.56066",x2:"12",y2:"12",key:"mksg6j"}],["line",{x1:"17",y1:"17",x2:"14.82",y2:"14.82",key:"1lwi1d"}],["circle",{cx:"8.5",cy:"15.5",r:"1.5",key:"12hfy1"}],["line",{x1:"9.56066",y1:"14.43934",x2:"17",y2:"7",key:"4jyfgs"}]]);var k=e.i(793479);function N(e){return!!e&&!!(e.pages?.trim()||e.slides?.trim()||e.sheet?.trim()||e.range?.trim()||e.lines?.trim())}function S(e,t){if("image"===e)return"none";let s=n(t);return"pdf"===s?"pages":"pptx"===s?"slides":"xlsx"===s?"sheet":"text"===e?"lines":"none"}function C(e,t){return"none"!==S(e,t)}function E(e,t,s){if(!N(s))return"Whole file";let r=S(e,t),a="csv"===n(t)||"tsv"===n(t)?"Rows":"Lines";switch(r){case"pages":return`Pages ${s.pages.trim()}`;case"slides":return`Slides ${s.slides.trim()}`;case"lines":return`${a} ${s.lines.trim()}`;case"sheet":{let e=s.sheet?.trim(),t=s.range?.trim();if(e&&t)return`${e} \xb7 ${t.toUpperCase()}`;if(e)return`Sheet ${e}`;if(t)return`Range ${t.toUpperCase()}`;return"Whole file"}default:return"Whole file"}}function T({kind:e,filename:t,selection:s,onChange:a}
1){let i=S(e,t),[o,l]=(0,j.useState)(!1);if("none"===i)return null;let d=N(s),c=E(e,t,s),u=e=>{let t={...s,...e};for(let e of Object.keys(t))t[e]?.trim()||delete t[e];a(N(t)?t:void 0)};return(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),title:"Choose what the models read",className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] transition-colors ${d?"border-foreground/30 bg-muted font-medium text-foreground":"border-border/60 bg-card text-muted-foreground hover:text-foreground"}`,children:[(0,r.jsx)(w,{className:"size-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:c})]}),o&&(0,r.jsxs)("div",{className:"absolute bottom-full left-0 z-30 mb-1 w-60 rounded-xl border border-border/70 bg-popover p-3 shadow-lg",children:[(0,r.jsx)("p",{className:"mb-2 text-[12px] font-medium text-foreground",children:"What should the models read?"}),"pages"===i&&(0,r.jsx)(A,{label:"Pages",placeholder:"e.g. 73-75 or 1,3,5-8",value:s?.pages??"",onChange:e=>u({pages:e})}),"slides"===i&&(0,r.jsx)(A,{label:"Slides",placeholder:"e.g. 2-3 or 1,4",value:s?.slides??"",onChange:e=>u({slides:e})}),"lines"===i&&(0,r.jsx)(A,{label:"csv"===n(t)||"tsv"===n(t)?"Rows":"Lines",placeholder:"e.g. 1-200",value:s?.lines??"",onChange:e=>u({lines:e})}),"sheet"===i&&(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)(A,{label:"Sheet",placeholder:"name or number (e.g. Q1 or 2)",value:s?.sheet??"",onChange:e=>u({sheet:e})}),(0,r.jsx)(A,{label:"Cell range",placeholder:"e.g. A1:D50 (optional)",value:s?.range??"",onChange:e=>u({range:e})})]}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s&&function(e,t){if("pages"===e||"slides"===e||"lines"===e){let s=function(e){let t=0;for(let{start:s,end:n}of function(e){if(!e)return[];let t=[];for(let s of e.split(",")){let e=s.trim();if(!e)continue;let n=e.match(/^(\d+)\s*(?:[-–]\s*(\d+))?$/);if(!n)continue;let r=Number(n[1]),a=void 0!==n[2]?Number(n[2]):r;Number.isFinite(r)&&Number.isFinite(a)&&(a<r&&([r,a]=[a,r]),t.push({start:r,end:a}))}return t}(e))t+=n-Math.max(1,s)+1;return Math.max(0,t)}("pages"===e?t.pages:"slides"===e?t.slides:t.lines);return s<=0?null:`Reads ~${s} ${"pages"===e?"page":"slides"===e?"slide":"line"}${s>1?"s":""}`}return"sheet"===e?t.range?.trim()?"Reads the selected range":t.sheet?.trim()?"Reads one sheet":"Reads every sheet":null}(i,s)||"Whole file"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[d&&(0,r.jsx)("button",{type:"button",onClick:()=>a(void 0),className:"rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:"Reset"}),(0,r.jsxs)("button",{type:"button",onClick:()=>l(!1),className:"inline-flex items-center gap-1 rounded-md bg-primary px-2 py-0.5 text-[11px] font-medium text-primary-foreground",children:[(0,r.jsx)(v.Check,{className:"size-3"})," Done"]})]})]})]})]})}function A({label:e,placeholder:t,value:s,onChange:n}){return(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"mb-1 block text-[11px] text-muted-foreground",children:e}),(0,r.jsx)(k.Input,{value:s,onChange:e=>n(e.target.value),placeholder:t,className:"h-7 text-[12px]"})]})}let M="files",D=new Map,_=null;function z(){return _||(_=new Promise(e=>{if("u"<typeof indexedDB)return e(null);try{let t=indexedDB.open("multiai-files",1);t.onupgradeneeded=()=>{t.result.objectStoreNames.contains(M)||t.result.createObjectStore(M)},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}}))}function P(e,t){return e.transaction(M,t).objectStore(M)}function O(e){return new Promise(t=>{e.onsuccess=()=>t(e.result),e.onerror=()=>t(null)})}async function L(e,t,s){let n={blob:t,name:s,mime:t.type||"application/octet-stream",addedAt:Date.now()},r=await z();if(r)try{return await O(P(r,"readwrite").put(n,e)),!0}catch{}return D.set(e,n),!1}async function I(e){let t=D.get(e);if(t)return t;let s=await z();if(!s)return null;try{return await O(P(s,"readonly").get(e))??null}catch{return null}}async function R(e){D.delete(e);let t=await z();if(t)try{await O(P(t,"readwrite").delete(e))}catch{}}
1function $(e){let[t,s]=(0,j.useState)(null);return(0,j.useEffect)(()=>{if(!e)return;let t=!0,n=null;return I(e).then(e=>{t&&e&&s(n=URL.createObjectURL(e.blob))}),()=>{t=!1,n&&URL.revokeObjectURL(n),s(null)}},[e]),t}function B(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}e.s(["deleteLocalFile",0,R,"getLocalFile",0,I,"putLocalFile",0,L],185915),e.s(["useLocalFileUrl",0,$],695225);let F=new Set(["xlsx","csv","tsv"]),U=new Set(["js","ts","py","json","html","css","sql","sh","yaml","yml","xml"]);function H({kind:e,filename:t,className:s}){let a=n(t);return"image"===e?(0,r.jsx)(l,{className:s}):"pdf"===e?(0,r.jsx)(u,{className:s}):F.has(a)?(0,r.jsx)(d.FileSpreadsheet,{className:s}):U.has(a)?(0,r.jsx)(o,{className:s}):(0,r.jsx)(c.FileText,{className:s})}function q({children:e,onClick:t,title:s,tone:n="default"}){return(0,r.jsx)("button",{type:"button",onClick:t,title:s,disabled:!t,className:`group/chip relative flex items-center gap-2 rounded-xl border px-2.5 py-1.5 text-left text-[13px] transition-colors ${"error"===n?"border-destructive/40 bg-destructive/5":"border-border/60 bg-card hover:bg-muted/60"} ${t?"cursor-pointer":"cursor-default"}`,children:e})}function K({src:e,kind:t,filename:s}){return e?(0,r.jsx)("img",{src:e,alt:s,className:"size-8 shrink-0 rounded-md object-cover"}):(0,r.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-md bg-muted text-muted-foreground",children:(0,r.jsx)(H,{kind:t,filename:s,className:"size-4"})})}e.s(["MessageChip",0,function({attachment:e,onPreview:t}){let s="image"===e.kind,n=$(s?e.id:void 0),a=e.selection&&C(e.kind,e.filename)?E(e.kind,e.filename,e.selection):null;return(0,r.jsxs)(q,{onClick:()=>t(e),title:e.filename,children:[(0,r.jsx)(K,{src:s?n??b(e.id):void 0,kind:e.kind,filename:e.filename}),(0,r.jsxs)("span",{className:"min-w-0 max-w-[12rem]",children:[(0,r.jsx)("span",{className:"block truncate font-medium",children:e.filename}),(0,r.jsx)("span",{className:"block text-[11px] text-muted-foreground",children:a?`${a} \xb7 ${B(e.sizeBytes)}`:B(e.sizeBytes)})]})]})},"StagedChip",0,function({item:e,onRemove:t,onPreview:s,onSelectionChange:n}){let i="error"===e.status,o="done"===e.status&&e.meta,l="done"===e.status&&e.meta&&C(e.meta.kind,e.name);return(0,r.jsxs)("div",{className:"relative flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(q,{tone:i?"error":"default",onClick:o?()=>s(e.meta):void 0,title:i?e.error:e.name,children:[(0,r.jsx)(K,{src:e.previewUrl,kind:e.isImage?"image":"other",filename:e.name}),(0,r.jsxs)("span",{className:"min-w-0 max-w-[10rem]",children:[(0,r.jsx)("span",{className:"block truncate font-medium",children:e.name}),(0,r.jsx)("span",{className:"block text-[11px] text-muted-foreground",children:i?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-destructive",children:[(0,r.jsx)(a.default,{className:"size-3"})," ",e.error]}):"uploading"===e.status?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(m.Spinner,{className:"size-3"}),Math.round(100*e.progress),"%"]}):B(e.sizeBytes)})]}),"uploading"===e.status&&(0,r.jsx)("span",{className:"absolute inset-x-2.5 bottom-1 h-0.5 overflow-hidden rounded-full bg-muted",children:(0,r.jsx)("span",{className:"block h-full bg-primary/70 transition-[width] duration-200",style:{width:`${Math.max(4,100*e.progress)}%`}})})]}),(0,r.jsx)("button",{type:"button",onClick:t,"aria-label":`Remove ${e.name}`,title:"Remove",className:"absolute -right-1.5 -top-1.5 grid size-5 place-items-center rounded-full border border-border/60 bg-background text-muted-foreground shadow-sm transition-colors hover:text-foreground",children:(0,r.jsx)(h.X,{className:"size-3"})})]}),l&&(0,r.jsx)(T,{kind:e.meta.kind,filename:e.name,selection:e.selection,onChange:n})]})},"formatBytes",0,B],289868)},638292,e=>{"use strict";let t=(0,e.i(456420).default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);e.s(["Mic",0,t],638292)},470533,e=>{"use strict";let t=(0,e.i(456420).default)("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}
1],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);e.s(["Library",0,t],470533)},202764,596973,721132,e=>{"use strict";e.s(["PROMPT_BODY_MAX",0,1e4,"PROMPT_TITLE_MAX",0,120,"canEditPrompt",0,function(e,t,s){return"admin"===s||e.createdByUserId===t},"titleFromBody",0,function(e){let t=e.trim().split("\n",1)[0]?.trim()??"";return t?t.length>120?`${t.slice(0,119)}…`:t:"Untitled prompt"}],202764);var t=e.i(271645);async function s(e){let t=await e.json().catch(()=>null);return Error(t?.error??`HTTP ${e.status}`)}async function n(e){let t=e?`?search=${encodeURIComponent(e)}`:"",n=await fetch(`/api/prompts${t}`,{cache:"no-store"});if(!n.ok)throw await s(n);return await n.json()}async function r(e,t){let n=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,body:t})});if(!n.ok)throw await s(n);return(await n.json()).prompt}async function a(e,t){let n=await fetch(`/api/prompts/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await s(n);return(await n.json()).prompt}async function i(e){let t=await fetch(`/api/prompts/${e}`,{method:"DELETE"});if(!t.ok)throw await s(t)}async function o(e){let t=await fetch("/api/prompts",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})});if(!t.ok)throw await s(t)}e.s(["createPromptApi",0,r,"deletePromptApi",0,i,"fetchPrompts",0,n,"setPromptsEnabledApi",0,o,"updatePromptApi",0,a],596973),e.s(["usePrompts",0,function({enabled:e,search:s=""}){let[l,d]=(0,t.useState)([]),[c,u]=(0,t.useState)(""),[h,m]=(0,t.useState)("member"),[p,x]=(0,t.useState)(!1),[f,g]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[j,v]=(0,t.useState)(null),[w,k]=(0,t.useState)(0),N=(0,t.useCallback)(()=>k(e=>e+1),[]);async function S(e,t){d(s=>s.map(s=>s.id===e?{...s,...t,updatedAt:Date.now()}:s));try{let s=await a(e,t);d(t=>t.map(t=>t.id===e?s:t))}catch(e){throw d(l),e}}async function C(e){d(t=>t.filter(t=>t.id!==e));try{await i(e)}catch(e){throw d(l),e}}async function E(e){x(e);try{await o(e)}catch(e){throw x(p),e}}return(0,t.useEffect)(()=>{if(!e)return;let t=!0,r=s.trim(),a=setTimeout(()=>{b(!0),n(r||void 0).then(e=>{t&&(d(e.prompts),u(e.you),m(e.role),x(e.enabled),v(null),g(!0),b(!1))}).catch(e=>{t&&(v(e instanceof Error?e.message:"Could not load prompts"),g(!0),b(!1))})},200*!!r);return()=>{t=!1,clearTimeout(a)}},[e,s,w]),{prompts:l,you:c,role:h,featureEnabled:p,setFeatureEnabled:E,loading:e&&!f,searching:y&&f,error:j,reload:N,create:async function(e,t){let s=await r(e,t);return d(e=>[s,...e.filter(e=>
1e.id!==s.id)]),s},update:S,remove:C}}],721132)},250832,e=>{"use strict";let t=(0,e.i(456420).default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);e.s(["Settings2",0,t],250832)},439745,e=>{"use strict";let t=(0,e.i(456420).default)("venetian-mask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);e.s(["VenetianMask",0,t],439745)},98072,e=>{"use strict";var t=e.i(271645);async function s(e){let t=await e.json().catch(()=>null);return Error(t?.error??`HTTP ${e.status}`)}async function n(){let e=await fetch("/api/personas",{cache:"no-store"});if(!e.ok)throw await s(e);return await e.json()}async function r(e){let t=await fetch("/api/personas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw await s(t);return(await t.json()).persona}async function a(e,t){let n=await fetch(`/api/personas/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await s(n);return(await n.json()).persona}async function i(e){let t=await fetch(`/api/personas/${e}`,{method:"DELETE"});if(!t.ok)throw await s(t)}async function o(e){let t=await fetch("/api/personas",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})});if(!t.ok)throw await s(t)}e.s(["usePersonas",0,function({enabled:e}){let[s,l]=(0,t.useState)([]),[d,c]=(0,t.useState)(""),[u,h]=(0,t.useState)("member"),[m,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)(!1),[g,y]=(0,t.useState)(null),[b,j]=(0,t.useState)(0),v=(0,t.useCallback)(()=>j(e=>e+1),[]);async function w(e,t){l(s=>s.map(s=>s.id===e?{...s,...t,updatedAt:Date.now()}:s));try{let s=await a(e,t);l(t=>t.map(t=>t.id===e?s:t))}catch(e){throw l(s),e}}async function k(e){p(e);try{await o(e)}catch(e){throw p(m),e}}async function N(e){l(t=>t.filter(t=>t.id!==e));try{await i(e)}catch(e){throw l(s),e}}return(0,t.useEffect)(()=>{if(!e)return;let t=!0;return n().then(e=>{t&&(l(e.personas),c(e.you),h(e.role),p(e.enabled),y(null),f(!0))}).catch(e=>{t&&(y(e instanceof Error?e.message:"Could not load personas"),f(!0))}),()=>{t=!1}},[e,b]),{personas:s,you:d,role:u,featureEnabled:m,setFeatureEnabled:k,loading:e&&!x,error:g,reload:v,create:async function(e){let t=await r(e);return l(e=>[t,...e.filter(e=>e.id!==t.id)]),t},update:w,remove:N}}],98072)},215380,e=>{"use strict";var t=e.i(843476),s=e.i(522016),n=e.i(776639),r=e.i(683341);e.s(["PricingDialog",0,function({open:e,onOpenChange:a}){return(0,t.jsx)(n.Dialog,{open:e,onOpenChange:a,children:(0,t.jsxs)(n.DialogContent,{className:"max-h-[90dvh] overflow-y-auto sm:max-w-[min(84rem,95vw)]",children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:"Upgrade your workspace"}),(0,t.jsx)(n.DialogDescription,{children:"Monthly credits on every plan, refreshed each cycle. 25% off billed yearly. Cancel anytime."})]}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(r.PricingCards,{})}),(0,t.jsxs)("p",{className:"mt-4 text-center text-sm text-muted-foreground",children:["Want the full picture?"," ",(0,t.jsx)(s.default,{href:"/pricing",className:"font-medium text-foreground underline-offset-4 hover:underline",children:"See more on the pricing page →"})]})]})})}])},554160,370812,165489,e=>{"use strict";var t=e.i(886043);let s=0;class n extends Error{constructor(e="out_of_credits"){super(e),this.name="OutOfCreditsError"}}class r extends n{constructor(){super("member_limit_reached"),this.name="MemberLimitError"}}let a=new Set(["no_byok_key","invalid_key","provider_no_funds"]),i="(max-width: 1023px)";e.s(["COMPOSER_MAX_PX",0,240,"DEMO_TEXT",0,"This is a demo response - no provider API key is configured yet. Add OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_GENERATIVE_AI_API_KEY to web/.env.local and restart to stream real models. The interface, live credit metering, and Multi mode all work exactly like this with real responses.","KEY_PROBLEM_CODES",0,a,"MemberLimitError",0,r,"ModelLockedError",0,class extends 
1Error{detail;constructor(e){super("model_requires_upgrade"),this.detail=e,this.name="ModelLockedError"}},"OutOfCreditsError",0,n,"ProviderError",0,class extends Error{payload;constructor(e){super(e.description),this.name="ProviderError",this.payload=e}},"continuedFrom",0,function(e){let t={};for(let s of e)s.continued&&s.groupId&&(t[s.groupId]=s.id);return t},"creditsRefusal",0,function(e){return"member_limit_reached"===(e&&"object"==typeof e?e.error:null)?new r:new n},"debateTurnCosts",0,function(e){let t={},s=0,n=0;for(let r of e){if("user"===r.role){s=0,n=0;continue}void 0!==r.millicredits&&(s+=r.millicredits),n+=1,r.synthesis&&(t[r.id]={millicredits:s,calls:n})}return t},"debatesFor",0,function(e){let t=[],s="",n=null;for(let r of e){if("user"===r.role){s=r.text,n=null;continue}if(!r.debateRound)continue;n||(n={id:r.id,question:s,rounds:[]},t.push(n));let e=n.rounds.find(e=>e.round===r.debateRound);e||(e={round:r.debateRound,messages:[]},n.rounds.push(e)),e.messages.push(r)}return t},"describeToolInput",0,function(e){if(e&&"object"==typeof e){if("string"==typeof e.url)return e.url;if("string"==typeof e.expression)return e.expression;if("string"==typeof e.timeZone)return e.timeZone}return"Running…"},"elideTitle",0,function(e){let t=e.trim().replace(/\s+/g," ");return t?t.length>60?`${t.slice(0,60)}…`:t:"New chat"},"historyFor",0,function(e,t,s){let n=[],r=(e,t)=>{let n=s&&e.authorUserId?s.get(e.authorUserId):void 0;return n?`${n}: ${t}`:t};for(let s=0;s<e.length;s++){let a=e[s];if("user"===a.role||!a.groupId){a.text.trim()&&n.push({role:a.role,content:r(a,a.text)});continue}let i=a.groupId,o=[];for(;s<e.length&&"assistant"===e[s].role&&e[s].groupId===i;)o.push(e[s]),s++;let l=e[s];if(s--,l?.synthesis||l?.debateRound===2)continue;let d=o.find(e=>e.id===t[i])??o[0];d?.text.trim()&&n.push({role:"assistant",content:d.text})}let a=[];for(let e of n){let t=a[a.length-1];t&&t.role===e.role?t.content+=`
2
3${e.content}`:a.push({...e})}return a},"isNarrow",0,function(){return"function"==typeof matchMedia&&matchMedia(i).matches},"nextId",0,()=>`m${++s}`,"readErrorPayload",0,function(e){return e&&"object"==typeof e?"string"!=typeof e.code||"string"!=typeof e.title||"string"!=typeof e.description?null:{code:e.code,title:e.title,description:e.description}:null},"subscribeNarrow",0,function(e){if("function"!=typeof matchMedia)return()=>{};let t=matchMedia(i);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},"toChatMsg",0,function(e){return{id:e.id,role:e.role,text:e.text,authorUserId:e.authorUserId,modelId:e.modelId,groupId:e.groupId,millicredits:e.millicredits,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedInputTokens:e.cachedInputTokens,cacheWriteTokens:e.cacheWriteTokens,ms:e.ms,reasoning:e.reasoning,thinkingMs:e.thinkingMs,demo:e.demo,synthesis:e.synthesis,debateRound:e.debateRound,sourceModelIds:e.sourceModelIds,attachments:e.attachments}},"toMessageInput",0,function(e){return{id:e.id,role:e.role,text:e.text,modelId:e.modelId,groupId:e.groupId,millicredits:e.millicredits,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cachedInputTokens:e.cachedInputTokens,cacheWriteTokens:e.cacheWriteTokens,ms:e.ms,reasoning:e.reasoning,thinkingMs:e.thinkingMs,demo:e.demo,synthesis:e.synthesis,debateRound:e.debateRound,sourceModelIds:e.sourceModelIds,attachmentIds:"user"===e.role?e.attachments?.map(e=>e.id):void 0,attachmentSelections:"user"===e.role?function(e){if(!e?.length)return;let t={};for(let s of e)s.selection&&(t[s.id]=s.selection);return Object.keys(t).length?t:void 0}(e.attachments):void 0,attachmentTexts:"user"===e.role?e.attachmentTexts:void 0}},"toPlanId",0,function(e){return e&&e in t.PLANS?e:"free"}],554160);var o=e.i(456420);let l=(0,o.default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);e.s(["Bell",0,l],370812);let d=(0,o.default)("megaphone",[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]]);e.s(["Megaphone",0,d],165489)},149319,357443,e=>{"use strict";var t=e.i(456420);let s=(0,t.default)("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);e.s(["UserMinus",0,s],149319);let n=(0,t.default)("user-plus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);e.s(["UserPlus",0,n],357443)},392962,996268,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(522016),r=e.i(370812),a=e.i(689664),i=e.i(165489),o=e.i(328623),l=e.i(573474),d=e.i(149319),c=e.i(357443),u=e.i(882303),h=e.i(755146),m=e.i(464987),p=e.i(996085);let x={group_invite:u.Users,workspace_invite:c.UserPlus,invite_accepted:a.Check,removed:d.UserMinus,chat_deleted:l.Trash2,announcement:i.Megaphone},f="multiai.update-seen";e.s(["NotificationBell",0,function({signedIn:e,collapsed:a}){let i,{items:l,unread:d,markRead:c}
3=function(e){let[t,n]=(0,s.useState)([]),[r,a]=(0,s.useState)(0),i=(0,s.useCallback)(()=>{fetch("/api/notifications",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{e&&(n(e.notifications??[]),a(e.unread??0))}).catch(()=>{})},[]);(0,s.useEffect)(()=>{e&&i()},[e,i]),(0,s.useEffect)(()=>{if(!e)return;let t=!1,s=null;return(async()=>{let e=await fetch("/api/realtime/user-token",{method:"POST"}).catch(()=>null);if(!e?.ok||t)return;let{token:r,url:o}=await e.json();if(t)return;(s=(0,p.io)(o,{transports:["websocket"],auth:{token:r}})).on("notify:new",e=>{n(t=>t.some(t=>t.id===e.notification.id)?t:[e.notification,...t]),a(e=>e+1)});let l=!1;s.on("connect",()=>{l&&i(),l=!0}),s.io.on("reconnect_attempt",()=>{fetch("/api/realtime/user-token",{method:"POST"}).then(e=>e.ok?e.json():null).then(e=>{e&&s&&(s.auth={token:e.token})}).catch(()=>{})})})(),()=>{t=!0,s?.disconnect()}},[e,i]);let o=(0,s.useCallback)(()=>{0!==r&&(a(0),n(e=>e.map(e=>({...e,read:!0}))),fetch("/api/notifications",{method:"POST"}).catch(()=>{}))},[r]);return{items:t,unread:r,markRead:o,refresh:i}}(e),[u,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[w,k]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{e&&fetch("/api/app-version",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(!e?.buildId||"dev"===e.buildId)return;let t=null;try{t=JSON.parse(window.localStorage.getItem(f)??"null")}catch{return}let s={build:e.buildId,changelog:e.changelog??null};if(!t?.build){try{window.localStorage.setItem(f,JSON.stringify(s))}catch{}return}t.build!==s.build&&(g(s),b(!!s.changelog&&(!t.changelog||t.changelog<s.changelog)),v(!0),k(!0))}).catch(()=>{})},[e]),!e)return null;let N=d+ +!!w;return(0,t.jsxs)(h.DropdownMenu,{onOpenChange:e=>{if(e&&(c(),w&&u)){try{window.localStorage.setItem(f,JSON.stringify(u))}catch{}k(!1)}},children:[(0,t.jsx)(h.DropdownMenuTrigger,{render:(0,t.jsxs)("button",{type:"button","aria-label":N>0?`Notifications, ${N} unread`:"Notifications",title:"Notifications",className:`relative grid place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90 ${a?"w-full py-2":"size-8 shrink-0"}`,children:[(0,t.jsx)(r.Bell,{className:"size-4"}),N>0&&(0,t.jsx)("span",{"aria-hidden":!0,className:"absolute right-1 top-1 size-2 rounded-full bg-destructive ring-2 ring-sidebar"})]})}),(0,t.jsxs)(h.DropdownMenuContent,{align:"end",side:"top",className:"w-80 p-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-border/60 px-3.5 py-2.5",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Notifications"}),N>0&&(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:[N," new"]})]}),0!==l.length||j?(0,t.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[j&&(i=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Sparkles,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:`block text-sm leading-snug ${w?"font-medium text-foreground":"text-muted-foreground"}`,children:"MultiAI just got updated"}),(0,t.jsx)("span",{className:"mt-0.5 block text-sm leading-snug text-muted-foreground",children:y?"See what is new on the changelog.":"You are on the newest version."})]})]}),y?(0,t.jsx)(n.default,{href:"/changelog",className:"flex items-start gap-2.5 border-b border-border/40 px-3.5 py-2.5 transition-colors last:border-0 hover:bg-muted/50",children:i}):(0,t.jsx)("div",{className:"flex items-start gap-2.5 border-b border-border/40 px-3.5 py-2.5 last:border-0",children:i})),l.map(e=>{let s=x[e.kind]??r.Bell,a=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:`block text-sm leading-snug ${e.read?"text-muted-foreground":"font-medium text-foreground"}`,children:e.title}),e.body&&(0,t.jsx)("span",{className:"mt-0.5 block text-sm leading-snug text-muted-foreground",children:e.body}),(0,t.jsx)("span",{className:"mt-1 block text-sm text-muted-foreground
3/70",children:(0,m.formatRelative)(e.createdAt)})]})]});return e.href?(0,t.jsx)(n.default,{href:e.href,className:"flex items-start gap-2.5 border-b border-border/40 px-3.5 py-2.5 transition-colors last:border-0 hover:bg-muted/50",children:a},e.id):(0,t.jsx)("div",{className:"flex items-start gap-2.5 border-b border-border/40 px-3.5 py-2.5 last:border-0",children:a},e.id)})]}):(0,t.jsx)("p",{className:"px-3.5 py-8 text-center text-sm text-muted-foreground",children:"Nothing yet. Invitations and updates land here."})]})]})}],392962);var g=e.i(846696);e.s(["UpdateWatcher",0,function(){return(0,s.useEffect)(()=>{let e=null,t=!1,s=!1;async function n(){try{let n=await fetch("/api/app-version",{cache:"no-store"});if(!n.ok||s)return;let r=(await n.json()).buildId;if(!r||"dev"===r)return;if(!e){e=r;return}r===e||t||(t=!0,(0,g.toast)("MultiAI has been updated",{id:"app-update",duration:1/0,description:"Refresh to get the newest version.",action:{label:"Refresh",onClick:()=>window.location.reload()}}))}catch{}}n();let r=window.setInterval(()=>void n(),24e4),a=()=>{"visible"===document.visibilityState&&n()};return document.addEventListener("visibilitychange",a),()=>{s=!0,window.clearInterval(r),document.removeEventListener("visibilitychange",a)}},[]),null}],996268)},367784,166794,e=>{"use strict";var t=e.i(456420);let s=(0,t.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",0,s],367784);let n=(0,t.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Settings",0,n],166794)},327085,e=>{"use strict";e.s(["PROJECT_INSTRUCTIONS_MAX",0,4e3,"UNFILED",0,"unfiled"])},987530,631698,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(618566),r=e.i(987968),a=e.i(846696),i=e.i(519455),o=e.i(793479),l=e.i(624687),d=e.i(776639),c=e.i(891913),u=e.i(327085);e.s(["CreateProjectDialog",0,function({open:e,onOpenChange:h,onCreated:m}){let p=(0,n.useRouter)(),[x,f]=(0,s.useState)(""),[g,y]=(0,s.useState)(""),[b,j]=(0,s.useState)(!1);async function v(){let e=x.trim();if(e&&!b){j(!0);try{let t=await (0,c.createFolderApi)(e,g.trim()||void 0);m?.(t),a.toast.success(`Project “${t.name}” created`),p.push(`/p/${t.id}`)}catch(e){j(!1),a.toast.error("Could not create project",{description:e instanceof Error?e.message:"Please try again."})}}}return(0,t.jsx)(d.Dialog,{open:e,onOpenChange:function(e){!b&&(h(e),e||(f(""),y("")))},children:(0,t.jsx)(d.DialogContent,{className:"sm:max-w-md",children:(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),v()},className:"grid gap-4",children:[(0,t.jsx)(d.DialogHeader,{children:(0,t.jsx)(d.DialogTitle,{children:"Create a project"})}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{htmlFor:"new-project-name",className:"text-sm font-medium",children:"What are you working on?"}),(0,t.jsx)(o.Input,{id:"new-project-name",autoFocus:!0,value:x,onChange:e=>f(e.target.value),placeholder:"Name your project",autoComplete:"off",maxLength:80,disabled:b})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)("label",{htmlFor:"new-project-goal",className:"text-sm font-medium",children:"What are you trying to achieve?"}),(0,t.jsx)(l.Textarea,{id:"new-project-goal",value:g,onChange:e=>y(e.target.value),placeholder:"Describe your project, goals, subject, etc.",rows:4,maxLength:u.PROJECT_INSTRUCTIONS_MAX,disabled:b,className:"max-h-40 resize-none overflow-y-auto text-[13px] leading-relaxed"}),(0,t.jsx)("p",{className:"text-[12px] leading-snug text-muted-foreground",children:"This becomes the project’s instructions: every chat inside it starts with this context. You can refine it any time on the project page."})]}),(0,t.jsxs)(d.DialogFooter,{children:[(0,t.jsx)(d.DialogClose,{render:(0,t.jsx)(i.Button,{variant:"ghost",disabled:b}),children:"Cancel"}),(0,t.jsxs)(i.Button,{type:"submit",disabled:!x.trim()||b,children:[b&&(0,t.jsx)(r.Spinner,{}),"Create project"]})]})]})})})}],987530);var h=e.i(154626);function m({className:e}){return(0,t.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e,children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,t.jsx)("line",{x1:"21.17",y1:"8",x2:"12",y2:"8"}),(0,t.jsx)("line",{x1:"3.95",y1:"6.06",x2:"8.54",y2:"14"}),(0,t.jsx)("line",{x1:"10.88",y1:"21.94",x2:"15.46",y2:"14"})]})}e.s(["ExtensionButton",0,function({className:e}){return(0,t.jsx)("a",{href:h.CHROME_STORE_URL,target:"_blank",rel:"noopener noreferrer","aria-label":"Get the Chrome extension",title:"MultiAI for Chrome - open the Chrome Web Store",className:e,children:(0,t.jsx)(m,{className:"size-4"})})}],631698)},726067,e=>{"use strict";let t=(0,e.i(456420).default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}
3]]);e.s(["Folder",0,t],726067)},406930,e=>{"use strict";let t=(0,e.i(456420).default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]);e.s(["ListFilter",0,t],406930)},175748,375775,206029,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(726067),r=e.i(406930),a=e.i(615227),i=e.i(566595),o=e.i(987968),l=e.i(776639),d=e.i(755146),c=e.i(891913),u=e.i(447120);let h=[{key:"latest",label:"Latest"},{key:"created",label:"Latest created"},{key:"working",label:"Working on"}],m=[{key:"1d",label:"Last day",ms:864e5},{key:"7d",label:"Last 7 days",ms:6048e5},{key:"30d",label:"Last 30 days",ms:2592e6}],p=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});function x(e){let t=Math.round((Date.now()-e)/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let s=Math.round(t/60);if(s<24)return`${s}h ago`;let n=Math.round(s/24);return n<7?`${n}d ago`:p.format(e)}e.s(["SearchDialog",0,function({open:e,onOpenChange:p,folders:f,onSelectChat:g}){let[y,b]=(0,s.useState)(""),[j,v]=(0,s.useState)(""),[w,k]=(0,s.useState)("latest"),[N,S]=(0,s.useState)(null),[C,E]=(0,s.useState)(null),[T,A]=(0,s.useState)(!1),[M,D]=(0,s.useState)(!1),_=(0,s.useSyncExternalStore)(u.subscribePreferences,u.getPreferencesSnapshot,u.getPreferencesServerSnapshot),z=(0,s.useMemo)(()=>new Set(_.pinnedChats),[_.pinnedChats]);(0,s.useEffect)(()=>{let e=window.setTimeout(()=>v(y.trim()),250);return()=>window.clearTimeout(e)},[y]),(0,s.useEffect)(()=>{if(!e)return;let t=!0;queueMicrotask(()=>{t&&A(!0)});let s=N?Date.now()-m.find(e=>e.key===N).ms:void 0;return(0,c.fetchChats)({search:j||void 0,from:s}).then(e=>{t&&(E(e),D(!1))}).catch(()=>{t&&D(!0)}).finally(()=>{t&&A(!1)}),()=>{t=!1}},[e,j,N]);let P=(0,s.useMemo)(()=>new Map(f.map(e=>[e.id,e.name])),[f]),O=(0,s.useMemo)(()=>{let e=C??[];return"working"===w&&(e=e.filter(e=>z.has(e.id))),[...e].sort((e,t)=>"created"===w?(t.createdAt??t.updatedAt)-(e.createdAt??e.updatedAt):t.updatedAt-e.updatedAt)},[C,w,z]);function L(e){p(!1),b(""),g(e)}return(0,t.jsx)(l.Dialog,{open:e,onOpenChange:p,children:(0,t.jsxs)(l.DialogContent,{className:"gap-0 overflow-hidden p-0 sm:max-w-xl",children:[(0,t.jsx)(l.DialogTitle,{className:"sr-only",children:"Search chats"}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border/60 px-4 py-3.5",children:[(0,t.jsx)(i.Search,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsx)("input",{autoFocus:!0,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&O[0]&&L(O[0].id)},placeholder:"Search chats…","aria-label":"Search chats",className:"min-w-0 flex-1 bg-transparent text-[15px] outline-none placeholder:text-muted-foreground"}),T&&(0,t.jsx)(o.Spinner,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)(d.DropdownMenu,{children:[(0,t.jsx)(d.DropdownMenuTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":"Search filters",title:"Filters",className:`grid size-8 shrink-0 place-items-center rounded-lg transition-colors duration-150 hover:bg-muted data-popup-open:bg-muted ${"latest"!==w||null!==N?"text-foreground":"text-muted-foreground hover:text-foreground"}`}),children:(0,t.jsx)(r.ListFilter,{className:"size-4"})}),(0,t.jsxs)(d.DropdownMenuContent,{align:"end",className:"w-48 min-w-48",children:[(0,t.jsx)(d.DropdownMenuLabel,{children:"Sort"}),(0,t.jsx)(d.DropdownMenuRadioGroup,{value:w,onValueChange:e=>k(e),children:h.map(e=>(0,t.jsx)(d.DropdownMenuRadioItem,{value:e.key,children:e.label},e.key))}),(0,t.jsx)(d.DropdownMenuSeparator,{}),(0,t.jsx)(d.DropdownMenuLabel,{children:"Time range"}),(0,t.jsxs)(d.DropdownMenuRadioGroup,{value:N??"all",onValueChange:e=>S("all"===e?null:e),children:[(0,t.jsx)(d.DropdownMenuRadioItem,{value:"all",children:"All time"}),m.map(e=>(0,t.jsx)(d.DropdownMenuRadioItem,{value:e.key,children:e.label},e.key))]})]})]})]}),(0,t.jsx)("div",{className:"max-h-80 overflow-y-auto p-1.5",children:M?(0,t.jsx)("p",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:"Search failed. Check your connection and try again."}):0===O.length?(0,t.jsx)("p",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:null===C?"Searching…":"working"===w&&0===z.size?"Nothing pinned yet. Pin a chat and it shows up under Working on.":"No chats match."}):(0,t.jsx)("ul",{children:O.map(e=>{let s=e.folderId?P.get(e.folderId):void 0,r="created"===w&&void 0!==e.createdAt?`created ${x(e.createdAt)}`:x(e.updatedAt);return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>L(e.id),className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-muted/60 focus-visible:bg-muted/60",children:[(0,t.jsx)(a.MessageCircle,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",children:e.title}),s&&(0,t.jsxs)("span",{className:"flex min-w-0 max-w-32 items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)(n.Folder,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s})]}),(0,t.jsx)("span",{suppressHydrationWarning:!0,className:"shrink-0 text-[12px] text-muted-foreground tabular-nums",children:r})]})},e.id)})})})]})})}],175748);var f=e.i(456420);let g=(0,f.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);e.s(["ArrowUpRight",0,g],375775);let y=(0,f.default)("circle-user",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);e.s(["CircleUser",0,y],206029)},826949,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(375775),r=e.i(206029),a=e.i(755146),i=e.i(519455),o=e.i(215380),l=e.i(307730),d=e.i(886043);
3e.s(["CreditsBar",0,function({remaining:e,total:c,plan:u,fullWidth:h,compact:m,onOpenSettings:p}){let x=d.PLANS[u],f=function(e,t=600){let[n,r]=(0,s.useState)(e),a=(0,s.useRef)(void 0),i=(0,s.useRef)(e),o=(0,s.useRef)(!0);return(0,s.useEffect)(()=>{if(o.current){o.current=!1,i.current=e,r(e);return}if(e===i.current)return;let s=i.current;if(i.current=e,e>s)return void r(e);let n=performance.now(),l=s-e,d=e=>{let i=Math.min(1,(e-n)/t);r(s-l*(1-Math.pow(1-i,3))),i<1&&(a.current=requestAnimationFrame(d))};return a.current=requestAnimationFrame(d),()=>{void 0!==a.current&&cancelAnimationFrame(a.current)}},[e,t]),n}(e),g=c>0?Math.max(0,Math.min(100,e/c*100)):0,y=g<=20,b=e<=0,[j,v]=(0,s.useState)(!1),w=m?(0,t.jsx)("button",{type:"button",title:`Account - ${(0,l.formatWholeCredits)(e)} credits left`,"aria-label":"Account",className:"grid w-full place-items-center rounded-lg py-2 transition-all duration-200 hover:bg-muted active:scale-90",children:(0,t.jsx)(r.CircleUser,{className:`size-4 ${b?"text-red-500":y?"text-amber-600":"text-muted-foreground"}`})}):(0,t.jsxs)("button",{type:"button",title:`Account - ${(0,l.formatWholeCredits)(e)} credits left on ${x.name}`,className:`inline-flex items-center gap-2 rounded-full border border-border/70 bg-card px-3 py-1.5 text-[13px] transition-all duration-200 hover:shadow-[0_2px_8px_rgba(0,0,0,0.08)] active:scale-[0.98] ${h?"w-full":"shrink-0"}`,children:[(0,t.jsx)(r.CircleUser,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:`${h?"flex-1 text-left":""} ${y?"font-medium text-foreground":"text-muted-foreground"}`,children:"Account"}),(y||b)&&(0,t.jsx)("span",{"aria-hidden":!0,title:`${(0,l.formatWholeCredits)(e)} credits left`,className:`size-1.5 shrink-0 rounded-full ${b?"bg-red-500":"bg-amber-500"}`}),(0,t.jsx)("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:x.name})]});return(0,t.jsxs)(a.DropdownMenu,{children:[(0,t.jsx)(a.DropdownMenuTrigger,{render:w}),(0,t.jsxs)(a.DropdownMenuContent,{align:"start",side:"top",className:"w-auto min-w-64 p-3",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Credits"}),(0,t.jsxs)("span",{className:"font-mono text-sm",children:[(0,l.formatWholeCredits)(f),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" / ",(0,l.formatWholeCredits)(c)]})]})]}),(0,t.jsx)("span",{className:"mt-2 block h-2 overflow-hidden rounded-full bg-muted",children:(0,t.jsx)("span",{className:`block h-full rounded-full transition-all duration-500 ease-out ${b?"bg-red-500":y?"bg-amber-500":"bg-primary"}`,style:{width:`${g}%`}})}),(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-4 border-t border-border/60 pt-3 text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Plan"}),(0,t.jsx)("span",{className:"font-medium",children:x.name})]}),x.note&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:x.note}),x.subscription&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[x.credits.toLocaleString()," credits refresh each billing cycle."]}),p&&(0,t.jsxs)("button",{type:"button",onClick:()=>p("usage"),className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border/60 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:["View usage",(0,t.jsx)(n.ArrowUpRight,{className:"size-3"})]}),(0,d.canUpgrade)(u)?(0,t.jsxs)(i.Button,{className:"mt-3 w-full rounded-full",size:"sm",onClick:()=>v(!0),children:["Upgrade",(0,t.jsx)(n.ArrowUpRight,{className:"size-3.5"})]}):(0,t.jsx)(i.Button,{className:"mt-3 w-full rounded-full",size:"sm",variant:"outline",onClick:()=>p?.("billing"),disabled:!p,children:"Billing"})]}),(0,t.jsx)(o.PricingDialog,{open:j,onOpenChange:v})]})}],826949)},652671,648119,751898,600505,341987,e=>{"use strict";var t=e.i(456420);let s=(0,t.default)("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);
3e.s(["FolderInput",0,s],652671);let n=(0,t.default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);e.s(["MoreHorizontal",0,n],648119);let r=(0,t.default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);e.s(["Pin",0,r],751898);let a=(0,t.default)("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);e.s(["PinOff",0,a],600505);let i=(0,t.default)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);e.s(["Share2",0,i],341987)},235149,e=>{"use strict";e.s(["titleForSentence",0,function(e,t="this chat"){let s=(e??"").trim();if(!s)return t;let n=s.replace(/[?!.,;:\s]+$/u,"");if(!n)return t;if(n.length<=60)return n;let r=n.slice(0,60),a=r.lastIndexOf(" ");return`${a>36?r.slice(0,a):r}…`}])},795230,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(882303);e.s(["RoomDeleteNotice",0,function({chatId:e,live:r=!1}){let[a,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(r);return((0,s.useEffect)(()=>{let t=!0;return fetch(`/api/chats/${e}/participants`,{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{t&&e&&(i((e.participants??[]).filter(e=>!e.leftAt).length),"boolean"==typeof e.session?.live&&l(e.session.live))}).catch(()=>{}),()=>{t=!1}},[e]),null===a||a<2)?null:(0,t.jsxs)("div",{className:"flex gap-2.5 rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm",children:[(0,t.jsx)(n.Users,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:o?`This room is live, with ${a} people in it`:`${a} people are in this room`}),(0,t.jsx)("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:"Deleting it removes the conversation for all of them, not just for you, and each one is told that it is gone."})]})]})}])},660143,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(689664),r=e.i(762368),a=e.i(726067),i=e.i(652671),o=e.i(615227),l=e.i(648119),d=e.i(515281),c=e.i(751898),u=e.i(600505),h=e.i(77071),m=e.i(920851),p=e.i(395925),x=e.i(341987),f=e.i(573474),g=e.i(882303),y=e.i(263676),b=e.i(519455),j=e.i(235149),v=e.i(776639),w=e.i(795230),k=e.i(755146),N=e.i(472607);function S({chat:e,active:s,folders:o,projectName:h,pinned:p,onSelect:b,onStartRename:j,onRequestDelete:v,onMove:w,onTogglePin:C,onShareChat:E,downloadable:T}){let A=o.length>0,M=void 0!==C;return(0,t.jsxs)("li",{className:"group/chat relative",children:[(0,t.jsx)("button",{type:"button",onClick:b,"data-row-active":s?"":void 0,className:`relative w-full rounded-lg py-2 pl-2.5 text-left text-[13px] transition-all duration-200 ${M?"pr-14":"pr-8"} ${s?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"}`,title:(e.shared?`${e.title} (live session)`:e.title)+(e.extension?" (started in the Chrome extension)":"")+(h?` \xb7 ${h}`:""),children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[e.group&&(0,t.jsx)(g.Users,{"aria-label":"Group chat",className:"size-3.5 shrink-0"}),e.extension&&(0,t.jsx)(m.Puzzle,{"aria-label":"Started in the Chrome extension",className:"size-3.5 shrink-0"}),e.shared&&(0,t.jsx)("span",{"aria-label":"Live session",className:"size-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[e.title,h&&(0,t.jsx)("span",{className:"ml-1.5 text-[11px] font-normal text-muted-foreground",children:h})]})]})}),(0,t.jsxs)("div",{className:"absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5 opacity-0 transition-opacity duration-150 focus-within:opacity-100 group-hover/chat:opacity-100 has-[[data-popup-open]]:opacity-100",children:[M&&(0,t.jsx)("button",{type:"button",onClick:()=>C(e.id),"aria-label":p?`Unpin ${e.title}
3`:`Pin ${e.title}`,title:p?"Unpin":"Pin",className:"grid size-6 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-background hover:text-foreground",children:p?(0,t.jsx)(u.PinOff,{className:"size-3.5"}):(0,t.jsx)(c.Pin,{className:"size-3.5"})}),(0,t.jsxs)(k.DropdownMenu,{children:[(0,t.jsx)(k.DropdownMenuTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":`Chat actions for ${e.title}`,title:"Chat actions",className:"grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-background hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 data-popup-open:bg-background data-popup-open:text-foreground"}),children:(0,t.jsx)(l.MoreHorizontal,{className:"size-3.5"})}),(0,t.jsxs)(k.DropdownMenuContent,{side:"right",align:"start",sideOffset:8,className:"w-56 min-w-56 rounded-2xl p-1.5",children:[E&&(0,t.jsxs)(k.DropdownMenuItem,{onClick:()=>E(e.id),className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(x.Share2,{className:"size-3.5"}),"Share"]}),T&&(0,t.jsxs)(k.DropdownMenuSub,{children:[(0,t.jsxs)(k.DropdownMenuSubTrigger,{className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(r.Download,{className:"size-3.5"}),"Download"]}),(0,t.jsx)(k.DropdownMenuSubContent,{className:"w-auto min-w-40 rounded-2xl p-1.5",children:N.TRANSCRIPT_FORMATS.map(s=>(0,t.jsx)(k.DropdownMenuItem,{onClick:()=>void(0,N.downloadChatById)(e.id,e.title,s.format),className:"rounded-lg px-2.5 py-2",children:s.label},s.format))})]}),(0,t.jsxs)(k.DropdownMenuItem,{onClick:j,className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(d.Pencil,{className:"size-3.5"}),"Rename"]}),A&&(0,t.jsxs)(k.DropdownMenuSub,{children:[(0,t.jsxs)(k.DropdownMenuSubTrigger,{className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(i.FolderInput,{className:"size-3.5"}),e.folderId&&h?`Move from ${h}`:"Move to project"]}),(0,t.jsxs)(k.DropdownMenuSubContent,{className:"w-52 min-w-52 rounded-2xl p-1.5",children:[o.map(s=>(0,t.jsxs)(k.DropdownMenuItem,{onClick:()=>{s.id!==e.folderId&&w(e.id,s.id)},className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(a.Folder,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:s.name}),s.id===e.folderId&&(0,t.jsx)(n.Check,{className:"size-3.5 shrink-0"})]},s.id)),e.folderId&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(k.DropdownMenuSeparator,{}),(0,t.jsxs)(k.DropdownMenuItem,{onClick:()=>w(e.id,null),className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(y.X,{className:"size-3.5"}),"Remove from project"]})]})]})]}),M&&(0,t.jsxs)(k.DropdownMenuItem,{onClick:()=>C(e.id),className:"gap-2.5 rounded-lg px-2.5 py-2",children:[p?(0,t.jsx)(u.PinOff,{className:"size-3.5"}):(0,t.jsx)(c.Pin,{className:"size-3.5"}),p?"Unpin chat":"Pin chat"]}),(0,t.jsx)(k.DropdownMenuSeparator,{}),(0,t.jsxs)(k.DropdownMenuItem,{variant:"destructive",onClick:v,className:"gap-2.5 rounded-lg px-2.5 py-2",children:[(0,t.jsx)(f.Trash2,{className:"size-3.5"}),"Delete"]})]})]})]})]})}function C({value:e,onChange:s,onCommit:r,onCancel:a,label:i,placeholder:o}){return(0,t.jsxs)("div",{className:"flex items-center gap-1 px-1 py-0.5",children:[(0,t.jsx)("input",{autoFocus:!0,value:e,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r()):"Escape"===e.key&&(e.preventDefault(),a())},onBlur:r,"aria-label":i,placeholder:o,className:"min-w-0 flex-1 rounded-md border border-foreground
3/30 bg-card px-2 py-1 text-[13px] outline-none"}),(0,t.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:r,"aria-label":"Save",className:"grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(n.Check,{className:"size-3.5"})}),(0,t.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:a,"aria-label":"Cancel",className:"grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(y.X,{className:"size-3.5"})})]})}function E({icon:e,title:s,action:n,onAction:r}){return(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-center gap-2 px-2 text-center",children:[(0,t.jsx)("span",{className:"grid size-10 place-items-center rounded-xl border border-border/60 bg-muted/40 text-muted-foreground",children:(0,t.jsx)(e,{className:"size-4"})}),(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground",children:s}),(0,t.jsxs)("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1.5 text-[13px] text-foreground underline-offset-4 transition-colors hover:underline",children:[(0,t.jsx)(h.Plus,{className:"size-3.5"}),n]})]})}e.s(["ChatList",0,function({chats:e,folders:n,activeChatId:r,foldersEnabled:a,search:i,filterCount:l,onClearFilters:d,loading:c,error:u,onRetry:h,onSelectChat:m,onRenameChat:x,onDeleteChat:f,onNewChat:g,onMoveChat:k,pinnedIds:N,onTogglePin:T,onShareChat:A,downloadable:M}){let[D,_]=(0,s.useState)(null),[z,P]=(0,s.useState)(""),[O,L]=(0,s.useState)(null);function I(){if(!D)return;let t=z.trim();_(null);let s=e.find(e=>e.id===D);t&&s&&t!==s.title&&x(D,t)}let R=l>0||i.trim().length>0,$=new Map(n.map(e=>[e.id,e.name])),B=N instanceof Set?N:new Set(N??[]),F=e.filter(e=>B.has(e.id)).sort((e,t)=>t.updatedAt-e.updatedAt),U=e.filter(e=>!B.has(e.id)),H=e=>D===e.id?(0,t.jsx)(C,{value:z,onChange:P,onCommit:I,onCancel:()=>_(null),label:"Rename chat"},e.id):(0,t.jsx)(S,{chat:e,active:e.id===r,folders:a?n:[],projectName:a&&e.folderId?$.get(e.folderId):void 0,pinned:B.has(e.id),onSelect:()=>m(e.id),onStartRename:()=>{_(e.id),P(e.title)},onRequestDelete:()=>L(e),onMove:k,onTogglePin:T,onShareChat:A,downloadable:M},e.id);return(0,t.jsxs)(t.Fragment,{children:[u&&(0,t.jsxs)("div",{className:"mb-2 flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-2 py-1.5 text-[12px] text-destructive",children:[(0,t.jsx)("span",{className:"min-w-0 flex-1",children:u}),(0,t.jsxs)("button",{type:"button",onClick:h,className:"flex shrink-0 items-center gap-1 font-medium underline-offset-2 hover:underline",children:[(0,t.jsx)(p.RotateCcw,{className:"size-3"}),"Retry"]})]}),F.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"px-2 pb-1 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Pinned"}),(0,t.jsx)("ul",{className:"mb-1 space-y-0.5",children:F.map(e=>H(e))})]}),(0,t.jsx)("p",{className:"px-2 pb-1 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:R?"Results":"Recents"}),c&&0===e.length?(0,t.jsx)("ul",{className:"space-y-1 px-1","aria-hidden":!0,children:[0,1,2,3].map(e=>(0,t.jsx)("li",{className:"h-7 animate-pulse rounded-lg bg-muted/60",style:{animationDelay:`${80*e}ms`}},e))}):0===U.length?e.length>0?(0,t.jsx)("p",{className:"px-2 pb-2 text-[12px] text-muted-foreground",children:"Everything here is pinned."}):l>0?(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-center gap-2 px-2 text-center",children:[(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"No chats match these filters."}),(0,t.jsxs)("button",{type:"button",onClick:d,className:"inline-flex items-center gap-1.5 text-[13px] text-foreground underline-offset-4 transition-colors hover:underline",children:[(0,t.jsx)(y.X,{className:"size-3.5"}),i.trim()?"Clear search and filters":"Clear filters"]})]}):i.trim()?(0,t.jsxs)("p",{className:"mt-6 px-2 text-center text-[13px] text-muted-foreground",children:["No chats match “",i.trim(),"”."]}):(0,t.jsx)(E,{icon:o.MessageCircle,title:"No chats yet",action:"Start a chat",onAction:g}):(0,t.jsx)("ul",{className:"space-y-0.5",children:U.map(e=>H(e))}),(0,t.jsx)(v.Dialog,{open:null!==O,onOpenChange:e=>{e||L(null)},children:(0,t.jsxs)(v.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(v.DialogHeader,{children:[(0,t.jsx)(v.DialogTitle,{children:"Delete this chat?"}),(0,t.jsxs)(v.DialogDescription,{children:["“",(0,j.titleForSentence)(O?.title),"” and its messages go with it. This cannot be undone."]})]}),O&&(O.shared||O.group)&&(0,t.jsx)(w.RoomDeleteNotice,{chatId:O.id,live:O.shared}),(0,t.jsxs)(v.DialogFooter,{children:[(0,t.jsx)(v.DialogClose,{render:(0,t.jsx)(b.Button,{variant:"outline"}),children:"Cancel"}),(0,t.jsx)(b.Button,{variant:"destructive",onClick:()=>
3{O&&(L(null),f(O.id))},children:"Delete chat"})]})]})})]})}])},317081,e=>{"use strict";var t=e.i(843476),s=e.i(406930),n=e.i(263676),r=e.i(755146),a=e.i(435998);let i={modelId:null,memberId:null,range:"all"},o=[{value:"all",label:"All time"},{value:"today",label:"Today"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function l(e){return+!!e.modelId+ +!!e.memberId+ +("all"!==e.range)}function d(e){return e.name?.trim()||e.email}function c({label:e,onRemove:s}){return(0,t.jsxs)("span",{className:"flex max-w-full items-center gap-1 rounded-md border border-border/60 bg-card py-0.5 pl-1.5 pr-1 text-[11px] text-foreground",children:[(0,t.jsx)("span",{className:"truncate",children:e}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":`Remove filter ${e}`,title:"Remove filter",className:"grid size-4 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(n.X,{className:"size-3"})})]})}e.s(["ActiveFilterChips",0,function({filters:e,onChange:s,members:n}){let r=l(e);if(0===r)return null;let u=e.memberId?n.find(t=>t.userId===e.memberId):void 0;return(0,t.jsxs)("div",{className:"mb-2 flex shrink-0 flex-wrap items-center gap-1",children:[e.modelId&&(0,t.jsx)(c,{label:(0,a.getModel)(e.modelId)?.name??e.modelId,onRemove:()=>s({...e,modelId:null})}),e.memberId&&(0,t.jsx)(c,{label:u?d(u):"Teammate",onRemove:()=>s({...e,memberId:null})}),"all"!==e.range&&(0,t.jsx)(c,{label:o.find(t=>t.value===e.range).label,onRemove:()=>s({...e,range:"all"})}),r>1&&(0,t.jsx)("button",{type:"button",onClick:()=>s(i),className:"rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground underline-offset-2 transition-colors hover:text-foreground hover:underline",children:"Clear all"})]})},"ChatFilterMenu",0,function({filters:e,onChange:c,members:u,pill:h=!1}){let m=l(e),p=u.length>1,x=(0,a.visibleModels)();return(0,t.jsxs)(r.DropdownMenu,{children:[(0,t.jsxs)(r.DropdownMenuTrigger,{render:(0,t.jsx)("button",{type:"button","aria-label":m?`Filters, ${m} active`:"Filter chats",title:"Filter chats",className:`flex shrink-0 items-center outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-ring/50 data-popup-open:bg-muted ${h?"h-8 gap-1.5 rounded-full border px-3 text-[12.5px]":"h-[30px] gap-1 rounded-lg border px-2 text-[12px]"}
3 ${m?"border-foreground/30 bg-muted font-medium text-foreground":"border-border/60 bg-card text-muted-foreground hover:text-foreground"}`}),children:[(0,t.jsx)(s.ListFilter,{className:"size-3.5"}),h&&(0,t.jsx)("span",{className:"hidden sm:inline",children:"Filters"}),m>0&&(0,t.jsx)("span",{className:"tabular-nums",children:m})]}),(0,t.jsxs)(r.DropdownMenuContent,{align:"end",side:"bottom",className:"w-60 min-w-60",children:[(0,t.jsxs)(r.DropdownMenuRadioGroup,{value:e.modelId??"",onValueChange:t=>c({...e,modelId:t||null}),children:[(0,t.jsx)(r.DropdownMenuLabel,{children:"Model"}),(0,t.jsx)(r.DropdownMenuRadioItem,{value:"",children:"Any model"}),x.map(e=>(0,t.jsx)(r.DropdownMenuRadioItem,{value:e.id,children:(0,t.jsx)("span",{className:"truncate",children:e.name})},e.id))]}),p&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.DropdownMenuSeparator,{}),(0,t.jsxs)(r.DropdownMenuRadioGroup,{value:e.memberId??"",onValueChange:t=>c({...e,memberId:t||null}),children:[(0,t.jsx)(r.DropdownMenuLabel,{children:"Asked by"}),(0,t.jsx)(r.DropdownMenuRadioItem,{value:"",children:"Anyone"}),u.map(e=>(0,t.jsx)(r.DropdownMenuRadioItem,{value:e.userId,children:(0,t.jsx)("span",{className:"truncate",children:d(e)})},e.userId))]})]}),(0,t.jsx)(r.DropdownMenuSeparator,{}),(0,t.jsxs)(r.DropdownMenuRadioGroup,{value:e.range,onValueChange:t=>c({...e,range:t}),children:[(0,t.jsx)(r.DropdownMenuLabel,{children:"Last activity"}),o.map(e=>(0,t.jsx)(r.DropdownMenuRadioItem,{value:e.value,children:e.label},e.value))]}),(0,t.jsx)(r.DropdownMenuSeparator,{}),(0,t.jsxs)(r.DropdownMenuItem,{disabled:0===m,onClick:()=>c(i),className:"gap-2",children:[(0,t.jsx)(n.X,{className:"size-3.5"}),"Clear filters"]})]})]})},"NO_FILTERS",0,i,"activeFilterCount",0,l,"rangeBounds",0,function(e){if("all"===e)return{};if("today"===e){let e=new Date;return e.setHours(0,0,0,0),{from:e.getTime()}}return{from:Date.now()-("7d"===e?7:30)*864e5}}])},441732,146387,108774,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(522016),r=e.i(554160),a=e.i(974594),i=e.i(618566),o=e.i(392962),l=e.i(996268),d=e.i(112234),c=e.i(142757),u=e.i(367784),h=e.i(615227),m=e.i(77071),p=e.i(566595),x=e.i(166794),f=e.i(987530),g=e.i(631698),y=e.i(596839),b=e.i(175748),j=e.i(826949),v=e.i(660143),w=e.i(317081);function k({className:e="size-[21px]",flip:s}){return(0,t.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:`${e} ${s?"-scale-x-100":""}`,children:[(0,t.jsx)("rect",{x:"3.25",y:"3.75",width:"17.5",height:"16.5",rx:"4.5"}),(0,t.jsx)("line",{x1:"14.75",y1:"3.75",x2:"14.75",y2:"20.25"})]})}var N=e.i(456420);let S=(0,N.default)("building-2",[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]]);e.s(["Building2",0,S],146387);var C=e.i(689664);let E=(0,N.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),T=(0,N.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);var A=e.i(987968),M=e.i(846696),D=e.i(755146);async function _(e){let t=await e.json().catch(()=>null);return Error(t?.error??`HTTP ${e.status}`)}async function z(){let e=await fetch("/api/workspaces/members",{cache:"no-store"});if(!e.ok)throw await _(e);return await e.json()}async function P(e,t){let s=await fetch("/api/workspaces/invites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,role:t})});if(!s.ok)throw await _(s);return await s.json()}async function O(e){let t=await fetch("/api/workspaces/invites",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({inviteId:e})});if(!t.ok)throw await _(t);return(await t.json()).invites}
3async function L(e,t){let s=await fetch("/api/workspaces/members",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,role:t})});if(!s.ok)throw await _(s)}async function I(e,t){let s=await fetch("/api/workspaces/members",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,creditLimitMillicredits:t})});if(!s.ok)throw await _(s)}async function R(e){let t=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultMemberCreditLimitMillicredits:e})});if(!t.ok)throw await _(t)}async function $(e){let t=await fetch("/api/workspaces/members",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{userId:e}:{})});if(!t.ok)throw await _(t)}async function B(e){let t=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw await _(t)}async function F(e){let t=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({liveSessionPolicy:e})});if(!t.ok)throw await _(t)}async function U(){let e=await fetch("/api/workspaces/switch",{cache:"no-store"});if(!e.ok)throw await _(e);return await e.json()}async function H(e){let t=await fetch("/api/workspaces/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:e})});if(!t.ok)throw await _(t)}function q(e){return e.owner?"Personal":"admin"===e.role?"Team · Admin":"Team · Member"}function K({workspaces:e,activeId:n}
3){let[r,a]=(0,s.useState)(!1),[i,o]=(0,s.useState)(e),[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(null),[h,m]=(0,s.useState)(null),p=i.find(e=>e.id===n);function x(){d(!0),u(null),(async()=>{try{let e=await U();o(e.workspaces)}catch(e){u(e instanceof Error?e.message:"Could not load workspaces")}finally{d(!1)}})()}function f(e){e.id===n?a(!1):h||(m(e.id),(async()=>{try{await H(e.id),window.location.assign("/")}catch(e){m(null),M.toast.error("Could not switch workspace",{description:e instanceof Error?e.message:"Please try again."})}})())}let g=i.filter(e=>e.owner),y=i.filter(e=>!e.owner);return(0,t.jsxs)(D.DropdownMenu,{open:r,onOpenChange:function(e){a(e),e&&!h&&x()},children:[(0,t.jsxs)(D.DropdownMenuTrigger,{render:(0,t.jsx)("button",{type:"button",title:p?`${p.name} \xb7 ${q(p)}`:"Switch workspace","aria-label":"Switch workspace",className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-1.5 py-1 text-left outline-none transition-colors duration-200 hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/50 data-popup-open:bg-muted"}),children:[(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate text-[13px] font-semibold leading-tight tracking-tight",children:p?.name??"Workspace"}),(0,t.jsx)("span",{className:"block truncate text-[11px] leading-tight text-muted-foreground",children:p?q(p):"Switch"})]}),(0,t.jsx)(E,{className:"size-3.5 shrink-0 text-muted-foreground"})]}),(0,t.jsxs)(D.DropdownMenuContent,{align:"start",side:"bottom",className:"w-64 min-w-64",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1.5 py-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Workspace"}),l&&(0,t.jsx)(A.Spinner,{className:"size-3 shrink-0 text-muted-foreground"})]}),g.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D.DropdownMenuSeparator,{}),(0,t.jsxs)(D.DropdownMenuGroup,{children:[y.length>0&&(0,t.jsx)(D.DropdownMenuLabel,{children:"Personal"}),g.map(e=>(0,t.jsx)(W,{ws:e,active:e.id===n,switching:h===e.id,disabled:null!==h&&h!==e.id,onSelect:()=>f(e)},e.id))]})]}),y.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D.DropdownMenuSeparator,{}),(0,t.jsxs)(D.DropdownMenuGroup,{children:[(0,t.jsx)(D.DropdownMenuLabel,{children:"Teams"}),y.map(e=>(0,t.jsx)(W,{ws:e,active:e.id===n,switching:h===e.id,disabled:null!==h&&h!==e.id,onSelect:()=>f(e)},e.id))]})]}),c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D.DropdownMenuSeparator,{}),(0,t.jsxs)("div",{className:"px-1.5 py-1",children:[(0,t.jsx)("p",{className:"text-xs text-destructive",children:c}),(0,t.jsx)("button",{type:"button",onClick:x,disabled:l,className:"mt-1 text-xs font-medium text-foreground underline-offset-4 transition-opacity hover:underline disabled:opacity-50",children:"Try again"})]})]})]})]})}function W({ws:e,active:s,switching:n,disabled:r,onSelect:a}){let i=e.owner?T:S;return(0,t.jsxs)(D.DropdownMenuItem,{closeOnClick:!1,disabled:r,onClick:a,className:"gap-2 py-1.5",children:[(0,t.jsx)(i,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate text-sm leading-tight",children:e.name}),(0,t.jsx)("span",{className:"block truncate text-[11px] leading-tight text-muted-foreground",children:q(e)})]}),n?(0,t.jsx)(A.Spinner,{className:"size-3.5 shrink-0"}):s?(0,t.jsx)(C.Check,{className:"size-3.5 shrink-0"}):null]})}function V(e,t,s=!1){return`flex w-full items-center rounded-xl transition-all duration-200 active:scale-[0.99] ${s?"text-[15px]":"text-sm"} ${t?"justify-center py-2":"gap-2.5 px-3 py-2"} ${e?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"}`}function J({icon:e,label:s,badge:n,collapsed:r}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e,{className:"size-4 shrink-0"}),!r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex-1 text-left",children:s}),void 0!==n&&(0,t.jsx)("span",{"data-nav-badge":"",className:"rounded-full bg-card px-1.5 text-[11px] text-muted-foreground transition-opacity duration-150",children:n})]})]})}function Y({icon:e,label:s,active:n,onClick:r,badge:a,collapsed:i}){return(0,t.jsx)("button",{type:"button",onClick:r,"aria-label":i?s:void 0,title:i?s:void 0,className:V(n,i),children:(0,t.jsx)(J,{icon:e,label:s,badge:a,collapsed:i})})}function G({icon:e,label:s,href:r,active:a,badge:i,collapsed:o}){return(0,t.jsx)(n.default,{href:r,"aria-label":o?s:void 0,"aria-current":a?"page":void 0,title:o?s:void 0,className:V(a,o,!0),children:(0,t.jsx)(J,{icon:e,label:s,badge:i,collapsed:o})})}e.s(["changeMemberRole",0,L,"fetchRoster",0,z,"fetchWorkspaces",0,U,"removeMember",0,$,"renameWorkspaceApi",0,B,"revokeInvite",0,O,"sendInvite",0,P,"setDefaultMemberCreditLimit",0,R,"setLiveSessionPolicy",0,F,"setMemberCreditLimit",0,I,"switchWorkspace",0,H],108774),e.s(["Sidebar",0,function({open:e,onOpenChange:N,chats:S,activeChatId:C,onNewChat:E,onSelectChat:T,onRenameChat:A,onDeleteChat:M,onOpenSettings:D,signedIn:_,credits:z,search:P,folders:O=[],foldersEnabled:L=!1,onMoveChat:I,pinnedIds:R,onTogglePin:$,onShareChat:B,filters:F,onFiltersChange:U,onClearNarrowing:H,members:q=[],chatsLoading:W=!1,chatsError:V=null,onRetryChats:J,workspaces:X=[],activeWorkspaceId:Q=null}
3){let Z=(0,i.usePathname)(),[ee,et]=(0,s.useState)(!1),[es,en]=(0,s.useState)(!1),er=(0,s.useSyncExternalStore)(r.subscribeNarrow,r.isNarrow,()=>!1),ea=F?(0,w.activeFilterCount)(F):0,ei=1===X.length&&q.length<=1,eo=null!==Q&&X.length>0&&!ei;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:`hidden shrink-0 transition-[width] duration-300 ease-out lg:block ${e?"lg:w-[14.5rem]":"lg:w-14"}`}),(0,t.jsx)("button",{type:"button","aria-label":"Close sidebar","aria-hidden":!e,tabIndex:e?0:-1,onClick:()=>N(!1),className:`fixed inset-0 z-30 bg-foreground/20 transition-opacity duration-300 ease-out lg:hidden ${e?"opacity-100":"pointer-events-none opacity-0"}`}),(0,t.jsx)("button",{type:"button","aria-label":"Open sidebar",title:"Open sidebar","aria-hidden":e,tabIndex:e?-1:0,onClick:()=>N(!0),className:`fixed left-3 top-3 z-40 grid size-8 place-items-center rounded-lg bg-sidebar/90 text-foreground/70 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.15)] backdrop-blur transition-all duration-200 ease-out hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50 active:scale-90 motion-reduce:active:scale-100 lg:hidden ${e?"pointer-events-none -translate-x-1 opacity-0":"translate-x-0 opacity-100"}`,children:(0,t.jsx)(k,{})}),(0,t.jsxs)("aside",{inert:er&&!e,className:`fixed inset-y-0 left-0 z-40 flex flex-col overflow-hidden border-r border-border/60 bg-sidebar transition-[width,transform] duration-300 ease-out ${e?"w-[14.5rem] translate-x-0":"w-[14.5rem] -translate-x-full lg:w-14 lg:translate-x-0"}`,children:[(0,t.jsx)("div",{className:`group/brand flex h-14 shrink-0 items-center gap-1 ${e?"justify-between pl-3 pr-2":"justify-center px-2"}`,children:e?(0,t.jsxs)(t.Fragment,{children:[eo?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.default,{href:"/","aria-label":"MultiAI home",title:"MultiAI",className:"shrink-0 rounded-lg outline-none transition-transform duration-200 hover:scale-105 focus-visible:ring-2 focus-visible:ring-ring/50 active:scale-95",children:(0,t.jsx)(a.BrandMark,{className:"size-7"})}),(0,t.jsx)(K,{workspaces:X,activeId:Q})]}):(0,t.jsxs)(n.default,{href:"/",className:"flex min-w-0 items-center gap-2.5",children:[(0,t.jsx)(a.BrandMark,{className:"size-7"}),(0,t.jsx)("span",{className:"truncate font-semibold tracking-tight",children:"MultiAI"})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center",children:[(0,t.jsx)("button",{type:"button",onClick:()=>en(!0),"aria-label":"Search chats",title:"Search chats",className:"grid size-8 shrink-0 place-items-center rounded-lg text-foreground/70 transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90",children:(0,t.jsx)(p.Search,{className:"size-4"})}),(0,t.jsx)("button",{type:"button",onClick:()=>N(!1),"aria-label":"Collapse sidebar",title:"Collapse sidebar",className:"grid size-8 shrink-0 place-items-center rounded-lg text-foreground/70 transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90",children:(0,t.jsx)(k,{})})]})]}):(0,t.jsxs)("div",{className:"relative size-8",children:[(0,t.jsx)(n.default,{href:"/",className:"absolute inset-0 grid place-items-center transition-opacity duration-200 group-hover/brand:opacity-0",children:(0,t.jsx)(a.BrandMark,{className:"size-7",label:"MultiAI home"})}),(0,t.jsx)("button",{type:"button",onClick:()=>N(!0),"aria-label":"Expand sidebar",title:"Expand sidebar",className:"absolute inset-0 grid place-items-center rounded-lg text-foreground/70 opacity-0 transition-all duration-200 hover:bg-muted hover:text-foreground focus-visible:opacity-100 active:scale-90 group-hover/brand:opacity-100",children:(0,t.jsx)(k,{})})]})}),(0,t.jsxs)("div",{className:`space-y-1 pt-2 ${e?"px-3":"px-2"}`,children:[(0,t.jsxs)("button",{type:"button",onClick:E,"aria-label":e?void 0:"New chat",title:e?void 0:"New chat",className:`flex w-full items-center rounded-xl border border-border/60 bg-card text-sm font-medium transition-all duration-200 hover:bg-muted active:scale-[0.99] ${e?"gap-2.5 px-3 py-2.5":"justify-center py-2.5"}`,children:[(0,t.jsx)(m.Plus,{className:"size-4 shrink-0"}),e&&"New chat"]}),(0,t.jsx)(G,{icon:h.MessageCircle,label:"Chats",href:"/chats",active:"/chats"===Z,badge:S.length||void 0,collapsed:!e}),(0,t.jsxs)("div",{className:`group/projects relative ${e&&L?"[&:focus-within_[data-nav-badge]]:opacity-0 [&:hover_[data-nav-badge]]:opacity-0":""}`,children:[(0,t.jsx)(G,{icon:d.FolderClosed,label:"Projects",href:"/projects",active:"/projects"===Z,badge:O.length||void 0,collapsed:!e}),e&&L&&(0,t.jsx)("button",{type:"button",onClick:()=>et(!0),"aria-label":"Create project",title:"Create project",className:"absolute right-1.5 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-md text-muted-foreground opacity-0 transition-all duration-150 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50 active:scale-90 group-hover/projects:opacity-100",children:(0,t.jsx)(m.Plus,{className:"size-3.5"})})]})]}),e?(0,t.jsx)("div",{className:"mt-4 flex min-h-0 flex-1 flex-col px-3 pb-2",children:(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,t.jsx)(v.ChatList,{chats:S,folders:O,activeChatId:C,foldersEnabled:L,search:P,filterCount:ea,onClearFilters:()=>H?H():U?.(w.NO_FILTERS),loading:W,error:V,onRetry:()=>J?.(),onSelectChat:T,onRenameChat:A,onDeleteChat:M,onNewChat:E,onMoveChat:(e,t)=>
3I?.(e,t),pinnedIds:R,onTogglePin:$,onShareChat:B,downloadable:_})})}):(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)("div",{className:`shrink-0 space-y-1 border-t border-border/60 py-3 ${e?"px-3":"px-2"}`,children:[(0,t.jsxs)("div",{className:e?"flex items-center gap-1":"space-y-1",children:[(0,t.jsx)("div",{className:e?"min-w-0 flex-1":void 0,children:(0,t.jsx)(Y,{icon:x.Settings,label:"Settings",onClick:()=>D(),collapsed:!e})}),(0,t.jsx)(y.ThemeCycleButton,{className:`grid place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90 ${e?"size-8 shrink-0":"w-full py-2"}`}),(0,t.jsx)(g.ExtensionButton,{className:`grid place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90 ${e?"size-8 shrink-0":"flex w-full justify-center py-2"}`})]}),(0,t.jsxs)("div",{className:e?"flex items-center gap-1":"space-y-1",children:[(0,t.jsx)("div",{className:e?"min-w-0 flex-1":void 0,children:(0,t.jsxs)(n.default,{href:"/help",target:"_blank",rel:"noopener","aria-label":e?void 0:"Help",title:e?void 0:"Help",className:`flex w-full items-center rounded-xl text-sm text-muted-foreground transition-all duration-200 hover:bg-muted/60 hover:text-foreground active:scale-[0.99] ${e?"gap-2.5 px-3 py-2":"justify-center py-2"}`,children:[(0,t.jsx)(c.LifeBuoy,{className:"size-4 shrink-0"}),e&&(0,t.jsx)("span",{className:"flex-1 text-left",children:"Help"})]})}),(0,t.jsx)(o.NotificationBell,{signedIn:!!_,collapsed:!e}),_&&(0,t.jsx)("form",{action:"/api/auth/logout",method:"post",className:e?void 0:"w-full",children:(0,t.jsx)("button",{type:"submit","aria-label":"Sign out",title:"Sign out",className:`grid place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-destructive/10 hover:text-destructive active:scale-90 ${e?"size-8 shrink-0":"w-full py-2"}`,children:(0,t.jsx)(u.LogOut,{className:"size-4"})})}),(0,t.jsx)(l.UpdateWatcher,{})]}),(0,t.jsx)("div",{className:e?"px-0.5 pt-1":"pt-1",children:(0,t.jsx)(j.CreditsBar,{remaining:z.remaining,total:z.total,plan:z.plan,fullWidth:e,compact:!e,onOpenSettings:D})})]})]}),L&&(0,t.jsx)(f.CreateProjectDialog,{open:ee,onOpenChange:et}),(0,t.jsx)(b.SearchDialog,{open:es,onOpenChange:en,folders:O,onSelectChat:T})]})}],441732)},694367,809584,368308,758925,e=>{"use strict";var t=e.i(456420);let s=(0,t.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);e.s(["ChartColumn",0,s],694367);let n=(0,t.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);e.s(["Database",0,n],809584);let r=(0,t.default)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);e.s(["Keyboard",0,r],368308);let a=(0,t.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);e.s(["KeyRound",0,a],758925)},950786,e=>{"use strict";let t=(0,e.i(456420).default)("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);e.s(["Palette",0,t],950786)},112092,e=>{"use strict";let t=(0,e.i(456420).default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}
3],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);e.s(["SlidersHorizontal",0,t],112092)},912505,699375,851659,186306,796530,925064,501139,660034,404164,569020,889121,986664,725981,792842,e=>{"use strict";let t;var s=e.i(843476);e.s(["EmptyState",0,function({icon:e,title:t,hint:n,action:r,className:a=""}){return(0,s.jsxs)("div",{className:`flex flex-col items-center gap-2 text-center ${a}`,children:[(0,s.jsx)("span",{className:"grid size-10 place-items-center rounded-xl border border-border/60 bg-muted/40 text-muted-foreground",children:(0,s.jsx)(e,{className:"size-4"})}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:t}),n&&(0,s.jsx)("p",{className:"max-w-sm text-xs leading-relaxed text-muted-foreground",children:n}),r&&(0,s.jsx)("div",{className:"mt-1",children:r})]})}],912505);var n=e.i(271645),r=e.i(689664);function a({on:e,onChange:t,label:i,disabled:o,title:l,id:d,confirm:c=!0}){let[u,h]=(0,n.useState)(!1),m=(0,n.useRef)(void 0);return(0,s.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${u?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]}),(0,s.jsx)("button",{id:d,type:"button",role:"switch","aria-checked":e,"aria-label":i,title:l,disabled:o,onClick:function(){t(!e),c&&(h(!0),window.clearTimeout(m.current),m.current=window.setTimeout(()=>h(!1),1600))},className:`inline-flex h-6 w-11 shrink-0 items-center rounded-full p-0 transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50 ${e?"bg-primary":"bg-muted-foreground/25"}`,children:(0,s.jsx)("span",{className:`inline-block size-5 rounded-full bg-background shadow-[0_1px_3px_rgba(0,0,0,0.2)] transition-transform duration-200 ease-out ${e?"translate-x-[22px]":"translate-x-[2px]"}`})})]})}e.s(["Switch",0,a],699375);let i="Shift",o={Comma:",",Period:".",Slash:"/",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Minus:"-",Equal:"=",Backquote:"`",Space:"Space",NumpadEnter:"Enter"},l=["Enter","Escape","Tab","Backspace","Delete","Home","End","PageUp","PageDown","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],d=["Shift","Control","Alt","Meta","CapsLock","OS","AltGraph","Dead"];function c(e){if(d.includes(e.key))return null;let t=e.code;return/^Key[A-Z]$/.test(t)?t.slice(3):/^Digit[0-9]$/.test(t)?t.slice(5):/^Numpad[0-9]$/.test(t)?t.slice(6):/^F([1-9]|1[0-9]|2[0-4])$/.test(t)?t:o[t]?o[t]:l.includes(t)?t:1===e.key.length?e.key.toUpperCase():l.includes(e.key)?e.key:null}function u(e){let t=e.split("+"),s=t[t.length-1]||"+";return{mod:t.includes("Mod"),alt:t.includes("Alt"),shift:t.includes(i),key:s}}function h(e,t){let s=u(t);if(s.mod!==(e.ctrlKey||e.metaKey)||s.alt!==e.altKey||s.shift!==e.shiftKey)return!1;let n=c(e);return null!==n&&n.toLowerCase()===s.key.toLowerCase()}function m(e){if(!e)return!1;let{key:t}=u(e);return t.length>0}let p={Mod:"⌘",Alt:"⌥",Shift:"⇧"},x={Mod:"Ctrl",Alt:"Alt",Shift:"Shift"},f={Escape:"Esc",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Space:"Space",PageUp:"PgUp",PageDown:"PgDn"};function g(e,t){let{mod:s,alt:n,shift:r,key:a}=u(e),i=t?p:x,o=[];return t?(n&&o.push(i.Alt),r&&o.push(i.Shift),s&&o.push(i.Mod)):(s&&o.push(i.Mod),n&&o.push(i.Alt),r&&o.push(i.Shift)),o.push(f[a]??a),o}function y(e,t){return g(e,t).join(t?"":"+")}function b(){return!("u"<typeof navigator)&&/Mac|iPhone|iPad|iPod/i.test(navigator.userAgent)}function j(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t||e.isContentEditable}e.s(["bindingChips",0,g,"bindingFromEvent",0,function(e){let t=c(e);if(!t)return null;let s=[];return(e.ctrlKey||e.metaKey)&&s.push("Mod"),e.altKey&&s.push("Alt"),e.shiftKey&&s.push(i),s.push(t),s.join("+")},"eventMatchesBinding",0,h,"formatBinding",0,y,"hasCommandModifier",0,function(e){let{mod:t,alt:s}=u(e);return t||s},"isMacPlatform",0,b,"isTypingTarget",0,j,"isValidBinding",0,m],851659);let v=[{id:"composer.send",label:"Send message",group:"composer",defaultKeys:"Enter",fixed:!0,worksWhileTyping:!0,hint:"Handled by the composer itself."},{id:"composer.newline",label:"New line",group:"composer",defaultKeys:"Shift+Enter",fixed:!0,worksWhileTyping:!0,hint:"Handled by the composer itself."},{id:"composer.focus",label:"Focus composer",group:"composer",defaultKeys:"Mod+L"},{id:"composer.cycleThinking",label:"Cycle thinking level",group:"composer",defaultKeys:"Mod+Shift+M",hint:"Steps through the levels the current model actually supports."},{id:"app.commandPalette",label:"Command palette / search",group:"app",defaultKeys:"Mod+K",worksWhileTyping:!0},{id:"app.showShortcuts",label:"Show shortcuts",group:"app",defaultKeys:"Mod+/",worksWhileTyping:!0},{id:"app.newChat",label:"New chat",group:"app",defaultKeys:"Mod+Shift+O"},{id:"app.toggleSidebar",label:"Toggle sidebar",group:"app",defaultKeys:"Mod+Shift+S"},{id:"app.toggleActivityPanel",label:"Toggle worklog panel",group:"app",defaultKeys:"Mod+Shift+A"},{id:"app.openSettings",label:"Open settings",group:"app",defaultKeys:"Mod+,"},{id:"app.toggleTheme",label:"Toggle light / dark theme",group:"app",defaultKeys:"Mod+Shift+L"},{id:"app.copyLastResponse",label:"Copy last response",group:"app",defaultKeys:"Mod+Shift+C"},{id:"app.copyLastCodeBlock",label:"Copy last code block",group:"app",defaultKeys:"Mod+Shift+;"},{id:"conversation.changeModel",label:"Change model",group:"conversation",defaultKeys:"Mod+M"},{id:"conversation.toggleAgent",label:"Switch to Chat / Agent",group:"conversation",defaultKeys:"Mod+Shift+E"},{id:"conversation.modeSolo",label:"Solo mode",group:"conversation",defaultKeys:"Mod+1"},{id:"conversation.modeMulti",label:"Multi mode",group:"conversation",defaultKeys:"Mod+2"},{id:"conversation.modeDebate",label:"Debate mode",group:"conversation",defaultKeys:"Mod+3"},{id:"conversation.modeGroup",label:"Group mode",group:"conversation",defaultKeys:"Mod+4"}],w=new Map(v.map(e=>[e.id,e]));function k(e){return w.get(e)}e.s(["CONV_MODE_SHORTCUT",0,{solo:"conversation.modeSolo",multi:"conversation.modeMulti",debate:"conversation.modeDebate",group:"conversation.modeGroup"},"SHORTCUTS",0,v,"SHORTCUT_GROUPS",0,[{id:"composer",label:"Composer"},{id:"app",label:"App"},{id:"conversation",label:"Conversation"}],"getShortcut",0,k],186306);let N="multiai.shortcuts.v1";function S(){return{overrides:{}}}function C(e){let t=S();if(!e||"object"!=typeof e||Array.isArray(e)||!e.overrides||"object"!=typeof e.overrides)return t;let s={};for(let[t,n]of Object.entries(e.overrides)){let e=k(t);if(!e||e.fixed||!n||"object"!=typeof n)continue;let r={};"boolean"==typeof n.enabled&&(r.enabled=n.enabled),"string"==typeof n.keys&&m(n.keys)&&(r.keys=n.keys),Object.keys(r).length>0&&(s[t]=r)}return{overrides:s}}function E(e){try{window.localStorage.setItem(N,JSON.stringify(e))}catch{}}function T(e,t){let s=t.fixed?void 0:e.overrides[t.id],n=s?.keys??t.defaultKeys;return{id:t.id,def:t,keys:n,enabled:!!t.fixed||(s?.enabled??!0),customised:n!==t.defaultKeys}
3}function A(e){return v.map(t=>T(e,t))}let M=S(),D=null,_=new Set,z=!1;function P(e){return _.add(e),z||(z=!0,fetch("/api/shortcuts",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>{if(!e||null==e.shortcuts)return;let t=C(e.shortcuts);if(JSON.stringify(t)!==JSON.stringify(O()))for(let e of(D=t,E(t),_))e()}).catch(()=>{})),()=>{_.delete(e)}}function O(){return D||(D=function(){let e=S();try{let t=window.localStorage.getItem(N);if(!t)return e;return C(JSON.parse(t))}catch{return e}}()),D}function L(){return M}function I(e){for(let s of(D=e,E(e),clearTimeout(t),t=setTimeout(()=>{fetch("/api/shortcuts",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})},500),_))s()}function R(e,t){let s=O(),n={...s.overrides[e],...t};I({overrides:{...s.overrides,[e]:n}})}e.s(["conflictingShortcutIds",0,function(e){let t=new Map;for(let s of A(e)){let e=s.keys.toLowerCase();t.set(e,[...t.get(e)??[],s.id])}let s=new Set;for(let e of t.values())if(e.length>1)for(let t of e)s.add(t);return s},"getShortcutsServerSnapshot",0,L,"getShortcutsSnapshot",0,O,"resetShortcuts",0,function(){I(S())},"resolveShortcut",0,T,"resolvedShortcuts",0,A,"setShortcutEnabled",0,function(e,t){let s=k(e);s&&!s.fixed&&R(e,{enabled:t})},"setShortcutKeys",0,function(e,t){var s;let n,r=k(e);if(!r||r.fixed)return{ok:!0};let a=(s=O(),n=t.toLowerCase(),A(s).find(t=>t.id!==e&&t.keys.toLowerCase()===n)?.def);return a?{ok:!1,conflict:a}:(R(e,{keys:t}),{ok:!0})},"subscribeShortcuts",0,P],796530);var $=e.i(975157);function B(){return(0,n.useSyncExternalStore)(P,O,L)}let F=()=>()=>{};function U(){return(0,n.useSyncExternalStore)(F,b,()=>!1)}e.s(["useIsMac",0,U,"useShortcutSettings",0,B,"useShortcuts",0,function(e,t){let s=B(),r=t?.enabled??!0,a=(0,n.useRef)(e);(0,n.useEffect)(()=>{a.current=e}),(0,n.useEffect)(()=>{if(!r)return;let e=A(s).filter(e=>e.enabled&&!e.def.fixed);function t(t){if(t.defaultPrevented||t.repeat)return;let s=j(t.target);for(let n of e){if(s&&!n.def.worksWhileTyping)continue;let e=a.current[n.id];if(e&&h(t,n.keys)){t.preventDefault(),t.stopPropagation(),e();return}}}return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[s,r])}],925064),e.s(["KeyChips",0,function({binding:e,className:t}){let n=U(),r=g(e,n);return(0,s.jsx)("span",{className:(0,$.cn)("inline-flex shrink-0 items-center gap-1",t),"aria-label":y(e,n),children:r.map((e,t)=>(0,s.jsx)("kbd",{className:"inline-flex h-5 min-w-[1.25rem] items-center justify-center rounded-md border border-border/70 bg-muted/60 px-1.5 font-sans text-[11px] font-medium leading-none text-muted-foreground transition-colors duration-200",children:e},`${e}-${t}`))})}],501139);var H=e.i(508734),q=e.i(367784),K=e.i(96315),W=e.i(515281),V=e.i(328623),J=e.i(573474),Y=e.i(357443),G=e.i(263676);function X({onConfirm:e,icon:t,label:a,confirmLabel:i,className:o,disabled:l}){let[d,c]=(0,n.useState)(!1),u=(0,n.useRef)(null);return((0,n.useEffect)(()=>{if(d)return u.current=setTimeout(()=>c(!1),4e3),()=>{u.current&&clearTimeout(u.current)}},[d]),d)?(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-0.5 duration-200 animate-in fade-in zoom-in-95",children:[(0,s.jsx)("button",{type:"button","aria-label":i,title:i,onClick:()=>{c(!1),e()},className:"grid size-8 place-items-center rounded-lg text-emerald-600 transition-colors duration-200 hover:bg-emerald-500/10 dark:text-emerald-400",children:(0,s.jsx)(r.Check,{className:"size-4"})}),(0,s.jsx)("button",{type:"button","aria-label":"Cancel",title:"Cancel",onClick:()=>c(!1),className:"grid size-8 place-items-center rounded-lg text-destructive transition-colors duration-200 hover:bg-destructive/10",children:(0,s.jsx)(G.X,{className:"size-4"})})]}):(0,s.jsx)("button",{type:"button","aria-label":a,title:a,disabled:l,onClick:()=>c(!0),className:(0,$.cn)("grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors duration-200 hover:bg-destructive/10 hover:text-destructive disabled:opacity-40",o),children:t})}e.s(["ConfirmInline",0,X],660034);var Q=e.i(987968),Z=e.i(846696),ee=e.i(519455),et=e.i(793479),es=e.i(108774),en=e.i(886043),er=e.i(307730),ea=e.i(215380),ei=e.i(852091);function eo({plan:e,value:t,onSave:a}
3){let[i,o]=(0,n.useState)(!1),[l,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(!1),[h,m]=(0,n.useState)(!1),p=(0,n.useRef)(void 0),x=(()=>{if(""===l.trim())return null;let e=Number(l);if(!Number.isFinite(e)||e<0)return null;let t=Math.round(e*er.MILLICREDITS_PER_CREDIT);return t<=1e8?t:null})();async function f(e){u(!0);try{await a(e),o(!1),m(!0),window.clearTimeout(p.current),p.current=window.setTimeout(()=>m(!1),1600)}catch(e){Z.toast.error("Could not change the default allowance",{description:e instanceof Error?e.message:"Please try again."})}finally{u(!1)}}let g=en.PLANS[e].credits;return(0,s.jsxs)("div",{className:"mt-5 rounded-xl border border-border/60 p-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Member spending"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:null===t?(0,s.jsxs)(s.Fragment,{children:["Everyone can use anything in the workspace’s"," ",g.toLocaleString()," credits a month. Set a monthly allowance to give each teammate a fixed share instead - you can still override any single person on their own row."]}):(0,s.jsxs)(s.Fragment,{children:["Each teammate can spend"," ",(0,s.jsxs)("span",{className:"font-medium text-foreground",children:[(0,er.formatWholeCredits)(t)," credits"]})," ","a month out of the workspace’s"," ",g.toLocaleString(),". A person with their own allowance below keeps theirs. Resets on the 1st."]})})]}),(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${h?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]}),!i&&(0,s.jsx)(ee.Button,{variant:"outline",size:"sm",className:"rounded-full",onClick:()=>{d(null===t?"":String(t/er.MILLICREDITS_PER_CREDIT)),o(!0)},children:null===t?"Set an allowance":"Change"})]})]}),i&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(et.Input,{autoFocus:!0,inputMode:"decimal",value:l,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&null!==x&&f(x),"Escape"===e.key&&o(!1)},placeholder:"Credits per member each month",className:"w-56","aria-label":"Default monthly credits per member"}),(0,s.jsx)(ee.Button,{size:"sm",disabled:null===x||c,onClick:()=>null!==x&&void f(x),children:"Set"}),(0,s.jsx)(ee.Button,{variant:"outline",size:"sm",disabled:c||null===t,onClick:()=>void f(null),children:"No limit"}),(0,s.jsx)(ee.Button,{variant:"ghost",size:"sm",onClick:()=>o(!1),children:"Cancel"})]})]})}function el({allocation:e,email:t,canManage:a,onSave:i}
3){let[o,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(""),[u,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),x=(0,n.useRef)(void 0),{monthSpendMillicredits:f,limitMillicredits:g}=e,y=(()=>{if(""===d.trim())return null;let e=Number(d);if(!Number.isFinite(e)||e<0)return null;let t=Math.round(e*er.MILLICREDITS_PER_CREDIT);return t<=1e8?t:null})();async function b(e){h(!0);try{await i(e),l(!1),p(!0),window.clearTimeout(x.current),x.current=window.setTimeout(()=>p(!1),1600)}catch(e){Z.toast.error("Could not change that limit",{description:e instanceof Error?e.message:"Please try again."})}finally{h(!1)}}return(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 border-t border-border/60 pt-2 pl-11",children:[(0,s.jsx)("span",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:null!=g?`${(0,er.formatWholeCredits)(f)} of ${(0,er.formatWholeCredits)(g)} credits this month`:`${(0,er.formatWholeCredits)(f)} credits this month \xb7 no limit`}),(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${m?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]}),a&&(o?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)(et.Input,{type:"number",min:0,step:.1,autoFocus:!0,value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"!==e.key||null===y||u||b(y),"Escape"===e.key&&l(!1)},placeholder:"Credits","aria-label":`Monthly credit limit for ${t}`,className:"h-7 w-24 px-2 text-xs",disabled:u}),(0,s.jsx)(ee.Button,{size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",disabled:u||null===y,onClick:()=>void b(y),children:u?(0,s.jsx)(Q.Spinner,{className:"size-3"}):"Set"}),(0,s.jsx)("button",{type:"button",disabled:u,onClick:()=>void b(null),className:"rounded-full border border-border/60 px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Unlimited"}),(0,s.jsx)("button",{type:"button",disabled:u,onClick:()=>l(!1),className:"rounded-full px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Cancel"})]}):(0,s.jsx)("button",{type:"button",onClick:()=>{c(null!=g?String(g/er.MILLICREDITS_PER_CREDIT):""),l(!0)},className:"rounded-full border border-border/60 px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:null!=g?"Edit limit":"Set limit"}))]})}let ed=[{value:"members",label:"All members"},{value:"admins",label:"Admins only"}];function ec({policy:e,canManage:t,onChange:a}){let[i,o]=(0,n.useState)(!1),l=(0,n.useRef)(void 0);return(0,s.jsx)("div",{className:"mt-6 rounded-xl border border-border/60 p-3.5",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start gap-x-3 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1 basis-52",children:[(0,s.jsx)("p",{className:`text-sm font-medium ${t?"":"text-muted-foreground"}`,children:"Who can start live sessions"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"admins"===e?(0,s.jsx)(s.Fragment,{children:"Only admins can take a chat live or end a session. Everyone can still join and talk in a session that is running."}):(0,s.jsx)(s.Fragment,{children:"Anyone here can take a chat live for the team to join, and end a running session."})})]}),(0,s.jsxs)("span",{className:"mt-0.5 inline-flex shrink-0 items-center gap-2",children:[(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${i?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]}),(0,s.jsx)("span",{role:"radiogroup","aria-label":"Who can start live sessions",className:`inline-flex rounded-full border border-border/60 p-0.5 ${t?"":"opacity-50"}`,children:ed.map(n=>(0,s.jsx)("button",{type:"button",role:"radio","aria-checked":e===n.value,disabled:!t,title:t?void 0:"Only workspace admins can change who may go live",onClick:()=>{var t;(t=n.value)!==e&&(a(t),o(!0),window.clearTimeout(l.current),l.current=window.setTimeout(()=>
3o(!1),1600))},className:`rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors duration-200 disabled:cursor-not-allowed ${e===n.value?"bg-primary text-primary-foreground":"text-muted-foreground enabled:hover:text-foreground"}`,children:n.label},n.value))})]})]})})}e.s(["MembersSection",0,function({plan:e}){let[t,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(null),[l,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(null),[h,m]=(0,n.useState)(""),[p,x]=(0,n.useState)("member"),[f,g]=(0,n.useState)(!1),[y,b]=(0,n.useState)(null),[j,v]=(0,n.useState)(null),[w,k]=(0,n.useState)(!1),[N,S]=(0,n.useState)(null),C=(0,n.useCallback)(async()=>{try{let e=await (0,es.fetchRoster)();o(e),d(e.workspace.defaultMemberCreditLimitMillicredits),u(null)}catch(e){u(e instanceof Error?e.message:"Could not load members")}},[]);(0,n.useEffect)(()=>{let e=!0;return(0,es.fetchRoster)().then(t=>{e&&(o(t),u(null))}).catch(t=>{e&&u(t instanceof Error?t.message:"Could not load members")}),()=>{e=!1}},[]);let E=i?.role==="admin",T=en.PLANS[e].priceUsdMonthly,A=Math.round(T*en.YEARLY_DISCOUNT*100)/100,M=i?Math.max(1,i.seats.used):1,D=i?.seats.canAdd??!0,_=en.PLANS[e].maxMembers;async function z(){if(h.trim()){g(!0);try{let{inviteUrl:t}=await (0,es.sendInvite)(h.trim(),p);b(t??null),m(""),await C(),Z.toast.success("Invite sent",{description:`We emailed an invite to ${h.trim()}. This user adds $${en.PLANS[e].priceUsdMonthly}/mo to your bill and ${en.PLANS[e].credits.toLocaleString()} credits to your pool.`})}catch(e){Z.toast.error("Could not invite",{description:e instanceof Error?e.message:"Please try again."})}finally{g(!1)}}}async function P(){let e=(j??"").trim(),t=i?.workspace.name??"";v(null),e&&e!==t&&await I("rename",async()=>{await (0,es.renameWorkspaceApi)(e),Z.toast.success("Workspace renamed",{description:"The new name shows for every member (switchers update on their next load)."})},"Could not rename the workspace")}async function O(){if(y)try{await navigator.clipboard.writeText(y),k(!0),setTimeout(()=>k(!1),1500)}catch{Z.toast.error("Could not copy",{description:"Clipboard access was blocked."})}}async function L(e){let t=i?.workspace.liveSessionPolicy;if(void 0===t||t===e)return;let s=e=>o(t=>t?{...t,workspace:{...t.workspace,liveSessionPolicy:e}}:t);s(e);try{await (0,es.setLiveSessionPolicy)(e)}catch(e){s(t),Z.toast.error("Could not change that setting",{description:e instanceof Error?e.message:"Please try again."})}}async function I(e,t,s){if(!N){S(e);try{await t(),await C()}catch(e){Z.toast.error(s,{description:e instanceof Error?e.message:"Please try again."})}finally{S(null)}}}return c?(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-base font-medium",children:"Team"}),(0,s.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:c})]}):i?(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-base font-medium",children:"Team"}),(0,s.jsxs)("p",{className:"mt-1 flex flex-wrap items-center gap-x-1 text-xs text-muted-foreground",children:[null!==j?(0,s.jsx)("input",{autoFocus:!0,value:j,maxLength:80,onChange:e=>v(e.target.value),onBlur:()=>void P(),onKeyDown:e=>{"Enter"===e.key&&P(),"Escape"===e.key&&v(null)},"aria-label":"Workspace name",className:"rounded border border-input bg-transparent px-1.5 py-0.5 text-xs outline-none focus:border-foreground
3/30"}):E?(0,s.jsxs)("button",{type:"button",onClick:()=>v(i.workspace.name),disabled:"rename"===N,title:"Rename workspace",className:"group/wsname inline-flex items-center gap-1 rounded text-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50",children:[i.workspace.name,"rename"===N?(0,s.jsx)(Q.Spinner,{className:"size-3"}):(0,s.jsx)(W.Pencil,{className:"size-3 opacity-0 transition-opacity group-hover/wsname:opacity-100 group-focus-visible/wsname:opacity-100"})]}):(0,s.jsx)("span",{className:"text-foreground",children:i.workspace.name}),(0,s.jsx)("span",{children:en.PLANS[e].subscription?`\xb7 $${T}/mo ($${A}/mo billed yearly) for the workspace \xb7 ${M} member${1===M?"":"s"}`:"· free plan"})," ",(0,s.jsx)(ei.DocsLink,{slug:"your-team"})]}),E&&!(0,en.allowsTeammates)(e)&&(0,s.jsxs)("div",{className:"mt-5 flex items-start justify-between gap-3 rounded-xl border border-border/60 bg-muted/30 p-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium",children:[en.PLANS[e].name," is a single-user plan"]}),(0,s.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Teammates cost nothing extra on any plan above it - they share this workspace's monthly credits and work with you in live sessions and projects. Professional holds up to"," ",en.PLANS.pro.maxMembers??"any number of"," people; Business takes any number."]})]}),(0,s.jsxs)(ee.Button,{size:"sm",className:"shrink-0 rounded-full",onClick:()=>a(!0),children:[(0,s.jsx)(V.Sparkles,{className:"size-3.5"}),"Upgrade"]})]}),(0,s.jsx)(ea.PricingDialog,{open:t,onOpenChange:a}),E&&(0,en.allowsTeammates)(e)&&(0,s.jsx)(eo,{plan:e,value:l,onSave:async e=>{await (0,es.setDefaultMemberCreditLimit)(e),d(e)}}),E&&(0,en.allowsTeammates)(e)&&(0,s.jsxs)("div",{className:"mt-5",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(et.Input,{type:"email",value:h,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&z()},"aria-label":"Teammate email",placeholder:"[email protected]",className:"flex-1"}),(0,s.jsxs)("select",{value:p,onChange:e=>x(e.target.value),"aria-label":"Role",className:"rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none disabled:opacity-50",children:[(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"admin",children:"Admin"})]}),(0,s.jsxs)(ee.Button,{onClick:()=>void z(),disabled:f||!h.trim(),children:[f?(0,s.jsx)(Q.Spinner,{className:"size-4"}):(0,s.jsx)(Y.UserPlus,{className:"size-4"}),"Invite"]})]}),(0,s.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:D?(0,s.jsxs)(s.Fragment,{children:["Teammates are free on this plan - the $",T,"/mo covers the whole workspace, and they share its"," ",en.PLANS[e].credits.toLocaleString()," credits a month."," ",null===_?"Add as many people as you like.":`${en.PLANS[e].name} holds up to ${_}; you have ${Math.max(0,_-M)} left.`]}):1===_?(0,s.jsxs)(s.Fragment,{children:[en.PLANS[e].name," is a single-user plan. Upgrade to add teammates - they cost nothing extra on any plan above it."]}):(0,s.jsxs)(s.Fragment,{children:[en.PLANS[e].name," holds ",_," people and is full. Upgrade to add more - Business takes any number."]})}),y&&(0,s.jsxs)("div",{className:"mt-3 rounded-xl border border-border/60 bg-muted/40 p-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:"Invite emailed. Dev-only link (shown once) for testing:"}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,s.jsx)("code",{className:"min-w-0 flex-1 truncate rounded bg-card px-2 py-1.5 font-mono text-[11px]",children:y}),(0,s.jsxs)(ee.Button,{size:"sm",variant:"outline",onClick:()=>void O(),children:[w?(0,s.jsx)(r.Check,{className:"size-3.5"}):(0,s.jsx)(H.Copy,{className:"size-3.5"}),w?"Copied":"Copy"]})]})]})]}),(0,s.jsx)("ul",{className:"mt-6 space-y-1",children:i.members.map(e=>{let t=e.userId===i.you;return(0,s.jsxs)("li",{className:"rounded-xl border border-border/60 px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-full bg-muted text-[11px] font-medium uppercase",children:(e.name??e.email).slice(0,2)}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate text-sm font-medium",children:e.name??e.email}),(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.email})]}),e.owner?(0,s.jsx)("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:"Owner"}):E&&(i.workspace.owner||"admin"!==e.role)?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[N===`role:${e.userId}`&&(0,s.jsx)(Q.Spinner,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,s.jsxs)("select",{value:e.role,disabled:null!==N,onChange:t=>void I(`role:${e.userId}`,()=>(0,es.changeMemberRole)(e.userId,t.target.value),"Could not change that role"),"aria-label":`Role for ${e.email}`,className:"rounded-lg border border-input bg-transparent px-2 py-1 text-xs outline-none disabled:opacity-50",children:[(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"admin",children:"Admin"})]})]}):(0,s.jsx)("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] capitalize text-muted-foreground",children:e.role}),E&&!e.owner&&!t&&(i.workspace.owner||"admin"!==e.role)&&(N===`member:${e.userId}`?(0,s.jsx)("span",{className:"grid size-8 shrink-0 place-items-center",children:(0,s.jsx)(Q.Spinner,{className:"size-3.5"})}):(0,s.jsx)(X,{icon:(0,s.jsx)(J.Trash2,{className:"size-3.5"}),label:`Remove ${e.email}`,confirmLabel:`Confirm removing ${e.email}`,disabled:null!==N,onConfirm:()=>void I(`member:${e.userId}`,()=>(0,es.removeMember)(e.userId),"Could not remove that member")}))]}),e.allocation&&(0,s.jsx)(el,{allocation:e.allocation,email:e.email,canManage:E&&!e.owner,onSave:async t=>{await (0,es.setMemberCreditLimit)(e.userId,t),await C()}})]},e.userId)})}),(0,s.jsx)(ec,{policy:i.workspace.liveSessionPolicy,canManage:E,onChange:e=>void L(e)}),E&&i.invites.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"mt-6 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Pending invites"}),(0,s.jsx)("ul",{className:"mt-2 space-y-1",children:i.invites.map(e=>(0,s.jsxs)("li",{className:"flex items-center gap-3 rounded-xl border border-dashed border-border/60 px-3 py-2.5",children:[(0,s.jsx)(K.Mail,{className:"size-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate text-sm",children:e.email}),(0,s.jsxs)("span",{className:"block text-xs text-muted-foreground",children:[e.role," · expires"," ",new Date(e.expiresAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]}),(0,s.jsxs)("button",{type:"button",disabled:null!==N,onClick:()=>void I(`invite:${e.id}`,async()=>void await (0,es.revokeInvite)(e.id),"Could not revoke that invite"),className:"inline-flex shrink-0 items-center gap-1.5 rounded-lg px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent",children:[N===`invite:${e.id}`&&(0,s.jsx)(Q.Spinner,{className:"size-3.5"}),N===`invite:${e.id}`?"Revoking…":"Revoke"]})]},e.id))})]}),!i.workspace.owner&&(0,s.jsxs)("button",{type:"button",disabled:null!==N,onClick:()=>{confirm("Leave this workspace? You will lose access to its chats.")&&I("leave",async()=>{await (0,es.removeMember)(),window.location.reload()},"Could not leave this workspace")},className:"mt-6 inline-flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50 disabled:hover:text-muted-foreground",children:["leave"===N?(0,s.jsx)(Q.Spinner,{className:"size-4"}):(0,s.jsx)(q.LogOut,{className:"size-4"}),"leave"===N?"Leaving…":"Leave workspace"]})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-base font-medium",children:"Team"}),(0,s.jsxs)("p",{className:"mt-4 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-4"}),"Loading…"]})]})}],404164);var eu=e.i(146387),eh=e.i(466787),em=e.i(624687);e.s(["WorkspaceSection",0,function({onEnabledChange:e}={}
3){let[t,i]=(0,n.useState)(!1),[o,l]=(0,n.useState)(null),[d,c]=(0,n.useState)(""),[u,h]=(0,n.useState)("member"),[m,p]=(0,n.useState)(!1),[x,f]=(0,n.useState)(""),g=(0,n.useRef)(""),[y,b]=(0,n.useState)(!1),[j,v]=(0,n.useState)(!1),w=(0,n.useRef)(void 0),k=(0,n.useRef)(void 0);async function N(e){if(e!==g.current){b(!0);try{let t=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`HTTP ${t.status}`)}g.current=e,v(!0),window.clearTimeout(w.current),w.current=window.setTimeout(()=>v(!1),1800)}catch(e){Z.toast.error("Could not save workspace instructions",{description:e instanceof Error?e.message:"Please try again."})}finally{b(!1)}}}async function S(t){p(t),e?.(t);try{let e=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({customizationEnabled:t})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`HTTP ${e.status}`)}}catch(s){p(!t),e?.(!t),Z.toast.error("Could not change that setting",{description:s instanceof Error?s.message:"Please try again."})}}(0,n.useEffect)(()=>{let t=!0;return fetch("/api/workspaces",{cache:"no-store"}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(s=>{t&&(c(s.name??""),h("admin"===s.role?"admin":"member"),p(!0===s.customizationEnabled),e?.(!0===s.customizationEnabled),f(s.instructions??""),g.current=s.instructions??"",i(!0))}).catch(()=>{t&&(l("Could not load workspace settings"),i(!0))}),()=>{t=!1}},[e]);let C="admin"===u;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(eu.Building2,{className:"size-4 text-muted-foreground"}),"Workspace instructions"]}),(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${j?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]})]}),t?o?(0,s.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 text-sm text-destructive",children:[(0,s.jsx)(eh.TriangleAlert,{className:"size-4"}),o]}):(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsxs)("div",{className:"mt-2 flex items-start justify-between gap-3 rounded-xl border border-border/60 p-3.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Enable customization"}),(0,s.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:[m?(0,s.jsxs)(s.Fragment,{children:["On: the instructions below are folded into every conversation in"," ",d?(0,s.jsx)("span",{className:"text-foreground",children:d}):"this workspace",", for every member."]}):(0,s.jsx)(s.Fragment,{children:"Off: the instructions below are kept, but nothing is sent to the models - answers are unaffected."})," ",!C&&"Only workspace admins can change this."]})]}),(0,s.jsx)("span",{className:"mt-0.5",children:(0,s.jsx)(a,{id:"customization-enabled",on:m,onChange:e=>void S(e),label:"Enable customization",disabled:!C,title:C?void 0:"Only workspace admins can change this"})})]}),(0,s.jsxs)("div",{className:m?"mt-4":"mt-4 opacity-50",children:[(0,s.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Tone, context about your team, things the models should always know."," ",C?m?"Saved automatically as you type.":"Turn customization on to edit.":"Only workspace admins can edit this."]}),C?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(em.Textarea,{value:x,onChange:e=>{var t;f(t=e.target.value),window.clearTimeout(k.current),k.current=window.setTimeout(()=>void N(t),900)},onBlur:function(){window.clearTimeout(k.current),N(x)},disabled:!m,maxLength:4e3,rows:8,placeholder:"e.g. We are a 6-person fintech startup in Berlin. Prefer concise answers with concrete examples. Always consider EU regulations.","aria-label":"Workspace custom instructions",className:"mt-3 max-h-72 resize-none overflow-y-auto text-[13px] leading-relaxed"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground tabular-nums",children:[x.length.toLocaleStr
3ing()," /"," ",4e3.toLocaleString()]}),y&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-3"}),"Saving…"]})]})]}):x?(0,s.jsx)("div",{className:"mt-3 whitespace-pre-wrap rounded-xl border border-border/60 bg-muted/30 p-3 text-[13px] leading-relaxed",children:x}):(0,s.jsx)("p",{className:"mt-3 rounded-xl border border-dashed border-border/60 p-3 text-xs text-muted-foreground",children:"No workspace instructions yet. An admin can add some here."})]})]}):(0,s.jsxs)("p",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-4"}),"Loading…"]})]})}],569020);var ep=e.i(456420);let ex=(0,ep.default)("circle-user-round",[["path",{d:"M17.925 20.056a6 6 0 0 0-11.851.001",key:"z69sun"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);e.s(["AboutYouSection",0,function({sending:e}){let[t,a]=(0,n.useState)(!1),[i,o]=(0,n.useState)(null),[l,d]=(0,n.useState)({nickname:"",occupation:"",about:""}),c=(0,n.useRef)(""),[u,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),x=(0,n.useRef)(void 0),f=(0,n.useRef)(void 0);async function g(e){if(JSON.stringify(e)!==c.current){h(!0);try{let t=await fetch("/api/profile",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`HTTP ${t.status}`)}c.current=JSON.stringify(e),p(!0),window.clearTimeout(x.current),x.current=window.setTimeout(()=>p(!1),1800)}catch(e){Z.toast.error("Could not save your profile",{description:e instanceof Error?e.message:"Please try again."})}finally{h(!1)}}}function y(e){let t={...l,...e};d(t),window.clearTimeout(f.current),f.current=window.setTimeout(()=>void g(t),900)}function b(){window.clearTimeout(f.current),g(l)}return(0,n.useEffect)(()=>{let e=!0;return fetch("/api/profile",{cache:"no-store"}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(t=>{if(!e)return;let s={nickname:t.nickname??"",occupation:t.occupation??"",about:t.about??""};d(s),c.current=JSON.stringify(s),a(!0)}).catch(()=>{e&&(o("Could not load your profile"),a(!0))}),()=>{e=!1}},[]),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(ex,{className:"size-4 text-muted-foreground"}),"About you"]}),(0,s.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${m?"opacity-100":"opacity-0"}`,children:[(0,s.jsx)(r.Check,{className:"size-3"}),"Saved!"]})]}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:!0===e?(0,s.jsx)(s.Fragment,{children:"Sent to the models with every conversation in this workspace, so answers can be tailored to you. Yours alone - teammates have their own."}):!1===e?(0,s.jsxs)(s.Fragment,{children:["Saved to your account, but"," ",(0,s.jsx)("span",{className:"text-foreground",children:"not sent to the models right now"})," - customization above is off. Turn it on and this is included with every conversation."]}):(0,s.jsx)(s.Fragment,{children:"Sent to the models with your conversations while customization (above) is on. Yours alone - teammates have their own."})}),t?i?(0,s.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 text-sm text-destructive",children:[(0,s.jsx)(eh.TriangleAlert,{className:"size-4"}),i]}):(0,s.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"profile-nickname",className:"text-xs font-medium",children:"Nickname"}),(0,s.jsx)(et.Input,{id:"profile-nickname",value:l.nickname,onChange:e=>y({nickname:e.target.value}),onBlur:b,maxLength:100,placeholder:"What should the models call you?",className:"mt-1.5 text-[13px]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"profile-occupation",className:"text-xs font-medium",children:"Occupation"}),(0,s.jsx)(et.Input,{id:"profile-occupation",value:l.occupation,onChange:e=>y({occupation:e.target.value}),onBlur:b,maxLength:150,placeholder:"e.g. Founder of a small design agency",className:"mt-1.5 text-[13px]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"profile-about",className:"text-xs font-medium",children:"More about you"}),(0,s.jsx)(em.Textarea,{id:"profile-about",value:l.about,onChange:e=>y({about:e.target.value}),onBlur:b,maxLength:3e3,rows:5,placeholder:"Anything the models should always know - your team, your tools, how you like answers.",className:"mt-1.5 max-h-56 resize-none overflow-y-auto text-[13px] leading-relaxed"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground tabular-nums",children:[l.about.length.toLocaleStr
3ing()," /"," ",3e3.toLocaleString()]}),u&&(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-3"}),"Saving…"]})]})]})]}):(0,s.jsxs)("p",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-4"}),"Loading…"]})]})}],889121);var ef=e.i(758925),eg=e.i(584026),ey=e.i(436723);async function eb(e,t){let s=await e.json().catch(()=>null);return Error(s?.error??t)}async function ej(){let e=await fetch("/api/byok",{headers:{"Cache-Control":"no-store"}});if(!e.ok)throw await eb(e,"Could not load API keys");return await e.json()}async function ev(e,t){let s=await fetch("/api/byok",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,apiKey:t})});if(!s.ok)throw await eb(s,"Could not save that key");return await s.json()}async function ew(e){let t=await fetch("/api/byok",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({byokOnly:e})});if(!t.ok)throw await eb(t,"Could not change that setting")}async function ek(e){let t=await fetch(`/api/byok/${e}`,{method:"DELETE"});if(!t.ok)throw await eb(t,"Could not remove that key")}var eN=e.i(435998);function eS(){return(0,s.jsxs)("div",{className:"border-b border-border/60 pb-3",children:[(0,s.jsx)("h2",{className:"text-base font-medium",children:"API keys"}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Run models on your own provider accounts instead of ours."," ",(0,s.jsx)(ei.DocsLink,{slug:"bring-your-own-key"})]})]})}function eC({on:e,canManage:t,onChange:n}){return(0,s.jsx)("div",{className:"mt-4 rounded-xl border border-border/60 p-3.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{htmlFor:"byok-only",className:`block text-sm font-medium ${t?"":"text-muted-foreground"}`,children:"Use only our own API keys"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:e?(0,s.jsx)(s.Fragment,{children:"Your keys are the only ones used. Nothing is charged to credits, and a model from a provider you have no key for will refuse to answer rather than fall back to ours."}):(0,s.jsx)(s.Fragment,{children:"Off: a provider you have added a key for uses that key for free, and every other provider runs on our keys and is charged credits. Turn this on to stop using our keys entirely."})})]}),(0,s.jsx)("span",{className:"mt-0.5",children:(0,s.jsx)(a,{id:"byok-only",on:e,onChange:n,label:"Use only our own API keys",disabled:!t,title:t?void 0:"Only workspace admins can change how billing works"})})]})})}function eE({vendor:e,stored:t,byokOnly:r,canManage:a,onSaved:i,onRemoved:o,onRestore:l}){let[d,c]=(0,n.useState)(""),[u,h]=(0,n.useState)(!1),[m,p]=(0,n.useState)(!1),[x,f]=(0,n.useState)(!1);async function g(){let t=d.trim();if(t&&!u){h(!0);try{let{key:s,warning:n}=await ev(e.id,t);i(s),c(""),n?Z.toast.warning(`${e.label} key saved, but not verified`,{description:n}):Z.toast.success(`${e.label} key saved`,{description:`${e.label} messages are no longer charged credits.`})}catch(t){Z.toast.error(`Could not save your ${e.label} key`,{description:t instanceof Error?t.message:"Please try again."})}finally{h(!1)}}}async function y(){if(t&&!m){f(!1),p(!0),o(e.id);try{await ek(e.id),Z.toast.success(`${e.label} key removed`,{description:`${e.label} messages are charged credits again.`})}catch(s){l(t),Z.toast.error(`Could not remove your ${e.label} key`,{description:s instanceof Error?s.message:"Please try again."})}finally{p(!1)}}}return(0,s.jsxs)("li",{className:"rounded-xl border border-border/60 px-3.5 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(ey.ModelLogo,{vendor:e.id,className:"size-4 shrink-0"}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),(0,s.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:t?(0,s.jsx)(eT,{info:t}):r?"No key · these models will refuse":"Using our key · charged credits"})]}),t?t.unreadable?(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-destructive/40 px-2 py-0.5 text-[11px] text-destructive",children:"Unreadable"}):(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:"Not charged"}):r&&(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-amber-500/40 px-2 py-0.5 text-[11px] text-amber-700 dark:text-amber-400",children:"Unavailable"}),t&&a&&!x&&(0,s.jsx)("button",{type:"button",title:`Remove the ${e.label} key`,"aria-label":`Remove the ${e.label} key`,disabled:m,onClick:()=>f(!0),className:"grid size-7 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors duration-200 hover:bg-muted hover:text-destructive disabled:opacity-50",children:m?(0,s.jsx)(Q.Spinner,{className:"size-3.5"}):(0,s.jsx)(J.Trash2,{className:"size-3.5"})})]}),t&&a&&x&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border border-destructive/30 bg-destructive/[0.03] px-3 py-2 dark:bg-destructive/10",children:[(0,s.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Remove this key? ",e.label," messages will use our key and be charged credits again."]}),(0,s.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,s.jsx)(ee.Button,{size:"sm",variant:"outline",onClick:()=>f(!1),children:"Cancel"}),(0,s.jsx)(ee.Button,{size:"sm",variant:"destructive",onClick:()=>void y(),children:"Remove key"})]})]}),a&&(0,s.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,s.jsx)(et.Input,{type:"password",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&g()},disabled:u,autoComplete:"off",spellCheck:!1,"aria-label":`${e.label} API key`,placeholder:t?"Paste a new key to replace it":`${e.label} API key`,className:"flex-1 font-mono text-xs"}),(0,s.jsxs)(ee.Button,{size:"sm",onClick:()=>void g(),disabled:u||!d.trim(),className:"shrink-0",children:[u?(0,s.jsx)(Q.Spinner,{}):(0,s.jsx)(ef.KeyRound,{}),t?"Replace":"Add key"]}
3)]})]})}function eT({info:e}){let t=new Date(e.addedAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.unreadable?(0,s.jsxs)(s.Fragment,{children:["Stored key can't be decrypted. Add it again · ",t]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"font-mono",children:e.maskedKey}),e.addedBy?` \xb7 added by ${e.addedBy}`:" · added"," ",t]})}e.s(["ApiKeysSection",0,function(){let[e,t]=(0,n.useState)(null),[r,a]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=!0;return ej().then(s=>{e&&(t(s),a(null))}).catch(t=>{e&&a(t instanceof Error?t.message:"Could not load API keys")}),()=>{e=!1}},[]);let i=e=>t(t=>t?{...t,keys:[...t.keys.filter(t=>t.provider!==e.provider),e]}:t);async function o(e){t(t=>t?{...t,byokOnly:e}:t);try{await ew(e)}catch(s){t(t=>t?{...t,byokOnly:!e}:t),Z.toast.error("Could not change that setting",{description:s instanceof Error?s.message:"Please try again."})}}if(r)return(0,s.jsxs)("div",{children:[(0,s.jsx)(eS,{}),(0,s.jsx)("p",{className:"mt-4 text-sm text-destructive",children:r})]});if(!e)return(0,s.jsxs)("div",{children:[(0,s.jsx)(eS,{}),(0,s.jsxs)("p",{className:"mt-4 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,s.jsx)(Q.Spinner,{className:"size-4"}),"Loading…"]})]});let l=e.keys.length,d=new Set(e.keys.filter(e=>!e.unreadable).map(e=>e.provider)),c=(0,eN.visibleModels)().filter(e=>!d.has(e.vendor)),u=[...new Set(c.map(e=>e.vendor))];return(0,s.jsxs)("div",{children:[(0,s.jsx)(eS,{}),(0,s.jsx)(eC,{on:e.byokOnly,canManage:e.canManage,onChange:e=>void o(e)}),e.byokOnly&&u.length>0&&(0,s.jsxs)("p",{className:"mt-3 flex gap-2 rounded-xl border border-amber-500/40 bg-amber-500/[0.05] p-3 text-xs leading-relaxed text-amber-700 dark:text-amber-400",children:[(0,s.jsx)(eh.TriangleAlert,{className:"mt-0.5 size-3.5 shrink-0"}),(0,s.jsxs)("span",{children:[(0,s.jsxs)("span",{className:"font-medium",children:[c.length," model",1===c.length?"":"s"," in the picker cannot answer right now."]})," ","You have no usable key for"," ",u.map(e=>eN.VENDOR_LABEL[e]).join(", "),", so choosing"," ",1===c.length?"that model":"one of those models"," returns an error instead of a reply. Add the missing key",1===u.length?"":"s"," ","below, or turn this setting off."]})]}),(0,s.jsxs)("div",{className:"mt-4 flex gap-2.5 rounded-xl border border-border/60 bg-muted/30 p-3.5",children:[(0,s.jsx)(eg.ShieldCheck,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"min-w-0 text-xs leading-relaxed text-muted-foreground",children:[(0,s.jsxs)("p",{className:"text-foreground",children:["Messages served on your own key are"," ",(0,s.jsx)("span",{className:"font-medium",children:"not charged credits"}),"."]}),(0,s.jsxs)("p",{className:"mt-1",children:["You pay ",l>0?"those providers":"the provider"," directly and we bill you nothing for the tokens. The usage still appears in your dashboard, at zero credits, so your team can see what was spent where. Keys are encrypted before they are stored and are never shown again once saved. Replace a key you need to change."]})]})]}),!e.encryptionReady&&(0,s.jsxs)("p",{className:"mt-3 flex gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-3 text-xs leading-relaxed text-destructive dark:bg-destructive/10",children:[(0,s.jsx)(eh.TriangleAlert,{className:"mt-0.5 size-3.5 shrink-0"}),(0,s.jsx)("span",{children:"This server has no encryption key configured, so provider keys cannot be stored or used. Contact your administrator."})]}),!e.canManage&&(0,s.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only workspace admins can add or remove keys, since a key changes billing for everyone here."}),(0,s.jsx)("ul",{className:"mt-4 space-y-2",children:e.vendors.map(n=>(0,s.jsx)(eE,{vendor:n,stored:e.keys.find(e=>e.provider===n.id)??null,byokOnly:e.byokOnly,canManage:e.canManage&&e.encryptionReady,onSaved:i,onRemoved:s=>{let n;return n=e.keys.filter(e=>e.provider!==s),t(e=>e?{...e,keys:n}:e)},onRestore:e=>i(e)},n.id))})]})}],986664);
3let eA=(0,ep.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);e.s(["Upload",0,eA],725981);let eM=(0,ep.default)("link-2-off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);e.s(["Link2Off",0,eM],792842)},331108,511633,e=>{"use strict";async function t(e){let t=await e.json().catch(()=>null);return Error(t?.error??`HTTP ${e.status}`)}async function s(){let e=await fetch("/api/shares",{cache:"no-store"});if(!e.ok)throw await t(e);return(await e.json()).shares}async function n(e){let s=await fetch(`/api/shares?chatId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!s.ok)throw await t(s);return(await s.json()).share}async function r(e,s={}){let n=await fetch("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatId:e,...s.expiresIn?{expiresIn:s.expiresIn}:{},...s.password?{password:s.password}:{},...s.access?{access:s.access}:{},...s.invitedEmails?.length?{invitedEmails:s.invitedEmails}:{}})});if(!n.ok)throw await t(n);return await n.json()}async function a(e){let s=await fetch("/api/shares",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({shareId:e})});if(!s.ok)throw await t(s);return(await s.json()).share}async function i(e){let s=await fetch("/api/shares",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({shareId:e})});if(!s.ok)throw await t(s);return(await s.json()).shares}e.s(["createShareApi",0,r,"deleteShareApi",0,i,"fetchShareForChat",0,n,"fetchShares",0,s,"updateShareApi",0,a],331108);let o=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;e.s(["MAX_SHARE_INVITEES",0,20,"MAX_SHARE_PASSWORD_LENGTH",0,128,"MIN_SHARE_PASSWORD_LENGTH",0,4,"SHARE_EMAIL_PATTERN",0,o,"SHARE_EXPIRY_PRESETS",0,[{id:"1h",label:"1 hour",seconds:3600},{id:"24h",label:"24 hours",seconds:86400},{id:"7d",label:"7 days",seconds:604800},{id:"30d",label:"30 days",seconds:2592e3}],"isShareExpired",0,function(e,t=Date.now()){return null!==e.expiresAt&&e.expiresAt<=t},"normalizeInvitedEmails",0,function(e){let t=new Set;for(let s of e){let e=s.trim().toLowerCase();e&&e.length<=320&&o.test(e)&&t.add(e)}return[...t]},"shareExpiryLabel",0,function(e,t=Date.now()){let s=e-t;if(s<=0)return"Expired";let n=Math.ceil(s/36e5);if(n<=1)return"Expires within the hour";if(n<48)return`Expires in ${n} hours`;let r=Math.round(n/24);return`Expires in ${r} day${1===r?"":"s"}`}],511633)},533056,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(711241),r=e.i(422768),a=e.i(762368),i=e.i(96315),o=e.i(573474),l=e.i(466787),d=e.i(725981),c=e.i(987968),u=e.i(846696),h=e.i(519455),m=e.i(793479),p=e.i(776639),x=e.i(522016),f=e.i(792842),g=e.i(806537),y=e.i(468590),b=e.i(487486),j=e.i(331108),v=e.i(511633);
3function w(){let[e,n]=(0,s.useState)(null),[r,a]=(0,s.useState)(null),[i,o]=(0,s.useState)(null);async function l(t){if(!confirm(`Delete the link for "${t.title}"? Deleting the link stops others viewing it. It does not delete the chat.`))return;o(t.id);let s=e??[];n(s.filter(e=>e.id!==t.id));try{n(await (0,j.deleteShareApi)(t.id)),u.toast.success("Link deleted",{description:"It no longer opens for anyone."})}catch(e){n(s),u.toast.error("Could not delete that link",{description:e instanceof Error?e.message:"Please try again."})}finally{o(null)}}return(0,s.useEffect)(()=>{let e=!0;return(0,j.fetchShares)().then(t=>{e&&(n(t),a(null))}).catch(t=>{e&&a(t instanceof Error?t.message:"Could not load shared links")}),()=>{e=!1}},[]),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:"Shared links"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Conversations published as a public link. Anyone holding a link can read the snapshot that was published - no account needed. Links are stored only as a hash, so they cannot be shown again here; open a chat to republish it or get a new link."}),r?(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r}),(0,t.jsx)(h.Button,{variant:"outline",size:"sm",className:"mt-3",onClick:function(){a(null),n(null),(0,j.fetchShares)().then(n).catch(e=>{a(e instanceof Error?e.message:"Could not load shared links")})},children:"Try again"})]}):null===e?(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(c.Spinner,{className:"size-4"}),"Loading…"]}):0===e.length?(0,t.jsxs)("div",{className:"mt-6 rounded-xl border border-dashed border-border/60 px-4 py-8 text-center",children:[(0,t.jsx)(f.Link2Off,{className:"mx-auto size-5 text-muted-foreground"}),(0,t.jsx)("p",{className:"mt-2 text-sm font-medium",children:"No shared links"}),(0,t.jsx)("p",{className:"mx-auto mt-1 max-w-sm text-xs text-muted-foreground",children:"Nothing in this workspace is published. Use Share on a chat to create a link you can send to anyone."})]}):(0,t.jsx)("ul",{className:"mt-6 space-y-1",children:e.map(e=>(0,t.jsx)(k,{link:e,revoking:i===e.id,onRevoke:()=>void l(e)},e.id))})]})}function k({link:e,revoking:s,onRevoke:n}){let r=(0,v.isShareExpired)(e);return(0,t.jsxs)("li",{className:"flex items-center gap-3 rounded-xl border border-border/60 px-3 py-2.5",children:[(0,t.jsx)("span",{className:`grid size-8 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground ${r?"opacity-50":""}`,children:(0,t.jsx)(y.MessageSquare,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,t.jsx)(x.default,{href:`/c/${e.chatId}`,className:`block truncate text-sm font-medium underline-offset-4 hover:underline ${r?"text-muted-foreground":""}`,title:`Open "${e.title}"`,children:e.title}),r&&(0,t.jsx)(b.Badge,{variant:"secondary",className:"shrink-0",children:"Expired"}),e.passwordProtected&&(0,t.jsx)(g.Lock,{className:"size-3 shrink-0 text-muted-foreground","aria-label":"Password protected"})]}),(0,t.jsxs)("span",{className:"block truncate text-xs text-muted-foreground",children:[r?"No longer opens - shared":"Shared"," ",new Date(e.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),e.updatedAt-e.createdAt>1e3&&(0,t.jsxs)(t.Fragment,{children:[" · updated ",new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]}),` \xb7 ${e.messageCount} message${1===e.messageCount?"":"s"}`,!r&&null!==e.expiresAt&&(0,t.jsxs)(t.Fragment,{children:[" · ",(0,v.shareExpiryLabel)(e.expiresAt).toLowerCase()]}),"invited"===e.access&&` \xb7 invited only (${e.invitedEmails.length})`,e.passwordProtected&&" · password protected"]})]}),(0,t.jsxs)(h.Button,{variant:"ghost",size:"sm",disabled:s,onClick:n,title:`Delete the link for "${e.title}"`,children:[s?(0,t.jsx)(c.Spinner,{}):null,"Delete link"]})]})}var N=e.i(920851);let S=(0,e.i(456420).default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);function C(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return"unknown";let s=Math.round((Date.now()-t)/6e4);if(s<1)return"just now";if(s<60)return`${s} minute${1===s?"":"s"} ago`;let n=Math.round(s/60);if(n<24)return`${n} hour${1===n?"":"s"} ago`;let r=Math.round(n/24);return 1===r?"yesterday":r<30?`${r} days ago`:new Date(t).toLocaleDateString()}
3function E(){let[e,n]=(0,s.useState)(null),[r,a]=(0,s.useState)(null),[i,o]=(0,s.useState)(null),l=(0,s.useCallback)(async()=>{let e=await fetch("/api/extension/tokens",{cache:"no-store"});if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).tokens??[]},[]);async function d(t){if(!confirm(`Disconnect ${t.label}? It will stop working immediately and will have to be connected again from the extension.`))return;o(t.id);let s=e??[];n(s.filter(e=>e.id!==t.id));try{let e=await fetch(`/api/extension/tokens?id=${encodeURIComponent(t.id)}`,{method:"DELETE"});if(!e.ok)throw Error(`HTTP ${e.status}`);u.toast.success("Extension disconnected",{description:"It can no longer reach your account."})}catch{n(s),u.toast.error("Could not disconnect that extension",{description:"Please try again."})}finally{o(null)}}return((0,s.useEffect)(()=>{let e=!0;return l().then(t=>{e&&(n(t),a(null))}).catch(()=>{e&&a("Could not load connected extensions")}),()=>{e=!1}},[l]),r)?(0,t.jsx)("p",{className:"py-4 text-sm text-muted-foreground",children:r}):null===e?(0,t.jsxs)("p",{className:"flex items-center gap-2 py-4 text-sm text-muted-foreground",children:[(0,t.jsx)(c.Spinner,{className:"size-4"}),"Loading…"]}):0===e.length?(0,t.jsx)("p",{className:"py-4 text-sm leading-relaxed text-muted-foreground",children:"No browser extensions are connected. Install the MultiAI extension and choose Connect inside it - connecting always starts from the extension, never from a link."}):(0,t.jsx)("ul",{className:"divide-y divide-border/60",children:e.map(e=>(0,t.jsxs)("li",{className:"flex items-start justify-between gap-6 py-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg border border-border/60 bg-muted/40 text-muted-foreground",children:(0,t.jsx)(N.Puzzle,{className:"size-4"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-sm",children:e.label}),(0,t.jsxs)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:["Connected ",C(e.createdAt),e.lastUsedAt?` . Last used ${C(e.lastUsedAt)}`:" . Not used yet"]})]})]}),(0,t.jsxs)(h.Button,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>void d(e),disabled:i===e.id,children:[i===e.id?(0,t.jsx)(c.Spinner,{className:"size-4"}):(0,t.jsx)(S,{}),"Disconnect"]})]},e.id))})}let T={chatgpt:"ChatGPT",claude:"Claude",gemini:"Gemini"};function A(e){let t=`${e.imported} chat${1===e.imported?"":"s"}`,s=e.skipped>0?` (${e.skipped} skipped)`:"";return`Imported ${t}${s}`}let M="DELETE";async function D(e){let t=await e.json().catch(()=>null);return Error(t?.error??`HTTP ${e.status}`)}async function _(){let e=await fetch("/api/account/export/otp",{method:"POST"});if(!e.ok)throw await D(e);return await e.json()}class z extends Error{reason;constructor(e,t){super(e),this.reason=t}}async function P(e,t){let s=await fetch("/api/account/export/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:e,code:t})});if(!s.ok){let e=await s.json().catch(()=>null),t=e?.reason==="expired"||e?.reason==="too-many-attempts"?e.reason:"wrong-code";throw new z(e?.error??`HTTP ${s.status}`,t)}return(await s.json()).token}async function O(e){let t=await fetch(`/api/account/export?token=${encodeURIComponent(e)}`);
3if(!t.ok)throw await D(t);let s=await t.blob(),n=t.headers.get("Content-Disposition")??"",r=/filename="([^"]+)"/.exec(n)?.[1]??"multiai-export.json",a=URL.createObjectURL(s),i=document.createElement("a");return i.href=a,i.download=r,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(a),r}async function L(){let e=await fetch("/api/chats/bulk",{cache:"no-store"});if(!e.ok)throw await D(e);return(await e.json()).scope}async function I(){let e=await fetch("/api/chats/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:M})});if(!e.ok)throw await D(e);return await e.json()}async function R(e){let t=new FormData;t.append("file",e);let s=await fetch("/api/account/import",{method:"POST",body:t});if(!s.ok)throw await D(s);return(await s.json()).result}var $=e.i(852091);function B({onManage:e}){return(0,t.jsx)(Y,{label:"Shared links",hint:"Conversations you have published as a public link. Review them and stop any that should no longer be readable.",children:(0,t.jsx)(h.Button,{variant:"outline",size:"sm",onClick:e,children:"Manage"})})}function F({onManage:e}){return(0,t.jsx)(Y,{label:"Connected extensions",hint:"Browser extensions signed in to this account. Each one holds its own credential, not your password and not your browser session, so disconnecting one here stops it immediately without touching anything else.",children:(0,t.jsx)(h.Button,{variant:"outline",size:"sm",onClick:e,children:"Manage"})})}function U(){let[e,n]=(0,s.useState)(!1);return(0,t.jsxs)(Y,{label:"Export data",hint:"Downloads one JSON file with every conversation and its messages (text, role, model, timestamps, credits and tokens), plus your projects and saved prompts. Attachments are listed by name, type and size - the files themselves are not included.",children:[(0,t.jsxs)(h.Button,{variant:"outline",size:"sm",onClick:()=>n(!0),children:[(0,t.jsx)(a.Download,{}),"Export"]}),(0,t.jsx)(H,{open:e,onOpenChange:n})]})}function H({open:e,onOpenChange:n}
3){let[r,a]=(0,s.useState)("intro"),[o,l]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[x,f]=(0,s.useState)(""),[g,y]=(0,s.useState)(null),[b,j]=(0,s.useState)(null),[v,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(null),[S,C]=(0,s.useState)(0);function E(e){"exporting"!==r&&(e||(a("intro"),u(null),f(""),y(null),j(null),w(!1),N(null)),n(e))}async function T(){if(!o){l(!0),j(null),w(!1);try{let e=await _();u(e),f(""),C(30),a("code")}catch(e){j(e instanceof Error?e.message:"Please try again.")}finally{l(!1)}}}async function A(){if(!o&&d&&6===x.length){l(!0),j(null);try{let e=await P(d.challenge,x);y(e),a("confirm")}catch(e){e instanceof z?(j(e.message),"wrong-code"!==e.reason&&w(!0)):j(e instanceof Error?e.message:"Please try again.")}finally{l(!1)}}}async function M(){if(g){a("exporting"),j(null);try{let e=await O(g);N(e),a("done")}catch(e){a("intro"),y(null),j(e instanceof Error?e.message:"The export failed. Please try again.")}}}return(0,s.useEffect)(()=>{if(S<=0)return;let e=setInterval(()=>C(e=>e-1),1e3);return()=>clearInterval(e)},[S]),(0,t.jsx)(p.Dialog,{open:e,onOpenChange:E,children:(0,t.jsxs)(p.DialogContent,{className:"sm:max-w-md",children:["intro"===r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsx)(p.DialogTitle,{children:"Export your data"}),(0,t.jsx)(p.DialogDescription,{children:"First, let's confirm it's you: we'll email a 6-digit code to your account address. Your export unlocks once you enter it."})]}),b&&(0,t.jsx)(K,{message:b}),(0,t.jsxs)(p.DialogFooter,{children:[(0,t.jsx)(p.DialogClose,{render:(0,t.jsx)(h.Button,{variant:"outline",disabled:o}),children:"Cancel"}),(0,t.jsx)(h.Button,{disabled:o,onClick:()=>void T(),children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.Spinner,{}),"Sending…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.Mail,{}),"Email me a code"]})})]})]}),"code"===r&&d&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsx)(p.DialogTitle,{children:"Enter your code"}),(0,t.jsxs)(p.DialogDescription,{children:["We sent a 6-digit code to"," ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:d.sentTo}),". It expires in ",d.expiresInMinutes," minutes."]})]}),d.devCode&&(0,t.jsxs)("p",{className:"rounded-lg bg-muted/60 px-3 py-2 font-mono text-xs text-muted-foreground",children:["Dev (no SMTP): your code is ",d.devCode]}),(0,t.jsx)(m.Input,{value:x,onChange:e=>{f(e.target.value.replace(/\D/g,"").slice(0,6)),j(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),A())},disabled:o||v,autoFocus:!0,autoComplete:"one-time-code",inputMode:"numeric",placeholder:"000000","aria-label":"6-digit export code",className:"text-center font-mono text-lg tracking-[0.5em]"}),b&&(0,t.jsx)(K,{message:b}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("button",{type:"button",disabled:o||S>0,onClick:()=>void T(),className:"text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-default disabled:opacity-60",children:S>0?`Resend code in ${S}s`:"Resend code"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(p.DialogClose,{render:(0,t.jsx)(h.Button,{variant:"outline",disabled:o}),children:"Cancel"}),(0,t.jsx)(h.Button,{disabled:o||6!==x.length||v,onClick:()=>void A(),children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.Spinner,{}),"Verifying…"]}):"Verify"})]})]})]}),"confirm"===r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.DialogHeader,{children:(0,t.jsx)(p.DialogTitle,{children:"Request data export - are you sure?"})}),(0,t.jsxs)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,t.jsx)(q,{children:"Your account details, every conversation, your projects and saved prompts will be included."}),(0,t.jsxs)(q,{children:["Everything arrives as"," ",(0,t.jsx)("span",{className:"text-foreground",children:"one JSON file"}),", downloaded straight to this device - it is not emailed or stored anywhere else."]}),(0,t.jsx)(q,{children:"Attachments are listed by name, type and size; the files themselves are not included."}),(0,t.jsx)(q,{children:"Preparing may take a moment for a large workspace. Leave this window open while it runs."})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"To proceed, click “Confirm export” below."}),(0,t.jsxs)(p.DialogFooter,{children:[(0,t.jsx)(p.DialogClose,{render:(0,t.jsx)(h.Button,{variant:"outline"}),children:"Cancel"}),(0,t.jsx)(h.Button,{onClick:()=>void M(),children:"Confirm export"})]})]}),"exporting"===r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsx)(p.DialogTitle,{children:"Preparing your export…"}),(0,t.jsx)(p.DialogDescription,{children:"Gathering every conversation, project and prompt into one file. The download starts on its own when it's ready."})]}),(0,t.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,t.jsx)(c.Spinner,{className:"size-6"})})]}),"done"===r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsx)(p.DialogTitle,{children:"Your export has downloaded"}),(0,t.jsx)(p.DialogDescription,{children:k?(0,t.jsxs)(t.Fragment,{children:["Saved as"," ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:k})," ","in your downloads."]}):"Check your downloads folder."})]}),(0,t.jsx)(p.DialogFooter,{children:(0,t.jsx)(h.Button,{onClick:()=>E(!1),children:"Done"})})]})]})})}function q({children:e}){return(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-foreground
3/60"}),(0,t.jsx)("span",{children:e})]})}function K({message:e}){return(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-3 dark:bg-destructive/10",children:[(0,t.jsx)(r.CircleAlert,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),(0,t.jsx)("p",{className:"text-xs leading-relaxed text-destructive",children:e})]})}function W(){let e=(0,s.useRef)(null),[n,a]=(0,s.useState)(!1),[i,o]=(0,s.useState)(null),[l,m]=(0,s.useState)(null);async function p(e){if(!n){a(!0),m(null),o(null);try{let t=await R(e);o(t),u.toast.success(A(t),{description:`${t.messages.toLocaleString()} messages from ${T[t.source]}. They are in your chat list now.`})}catch(t){let e=t instanceof Error?t.message:"Please try again.";m(e),u.toast.error("Could not import that file",{description:e})}finally{a(!1)}}}return(0,t.jsxs)("div",{className:"border-b border-border/60 py-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-6",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Import chats"}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:["Bring your history over from ChatGPT, Claude or Google Gemini. Export your data there, unzip it, and upload the"," ",(0,t.jsx)("code",{className:"font-mono",children:"conversations.json"})," (ChatGPT, Claude) or ",(0,t.jsx)("code",{className:"font-mono",children:"MyActivity.json"})," ","(Gemini) file - we work out which one it is. For Gemini, request your data at takeout.google.com under My Activity → Gemini Apps, with the activity record format set to JSON. Imported chats keep their titles and dates and are searchable like any other."]})]}),(0,t.jsxs)("div",{className:"shrink-0",children:[(0,t.jsx)("input",{ref:e,type:"file",accept:".json,application/json",className:"hidden",disabled:n,onChange:e=>{let t=e.target.files?.[0];e.target.value="",t&&p(t)}}),(0,t.jsxs)(h.Button,{variant:"outline",size:"sm",disabled:n,onClick:()=>e.current?.click(),children:[n?(0,t.jsx)(c.Spinner,{}):(0,t.jsx)(d.Upload,{}),n?"Importing…":"Choose file"]})]})]}),n&&(0,t.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"Reading your export and creating the chats. A few years of history can take a minute - leave this open."}),i&&!n&&(0,t.jsxs)("div",{className:"mt-3 rounded-xl border border-border/60 bg-muted/40 p-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:A(i)}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:[i.messages.toLocaleString()," message",1===i.messages?"":"s"," from"," ",T[i.source],".","gemini"===i.source&&" Gemini's Takeout file is an activity log rather than full conversations, so each prompt and its reply became one chat.",i.skipped>0&&" Skipped conversations had no readable text - nothing was lost from the ones that imported.",i.truncated&&" This export was larger than one import can take, so the rest was left out - upload it again to continue."," ","Assistant replies show no model, because the export doesn't say which one answered."]})]}),l&&!n&&(0,t.jsxs)("div",{className:"mt-3 flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-3 dark:bg-destructive/10",children:[(0,t.jsx)(r.CircleAlert,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),(0,t.jsx)("p",{className:"text-xs leading-relaxed text-destructive",children:l})]}),(0,t.jsxs)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:["Up to ","64.0 MB"," per file. Nothing is sent to a model - the file is read and stored, that is all."]})]})}
3function V(){let[e,n]=(0,s.useState)(null),[r,a]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!0;return L().then(t=>{e&&n(t)}).catch(()=>{}),()=>{e=!1}},[]);let i=e?.chats===0;return(0,t.jsxs)("div",{className:"mt-6 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-sm font-medium text-destructive",children:[(0,t.jsx)(l.TriangleAlert,{className:"size-4"}),"Danger zone"]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Delete all chats"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:null===e?"Removes every conversation in this workspace, for everyone in it.":i?"There are no chats in this workspace to delete.":`Removes all ${e.chats.toLocaleString()} conversation${1===e.chats?"":"s"} in this workspace, for everyone in it. Your saved prompts, projects and credits are untouched.`})]}),(0,t.jsxs)(h.Button,{variant:"destructive",size:"sm",className:"shrink-0",disabled:i,onClick:()=>a(!0),children:[(0,t.jsx)(o.Trash2,{}),"Delete all"]})]}),(0,t.jsx)(J,{open:r,onOpenChange:a,scope:e})]})}function J({open:e,onOpenChange:n,scope:r}){let[a,i]=(0,s.useState)(""),[o,l]=(0,s.useState)(!1),[d,x]=(0,s.useState)(null),f=a===M&&!o;async function g(){if(a===M&&!o){l(!0);try{let e=await I();x(e.deleted)}catch(e){u.toast.error("Could not delete your chats",{description:e instanceof Error?e.message:"Please try again."}),l(!1)}}}return(0,t.jsx)(p.Dialog,{open:e,onOpenChange:e=>{o||null!==d||(e||i(""),n(e))},children:(0,t.jsx)(p.DialogContent,{className:"sm:max-w-md",children:null!==d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsxs)(p.DialogTitle,{children:["Deleted ",d.toLocaleString()," chat",1===d?"":"s"]}),(0,t.jsx)(p.DialogDescription,{children:"Your prompts, projects and credits were not touched."})]}),(0,t.jsx)(p.DialogFooter,{children:(0,t.jsx)(h.Button,{onClick:()=>window.location.assign("/"),children:"Done"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(p.DialogHeader,{children:[(0,t.jsx)(p.DialogTitle,{className:"text-destructive",children:"Delete all chats?"}),(0,t.jsx)(p.DialogDescription,{children:r&&r.chats>0?`This removes all ${r.chats.toLocaleString()} conversation${1===r.chats?"":"s"} in this workspace. It can't be undone from here.`:"This removes every conversation in this workspace. It can't be undone from here."})]}),(0,t.jsxs)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-destructive"}),(0,t.jsxs)("span",{children:["Every conversation disappears"," ",(0,t.jsx)("span",{className:"text-foreground",children:"for everyone in this workspace"}),", not just for you."]})]}),(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-destructive"}),(0,t.jsx)("span",{children:r&&r.sharedLinks>0?(0,t.jsxs)(t.Fragment,{children:["Your"," ",(0,t.jsxs)("span",{className:"text-foreground",children:[r.sharedLinks," shared link",1===r.sharedLinks?"":"s"]})," ","stop opening - anyone holding one sees a missing page."]}):(0,t.jsxs)(t.Fragment,{children:["Any ",(0,t.jsx)("span",{className:"text-foreground",children:"shared links"})," to these chats stop opening."]})})]}),(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-destructive"}),(0,t.jsxs)("span",{children:["Your ",(0,t.jsx)("span",{className:"text-foreground",children:"prompts, projects and credits"})," ","are kept. Only chats and their messages go."]})]})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{htmlFor:"delete-all-confirm",className:"text-sm",children:["Type"," ",(0,t.jsx)("span",{className:"font-mono font-medium text-foreground",children:M})," ","to confirm"]}
3),(0,t.jsx)(m.Input,{id:"delete-all-confirm",value:a,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),g())},disabled:o,autoComplete:"off",autoFocus:!0,placeholder:M,"aria-label":`Type ${M} to confirm deleting all chats`})]}),(0,t.jsxs)(p.DialogFooter,{children:[(0,t.jsx)(p.DialogClose,{render:(0,t.jsx)(h.Button,{variant:"outline",disabled:o}),children:"Cancel"}),(0,t.jsx)(h.Button,{variant:"destructive",disabled:!f,onClick:()=>void g(),children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.Spinner,{}),"Deleting…"]}):"Delete all chats"})]})]})})})}function Y({label:e,hint:s,children:n}){return(0,t.jsxs)("div",{className:"flex items-start justify-between gap-6 border-b border-border/60 py-4",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:e}),s&&(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:s})]}),(0,t.jsx)("div",{className:"shrink-0",children:n})]})}e.s(["DataSection",0,function(){let[e,r]=(0,s.useState)("root");return"shares"===e?(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r("root"),className:"mb-3 inline-flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(n.ArrowLeft,{className:"size-3.5"}),"Data controls"]}),(0,t.jsx)(w,{})]}):"extensions"===e?(0,t.jsxs)("div",{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>r("root"),className:"mb-3 inline-flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(n.ArrowLeft,{className:"size-3.5"}),"Data controls"]}),(0,t.jsx)(E,{})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"border-b border-border/60 pb-3 text-base font-medium",children:"Data controls"}),(0,t.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:["Your conversations belong to you. Take a copy whenever you like, bring your history over from another assistant, and clear it all out on your terms. ",(0,t.jsx)($.DocsLink,{slug:"your-data"})]}),(0,t.jsx)(B,{onManage:()=>r("shares")}),(0,t.jsx)(F,{onManage:()=>r("extensions")}),(0,t.jsx)(U,{}),(0,t.jsx)(W,{}),(0,t.jsx)(V,{})]})}],533056)},222610,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(466787),r=e.i(987968),a=e.i(522016),i=e.i(14358),o=e.i(328623);let l=(0,e.i(456420).default)("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]]);var d=e.i(882303),c=e.i(938727),u=e.i(464987),h=e.i(307730),m=e.i(886043);function p({summary:e}){let s=(0,u.formatDayLabel)(e.cycleStart),n=e.cycleGrantedMillicredits>0?`${(0,h.formatWholeCredits)(e.cycleGrantedMillicredits)} granted on ${s}`:"No credit grant on record yet";return(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,t.jsx)(c.StatCard,{label:"Credit balance",value:(0,h.formatWholeCredits)(e.balanceMillicredits),icon:(0,t.jsx)(i.CircleDollarSign,{className:"size-4"}),sub:e.trialExpiresAt?`Trial credits expire ${(0,u.formatDayLabel)(e.trialExpiresAt)}`:n}),(0,t.jsx)(c.StatCard,{label:"Plan",value:e.planName,icon:(0,t.jsx)(o.Sparkles,{className:"size-4"}),sub:(0,m.canUpgrade)(e.plan)?(0,t.jsx)(a.default,{href:"/pricing",className:"font-medium text-foreground underline-offset-4 hover:underline",children:"See plans"}):"Credits are a shared workspace pool"}),(0,t.jsx)(c.StatCard,{label:"Used this cycle",value:(0,h.formatWholeCredits)(e.cycleUsedMillicredits),icon:(0,t.jsx)(l,{className:"size-4"}),sub:e.cycleFromGrant?`Since your last grant on ${s}`:`Since this workspace was created on ${s}`}),(0,t.jsx)(c.StatCard,{label:"Team",value:e.members,icon:(0,t.jsx)(d.Users,{className:"size-4"}),sub:[`${1===e.members?"1 seat":`${e.members} seats`} in use`,e.pendingInvites>0?`${e.pendingInvites} ${1===e.pendingInvites?"invite":"invites"} pending`:null].filter(Boolean).join(" · ")})]})}var x=e.i(88478),f=e.i(150858),g=e.i(852091);async function y(){let e=await fetch(`/api/usage?days=${f.DEFAULT_USAGE_RANGE}&full=1`,{cache:"no-store",headers:{accept:"application/json"}});if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}function b(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Usage"}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Credits and requests this workspace has used. Everyone here draws from the same credit pool. ",(0,t.jsx)(g.DocsLink,{slug:"how-credits-work"})]})]})}e.s(["UsageSection",0,function({enabled:e=!0}
3){let[a,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),[d,c]=(0,s.useState)(""),[u,h]=(0,s.useState)(null);function m(e){h(null),l(e.summary),c(e.you),i({range:e.range,series:e.series,models:e.models,members:e.members})}let f=(0,s.useCallback)(()=>{y().then(m).catch(e=>h(e instanceof Error?e.message:"Could not load usage"))},[]);return((0,s.useEffect)(()=>{if(!e)return;let t=!0;return y().then(e=>{t&&m(e)}).catch(e=>{t&&h(e instanceof Error?e.message:"Could not load usage")}),()=>{t=!1}},[e]),u)?(0,t.jsxs)("div",{children:[(0,t.jsx)(b,{}),(0,t.jsxs)("div",{className:"mt-4 flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/5 p-3 text-[13px] text-destructive",children:[(0,t.jsx)(n.TriangleAlert,{className:"mt-0.5 size-4 shrink-0"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("p",{children:u}),(0,t.jsx)("button",{type:"button",onClick:()=>void f(),className:"mt-1.5 font-medium underline underline-offset-2",children:"Try again"})]})]})]}):a&&o?(0,t.jsxs)("div",{children:[(0,t.jsx)(b,{}),(0,t.jsxs)("div",{className:"mt-4 flex flex-col gap-3",children:[(0,t.jsx)(p,{summary:o}),(0,t.jsx)(x.UsageDashboard,{initial:a,currentUserId:d})]})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)(b,{}),(0,t.jsxs)("div",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(r.Spinner,{className:"size-4"}),"Loading usage…"]})]})}],222610)},379925,701343,832284,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(856423),r=e.i(226091),a=e.i(77071),i=e.i(573474),o=e.i(466787),l=e.i(846696),d=e.i(987968),c=e.i(519455),u=e.i(725015),h=e.i(289868),m=e.i(801890),p=e.i(699375),x=e.i(852091),f=e.i(912505);e.s(["KnowledgeSection",0,function(){let[e,g]=(0,s.useState)([]),[y,b]=(0,s.useState)(!1),[j,v]=(0,s.useState)(!1),[w,k]=(0,s.useState)(null),[N,S]=(0,s.useState)([]),[C,E]=(0,s.useState)(0),T=(0,s.useRef)(null),A=(0,s.useCallback)(()=>E(e=>e+1),[]);async function M(e){if(0!==e.length)for(let t of(S(t=>[...t,...e.map(e=>e.name)]),e))try{g(await (0,m.addSource)(t)),l.toast.success(`${t.name} added`,{description:"Its text is indexed and the file itself has been discarded - chats here can use it now."})}catch(s){let e=s instanceof m.KnowledgeError&&402===s.status;l.toast.error(`Could not add ${t.name}`,{description:e?"Indexing a document costs a small amount of credits, and this workspace is out.":s instanceof Error?s.message:"Please try again."})}finally{S(e=>e.filter(e=>e!==t.name))}}async function D(t){if(confirm(`Remove "${t.filename}" from the knowledge base? Its text and passages are deleted and chats stop being able to draw on it. (The file itself was never stored.)`)){g(e=>e.filter(e=>e.id!==t.id));try{await (0,m.removeSourceApi)(t.id),l.toast.success(`${t.filename} removed`)}catch(t){g(e),l.toast.error("Could not remove that document",{description:t instanceof Error?t.message:"Please try again."})}}}return(0,s.useEffect)(()=>{let e=!0;return(0,m.fetchKnowledge)().then(t=>{e&&(g(t.sources),b(t.enabled),k(null),v(!0))}).catch(t=>{e&&(k(t instanceof Error?t.message:"Could not load the knowledge base"),v(!0))}),()=>{e=!1}},[C]),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Knowledge"}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Your team’s shared documents, added once and available to every chat here. We keep the text we read, never the file itself. Up to about 100 pages a document. ",(0,t.jsx)(x.DocsLink,{slug:"knowledge-base"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Use the knowledge base"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:y?"Chats here can draw on these documents. Turn this off to pause it without removing anything.":"Off. Your documents stay indexed, but no chat draws on them and the control is hidden in the composer."})]}),(0,t.jsx)(p.Switch,{on:y,onChange:e=>{b(e),(0,m.setKnowledgeEnabledApi)(e).catch(e=>{b(y),l.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Use the knowledge base"})]}),(0,t.jsxs)("div",{className:"mt-4 flex justify-end",children:[(0,t.jsx)("input",{ref:T,type:"file",multiple:!0,accept:(0,u.acceptAttribute)(),className:"hidden",onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value="",M(t)}}),(0,t.jsxs)(c.Button,{size:"sm",onClick:()=>T.current?.click(),children:[(0,t.jsx)(a.Plus,{}),"Add document"]})]}),j?w?(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-destructive",children:[(0,t.jsx)(o.TriangleAlert,{className:"size-4"}),w]}),(0,t.jsx)(c.Button,{variant:"outline",size:"sm",onClick:A,children:"Try again"})]}):0===e.length&&0===N.length?(0,t.jsx)(f.EmptyState,{className:"mt-8",icon:n.BookOpen,title:"No documents yet",hint:"Add the handful of files your team keeps re-explaining to the AI. PDFs, Word documents, spreadsheets, slides, code and plain text all work - anything we can read text out of."}):(0,t.jsxs)("ul",{className:"mt-4 space-y-2",children:[N.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-3 rounded-xl border border-border/60 px-3 py-2.5",children:[(0,t.jsx)(d.Spinner,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate text-sm",children:e}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Reading and indexing…"})]})]},`busy-${e}`)),e.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-3 rounded-xl border border-border/60 px-3 py-2.5",children:[(0,t.jsx)("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-muted text-muted-foreground",children:(0,t.jsx)(r.FileText,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate text-sm",children:e.filename}),(0,t.jsxs)("span",{className:`block text-xs ${"ready"===e.status||"pending"===e.status?"text-muted-foreground":"text-destructive"}`,children:[function(e){switch(e.status){case"ready":return e.truncated?`First ~100 pages indexed (${e.chunks} passages) - the rest was too long to read`:`${e.chunks} passage${1===e.chunks?"":"s"} indexed`;
3case"pending":return"Indexing…";case"unsupported":return"No readable text in this file";case"failed":return"Indexing failed - remove and try again"}}(e)," · ",(0,h.formatBytes)(e.sizeBytes)]})]}),(0,t.jsx)("button",{type:"button","aria-label":`Remove ${e.filename}`,onClick:()=>void D(e),className:"grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-destructive active:scale-90",children:(0,t.jsx)(i.Trash2,{className:"size-4"})})]},e.id))]}):(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(d.Spinner,{className:"size-4"}),"Loading…"]})]})}],379925);var g=e.i(262633),y=e.i(689664),b=e.i(515281),j=e.i(263676),v=e.i(776639),w=e.i(793479);class k extends Error{status;constructor(e,t){super(e),this.status=t,this.name="MemoryError"}}async function N(e){let t=await e.json().catch(()=>null);throw new k(t?.error??`Request failed (${e.status})`,e.status)}async function S(){let e=await fetch("/api/memories",{cache:"no-store"});e.ok||await N(e);let t=await e.json();return{facts:t.facts,enabled:!0===t.enabled,saveEnabled:!0===t.saveEnabled,sensitiveEnabled:!0===t.sensitiveEnabled,chatSearchEnabled:!0===t.chatSearchEnabled}}async function C(e){let t=await fetch("/api/memories",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:e})});t.ok||await N(t)}async function E(e){let t=await fetch("/api/memories",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({saveEnabled:e})});t.ok||await N(t)}async function T(e){let t=await fetch("/api/memories",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({sensitiveEnabled:e})});t.ok||await N(t)}async function A(e){let t=await fetch("/api/memories",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({chatSearchEnabled:e})});t.ok||await N(t)}async function M(e){let t=await fetch("/api/memories",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({content:e})});return t.ok||await N(t),(await t.json()).facts}async function D(e,t){let s=await fetch(`/api/memories/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({content:t})});s.ok||await N(s)}async function _(e){let t=await fetch(`/api/memories/${e}`,{method:"DELETE"});t.ok||await N(t)}async function z(){let e=await fetch("/api/memories",{method:"DELETE"});e.ok||await N(e)}async function P(e){try{let t=await fetch("/api/memories/extract",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0});if(!t.ok)return{applied:0,sensitive:0};let s=await t.json();return{applied:"number"==typeof s.applied?s.applied:0,sensitive:"number"==typeof s.sensitive?s.sensitive:0}}catch{return{applied:0,sensitive:0}}}e.s(["MemoryError",0,k,"addMemoryApi",0,M,"clearMemoriesApi",0,z,"extractMemoryApi",0,P,"fetchMemory",0,S,"removeMemoryApi",0,_,"setChatSearchEnabledApi",0,A,"setMemoryEnabledApi",0,C,"setMemorySaveEnabledApi",0,E,"setMemorySensitiveEnabledApi",0,T,"updateMemoryApi",0,D],701343),e.s(["MemorySection",0,function(){let[e,n]=(0,s.useState)([]),[r,u]=(0,s.useState)(!1),[h,m]=(0,s.useState)(!1),[N,P]=(0,s.useState)(!1),[O,L]=(0,s.useState)(!1),[I,R]=(0,s.useState)(!1),[$,B]=(0,s.use
3State)(!1),[F,U]=(0,s.useState)(null),[H,q]=(0,s.useState)(0),[K,W]=(0,s.useState)(null),[V,J]=(0,s.useState)(""),[Y,G]=(0,s.useState)(""),[X,Q]=(0,s.useState)(!1),Z=(0,s.useCallback)(()=>q(e=>e+1),[]);async function ee(){let e=Y.trim();if(e&&!X){Q(!0);try{n(await M(e)),G("")}catch(t){let e=t instanceof k&&409===t.status;l.toast.error(e?"Memory is full":"Could not save that",{description:e?"Remove a memory you no longer need before adding another.":t instanceof Error?t.message:"Please try again."})}finally{Q(!1)}}}async function et(t){let s=V.trim();if(W(null),s&&s!==t.content){n(e=>e.map(e=>e.id===t.id?{...e,content:s}:e));try{await D(t.id,s)}catch(t){n(e),l.toast.error("Could not save that change",{description:t instanceof Error?t.message:"Please try again."})}}}async function es(t){n(e=>e.filter(e=>e.id!==t.id));try{await _(t.id)}catch(t){n(e),l.toast.error("Could not forget that",{description:t instanceof Error?t.message:"Please try again."})}}async function en(){if(confirm(`Forget all ${e.length} memories? They are deleted permanently and the AI starts from a blank slate. (The switches are untouched.)`)){n([]);try{await z(),l.toast.success("All memories forgotten")}catch(t){n(e),l.toast.error("Could not clear your memory",{description:t instanceof Error?t.message:"Please try again."})}}}return(0,s.useEffect)(()=>{let e=!0;return S().then(t=>{e&&(n(t.facts),u(t.enabled),m(t.saveEnabled),P(t.sensitiveEnabled),L(t.chatSearchEnabled),U(null),B(!0))}).catch(t=>{e&&(U(t instanceof Error?t.message:"Could not load your memory"),B(!0))}),()=>{e=!1}},[H]),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-medium",children:"Memory"}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Useful facts the AI picks up from your chats and carries into future ones - your preferences, your work, your projects. Yours alone: only you see them, and every model you talk to here shares them."," ",(0,t.jsx)(x.DocsLink,{slug:"memory"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Save new memories"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:h?"After a chat, useful details about you are saved to your memories. Turn this off to stop learning without forgetting anything.":"Off. Nothing new is learned from your chats. What is already saved stays, and is still used while the switch below is on."})]}),(0,t.jsx)(p.Switch,{on:h,onChange:e=>{m(e),E(e).catch(e=>{m(h),l.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Save new memories"})]}),(0,t.jsx)("div",{className:`ml-4 border-l border-border/60 pl-3 transition-opacity duration-200 ${h?"":"opacity-50"}`,children:(0,t.jsxs)("div",{className:"mt-2 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Include sensitive topics"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:h?N?"Health, beliefs, politics, gender identity, sexuality and precise location can be saved. New chats only, and you are told each time one is saved.":"Off. Nothing about health, beliefs, politics, gender identity, sexuality or precise location is saved, even if you ask for it in a chat. You can still add such a fact yourself under Manage.":"Saving is off, so nothing is learned from your chats either way. Turn saving back on and this decides whether sensitive topics are included."})]}),(0,t.jsx)(p.Switch,{on:N,onChange:e=>{P(e),T(e).catch(e=>{P(N),l.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Include sensitive topics"})]})}),(0,t.jsxs)("div",{className:"mt-3 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Use memories"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:r?"Your saved memories automatically shape every answer, on every model. Turn this off to pause that without deleting anything.":"Off. Your saved memories are kept, but no model is told about them."})]}),(0,t.jsx)(p.Switch,{on:r,onChange:e=>{u(e),C(e).catch(e=>{u(r),l.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Use memories"})]}),(0,t.jsxs)("div",{className:"mt-3 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Search past chats"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:O?"In Agent mode, the AI can search your past conversations here to recall earlier decisions and discussions.":"Off. In Agent mode, the AI cannot look anything up in your past conversations."})]}),(0,t.jsx)(p.Switch,{on:O,onChange:e=>{L(e),A(e).catch(e=>{L(O),l.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Search past chats"})]}),(0,t.jsxs)("div",{className:"mt-3 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Your memories"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:$?F?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-destructive",children:[(0,t.jsx)(o.TriangleAlert,{className:"size-3.5"}),F]}):0===e.length?"Nothing saved yet. See, edit and delete everything the AI remembers - or add something yourself.":`${e.length} ${1===e.length?"memory":"memories"} saved. See, edit and delete everything the AI remembers.`:"Loading…"})]}),F?(0,t.jsx)(c.Button,{variant:"outline",size:"sm",onClick:Z,className:"shrink-0",children:"Try again"}):(0,t.jsx)(c.Button,{variant:"outline",size:"sm",onClick:()=>R(!0),disabled:!$,className:"shrink-0",children:$?"Manage":(0,t.jsx)(d.Spinner,{className:"size-4"})})]}),(0,t.jsx)(v.Dialog,{open:I,onOpenChange:R,children:(0,t.jsxs)(v.DialogContent,{className:"sm:max-w-lg",children:[(0,t.jsxs)(v.DialogHeader,{children:[(0,t.jsx)(v.DialogTitle,{children:"Your memories"}),(0,t.jsx)(v.DialogDescription,{children:"Everything the AI remembers about you - edit or delete any of it, any time. Models are told exactly this list, nothing more."})]}),(0,t.jsxs)("form",{className:"flex items-center gap-2",onSubmit:e=>{e.preventDefault(),ee()},children:[(0,t.jsx)(w.Input,{value:Y,onChange:e=>G(e.target.value),maxLength:400,placeholder:"Add something to remember, e.g. “Answers in French, please”","aria-label":"Add a memory"}),(0,t.jsxs)(c.Button,{size:"sm",type:"submit",disabled:!Y.trim()||X,children:[X?(0,t.jsx)(d.Spinner,{className:"size-4"}):(0,t.jsx)(a.Plus,{}),"Add"]})]}),0===e.length?(0,t.jsx)(f.EmptyState,{className:"my-6",icon:g.Brain,title:"Nothing remembered yet",hint:h?"As you chat, useful details get saved here automatically - or add one yourself above.":"Saving is off, so chats teach nothing - add one yourself above, or turn on Save new memories."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("ul",{className:`max-h-[50vh] space-y-2 overflow-y-auto pr-1 ${r?"":"op
3acity-50"}`,children:e.map(e=>(0,t.jsx)("li",{className:"flex items-center gap-3 rounded-xl border border-border/60 px-3 py-2.5",children:K===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.Input,{autoFocus:!0,value:V,onChange:e=>J(e.target.value),maxLength:400,"aria-label":"Edit this memory",onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),et(e)),"Escape"===t.key&&W(null)}}),(0,t.jsx)("button",{type:"button","aria-label":"Save the change",onClick:()=>void et(e),className:"grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90",children:(0,t.jsx)(y.Check,{className:"size-4"})}),(0,t.jsx)("button",{type:"button","aria-label":"Discard the change",onClick:()=>W(null),className:"grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90",children:(0,t.jsx)(j.X,{className:"size-4"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm",children:e.content}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:new Date(e.updatedAt).toLocaleDateString()})]}),(0,t.jsx)("button",{type:"button","aria-label":"Edit this memory",onClick:()=>{W(e.id),J(e.content)},className:"grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground active:scale-90",children:(0,t.jsx)(b.Pencil,{className:"size-4"})}),(0,t.jsx)("button",{type:"button","aria-label":"Forget this memory",onClick:()=>void es(e),className:"grid size-8 shrink-0 place-items-center rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-destructive active:scale-90",children:(0,t.jsx)(i.Trash2,{className:"size-4"})})]})},e.id))}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:()=>void en(),children:[(0,t.jsx)(i.Trash2,{}),"Forget everything"]})})]})]})})]})}],832284)},715465,697214,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(470533),r=e.i(515281),a=e.i(77071),i=e.i(573474),o=e.i(466787),l=e.i(263676),d=e.i(987968),c=e.i(846696),u=e.i(519455),h=e.i(793479),m=e.i(624687),p=e.i(202764),x=e.i(721132),f=e.i(852091),g=e.i(699375);function y({prompt:e,editable:s,mine:n,onEdit:a,onDelete:o}){return(0,t.jsx)("li",{className:"rounded-xl border border-border/60 px-3 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm font-medium",children:e.title}),(0,t.jsx)("p",{className:"mt-0.5 line-clamp-2 whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:e.body}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[n?"Saved by you":`Saved by ${e.createdByName??"a former teammate"}`," · ",new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]}),s&&(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:a,title:`Edit "${e.title}"`,"aria-label":`Edit "${e.title}"`,className:"grid size-7 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(r.Pencil,{className:"size-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:()=>void o(),title:`Delete "${e.title}"`,"aria-label":`Delete "${e.title}"`,className:"grid size-7 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:(0,t.jsx)(i.Trash2,{className:"size-3.5"})})]})]})})}function b({initialTitle:e,initialBody:n,submitLabel:r,onSubmit:a,onCancel:i,failureMessage:o,className:x=""}){let[f,g]=(0,s.useState)(e),[y,j]=(0,s.useState)(n),[v,w]=(0,s.useState)(!1),k=f.trim().length>0&&y.trim().length>0&&!v;async function N(){if(k){w(!0);try{await a(f.trim(),y.trim())}catch(e){c.toast.error(o,{description:e instanceof Error?e.message:"Please try again."}),w(!1)}}}return(0,t.jsxs)("div",{className:`rounded-xl border border-border/60 bg-muted/30 p-3 ${x}`,children:[(0,t.jsx)(h.Input,{value:f,onChange:e=>g(e.target.value),maxLength:p.PROMPT_TITLE_MAX,placeholder:"Prompt name","aria-label":"Prompt name",autoFocus:!0}),(0,t.jsx)(m.Textarea,{value:y,onChange:e=>j(e.target.value),maxLength:p.PROMPT_BODY_MAX,rows:5,placeholder:"The prompt text your teammates will reuse…","aria-label":"Prompt text",className:"mt-2 max-h-56 resize-none overflow-y-auto text-xs"}),(0,t.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[y.length.toLocaleStr
3ing()," / ",p.PROMPT_BODY_MAX.toLocaleString()]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(u.Button,{variant:"outline",size:"sm",disabled:v,onClick:i,children:[(0,t.jsx)(l.X,{}),"Cancel"]}),(0,t.jsxs)(u.Button,{size:"sm",disabled:!k,onClick:()=>void N(),children:[v&&(0,t.jsx)(d.Spinner,{}),r]})]})]})]})}e.s(["PromptsSection",0,function(){let[e,r]=(0,s.useState)(""),i=(0,x.usePrompts)({enabled:!0,search:e}),[l,m]=(0,s.useState)(null),[j,v]=(0,s.useState)(!1),w=""!==i.you;return(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"border-b border-border/60 pb-3 text-base font-medium",children:"Prompts"}),(0,t.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:["Reusable prompts saved to this workspace, inserted from the composer. Everyone here can use them. ",(0,t.jsx)(f.DocsLink,{slug:"personas"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Use the prompt library"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:i.featureEnabled?"The library button shows in the composer for everyone here. Turn this off to hide it without deleting anything.":"Off. Saved prompts are kept and editable here, but the composer button is hidden."})]}),(0,t.jsx)(g.Switch,{on:i.featureEnabled,onChange:e=>{i.setFeatureEnabled(e).catch(e=>{c.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Use the prompt library"})]}),(0,t.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,t.jsx)(h.Input,{value:e,onChange:e=>r(e.target.value),placeholder:"Search prompts…","aria-label":"Search prompts",className:"flex-1"}),(0,t.jsxs)(u.Button,{size:"sm",disabled:j||!w,onClick:()=>{v(!0),m(null)},children:[(0,t.jsx)(a.Plus,{}),"New prompt"]})]}),j&&(0,t.jsx)(b,{className:"mt-3",initialTitle:"",initialBody:"",submitLabel:"Save prompt",onCancel:()=>v(!1),onSubmit:async(e,t)=>{await i.create(e,t),v(!1),c.toast.success("Prompt saved",{description:`"${e}" is now shared.`})},failureMessage:"Could not save that prompt"}),i.loading?(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(d.Spinner,{className:"size-4"}),"Loading…"]}):i.error?(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-destructive",children:[(0,t.jsx)(o.TriangleAlert,{className:"size-4"}),i.error]}),(0,t.jsx)(u.Button,{variant:"outline",size:"sm",onClick:i.reload,children:"Try again"})]}):0===i.prompts.length?(0,t.jsxs)("div",{className:"mt-8 flex flex-col items-center gap-2 text-center",children:[(0,t.jsx)("span",{className:"grid size-10 place-items-center rounded-xl border border-border/60 bg-muted/40 text-muted-foreground",children:(0,t.jsx)(n.Library,{className:"size-4"})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e.trim()?`No prompts match "${e.trim()}"`:"No saved prompts yet"}),!e.trim()&&(0,t.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:"Save one here, or from the library button in the composer, and every teammate in this workspace can use it."})]}):(0,t.jsx)("ul",{className:"mt-4 space-y-2",children:i.prompts.map(e=>l===e.id?(0,t.jsx)("li",{children:(0,t.jsx)(b,{initialTitle:e.title,initialBody:e.body,submitLabel:"Save changes",onCancel:()=>m(null),onSubmit:async(t,s)=>{await i.update(e.id,{title:t,body:s}),m(null),c.toast.success("Prompt updated")},failureMessage:"Could not update that prompt"})},e.id):(0,t.jsx)(y,{prompt:e,editable:(0,p.canEditPrompt)(e,i.you,i.role),mine:e.createdByUserId===i.you,onEdit:()=>{m(e.id),v(!1)},onDelete:async()=>{if(confirm(`Delete "${e.title}"? Everyone in this workspace loses it.`))try{await i.remove(e.id),c.toast.success("Prompt deleted")}catch(e){c.toast.error("Could not delete that prompt",{description:e instanceof Error?e.message:"Please try again."})}}},e.id))})]})}],715465),e.s(["PERSONA_EMOJI_MAX",0,16,"PERSONA_NAME_MAX",0,60,"PERSONA_PROMPT_MAX",0,4e3,"canEditPersona",0,function(e,t,s){return"admin"===s||e.createdByUserId===t}],697214)},168162,715084,205809,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(515281),r=e.i(77071),a=e.i(573474),i=e.i(466787),o=e.i(439745),l=e.i(263676),d=e.i(987968),c=e.i(846696),u=e.i(912505),h=e.i(519455),m=e.i(793479),p=e.i(624687),x=e.i(697214),f=e.i(98072),g=e.i(852091),y=e.i(699375);function b({persona:e,editable:s,mine:r,onEdit:i,onDelete:l}){return(0,t.jsx)("li",{className:"rounded-xl border border-border/60 px-3 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg border border-border/60 bg-muted/40 text-[15px]",children:e.emoji||(0,t.jsx)(o.VenetianMask,{className:"size-4 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm font-medium",children:e.name}),(0,t.jsx)("p",{className:"mt-0.5 line-clamp-2 whitespace-pre-wrap text-xs leading-relaxed text-muted-foreground",children:e.prompt}),(0,t.jsxs)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[r?"Created by you":`Created by ${e.createdByName??"a former teammate"}`," · ",new Date(e.updatedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]})]}),s&&(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:i,title:`Edit "${e.name}"`,"aria-label":`Edit "${e.name}"`,className:"grid size-7 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,t.jsx)(n.Pencil,{className:"size-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:()=>void l(),title:`Delete "${e.name}"`,"aria-label":`Delete "${e.name}"`,className:"grid size-7 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-destructive",children:(0,t.jsx)(a.Trash2,{className:"size-3.5"})})]})]})})}function j({initial:e,submitLabel:n,onSubmit:r,onCancel:a,failureMessage:i,className:o=""}
3){let[u,f]=(0,s.useState)(e?.name??""),[g,y]=(0,s.useState)(e?.emoji??""),[b,v]=(0,s.useState)(e?.prompt??""),[w,k]=(0,s.useState)(!1),N=u.trim().length>0&&b.trim().length>0&&!w;async function S(){if(N){k(!0);try{await r({name:u.trim(),emoji:g.trim()||void 0,prompt:b.trim()})}catch(e){c.toast.error(i,{description:e instanceof Error?e.message:"Please try again."}),k(!1)}}}return(0,t.jsxs)("div",{className:`rounded-xl border border-border/60 bg-muted/30 p-3 ${o}`,children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Input,{value:g,onChange:e=>y(e.target.value),maxLength:x.PERSONA_EMOJI_MAX,placeholder:"🎭","aria-label":"Emoji label (optional)",className:"w-14 text-center"}),(0,t.jsx)(m.Input,{value:u,onChange:e=>f(e.target.value),maxLength:x.PERSONA_NAME_MAX,placeholder:"Persona name, e.g. Senior code reviewer","aria-label":"Persona name",autoFocus:!0,className:"flex-1"})]}),(0,t.jsx)(p.Textarea,{value:b,onChange:e=>v(e.target.value),maxLength:x.PERSONA_PROMPT_MAX,rows:5,placeholder:"How should the models behave as this persona? Tone, expertise, style, what to always or never do…","aria-label":"Persona prompt",className:"mt-2 max-h-56 resize-none overflow-y-auto text-xs"}),(0,t.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,t.jsxs)("span",{className:"text-[11px] text-muted-foreground tabular-nums",children:[b.length.toLocaleString()," / ",x.PERSONA_PROMPT_MAX.toLocaleString()]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(h.Button,{variant:"outline",size:"sm",disabled:w,onClick:a,children:[(0,t.jsx)(l.X,{}),"Cancel"]}),(0,t.jsxs)(h.Button,{size:"sm",disabled:!N,onClick:()=>void S(),children:[w&&(0,t.jsx)(d.Spinner,{}),n]})]})]})]})}e.s(["PersonasSection",0,function(){let e=(0,f.usePersonas)({enabled:!0}),[n,a]=(0,s.useState)(null),[l,m]=(0,s.useState)(!1),p=""!==e.you;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(o.VenetianMask,{className:"size-4 text-muted-foreground"}),"Personas"]}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Reusable voices for your chats - pick one in the composer and it shapes how the models answer. Shared with everyone here."," ",(0,t.jsx)(g.DocsLink,{slug:"personas"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Use personas"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:e.featureEnabled?"Anyone here can pick a persona in the composer. Turn this off to pause personas without deleting anything.":"Off. Saved personas are kept, but no chat answers as one and the picker is hidden in the composer."})]}),(0,t.jsx)(y.Switch,{on:e.featureEnabled,onChange:t=>{e.setFeatureEnabled(t).catch(e=>{c.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Use personas"})]}),(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsxs)(h.Button,{size:"sm",disabled:l||!p,onClick:()=>{m(!0),a(null)},children:[(0,t.jsx)(r.Plus,{}),"New persona"]})}),l&&(0,t.jsx)(j,{className:"mt-3",initial:null,submitLabel:"Create persona",onCancel:()=>m(!1),onSubmit:async t=>{await e.create(t),m(!1),c.toast.success("Persona created",{description:`"${t.name}" is now available in every chat here.`})},failureMessage:"Could not create that persona"}),e.loading?(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(d.Spinner,{className:"size-4"}),"Loading…"]}):e.error?(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-destructive",children:[(0,t.jsx)(i.TriangleAlert,{className:"size-4"}),e.error]}),(0,t.jsx)(h.Button,{variant:"outline",size:"sm",onClick:e.reload,children:"Try again"})]}):0===e.personas.length?(0,t.jsx)(u.EmptyState,{className:"mt-8",icon:o.VenetianMask,title:"No personas yet",hint:(0,t.jsx)(t.Fragment,{children:"Create one - “Socratic tutor”, “Senior code reviewer”, “Brand copywriter” - and every teammate can select it in the composer."})}):(0,t.jsx)("ul",{className:"mt-4 space-y-2",children:e.personas.map(s=>n===s.id?(0,t.jsx)("li",{children:(0,t.jsx)(j,{initial:s,submitLabel:"Save changes",onCancel:()=>a(null),onSubmit:async t=>{await e.update(s.id,{name:t.name,emoji:t.emoji??null,prompt:t.prompt}),a(null),c.toast.success("Persona updated")},failureMessage:"Could not update that persona"})},s.id):(0,t.jsx)(b,{persona:s,editable:(0,x.canEditPersona)(s,e.you,e.role),mine:s.createdByUserId===e.you,onEdit:()=>{a(s.id),m(!1)},onDelete:async()=>
3{if(confirm(`Delete "${s.name}"? Chats using it keep their history but lose the persona.`))try{await e.remove(s.id),c.toast.success("Persona deleted")}catch(e){c.toast.error("Could not delete that persona",{description:e instanceof Error?e.message:"Please try again."})}}},s.id))})]})}],168162);let v=(0,e.i(456420).default)("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);e.s(["FileWarning",0,v],715084),e.s(["canEditSkill",0,function(e,t,s){return"admin"===s||e.createdByUserId===t}],205809)},372556,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(715084),r=e.i(920851),a=e.i(466787),i=e.i(725981),o=e.i(846696),l=e.i(912505),d=e.i(519455),c=e.i(487486),u=e.i(699375),h=e.i(987968),m=e.i(205809),p=e.i(998936),x=e.i(711241),f=e.i(452330),g=e.i(762368),y=e.i(772382),b=e.i(573474),j=e.i(755146),v=e.i(918789),w=e.i(742531),k=e.i(522016);let N=["openai.com"];function S(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}let C={p:({children:e})=>(0,t.jsx)("p",{className:"my-4 leading-[1.75] text-[15px] text-foreground/90",children:e}),h2:({children:e})=>(0,t.jsx)("h2",{id:S(e),className:"mt-10 scroll-mt-24 border-t border-border/60 pt-8 text-xl font-semibold tracking-tight first:mt-0 first:border-0 first:pt-0",children:e}),h3:({children:e})=>(0,t.jsx)("h3",{id:S(e),className:"mt-7 scroll-mt-24 text-base font-semibold",children:e}),ul:({children:e})=>(0,t.jsx)("ul",{className:"my-4 list-disc space-y-2 pl-5 marker:text-muted-foreground",children:e}),ol:({children:e})=>(0,t.jsx)("ol",{className:"my-4 list-decimal space-y-2 pl-5 marker:text-muted-foreground",children:e}),li:({children:e})=>(0,t.jsx)("li",{className:"leading-[1.7] text-[15px] text-foreground/90",children:e}),strong:({children:e})=>(0,t.jsx)("strong",{className:"font-semibold text-foreground",children:e}),a:({href:e,children:s})=>e?.startsWith("/")&&e?(0,t.jsx)(k.default,{href:e,className:"font-medium underline decoration-muted-foreground/40 underline-offset-2 transition-colors hover:decoration-foreground",children:s}):(0,t.jsx)("a",{href:e,target:"_blank",rel:!function(e){if(!e)return!1;try{let{hostname:t}=new URL(e);return N.some(e=>t===e||t.endsWith(`.${e}`))}catch{return!1}}(e)?"noopener noreferrer nofollow":"noopener noreferrer",className:"font-medium underline decoration-muted-foreground/40 underline-offset-2 transition-colors hover:decoration-foreground",children:s}),blockquote:({children:e})=>(0,t.jsx)("blockquote",{className:"my-5 border-l-2 border-border pl-4 text-[15px] italic text-muted-foreground",children:e}),table:({children:e})=>(0,t.jsx)("div",{className:"my-6 overflow-x-auto rounded-xl border border-border/60",children:(0,t.jsx)("table",{className:"w-full min-w-[28rem] border-collapse text-sm",children:e})}),thead:({children:e})=>(0,t.jsx)("thead",{className:"bg-muted/40",children:e}),th:({children:e})=>(0,t.jsx)("th",{className:"border-b border-border/60 px-3.5 py-2.5 text-left text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),td:({children:e})=>(0,t.jsx)("td",{className:"border-b border-border/40 px-3.5 py-2.5 align-top last:border-0",children:e}),code:({children:e,className:s})=>"string"==typeof s&&s.includes("language-")?(0,t.jsx)("code",{className:"font-mono text-[13px] leading-relaxed",children:e}):(0,t.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[13.5px]",children:e}),pre:({children:e})=>(0,t.jsx)("pre",{className:"my-5 overflow-x-auto rounded-xl border border-border/60 bg-muted/40 p-4",children:e}),hr:()=>(0,t.jsx)("hr",{className:"my-8 border-border/60"}),img:({src:e,alt:s})=>(0,t.jsx)("img",{src:"string"==typeof e?e:void 0,alt:s??"",loading:"lazy",className:"my-6 w-full rounded-xl border border-border/60"})};function E({children:e}){return(0,t.jsx)("div",{className:"max-w-[70ch]",children:(0,t.jsx)(v.default,{remarkPlugins:[w.default],components:C,children:e})})}var T=e.i(289868),A=e.i(885227);let M="SKILL.md";function D({id:e,you:r,role:i,featureEnabled:l,onBack:p,onToggle:x,onRemove:v}
3){let[w,k]=(0,s.useState)(null),[N,S]=(0,s.useState)(null),[C,P]=(0,s.useState)(M),[O,L]=(0,s.useState)(null),[I,R]=(0,s.useState)(!1),[$,B]=(0,s.useState)(!1);if((0,s.useEffect)(()=>{let t=!0;return(0,A.fetchSkillDetail)(e).then(e=>{t&&(k(e),S(null))}).catch(e=>{t&&S(e instanceof Error?e.message:"Could not open that skill")}),()=>{t=!1}},[e]),(0,s.useEffect)(()=>{if(C===M||O?.path===C)return;let t=!0;return(0,A.fetchSkillFile)(e,C).then(e=>{t&&L({path:C,text:e.text})}).catch(()=>{t&&L({path:C,text:null})}),()=>{t=!1}},[e,C,O?.path]),N)return(0,t.jsxs)("div",{children:[(0,t.jsx)(_,{onBack:p}),(0,t.jsx)("div",{className:"mt-4 flex flex-col items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:(0,t.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-destructive",children:[(0,t.jsx)(a.TriangleAlert,{className:"size-4"}),N]})})]});if(!w)return(0,t.jsxs)("div",{children:[(0,t.jsx)(_,{onBack:p}),(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(h.Spinner,{className:"size-4"}),"Loading…"]})]});let{skill:F,body:U,files:H}=w,q=(0,m.canEditSkill)(F,r,i),K=C===M||O?.path===C,W=C===M?U:O?.text??null,V=H.find(e=>e.path===C);return(0,t.jsxs)("div",{children:[(0,t.jsx)(_,{onBack:p}),(0,t.jsxs)("div",{className:"mt-3 flex items-start justify-between gap-6",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h3",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"font-mono text-[0.9375rem]",children:F.name}),F.hasScripts&&(0,t.jsxs)(c.Badge,{variant:"outline",className:"gap-1 font-normal",children:[(0,t.jsx)(n.FileWarning,{className:"size-3"}),"Scripts not run"]})]}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[F.createdByName?`by ${F.createdByName}`:"Added here",F.license&&` \xb7 ${F.license}`,F.compatibility&&` \xb7 ${F.compatibility}`]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)("a",{href:(0,A.skillDownloadUrl)(F.id),className:"grid size-8 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Download this skill as a .zip - it works in any agent that reads the format",children:(0,t.jsx)(g.Download,{className:"size-4"})}),q&&(0,t.jsx)("button",{type:"button",onClick:()=>B(!0),className:"grid size-8 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive",title:"Remove this skill",children:(0,t.jsx)(b.Trash2,{className:"size-4"})}),(0,t.jsx)(u.Switch,{on:F.enabled,disabled:!q,onChange:e=>{k({...w,skill:{...F,enabled:e}}),x(F.id,e).catch(()=>{k({...w,skill:{...F,enabled:!e}})})},label:`Use ${F.name}`})]})]}),(0,t.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:F.description}),F.enabled&&!l&&(0,t.jsx)("p",{className:"mt-3 rounded-lg border border-border/60 bg-muted/40 px-3 py-2 text-[0.6875rem] leading-relaxed text-muted-foreground",children:"This skill is switched on, but skills are switched off for the workspace, so no model is being told about it."}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsxs)(j.DropdownMenu,{children:[(0,t.jsx)(j.DropdownMenuTrigger,{render:(0,t.jsx)("button",{type:"button",className:"inline-flex h-7 max-w-56 items-center gap-1.5 rounded-full border border-border/70 bg-muted/60 px-2.5 text-[12px] font-medium transition-colors duration-200 hover:text-foreground",children:(0,t.jsx)("span",{className:"truncate font-mono",children:C})})}),(0,t.jsxs)(j.DropdownMenuContent,{align:"start",className:"max-h-72 w-72 overflow-y-auto",children:[(0,t.jsx)(j.DropdownMenuItem,{onClick:()=>P(M),className:"font-mono text-[0.8125rem]",children:M}),H.map(e=>(0,t.jsxs)(j.DropdownMenuItem,{onClick:()=>P(e.path),className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-[0.8125rem]",children:e.path}),(0,t.jsx)("span",{className:"shrink-0 text-[0.6875rem] text-muted-foreground",children:(0,T.formatBytes)(e.sizeBytes)})]},e.path))]})]}),H.length>0&&(0,t.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[H.length," file",1===H.length?"":"s"]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 rounded-full border border-border/70 p-0.5",children:[(0,t.jsx)(z,{active:!I,onClick:()=>R(!1),title:"Rendered",children:(0,t.jsx)(y.Eye,{className:"size-3.5"})}),(0,t.jsx)(z,{active:I,onClick:()=>R(!0),title:"Source",children:(0,t.jsx)(f.Code2,{className:"size-3.5"})})]})]}),(0,t.jsx)("div",{className:"mt-2 max-h-96 overflow-y-auto rounded-xl border border-border/60 px-4 py-1",children:K?
3null===W?(0,t.jsx)("p",{className:"py-4 text-xs text-muted-foreground",children:V&&!V.readable?"This is a binary file. It ships with the skill, but there is no text to show.":"Nothing to show."}):I?(0,t.jsx)("pre",{className:"overflow-x-auto py-3 text-xs leading-relaxed whitespace-pre-wrap",children:W}):(0,t.jsx)("div",{className:"text-sm",children:(0,t.jsx)(E,{children:W})}):(0,t.jsxs)("p",{className:"flex items-center gap-2 py-4 text-sm text-muted-foreground",children:[(0,t.jsx)(h.Spinner,{className:"size-4"}),"Loading…"]})}),$&&(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-lg border border-destructive/30 bg-destructive/[0.03] p-2.5 dark:bg-destructive/10",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Remove “",F.name,"”? Download it first if you want to keep a copy."]}),(0,t.jsxs)("div",{className:"flex shrink-0 gap-1.5",children:[(0,t.jsx)(d.Button,{variant:"ghost",size:"sm",onClick:()=>B(!1),children:"Cancel"}),(0,t.jsx)(d.Button,{variant:"destructive",size:"sm",onClick:()=>{B(!1),v(F.id).then(p).catch(e=>{o.toast.error("Could not remove that skill",{description:e instanceof Error?e.message:void 0})})},children:"Remove"})]})]})]})}function _({onBack:e}){return(0,t.jsxs)("button",{type:"button",onClick:e,className:"inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(x.ArrowLeft,{className:"size-3.5"}),"All skills"]})}function z({active:e,onClick:s,title:n,children:r}){return(0,t.jsx)("button",{type:"button",onClick:s,title:n,"aria-pressed":e,className:`grid size-6 place-items-center rounded-full transition-colors duration-200 ${e?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:r})}var P=e.i(852091);function O({skill:e,canEdit:s,blockedByBudget:r,onOpen:a,onToggle:i}){return(0,t.jsxs)("li",{className:"border-b border-border/60 last:border-b-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 py-2.5",children:[(0,t.jsxs)("button",{type:"button",onClick:a,className:"group min-w-0 flex-1 text-left",children:[(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"truncate font-mono text-[0.8125rem] font-medium group-hover:underline",children:e.name}),e.hasScripts&&(0,t.jsxs)(c.Badge,{variant:"outline",className:"gap-1 font-normal",children:[(0,t.jsx)(n.FileWarning,{className:"size-3"}),"Scripts not run"]})]}),(0,t.jsx)("span",{className:"mt-0.5 line-clamp-1 block text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("span",{className:"hidden shrink-0 text-[0.6875rem] text-muted-foreground sm:block",children:e.createdByName??"-"}),(0,t.jsx)(u.Switch,{on:e.enabled,disabled:!s||r,onChange:e=>void i(e),label:`Use ${e.name}`})]}),r&&(0,t.jsx)("p",{className:"pb-2.5 text-[0.6875rem] text-muted-foreground",children:"Switch another skill off to make room - every switched-on skill is described to the model on every message."})]})}e.s(["SkillsSection",0,function(){let e=(0,p.useSkills)({enabled:!0}),n=(0,s.useRef)(null),[c,x]=(0,s.useState)(!1),[f,g]=(0,s.useState)(null);async function y(t){if(t){x(!0);try{let s=await e.upload(t);o.toast.success(`Added "${s.name}"`,{description:s.hasScripts?"Its instructions are live. The scripts it bundles are stored but not run.":"It is now offered to every model in this workspace."})}catch(e){o.toast.error("Could not add that skill",{description:e instanceof Error?e.message:void 0})}finally{x(!1),n.current&&(n.current.value="")}}}let b=e.enabledMax>0&&e.enabledCount>=e.enabledMax;async function j(t,s){try{await e.setEnabled(t,s)}catch(e){throw o.toast.error("Could not change that skill",{description:e instanceof Error?e.message:void 0}),e}}async function v(t){let s=e.skills.find(e=>e.id===t)?.name;await e.remove(t),o.toast.success(s?`Removed "${s}"`:"Skill removed")}return f?(0,t.jsx)(D,{id:f,you:e.you,role:e.role,featureEnabled:e.featureEnabled,onBack:()=>g(null),onToggle:j,onRemove:v}):(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(r.Puzzle,{className:"size-4 text-muted-foreground"}),"Skills"]}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["A skill is a folder of instructions that teaches the AI how your team does a specific job. Skills use an open format, so one you already made for Claude or ChatGPT works here unchanged - and here it runs on every model, not just one. ",(0,t.jsx)(P.DocsLink,{slug:"skills"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-start justify-between gap-6 rounded-xl border border-border/60 p-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Use skills in this workspace"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:e.featureEnabled?"Switched-on skills are offered to the models here. Turn this off to pause all of them without remov
3ing anything.":"Off. Your skills are kept, but no model is told about them and the skill control is hidden in chats."})]}),(0,t.jsx)(u.Switch,{on:e.featureEnabled,onChange:t=>{e.setFeatureEnabled(t).catch(e=>{o.toast.error("Could not change that setting",{description:e instanceof Error?e.message:void 0})})},label:"Use skills in this workspace"})]}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-between gap-3",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.enabledCount," of ",e.enabledMax," switched on"]}),(0,t.jsx)("input",{ref:n,type:"file",accept:".zip,application/zip",className:"hidden",onChange:e=>void y(e.target.files?.[0])}),(0,t.jsxs)(d.Button,{size:"sm",disabled:c,onClick:()=>n.current?.click(),children:[c?(0,t.jsx)(h.Spinner,{className:"size-4"}):(0,t.jsx)(i.Upload,{}),"Add skill"]})]}),e.loading?(0,t.jsxs)("p",{className:"mt-6 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(h.Spinner,{className:"size-4"}),"Loading…"]}):e.error?(0,t.jsxs)("div",{className:"mt-6 flex flex-col items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-destructive",children:[(0,t.jsx)(a.TriangleAlert,{className:"size-4"}),e.error]}),(0,t.jsx)(d.Button,{variant:"outline",size:"sm",onClick:e.reload,children:"Try again"})]}):0===e.skills.length?(0,t.jsx)(l.EmptyState,{className:"mt-8",icon:r.Puzzle,title:"No skills yet",hint:"Upload a skill folder as a .zip - it needs a SKILL.md inside. Bring one you already use elsewhere, or write one for how your team wants a job done."}):(0,t.jsx)("ul",{className:"mt-4",children:e.skills.map(s=>(0,t.jsx)(O,{skill:s,canEdit:(0,m.canEditSkill)(s,e.you,e.role),blockedByBudget:b&&!s.enabled,onOpen:()=>g(s.id),onToggle:async e=>{await j(s.id,e).catch(()=>{})}},s.id))})]})}],372556)},310410,e=>{"use strict";var t=e.i(843476),s=e.i(271645),n=e.i(856423),r=e.i(694367),a=e.i(689664),i=e.i(716327),o=e.i(206029),l=e.i(870387),d=e.i(809584),c=e.i(368308),u=e.i(758925),h=e.i(470533),m=e.i(920851),p=e.i(97923),x=e.i(367784),f=e.i(638292),g=e.i(950786),y=e.i(395925),b=e.i(250832),j=e.i(112092),v=e.i(328623),w=e.i(573474),k=e.i(466787),N=e.i(882303),S=e.i(439745),C=e.i(987968),E=e.i(846696),T=e.i(912505),A=e.i(776639),M=e.i(793479),D=e.i(755146),_=e.i(519455),z=e.i(962430),P=e.i(699375),O=e.i(886043),L=e.i(307730),I=e.i(550831),R=e.i(435998),$=e.i(447120),B=e.i(481868),F=e.i(851659),U=e.i(186306),H=e.i(796530),q=e.i(501139),K=e.i(925064),W=e.i(404164),V=e.i(215380),J=e.i(569020),Y=e.i(889121),G=e.i(986664),X=e.i(533056),Q=e.i(222610),Z=e.i(379925),ee=e.i(832284),et=e.i(852091),es=e.i(522016),en=e.i(715465),er=e.i(168162),ea=e.i(372556),ei=e.i(436723),eo=e.i(15439),el=e.i(334184);let ed=[{id:"app",label:"General",icon:j.SlidersHorizontal},{id:"models",label:"AI models",icon:v.Sparkles},{id:"prompts",label:"Prompt library",icon:h.Library},{id:"skills",label:"Skills",icon:m.Puzzle},{id:"personalization",label:"Personalization",icon:S.VenetianMask},{id:"knowledge",label:"Knowledge",icon:n.BookOpen},{id:"preferences",label:"Preferences",icon:g.Palette},{id:"voice",label:"Voice dictation",icon:f.Mic},{id:"usage",label:"Usage",icon:r.ChartColumn},{id:"billing",label:"Billing",icon:l.CreditCard},{id:"keys",label:"API keys",icon:u.KeyRound},{id:"data",label:"Data controls",icon:d.Database},{id:"keyboard",label:"Shortcuts",icon:c.Keyboard},{id:"members",label:"Team",icon:N.Users},{id:"account",label:"Account",icon:o.CircleUser}],ec=ed.map(e=>e.id),eu=["personalization","knowledge","prompts","skills","usage","billing","members","keys","data","account"],eh=["app","personalization","knowledge","preferences","members","prompts","skills","models","voice","keyboard","usage","billing","keys","data","account"],em="multiai.settings.section";function ep({label:e,onSignIn:s}){return(0,t.jsxs)("div",{className:"flex h-full flex-col items-center justify-center py-16 text-center",children:[(0,t.jsx)("div",{className:"grid size-11 place-items-center rounded-full border border-border/60 bg-muted/40",children:(0,t.jsx)(p.LogIn,{className:"size-5 text-muted-foreground"})}),(0,t.jsxs)("h2",{className:"mt-4 text-base font-semibold tracking-tight",children:["Sign in to use ",e]}),(0,t.jsxs)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:[e," belongs to your MultiAI account. Sign in, or create one, and your conversations, settings and credits follow you everywhere - including the Chrome extension."]}),(0,t.jsx)(_.Button,{className:"mt-6 rounded-full",onClick:s,children:"Sign in"})]})}
3function ex(){let[e,n]=(0,s.useState)(null);return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Personalization"}),(0,t.jsxs)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:["Standing instructions for every chat here, and what the models know about you. ",(0,t.jsx)(et.DocsLink,{slug:"projects"})]}),(0,t.jsx)("div",{className:"mt-5",children:(0,t.jsx)(J.WorkspaceSection,{onEnabledChange:n})}),(0,t.jsx)("div",{className:"mt-8 border-t border-border/60 pt-5",children:(0,t.jsx)(Y.AboutYouSection,{sending:e})}),(0,t.jsx)("div",{className:"mt-8 border-t border-border/60 pt-5",children:(0,t.jsx)(ee.MemorySection,{})}),(0,t.jsx)("div",{className:"mt-8 border-t border-border/60 pt-5",children:(0,t.jsx)(er.PersonasSection,{})})]})}let ef=[{id:"default",label:"Default"},{id:"red",label:"Red",swatch:"oklch(0.637 0.237 25.331)"},{id:"orange",label:"Orange",swatch:"oklch(0.705 0.213 47.604)"},{id:"yellow",label:"Yellow",swatch:"oklch(0.795 0.184 86.047)"},{id:"green",label:"Green",swatch:"oklch(0.723 0.219 149.579)"},{id:"teal",label:"Teal",swatch:"oklch(0.704 0.14 182.503)"},{id:"cyan",label:"Cyan",swatch:"oklch(0.715 0.143 215.221)"},{id:"blue",label:"Blue",swatch:"oklch(0.623 0.214 259.815)"},{id:"indigo",label:"Indigo",swatch:"oklch(0.585 0.233 277.117)"},{id:"purple",label:"Purple",swatch:"oklch(0.627 0.265 303.9)"},{id:"pink",label:"Pink",swatch:"oklch(0.656 0.241 354.308)"}],eg=[{id:"default",label:"Default (Geist)",stack:"var(--font-geist-sans)"},{id:"inter",label:"Inter",stack:"var(--font-chat-inter)"},{id:"instrument",label:"Instrument Sans",stack:"var(--font-chat-instrument)"},{id:"space-grotesk",label:"Space Grotesk",stack:"var(--font-chat-grotesk)"},{id:"plex",label:"IBM Plex Sans",stack:"var(--font-chat-plex)"},{id:"serif",label:"Serif (Lora)",stack:"var(--font-chat-serif)"},{id:"newsreader",label:"Newsreader",stack:"var(--font-chat-newsreader)"},{id:"mono",label:"Mono (Geist Mono)",stack:"var(--font-geist-mono)"},{id:"system",label:"System",stack:'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif'},{id:"dyslexic",label:"Dyslexia-friendly",stack:"var(--font-chat-dyslexic)"}];function ey({preferences:e,onPreferencesChange:s}){let n=t=>{s({...e,theme:t})},r=eg.find(t=>t.id===e.chatFont)??eg[0];return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Preferences"}),(0,t.jsx)(eV,{label:"Appearance",hint:"Match your system, or pin light or dark.",children:(0,t.jsx)(eJ,{value:"system"===e.theme?"System":"dark"===e.theme?"Dark":"Light",options:[{label:"System",onSelect:()=>n("system")},{label:"Light",onSelect:()=>n("light")},{label:"Dark",onSelect:()=>n("dark")}]})}),(0,t.jsx)(eV,{label:"Accent color",hint:"Colors buttons, selections and focus rings. Default keeps the monochrome look.",children:(0,t.jsx)(ew,{value:e.accent,onChange:t=>s({...e,accent:t})})}),(0,t.jsx)(eV,{label:"Chat font",hint:"The typeface your conversations read in. Code always stays in Geist Mono.",children:(0,t.jsx)(eJ,{value:r.label,options:eg.map(t=>({label:t.label,style:{fontFamily:t.stack},onSelect:()=>s({...e,chatFont:t.id})}))})}),(0,t.jsx)(eV,{label:"Text size",hint:"Everything scales in proportion - text, spacing, controls - so nothing overlaps or clips.",children:(0,t.jsx)(eJ,{value:ej[e.textSize],options:eb.map(t=>({label:t.label,onSelect:()=>s({...e,textSize:t.id})}))})}),"default"!==e.textSize&&(0,t.jsx)(eV,{label:"Apply it to",hint:"chat"===e.textSizeScope?"Only the conversation and composer resize - the sidebar, dialogs and menus keep the standard size.":"The whole interface resizes - conversation, sidebar, dialogs and menus alike.",children:(0,t.jsx)(eJ,{value:ev[e.textSizeScope],options:$.TEXT_SIZE_SCOPES.map(t=>({label:ev[t],onSelect:()=>s({...e,textSizeScope:t})}))})}),(0,t.jsx)(eV,{label:"Help & feedback button",hint:"The control on the right edge that opens live chat, feedback and feature requests. Turning it off does not take the channels away - the Help centre has all three.",children:(0,t.jsx)(eY,{label:"Show the help & feedback button",on:e.showFeedbackControl,onChange:t=>s({...e,showFeedbackControl:t})})})]})}let eb=[{id:"compact",label:"Compact"},{id:"default",label:"Default"},{id:"large",label:"Large"},{id:"x-large",label:"Extra large"}],ej={compact:"Compact",default:"Default",large:"Large","x-large":"Extra large"},ev={app:"The whole app",chat:"Chat only"};
3function ew({value:e,onChange:n}){let[r,i]=(0,s.useState)(!1),o=(0,s.useRef)(void 0);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-2.5",children:[(0,t.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${r?"opacity-100":"opacity-0"}`,children:[(0,t.jsx)(a.Check,{className:"size-3"}),"Saved!"]}),(0,t.jsx)("span",{role:"radiogroup","aria-label":"Accent color",className:"flex max-w-56 flex-wrap items-center justify-end gap-1",children:ef.map(s=>{let r=s.id===e;return(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":r,"aria-label":s.label,title:s.label,onClick:()=>{s.id!==e&&(n(s.id),i(!0),window.clearTimeout(o.current),o.current=window.setTimeout(()=>i(!1),1800))},className:`grid size-7 place-items-center rounded-full transition-all duration-200 active:scale-90 ${r?"ring-2 ring-foreground/60":"hover:bg-muted"}`,children:(0,t.jsx)("span",{className:`size-4 rounded-full border border-black/10 dark:border-white/15 ${s.swatch?"":"bg-foreground"}`,style:s.swatch?{background:s.swatch}:void 0})},s.id)})})]})}function ek({preferences:e,onPreferencesChange:s}){let n=(0,$.preferenceModels)();return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"General"}),(0,t.jsxs)("p",{className:"mb-2 mt-4 text-xs leading-relaxed text-muted-foreground",children:["How a new chat opens, and how the worklog behaves."," ",(0,t.jsx)(et.DocsLink,{slug:"your-first-chat"})]}),(0,t.jsx)(eV,{label:"Default mode",hint:(0,t.jsxs)(t.Fragment,{children:["Agent works through a task in steps - searching, reading pages, checking your documents and following your skills."," ",(0,t.jsx)(et.DocsLink,{slug:"agent-mode"})]}),children:(0,t.jsx)(eJ,{value:"agent"===e.defaultChatMode?"Agent":"Chat",options:[{label:"Chat",onSelect:()=>s({...e,defaultChatMode:"chat"})},{label:"Agent",onSelect:()=>s({...e,defaultChatMode:"agent"})}]})}),(0,t.jsx)(eV,{label:"Default conversation",hint:(0,el.minModelsFor)(e.defaultConvMode)>1?`${(0,el.convModeDef)(e.defaultConvMode).label} runs several models - add a second one when a new chat opens.`:(0,el.convModeDef)(e.defaultConvMode).hint,children:(0,t.jsx)(eJ,{value:(0,el.convModeDef)(e.defaultConvMode).label,options:el.CONV_MODES.map(t=>({label:t.label,onSelect:()=>s({...e,defaultConvMode:t.id})}))})}),(0,t.jsx)(eV,{label:"Show cost on every answer",hint:"Display credits and response time under each reply.",children:(0,t.jsx)(eY,{label:"Show cost on every answer",on:e.showCostPerAnswer,onChange:t=>s({...e,showCostPerAnswer:t})})}),(0,t.jsx)(eV,{label:"Open the worklog",hint:"The right-hand panel records how an answer was reached - an agent's steps and a debate's working rounds. A model's thinking shows in the conversation itself; see the Thinking section below.",children:(0,t.jsx)(eJ,{value:eS[e.railAutoOpen],options:eN.map(t=>({label:t.label,onSelect:()=>s({...e,railAutoOpen:t.id})}))})}),(0,t.jsx)(eV,{label:"Close it when finished",hint:"Slide the worklog back once the debate or agent run completes, or keep it open. A debate whose rounds live in the panel keeps it open either way - there is something to read there.",children:(0,t.jsx)(eY,{label:"Close the worklog when finished",on:e.railAutoClose,onChange:t=>s({...e,railAutoClose:t})})}),(0,t.jsx)("p",{className:"mt-8 text-sm font-medium",children:"Thinking"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"When a model reasons before answering, the thought process appears in the conversation above its answer, with a live timer while it runs."}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)(eV,{label:"Show the reasoning",hint:eC.find(t=>t.id===e.thinkingDisplay)?.hint,children:(0,t.jsx)(eJ,{value:eE[e.thinkingDisplay],options:eC.map(t=>({label:t.label,onSelect:()=>s({...e,thinkingDisplay:t.id})}))})}),"hidden"!==e.thinkingDisplay&&(0,t.jsx)(eV,{label:"Fold it away when done",hint:"Once the answer starts, the reasoning folds down to the indicator and its time. Click the indicator any time to read the full thought process again.",children:(0,t.jsx)(eY,{label:"Fold the reasoning away when done",on:e.thinkingCollapseWhenDone,onChange:t=>s({...e,thinkingCollapseWhenDone:t})})})]}),(0,t.jsx)("p",{className:"mt-8 text-sm font-medium",children:"Debate"}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:["Everyone answers, they read each other and answer again, then one writes the combined answer. ",(0,t.jsx)(et.DocsLink,{slug:"debate-mode"})]}),(0,t.jsxs)("div",{className:"mt-2",children:[(0,t.jsx)(eV,{label:"Critique round",hint:"Each model reads every other answer and revises its own before the combined answer is written. This is what makes a wrong answer get challenged - and it roughly doubles what a debate turn costs, since every model answers twice.",children:(0,t.jsx)(eY,{on:e.debateCritique,onChange:t=>s({...e,debateCritique:t}),label:"Critique round"})}),(0,t.jsx)(eV,{label:"Where the rounds appear",hint:"The drafts and revisions are the models' working-out. Keeping them in the worklog panel leaves the conversation as your question and the combined answer; showing them in the chat stacks every round inline. Nothing is lost either way - both are saved with the chat.",children:(0,t.jsx)(eJ,{value:eA[e.debatePlacement],options:eT.map(t=>({label:eA[t],onSelect:()=>s({...e,debatePlacement:t})}))})}),(0,t.jsx)(eV,{label:"Moderator",hint:"The model that writes the final combined answer. It must be one of the models in the debate, so a choice that is not selected for a given chat falls back to the first one.",children:(0,t.jsx)(eJ,{value:e.debateModerator&&n.find(t=>
3t.id===e.debateModerator)?.name||"First selected",options:[{label:"First selected",onSelect:()=>s({...e,debateModerator:null})},...n.map(t=>({label:t.name,onSelect:()=>s({...e,debateModerator:t.id})}))]})})]})]})}let eN=[{id:"always",label:"Always"},{id:"active",label:"When there's a debate or agent run"},{id:"never",label:"Never"}],eS={always:"Always",active:"When there's a debate or agent run",never:"Never"},eC=[{id:"hidden",label:"Indicator only",hint:"Just “Thinking” and the elapsed time - the reasoning itself never shows."},{id:"preview",label:"Glimpse",hint:"The newest lines stream through a small window while the model reasons."},{id:"full",label:"Full",hint:"The entire thought process, at full height, as it streams."}],eE={hidden:"Indicator only",preview:"Glimpse",full:"Full"},eT=["panel","chat"],eA={panel:"In the worklog panel",chat:"In the conversation"},eM="multiai.settings.modelsOrder",eD=[{id:"capability",label:"Capability"},{id:"provider",label:"Provider"},{id:"price-desc",label:"Most expensive first"},{id:"price-asc",label:"Cheapest first"}];function e_(){try{let e=window.localStorage.getItem(eM);if(e&&eD.some(t=>t.id===e))return e}catch{}return"capability"}let ez=[{id:"fast",label:"Fast"},{id:"smart",label:"Smart"},{id:"frontier",label:"Frontier"}];function eP(e){return e.inputUsdPerMTok+e.outputUsdPerMTok}function eO({preferences:e,onPreferencesChange:n}){let r=(0,$.preferenceModels)(),[a,i]=(0,s.useState)(e_);return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"AI models"}),(0,t.jsxs)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:["Every new chat opens with your default model - click one to make it the default. The pill on each row sets how deeply that model thinks: the starting level for new conversations, changeable per chat. Each provider exposes its own levels, so the options differ per model."," ",(0,t.jsx)(et.DocsLink,{slug:"choosing-a-model"})]}),(0,t.jsx)(eV,{label:"Organize by",hint:"Group by capability tier or provider family, or rank the whole list by relative cost.",children:(0,t.jsx)(eJ,{value:eD.find(e=>e.id===a)?.label??"Capability",options:eD.map(e=>({label:e.label,onSelect:()=>(e=>{i(e);try{window.localStorage.setItem(eM,e)}catch{}})(e.id)}
3))})}),(0,t.jsx)("div",{className:"mt-4 space-y-5 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-300",children:(function(e,t){switch(t){case"provider":return R.VISIBLE_VENDORS.map(t=>({key:t,label:R.VENDOR_LABEL[t],models:e.filter(e=>e.vendor===t)})).filter(e=>e.models.length>0);case"price-desc":case"price-asc":return[{key:t,label:null,models:[...e].sort((e,s)=>("price-desc"===t?eP(s)-eP(e):eP(e)-eP(s))||e.name.localeCompare(s.name))}];default:return ez.map(t=>({key:t.id,label:t.label,models:e.filter(e=>e.tier===t.id)})).filter(e=>e.models.length>0)}})(r,a).map(s=>(0,t.jsxs)("div",{children:[s.label&&(0,t.jsx)("p",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s.label}),(0,t.jsx)("div",{className:"divide-y divide-border/60 overflow-hidden rounded-xl border border-border/60",children:s.models.map(s=>{let r=e.defaultModelId===s.id;return(0,t.jsxs)("div",{className:`flex items-center gap-3 px-3 py-2.5 transition-colors duration-200 ${r?"bg-muted/60":"hover:bg-muted/30"}`,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{let t;return t=s.id,n({...e,defaultModelId:t})},title:r?void 0:`Make ${s.name} the default`,className:"flex min-w-0 flex-1 items-center gap-3 text-left transition-transform duration-200 active:scale-[0.99]",children:[(0,t.jsx)(ei.ModelLogo,{vendor:s.vendor,className:"size-4 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-sm",children:s.name}),"capability"!==a&&(0,t.jsx)("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium capitalize text-muted-foreground",children:s.tier}),(0,t.jsxs)("span",{title:(0,R.costTierTitle)(s),className:"shrink-0 text-[11px] font-medium tracking-tight text-muted-foreground tabular-nums","aria-label":(0,R.costTierTitle)(s),children:[(0,R.costTier)(s),(0,t.jsx)("span",{className:"opacity-25",children:"$$$$$".slice((0,R.costTier)(s).length)})]}),r&&(0,t.jsx)("span",{className:"shrink-0 rounded-full bg-primary px-2 py-0.5 text-[10px] font-medium text-primary-foreground",children:"Default"})]}),(0,I.supportsEffort)(s)?(0,t.jsx)(eo.EffortSelect,{model:s,value:e.defaultEfforts[s.id],onChange:t=>{let r;return r=s.id,n({...e,defaultEfforts:{...e.defaultEfforts,[r]:t}})},variant:"inline"}):(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/70",title:`${s.name} does not expose a thinking control`,children:"Not adjustable"})]},s.id)})})]},s.key))},a)]})}function eL({preferences:e,onPreferencesChange:s}){let n=e.voice,r=t=>s({...e,voice:{...n,...t}}),a=B.VOICE_NOISE_OPTIONS.find(e=>e.id===n.noise)?.label??"Off",i=B.VOICE_MODES.find(e=>e.id===n.mode)?.label??"Balanced";return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Voice dictation"}),(0,t.jsxs)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:["Dictate messages by voice with the mic button in the composer. Speech is transcribed live and fills the message box. It never sends on its own."," ",(0,t.jsx)(et.DocsLink,{slug:"your-first-chat"})]}),(0,t.jsx)(eV,{label:"Voice dictation",hint:"Turn this off to remove the mic button from the composer entirely.",children:(0,t.jsx)(eY,{label:"Enable voice dictation",on:n.enabled,onChange:e=>r({enabled:e})})}),n.enabled?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eV,{label:"Language",hint:"Auto-detect works across all supported languages, or pin one for the best accuracy.",children:(0,t.jsx)(eJ,{value:(0,B.voiceLanguageLabel)(n.language),options:[{label:"Auto-detect",onSelect:()=>r({language:B.AUTO_LANGUAGE})},...B.DICTATION_LANGUAGES.map(e=>({label:e.label,onSelect:()=>r({language:e.code})}))]})}),(0,t.jsx)(eV,{label:"Background-noise suppression",hint:"Isolate your voice from surrounding noise. Near-field suits headsets; far-field suits laptop and room mics.",children:(0,t.jsx)(eJ,{value:a,options:B.VOICE_NOISE_OPTIONS.map(e=>({label:e.label,onSelect:()=>r({noise:e.id})}))})}),(0,t.jsx)(eV,{label:"Accuracy vs. latency",hint:"Fastest shows words the instant you speak; most accurate is best for noisy audio.",children:(0,t.jsx)(eJ,{value:i,options:B.VOICE_MODES.map(e=>({label:e.label,onSelect:()=>r({mode:e.id})}))})}),(0,t.jsx)(eV,{label:"Auto-stop after silence",hint:"Dictation ends automatically after this much quiet, so a forgotten mic can't keep listening.",children:(0,t.jsx)(eJ,{value:`${n.autoStopSeconds} seconds`,options:B.AUTO_STOP_OPTIONS.map(e=>({label:`${e} seconds`,onSelect:()=>r({autoStopSeconds:e})}))})}),(0,t.jsx)(eV,{label:"Maximum length",hint:"A fixed limit per dictation to keep sessions short. This can't be changed.",children:(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:[B.MAX_DICTATION_SECONDS/60," min per dictation"]})})]}):(0,t.jsx)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:"Dictation is off. Turn it on to choose a language, noise suppression and how long it listens."})]})}function eI(){let e=(0,K.useShortcutSettings)(),n=(0,K.useIsMac)(),[r,a]=(0,s.use
3State)(null),i=(0,H.resolvedShortcuts)(e),o=(0,H.conflictingShortcutIds)(e);return(0,s.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),"Escape"===e.key)return void a(null);let t=(0,F.bindingFromEvent)(e);if(!t)return;if(!(0,F.hasCommandModifier)(t))return void E.toast.error("Add Ctrl, Cmd or Alt",{description:"Plain keys would fire while you are typing."});let s=(0,H.setShortcutKeys)(r,t);s.ok?(a(null),E.toast.success("Shortcut updated",{description:(0,F.formatBinding)(t,n)})):E.toast.error(`${(0,F.formatBinding)(t,n)} is taken`,{description:`Already bound to "${s.conflict.label}".`})};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[r,n]),(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Shortcuts"}),(0,t.jsx)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:"Click a binding to change it, or switch a shortcut off to hand the combination back to your browser. Bindings are stored once and shown as ⌘ on Mac, Ctrl on Windows."}),(0,t.jsx)("div",{className:"mt-4 space-y-5",children:U.SHORTCUT_GROUPS.map(e=>{let s=i.filter(t=>t.def.group===e.id);return 0===s.length?null:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e.label}),(0,t.jsx)("div",{className:"divide-y divide-border/60 rounded-xl border border-border/60",children:s.map(e=>{let s=r===e.id,n=o.has(e.id);return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-2.5",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:`truncate text-sm transition-opacity duration-200 ${e.enabled?"":"opacity-50"}`,children:e.def.label}),n&&(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-destructive",children:"Same keys as another shortcut"})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-3",children:e.def.fixed?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(q.KeyChips,{binding:e.keys}),(0,t.jsx)("span",{className:"w-11 text-right text-[11px] text-muted-foreground",children:"Always on"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:()=>a(s?null:e.id),title:"Click, then press the new combination",className:`rounded-lg px-2 py-1 transition-all duration-200 active:scale-95 ${s?"bg-muted text-[12px] text-foreground":"hover:bg-muted"}`,children:s?(0,t.jsx)("span",{className:"animate-pulse",children:"Press new keys…"}):(0,t.jsx)(q.KeyChips,{binding:e.keys,className:e.enabled?"":"opacity-50"})}),(0,t.jsx)(eY,{label:`Enable ${e.def.label}`,on:e.enabled,onChange:t=>(0,H.setShortcutEnabled)(e.id,t)})]})})]},e.id)})})]},e.id)})}),(0,t.jsxs)("div",{className:"mt-5 flex items-center justify-between gap-4 border-t border-border/60 pt-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Restores every binding and turns all shortcuts back on."}),(0,t.jsxs)(_.Button,{variant:"outline",size:"sm",className:"rounded-full",onClick:()=>{(0,H.resetShortcuts)(),a(null),E.toast.success("Shortcuts restored to defaults")},children:[(0,t.jsx)(y.RotateCcw,{className:"size-3.5"}),"Restore defaults"]})]})]})}function eR({plan:e,creditsRemaining:n}){let r=O.PLANS[e],[a,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[d,c]=(0,s.useState)(!1),[u,h]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!0;return fetch("/api/billing/subscription",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{e&&(i(t),l(!0))}).catch(()=>{e&&l(!0)}),()=>{e=!1}},[]);let m=a?.subscription??null,p=m?.status==="cancelled",x=e=>e?new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):null;return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Billing"}),(0,t.jsxs)("p",{className:"mb-4 text-xs leading-relaxed text-muted-foreground",children:["Your plan, what is left of this cycle’s credits, and what moves the number. ",(0,t.jsx)(et.DocsLink,{slug:"how-credits-work"})]}),(0,t.jsxs)("div",{className:"rounded-xl border border-border/60 bg-muted/30 p-4",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:r.name}),(0,t.jsxs)("span",{className:"font-mono text-sm",children:[(0,L.formatWholeCredits)(n),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" ","/ ",r.credits.toLocaleStr
3ing()," credits"]})]})]}),r.note&&(0,t.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:r.note}),m&&(0,t.jsx)("p",{className:"mt-1.5 text-sm text-muted-foreground",children:p?m.endsAt?`Cancelled - your plan stays active until ${x(m.endsAt)}.`:"Cancelled - your plan stays active until the end of the paid period.":m.renewsAt?`Renews on ${x(m.renewsAt)}.`:null}),(0,t.jsx)(_.Button,{className:"mt-4 rounded-full",size:"sm",variant:(0,O.canUpgrade)(e)?"default":"outline",onClick:()=>h(!0),children:(0,O.canUpgrade)(e)?"Upgrade plan":"Manage plan"}),(0,t.jsx)(V.PricingDialog,{open:u,onOpenChange:h})]}),o?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eV,{label:"Billing email",hint:"Invoices and receipts go here.",children:(0,t.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:m.email??"Set after checkout"})}),(0,t.jsx)(eV,{label:"Payment method",children:(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:m.cardBrand&&m.cardLastFour?`${m.cardBrand.charAt(0).toUpperCase()}${m.cardBrand.slice(1)} •••• ${m.cardLastFour}`:"None on file"})}),(0,t.jsx)(eV,{label:"Invoices & receipts",hint:"Opens your secure billing portal - every invoice, and your card.",children:m.portalUrl?(0,t.jsx)(_.Button,{size:"sm",variant:"outline",nativeButton:!1,render:(0,t.jsx)("a",{href:m.portalUrl,target:"_blank",rel:"noreferrer"}),children:"Open billing portal"}):(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Unavailable"})}),!p&&(0,t.jsx)(eV,{label:"Cancel subscription",hint:(0,t.jsxs)(t.Fragment,{children:["Your plan and credits stay until the end of the paid period. Cancelling on its own does not refund the current cycle - if the plan started in the last seven days, see the"," ",(0,t.jsx)(es.default,{href:"/refund",target:"_blank",rel:"noopener",className:"font-medium text-foreground underline-offset-4 hover:underline",children:"refund policy"}),"."]}),children:(0,t.jsx)(_.Button,{size:"sm",variant:"outline",className:"border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:()=>c(!0),children:"Cancel subscription"})}),(0,t.jsx)(e$,{open:d,onOpenChange:c,planName:r.name,paidUntil:x(m.renewsAt)})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eV,{label:"Billing email",hint:"Invoices and receipts go here.",children:(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Set after checkout"})}),(0,t.jsx)(eV,{label:"Payment method",children:(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"None on file"})})]}):(0,t.jsxs)("div",{className:"mt-5 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(C.Spinner,{className:"size-4"})," Loading billing details…"]})]})}function e$({open:e,onOpenChange:n,planName:r,paidUntil:a}
3){let[i,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(!1),c=async()=>{o(!0);try{let e=await fetch("/api/billing/cancel",{method:"POST"}),t=await e.json().catch(()=>null);if(!e.ok){E.toast.error("Couldn't cancel your subscription",{description:t?.message??"Please try again."}),o(!1);return}d(!0),E.toast.success("Subscription cancelled",{description:a?`Your plan stays active until ${a}.`:"Your plan stays active until the end of the paid period."})}catch{E.toast.error("Couldn't cancel your subscription",{description:"Please try again."}),o(!1)}};return(0,t.jsx)(A.Dialog,{open:e,onOpenChange:e=>{(!i||l)&&(n(e),!e&&l&&window.location.reload())},children:(0,t.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(A.DialogHeader,{children:[(0,t.jsxs)(A.DialogTitle,{children:["Cancel your ",r," subscription?"]}),(0,t.jsx)(A.DialogDescription,{children:a?`You keep your plan and its credits until ${a} - what you've paid for is honoured. After that your workspace moves to the Free plan. Cancelling does not refund the current cycle.`:"You keep your plan and its credits until the end of the paid period. After that your workspace moves to the Free plan. Cancelling does not refund the current cycle."})]}),(0,t.jsxs)(A.DialogFooter,{children:[(0,t.jsx)(A.DialogClose,{render:(0,t.jsx)(_.Button,{variant:"outline",disabled:i&&!l}),children:"Keep my plan"}),(0,t.jsx)(_.Button,{variant:"destructive",disabled:i,onClick:()=>void c(),children:i&&!l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.Spinner,{}),"Cancelling…"]}):l?"Cancelled":"Cancel subscription"})]})]})})}
3function eB(){let[e,n]=(0,s.useState)(""),[r,a]=(0,s.useState)(""),[i,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(!1),[h,m]=(0,s.useState)("");async function p(){let t=e.trim();if(t&&t!==h){u(!0);try{let e=await fetch("/api/account/profile",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t})}),s=await e.json();if(!e.ok)throw Error(s.error??`HTTP ${e.status}`);m(s.name??t),n(s.name??t),E.toast.success("Name updated")}catch(e){n(h),E.toast.error("Could not update your name",{description:e instanceof Error?e.message:"Please try again."})}finally{u(!1)}}}return((0,s.useEffect)(()=>{let e=!0;return fetch("/api/account/profile",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(t=>{e&&t&&(n(t.name??""),m(t.name??""),a(t.email??""),o(!!t.editable),d(!0))}).catch(()=>{e&&d(!0)}),()=>{e=!1}},[]),l)?(0,t.jsxs)("div",{className:"mt-5 space-y-4",children:[(0,t.jsx)(eV,{label:"Email",hint:"You sign in with this address; it can't be changed here.",children:(0,t.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:r||"Not set"})}),(0,t.jsx)(eV,{label:"Name",hint:"How you appear to teammates in this workspace.",children:i?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(M.Input,{value:e,onChange:e=>n(e.target.value),onBlur:()=>void p(),onKeyDown:e=>{"Enter"===e.key&&p(),"Escape"===e.key&&n(h)},maxLength:80,placeholder:"Your name",className:"h-9 w-52","aria-label":"Your name"}),(0,t.jsx)(_.Button,{size:"sm",variant:"outline",onClick:()=>void p(),disabled:c||!e.trim()||e.trim()===h,children:c?(0,t.jsx)(C.Spinner,{className:"size-3.5"}):"Save"})]}):(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:e||"Not set"})})]}):(0,t.jsxs)("div",{className:"mt-5 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(C.Spinner,{className:"size-4"})," Loading your profile…"]})}function eF({plan:e,creditsRemaining:n}
3){let[r,a]=(0,s.useState)(!1);return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:"Account"}),(0,t.jsxs)("p",{className:"mt-4 text-xs leading-relaxed text-muted-foreground",children:["Your profile, and the permanent actions below it."," ",(0,t.jsx)(et.DocsLink,{slug:"your-data"})]}),(0,t.jsx)(eB,{}),(0,t.jsx)(eU,{}),(0,t.jsxs)("div",{className:"mt-6 rounded-xl border border-destructive/30 bg-destructive/[0.03] p-4 dark:bg-destructive/10",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-sm font-medium text-destructive",children:[(0,t.jsx)(k.TriangleAlert,{className:"size-4"}),"Danger zone"]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:"Delete account"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"Permanently deletes your account, all chats, and any remaining credits. This can't be undone."})]}),(0,t.jsxs)(_.Button,{variant:"destructive",size:"sm",className:"shrink-0",onClick:()=>a(!0),children:[(0,t.jsx)(w.Trash2,{}),"Delete account"]})]})]}),(0,t.jsx)(eq,{open:r,onOpenChange:a,plan:e,creditsRemaining:n})]})}
3function eU(){let[e,n]=(0,s.useState)(null),[r,a]=(0,s.useState)(!1);async function i(e){a(!0);try{if(!(await fetch("/api/account/email-preferences",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscribed:e})})).ok)return void E.toast.error("Could not change your email settings");n(e),E.toast.success(e?"You will get product emails":"You will not get product emails")}finally{a(!1)}}return(0,s.useEffect)(()=>{let e=new AbortController;return fetch("/api/account/email-preferences",{cache:"no-store",signal:e.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&n(e.subscribed??!0)}).catch(()=>{}),()=>e.abort()},[]),(0,t.jsx)("div",{className:"mt-6 rounded-xl border border-border/70 p-4",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Product emails"}),(0,t.jsx)("p",{className:"mt-0.5 text-sm leading-relaxed text-muted-foreground",children:"News, tips and the occasional offer. Sign-in codes, invites and billing notices are not affected: you need those to use your account."})]}),(0,t.jsx)(_.Button,{variant:e?"outline":"default",size:"sm",className:"shrink-0",disabled:null===e||r,onClick:()=>void i(!e),children:null===e?"Loading…":e?"Unsubscribe":"Subscribe"})]})})}let eH="DELETE";function eq({open:e,onOpenChange:n,plan:r,creditsRemaining:a}
3){let[i,o]=(0,s.useState)(""),[l,d]=(0,s.useState)(!1),c=i===eH&&!l,u=async()=>{if(i===eH&&!l){d(!0);try{let e=await fetch("/api/account/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:eH})});if(409===e.status){let t=await e.json().catch(()=>null);E.toast.error("Cancel your subscription first",{description:t?.message??"Cancel your subscription in Settings → Billing, then delete your account."}),d(!1);return}if(!e.ok)throw Error(`Delete failed (${e.status})`);window.location.href="/"}catch{E.toast.error("Could not delete your account",{description:"Something went wrong. Please try again."}),d(!1)}}};return(0,t.jsx)(A.Dialog,{open:e,onOpenChange:e=>{l||(e||o(""),n(e))},children:(0,t.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(A.DialogHeader,{children:[(0,t.jsx)(A.DialogTitle,{className:"text-destructive",children:"Delete your account?"}),(0,t.jsx)(A.DialogDescription,{children:"This is permanent and can't be undone. Confirming will immediately:"})]}),(0,t.jsxs)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-destructive"}),(0,t.jsxs)("span",{children:["Delete ",(0,t.jsx)("span",{className:"text-foreground",children:"all your chats and messages"}),"."]})]}),(0,t.jsxs)("li",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"mt-1.5 size-1 shrink-0 rounded-full bg-destructive"}),(0,t.jsxs)("span",{children:["Forfeit your"," ",(0,t.jsxs)("span",{className:"text-foreground",children:[(0,L.formatWholeCredits)(a)," remaining credits"]})," ","- no refund."]})]})]}),O.PLANS[r].subscription&&(0,t.jsx)("p",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-400",children:"Your workspace is on a paid plan. If the subscription is still active, deletion is blocked — cancel it in Settings → Billing first. Already cancelled? You're good to continue."}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("label",{htmlFor:"delete-confirm",className:"text-sm",children:["Type ",(0,t.jsx)("span",{className:"font-mono font-medium text-foreground",children:"DELETE"})," ","to confirm"]}),(0,t.jsx)(M.Input,{id:"delete-confirm",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),u())},disabled:l,autoComplete:"off",autoFocus:!0,placeholder:"DELETE","aria-label":"Type DELETE to confirm account deletion"})]}),(0,t.jsxs)(A.DialogFooter,{children:[(0,t.jsx)(A.DialogClose,{render:(0,t.jsx)(_.Button,{variant:"outline",disabled:l}),children:"Cancel"}),(0,t.jsx)(_.Button,{variant:"destructive",disabled:!c,onClick:()=>void u(),children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(C.Spinner,{}),"Deleting…"]}):"Delete account"})]})]})})}function eK({label:e}){return(0,t.jsxs)("div",{children:[(0,t.jsx)(eW,{children:e}),(0,t.jsx)(T.EmptyState,{className:"mt-8",icon:b.Settings2,title:`${e} settings arrive with the next release.`})]})}function eW({children:e}){return(0,t.jsx)("h2",{className:"border-b border-border/60 pb-3 text-base font-medium",children:e})}function eV({label:e,hint:s,children:n}){return(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 border-b border-border/60 py-4 sm:flex-row sm:items-start sm:justify-between sm:gap-6",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm",children:e}),s&&(0,t.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:s})]}),(0,t.jsx)("div",{className:"shrink-0 self-end sm:self-start",children:n})]})}function eJ({value:e,options:n}
3){let[r,o]=(0,s.useState)(!1),l=(0,s.useRef)(void 0);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsxs)("span",{"aria-live":"polite",className:`inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 transition-opacity duration-300 dark:text-emerald-400 ${r?"opacity-100":"opacity-0"}`,children:[(0,t.jsx)(a.Check,{className:"size-3"}),"Saved!"]}),(0,t.jsxs)(D.DropdownMenu,{children:[(0,t.jsx)(D.DropdownMenuTrigger,{render:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-lg px-2 py-1 text-sm transition-colors duration-200 hover:bg-muted",children:[e,(0,t.jsx)(i.ChevronDown,{className:"size-3.5 opacity-60"})]})}),(0,t.jsx)(D.DropdownMenuContent,{align:"end",className:"w-auto min-w-36",children:n.map(s=>(0,t.jsxs)(D.DropdownMenuItem,{onClick:()=>{s.label!==e&&(s.onSelect?.(),o(!0),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(!1),1800))},className:"flex items-center justify-between gap-3",style:s.style,children:[s.label,s.label===e&&(0,t.jsx)(a.Check,{className:"size-3.5"})]},s.label))})]})]})}function eY({on:e,onChange:s,disabled:n,label:r}){return(0,t.jsx)(P.Switch,{on:e,onChange:s,disabled:n,label:r})}e.s(["SETTINGS_SECTIONS",0,ec,"SettingsDialog",0,function({open:e,onOpenChange:n,plan:r,creditsRemaining:a,preferences:i,onPreferencesChange:o,signedIn:l=!0,initialSection:d="app"}){let[c,u]=(0,s.useState)(d),[h,m]=(0,s.useState)(!1),f=(0,s.useRef)(null);return(0,s.useEffect)(()=>{e&&f.current?.querySelector("[data-row-active]")?.scrollIntoView({inline:"center",block:"nearest"})},[e,c]),(0,s.useEffect)(()=>{e&&function(e){try{window.localStorage.setItem(em,e)}catch{}}(c)},[e,c]),(0,t.jsxs)(A.Dialog,{open:e,onOpenChange:n,children:[(0,t.jsx)(A.DialogContent,{className:"gap-0 overflow-hidden p-0 sm:max-w-[60rem]",children:(0,t.jsxs)("div",{className:"flex h-[min(94dvh,60rem)] flex-col sm:flex-row",children:[(0,t.jsxs)("div",{className:"shrink-0 border-b border-border/60 bg-muted/30 sm:hidden",children:[(0,t.jsx)("p",{"aria-hidden":!0,className:"px-4 pb-1 pr-12 pt-4 text-sm font-medium",children:"Settings"}),(0,t.jsxs)("div",{ref:f,className:"flex gap-1.5 overflow-x-auto px-3 pb-3 pt-1.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[ed.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>u(e.id),"data-row-active":c===e.id?"":void 0,className:`relative flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border px-3 py-1.5 text-[13px] transition-all duration-200 active:scale-[0.98] ${c===e.id?"border-border bg-card font-medium text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)]":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[(0,t.jsx)(e.icon,{className:"size-3.5 shrink-0"}),e.label]},e.id)),l?(0,t.jsx)("form",{action:"/api/auth/logout",method:"post",className:"shrink-0",children:(0,t.jsxs)("button",{type:"submit",className:"flex items-center gap-1.5 whitespace-nowrap rounded-full border border-transparent px-3 py-1.5 text-[13px] text-muted-foreground transition-all duration-200 hover:bg-destructive/10 hover:text-destructive active:scale-[0.98]",children:[(0,t.jsx)(x.LogOut,{className:"size-3.5 shrink-0"}),"Sign out"]})}):(0,t.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-transparent px-3 py-1.5 text-[13px] text-muted-foreground transition-all duration-200 hover:text-foreground active:scale-[0.98]",children:[(0,t.jsx)(p.LogIn,{className:"size-3.5 shrink-0"}),"Sign in"]})]})]}),(0,t.jsxs)("nav",{className:"hidden w-56 shrink-0 flex-col border-r border-border/60 bg-muted/30 p-3 sm:flex",children:[(0,t.jsx)(A.DialogTitle,{className:"flex items-center gap-2 px-2 pb-2 pt-1 text-sm font-medium",children:"Settings"}),(0,t.jsx)("div",{className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto",children:ed.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>u(e.id),"data-row-active":c===e.id?"":void 0,className:`relative flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-[13px] transition-all duration-200 active:scale-[0.99] ${c===e.id?"bg-card font-medium text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.04)]":"text-muted-foreground hover:bg-card/60 hover:text-foreground"}`,children:[(0,t.jsx)(e.icon,{className:"size-4 shrink-0"}),e.label]},e.id))}),l?(0,t.jsx)("form",{action:"/api/auth/logout",method:"post",className:"mt-2 shrink-0 border-t border-border/60 pt-2",children:(0,t.jsxs)("button",{type:"submit",className:"flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-[13px] text-muted-foreground transition-all duration-200 hover:bg-destructive/10 hover:text-destructive active:scale-[0.99]",children:[(0,t.jsx)(x.LogOut,{className:"size-4 shrink-0"}
3),"Sign out"]})}):(0,t.jsx)("div",{className:"mt-2 shrink-0 border-t border-border/60 pt-2",children:(0,t.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-[13px] text-muted-foreground transition-all duration-200 hover:bg-card/60 hover:text-foreground active:scale-[0.99]",children:[(0,t.jsx)(p.LogIn,{className:"size-4 shrink-0"}),"Sign in"]})})]}),(0,t.jsx)("div",{className:"min-w-0 flex-1 overflow-y-auto px-5 py-5 sm:px-8 sm:py-6",children:!l&&eu.includes(c)?(0,t.jsx)(ep,{label:ed.find(e=>e.id===c).label,onSignIn:()=>m(!0)}):(0,t.jsxs)(t.Fragment,{children:["personalization"===c&&(0,t.jsx)(ex,{}),"preferences"===c&&(0,t.jsx)(ey,{preferences:i,onPreferencesChange:o}),"app"===c&&(0,t.jsx)(ek,{preferences:i,onPreferencesChange:o}),"models"===c&&(0,t.jsx)(eO,{preferences:i,onPreferencesChange:o}),"voice"===c&&(0,t.jsx)(eL,{preferences:i,onPreferencesChange:o}),"keyboard"===c&&(0,t.jsx)(eI,{}),"usage"===c&&(0,t.jsx)(Q.UsageSection,{enabled:"usage"===c}),"billing"===c&&(0,t.jsx)(eR,{plan:r,creditsRemaining:a}),"members"===c&&(0,t.jsx)(W.MembersSection,{plan:r}),"prompts"===c&&(0,t.jsx)(en.PromptsSection,{}),"skills"===c&&(0,t.jsx)(ea.SkillsSection,{}),"knowledge"===c&&(0,t.jsx)(Z.KnowledgeSection,{}),"keys"===c&&(0,t.jsx)(G.ApiKeysSection,{}),"data"===c&&(0,t.jsx)(X.DataSection,{}),"account"===c&&(0,t.jsx)(eF,{plan:r,creditsRemaining:a}),!eh.includes(c)&&(0,t.jsx)(eK,{label:ed.find(e=>e.id===c).label})]})})]})}),(0,t.jsx)(z.LoginDialog,{open:h,onOpenChange:m})]})},"lastSettingsSection",0,function(){try{let e=window.localStorage.getItem(em);if(e&&eh.includes(e))return e}catch{}return"app"}])}]);

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