1const __vite__fileDeps=["./wrapper-CviSselG-DCvi549i.js","./__vite-browser-external-DFe-p4yY.js","./Index-DyMt_EUv.js","./Index-CvNW6sLS.css"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); 2import*as de from"./svelte/svelte.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function e(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=e(i);fetch(i.href,o)}})();const et="modulepreload",tt=function(t,s){return new URL(t,s).href},Oe={},ee=function(s,e,n){let i=Promise.resolve();if(e&&e.length>0){const o=document.getElementsByTagName("link"),r=document.querySelector("meta[property=csp-nonce]"),a=r?.nonce||r?.getAttribute("nonce");i=Promise.all(e.map(c=>{if(c=tt(c,n),c in Oe)return;Oe[c]=!0;const u=c.endsWith(".css"),_=u?'[rel="stylesheet"]':"";if(!!n)for(let y=o.length-1;y>=0;y--){const b=o[y];if(b.href===c&&(!u||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${_}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":et,u||(h.as="script",h.crossOrigin=""),h.href=c,a&&h.setAttribute("nonce",a),document.head.appendChild(h),u)return new Promise((y,b)=>{h.addEventListener("load",y),h.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}return i.then(()=>s()).catch(o=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=o,window.dispatchEvent(r),!r.defaultPrevented)throw o})};var st=Object.defineProperty,nt=(t,s,e)=>s in t?st(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e,f=(t,s,e)=>(nt(t,typeof s!="symbol"?s+"":s,e),e),Ie=(t,s,e)=>{if(!s.has(t))throw TypeError("Cannot "+e)},K=(t,s,e)=>(Ie(t,s,"read from private field"),e?e.call(t):s.get(t)),it=(t,s,e)=>{if(s.has(t))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(t):s.set(t,e)},ot=(t,s,e,n)=>(Ie(t,s,"write to private field"),s.set(t,e),e),z,fe=new Intl.Collator(0,{numeric:1}).compare;function qe(t,s,e){return t=t.split("."),s=s.split("."),fe(t[0],s[0])||fe(t[1],s[1])||(s[2]=s.slice(2).join("."),e=/[.-]/.test(t[2]=t.slice(2).join(".")),e==/[.-]/.test(s[2])?fe(t[2],s[2]):e?-1:1)}const rt="host",Te="upload",at="login",ct="config",lt="info",ut="runtime",pt="sleeptime",ht="https://gradio-space-api-fetcher-v2.hf.space/api",je="This application is currently busy. Please try again. ",B="Connection errored out. ",W="Could not resolve app config. ",dt="Could not get space status. ",ft="Could not get API info. ",ve="Space metadata could not be loaded. ",_t="Invalid URL. A full URL path is required.",mt="Not authorized to access this space. ",Ue="Invalid credentials. Could not login. ",gt="Login credentials are required to access this space.",wt="File system access is only available in Node.js environments",ze="Root URL not found in client config",yt="Error uploading file";function Fe(t,s,e){return s.startsWith("http://")||s.startsWith("https://")?e?t:s:t+s}async function Ae(t,s,e){try{return(await(await fetch(`https://huggingface.co/api/spaces/${t}/jwt`,{headers:{Authorization:`Bearer ${s}`,...e?{Cookie:e}:{}}})).json()).token||!1}catch{return!1}}function vt(t){let s={};return t.forEach(({api_name:e,id:n})=>{e&&(s[e]=n)}),s}async function bt(t){var s;const e=this.options.hf_token?{Authorization:`Bearer ${this.options.hf_token}`}:{};if(e["Content-Type"]="application/json",typeof window<"u"&&window.gradio_config&&location.origin!=="http://localhost:9876"&&!window.gradio_config.dev_mode){const n=window.gradio_config.root,i=window.gradio_config;let o=Fe(t,i.root,!1);return i.root=o,{...i,path:n}}else if(t){const n=Ge(t,ct),i=await this.fetch(n,{headers:e,credentials:"include"});if(i?.status===401&&!this.options.auth)throw new Error(gt);if(i?.status===401&&this.options.auth)throw new Error(Ue);if(i?.status===200){let o=await i.json();return o.path=o.path??"",o.root=t,(s=o.dependencies)==null||s.forEac
2h((r,a)=>{r.id===void 0&&(r.id=a)}),o}else if(i?.status===401)throw new Error(mt);throw new Error(W)}throw new Error(W)}async function St(){const{http_protocol:t,host:s}=await ne(this.app_reference,this.options.hf_token);try{if(this.options.auth){const e=await Be(t,s,this.options.auth,this.fetch,this.options.hf_token);e&&this.set_cookies(e)}}catch(e){throw Error(e.message)}}async function Be(t,s,e,n,i){const o=new FormData;o.append("username",e?.[0]),o.append("password",e?.[1]);let r={};i&&(r.Authorization=`Bearer ${i}`);const a=await n(`${t}//${s}/${at}`,{headers:r,method:"POST",body:o,credentials:"include"});if(a.status===200)return a.headers.get("set-cookie");throw a.status===401?new Error(Ue):new Error(ve)}function _e(t){if(t.startsWith("http")){const{protocol:s,host:e,pathname:n}=new URL(t);return e.endsWith("hf.space")?{ws_protocol:"wss",host:e,http_protocol:s}:{ws_protocol:s==="https:"?"wss":"ws",http_protocol:s,host:e+(n!=="/"?n:"")}}else if(t.startsWith("file:"))return{ws_protocol:"ws",http_protocol:"http:",host:"lite.local"};return{ws_protocol:"wss",http_protocol:"https:",host:t}}const Me=t=>{let s=[];return t.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach(n=>{const[i,o]=n.split(";")[0].split("=");i&&o&&s.push(`${i.trim()}=${o.trim()}`)}),s},be=/^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/,Et=/.*hf\.space\/{0,1}$/;async function ne(t,s){const e={};s&&(e.Authorization=`Bearer ${s}`);const n=t.trim().replace(/\/$/,"");if(be.test(n))try{const o=(await(await fetch(`https://huggingface.co/api/spaces/${n}/${rt}`,{headers:e})).json()).host;return{space_id:t,..._e(o)}}catch{throw new Error(ve)}if(Et.test(n)){const{ws_protocol:i,http_protocol:o,host:r}=_e(n);return{space_id:r.replace(".hf.space",""),ws_protocol:i,http_protocol:o,host:r}}return{space_id:!1,..._e(n)}}const Ge=(...t)=>{try{return t.reduce((s,e)=>(s=s.replace(/\/+$/,""),e=e.replace(/^\/+/,""),new URL(e,s+"/").toString()))}catch{throw new Error(_t)}};function kt(t,s,e){const n={named_endpoints:{},unnamed_endpoints:{}};return Object.keys(t).forEach(i=>{(i==="named_endpoints"||i==="unnamed_endpoints")&&(n[i]={},Object.entries(t[i]).forEach(([o,{parameters:r,returns:a}])=>{var c,u,_,p;const h=((c=s.dependencies.find(l=>l.api_name===o||l.api_name===o.replace("/","")))==null?void 0:c.id)||e[o.replace("/","")]||-1,y=h!==-1?(u=s.dependencies.find(l=>l.id==h))==null?void 0:u.types:{generator:!1,cancel:!1};if(h!==-1&&((p=(_=s.dependencies.find(l=>l.id==h))==null?void 0:_.inputs)==null?void 0:p.length)!==r.length){const l=s.dependencies.find(m=>m.id==h).inputs.map(m=>{var k;return(k=s.components.find(A=>A.id===m))==null?void 0:k.type});try{l.forEach((m,k)=>{if(m==="state"){const A={component:"state",example:null,parameter_default:null,parameter_has_default:!0,parameter_name:null,hidden:!0};r.splice(k,0,A)}})}catch(m){console.error(m)}}const b=(l,m,k,A)=>({...l,description:Ct(l?.type,k),type:$t(l?.type,m,k,A)||""});n[i][o]={parameters:r.map(l=>b(l,l?.component,l?.serializer,"parameter")),returns:a.map(l=>b(l,l?.component,l?.serializer,"return")),type:y}}))}),n}function $t(t,s,e,n){switch(t?.type){case"string":return"string";case"boolean":return"boolean";case"number":return"number"}if(e==="JSONSerializable"||e==="StringSerializable")return"any";if(e==="ListStringSerializable")return"string[]";if(s==="Image")return n==="parameter"?"Blob | File | Buffer":"string";if(e==="FileSerializable")return t?.type==="array"?n==="parameter"?"(Blob | File | Buffer)[]":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]":n==="parameter"?"Blob | File | Buffer":"{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";if(e==="GallerySerializable")return n==="parameter"?"[(Blob | File | Buffer), (string | null)][]":"[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]"}function Ct(t,s){return s==="GallerySerializable"?"array of [file, label] tuples":s==="ListStringSerializable"?"array of strings":s==="FileSerializable"?"array of files or single file":t?.description}function me(t,s){switch(t.msg){case"send_data":return{type:"data"};case"send_hash":return{type:"hash"};case"queue_full":return{type:"update",status:{queue:!0,message:je,stage:"error",code:t.code,success:t.success}};case"heartbeat":return{type:"heartbeat"};case"unexpected_error":return{type:"unexpected_error",status:{queue:!0,message:t.message,stage:"error",success:!1}};case"estimation":return{type:"update",status:{queue:!0,stage:s||"pending",code:t.code,size:t.queue_size,position:t.rank,eta:t.rank_eta,success:t.success}};case"progress":return{type:"update",status:{queue:!0,stage:"pending",code:t.code,progress_data:t.progress_data,success:t.success}};case"log":return{type:"log",data:t};case"process_generating":return{type:"generating",status:{queue:!0,message:t.success?null:t.output.error,stage:t.success?"generating":"error",code:t.code,progress_data:t.progress_data,eta:t.average_duration},data:t.success?t.output:null};case"process_completed":return"error"in t.output?{type:"update",status:{queue:!0,message:t.output.error,visible:t.output.visible,duration:t.output.duration,stage:"error",code:t.code,success:t.success}}:{type:"complete",status:{queue:!0,message:t.success?void 0:t.output.error,stage:t.success?"complete":"error",code:t.code,progress_data:t.progress_data,changed_state_ids:t.success?t.output.changed_state_ids:void 0},data:t.success?t.output:null};case"process_starts":return{type:"update",status:{queue:!0,stage:"pending",code:t.code,size:t.rank,position:0,success:t.success,eta:t.eta}}}return{type:"none",status:{stage:"error",queue:!0}}}const Rt=(t=[],s)=>{const e=s?s.parameters:[];if(Array.isArray(t))return t.length>e.length&&console.warn("Too many arguments provided for the endpoint."),t;const n=[],i=Object.keys(t);return e.forEach((o,r)=>
2{if(t.hasOwnProperty(o.parameter_name))n[r]=t[o.parameter_name];else if(o.parameter_has_default)n[r]=o.parameter_default;else throw new Error(`No value provided for required parameter: ${o.parameter_name}`)}),i.forEach(o=>{if(!e.some(r=>r.parameter_name===o))throw new Error(`Parameter \`${o}\` is not a valid keyword argument. Please refer to the API for usage.`)}),n.forEach((o,r)=>{if(o===void 0&&!e[r].parameter_has_default)throw new Error(`No value provided for required parameter: ${e[r].parameter_name}`)}),n};async function Ot(){if(this.api_info)return this.api_info;const{hf_token:t}=this.options,{config:s}=this,e={"Content-Type":"application/json"};if(t&&(e.Authorization=`Bearer ${t}`),!!s)try{let n,i;if(typeof window<"u"&&window.gradio_api_info)i=window.gradio_api_info;else{if(qe(s?.version||"2.0.0","3.30")<0)n=await this.fetch(ht,{method:"POST",body:JSON.stringify({serialize:!1,config:JSON.stringify(s)}),headers:e,credentials:"include"});else{const o=Ge(s.root,lt);n=await this.fetch(o,{headers:e,credentials:"include"})}if(!n.ok)throw new Error(B);i=await n.json()}return"api"in i&&(i=i.api),i.named_endpoints["/predict"]&&!i.unnamed_endpoints[0]&&(i.unnamed_endpoints[0]=i.named_endpoints["/predict"]),kt(i,s,this.api_map)}catch(n){""+n.message}}async function Tt(t,s,e){var n;const i={};(n=this==null?void 0:this.options)!=null&&n.hf_token&&(i.Authorization=`Bearer ${this.options.hf_token}`);const o=1e3,r=[];let a;for(let c=0;c<s.length;c+=o){const u=s.slice(c,c+o),_=new FormData;u.forEach(h=>{_.append("files",h)});try{const h=e?`${t}/${Te}?upload_id=${e}`:`${t}/${Te}`;a=await this.fetch(h,{method:"POST",body:_,headers:i,credentials:"include"})}catch(h){throw new Error(B+h.message)}if(!a.ok){const h=await a.text();return{error:`HTTP ${a.status}: ${h}`}}const p=await a.json();p&&r.push(...p)}return{files:r}}async function At(t,s,e,n){let i=(Array.isArray(t)?t:[t]).map(r=>r.blob);const o=i.filter(r=>r.size>(n??1/0));if(o.length)throw new Error(`File size exceeds the maximum allowed size of ${n} bytes: ${o.map(r=>r.name).join(", ")}`);return await Promise.all(await this.upload_files(s,i,e).then(async r=>{if(r.error)throw new Error(r.error);return r.files?r.files.map((a,c)=>new ie({...t[c],path:a,url:s+"/file="+a})):[]}))}async function as(t,s){return t.map(e=>new ie({path:e.name,orig_name:e.name,blob:e,size:e.size,mime_type:e.type,is_stream:s}))}class ie{constructor({path:s,url:e,orig_name:n,size:i,blob:o,is_stream:r,mime_type:a,alt_text:c}){f(this,"path"),f(this,"url"),f(this,"orig_name"),f(this,"size"),f(this,"blob"),f(this,"is_stream"),f(this,"mime_type"),f(this,"alt_text"),f(this,"meta",{_type:"gradio.FileData"}),this.path=s,this.url=e,this.orig_name=n,this.size=i,this.blob=e?void 0:o,this.is_stream=r,this.mime_type=a,this.alt_text=c}}class Nt{constructor(s,e){f(this,"type"),f(this,"command"),f(this,"meta"),f(this,"fileData"),this.type="command",this.command=s,this.meta=e}}typeof process<"u"&&process.versions&&process.versions.node;function Ne(t,s,e){for(;e.length>1;){const i=e.shift();if(typeof i=="string"||typeof i=="number")t=t[i];else throw new Error("Invalid key type")}const n=e.shift();if(typeof n=="string"||typeof n=="number")t[n]=s;else throw new Error("Invalid key type")}async function ge(t,s=void 0,e=[],n=!1,i=void 0){if(Array.isArray(t)){let o=[];return await Promise.all(t.map(async(r,a)=>{var c;let u=e.slice();u.push(String(a));const _=await ge(t[a],n?((c=i?.parameters[a])==null?void 0:c.component)||void 0:s,u,!1,i);o=o.concat(_)})),o}else{if(globalThis.Buffer&&t instanceof globalThis.Buffer||t instanceof Blob)return[{path:e,blob:new Blob([t]),type:s}];if(typeof t=="object"&&t!==null){let o=[];for(const r of Object.keys(t)){const a=[...e,r],c=t[r];o=o.concat(await ge(c,void 0,a,!1,i))}return o}}return[]}function Pt(t,s){var e,n;let i=(n=(e=s?.dependencies)==null?void 0:e.find(o=>o.id==t))==null?void 0:n.queue;return i!=null?!i:!s.enable_queue}function Dt(t,s){return new Promise((e,n)=>{const i=new MessageChannel;i.port1.onmessage=({data:o})=>{i.port1.close(),e(o)},window.parent.postMessage(t,s,[i.port2])})}function Z(t,s,e,n,i=!1){if(n==="input"&&!i)throw new Error("Invalid code path. Cannot skip state inputs for input.");if(n==="output"&&i)return t;let o=[],r=0;const a=n==="input"?s.inputs:s.outputs;for(let c=0;c<a.length;c++){const u=a[c],_=e.find(p=>p.id===u);if(_?.type==="state"){if(i)if(t.length===a.length){const p=t[r];o.push(p),r++}else o.push(null);else{r++;continue}continue}else{const p=t[r];o.push(p),r++}}return o}async function Lt(t,s,e){const n=this;await xt(n,s);const i=await ge(s,void 0,[],!0,e);return(await Promise.all(i.map(async({path:r,blob:a,type:c})=>{if(!a)return{path:r,type:c};const u=await n.upload_files(t,[a]),_=u.files&&u.files[0];
vendor: 6,453 bytes, lines 2-3
2return{path:r,file_url:_,type:c,name:typeof File<"u"&&a instanceof File?a?.name:void 0}}))).forEach(({path:r,file_url:a,type:c,name:u})=>{if(c==="Gallery")Ne(s,a,r);else if(a){const _=new ie({path:a,orig_name:u});Ne(s,_,r)}}),s}async function xt(t,s){var e,n;if(!(((e=t.config)==null?void 0:e.root)||((n=t.config)==null?void 0:n.root_url)))throw new Error(ze);await Je(t,s)}async function Je(t,s,e=[]){for(const n in s)s[n]instanceof Nt?await It(t,s,n):typeof s[n]=="object"&&s[n]!==null&&await Je(t,s[n],[...e,n])}async function It(t,s,e){var n,i;let o=s[e];const r=((n=t.config)==null?void 0:n.root)||((i=t.config)==null?void 0:i.root_url);if(!r)throw new Error(ze);try{let a,c;if(typeof process<"u"&&process.versions&&process.versions.node){const h=await ee(()=>import("./__vite-browser-external-DFe-p4yY.js").then(b=>b._),[],import.meta.url);c=(await ee(()=>import("./__vite-browser-external-DFe-p4yY.js").then(b=>b._),[],import.meta.url)).resolve(process.cwd(),o.meta.path),a=await h.readFile(c)}else throw new Error(wt);const u=new Blob([a],{type:"application/octet-stream"}),_=await t.upload_files(r,[u]),p=_.files&&_.files[0];if(p){const h=new ie({path:p,orig_name:o.meta.name||""});s[e]=h}}catch(a){console.error(yt,a)}}async function qt(t,s,e){const n={"Content-Type":"application/json"};this.options.hf_token&&(n.Authorization=`Bearer ${this.options.hf_token}`);try{var i=await this.fetch(t,{method:"POST",body:JSON.stringify(s),headers:{...n,...e},credentials:"include"})}catch{return[{error:B},500]}let o,r;try{o=await i.json(),r=i.status}catch(a){o={error:`Could not parse server response: ${a}`},r=500}return[o,r]}async function jt(t,s={}){let e=!1,n=!1;if(!this.config)throw new Error("Could not resolve app config");if(typeof t=="number")this.config.dependencies.find(i=>i.id==t);else{const i=t.replace(/^\//,"");this.config.dependencies.find(o=>o.id==this.api_map[i])}return new Promise(async(i,o)=>{const r=this.submit(t,s,null,null,!0);let a;for await(const c of r)c.type==="data"&&(n&&i(a),e=!0,a=c),c.type==="status"&&(c.stage==="error"&&o(c),c.stage==="complete"&&(n=!0,e&&i(a)))})}async function Y(t,s,e){let n=s==="subdomain"?`https://huggingface.co/api/spaces/by-subdomain/${t}`:`https://huggingface.co/api/spaces/${t}`,i,o;try{if(i=await fetch(n),o=i.status,o!==200)throw new Error;i=await i.json()}catch{e({status:"error",load_status:"error",message:dt,detail:"NOT_FOUND"});return}if(!i||o!==200)return;const{runtime:{stage:r},id:a}=i;switch(r){case"STOPPED":case"SLEEPING":e({status:"sleeping",load_status:"pending",message:"Space is asleep. Waking it up...",detail:r}),setTimeout(()=>{Y(t,s,e)},1e3);break;case"PAUSED":e({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:r,discussions_enabled:await Pe(a)});break;case"RUNNING":case"RUNNING_BUILDING":e({status:"running",load_status:"complete",message:"Space is running.",detail:r});break;case"BUILDING":e({status:"building",load_status:"pending",message:"Space is building...",detail:r}),setTimeout(()=>{Y(t,s,e)},1e3);break;case"APP_STARTING":e({status:"starting",load_status:"pending",message:"Space is starting...",detail:r}),setTimeout(()=>{Y(t,s,e)},1e3);break;default:e({status:"space_error",load_status:"error",message:"This space is experiencing an issue.",detail:r,discussions_enabled:await Pe(a)});break}}const We=async(t,s)=>{let e=0;const n=12,i=5e3;return new Promise(o=>{Y(t,be.test(t)?"space_name":"subdomain",r=>{s(r),r.status==="running"||r.status==="error"||r.status==="paused"||r.status==="space_error"?o():(r.status==="sleeping"||r.status==="building")&&(e<n?(e++,setTimeout(()=>{We(t,s).then(o)},i)):o())})})},Ut=/^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;async function Pe(t){try{const s=await fetch(`https://huggingface.co/api/spaces/${t}/discussions`,{method:"HEAD"}),e=s.headers.get("x-error-message");return!(!s.ok||e&&Ut.test(e))}catch{return!1}}async function zt(t,s){const e={};s&&(e.Authorization=`Bearer ${s}`);try{const n=await fetch(`https://huggingface.co/api/spaces/${t}/${ut}`,{headers:e});if(n.status!==200)throw new Error("Space hardware could not be obtained.");const{hardware:i}=await n.json();return i.current}catch(n){throw new Error(n.message)}}async function Ft(t,s,e){const n={};e&&(n.Authorization=`Bearer ${e}`);const i={seconds:s};try{const o=await fetch(`https://huggingface.co/api/spaces/${t}/${pt}`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(i)});if(o.status!==200)throw new Error("Could not set sleep timeout on duplicated Space. Please visit *ADD HF LINK TO SETTINGS* to set a timeout manually to reduce billing charges.");return await o.json()}catch(o){throw new Error(o.message)}}const De=["cpu-basic","cpu-upgrade","cpu-xl","t4-small","t4-medium","a10g-small","a10g-large","a10g-largex2","a10g-largex4","a100-large","zero-a10g","h100","h100x8"];async function Bt(t,s){const{hf_token:e,private:n,hardware:i,timeout:o,auth:r}=s;if(i&&!De.includes(i))throw new Error(`Invalid hardware type provided. Valid types are: ${De.map(m=>`"${m}"`).join(",")}.`);const{http_protocol:a,host:c}=await ne(t,e);let u=null;if(r){const m=await Be(a,c,r,fetch);m&&(u=Me(m))}const _={Authorization:`Bearer ${e}`,"Content-Type":"application/json",...u?{Cookie:u.join("; ")}:{}},p=(await(await fetch("https://huggingface.co/api/whoami-v2",{headers:_})).json()).name,h=t.split("/")[1],y={repository:`${p}/${h}`};n&&(y.private=!0);let b;try{i||(b=await zt(t,e))}catch(m){throw Error(ve+m.message)}const l=i||b||"cpu-basic";y.hardware=l;try{const m=await fetch(`https://huggingface.co/api/spaces/${t}/duplicate`,{method:"POST",headers:_,body:JSON.stringify(y)});if(m.status===409)try{return await se.connect(`${p}/${h}`,s)}catch(A){throw console.error("Failed to connect Client instance:",A),A}else if(m.status!==200)throw new Error(m.statusText);const k=await m.json();return await Ft(`${p}/${h}`,o||300,e),await se.connect(Mt(k.url),s)}catch(m){throw new Error(m)}}function Mt(t){const s=/https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/,e=t.match(s);if(e)return e[1]}class Gt extends TransformStream{constructor(s={allowCR:!1}){super({transform:(e,n)=>{for(e=K(this,z)+e;;){const i=e.indexOf(` 3`),o=s.allowCR?e.indexOf("\r"):-1;if(o!==-1&&o!==e.length-1&&(i===-1||i-1>o)){n.enqueue(e.slice(0,o)),e=e.slice(o+1);continue}if(i===-1)break;const r=e[i-1]==="\r"?i-1:i;
3n.enqueue(e.slice(0,r)),e=e.slice(i+1)}ot(this,z,e)},flush:e=>{if(K(this,z)==="")return;const n=s.allowCR&&K(this,z).endsWith("\r")?K(this,z).slice(0,-1):K(this,z);e.enqueue(n)}}),it(this,z,"")}}z=new WeakMap;function Jt(t){let s=new TextDecoderStream,e=new Gt({allowCR:!0});return t.pipeThrough(s).pipeThrough(e)}function Wt(t){let e=/[:]\s*/.exec(t),n=e&&e.index;if(n)return[t.substring(0,n),t.substring(n+e[0].length)]}function Le(t,s,e){t.get(s)||t.set(s,e)}async function*Ht(t,s){if(!t.body)return;let e=Jt(t.body),n,i=e.getReader(),o;for(;;){if(s&&s.aborted)return i.cancel();if(n=await i.read(),n.done)return;if(!n.value){o&&(yield o),o=void 0;continue}let[r,a]=Wt(n.value)||[];r&&(r==="data"?(o||(o={}),o[r]=o[r]?o[r]+` 4`+a:a):r==="event"?(o||(o={}),o[r]=a):r==="id"?(o||(o={}),o[r]=+a||a):r==="retry"&&(o||(o={}),o[r]=+a||void 0))}}async function Vt(t,s){let e=new Request(t,s);Le(e.headers,"Accept","text/event-stream"),Le(e.headers,"Content-Type","application/json");let n=await fetch(e);if(!n.ok)throw n;return Ht(n,e.signal)}async function Kt(){let{event_callbacks:t,unclosed_events:s,pending_stream_messages:e,stream_status:n,config:i,jwt:o}=this;const r=this;if(!i)throw new Error("Could not resolve app config");n.open=!0;let a=null,c=new URLSearchParams({session_hash:this.session_hash}).toString(),u=new URL(`${i.root}/queue/data?${c}`);if(o&&u.searchParams.set("__sign",o),a=this.stream(u),!a){console.warn("Cannot connect to SSE endpoint: "+u.toString());return}a.onmessage=async function(_){let p=JSON.parse(_.data);if(p.msg==="close_stream"){te(n,r.abort_controller);return}const h=p.event_id;if(!h)await Promise.all(Object.keys(t).map(y=>t[y](p)));else if(t[h]&&i){p.msg==="process_completed"&&["sse","sse_v1","sse_v2","sse_v2.1","sse_v3"].includes(i.protocol)&&s.delete(h);let y=t[h];typeof window<"u"&&typeof document<"u"?setTimeout(y,0,p):y(p)}else e[h]||(e[h]=[]),e[h].push(p)},a.onerror=async function(){await Promise.all(Object.keys(t).map(_=>t[_]({msg:"unexpected_error",message:B})))}}function te(t,s){t&&(t.open=!1,s?.abort())}function Zt(t,s,e){!t[s]?(t[s]=[],e.data.forEach((i,o)=>{t[s][o]=i})):e.data.forEach((i,o)=>{let r=Yt(t[s][o],i);t[s][o]=r,e.data[o]=r})}function Yt(t,s){return s.forEach(([e,n,i])=>{t=Qt(t,n,e,i)}),t}function Qt(t,s,e,n){if(s.length===0){if(e==="replace")return n;if(e==="append")return t+n;throw new Error(`Unsupported action: ${e}`)}let i=t;for(let r=0;r<s.length-1;r++)i=i[s[r]];const o=s[s.length-1];switch(e){case"replace":i[o]=n;break;case"append":i[o]+=n;break;case"add":Array.isArray(i)?i.splice(Number(o),0,n):i[o]=n;break;case"delete":Array.isArray(i)?i.splice(Number(o),1):delete i[o];break;default:throw new Error(`Unknown action: ${e}`)}return t}function Xt(t,s={}){const e={close:()=>{console.warn("Method not implemented.")},onerror:null,onmessage:null,onopen:null,readyState:0,url:t.toString(),withCredentials:!1,CONNECTING:0,OPEN:1,CLOSED:2,addEventListener:()=>{throw new Error("Method not implemented.")},dispatchEvent:()=>{throw new Error("Method not implemented.")},removeEventListener:()=>{throw new Error("Method not implemented.")}};return Vt(t,s).then(async n=>{e.readyState=e.OPEN;try{for await(const i of n)e.onmessage&&e.onmessage(i);e.readyState=e.CLOSED}catch(i){e.onerror&&e.onerror(i),e.readyState=e.CLOSED}}).catch(n=>{console.error(n),e.onerror&&e.onerror(n),e.readyState=e.CLOSED}),e}function es(t,s={},e,n,i){var o;try{let r=function(w){(i||Ye[w.type])&&_(w)},a=function(){for(ue=!0;V.length>0;)V.shift()({value:void 0,done:!0})},c=function(w){ue||(V.length>0?V.shift()(w):pe.push(w))},u=function(w){c(ts(w)),a()},_=function(w){c({value:w,done:!1})},p=function(){return pe.length>0?Promise.resolve(pe.shift()):ue?Promise.resolve({value:void 0,done:!0}):new Promise(w=>V.push(w))};const{hf_token:h}=this.options,{fetch:y,app_reference:b,config:l,session_hash:m,api_info:k,api_map:A,stream_status:Q,pending_stream_messages:oe,pending_diff_streams:re,event_callbacks:ae,unclosed_events:Ke,post_data:ce,options:M}=this,Se=this;if(!k)throw new Error("No API found");if(!l)throw new Error("Could not resolve app config");
4let{fn_index:d,endpoint_info:Ee,dependency:G}=ss(k,t,A,l),Ze=Rt(s,Ee),C,x,I=l.protocol??"ws";const g=typeof t=="number"?"/predict":t;let H,E=null,R=!1,le={},F=typeof window<"u"&&typeof document<"u"?new URLSearchParams(window.location.search).toString():"";const Ye=((o=M?.events)==null?void 0:o.reduce((w,N)=>(w[N]=!0,w),{}))||{};async function Qe(){const w={stage:"complete",queue:!1,time:new Date};R=w,r({...w,type:"status",endpoint:g,fn_index:d});let N={},J={};I==="ws"?(C&&C.readyState===0?C.addEventListener("open",()=>{C.close()}):C.close(),N={fn_index:d,session_hash:m}):(te(Q,Se.abort_controller),a(),N={event_id:E},J={event_id:E,session_hash:m,fn_index:d});try{if(!l)throw new Error("Could not resolve app config");"event_id"in J&&await y(`${l.root}/cancel`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(J)}),await y(`${l.root}/reset`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(N)})}catch{console.warn("The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.")}}const Xe=async w=>{await this._resolve_hearbeat(w)};async function ke(w){if(!l)return;let N=w.render_id;l.components=[...l.components.filter(v=>v.props.rendered_in!==N),...w.components],l.dependencies=[...l.dependencies.filter(v=>v.rendered_in!==N),...w.dependencies];const J=l.components.some(v=>v.type==="state"),X=l.dependencies.some(v=>v.targets.some(j=>j[1]==="unload"));l.connect_heartbeat=J||X,await Xe(l),r({type:"render",data:w,endpoint:g,fn_index:d})}this.handle_blob(l.root,Ze,Ee).then(async w=>{var N;if(H={data:Z(w,G,l.components,"input",!0)||[],event_data:e,fn_index:d,trigger_id:n},Pt(d,l))r({type:"status",endpoint:g,stage:"pending",queue:!1,fn_index:d,time:new Date}),ce(`${l.root}/run${g.startsWith("/")?g:`/${g}`}${F?"?"+F:""}`,{...H,session_hash:m}).then(([v,j])=>{const q=v.data;j==200?(r({type:"data",endpoint:g,fn_index:d,data:Z(q,G,l.components,"output",M.with_null_state),time:new Date,event_data:e,trigger_id:n}),v.render_config&&ke(v.render_config),r({type:"status",endpoint:g,fn_index:d,stage:"complete",eta:v.average_duration,queue:!1,time:new Date})):r({type:"status",stage:"error",endpoint:g,fn_index:d,message:v.error,queue:!1,time:new Date})}).catch(v=>{r({type:"status",stage:"error",message:v.message,endpoint:g,fn_index:d,queue:!1,time:new Date})});else if(I=="ws"){const{ws_protocol:v,host:j}=await ne(b,h);r({type:"status",stage:"pending",queue:!0,endpoint:g,fn_index:d,time:new Date});let q=new URL(`${v}://${Fe(j,l.path,!0)}/queue/join${F?"?"+F:""}`);this.jwt&&q.searchParams.set("__sign",this.jwt),C=new WebSocket(q),C.onclose=P=>{P.wasClean||r({type:"status",stage:"error",broken:!0,message:B,queue:!0,endpoint:g,fn_index:d,time:new Date})},C.onmessage=function(P){const O=JSON.parse(P.data),{type:$,status:D,data:T}=me(O,le[d]);if($==="update"&&D&&!R)r({type:"status",endpoint:g,fn_index:d,time:new Date,...D}),D.stage==="error"&&C.close();else if($==="hash"){C.send(JSON.stringify({fn_index:d,session_hash:m}));return}else $==="data"?C.send(JSON.stringify({...H,session_hash:m})):$==="complete"?R=D:$==="log"?r({type:"log",log:T.log,level:T.level,endpoint:g,duration:T.duration,visible:T.visible,fn_index:d}):$==="generating"&&r({type:"status",time:new Date,...D,stage:D?.stage,queue:!0,endpoint:g,fn_index:d});T&&(r({type:"data",time:new Date,data:Z(T.data,G,l.components,"output",M.with_null_state),endpoint:g,fn_index:d,event_data:e,trigger_id:n}),R&&(r({type:"status",time:new Date,...R,stage:D?.stage,queue:!0,endpoint:g,fn_index:d}),C.close()))},qe(l.version||"2.0.0","3.6")<0&&addEventListener("open",()=>C.send(JSON.stringify({hash:m})))}else if(I=="sse"){r({type:"status",stage:"pending",queue:!0,endpoint:g,fn_index:d,time:new Date});var X=new URLSearchParams({fn_index:d.toString(),session_hash:m}).toString();let v=new URL(`${l.root}/queue/join?${F?F+"&":""}${X}`);if(this.jwt&&v.searchParams.set("__sign",this.jwt),x=this.stream(v),!x)return Promise.reject(new Error("Cannot connect to SSE endpoint: "+v.toString()));
4x.onmessage=async function(j){const q=JSON.parse(j.data),{type:P,status:O,data:$}=me(q,le[d]);if(P==="update"&&O&&!R)r({type:"status",endpoint:g,fn_index:d,time:new Date,...O}),O.stage==="error"&&(x?.close(),a());else if(P==="data"){E=q.event_id;let[D,T]=await ce(`${l.root}/queue/data`,{...H,session_hash:m,event_id:E});T!==200&&(r({type:"status",stage:"error",message:B,queue:!0,endpoint:g,fn_index:d,time:new Date}),x?.close(),a())}else P==="complete"?R=O:P==="log"?r({type:"log",log:$.log,level:$.level,endpoint:g,duration:$.duration,visible:$.visible,fn_index:d}):P==="generating"&&r({type:"status",time:new Date,...O,stage:O?.stage,queue:!0,endpoint:g,fn_index:d});$&&(r({type:"data",time:new Date,data:Z($.data,G,l.components,"output",M.with_null_state),endpoint:g,fn_index:d,event_data:e,trigger_id:n}),R&&(r({type:"status",time:new Date,...R,stage:O?.stage,queue:!0,endpoint:g,fn_index:d}),x?.close(),a()))}}else if(I=="sse_v1"||I=="sse_v2"||I=="sse_v2.1"||I=="sse_v3"){r({type:"status",stage:"pending",queue:!0,endpoint:g,fn_index:d,time:new Date});let v="";typeof window<"u"&&typeof document<"u"&&(v=(N=window?.location)==null?void 0:N.hostname);const q=v.includes(".dev.")?`https://moon-${v.split(".")[1]}.dev.spaces.huggingface.tech`:"https://huggingface.co",P=typeof window<"u"&&typeof document<"u"&&window.parent!=window,O=G.zerogpu&&l.space_id;(P&&O?Dt("zerogpu-headers",q):Promise.resolve(null)).then(T=>ce(`${l.root}/queue/join?${F}`,{...H,session_hash:m},T)).then(async([T,Ce])=>{if(Ce===503)r({type:"status",stage:"error",message:je,queue:!0,endpoint:g,fn_index:d,time:new Date});else if(Ce!==200)r({type:"status",stage:"error",message:B,queue:!0,endpoint:g,fn_index:d,time:new Date});else{E=T.event_id;let Re=async function(he){try{const{type:U,status:S,data:L}=me(he,le[d]);if(U=="heartbeat")return;if(U==="update"&&S&&!R)r({type:"status",endpoint:g,fn_index:d,time:new Date,...S});else if(U==="complete")R=S;else if(U=="unexpected_error")console.error("Unexpected error",S?.message),r({type:"status",stage:"error",message:S?.message||"An Unexpected Error Occurred!",queue:!0,endpoint:g,fn_index:d,time:new Date});else if(U==="log"){r({type:"log",log:L.log,level:L.level,endpoint:g,duration:L.duration,visible:L.visible,fn_index:d});return}else U==="generating"&&(r({type:"status",time:new Date,...S,stage:S?.stage,queue:!0,endpoint:g,fn_index:d}),L&&["sse_v2","sse_v2.1","sse_v3"].includes(I)&&Zt(re,E,L));L&&(r({type:"data",time:new Date,data:Z(L.data,G,l.components,"output",M.with_null_state),endpoint:g,fn_index:d}),L.render_config&&await ke(L.render_config),R&&(r({type:"status",time:new Date,...R,stage:S?.stage,queue:!0,endpoint:g,fn_index:d}),a())),(S?.stage==="complete"||S?.stage==="error")&&(ae[E]&&delete ae[E],E in re&&delete re[E])}catch(U){console.error("Unexpected client exception",U),r({type:"status",stage:"error",message:"An Unexpected Error Occurred!",queue:!0,endpoint:g,fn_index:d,time:new Date}),["sse_v2","sse_v2.1","sse_v3"].includes(I)&&(te(Q,Se.abort_controller),Q.open=!1,a())}};E in oe&&(oe[E].forEach(he=>Re(he)),delete oe[E]),ae[E]=Re,Ke.add(E),Q.open||await this.open_stream()}})}});let ue=!1;const pe=[],V=[],$e={[Symbol.asyncIterator]:()=>$e,next:p,throw:async w=>(u(w),p()),return:async()=>(a(),p()),cancel:Qe};return $e}catch(r){throw console.error("Submit function encountered an error:",r),r}}function ts(t){return{then:(s,e)=>e(t)}}function ss(t,s,e,n){let i,o,r;if(typeof s=="number")i=s,o=t.unnamed_endpoints[i],r=n.dependencies.find(a=>a.id==s);else{const a=s.replace(/^\//,"");i=e[a],o=t.named_endpoints[s.trim()],r=n.dependencies.find(c=>c.id==e[a])}if(typeof i!="number")throw new Error("There is no endpoint matching that name of fn_index matching that number.");return{fn_index:i,endpoint_info:o,dependency:r}}class se{constructor(s,e={events:["data"]}){f(this,"app_reference"),f(this,"options"),f(this,"config"),f(this,"api_info"),f(this,"api_map",{}),f(this,"session_hash",Math.random().toString(36).substring(2)),f(this,"jwt",!1),f(this,"last_status",{}),f(this,"cookies",null),f(this,"stream_status",{open:!1}),f(this,"pending_stream_messages",{}),f(this,"pending_diff_streams",{}),f(this,"event_callbacks",{}),f(this,"unclosed_events",new Set),f(this,"heartbeat_event",null),f(this,"abort_controller",null),f(this,"stream_instance",null),f(this,"view_api"),f(this,"upload_files"),f(this,"upload"),f(this,"handle_blob"),f(this,"post_data"),f(this,"submit"),f(this,"predict"),f(this,"open_stream"),f(this,"resolve_config"),f(this,"resolve_cookies"),this.app_reference=s,e.events||(e.events=["data"]),this.options=e,this.view_api=Ot.bind(this),this.upload_files=Tt.bind(this),this.handle_blob=Lt.bind(this),this.post_data=qt.bind(this),this.submit=es.bind(this),this.predict=jt.bind(this),this.open_stream=Kt.bind(this),this.resolve_config=bt.bind(this),this.resolve_cookies=St.bind(this),this.upload=At.bind(this),this.fetch=this.fetch.bind(this),this.handle_space_success=this.handle_space_success.bind(this),this.stream=this.stream.bind(this)}fetch(s,e){const n=new Headers(e?.headers||{});return this&&this.cookies&&n.append("Cookie",this.cookies),fetch(s,{...e,headers:n})}stream(s){const e=new Headers;return this&&this.cookies&&e.append("Cookie",this.cookies),this.abort_controller=new AbortController,this.stream_instance=Xt(s.toString(),{credentials:"include",headers:e,signal:this.abort_controller.signal}),this.stream_instance}
4async init(){var s;if((typeof window>"u"||!("WebSocket"in window))&&!global.WebSocket){const e=await ee(()=>import("./wrapper-CviSselG-DCvi549i.js"),__vite__mapDeps([0,1]),import.meta.url);global.WebSocket=e.WebSocket}try{this.options.auth&&await this.resolve_cookies(),await this._resolve_config().then(({config:e})=>this._resolve_hearbeat(e))}catch(e){throw Error(e)}this.api_info=await this.view_api(),this.api_map=vt(((s=this.config)==null?void 0:s.dependencies)||[])}async _resolve_hearbeat(s){if(s&&(this.config=s,this.config&&this.config.connect_heartbeat&&this.config.space_id&&this.options.hf_token&&(this.jwt=await Ae(this.config.space_id,this.options.hf_token,this.cookies))),s.space_id&&this.options.hf_token&&(this.jwt=await Ae(s.space_id,this.options.hf_token)),this.config&&this.config.connect_heartbeat){const e=new URL(`${this.config.root}/heartbeat/${this.session_hash}`);this.jwt&&e.searchParams.set("__sign",this.jwt),this.heartbeat_event||(this.heartbeat_event=this.stream(e))}}static async connect(s,e={events:["data"]}){const n=new this(s,e);return await n.init(),n}close(){te(this.stream_status,this.abort_controller)}static async duplicate(s,e={events:["data"]}){return Bt(s,e)}async _resolve_config(){const{http_protocol:s,host:e,space_id:n}=await ne(this.app_reference,this.options.hf_token),{status_callback:i}=this.options;n&&i&&await We(n,i);let o;try{if(o=await this.resolve_config(`${s}//${e}`),!o)throw new Error(W);return this.config_success(o)}catch(r){if(n&&i)Y(n,be.test(n)?"space_name":"subdomain",this.handle_space_success);else throw i&&i({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"}),Error(r)}}async config_success(s){if(this.config=s,typeof window<"u"&&typeof document<"u"&&window.location.protocol==="https:"&&(this.config.root=this.config.root.replace("http://","https://")),this.config.auth_required)return this.prepare_return_obj();try{this.api_info=await this.view_api()}catch(e){console.error(ft+e.message)}return this.prepare_return_obj()}async handle_space_success(s){if(!this)throw new Error(W);const{status_callback:e}=this.options;if(e&&e(s),s.status==="running")try{if(this.config=await this._resolve_config(),!this.config)throw new Error(W);return await this.config_success(this.config)}catch(n){throw e&&e({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"}),n}}async component_server(s,e,n){var i;if(!this.config)throw new Error(W);const o={},{hf_token:r}=this.options,{session_hash:a}=this;r&&(o.Authorization=`Bearer ${this.options.hf_token}`);let c,u=this.config.components.find(p=>p.id===s);(i=u?.props)!=null&&i.root_url?c=u.props.root_url:c=this.config.root;let _;if("binary"in n){_=new FormData;for(const p in n.data)p!=="binary"&&_.append(p,n.data[p]);_.set("component_id",s.toString()),_.set("fn_name",e),_.set("session_hash",a)}else _=JSON.stringify({data:n,component_id:s,fn_name:e,session_hash:a}),o["Content-Type"]="application/json";r&&(o.Authorization=`Bearer ${r}`);try{const p=await this.fetch(`${c}/component_server/`,{method:"POST",body:_,headers:o,credentials:"include"});if(!p.ok)throw new Error("Could not connect to component server: "+p.statusText);return await p.json()}catch(p){console.warn(p)}}set_cookies(s){this.cookies=Me(s).join("; ")}prepare_return_obj(){return{config:this.config,predict:this.predict,submit:this.submit,view_api:this.view_api,component_server:this.component_server}}}let He=!1;"attachShadow"in Element.prototype&&"adoptedStyleSheets"in Document.prototype&&(He="adoptedStyleSheets"in document.createElement("div").attachShadow({mode:"open"}));function xe(t,s){const e=new URL(import.meta.url).origin,n=new URL(t,e).href;if(document.querySelector(`link[href='${n}']`))return Promise.resolve();const o=document.createElement("link");return o.rel="stylesheet",o.href=n,new Promise((r,a)=>{o.addEventListener("load",()=>r()),o.addEventListener("error",()=>{console.error(`Unable to preload CSS for ${n}`),r()}),s.appendChild(o)})}function cs(t,s,e=document.createElement("style")){if(!He)return null;e.remove();const n=new CSSStyleSheet;n.replaceSync(t);let i="";t=t.replace(/@import\s+url\((.*?)\);\s*/g,(c,u)=>(i+=`@import url(${u}); 5`,""));const o=n.cssRules;let r="",a=`gradio-app .gradio-container.gradio-container-${s} .contain `;for(let c=0;c<o.length;c++){const u=o[c];let _=u.cssText.includes(".dark");if(u instanceof CSSStyleRule){const p=u.selectorText;if(p){const h=p.replace(".dark","").split(",").map(y=>`${_?".dark":""} ${a} ${y.trim()} `).join(",");r+=u.cssText,r+=u.cssText.replace(p,h)}}else if(u instanceof CSSMediaRule){let p=`@media ${u.media.mediaText} {`;
5for(let h=0;h<u.cssRules.length;h++){const y=u.cssRules[h];if(y instanceof CSSStyleRule){let b=y.cssText.includes(".dark ");const l=y.selectorText,m=l.replace(".dark","").split(",").map(k=>`${b?".dark":""} ${a} ${k.trim()} `).join(",");p+=y.cssText.replace(l,m)}}p+="}",r+=p}else if(u instanceof CSSKeyframesRule){r+=`@keyframes ${u.name} {`;for(let p=0;p<u.cssRules.length;p++){const h=u.cssRules[p];h instanceof CSSKeyframeRule&&(r+=`${h.keyText} { ${h.style.cssText} }`)}r+="}"}else u instanceof CSSFontFaceRule&&(r+=`@font-face { ${u.style.cssText} }`)}return r=i+r,e.textContent=r,document.head.appendChild(e),e}const ns="./assets/index-CKyT5UbA.css";let we;we=[];let ye,Ve,is=new Promise(t=>{Ve=t});async function os(){ye=(await ee(()=>import("./Index-DyMt_EUv.js").then(t=>t.k),__vite__mapDeps([2,3]),import.meta.url)).default,Ve()}function rs(){const t={SvelteComponent:de.SvelteComponent};for(const e in de)e!=="SvelteComponent"&&(e==="SvelteComponentDev"?t[e]=t.SvelteComponent:t[e]=de[e]);window.__gradio__svelte__internal=t;class s extends HTMLElement{constructor(){super(),this.host=this.getAttribute("host"),this.space=this.getAttribute("space"),this.src=this.getAttribute("src"),this.control_page_title=this.getAttribute("control_page_title"),this.initial_height=this.getAttribute("initial_height")??"300px",this.is_embed=this.getAttribute("embed")??"true",this.container=this.getAttribute("container")??"true",this.info=this.getAttribute("info")??!0,this.autoscroll=this.getAttribute("autoscroll"),this.eager=this.getAttribute("eager"),this.theme_mode=this.getAttribute("theme_mode"),this.updating=!1,this.loading=!1}async connectedCallback(){await os(),this.loading=!0,this.app&&this.app.$destroy(),typeof we!="string"&&we.forEach(o=>xe(o,document.head)),await xe(ns,document.head);const n=new CustomEvent("domchange",{bubbles:!0,cancelable:!1,composed:!0});new MutationObserver(o=>{this.dispatchEvent(n)}).observe(this,{childList:!0}),this.app=new ye({target:this,props:{space:this.space?this.space.trim():this.space,src:this.src?this.src.trim():this.src,host:this.host?this.host.trim():this.host,info:this.info!=="false",container:this.container!=="false",is_embed:this.is_embed!=="false",initial_height:this.initial_height,eager:this.eager==="true",version:"4-41-0",theme_mode:this.theme_mode,autoscroll:this.autoscroll==="true",control_page_title:this.control_page_title==="true",Client:se,app_mode:window.__gradio_mode__==="app"}}),this.updating&&this.setAttribute(this.updating.name,this.updating.value),this.loading=!1}static get observedAttributes(){return["src","space","host"]}async attributeChangedCallback(n,i,o){if(await is,(n==="host"||n==="space"||n==="src")&&o!==i){if(this.updating={name:n,value:o},this.loading)return;this.app&&this.app.$destroy(),this.space=null,this.host=null,this.src=null,n==="host"?this.host=o:n==="space"?this.space=o:n==="src"&&(this.src=o),this.app=new ye({target:this,props:{space:this.space?this.space.trim():this.space,src:this.src?this.src.trim():this.src,host:this.host?this.host.trim():this.host,info:this.info!=="false",container:this.container!=="false",is_embed:this.is_embed!=="false",initial_height:this.initial_height,eager:this.eager==="true",version:"4-41-0",theme_mode:this.theme_mode,autoscroll:this.autoscroll==="true",control_page_title:this.control_page_title==="true",Client:se,app_mode:window.__gradio_mode__==="app"}}),this.updating=!1}}}customElements.get("gradio-app")||customElements.define("gradio-app",s)}rs();export{ee as _,cs as a,xe as m,as as p}; 6//# sourceMappingURL=index-NyBnvGBo.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.