async function handleRequest(a){const b=new URL(a.url);let c=b.searchParams.get("apiurl");null==c&&(c=API_URL),a=new Request(c,a),a.headers.set("Origin",new URL(c).origin);let d=await fetch(a);return d=new Response(d.body,d),d.headers.set("Access-Control-Allow-Origin","*"),d.headers.append("Vary","Origin"),d}function handleOptions(a){return null!==a.headers.get("Origin")&&null!==a.headers.get("Access-Control-Request-Method")&&null!==a.headers.get("Access-Control-Request-Headers")?new Response(null,{headers:corsHeaders}):new Response(null,{headers:{Allow:"GET, HEAD, POST, OPTIONS"}})}addEventListener("fetch",a=>{const b=a.request,c=new URL(b.url);c.pathname.startsWith(PROXY_ENDPOINT)?"OPTIONS"===b.method?a.respondWith(handleOptions(b)):"GET"===b.method||"HEAD"===b.method||"POST"===b.method?a.respondWith(handleRequest(b)):a.respondWith(new Response(null,{status:405,statusText:"Method Not Allowed"})):a.respondWith(rawHtmlResponse(DEMO_PAGE))});const corsHeaders={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, HEAD, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"},API_URL="https://workers-tooling.cf/demos/demoapi",PROXY_ENDPOINT="/corsproxy/";async function rawHtmlResponse(a){return new Response(a,{headers:{"content-type":"text/html;charset=UTF-8"}})}const DEMO_PAGE=`
Waiting
Waiting
Waiting
`;