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

  & + & {
    margin-top: calc(var(--spacing-base) * 2);
  }
`,K=h(v)`
  padding-left: 0;
`,re=M(q);export{re as McpTool};
