var E=Object.defineProperty,T=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var g=(s,t,n)=>t in s?E(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,d=(s,t)=>{for(var n in t||(t={}))C.call(t,n)&&g(s,n,t[n]);if(y)for(var n of y(t))L.call(t,n)&&g(s,n,t[n]);return s},b=(s,t)=>T(s,O(t));import{j as e,N as h,a as c,C as S,b as v,r as w,u as P,T as j,F as m,B as N,R as x,c as z}from"./vendor.ce87bf07.js";const D=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerpolicy&&(o.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?o.credentials="include":r.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}};D();const I=()=>e(h,{bg:"light",expand:"lg",children:c(S,{children:[e(h.Brand,{href:"/",children:"Debouncer"}),e(h.Toggle,{"aria-controls":"main-nav"}),e(h.Collapse,{id:"main-nav",children:e(v,{className:"ms-auto",children:e(v.Link,{target:"_blank",href:"https://github.com/jooola/debouncer",children:"Github"})})})]})}),p=new URL("/api",window.location.origin);class f{static list(){return fetch(`${p}/`)}static create(t){return fetch(`${p}/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}static delete(t){return fetch(`${p}/${t}`,{method:"DELETE"})}}const R=()=>{const[s,t]=w.exports.useState([]),n=async()=>{const u=await(await f.list()).json();t(u)},{register:a,watch:r}=P({defaultValues:{url:"https://example.com/",method:"POST",timeout:10}}),o=async()=>{const i=await f.create(r());console.log(i),await n()},l=i=>async()=>{const u=await f.delete(i);console.log(u),await n()};return w.exports.useEffect(()=>{n()},[]),c(j,{striped:!0,bordered:!0,hover:!0,children:[e("thead",{children:c("tr",{children:[e("th",{style:{width:"22rem"},children:"ID"}),e("th",{style:{width:"8rem"},children:"Method"}),e("th",{children:"URL"}),e("th",{style:{width:"6rem"},children:"Timeout"}),e("th",{style:{width:"6rem"}})]})}),c("tbody",{children:[c("tr",{children:[e("td",{}),e("td",{className:"p-1",children:c(m.Select,b(d({size:"sm"},a("method")),{children:[e("option",{value:"POST",children:"POST"}),e("option",{value:"GET",children:"GET"})]}))}),e("td",{className:"p-1",children:e(m.Control,d({size:"sm",type:"text"},a("url")))}),e("td",{className:"p-1",children:e(m.Control,d({size:"sm",type:"number"},a("timeout")))}),e("td",{className:"p-1",children:e(N,{variant:"success",size:"sm",onClick:o,children:"Create"})})]}),s.map(i=>c("tr",{children:[e("td",{children:i.uid}),e("td",{children:i.method}),e("td",{children:i.url}),e("td",{children:i.timeout}),e("td",{className:"p-1",children:e(N,{variant:"danger",size:"sm",onClick:l(i.uid),children:"Delete"})})]},i.uid))]})]})},k=()=>c("div",{children:[e(I,{}),e("div",{className:"container-md p-4",children:e(R,{})})]});x.render(e(z.StrictMode,{children:e(k,{})}),document.getElementById("root"));
