vendor: 36,091 bytes, lines 1-4
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Index-5Abk5KKk.js","./i18n-Dub1g69U.js","./i18n-DVe3Q23J.css","./StreamingBar-DwBbQPSd.js","./FullscreenButton-CY3DenSN.js","./MarkdownCode-B_oSAavQ.js","./prism-python-BTLJbtOb.js","./MarkdownCode-CN4TU2_A.css","./FullscreenButton-o28pHKz1.css","./StreamingBar-W6tCEweZ.css","./DownloadLink-Clun45p7.js","./DownloadLink-BxEHTUoe.css","./Index-BkyjjaNE.css","./index-DiLM2iIA.js"])))=>i.map(i=>d[i]); 2import*as ae from"./svelte/svelte.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function e(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(o){if(o.ep)return;o.ep=!0;const i=e(o);fetch(o.href,i)}})();const Qe="modulepreload",Xe=function(t,s){return new URL(t,s).href},Se={},K=function(s,e,n){let o=Promise.resolve();if(e&&e.length>0){const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");o=Promise.allSettled(e.map(u=>{if(u=Xe(u,n),u in Se)return;Se[u]=!0;const p=u.endsWith(".css"),c=p?'[rel="stylesheet"]':"";if(!!n)for(let h=r.length-1;h>=0;h--){const y=r[h];if(y.href===u&&(!p||y.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${c}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":Qe,p||(g.as="script"),g.crossOrigin="",g.href=u,l&&g.setAttribute("nonce",l),document.head.appendChild(g),p)return new Promise((h,y)=>{g.addEventListener("load",h),g.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return o.then(r=>{for(const a of r||[])a.status==="rejected"&&i(a.reason);return s().catch(i)})};var ce=new Intl.Collator(0,{numeric:1}).compare;function Te(t,s,e){return t=t.split("."),s=s.split("."),ce(t[0],s[0])||ce(t[1],s[1])||(s[2]=s.slice(2).join("."),e=/[.-]/.test(t[2]=t.slice(2).join(".")),e==/[.-]/.test(s[2])?ce(t[2],s[2]):e?-1:1)}const et="host",Le="queue/data",tt="queue/join",$e="upload",st="login",ke="config",nt="info",it="runtime",ot="sleeptime",rt="heartbeat",at="component_server",ct="reset",lt="cancel",ut="app_id",pt="https://gradio-space-api-fetcher-v2.hf.space/api",Pe="This application is currently busy. Please try again. ",U="Connection errored out. ",I="Could not resolve app config. ",ht="Could not get space status. ",ft="Could not get API info. ",_e="Space metadata could not be loaded. ",dt="Invalid URL. A full URL path is required.",_t="Not authorized to access this space. ",De="Invalid credentials. Could not login. ",mt="Login credentials are required to access this space.",gt="File system access is only available in Node.js environments",xe="Root URL not found in client config",wt="Error uploading file";function yt(t,s,e){return s.startsWith("http://")||s.startsWith("https://")?e?t:s:t+s}async function Re(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 bt(t){let s={};return t.forEach(({api_name:e,id:n})=>{e&&(s[e]=n)}),s}async function vt(t){const s=this.options.hf_token?{Authorization:`Bearer ${this.options.hf_token}`}:{};if(s["Content-Type"]="application/json",typeof window<"u"&&window.gradio_config&&location.origin!=="http://localhost:9876"&&!window.gradio_config.dev_mode)return window.gradio_config.current_page&&(t=t.substring(0,t.lastIndexOf("/"))),window.gradio_config.root=t,{...window.gradio_config};if(t){let e=qe(t,this.deep_link?ke+"?deep_link="+this.deep_link:ke);const n=await this.fetch(e,{headers:s,credentials:"include"});return Et(n,t,!!this.options.auth)}throw new Error(I)}async function Et(t,s,e){if(t?.status===401&&!e){const o=(await t.json())?.detail?.auth_message;throw new Error(o||mt)}else if(t?.status===401&&e)throw new Error(De);if(t?.status===200){let n=await t.json();return n.root=s,n.dependencies?.forEach((o,i)=>{o.id===void 0&&(o.id=i)}),n}else if(t?.status===401)throw new Error(_t);throw new Error(I)}async function St(){const{http_protocol:t,host:s}=await Y(this.app_reference,this.options.hf_token);try{if(this.options.auth){const e=await Ie(t,s,this.options.auth,this.fetch,this.options.hf_token);e&&this.set_cookies(e)}}catch(e){throw Error(e.message)}}async function Ie(t,s,e,n,o){const i=new FormData;i.append("username",e?.[0]),i.append("password",e?.[1]);let r={};o&&(r.Authorization=`Bearer ${o}`);const a=await n(`${t}//${s}/${st}`,{headers:r,method:"POST",body:i,credentials:"include"});if(a.status===200)return a.headers.get("set-cookie");throw a.status===401?new Error(De):new Error(_e)}function le(t){if(t.startsWith("http")){const{protocol:s,host:e,pathname:n}=new URL(t);return{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:new URL(t).host}}const je=t=>{let s=[];return t.split(/,(?=\s*[^\s=;]+=[^\s=;]+)/).forEach(n=>{const[o,i]=n.split(";")[0].split("=");o&&i&&s.push(`${o.trim()}=${i.trim()}`)}),s},me=/^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/,$t=/.*hf\.space\/{0,1}.*$/;async function Y(t,s){const e={};s&&(e.Authorization=`Bearer ${s}`);const n=t.trim().replace(/\/$/,"");if(me.test(n))try{const i=(await(await fetch(`https://huggingface.co/api/spaces/${n}/${et}`,{headers:e})).json()).host;return{space_id:t,...le(i)}}catch{throw new Error(_e)}if($t.test(n)){const{ws_protocol:o,http_protocol:i,host:r}=le(n);return{space_id:r.split("/")[0].replace(".hf.space",""),ws_protocol:o,http_protocol:i,host:r}}return{space_id:!1,...le(n)}}const qe=(...t)=>{try{return t.reduce((s,e)=>(s=s.replace(/\/+$/,""),e=e.replace(/^\/+/,""),new URL(e,s+"/").toString()))}catch{throw new Error(dt)}};function kt(t,s,e){const n={named_endpoints:{},unnamed_endpoints:{}};return Object.keys(t).forEach(o=>{(o==="named_endpoints"||o==="unnamed_endpoints")&&(n[o]={},Object.entries(t[o]).forEach(([i,{parameters:r,returns:a}])=>{const l=s.dependencies.find(c=>c.api_name===i||c.api_name===i.replace("/",""))?.id||e[i.replace("/","")]||-1,u=l!==-1?s.dependencies.find(c=>c.id==l)?.types:{generator:!1,cancel:!1};if(l!==-1&&s.dependencies.find(c=>c.id==l)?.inputs?.length!==r.length){const c=s.dependencies.find(_=>_.id==l).inputs.map(_=>s.components.find(g=>g.id===_)?.type);try{c.forEach((_,g)=>{if(_==="state"){const h={component:"state",example:null,parameter_default:null,parameter_has_default:!0,parameter_name:null,hidden:!0};r.splice(g,0,h)}})}catch(_){console.error(_)}}const p=(c,_,g,h)=>({...c,description:Ot(c?.type,g),type:Rt(c?.type,_,g,h)||""});n[o][i]={parameters:r.map(c=>p(c,c?.component,c?.serializer,"parameter")),returns:a.map(c=>p(c,c?.component,c?.serializer,"return")),type:u}}))}),n}function Rt(t,s,e,n){if(s==="Api")return t.type;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 Ot(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 ue(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:Pe,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,session_not_found:t.session_not_found,stage:"error",success:!1}};case"broken_connection":return{type:"broken_connection",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,changed_state_ids:t.success?t.output.changed_state_ids:void 0},data:t.success?t.output:null};case"process_streaming":return{type:"streaming",status:{queue:!0,message:t.output.error,stage:"streaming",time_limit:t.time_limit,code:t.code,progress_data:t.progress_data,eta:t.eta},data:t.output};case"process_completed":return"error"in t.output?{type:"update",status:{queue:!0,title:t.output.title,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},original_msg:"process_starts"}}return{type:"none",status:{stage:"error",queue:!0}}}const At=(t=[],s)=>{const e=s?s.parameters:[];if(Array.isArray(t))return s&&e.length>0&&t.length>e.length&&console.warn("Too many arguments provided for the endpoint."),t;const n=[],o=Object.keys(t);return e.forEach((i,r)=>{if(t.hasOwnProperty(i.parameter_name))n[r]=t[i.parameter_name];else if(i.parameter_has_default)n[r]=i.parameter_default;else throw new Error(`No value provided for required parameter: ${i.parameter_name}`)}),o.forEach(i=>{if(!e.some(r=>r.parameter_name===i))throw new Error(`Parameter \`${i}\` is not a valid keyword argument. Please refer to the API for usage.`)}),n.forEach((i,r)=>{if(i===void 0&&!e[r].parameter_has_default)throw new Error(`No value provided for required parameter: ${e[r].parameter_name}`)}),n};async function Ct(){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,o;if(typeof window<"u"&&window.gradio_api_info)o=window.gradio_api_info;else{if(Te(s?.version||"2.0.0","3.30")<0)n=await this.fetch(pt,{method:"POST",body:JSON.stringify({serialize:!1,config:JSON.stringify(s)}),headers:e,credentials:"include"});else{const i=qe(s.root,this.api_prefix,nt);n=await this.fetch(i,{headers:e,credentials:"include"})}if(!n.ok)throw new Error(U);o=await n.json()}return"api"in o&&(o=o.api),o.named_endpoints["/predict"]&&!o.unnamed_endpoints[0]&&(o.unnamed_endpoints[0]=o.named_endpoints["/predict"]),kt(o,s,this.api_map)}catch(n){throw new Error("Could not get API info. "+n.message)}}async function Nt(t,s,e){const n={};this?.options?.hf_token&&(n.Authorization=`Bearer ${this.options.hf_token}`);const o=1e3,i=[];let r;for(let a=0;a<s.length;a+=o){const l=s.slice(a,a+o),u=new FormData;l.forEach(c=>{u.append("files",c)});try{const c=e?`${t}${this.api_prefix}/${$e}?upload_id=${e}`:`${t}${this.api_prefix}/${$e}`;r=await this.fetch(c,{method:"POST",body:u,headers:n,credentials:"include"})}catch(c){throw new Error(U+c.message)}if(!r.ok){const c=await r.text();return{error:`HTTP ${r.status}: ${c}`}}const p=await r.json();p&&i.push(...p)}return{files:i}}async function Tt(t,s,e,n){let o=(Array.isArray(t)?t:[t]).map(r=>r.blob);const i=o.filter(r=>r.size>(n??1/0));if(i.length)throw new Error(`File size exceeds the maximum allowed size of ${n} bytes: ${i.map(r=>r.name).join(", ")}`);return await Promise.all(await this.upload_files(s,o,e).then(async r=>{if(r.error)throw new Error(r.error);return r.files?r.files.map((a,l)=>new Q({...t[l],path:a,url:`${s}${this.api_prefix}/file=${a}`})):[]}))}async function cs(t,s){return t.map(e=>new Q({path:e.name,orig_name:e.name,blob:e,size:e.size,mime_type:e.type,is_stream:s}))}class Q{path;url;orig_name;size;blob;is_stream;mime_type;alt_text;b64;meta={_type:"gradio.FileData"};constructor({path:s,url:e,orig_name:n,size:o,blob:i,is_stream:r,mime_type:a,alt_text:l,b64:u}){this.path=s,this.url=e,this.orig_name=n,this.size=o,this.blob=e?void 0:i,this.is_stream=r,this.mime_type=a,this.alt_text=l,this.b64=u}}class Lt{type;command;meta;fileData;constructor(s,e){this.type="command",this.command=s,this.meta=e}}typeof process<"u"&&process.versions&&process.versions.node;function Oe(t,s,e){for(;e.length>1;){const o=e.shift();if(typeof o=="string"||typeof o=="number")t=t[o];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 pe(t,s=void 0,e=[],n=!1,o=void 0){if(Array.isArray(t)){let i=[];return await Promise.all(t.map(async(r,a)=>{let l=e.slice();l.push(String(a));const u=await pe(t[a],n?o?.parameters[a]?.component||void 0:s,l,!1,o);i=i.concat(u)})),i}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 i=[];for(const r of Object.keys(t)){const a=[...e,r],l=t[r];i=i.concat(await pe(l,void 0,a,!1,o))}return i}}return[]}function Pt(t,s){let e=s?.dependencies?.find(n=>n.id==t)?.queue;return e!=null?!e:!s.enable_queue}function Dt(t,s){return new Promise((e,n)=>{const o=new MessageChannel;o.port1.onmessage=({data:i})=>{o.port1.close(),e(i)},window.parent.postMessage(t,s,[o.port2])})}function W(t,s,e,n,o=!1){if(n==="input"&&!o)throw new Error("Invalid code path. Cannot skip state inputs for input.");if(n==="output"&&o)return t;let i=[],r=0;const a=n==="input"?s.inputs:s.outputs;for(let l=0;l<a.length;l++){const u=a[l];if(e.find(c=>c.id===u)?.type==="state"){if(o)if(t.length===a.length){const c=t[r];i.push(c),r++}else i.push(null);else{r++;continue}continue}else{const c=t[r];i.push(c),r++}}return i}async function xt(t,s,e){const n=this;await It(n,s);const o=await pe(s,void 0,[],!0,e);return(await Promise.all(o.map(async({path:r,blob:a,type:l})=>{if(!a)return{path:r,type:l};const u=await n.upload_files(t,[a]),p=u.files&&u.files[0];return{path:r,file_url:p,type:l,name:typeof File<"u"&&a instanceof File?a?.name:void 0}}))).forEach(({path:r,file_url:a,type:l,name:u})=>{if(l==="Gallery")Oe(s,a,r);else if(a){const p=new Q({path:a,orig_name:u});Oe(s,p,r)}}),s}async function It(t,s){if(!(t.config?.root||t.config?.root_url))throw new Error(xe);await Ue(t,s)}async function Ue(t,s,e=[]){for(const n in s)s[n]instanceof Lt?await jt(t,s,n):typeof s[n]=="object"&&s[n]!==null&&await Ue(t,s[n],[...e,n])}async function jt(t,s,e){let n=s[e];const o=t.config?.root||t.config?.root_url;if(!o)throw new Error(xe);try{let i,r;if(typeof process<"u"&&process.versions&&process.versions.node){const p=await K(()=>import("./__vite-browser-external-D7Ct-6yo.js").then(_=>_._),[],import.meta.url);r=(await K(()=>import("./__vite-browser-external-D7Ct-6yo.js").then(_=>_._),[],import.meta.url)).resolve(process.cwd(),n.meta.path),i=await p.readFile(r)}else throw new Error(gt);const a=new Blob([i],{type:"application/octet-stream"}),l=await t.upload_files(o,[a]),u=l.files&&l.files[0];if(u){const p=new Q({path:u,orig_name:n.meta.name||""});s[e]=p}}catch(i){console.error(wt,i)}}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 o=await this.fetch(t,{method:"POST",body:JSON.stringify(s),headers:{...n,...e},credentials:"include"})}catch{return[{error:U},500]}let i,r;try{i=await o.json(),r=o.status}catch(a){i={error:`Could not parse server response: ${a}`},r=500}return[i,r]}async function Ut(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(o=>o.id==t);else{const o=t.replace(/^\//,"");this.config.dependencies.find(i=>i.id==this.api_map[o])}return new Promise(async(o,i)=>{const r=this.submit(t,s,null,null,!0);let a;for await(const l of r)l.type==="data"&&(n&&o(a),e=!0,a=l),l.type==="status"&&(l.stage==="error"&&i(l),l.stage==="complete"&&(n=!0,e&&o(a)))})}async function H(t,s,e){let n=s==="subdomain"?`https://huggingface.co/api/spaces/by-subdomain/${t}`:`https://huggingface.co/api/spaces/${t}`,o,i;try{if(o=await fetch(n),i=o.status,i!==200)throw new Error;o=await o.json()}catch{e({status:"error",load_status:"error",message:ht,detail:"NOT_FOUND"});return}if(!o||i!==200)return;const{runtime:{stage:r},id:a}=o;switch(r){case"STOPPED":case"SLEEPING":e({status:"sleeping",load_status:"pending",message:"Space is asleep. Waking it up...",detail:r}),setTimeout(()=>{H(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 Ae(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(()=>{H(t,s,e)},1e3);break;case"APP_STARTING":e({status:"starting",load_status:"pending",message:"Space is starting...",detail:r}),setTimeout(()=>{H(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 Ae(a)});break}}const ze=async(t,s)=>{let e=0;const n=12,o=5e3;return new Promise(i=>{H(t,me.test(t)?"space_name":"subdomain",r=>{s(r),r.status==="running"||r.status==="error"||r.status==="paused"||r.status==="space_error"?i():(r.status==="sleeping"||r.status==="building")&&(e<n?(e++,setTimeout(()=>{ze(t,s).then(i)},o)):i())})})},zt=/^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;async function Ae(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&&zt.test(e))}catch{return!1}}async function Bt(t,s){const e={};s&&(e.Authorization=`Bearer ${s}`);try{const n=await fetch(`https://huggingface.co/api/spaces/${t}/${it}`,{headers:e});if(n.status!==200)throw new Error("Space hardware could not be obtained.");const{hardware:o}=await n.json();return o.current}catch(n){throw new Error(n.message)}}async function Ft(t,s,e){const n={};e&&(n.Authorization=`Bearer ${e}`);const o={seconds:s};try{const i=await fetch(`https://huggingface.co/api/spaces/${t}/${ot}`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(o)});if(i.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 i.json()}catch(i){throw new Error(i.message)}}const Ce=["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 Mt(t,s){const{hf_token:e,private:n,hardware:o,timeout:i,auth:r}=s;if(o&&!Ce.includes(o))throw new Error(`Invalid hardware type provided. Valid types are: ${Ce.map(b=>`"${b}"`).join(",")}.`);const{http_protocol:a,host:l}=await Y(t,e);let u=null;if(r){const b=await Ie(a,l,r,fetch);b&&(u=je(b))}const p={Authorization:`Bearer ${e}`,"Content-Type":"application/json",...u?{Cookie:u.join("; ")}:{}},c=(await(await fetch("https://huggingface.co/api/whoami-v2",{headers:p})).json()).name,_=t.split("/")[1],g={repository:`${c}/${_}`};n&&(g.private=!0);let h;try{o||(h=await Bt(t,e))}catch(b){throw Error(_e+b.message)}const y=o||h||"cpu-basic";g.hardware=y;try{const b=await fetch(`https://huggingface.co/api/spaces/${t}/duplicate`,{method:"POST",headers:p,body:JSON.stringify(g)});if(b.status===409)try{return await Z.connect(`${c}/${_}`,s)}catch(j){throw console.error("Failed to connect Client instance:",j),j}else if(b.status!==200)throw new Error(b.statusText);const X=await b.json();return await Ft(`${c}/${_}`,i||300,e),await Z.connect(Gt(X.url),s)}catch(b){throw new Error(b)}}function Gt(t){const s=/https:\/\/huggingface.co\/spaces\/([^/]+\/[^/]+)/,e=t.match(s);if(e)return e[1]}class Jt extends TransformStream{#e="";constructor(s={allowCR:!1}){super({transform:(e,n)=>{for(e=this.#e+e;;){const o=e.indexOf(` 3`),i=s.allowCR?e.indexOf("\r"):-1;if(i!==-1&&i!==e.length-1&&(o===-1||o-1>i)){n.enqueue(e.slice(0,i)),e=e.slice(i+1);continue}if(o===-1)break;const r=e[o-1]==="\r"?o-1:o;n.enqueue(e.slice(0,r)),e=e.slice(o+1)}this.#e=e},flush:e=>{if(this.#e==="")return;const n=s.allowCR&&this.#e.endsWith("\r")?this.#e.slice(0,-1):this.#e;e.enqueue(n)}})}}function Wt(t){let s=new TextDecoderStream,e=new Jt({allowCR:!0});return t.pipeThrough(s).pipeThrough(e)}function Ht(t){let e=/[:]\s*/.exec(t),n=e&&e.index;if(n)return[t.substring(0,n),t.substring(n+e[0].length)]}function Ne(t,s,e){t.get(s)||t.set(s,e)}async function*Vt(t,s){if(!t.body)return;let e=Wt(t.body),n,o=e.getReader(),i;for(;;){if(s&&s.aborted)return o.cancel();if(n=await o.read(),n.done)return;if(!n.value){i&&(yield i),i=void 0;continue}let[r,a]=Ht(n.value)||[];r&&(r==="data"?(i||={},i[r]=i[r]?i[r]+` 4`+a:a):r==="event"?(i||={},i[r]=a):r==="id"?(i||={},i[r]=+a||a):r==="retry"&&(i||={},i[r]=+a||void 0))}}async function Kt(t,s){let e=new Request(t,s);Ne(e.headers,"Accept","text/event-stream"),Ne(e.headers,"Content-Type","application/json");let n=await fetch(e);if(!n.ok)throw n;return Vt(n,e.signal)}async function Zt(){let{event_callbacks:t,unclosed_events:s,pending_stream_messages:e,stream_status:n,config:o,jwt:i}=this;const r=this;if(!o)throw new Error("Could not resolve app config");n.open=!0;let a=null,l=new URLSearchParams({session_hash:this.session_hash}).toString(),u=new URL(`${o.root}${this.api_prefix}/${Le}?${l}`);if(i&&u.searchParams.set("__sign",i),a=this.stream(u),!a){console.warn("Cannot connect to SSE endpoint: "+u.toString());return}a.onmessage=async function(p){let c=JSON.parse(p.data);if(c.msg==="close_stream"){ge(n,r.abort_controller);return}const _=c.event_id;if(!_)await Promise.all(Object.keys(t).map(g=>t[g](c)));else if(t[_]&&o){c.msg==="process_completed"&&["sse","sse_v1","sse_v2","sse_v2.1","sse_v3"].includes(o.protocol)&&s.delete(_);let g=t[_];typeof window<"u"&&typeof document<"u"?setTimeout(g,0,c):g(c)}else e[_]||(e[_]=[]),e[_].push(c)},a.onerror=async function(p){console.error(p),await Promise.all(Object.keys(t).map(c=>t[c]({msg:"broken_connection",message:U})))}}function ge(t,s){t&&(t.open=!1,s?.abort())}function Yt(t,s,e){!t[s]?(t[s]=[],e.data.forEach((o,i)=>{t[s][i]=o})):e.data.forEach((o,i)=>{let r=Qt(t[s][i],o);t[s][i]=r,e.data[i]=r})}function Qt(t,s){return s.forEach(([e,n,o])=>{t=Xt(t,n,e,o)}),t}function Xt(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 o=t;for(let r=0;r<s.length-1;r++)o=o[s[r]];const i=s[s.length-1];switch(e){case"replace":o[i]=n;break;case"append":o[i]+=n;break;case"add":Array.isArray(o)?o.splice(Number(i),0,n):o[i]=n;break;case"delete":Array.isArray(o)?o.splice(Number(i),1):delete o[i];break;default:throw new Error(`Unknown action: ${e}`)}return t}function es(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 Kt(t,s).then(async n=>{e.readyState=e.OPEN;try{for await(const o of n)e.onmessage&&e.onmessage(o);e.readyState=e.CLOSED}catch(o){e.onerror&&e.onerror(o),e.readyState=e.CLOSED}}).catch(n=>{console.error(n),e.onerror&&e.onerror(n),e.readyState=e.CLOSED}),e}function ts(t,s={},e,n,o){try{let i=function(m){(o||We[m.type])&&u(m)},r=function(){for(Ke=!0;J.length>0;)J.shift()({value:void 0,done:!0})},a=function(m){J.length>0?J.shift()(m):oe.push(m)},l=function(m){a(ss(m)),r()},u=function(m){a({value:m,done:!1})},p=function(){return oe.length>0?Promise.resolve(oe.shift()):new Promise(m=>J.push(m))};const{hf_token:c}=this.options,{fetch:_,app_reference:g,config:h,session_hash:y,api_info:b,api_map:X,stream_status:j,pending_stream_messages:ee,pending_diff_streams:te,event_callbacks:se,unclosed_events:Fe,post_data:ne,options:M,api_prefix:z}=this,Me=this;if(!b)throw new Error("No API found");if(!h)throw new Error("Could not resolve app config");let{fn_index:f,endpoint_info:we,dependency:B}=ns(b,t,X,h),Ge=At(s,we),$,F,D=h.protocol??"ws",ye="",Je=()=>ye;const d=typeof t=="number"?"/predict":t;let G,v=null,k=!1,ie={},q=typeof window<"u"&&typeof document<"u"?new URLSearchParams(window.location.search).toString():"";const We=M?.events?.reduce((m,x)=>(m[x]=!0,m),{})||{};async function He(){let m={},x={};D==="ws"?($&&$.readyState===0?$.addEventListener("open",()=>{$.close()}):$.close(),m={fn_index:f,session_hash:y}):(m={event_id:v},x={event_id:v,session_hash:y,fn_index:f});try{if(!h)throw new Error("Could not resolve app config");"event_id"in x&&await _(`${h.root}${z}/${lt}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(x)}),await _(`${h.root}${z}/${ct}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(m)})}catch{console.warn("The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.")}}const Ve=async m=>{await this._resolve_heartbeat(m)};async function be(m){if(!h)return;let x=m.render_id;h.components=[...h.components.filter(S=>S.props.rendered_in!==x),...m.components],h.dependencies=[...h.dependencies.filter(S=>S.rendered_in!==x),...m.dependencies];const V=h.components.some(S=>S.type==="state"),w=h.dependencies.some(S=>S.targets.some(L=>L[1]==="unload"));h.connect_heartbeat=V||w,await Ve(h),i({type:"render",data:m,endpoint:d,fn_index:f})}this.handle_blob(h.root,Ge,we).then(async m=>{if(G={data:W(m,B,h.components,"input",!0)||[],event_data:e,fn_index:f,trigger_id:n},Pt(f,h))i({type:"status",endpoint:d,stage:"pending",queue:!1,fn_index:f,time:new Date}),ne(`${h.root}${z}/run${d.startsWith("/")?d:`/${d}`}${q?"?"+q:""}`,{...G,session_hash:y}).then(([w,S])=>{const L=w.data;S==200?(i({type:"data",endpoint:d,fn_index:f,data:W(L,B,h.components,"output",M.with_null_state),time:new Date,event_data:e,trigger_id:n}),w.render_config&&be(w.render_config),i({type:"status",endpoint:d,fn_index:f,stage:"complete",eta:w.average_duration,queue:!1,time:new Date})):i({type:"status",stage:"error",endpoint:d,fn_index:f,message:w.error,queue:!1,time:new Date})}).catch(w=>{i({type:"status",stage:"error",message:w.message,endpoint:d,fn_index:f,queue:!1,time:new Date})});else if(D=="ws"){const{ws_protocol:w,host:S}=await Y(g,c);i({type:"status",stage:"pending",queue:!0,endpoint:d,fn_index:f,time:new Date});let L=new URL(`${w}://${yt(S,h.root,!0)}/queue/join${q?"?"+q:""}`);this.jwt&&L.searchParams.set("__sign",this.jwt),$=new WebSocket(L),$.onclose=A=>{A.wasClean||i({type:"status",stage:"error",broken:!0,message:U,queue:!0,endpoint:d,fn_index:f,time:new Date})},$.onmessage=function(A){const P=JSON.parse(A.data),{type:E,status:R,data:O}=ue(P,ie[f]);if(E==="update"&&R&&!k)i({type:"status",endpoint:d,fn_index:f,time:new Date,...R}),R.stage==="error"&&$.close();else if(E==="hash"){$.send(JSON.stringify({fn_index:f,session_hash:y}));return}else E==="data"?$.send(JSON.stringify({...G,session_hash:y})):E==="complete"?k=R:E==="log"?i({type:"log",title:O.title,log:O.log,level:O.level,endpoint:d,duration:O.duration,visible:O.visible,fn_index:f}):E==="generating"&&i({type:"status",time:new Date,...R,stage:R?.stage,queue:!0,endpoint:d,fn_index:f});O&&(i({type:"data",time:new Date,data:W(O.data,B,h.components,"output",M.with_null_state),endpoint:d,fn_index:f,event_data:e,trigger_id:n}),k&&(i({type:"status",time:new Date,...k,stage:R?.stage,queue:!0,endpoint:d,fn_index:f}),$.close()))},Te(h.version||"2.0.0","3.6")<0&&addEventListener("open",()=>$.send(JSON.stringify({hash:y})))}else if(D=="sse"){i({type:"status",stage:"pending",queue:!0,endpoint:d,fn_index:f,time:new Date});var V=new URLSearchParams({fn_index:f.toString(),session_hash:y}).toString();let w=new URL(`${h.root}${z}/${Le}?${q?q+"&":""}${V}`);if(this.jwt&&w.searchParams.set("__sign",this.jwt),F=this.stream(w),!F)return Promise.reject(new Error("Cannot connect to SSE endpoint: "+w.toString()));F.onmessage=async function(S){const L=JSON.parse(S.data),{type:A,status:P,data:E}=ue(L,ie[f]);if(A==="update"&&P&&!k)i({type:"status",endpoint:d,fn_index:f,time:new Date,...P}),P.stage==="error"&&(F?.close(),r());else if(A==="data"){let[R,O]=await ne(`${h.root}${z}/queue/data`,{...G,session_hash:y,event_id:v});O!==200&&(i({type:"status",stage:"error",message:U,queue:!0,endpoint:d,fn_index:f,time:new Date}),F?.close(),r())}else A==="complete"?k=P:A==="log"?i({type:"log",title:E.title,log:E.log,level:E.level,endpoint:d,duration:E.duration,visible:E.visible,fn_index:f}):(A==="generating"||A==="streaming")&&i({type:"status",time:new Date,...P,stage:P?.stage,queue:!0,endpoint:d,fn_index:f});E&&(i({type:"data",time:new Date,data:W(E.data,B,h.components,"output",M.with_null_state),endpoint:d,fn_index:f,event_data:e,trigger_id:n}),k&&(i({type:"status",time:new Date,...k,stage:P?.stage,queue:!0,endpoint:d,fn_index:f}),F?.close(),r()))}}else if(D=="sse_v1"||D=="sse_v2"||D=="sse_v2.1"||D=="sse_v3"){i({type:"status",stage:"pending",queue:!0,endpoint:d,fn_index:f,time:new Date});let w="";typeof window<"u"&&typeof document<"u"&&(w=window?.location?.hostname);const L=w.includes(".dev.")?`https://moon-${w.split(".")[1]}.dev.spaces.huggingface.tech`:"https://huggingface.co";(typeof window<"u"&&typeof document<"u"&&window.parent!=window&&window.supports_zerogpu_headers?Dt("zerogpu-headers",L):Promise.resolve(null)).then(R=>ne(`${h.root}${z}/${tt}?${q}`,{...G,session_hash:y},R)).then(async([R,O])=>{if(O===503)i({type:"status",stage:"error",message:Pe,queue:!0,endpoint:d,fn_index:f,time:new Date});else if(O!==200)i({type:"status",stage:"error",broken:!0,message:U,queue:!0,endpoint:d,fn_index:f,time:new Date});else{v=R.event_id,ye=v;let Ee=async function(re){try{const{type:C,status:N,data:T,original_msg:Ze}=ue(re,ie[f]);if(C=="heartbeat")return;if(C==="update"&&N&&!k)i({type:"status",endpoint:d,fn_index:f,time:new Date,original_msg:Ze,...N});else if(C==="complete")k=N;else if(C=="unexpected_error"||C=="broken_connection"){console.error("Unexpected error",N?.message);const Ye=C==="broken_connection";i({type:"status",stage:"error",message:N?.message||"An Unexpected Error Occurred!",queue:!0,endpoint:d,broken:Ye,session_not_found:N?.session_not_found,fn_index:f,time:new Date})}else if(C==="log"){i({type:"log",title:T.title,log:T.log,level:T.level,endpoint:d,duration:T.duration,visible:T.visible,fn_index:f});return}else(C==="generating"||C==="streaming")&&(i({type:"status",time:new Date,...N,stage:N?.stage,queue:!0,endpoint:d,fn_index:f}),T&&B.connection!=="stream"&&["sse_v2","sse_v2.1","sse_v3"].includes(D)&&Yt(te,v,T));T&&(i({type:"data",time:new Date,data:W(T.data,B,h.components,"output",M.with_null_state),endpoint:d,fn_index:f}),T.render_config&&await be(T.render_config),k&&(i({type:"status",time:new Date,...k,stage:N?.stage,queue:!0,endpoint:d,fn_index:f}),r())),(N?.stage==="complete"||N?.stage==="error")&&(se[v]&&delete se[v],v in te&&delete te[v])}catch(C){console.error("Unexpected client exception",C),i({type:"status",stage:"error",message:"An Unexpected Error Occurred!",queue:!0,endpoint:d,fn_index:f,time:new Date}),["sse_v2","sse_v2.1","sse_v3"].includes(D)&&(ge(j,Me.abort_controller),j.open=!1,r())}};v in ee&&(ee[v].forEach(re=>Ee(re)),delete ee[v]),se[v]=Ee,Fe.add(v),j.open||await this.open_stream()}})}});let Ke=!1;const oe=[],J=[],ve={[Symbol.asyncIterator]:()=>ve,next:p,throw:async m=>(l(m),p()),return:async()=>(r(),p()),cancel:He,event_id:Je};return ve}catch(i){throw console.error("Submit function encountered an error:",i),i}}function ss(t){return{then:(s,e)=>e(t)}}function ns(t,s,e,n){let o,i,r;if(typeof s=="number")o=s,i=t.unnamed_endpoints[o],r=n.dependencies.find(a=>a.id==s);else{const a=s.replace(/^\//,"");o=e[a],i=t.named_endpoints[s.trim()],r=n.dependencies.find(l=>l.id==e[a])}if(typeof o!="number")throw new Error("There is no endpoint matching that name of fn_index matching that number.");return{fn_index:o,endpoint_info:i,dependency:r}}class Z{app_reference;options;deep_link=null;config;api_prefix="";api_info;api_map={};session_hash=Math.random().toString(36).substring(2);jwt=!1;last_status={};cookies=null;stream_status={open:!1};closed=!1;pending_stream_messages={};pending_diff_streams={};event_callbacks={};unclosed_events=new Set;heartbeat_event=null;abort_controller=null;stream_instance=null;current_payload;ws_map={};get_url_config(s=null){if(!this.config)throw new Error(I);s===null&&(s=window.location.href);const e=r=>r.replace(/^\/+|\/+$/g,"");let n=e(new URL(this.config.root).pathname),o=e(new URL(s).pathname),i;return o.startsWith(n)?i=e(o.substring(n.length)):i="",this.get_page_config(i)}get_page_config(s){if(!this.config)throw new Error(I);let e=this.config;return s in e.page||(s=""),{...e,current_page:s,layout:e.page[s].layout,components:e.components.filter(n=>e.page[s].components.includes(n.id)),dependencies:this.config.dependencies.filter(n=>e.page[s].dependencies.includes(n.id))}}fetch(s,e){const n=new Headers(e?.headers||{});if(this&&this.cookies&&n.append("Cookie",this.cookies),this&&this.options.headers)for(const o in this.options.headers)n.append(o,this.options.headers[o]);return fetch(s,{...e,headers:n})}stream(s){const e=new Headers;if(this&&this.cookies&&e.append("Cookie",this.cookies),this&&this.options.headers)for(const n in this.options.headers)e.append(n,this.options.headers[n]);return this&&this.options.hf_token&&e.append("Authorization",`Bearer ${this.options.hf_token}`),this.abort_controller=new AbortController,this.stream_instance=es(s.toString(),{credentials:"include",headers:e,signal:this.abort_controller.signal}),this.stream_instance}view_api;upload_files;upload;handle_blob;post_data;submit;predict;open_stream;resolve_config;resolve_cookies;constructor(s,e={events:["data"]}){this.app_reference=s,this.deep_link=e.query_params?.deep_link||null,e.events||(e.events=["data"]),this.options=e,this.current_payload={},this.view_api=Ct.bind(this),this.upload_files=Nt.bind(this),this.handle_blob=xt.bind(this),this.post_data=qt.bind(this),this.submit=ts.bind(this),this.predict=Ut.bind(this),this.open_stream=Zt.bind(this),this.resolve_config=vt.bind(this),this.resolve_cookies=St.bind(this),this.upload=Tt.bind(this),this.fetch=this.fetch.bind(this),this.handle_space_success=this.handle_space_success.bind(this),this.stream=this.stream.bind(this)}
4async init(){this.options.auth&&await this.resolve_cookies(),await this._resolve_config().then(({config:s})=>this._resolve_heartbeat(s)),this.api_info=await this.view_api(),this.api_map=bt(this.config?.dependencies||[])}async _resolve_heartbeat(s){if(s&&(this.config=s,this.api_prefix=s.api_prefix||"",this.config&&this.config.connect_heartbeat&&this.config.space_id&&this.options.hf_token&&(this.jwt=await Re(this.config.space_id,this.options.hf_token,this.cookies))),s.space_id&&this.options.hf_token&&(this.jwt=await Re(s.space_id,this.options.hf_token)),this.config&&this.config.connect_heartbeat){const e=new URL(`${this.config.root}${this.api_prefix}/${rt}/${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 e.session_hash&&(n.session_hash=e.session_hash),await n.init(),n}async reconnect(){const s=new URL(`${this.config.root}${this.api_prefix}/${ut}`);let e;try{const n=await this.fetch(s);if(!n.ok)throw new Error;e=(await n.json()).app_id}catch{return"broken"}return e!==this.config.app_id?"changed":"connected"}close(){this.closed=!0,ge(this.stream_status,this.abort_controller)}set_current_payload(s){this.current_payload=s}static async duplicate(s,e={events:["data"]}){return Mt(s,e)}async _resolve_config(){const{http_protocol:s,host:e,space_id:n}=await Y(this.app_reference,this.options.hf_token),{status_callback:o}=this.options;n&&o&&await ze(n,o);let i;try{let r=`${s}//${e}`;if(i=await this.resolve_config(r),!i)throw new Error(I);return this.config_success(i)}catch(r){if(n&&o)H(n,me.test(n)?"space_name":"subdomain",this.handle_space_success);else throw o&&o({status:"error",message:"Could not load this space.",load_status:"error",detail:"NOT_FOUND"}),Error(r)}}async config_success(s){if(this.config=s,this.api_prefix=s.api_prefix||"",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(I);const{status_callback:e}=this.options;if(e&&e(s),s.status==="running")try{if(this.config=await this._resolve_config(),this.api_prefix=this?.config?.api_prefix||"",!this.config)throw new Error(I);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){if(!this.config)throw new Error(I);const o={},{hf_token:i}=this.options,{session_hash:r}=this;i&&(o.Authorization=`Bearer ${this.options.hf_token}`);let a,l=this.config.components.find(p=>p.id===s);l?.props?.root_url?a=l.props.root_url:a=this.config.root;let u;if("binary"in n){u=new FormData;for(const p in n.data)p!=="binary"&&u.append(p,n.data[p]);u.set("component_id",s.toString()),u.set("fn_name",e),u.set("session_hash",r)}else u=JSON.stringify({data:n,component_id:s,fn_name:e,session_hash:r}),o["Content-Type"]="application/json";i&&(o.Authorization=`Bearer ${i}`);try{const p=await this.fetch(`${a}${this.api_prefix}/${at}/`,{method:"POST",body:u,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=je(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}}async connect_ws(s){return new Promise((e,n)=>{let o;try{o=new WebSocket(s)}catch{this.ws_map[s]="failed";return}this.ws_map[s]="pending",o.onopen=()=>{this.ws_map[s]=o,e()},o.onerror=i=>{console.error("WebSocket error:",i),this.close_ws(s),this.ws_map[s]="failed",e()},o.onclose=()=>{this.ws_map[s]="closed"},o.onmessage=i=>{}})}async send_ws_message(s,e){if(!(s in this.ws_map))await this.connect_ws(s);else if(this.ws_map[s]==="pending"||this.ws_map[s]==="closed"||this.ws_map[s]==="failed")return;const n=this.ws_map[s];n instanceof WebSocket?n.send(JSON.stringify(e)):this.post_data(s,e)}async close_ws(s){if(s in this.ws_map){const e=this.ws_map[s];e instanceof WebSocket&&(e.close(),delete this.ws_map[s])}}}const is="./assets/index-deRdhtgc.css";let he;he=[];let fe,de,Be,os=new Promise(t=>{Be=t});async function rs(){const t=await Promise.all([K(()=>import("./Index-5Abk5KKk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url),K(()=>import("./index-DiLM2iIA.js"),__vite__mapDeps([13,1,2]),import.meta.url)]);fe=t[0].default,de=t[1].mount_css,Be()}function as(){const t={SvelteComponent:ae.SvelteComponent};for(const e in ae)e!=="SvelteComponent"&&(e==="SvelteComponentDev"?t[e]=t.SvelteComponent:t[e]=ae[e]);window.__gradio__svelte__internal=t;class s extends HTMLElement{control_page_title;initial_height;is_embed;container;info;autoscroll;eager;theme_mode;host;space;src;app;loading;updating;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 rs(),this.loading=!0,this.app&&this.app.$destroy(),typeof he!="string"&&he.forEach(i=>
4de(i,document.head)),await de(is,document.head);const n=new CustomEvent("domchange",{bubbles:!0,cancelable:!1,composed:!0});new MutationObserver(i=>{this.dispatchEvent(n)}).observe(this,{childList:!0}),this.app=new fe({target:this,props:{space:this.space?this.space.trim():this.space,src:this.src?this.src.trim():this.src,info:this.info!=="false",container:this.container!=="false",is_embed:this.is_embed!=="false",initial_height:this.initial_height,eager:this.eager==="true",version:"5-44-1",theme_mode:this.theme_mode,autoscroll:this.autoscroll==="true",control_page_title:this.control_page_title==="true",Client:Z,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,o,i){if(await os,(n==="host"||n==="space"||n==="src")&&i!==o){if(this.updating={name:n,value:i},this.loading)return;this.app&&this.app.$destroy(),this.space=null,this.host=null,this.src=null,n==="host"?this.host=i:n==="space"?this.space=i:n==="src"&&(this.src=i),this.app=new fe({target:this,props:{space:this.space?this.space.trim():this.space,src:this.src?this.src.trim():this.src,info:this.info!=="false",container:this.container!=="false",is_embed:this.is_embed!=="false",initial_height:this.initial_height,eager:this.eager==="true",version:"5-44-1",theme_mode:this.theme_mode,autoscroll:this.autoscroll==="true",control_page_title:this.control_page_title==="true",Client:Z,app_mode:window.__gradio_mode__==="app"}}),this.updating=!1}}}customElements.get("gradio-app")||customElements.define("gradio-app",s)}as();export{Q as F,K as _,cs as p}; 5//# sourceMappingURL=index-6iIxEka4.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.