var c=Object.defineProperty;var u=(e,o,t)=>o in e?c(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var i=(e,o,t)=>u(e,typeof o!="symbol"?o+"":o,t);import{e as m,a as l,w as p}from"./index-BKC7zwXz.js";function C(e,o){return p(),m("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[l("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m4.5 12.75 6 6 9-13.5"})])}class f extends Error{constructor(t,n){super(n.message||n.code||"API error");i(this,"status");i(this,"code");i(this,"fieldErrors");this.status=t,this.code=n.code,this.fieldErrors=n.errors}}async function r(e,o={}){const t=(e.startsWith("http"),e),n=await fetch(t,{method:o.method??"GET",headers:{Accept:"application/json",...o.body!==void 0?{"Content-Type":"application/json"}:{},...o.headers??{}},body:o.body!==void 0?JSON.stringify(o.body):void 0});if(n.status===204)return;const a=n.headers.get("content-type")??"";if(!n.ok){let d={code:"http_"+n.status,message:n.statusText};if(a.includes("application/json"))try{d=await n.json()}catch{}throw new f(n.status,d)}return a.includes("application/json")?await n.json():await n.blob()}const s="/api/polls";function P(e){return r(s,{method:"POST",body:e})}function g(e,o){const t={};return o&&(t["X-Participant-Token"]=o),r(`${s}/${encodeURIComponent(e)}`,{headers:t})}function E(e){return r(`${s}/admin/${encodeURIComponent(e)}`)}function I(e){return r(`${s}/${encodeURIComponent(e)}/suggest`)}function R(e,o,t){const n={};return t&&(n["X-Participant-Token"]=t),r(`${s}/${encodeURIComponent(e)}/votes`,{method:"POST",body:o,headers:n})}function U(e,o){return r(`${s}/${encodeURIComponent(e)}/votes/${encodeURIComponent(o)}`,{method:"DELETE"})}function w(e,o){return r(`${s}/admin/${encodeURIComponent(e)}/finalize`,{method:"POST",body:{optionId:o}})}function y(e){return r(`${s}/admin/${encodeURIComponent(e)}/reopen`,{method:"POST"})}function T(e){return r(`${s}/admin/${encodeURIComponent(e)}`,{method:"DELETE"})}function b(e,o){return r(`${s}/${encodeURIComponent(e)}/options`,{method:"POST",body:{label:o}})}function v(e,o){return r(`${s}/admin/${encodeURIComponent(e)}/options/${encodeURIComponent(o)}`,{method:"DELETE"})}function A(e,o,t){return r(`${s}/admin/${encodeURIComponent(e)}/options/${encodeURIComponent(o)}`,{method:"PATCH",body:{label:t}})}export{f as A,b as a,P as b,R as c,v as d,T as e,w as f,g,E as h,I as i,C as j,y as k,U as r,A as u};