import{k as e,q as t,aY as s,du as i,oM as o,h8 as r,PN as a,vZ as n,kX as c,kY as l,ex as u,q_ as d,SB as p,bC as h,y as m,bD as g,qY as f,Mu as w,SC as _,I as b,a9 as v,et as C,cC as y,SD as k,SE as E,SF as S,SG as q,SH as I,SI as L,SJ as V,SK as $,SL as M,SM as H,SN as x,SO as z,SP as R,SQ as T,SR as P,SS as j,hm as N,hn as O,ST as A,SU as U,db as Z,SV as F,hp as W,SW as Y}from"./c818056db-BBpc4u6S.js";import{r as D,j as G}from"./vendor-react-RSDKEZ60.js";import{c as X}from"./vendor-query-AdjnXGiH.js";const B="claude:new-conversation";function K(){const u=e(),d=t(),{matchShortcut:p}=s("quick_chat"),h=i(),m=o(),g=r(),f=a(),w="/task"===u||u.startsWith("/task/"),_=m?f[g]:w?"/task/new":"/new",b=!h.isAvailable||u===_||u.startsWith("/code"),v=D.useCallback(()=>{d.push(_)},[d,_]);n("quick_chat",v,{disabled:b});const C=D.useCallback(()=>{const e=new CustomEvent(B,{cancelable:!0});window.dispatchEvent(e),e.defaultPrevented||b||v()},[b,v]);return c(l.cmdK,C),D.useEffect(()=>{if(b)return;const e=e=>{p(e)&&(e.preventDefault(),C())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[b,p,C]),null}function J(e){switch(e){case"task":return d;case"code":case"epitaxy":return u;default:return"/new"}}function Q(){const{matchShortcut:e}=s("new_conversation"),i=t(),{selectedMode:o}=p(),r=J(o),a=D.useCallback(()=>{const e=new CustomEvent(B,{cancelable:!0});window.dispatchEvent(e),e.defaultPrevented||window.location.pathname!==r&&i.push(r)},[i,r]);n("new_conversation",a),D.useEffect(()=>{const t=t=>{if(e(t))return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),a(),!1};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[e,a])}function ee({pluginName:e,selectedMode:t,subCustomization:s}){let i;i=s?.specificItemName?`Customize the "${s.specificItemName}" ${s.category} of the "${e}" plugin for me based on my company`:s?`Customize the ${s.category}s of the "${e}" plugin for me based on my company`:`Customize the "${e}" plugin for me based on my company`;const o=new URLSearchParams({q:i});return`${J(t)}?${o.toString()}`}function te(e){const t=h(),{track:s}=m(),i=g(),o=f(),r=w();return{customize:D.useCallback(()=>{const a=!!e.pluginId&&r(e.pluginId);s({event_key:"claudeai.fusion.customize_clicked",...a&&{plugin_id:e.pluginId},is_local:e.isLocal,plugin_context:i?"ccd":"cowork",context:e.context,...e.subCustomization&&{sub_customization:e.subCustomization.category}});const n=ee({pluginName:e.pluginName,selectedMode:o,subCustomization:e.subCustomization});t.push(n)},[r,s,e.context,e.pluginId,e.isLocal,e.pluginName,e.subCustomization,i,o,t])}}function se({iconDataUrl:e,fallback:t,size:s=16}){return t?G.jsx(t,{size:s}):e?G.jsx("span",{"aria-hidden":"true",style:{width:s,height:s,display:"inline-block",backgroundImage:`url("${e}")`,backgroundSize:"115%",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}):null}const ie={[_.VSCode]:{name:"VS Code",icon:function({size:e=16}){return G.jsx("img",{src:"/images/home-page-assets/vscode.svg",alt:"",width:e,height:e})},successMessage:"Opening VS Code"},[_.Cursor]:{name:"Cursor",icon:function({size:e=16}){return G.jsx("svg",{width:e,height:e,viewBox:"0 0 466.73 532.09",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fill:"currentColor",d:"M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"})})},successMessage:"Opening Cursor"},[_.Zed]:{name:"Zed",icon:function({size:e=16}){return G.jsx("svg",{width:e,height:e,viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.4375 5.625C6.8842 5.625 5.625 6.8842 5.625 8.4375V70.3125H0V8.4375C0 3.7776 3.7776 0 8.4375 0H83.7925C87.551 0 89.4333 4.5442 86.7756 7.20186L40.3642 53.6133H53.4375V47.8125H59.0625V55.0195C59.0625 57.3495 57.1737 59.2383 54.8438 59.2383H34.7392L25.0712 68.9062H68.9062V33.75H74.5312V68.9062C74.5312 72.0128 72.0128 74.5312 68.9062 74.5312H19.4462L9.60248 84.375H81.5625C83.1158 84.375 84.375 83.1158 84.375 81.5625V19.6875H90V81.5625C90 86.2224 86.2224 90 81.5625 90H6.20749C2.44898 90 0.566723 85.4558 3.22438 82.7981L49.46 36.5625H36.5625V42.1875H30.9375V35.1562C30.9375 32.8263 32.8263 30.9375 35.1562 30.9375H55.085L64.9288 21.0938H21.0938V56.25H15.4688V21.0938C15.4688 17.9871 17.9871 15.4688 21.0938 15.4688H70.5538L80.3975 5.625H8.4375Z",fill:"currentColor"})})},successMessage:"Opening Zed"},[_.Windsurf]:{name:"Windsurf",successMessage:"Opening Windsurf"},[_.Xcode]:{name:"Xcode",successMessage:"Opening Xcode"}},oe="claude-code-preferred-editor";function re(e){const t=b(),{track:s}=m(),i=g(),{addSuccess:o,addError:r}=v(),{data:a=[]}=X({queryKey:["installedEditors"],queryFn:async()=>{const e=await(C?.getInstalledEditors?.());return e?.filter(e=>e.installed)??[]},enabled:t,staleTime:1/0});return{installedEditors:a,handleOpenEditor:D.useCallback(async t=>{if(C?.openInEditor){const a=ie[t];s({event_key:"claudeai.fusion.edited",method:t,plugin_context:i?"ccd":"cowork"});await C.openInEditor(e,t)?o(a.successMessage):r(`Failed to open ${a.name}.`,{errorContext:{tags:{source:"open_in_editor"}}})}},[e,i,o,r,s]),handleRevealInFinder:D.useCallback(async()=>{s({event_key:"claudeai.fusion.edited",method:"show_in_folder",plugin_context:i?"ccd":"cowork"}),await(y?.showInFolder?.(e))},[e,i,s])}}class ae{constructor(e){this._server=e}requestStream(e,t,s){return this._server.requestStream(e,t,s)}createMessageStream(e,t){const s=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!s?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],s=Array.isArray(t.content)?t.content:[t.content],i=s.some(e=>"tool_result"===e.type),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,r=o?Array.isArray(o.content)?o.content:[o.content]:[],a=r.some(e=>"tool_use"===e.type);if(i){if(s.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!a)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(a){const e=new Set(r.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(s.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},k,t)}elicitInputStream(e,t){const s=this._server.getClientCapabilities(),i=e.mode??"form";switch(i){case"url":if(!s?.elicitation?.url)throw new Error("Client does not support url elicitation.");break;case"form":if(!s?.elicitation?.form)throw new Error("Client does not support form elicitation.")}const o="form"===i&&void 0===e.mode?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},E,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._server.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}}class ne extends S{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(q.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{const s=this._loggingLevels.get(t);return!!s&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(s)},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new I,this.setRequestHandler(L,e=>this._oninitialize(e)),this.setNotificationHandler(V,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler($,async(e,t)=>{const s=t.sessionId||t.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=e.params,o=q.safeParse(i);return o.success&&this._loggingLevels.set(s,o.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ae(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=M(this._capabilities,e)}setRequestHandler(e,t){const s=H(e),i=s?.method;if(!i)throw new Error("Schema is missing a method literal");let o;if(x(i)){const e=i,t=e._zod?.def;o=t?.value??e.value}else{const e=i,t=e._def;o=t?.value??e.value}if("string"!=typeof o)throw new Error("Schema method literal must be a string");if("tools/call"===o){const s=async(e,s)=>{const i=U(Z,e);if(!i.success){const e=i.error instanceof Error?i.error.message:String(i.error);throw new N(O.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:o}=i.data,r=await Promise.resolve(t(e,s));if(o.task){const e=U(F,r);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new N(O.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const a=U(W,r);if(!a.success){const e=a.error instanceof Error?a.error.message:String(a.error);throw new N(O.InvalidParams,`Invalid tools/call result: ${e}`)}return a.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){z(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&R(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;return{protocolVersion:Y.includes(t)?t:T,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},P)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],s=Array.isArray(t.content)?t.content:[t.content],i=s.some(e=>"tool_result"===e.type),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,r=o?Array.isArray(o.content)?o.content:[o.content]:[],a=r.some(e=>"tool_use"===e.type);if(i){if(s.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!a)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(a){const e=new Set(r.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(s.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},j,t):this.request({method:"sampling/createMessage",params:e},k,t)}async elicitInput(e,t){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const s=e;return this.request({method:"elicitation/create",params:s},E,t)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const i="form"===e.mode?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:i},E,t);if("accept"===o.action&&o.content&&i.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!e.valid)throw new N(O.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(s){if(s instanceof N)throw s;throw new N(O.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},A,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}export{K as C,ie as E,B as N,oe as P,ne as S,se as a,te as b,ee as c,Q as d,J as g,re as u};
