import{jsxs as r,jsx as o}from"react/jsx-runtime";import{memo as j,useCallback as v,useMemo as l}from"react";import{useAtomValue as s}from"jotai";import{LayoutVariant as h}from"@redocly/config";import{getMediaContent as A,getSecurity as E}from"../../models/index.js";import{globalStoreAtom as f}from"../../jotai/store.js";import{Section as P,Row as b,SamplesMiddlePanel as R,SamplesPanel as w,CodeBlockPanel as D}from"../common/index.js";import{Schema as F}from"../Schema/index.js";import{getSchema as L}from"../../models/schema.js";import{layoutAtom as S}from"../../jotai/app.js";import{MediaTypeSamples as N}from"../PayloadSamples/MediaTypeSamples.js";import{useTranslate as O}from"../../hooks/index.js";import{Title as I}from"../common/OperationItemTitle.js";import{LinkToField as K}from"../common/LinkToField.js";import{makeDeepLink as V}from"../../services/index.js";import{Security as _}from"../Security/Security.js";import{Markdown as q}from"../Markdown/index.js";import{styled as T}from"../../styled-components.js";function B({name:i,id:m}){const{parser:p}=s(f),t=O(),a=s(S),u=a===h.STACKED,e=l(()=>(p.definition["x-mcp"]?.tools||[]).find(c=>c.name===i),[p,i]),n=l(()=>e?E(e.security,p):null,[p,e]);return e?r(P,{className:"mcp-tool",children:[o(x,{layout:a,children:o(M,{isStacked:u,children:r("div",{children:[r("p",{children:[t("openapi.mcp.toolName","Tool name"),": ",o("code",{children:e.name})]}),e.description&&o(q,{source:e.description})]})})}),o(y,{id:m,type:"input",schema:e.inputSchema,title:t("openapi.mcp.inputSchema","Input schema"),exampleTitle:t("openapi.mcp.inputExample","Input example"),children:n&&o(_,{securities:n})}),e.outputSchema&&o(y,{id:m,type:"output",schema:e.outputSchema,title:t("openapi.mcp.outputSchema","Output schema"),exampleTitle:t("openapi.mcp.outputExample","Output example")})]}):r("div",{children:["Tool not found: ",i]})}function y({schema:i,title:m,exampleTitle:p,id:t,type:a,children:u}){const{parser:e,options:n}=s(f),d=s(S),c=d===h.STACKED,k=l(()=>A({parser:e,info:{"application/json":{schema:i}},isRequestType:!1,options:n,data:{operation:{pointer:"McpTool"}}}),[n,e,i]),g=l(()=>i&&L({parser:e,schemaOrRef:i,pointer:"#",options:n,deps:{operation:{pointer:t},parentFieldFullPath:a+"-schema"}}),[n,e,i,t,a]),C=v(()=>{},[]);return r(x,{layout:d,children:[o(M,{isStacked:c,children:r("div",{children:[r(I,{children:[t&&o(K,{to:V(t,a)}),m]}),u,o(F,{schema:g})]})}),o(w,{isStacked:c,children:o(D,{className:"panel-response-samples",header:p,children:o(N,{mediaType:k.mediaTypes[0],onChange:C})})})]})}const x=T(b)`
  margin: calc(var(--spacing-unit) * 2) 0;

  & + & {
    margin-top: calc(var(--spacing-base) * 2);
  }
`,M=T(R)`
  && {
    padding-left: 0;
  }
`,ae=j(B);export{ae as McpTool};
