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

  & + & {
    margin-top: calc(var(--spacing-base) * 2);
  }
`,H=x(v)`
  && {
    padding-left: 0;
  }
`,me=k(N);export{me as McpPrompt};
