import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{Fragment as n,jsx as r,jsxs as i}from"hono/jsx/jsx-runtime";import{load as a}from"cheerio";import{renderToString as o}from"hono/jsx/dom/server";const s=async s=>{let{state:c=`all`}=s.req.param(),l=Number.parseInt(s.req.query(`limit`)??`50`,10),u=`https://petition.parliament.uk`,d=new URL(`petitions?state=${c}`,u).href,f=new URL(`petitions.json`,u).href,p=a(await e(d)),m=p(`html`).prop(`lang`)??`en`,h=(await e(f,{query:{page:1,state:c}})).data.slice(0,l).map(e=>{let a=e.attributes,s=a.action,c=o(i(n,{children:[a.background?r(`blockquote`,{children:a.background}):null,a.additional_details?r(`p`,{children:a.additional_details}):null]})),l=`parliament.uk-petition-${e.id}`,d=a.creator_name,f=a.departments?.map(e=>({url:e.url,type:`related`,content_html:e.name}));return{title:s,description:c,pubDate:t(a.created_at),link:new URL(`petitions/${e.id}`,u).href,category:[...new Set([...a.topics??[],...a.departments?.map(e=>e.name)??[]])].filter(Boolean),author:d,guid:l,id:l,content:{html:c,text:a.background},updated:t(a.updated_at),language:m,_extra:{links:f?.length?f:void 0}}}),g=p(`meta[property="og:image"]`).prop(`content`);return{title:p(`h1.page-title`).text(),description:p(`meta[property="twitter:description"]`).prop(`content`),link:d,item:h,allowEmpty:!0,image:g,author:p(`meta[name="msapplication-tooltip"]`).prop(`content`),language:m,id:p(`meta[property="og:url"]`).prop(`content`)}},c={path:`/petitions/:state?`,name:`Petitions`,url:`petition.parliament.uk`,maintainers:[`nczitzk`],handler:s,example:`/parliament.uk/petitions/all`,parameters:{state:"State, `all` by default, see below"},description:`::: tip
If you subscribe to [Recent petitions](https://petition.parliament.uk/petitions?state=recent)，where the URL is \`https://petition.parliament.uk/petitions?state=recent\`, use the value of \`state\` as the parameter to fill in. Therefore, the route will be [\`/parliament.uk/petitions/recent\`](https://rsshub.app/parliament.uk/petitions/recent).
:::

<details>
<summary>More states</summary>

| Name                            | ID                |
| ------------------------------- | ----------------- |
| All petitions                   | all               |
| Open petitions                  | open              |
| Recent petitions                | recent            |
| Closed petitions                | closed            |
| Rejected petitions              | rejected          |
| Awaiting government response    | awaiting_response |
| Government responses            | with_response     |
| Awaiting a debate in Parliament | awaiting_debate   |
| Debated in Parliament           | debated           |
| Not debated in Parliament       | not_debated       |

</details>
    `,categories:[`government`],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`petition.parliament.uk/petitions`],target:(e,t)=>{let n=new URL(t).searchParams.get(`state`);return`/parliament.uk/petitions${n?`/${n}`:``}`}},{title:`All petitions`,source:[`petition.parliament.uk/petitions`],target:`/petitions/all`},{title:`Open petitions`,source:[`petition.parliament.uk/petitions`],target:`/petitions/open`},{title:`Recent petitions`,source:[`petition.parliament.uk/petitions`],target:`/petitions/recent`},{title:`Closed petitions`,source:[`petition.parliament.uk/petitions`],target:`/petitions/closed`},{title:`Rejected petitions`,source:[`petition.parliament.uk/petitions`],target:`/petitions/rejected`},{title:`Awaiting government response`,source:[`petition.parliament.uk/petitions`],target:`/petitions/awaiting_response`},{title:`Government responses`,source:[`petition.parliament.uk/petitions`],target:`/petitions/with_response`},{title:`Awaiting a debate in Parliament`,source:[`petition.parliament.uk/petitions`],target:`/petitions/awaiting_debate`},{title:`Debated in Parliament`,source:[`petition.parliament.uk/petitions`],target:`/petitions/debated`},{title:`Not debated in Parliament`,source:[`petition.parliament.uk/petitions`],target:`/petitions/not_debated`}],view:0};export{s as handler,c as route};