import{deleteCookie as S,getCookie as q,setCookie as b}from"hono/cookie";const j=new Set([101,103,204,205,304]),l=t=>t!==void 0&&j.has(t),k=({honoCtx:t,ctx:d,telemetry:o,getKv:m})=>{const u=t.req.routePath,p=t.req.param(),f=Object.fromEntries(Object.entries(p).map(([e,r])=>{if(r&&(u.includes(`/:${e}{.*}`)||u.includes(`/:${e}{.+}`))){const a=r.split("/").filter(Boolean);return[e,a.length?a:void 0]}return[e,r]}));let n;const i=e=>{n=e,t.status(e)},s={...t.res,status:e=>(i(e),s),json:e=>l(n)?t.body(null):t.json(e),text:(e,r)=>(r&&i(r),l(n)?t.body(null):t.text(e)),redirect:(e,r=302)=>t.redirect(e,r),setCookie:(e,r,c)=>(b(t,e,r,c),s),deleteCookie:e=>(S(t,e),s)};return{...d,...s,params:f,query:t.req.query()||{},cookies:q(t),telemetry:o,getKv:m}};export{k as enhanceContext};
