var wt=Object.defineProperty;var yt=(e,t,n)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ne=(e,t,n)=>(yt(e,typeof t!="symbol"?t+"":t,n),n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).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 s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function Q(){}function it(e){return e()}function Ge(){return Object.create(null)}function ce(e){e.forEach(it)}function at(e){return typeof e=="function"}function Ue(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function vt(e){return Object.keys(e).length===0}function L(e,t){e.appendChild(t)}function A(e,t,n){e.insertBefore(t,n||null)}function C(e){e.parentNode&&e.parentNode.removeChild(e)}function B(e){return document.createElement(e)}function J(e){return document.createTextNode(e)}function M(){return J(" ")}function bt(){return J("")}function me(e,t,n,s){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n,s)}function ae(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function $t(e){return Array.from(e.childNodes)}function le(e,t){t=""+t,e.data!==t&&(e.data=t)}function pe(e,t){e.value=t??""}let Ie;function ue(e){Ie=e}const te=[],We=[];let ne=[];const Ve=[],St=Promise.resolve();let Pe=!1;function Et(){Pe||(Pe=!0,St.then(lt))}function Ce(e){ne.push(e)}const ke=new Set;let ee=0;function lt(){if(ee!==0)return;const e=Ie;do{try{for(;eee.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),ne=t}const he=new Set;let kt;function je(e,t){e&&e.i&&(he.delete(e),e.i(t))}function He(e,t,n,s){if(e&&e.o){if(he.has(e))return;he.add(e),kt.c.push(()=>{he.delete(e),s&&(n&&e.d(1),s())}),e.o(t)}else s&&s()}function Ke(e){e&&e.c()}function Ae(e,t,n){const{fragment:s,after_update:r}=e.$$;s&&s.m(t,n),Ce(()=>{const o=e.$$.on_mount.map(it).filter(at);e.$$.on_destroy?e.$$.on_destroy.push(...o):ce(o),e.$$.on_mount=[]}),r.forEach(Ce)}function Te(e,t){const n=e.$$;n.fragment!==null&&(Nt(n.after_update),ce(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function qt(e,t){e.$$.dirty[0]===-1&&(te.push(e),Et(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const $=h.length?h[0]:d;return l.ctx&&r(l.ctx[f],l.ctx[f]=$)&&(!l.skip_bound&&l.bound[f]&&l.bound[f]($),u&&qt(e,f)),d}):[],l.update(),u=!0,ce(l.before_update),l.fragment=s?s(l.ctx):!1,t.target){if(t.hydrate){const f=$t(t.target);l.fragment&&l.fragment.l(f),f.forEach(C)}else l.fragment&&l.fragment.c();t.intro&&je(e.$$.fragment),Ae(e,t.target,t.anchor),lt()}ue(p)}class Fe{constructor(){Ne(this,"$$");Ne(this,"$$set")}$destroy(){Te(this,1),this.$destroy=Q}$on(t,n){if(!at(n))return Q;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(n),()=>{const r=s.indexOf(n);r!==-1&&s.splice(r,1)}}$set(t){this.$$set&&!vt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Dt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Dt);const Lt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20aria-hidden='true'%20role='img'%20class='iconify%20iconify--logos'%20width='26.6'%20height='32'%20preserveAspectRatio='xMidYMid%20meet'%20viewBox='0%200%20256%20308'%3e%3cpath%20fill='%23FF3E00'%20d='M239.682%2040.707C211.113-.182%20154.69-12.301%20113.895%2013.69L42.247%2059.356a82.198%2082.198%200%200%200-37.135%2055.056a86.566%2086.566%200%200%200%208.536%2055.576a82.425%2082.425%200%200%200-12.296%2030.719a87.596%2087.596%200%200%200%2014.964%2066.244c28.574%2040.893%2084.997%2053.007%20125.787%2027.016l71.648-45.664a82.182%2082.182%200%200%200%2037.135-55.057a86.601%2086.601%200%200%200-8.53-55.577a82.409%2082.409%200%200%200%2012.29-30.718a87.573%2087.573%200%200%200-14.963-66.244'%3e%3c/path%3e%3cpath%20fill='%23FFF'%20d='M106.889%20270.841c-23.102%206.007-47.497-3.036-61.103-22.648a52.685%2052.685%200%200%201-9.003-39.85a49.978%2049.978%200%200%201%201.713-6.693l1.35-4.115l3.671%202.697a92.447%2092.447%200%200%200%2028.036%2014.007l2.663.808l-.245%202.659a16.067%2016.067%200%200%200%202.89%2010.656a17.143%2017.143%200%200%200%2018.397%206.828a15.786%2015.786%200%200%200%204.403-1.935l71.67-45.672a14.922%2014.922%200%200%200%206.734-9.977a15.923%2015.923%200%200%200-2.713-12.011a17.156%2017.156%200%200%200-18.404-6.832a15.78%2015.78%200%200%200-4.396%201.933l-27.35%2017.434a52.298%2052.298%200%200%201-14.553%206.391c-23.101%206.007-47.497-3.036-61.101-22.649a52.681%2052.681%200%200%201-9.004-39.849a49.428%2049.428%200%200%201%2022.34-33.114l71.664-45.677a52.218%2052.218%200%200%201%2014.563-6.398c23.101-6.007%2047.497%203.036%2061.101%2022.648a52.685%2052.685%200%200%201%209.004%2039.85a50.559%2050.559%200%200%201-1.713%206.692l-1.35%204.116l-3.67-2.693a92.373%2092.373%200%200%200-28.037-14.013l-2.664-.809l.246-2.658a16.099%2016.099%200%200%200-2.89-10.656a17.143%2017.143%200%200%200-18.398-6.828a15.786%2015.786%200%200%200-4.402%201.935l-71.67%2045.674a14.898%2014.898%200%200%200-6.73%209.975a15.9%2015.9%200%200%200%202.709%2012.012a17.156%2017.156%200%200%200%2018.404%206.832a15.841%2015.841%200%200%200%204.402-1.935l27.345-17.427a52.147%2052.147%200%200%201%2014.552-6.397c23.101-6.006%2047.497%203.037%2061.102%2022.65a52.681%2052.681%200%200%201%209.003%2039.848a49.453%2049.453%200%200%201-22.34%2033.12l-71.664%2045.673a52.218%2052.218%200%200%201-14.563%206.398'%3e%3c/path%3e%3c/svg%3e",Pt="/vite.svg";function Ct(e){let t,n,s,r,o;return{c(){t=B("button"),n=J("count is "),s=J(e[0])},m(i,a){A(i,t,a),L(t,n),L(t,s),r||(o=me(t,"click",e[1]),r=!0)},p(i,[a]){a&1&&le(s,i[0])},i:Q,o:Q,d(i){i&&C(t),r=!1,o()}}}function jt(e,t,n){let s=0;return[s,()=>{n(0,s+=1)}]}class At extends Fe{constructor(t){super(),Re(this,t,jt,Ct,Ue,{})}}const Tt="modulepreload",xt=function(e){return"/"+e},Qe={},Ye=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link");r=Promise.all(n.map(i=>{if(i=xt(i),i in Qe)return;Qe[i]=!0;const a=i.endsWith(".css"),p=a?'[rel="stylesheet"]':"";if(!!s)for(let f=o.length-1;f>=0;f--){const d=o[f];if(d.href===i&&(!a||d.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${p}`))return;const u=document.createElement("link");if(u.rel=a?"stylesheet":Tt,a||(u.as="script",u.crossOrigin=""),u.href=i,document.head.appendChild(u),a)return new Promise((f,d)=>{u.addEventListener("load",f),u.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${i}`)))})}))}return r.then(()=>t()).catch(o=>{const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=o,window.dispatchEvent(i),!i.defaultPrevented)throw o})};var qe=new Intl.Collator(0,{numeric:1}).compare;function Xe(e,t,n){return e=e.split("."),t=t.split("."),qe(e[0],t[0])||qe(e[1],t[1])||(t[2]=t.slice(2).join("."),n=/[.-]/.test(e[2]=e.slice(2).join(".")),n==/[.-]/.test(t[2])?qe(e[2],t[2]):n?-1:1)}function ut(e,t,n){return t.startsWith("http://")||t.startsWith("https://")?n?e:t:e+t}function De(e){if(e.startsWith("http")){const{protocol:t,host:n}=new URL(e);return n.endsWith("hf.space")?{ws_protocol:"wss",host:n,http_protocol:t}:{ws_protocol:t==="https:"?"wss":"ws",http_protocol:t,host:n}}else if(e.startsWith("file:"))return{ws_protocol:"ws",http_protocol:"http:",host:"lite.local"};return{ws_protocol:"wss",http_protocol:"https:",host:e}}const ct=/^[^\/]*\/[^\/]*$/,Bt=/.*hf\.space\/{0,1}$/;async function Ut(e,t){const n={};t&&(n.Authorization=`Bearer ${t}`);const s=e.trim();if(ct.test(s))try{const r=await fetch(`https://huggingface.co/api/spaces/${s}/host`,{headers:n});if(r.status!==200)throw new Error("Space metadata could not be loaded.");const o=(await r.json()).host;return{space_id:e,...De(o)}}catch(r){throw new Error("Space metadata could not be loaded."+r.message)}if(Bt.test(s)){const{ws_protocol:r,http_protocol:o,host:i}=De(s);return{space_id:i.replace(".hf.space",""),ws_protocol:r,http_protocol:o,host:i}}return{space_id:!1,...De(s)}}function It(e){let t={};return e.forEach(({api_name:n},s)=>{n&&(t[n]=s)}),t}const Rt=/^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;async function Ze(e){try{const n=(await fetch(`https://huggingface.co/api/spaces/${e}/discussions`,{method:"HEAD"})).headers.get("x-error-message");return!(n&&Rt.test(n))}catch{return!1}}function ie(e,t,n){if(e==null)return null;if(Array.isArray(e)){const s=[];for(const r of e)r==null?s.push(null):s.push(ie(r,t,n));return s}return e.is_stream?n==null?new _e({...e,url:t+"/stream/"+e.path}):new _e({...e,url:"/proxy="+n+"stream/"+e.path}):new _e({...e,url:zt(e.path,t,n)})}function Ft(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function zt(e,t,n){return e==null?n?`/proxy=${n}file=`:`${t}/file=`:Ft(e)?e:n?`/proxy=${n}file=${e}`:`${t}/file=${e}`}class _e{constructor({path:t,url:n,orig_name:s,size:r,blob:o,is_stream:i,mime_type:a,alt_text:p}){this.path=t,this.url=n,this.orig_name=s,this.size=r,this.blob=n?void 0:o,this.is_stream=i,this.mime_type=a,this.alt_text=p}}const ft="This application is too busy. Keep trying!",Y="Connection errored out.";let dt;function Jt(e,t){return{post_data:n,upload_files:s,client:r,handle_blob:o};async function n(i,a,p){const l={"Content-Type":"application/json"};p&&(l.Authorization=`Bearer ${p}`);try{var u=await e(i,{method:"POST",body:JSON.stringify(a),headers:l})}catch{return[{error:Y},500]}let f,d;try{f=await u.json(),d=u.status}catch(h){f={error:`Could not parse server response: ${h}`},d=500}return[f,d]}async function s(i,a,p,l){const u={};p&&(u.Authorization=`Bearer ${p}`);const f=1e3,d=[];for(let $=0;${y.append("files",_)});try{const _=l?`${i}/upload?upload_id=${l}`:`${i}/upload`;var h=await e(_,{method:"POST",body:y,headers:u})}catch{return{error:Y}}const g=await h.json();d.push(...g)}return{files:d}}async function r(i,a={normalise_files:!0}){return new Promise(async p=>{const{status_callback:l,hf_token:u,normalise_files:f}=a,d={predict:gt,submit:Je,view_api:Me,component_server:ht},h=f??!0;if((typeof window>"u"||!("WebSocket"in window))&&!global.Websocket){const w=await Ye(()=>import("./wrapper-6f348d45-9VzsDyGv.js"),__vite__mapDeps([0,1]));dt=(await Ye(()=>import("./__vite-browser-external-XPXQPciS.js"),__vite__mapDeps([]))).Blob,global.WebSocket=w.WebSocket}const{ws_protocol:$,http_protocol:O,host:y,space_id:g}=await Ut(i,u),_=Math.random().toString(36).substring(2),we={};let ye=!1,X={},se=null;const V={},ve=new Set;let v,fe={},be=!1;u&&g&&(be=await Wt(g,u));async function ze(w){if(v=w,fe=It((w==null?void 0:w.dependencies)||[]),v.auth_required)return{config:v,...d};try{re=await Me(v)}catch(T){console.error(`Could not get api details: ${T.message}`)}return{config:v,...d}}let re;async function pt(w){if(l&&l(w),w.status==="running")try{v=await st(e,`${O}//${y}`,u);const T=await ze(v);p(T)}catch(T){console.error(T),l&&l({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"})}}try{v=await st(e,`${O}//${y}`,u);const w=await ze(v);p(w)}catch(w){console.error(w),g?Be(g,ct.test(g)?"space_name":"subdomain",pt):l&&l({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"})}function gt(w,T,U){let N=!1,c=!1,P;if(typeof w=="number")P=v.dependencies[w];else{const q=w.replace(/^\//,"");P=v.dependencies[fe[q]]}if(P.types.continuous)throw new Error("Cannot call predict on this function as it may run forever. Use submit instead");return new Promise((q,R)=>{const H=Je(w,T,U);let m;H.on("data",F=>{c&&(H.destroy(),q(F)),N=!0,m=F}).on("status",F=>{F.stage==="error"&&R(F),F.stage==="complete"&&(c=!0,N&&(H.destroy(),q(m)))})})}function Je(w,T,U,N=null){let c,P;if(typeof w=="number")c=w,P=re.unnamed_endpoints[c];else{const j=w.replace(/^\//,"");c=fe[j],P=re.named_endpoints[w.trim()]}if(typeof c!="number")throw new Error("There is no endpoint matching that name of fn_index matching that number.");let q,R,H=v.protocol??"ws";const m=typeof w=="number"?"/predict":w;let F,G=null,I=!1;const oe={};let K="";typeof window<"u"&&(K=new URLSearchParams(window.location.search).toString()),o(`${v.root}`,T,P,u).then(j=>{if(F={data:j||[],event_data:U,fn_index:c,trigger_id:N},Vt(c,v))b({type:"status",endpoint:m,stage:"pending",queue:!1,fn_index:c,time:new Date}),n(`${v.root}/run${m.startsWith("/")?m:`/${m}`}${K?"?"+K:""}`,{...F,session_hash:_},u).then(([k,D])=>{const W=h?ge(k.data,P,v.root,v.root_url):k.data;D==200?(b({type:"data",endpoint:m,fn_index:c,data:W,time:new Date}),b({type:"status",endpoint:m,fn_index:c,stage:"complete",eta:k.average_duration,queue:!1,time:new Date})):b({type:"status",stage:"error",endpoint:m,fn_index:c,message:k.error,queue:!1,time:new Date})}).catch(k=>{b({type:"status",stage:"error",message:k.message,endpoint:m,fn_index:c,queue:!1,time:new Date})});else if(H=="ws"){b({type:"status",stage:"pending",queue:!0,endpoint:m,fn_index:c,time:new Date});let k=new URL(`${$}://${ut(y,v.path,!0)} /queue/join${K?"?"+K:""}`);be&&k.searchParams.set("__sign",be),q=new WebSocket(k),q.onclose=D=>{D.wasClean||b({type:"status",stage:"error",broken:!0,message:Y,queue:!0,endpoint:m,fn_index:c,time:new Date})},q.onmessage=function(D){const W=JSON.parse(D.data),{type:x,status:S,data:E}=Le(W,we[c]);if(x==="update"&&S&&!I)b({type:"status",endpoint:m,fn_index:c,time:new Date,...S}),S.stage==="error"&&q.close();else if(x==="hash"){q.send(JSON.stringify({fn_index:c,session_hash:_}));return}else x==="data"?q.send(JSON.stringify({...F,session_hash:_})):x==="complete"?I=S:x==="log"?b({type:"log",log:E.log,level:E.level,endpoint:m,fn_index:c}):x==="generating"&&b({type:"status",time:new Date,...S,stage:S==null?void 0:S.stage,queue:!0,endpoint:m,fn_index:c});E&&(b({type:"data",time:new Date,data:h?ge(E.data,P,v.root,v.root_url):E.data,endpoint:m,fn_index:c}),I&&(b({type:"status",time:new Date,...I,stage:S==null?void 0:S.stage,queue:!0,endpoint:m,fn_index:c}),q.close()))},Xe(v.version||"2.0.0","3.6")<0&&addEventListener("open",()=>q.send(JSON.stringify({hash:_})))}else if(H=="sse"){b({type:"status",stage:"pending",queue:!0,endpoint:m,fn_index:c,time:new Date});var z=new URLSearchParams({fn_index:c.toString(),session_hash:_}).toString();let k=new URL(`${v.root}/queue/join?${K?K+"&":""}${z}`);R=t(k),R.onmessage=async function(D){const W=JSON.parse(D.data),{type:x,status:S,data:E}=Le(W,we[c]);if(x==="update"&&S&&!I)b({type:"status",endpoint:m,fn_index:c,time:new Date,...S}),S.stage==="error"&&R.close();else if(x==="data"){G=W.event_id;let[Z,_t]=await n(`${v.root}/queue/data`,{...F,session_hash:_,event_id:G},u);_t!==200&&(b({type:"status",stage:"error",message:Y,queue:!0,endpoint:m,fn_index:c,time:new Date}),R.close())}else x==="complete"?I=S:x==="log"?b({type:"log",log:E.log,level:E.level,endpoint:m,fn_index:c}):x==="generating"&&b({type:"status",time:new Date,...S,stage:S==null?void 0:S.stage,queue:!0,endpoint:m,fn_index:c});E&&(b({type:"data",time:new Date,data:h?ge(E.data,P,v.root,v.root_url):E.data,endpoint:m,fn_index:c}),I&&(b({type:"status",time:new Date,...I,stage:S==null?void 0:S.stage,queue:!0,endpoint:m,fn_index:c}),R.close()))}}else H=="sse_v1"&&(b({type:"status",stage:"pending",queue:!0,endpoint:m,fn_index:c,time:new Date}),n(`${v.root}/queue/join?${K}`,{...F,session_hash:_},u).then(([k,D])=>{if(D===503)b({type:"status",stage:"error",message:ft,queue:!0,endpoint:m,fn_index:c,time:new Date});else if(D!==200)b({type:"status",stage:"error",message:Y,queue:!0,endpoint:m,fn_index:c,time:new Date});else{G=k.event_id;let W=async function(x){try{const{type:S,status:E,data:Z}=Le(x,we[c]);if(S=="heartbeat")return;if(S==="update"&&E&&!I)b({type:"status",endpoint:m,fn_index:c,time:new Date,...E});else if(S==="complete")I=E;else if(S=="unexpected_error")console.error("Unexpected error",E==null?void 0:E.message),b({type:"status",stage:"error",message:(E==null?void 0:E.message)||"An Unexpected Error Occurred!",queue:!0,endpoint:m,fn_index:c,time:new Date});else if(S==="log"){b({type:"log",log:Z.log,level:Z.level,endpoint:m,fn_index:c});return}else S==="generating"&&b({type:"status",time:new Date,...E,stage:E==null?void 0:E.stage,queue:!0,endpoint:m,fn_index:c});Z&&(b({type:"data",time:new Date,data:h?ge(Z.data,P,v.root,v.root_url):Z.data,endpoint:m,fn_index:c}),I&&b({type:"status",time:new Date,...I,stage:E==null?void 0:E.stage,queue:!0,endpoint:m,fn_index:c})),((E==null?void 0:E.stage)==="complete"||(E==null?void 0:E.stage)==="error")&&V[G]&&delete V[G]}catch(S){console.error("Unexpected client exception",S),b({type:"status",stage:"error",message:"An Unexpected Error Occurred!",queue:!0,endpoint:m,fn_index:c,time:new Date}),$e()}};G in X&&(X[G].forEach(x=>W(x)),delete X[G]),V[G]=W,ve.add(G),ye||mt()}}))});function b(j){const k=oe[j.type]||[];k==null||k.forEach(D=>D(j))}function Se(j,z){const k=oe,D=k[j]||[];return k[j]=D,D==null||D.push(z),{on:Se,off:de,cancel:Ee,destroy:Oe}}function de(j,z){const k=oe;let D=k[j]||[];return D=D==null?void 0:D.filter(W=>W!==z),k[j]=D,{on:Se,off:de,cancel:Ee,destroy:Oe}}async function Ee(){const j={stage:"complete",queue:!1,time:new Date};I=j,b({...j,type:"status",endpoint:m,fn_index:c});let z={};H==="ws"?(q&&q.readyState===0?q.addEventListener("open",()=>{q.close()}):q.close(),z={fn_index:c,session_hash:_}):(R.close(),z={event_id:G});try{await e(`${v.root}/reset`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(z)})}catch{console.warn("The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.")}}function Oe(){for(const j in oe)oe[j].forEach(z=>{de(j,z)})}return{on:Se,off:de,cancel:Ee,destroy:Oe}}function mt(){ye=!0;let w=new URLSearchParams({session_hash:_}).toString(),T=new URL(`${v.root}/queue/data?${w}`);se=t(T),se.onmessage=async function(U){let N=JSON.parse(U.data);const c=N.event_id;if(!c)await Promise.all(Object.keys(V).map(P=>V[P](N)));else if(V[c]){N.msg==="process_completed"&&(ve.delete(c),ve.size===0&&$e());let P=V[c];window.setTimeout(P,0,N)}else X[c]||(X[c]=[]),X[c].push(N)},se.onerror=async function(U){await Promise.all(Object.keys(V).map(N=>V[N]({msg:"unexpected_error",message:Y}))),$e()}}function $e(){ye=!1,se==null||se.close()}async function ht(w,T,U){var N;const c={"Content-Type":"application/json"};u&&(c.Authorization=`Bearer ${u}`);let P,q=v.components.find(m=>m.id===w);(N=q==null?void 0:q.props)!=null&&N.root_url?P=q.props.root_url:P=v.root;const R=await e(`${P}/component_server/`,{method:"POST",body:JSON.stringify({data:U,component_id:w,fn_name:T,session_hash:_}),headers:c});if(!R.ok)throw new Error("Could not connect to component server: "+R.statusText);return await R.json()}async function Me(w){if(re)return re;const T={"Content-Type":"application/json"};u&&(T.Authorization=`Bearer ${u}`);let U;if(Xe(w.version||"2.0.0","3.30")<0?U=await e("https://gradio-space-api-fetcher-v2.hf.space/api",{method:"POST",body:JSON.stringify({serialize:!1,config:JSON.stringify(w)}),headers:T}):U=await e(`${w.root}/info`,{headers:T}),!U.ok)throw new Error(Y);let N=await U.json();return"api"in N&&(N=N.api),N.named_endpoints["/predict"]&&!N.unnamed_endpoints[0]&&(N.unnamed_endpoints[0]=N.named_endpoints["/predict"]),Gt(N,w,fe)}})}async function o(i,a,p,l){const u=await xe(a,void 0,[],!0,p);return Promise.all(u.map(async({path:f,blob:d,type:h})=>{if(d){const $=(await s(i,[d],l)).files[0];return{path:f,file_url:$,type:h,name:d==null?void 0:d.name}}return{path:f,type:h}})).then(f=>(f.forEach(({path:d,file_url:h,type:$,name:O})=>{if($==="Gallery")nt(a,h,d);else if(h){const y=new _e({path:h,orig_name:O});nt(a,y,d)}}),a))}}const{post_data:en,upload_files:tn,client:Mt,handle_blob:nn}=Jt(fetch,(...e)=>new EventSource(...e));function ge(e,t,n,s){return e.map((r,o)=>{var i,a,p,l;return((a=(i=t==null?void 0:t.returns)==null?void 0:i[o])==null?void 0:a.component)==="File"?ie(r,n,s):((l=(p=t==null?void 0:t.returns)==null?void 0:p[o])==null?void 0:l.component)==="Gallery"?r.map(u=>Array.isArray(u)?[ie(u[0],n,s),u[1]]:[ie(u,n,s),null]):typeof r=="object"&&r.path?ie(r,n,s):r})}function et(e,t,n,s){switch(e.type){case"string":return"string";case"boolean":return"boolean";case"number":return"number"}if(n==="JSONSerializable"||n==="StringSerializable")return"any";if(n==="ListStringSerializable")return"string[]";if(t==="Image")return s==="parameter"?"Blob | File | Buffer":"string";if(n==="FileSerializable")return(e==null?void 0:e.type)==="array"?s==="parameter"?"(Blob | File | Buffer)[]":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]":s==="parameter"?"Blob | File | Buffer":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";if(n==="GallerySerializable")return s==="parameter"?"[(Blob | File | Buffer), (string | null)][]":"[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]"}function tt(e,t){return t==="GallerySerializable"?"array of [file, label] tuples":t==="ListStringSerializable"?"array of strings":t==="FileSerializable"?"array of files or single file":e.description}function Gt(e,t,n){const s={named_endpoints:{},unnamed_endpoints:{}};for(const r in e){const o=e[r];for(const i in o){const a=t.dependencies[i]?i:n[i.replace("/","")],p=o[i];s[r][i]={},s[r][i].parameters={},s[r][i].returns={},s[r][i].type=t.dependencies[a].types,s[r][i].parameters=p.parameters.map(({label:l,component:u,type:f,serializer:d})=>({label:l,component:u,type:et(f,u,d,"parameter"),description:tt(f,d)})),s[r][i].returns=p.returns.map(({label:l,component:u,type:f,serializer:d})=>({label:l,component:u,type:et(f,u,d,"return"),description:tt(f,d)}))}}return s}async function Wt(e,t){try{return(await(await fetch(`https://huggingface.co/api/spaces/${e}/jwt`,{headers:{Authorization:`Bearer ${t}`}})).json()).token||!1}catch(n){return console.error(n),!1}}function nt(e,t,n){for(;n.length>1;)e=e[n.shift()];e[n.shift()]=t}async function xe(e,t=void 0,n=[],s=!1,r=void 0){if(Array.isArray(e)){let o=[];return await Promise.all(e.map(async(i,a)=>{var p;let l=n.slice();l.push(a);const u=await xe(e[a],s?((p=r==null?void 0:r.parameters[a])==null?void 0:p.component)||void 0:t,l,!1,r);o=o.concat(u)})),o}else{if(globalThis.Buffer&&e instanceof globalThis.Buffer)return[{path:n,blob:t==="Image"?!1:new dt([e]),type:t}];if(typeof e=="object"){let o=[];for(let i in e)if(e.hasOwnProperty(i)){let a=n.slice();a.push(i),o=o.concat(await xe(e[i],void 0,a,!1,r))}return o}}return[]}function Vt(e,t){var n,s,r,o;return!(((s=(n=t==null?void 0:t.dependencies)==null?void 0:n[e])==null?void 0:s.queue)===null?t.enable_queue:(o=(r=t==null?void 0:t.dependencies)==null?void 0:r[e])!=null&&o.queue)||!1}async function st(e,t,n){const s={};if(n&&(s.Authorization=`Bearer ${n}`),typeof window<"u"&&window.gradio_config&&location.origin!=="http://localhost:9876"&&!window.gradio_config.dev_mode){const r=window.gradio_config.root,o=window.gradio_config;return o.root=ut(t,o.root,!1),{...o,path:r}}else if(t){let r=await e(`${t}/config`,{headers:s});if(r.status===200){const o=await r.json();return o.path=o.path??"",o.root=t,o}throw new Error("Could not get config.")}throw new Error("No config or app endpoint found")}async function Be(e,t,n){let s=t==="subdomain"?`https://huggingface.co/api/spaces/by-subdomain/${e}`:`https://huggingface.co/api/spaces/${e}`,r,o;try{if(r=await fetch(s),o=r.status,o!==200)throw new Error;r=await r.json()}catch{n({status:"error",load_status:"error",message:"Could not get space status",detail:"NOT_FOUND"});return}if(!r||o!==200)return;const{runtime:{stage:i},id:a}=r;switch(i){case"STOPPED":case"SLEEPING":n({status:"sleeping",load_status:"pending",message:"Space is asleep. Waking it up...",detail:i}),setTimeout(()=>{Be(e,t,n)},1e3);break;case"PAUSED":n({status:"paused",load_status:"error",message:"This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",detail:i,discussions_enabled:await Ze(a)});break;case"RUNNING":case"RUNNING_BUILDING":n({status:"running",load_status:"complete",message:"",detail:i});break;case"BUILDING":n({status:"building",load_status:"pending",message:"Space is building...",detail:i}),setTimeout(()=>{Be(e,t,n)},1e3);break;default:n({status:"space_error",load_status:"error",message:"This space is experiencing an issue.",detail:i,discussions_enabled:await Ze(a)});break}}function Le(e,t){switch(e.msg){case"send_data":return{type:"data"};case"send_hash":return{type:"hash"};case"queue_full":return{type:"update",status:{queue:!0,message:ft,stage:"error",code:e.code,success:e.success}};case"heartbeat":return{type:"heartbeat"};case"unexpected_error":return{type:"unexpected_error",status:{queue:!0,message:e.message,stage:"error",success:!1}};case"estimation":return{type:"update",status:{queue:!0,stage:t||"pending",code:e.code,size:e.queue_size,position:e.rank,eta:e.rank_eta,success:e.success}};case"progress":return{type:"update",status:{queue:!0,stage:"pending",code:e.code,progress_data:e.progress_data,success:e.success}};case"log":return{type:"log",data:e};case"process_generating":return{type:"generating",status:{queue:!0,message:e.success?null:e.output.error,stage:e.success?"generating":"error",code:e.code,progress_data:e.progress_data,eta:e.average_duration},data:e.success?e.output:null};case"process_completed":return"error"in e.output?{type:"update",status:{queue:!0,message:e.output.error,stage:"error",code:e.code,success:e.success}}:{type:"complete",status:{queue:!0,message:e.success?void 0:e.output.error,stage:e.success?"complete":"error",code:e.code,progress_data:e.progress_data},data:e.success?e.output:null};case"process_starts":return{type:"update",status:{queue:!0,stage:"pending",code:e.code,size:e.rank,position:0,success:e.success,eta:e.eta}}}return{type:"none",status:{stage:"error",queue:!0}}}function rt(e){let t,n,s=e[1].matching_letters+"",r,o,i=JSON.stringify(e[1].exact_letters)+"",a,p,l,u,f=JSON.stringify(e[0].data)+"",d;return{c(){t=B("p"),n=J("Matching Letters: "),r=J(s),o=J(" - "),a=J(i),p=M(),l=B("p"),u=J("Result: "),d=J(f)},m(h,$){A(h,t,$),L(t,n),L(t,r),L(t,o),L(t,a),A(h,p,$),A(h,l,$),L(l,u),L(l,d)},p(h,$){$&2&&s!==(s=h[1].matching_letters+"")&&le(r,s),$&2&&i!==(i=JSON.stringify(h[1].exact_letters)+"")&&le(a,i),$&1&&f!==(f=JSON.stringify(h[0].data)+"")&&le(d,f)},d(h){h&&(C(t),C(p),C(l))}}}function ot(e){let t,n,s=e[2].message+"",r;return{c(){t=B("p"),n=J("Error: "),r=J(s)},m(o,i){A(o,t,i),L(t,n),L(t,r)},p(o,i){i&4&&s!==(s=o[2].message+"")&&le(r,s)},d(o){o&&C(t)}}}function Ht(e){let t,n,s,r,o,i,a,p,l,u,f,d,h,$,O=e[0]&&rt(e),y=e[2]&&ot(e);return{c(){t=B("div"),t.innerHTML="

Gradio Client Test

",n=M(),s=B("h3"),s.textContent="Spelling based comparison interface through api test - (22/01/2023 - may break after due changes to underlying space - https://huggingface.co/spaces/KwabsHug/Language-Learn-Idea)",r=M(),o=B("input"),i=M(),a=B("input"),p=M(),l=B("button"),l.textContent="Predict",u=M(),O&&O.c(),f=M(),y&&y.c(),d=bt(),ae(o,"type","text"),ae(a,"type","text")},m(g,_){A(g,t,_),A(g,n,_),A(g,s,_),A(g,r,_),A(g,o,_),pe(o,e[3]),A(g,i,_),A(g,a,_),pe(a,e[4]),A(g,p,_),A(g,l,_),A(g,u,_),O&&O.m(g,_),A(g,f,_),y&&y.m(g,_),A(g,d,_),h||($=[me(o,"input",e[6]),me(a,"input",e[7]),me(l,"click",e[5])],h=!0)},p(g,[_]){_&8&&o.value!==g[3]&&pe(o,g[3]),_&16&&a.value!==g[4]&&pe(a,g[4]),g[0]?O?O.p(g,_):(O=rt(g),O.c(),O.m(f.parentNode,f)):O&&(O.d(1),O=null),g[2]?y?y.p(g,_):(y=ot(g),y.c(),y.m(d.parentNode,d)):y&&(y.d(1),y=null)},i:Q,o:Q,d(g){g&&(C(t),C(n),C(s),C(r),C(o),C(i),C(a),C(p),C(l),C(u),C(f),C(d)),O&&O.d(g),y&&y.d(g),h=!1,ce($)}}}function Kt(e,t,n){let s,r,o,i="hello",a="world";async function p(){const f=await Mt("https://kwabshug-language-learn-idea.hf.space/--replicas/m8usa/");try{n(0,s=await f.predict("/predict_4",[i,a]))}catch(d){n(2,o=d)}console.log(s.data),n(1,r=JSON.parse(String(s.data).replace(/'/g,'"')))}function l(){i=this.value,n(3,i)}function u(){a=this.value,n(4,a)}return[s,r,o,i,a,p,l,u]}class Qt extends Fe{constructor(t){super(),Re(this,t,Kt,Ht,Ue,{})}}function Yt(e){let t,n,s,r,o,i,a,p,l,u,f,d,h,$,O;return o=new Qt({}),u=new At({}),{c(){t=B("main"),n=B("div"),n.innerHTML=` `,s=M(),r=B("div"),Ke(o.$$.fragment),i=M(),a=B("h1"),a.textContent="Vite + Svelte",p=M(),l=B("div"),Ke(u.$$.fragment),f=M(),d=B("p"),d.innerHTML='Check out SvelteKit, the official Svelte app framework powered by Vite!',h=M(),$=B("p"),$.textContent="Click on the Vite and Svelte logos to learn more",ae(r,"class","my-edits svelte-1fm2ok"),ae(l,"class","card"),ae($,"class","read-the-docs svelte-1fm2ok")},m(y,g){A(y,t,g),L(t,n),L(t,s),L(t,r),Ae(o,r,null),L(t,i),L(t,a),L(t,p),L(t,l),Ae(u,l,null),L(t,f),L(t,d),L(t,h),L(t,$),O=!0},p:Q,i(y){O||(je(o.$$.fragment,y),je(u.$$.fragment,y),O=!0)},o(y){He(o.$$.fragment,y),He(u.$$.fragment,y),O=!1},d(y){y&&C(t),Te(o),Te(u)}}}class Xt extends Fe{constructor(t){super(),Re(this,t,null,Yt,Ue,{})}}new Xt({target:document.getElementById("app")}); function __vite__mapDeps(indexes) { if (!__vite__mapDeps.viteFileDeps) { __vite__mapDeps.viteFileDeps = ["assets/wrapper-6f348d45-9VzsDyGv.js","assets/__vite-browser-external-XPXQPciS.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) }