import{useCallback as f}from"react";import{withPathPrefix as b,combineUrls as u}from"@redocly/theme/core/utils";import{ServerRoutes as l}from"../../../constants/api";import{usePageData as P}from"../../providers/hooks";import{usePageSharedData as g}from"../../providers/page-data/hooks";function O(){const{basePath:o}=g("openAPIDocsStore")||{},e=P()?.templateId==="openapi_docs";return{submitFeedback:f(async({type:i,values:r,path:n,location:s,lang:c})=>{const m=u(window.location.origin,e?o:"",n),a={};for(const[d,t]of Object.entries(r))a[d]=typeof t=="string"?t.trim():t;const p={location:s?.trim(),lang:c?.trim(),component:i,...a,path:m};await fetch(b(l.FEEDBACK),{method:"POST",body:JSON.stringify(p)})},[o,e])}}export{O as useSubmitFeedback};
