opus-submitter/polylan_submitter/static_source/vite/assets/sdk.gen-yuJ1arsq.js
2026-05-24 19:21:05 +02:00

7 lines
10 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const F={bodySerializer:e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString():r)};function Q({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:a,responseValidator:o,sseDefaultRetryDelay:c,sseMaxRetryAttempts:n,sseMaxRetryDelay:s,sseSleepFn:i,url:m,...u}){let l;const w=i??(d=>new Promise(h=>setTimeout(h,d)));return{stream:async function*(){let d=c??3e3,h=0;const g=u.signal??new AbortController().signal;for(;!g.aborted;){h++;const A=u.headers instanceof Headers?u.headers:new Headers(u.headers);l!==void 0&&A.set("Last-Event-ID",l);try{const z={redirect:"follow",...u,body:u.serializedBody,headers:A,signal:g};let E=new Request(m,z);e&&(E=await e(m,z));const p=await(u.fetch??globalThis.fetch)(E);if(!p.ok)throw new Error(`SSE failed: ${p.status} ${p.statusText}`);if(!p.body)throw new Error("No body in SSE response");const S=p.body.pipeThrough(new TextDecoderStream).getReader();let y="";const v=()=>{try{S.cancel()}catch{}};g.addEventListener("abort",v);try{for(;;){const{done:_,value:M}=await S.read();if(_)break;y+=M,y=y.replace(/\r\n?/g,`
`);const $=y.split(`
`);y=$.pop()??"";for(const J of $){const G=J.split(`
`),C=[];let I;for(const k of G)if(k.startsWith("data:"))C.push(k.replace(/^data:\s*/,""));else if(k.startsWith("event:"))I=k.replace(/^event:\s*/,"");else if(k.startsWith("id:"))l=k.replace(/^id:\s*/,"");else if(k.startsWith("retry:")){const U=Number.parseInt(k.replace(/^retry:\s*/,""),10);Number.isNaN(U)||(d=U)}let x,B=!1;if(C.length){const k=C.join(`
`);try{x=JSON.parse(k),B=!0}catch{x=k}}B&&(o&&await o(x),a&&(x=await a(x))),r?.({data:x,event:I,id:l,retry:d}),C.length&&(yield x)}}}finally{g.removeEventListener("abort",v),S.releaseLock()}break}catch(z){if(t?.(z),n!==void 0&&h>=n)break;const E=Math.min(d*2**(h-1),s??3e4);await w(E)}}}()}}const K=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},X=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},Y=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},D=({allowReserved:e,explode:t,name:r,style:a,value:o})=>{if(!t){const s=(e?o:o.map(i=>encodeURIComponent(i))).join(X(a));switch(a){case"label":return`.${s}`;case"matrix":return`;${r}=${s}`;case"simple":return s;default:return`${r}=${s}`}}const c=K(a),n=o.map(s=>a==="label"||a==="simple"?e?s:encodeURIComponent(s):O({allowReserved:e,name:r,value:s})).join(c);return a==="label"||a==="matrix"?c+n:n},O=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects arent supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},W=({allowReserved:e,explode:t,name:r,style:a,value:o,valueOnly:c})=>{if(o instanceof Date)return c?o.toISOString():`${r}=${o.toISOString()}`;if(a!=="deepObject"&&!t){let i=[];Object.entries(o).forEach(([u,l])=>{i=[...i,u,e?l:encodeURIComponent(l)]});const m=i.join(",");switch(a){case"form":return`${r}=${m}`;case"label":return`.${m}`;case"matrix":return`;${r}=${m}`;default:return m}}const n=Y(a),s=Object.entries(o).map(([i,m])=>O({allowReserved:e,name:a==="deepObject"?`${r}[${i}]`:i,value:m})).join(n);return a==="label"||a==="matrix"?n+s:s},Z=/\{[^{}]+\}/g,ee=({path:e,url:t})=>{let r=t;const a=t.match(Z);if(a)for(const o of a){let c=!1,n=o.substring(1,o.length-1),s="simple";n.endsWith("*")&&(c=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),s="label"):n.startsWith(";")&&(n=n.substring(1),s="matrix");const i=e[n];if(i==null)continue;if(Array.isArray(i)){r=r.replace(o,D({explode:c,name:n,style:s,value:i}));continue}if(typeof i=="object"){r=r.replace(o,W({explode:c,name:n,style:s,value:i,valueOnly:!0}));continue}if(s==="matrix"){r=r.replace(o,`;${O({name:n,value:i})}`);continue}const m=encodeURIComponent(s==="label"?`.${i}`:i);r=r.replace(o,m)}return r},te=({baseUrl:e,path:t,query:r,querySerializer:a,url:o})=>{const c=o.startsWith("/")?o:`/${o}`;let n=(e??"")+c;t&&(n=ee({path:t,url:n}));let s=r?a(r):"";return s.startsWith("?")&&(s=s.substring(1)),s&&(n+=`?${s}`),n};function R(e){const t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}const re=async(e,t)=>{const r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r},H=({parameters:e={},...t}={})=>a=>{const o=[];if(a&&typeof a=="object")for(const c in a){const n=a[c];if(n==null)continue;const s=e[c]||t;if(Array.isArray(n)){const i=D({allowReserved:s.allowReserved,explode:!0,name:c,style:"form",value:n,...s.array});i&&o.push(i)}else if(typeof n=="object"){const i=W({allowReserved:s.allowReserved,explode:!0,name:c,style:"deepObject",value:n,...s.object});i&&o.push(i)}else{const i=O({allowReserved:s.allowReserved,name:c,value:n});i&&o.push(i)}}return o.join("&")},se=e=>{if(!e)return"stream";const t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},ae=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`)):!1;async function ne(e){for(const t of e.security??[]){if(ae(e,t.name))continue;const r=await re(t,e.auth);if(!r)continue;const a=t.name??"Authorization";switch(t.in){case"query":e.query||(e.query={}),e.query[a]=r;break;case"cookie":e.headers.append("Cookie",`${a}=${r}`);break;case"header":default:e.headers.set(a,r);break}}}const N=e=>te({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:H(e.querySerializer),url:e.url}),P=(e,t)=>{const r={...e,...t};return r.baseUrl?.endsWith("/")&&(r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1)),r.headers=L(e.headers,t.headers),r},ie=e=>{const t=[];return e.forEach((r,a)=>{t.push([a,r])}),t},L=(...e)=>{const t=new Headers;for(const r of e){if(!r)continue;const a=r instanceof Headers?ie(r):Object.entries(r);for(const[o,c]of a)if(c===null)t.delete(o);else if(Array.isArray(c))for(const n of c)t.append(o,n);else c!==void 0&&t.set(o,typeof c=="object"?JSON.stringify(c):c)}return t};class T{fns=[];clear(){this.fns=[]}eject(t){const r=this.getInterceptorIndex(t);this.fns[r]&&(this.fns[r]=null)}exists(t){const r=this.getInterceptorIndex(t);return!!this.fns[r]}getInterceptorIndex(t){return typeof t=="number"?this.fns[t]?t:-1:this.fns.indexOf(t)}update(t,r){const a=this.getInterceptorIndex(t);return this.fns[a]?(this.fns[a]=r,t):!1}use(t){return this.fns.push(t),this.fns.length-1}}const oe=()=>({error:new T,request:new T,response:new T}),ce=H({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),le={"Content-Type":"application/json"},V=(e={})=>({...F,headers:le,parseAs:"auto",querySerializer:ce,...e}),ue=(e={})=>{let t=P(V(),e);const r=()=>({...t}),a=u=>(t=P(t,u),r()),o=oe(),c=async u=>{const l={...t,...u,fetch:u.fetch??t.fetch??globalThis.fetch,headers:L(t.headers,u.headers),serializedBody:void 0};l.security&&await ne(l),l.requestValidator&&await l.requestValidator(l),l.body!==void 0&&l.bodySerializer&&(l.serializedBody=l.bodySerializer(l.body)),(l.body===void 0||l.serializedBody==="")&&l.headers.delete("Content-Type");const w=l,b=N(w);return{opts:w,url:b}},n=async u=>{const l=u.throwOnError??t.throwOnError,w=u.responseStyle??t.responseStyle;let b,f;try{const{opts:d,url:h}=await c(u),g={redirect:"follow",...d,body:R(d)};b=new Request(h,g);for(const p of o.request.fns)p&&(b=await p(b,d));const A=d.fetch;f=await A(b);for(const p of o.response.fns)p&&(f=await p(f,b,d));const z={request:b,response:f};if(f.ok){const p=(d.parseAs==="auto"?se(f.headers.get("Content-Type")):d.parseAs)??"json";if(f.status===204||f.headers.get("Content-Length")==="0"){let y;switch(p){case"arrayBuffer":case"blob":case"text":y=await f[p]();break;case"formData":y=new FormData;break;case"stream":y=f.body;break;case"json":default:y={};break}return d.responseStyle==="data"?y:{data:y,...z}}let S;switch(p){case"arrayBuffer":case"blob":case"formData":case"text":S=await f[p]();break;case"json":{const y=await f.text();S=y?JSON.parse(y):{};break}case"stream":return d.responseStyle==="data"?f.body:{data:f.body,...z}}return p==="json"&&(d.responseValidator&&await d.responseValidator(S),d.responseTransformer&&(S=await d.responseTransformer(S))),d.responseStyle==="data"?S:{data:S,...z}}const E=await f.text();let q;try{q=JSON.parse(E)}catch{}throw q??E}catch(d){let h=d;for(const g of o.error.fns)g&&(h=await g(h,f,b,u));if(h=h||{},l)throw h;return w==="data"?void 0:{error:h,request:b,response:f}}},s=u=>l=>n({...l,method:u}),i=u=>async l=>{const{opts:w,url:b}=await c(l);return Q({...w,body:w.body,method:u,onRequest:async(f,d)=>{let h=new Request(f,d);for(const g of o.request.fns)g&&(h=await g(h,w));return h},serializedBody:R(w),url:b})};return{buildUrl:u=>N({...t,...u}),connect:s("CONNECT"),delete:s("DELETE"),get:s("GET"),getConfig:r,head:s("HEAD"),interceptors:o,options:s("OPTIONS"),patch:s("PATCH"),post:s("POST"),put:s("PUT"),request:n,setConfig:a,sse:{connect:i("CONNECT"),delete:i("DELETE"),get:i("GET"),head:i("HEAD"),options:i("OPTIONS"),patch:i("PATCH"),post:i("POST"),put:i("PUT"),trace:i("TRACE")},trace:s("TRACE")}},j=ue(V()),de=e=>(e?.client??j).get({url:"/api/user",...e}),fe=e=>(e?.client??j).get({url:"/api/opus-magnum/puzzles",...e}),he=e=>(e?.client??j).get({url:"/api/opus-magnum/collection",...e}),pe=e=>(e?.client??j).get({url:"/api/games/",...e}),ye=e=>(e?.client??j).get({url:"/api/market/",...e}),be=e=>(e?.client??j).get({url:"/api/market/user/bets",...e}),me=e=>(e.client??j).post({url:"/api/market/{market_uuid}/actions/close",...e}),ge=e=>(e.client??j).post({url:"/api/market/{market_uuid}/actions/resolve",...e,headers:{"Content-Type":"application/json",...e.headers}}),we=e=>(e.client??j).post({url:"/api/market/{market_uuid}/bets",...e,headers:{"Content-Type":"application/json",...e.headers}});export{he as a,be as b,me as c,ge as d,we as e,pe as g,ye as m,fe as o,de as p};