import { f as fallback } from './async-D55cHugf.js';
import { b as store_get, f as attr_class, g as attr_style, s as slot, a as attr, i as stringify, u as unsubscribe_stores, d as bind_props, e as ensure_array_like } from './index-u8mz_F03.js';
import { t as tick } from './index-server-CQz6EZl_.js';
import { h as hs, l as ls, m as ms, d as ds, _ as _s } from './2-BLdXJizP.js';
export { E as changeLocale, x as get_initial_locale, y as is_translation_metadata, w as language_choices, a as load_translations, f as mount_css, p as prefix_css, r as process_langs, v as setupi18n } from './2-BLdXJizP.js';
import { u } from './utils.svelte-B2py64Fz.js';
export { d as i18n_marker } from './utils.svelte-B2py64Fz.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './clone-Yk88IHKV.js';

const $="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='10'%20fill='none'%3e%3cpath%20fill='%23FF3270'%20d='M1.93%206.03v2.04h2.04V6.03H1.93Z'/%3e%3cpath%20fill='%23861FFF'%20d='M6.03%206.03v2.04h2.04V6.03H6.03Z'/%3e%3cpath%20fill='%23097EFF'%20d='M1.93%201.93v2.04h2.04V1.93H1.93Z'/%3e%3cpath%20fill='%23000'%20fill-rule='evenodd'%20d='M.5%201.4c0-.5.4-.9.9-.9h3.1a.9.9%200%200%201%20.87.67A2.44%202.44%200%200%201%209.5%202.95c0%20.65-.25%201.24-.67%201.68.39.1.67.46.67.88v3.08c0%20.5-.4.91-.9.91H1.4a.9.9%200%200%201-.9-.9V1.4Zm1.43.53v2.04h2.04V1.93H1.93Zm0%206.14V6.03h2.04v2.04H1.93Zm4.1%200V6.03h2.04v2.04H6.03Zm0-5.12a1.02%201.02%200%201%201%202.04%200%201.02%201.02%200%200%201-2.04%200Z'%20clip-rule='evenodd'/%3e%3cpath%20fill='%23FFD702'%20d='M7.05%201.93a1.02%201.02%200%201%200%200%202.04%201.02%201.02%200%200%200%200-2.04Z'/%3e%3c/svg%3e";function ct(e,t){e.component(i=>{var s;let r,n,p=t.wrapper,a=t.version,l=t.initial_height,h=t.fill_width,c=t.is_embed,g=t.space,b=t.display,A=t.info,j=t.loaded,F=fallback(t.pages,()=>[],true),L=fallback(t.current_page,""),I=t.root,P=fallback(t.components,()=>[],true),M=P.find(f=>f.type==="navbar"),u=M?{visible:M.props.visible,main_page_name:M.props.main_page_name,value:M.props.value}:null;u&&hs.set(u);function U(f){let d=f.split("?")[0].split("#")[0];return d=d.replace(/^\/+|\/+$/g,""),d}function Q(f,d){return f.startsWith("http://")||f.startsWith("https://")?false:U(f)===U(d)}if(store_get(s??={},"$navbar_config",hs)&&(u={visible:store_get(s??={},"$navbar_config",hs).visible??true,main_page_name:store_get(s??={},"$navbar_config",hs).main_page_name??"Home",value:store_get(s??={},"$navbar_config",hs).value??null}),r=F.length>1&&(u===null||u.visible!==false),n=(()=>{let f=F.filter(([v,_,m],y)=>y===0&&v===""?u?.main_page_name!==false:m!==false),d=u&&u.main_page_name!==false&&u.main_page_name!=="Home"?f.map(([v,_,m],y)=>y===0&&v===""&&_==="Home"?[v,u.main_page_name]:[v,_]):f.map(([v,_])=>[v,_]);if(u?.value&&u.value.length>0){const v=new Set(d.map(([m])=>m)),_=u.value.map(([m,y])=>[y,m]).filter(([m])=>!v.has(m));return [...d,..._]}return d})(),i.push(`<div${attr_class(`gradio-container gradio-container-${stringify(a)}`,"svelte-99kmwu",{fill_width:h,"embed-container":b,"with-info":A})} data-iframe-height=""${attr_style("",{"min-height":j?"initial":l,"flex-grow":b?"auto":"1"})}>`),r){i.push("<!--[-->"),i.push(`<div class="nav-holder svelte-99kmwu"><nav${attr_class("fillable svelte-99kmwu",void 0,{fill_width:h})}><!--[-->`);const f=ensure_array_like(n);for(let d=0,v=f.length;d<v;d++){let[_,m]=f[d];i.push(`<a${attr("href",_.startsWith("http://")||_.startsWith("https://")?_:`${I}/${_}`)} data-sveltekit-reload=""${attr("target",_.startsWith("http://")||_.startsWith("https://")?"_blank":"_self")}${attr("rel",_.startsWith("http://")||_.startsWith("https://")?"noopener noreferrer":"")}${attr_class("svelte-99kmwu",void 0,{active:Q(_,L)})}>${escape_html(m)}</a>`);}i.push("<!--]--></nav></div>");}else i.push("<!--[!-->");i.push(`<!--]--> <div${attr_class("main fillable svelte-99kmwu",void 0,{fill_width:h,app:!b&&!c})}><!--[-->`),slot(i,t,"default",{}),i.push("<!--]--> <div>"),b&&g&&A?(i.push("<!--[-->"),i.push(`<div class="info svelte-99kmwu"><span class="svelte-99kmwu"><a${attr("href",`https://huggingface.co/spaces/${stringify(g)}`)} class="title svelte-99kmwu">${escape_html(g)}</a></span> <span class="svelte-99kmwu">${escape_html(store_get(s??={},"$_",ls)("common.built_with"))} <a class="gradio svelte-99kmwu" href="https://gradio.app">Gradio</a>.</span> <span class="svelte-99kmwu">${escape_html(store_get(s??={},"$_",ls)("common.hosted_on"))} <a class="hf svelte-99kmwu" href="https://huggingface.co/spaces"><span class="space-logo svelte-99kmwu"><img${attr("src",$)} alt="Hugging Face Space" class="svelte-99kmwu"/></span> Spaces</a></span></div>`)):i.push("<!--[!-->"),i.push("<!--]--></div></div></div>"),s&&unsubscribe_stores(s),bind_props(t,{wrapper:p,version:a,initial_height:l,fill_width:h,is_embed:c,space:g,display:b,info:A,loaded:j,pages:F,current_page:L,root:I,components:P});});}var R=Object.prototype.hasOwnProperty;function B(e,t,i){for(i of e.keys())if(E(i,t))return i}function E(e,t){var i,s,r;if(e===t)return  true;if(e&&t&&(i=e.constructor)===t.constructor){if(i===Date)return e.getTime()===t.getTime();if(i===RegExp)return e.toString()===t.toString();if(i===Array){if((s=e.length)===t.length)for(;s--&&E(e[s],t[s]););return s===-1}if(i===Set){if(e.size!==t.size)return  false;for(s of e)if(r=s,r&&typeof r=="object"&&(r=B(t,r),!r)||!t.has(r))return  false;return  true}if(i===Map){if(e.size!==t.size)return  false;for(s of e)if(r=s[0],r&&typeof r=="object"&&(r=B(t,r),!r)||!E(s[1],t.get(r)))return  false;return  true}if(i===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(i===DataView){if((s=e.byteLength)===t.byteLength)for(;s--&&e.getInt8(s)===t.getInt8(s););return s===-1}if(ArrayBuffer.isView(e)){if((s=e.byteLength)===t.byteLength)for(;s--&&e[s]===t[s];);return s===-1}if(!i||typeof e=="object"){s=0;for(i in e)if(R.call(e,i)&&++s&&!R.call(t,i)||!(i in t)||!E(e[i],t[i]))return  false;return Object.keys(t).length===s}}return e!==e&&t!==t}const tt={walkthrough:"tabs",walkthroughstep:"tabitem"};function O(e){const t=new URL(e.root),i=t.pathname.endsWith("/")?t.pathname:t.pathname+"/",s=e.api_prefix.startsWith("/")?e.api_prefix:"/"+e.api_prefix;return new URL(i.slice(0,-1)+s,t.origin).toString()}class ht{#p;#i;#s;reactive_formatter=t=>t;#t;client;root;root_untracked;#l=new Set;#o=new Set;#_=[];#c=new Map;#e=new Map;#r=new Map;#a;component_ids;initial_tabs={};components_to_register=new Set;ready;ready_resolve;resolved=false;#n=new Set;constructor(t,i,s,r,n,p,a){this.ready=new Promise(c=>{this.ready_resolve=c;}),this.reactive_formatter=p;const l=O(r);this.#t={...r,api_url:l},this.#p=t,this.#i=i,this.#s=s,this.#a=a,this.root=this.create_node({id:i.id,children:[]},new Map,true);for(const c of t)c.props.visible!=false&&this.components_to_register.add(c.id);this.client=n,this.prepare();const h=t.reduce((c,g)=>(c.set(g.id,g),c),new Map);this.root.children=this.#i.children.map(c=>this.traverse(c,g=>this.create_node(g,h,false,this.reactive_formatter))),this.component_ids=t.map(c=>c.id),this.initial_tabs={},W(this.root,this.initial_tabs),this.postprocess(this.root),this.root_untracked=this.root;}reload(t,i,s,r){this.#i=i,this.#p=t;const n=O(r);this.#t={...r,api_url:n},this.#s=s,this.root=this.create_node({id:i.id,children:[]},new Map,true);for(const a of t)a.props.visible!=false&&this.components_to_register.add(a.id);this.prepare();const p=t.reduce((a,l)=>(a.set(l.id,l),a),new Map);this.root.children=this.#i.children.map(a=>this.traverse(a,l=>this.create_node(l,p,false,this.reactive_formatter))),this.component_ids=t.map(a=>a.id),this.initial_tabs={},W(this.root,this.initial_tabs),this.postprocess(this.root);}register_component(t,i,s){this.#e.set(t,i),this.#c.set(t,s),this.components_to_register.delete(t);const r=this.#r.get(t);r&&(this.#r.delete(t),tick().then(()=>{const n=this.#e.get(t);n&&n(r);})),this.components_to_register.size===0&&!this.resolved&&(this.resolved=true,this.ready_resolve());}prepare(){const[t,i]=ms(this.#s);this.#l=t,this.#o=i;}process(){}postprocess(t){this.root=this.traverse(t,[i=>Z(i,this.#t.api_url),i=>rt(i,this.components_to_register),i=>T(i,this.initial_tabs),i=>this.find_attached_events(i,this.#s),i=>nt(i,this.components_to_register,this.#n)]);}find_attached_events(t,i){const s=i.filter(r=>r.targets.find(([n])=>n===t.id)).map(r=>{const n=r.targets.find(([p])=>p===t.id);return n?n[1]:null}).filter(Boolean);return t.props.shared_props.attached_events=s,t}traverse(t,i){function s(r,n,p){const a=n(r);return "children"in r&&r.children.length>0&&(a.children=r.children?.map(l=>p(l,n))||[]),a}if(Array.isArray(i)){let r=t;for(const n of i)r=s(r,n,this.traverse.bind(this));return r}else return s(t,i,this.traverse.bind(this))}create_node(t,i,s=false,r){let n;if(s?n={type:"column",id:t.id,props:{visible:true,root:"",theme_mode:"light",scale:this.#t.fill_height?1:null},component_class_id:"column",key:null}:n=i.get(t.id),!n)throw new Error(`Component with ID ${t.id} not found`);r&&(n.props.i18n=r);const p=it(t.id,n.props,[this.#l,this.#o],this.client,this.#t.api_url,{...this.#t,register_component:this.register_component.bind(this),dispatcher:this.#a.bind(this)}),a=tt[n.type]||n.type,l=p.shared_props.visible!==false?ds(n.type,n.component_class_id,this.#t.api_url||""):null;return {id:t.id,type:a,props:p,children:[],show_progress_on:null,component_class_id:n.component_class_id||n.type,component:p.shared_props.visible!==false&&l?.component||null,runtime:l?.runtime||false,key:n.key,rendered_in:n.rendered_in,documentation:n.documentation,original_visibility:p.shared_props.visible}}rerender(t,i){const s=t.reduce((a,l)=>(a.set(l.id,l),a),new Map),r=this.traverse(i,a=>this.create_node(a,s,false,this.reactive_formatter));W(r,this.initial_tabs);const n=this.traverse(r,a=>T(a,this.initial_tabs)),p=k(this.root,n.id);if(!p)throw new Error("Rerender failed: root node not found in current tree");p.children=n.children;}async update_state(t,i,s=true){const r=k(this.root,t);let n=false;s&&!r?.component&&(await tick(),this.root=this.traverse(this.root,[a=>st(a,t,i.visible),a=>Z(a,this.#t.api_url)]),await tick(),n=true);const p=this.#e.get(t);if(p)p&&p(i);else {const a=r?.props.props.value,l=J(i);for(const c in l.shared_props)r.props.shared_props[c]=l.shared_props[c];for(const c in l.props)r.props.props[c]=l.props[c];const h=this.#r.get(t)||{};this.#r.set(t,{...h,...i}),"value"in i&&!E(a,i.value)&&this.#a(t,"change",null),r?.type==="tabitem"&&this.#h(t,r);}!s||n||(await tick(),await this.update_visibility(r,i));}async update_visibility(t,i){t.children.forEach(s=>{const r=this.#e.get(s.id);r&&r(i),this.update_visibility(s,i);});}#h(t,i){const s=N(this.root,t);if(!s||s.type!=="tabs")return;const r=s.props.props.initial_tabs;if(!r)return;const n=r.findIndex(c=>c.component_id===i.id);if(n===-1)return;const p=i.props.props.i18n,a=i.props.shared_props.label,l="original_visibility"in i?i.original_visibility:i.props.shared_props.visible;r[n]={label:p?p(a):a,id:i.props.props.id,elem_id:i.props.shared_props.elem_id,visible:l,interactive:i.props.shared_props.interactive,scale:i.props.shared_props.scale||null,component_id:i.id},s.props.props.initial_tabs=[...r];const h=this.#e.get(s.id);h&&h({initial_tabs:s.props.props.initial_tabs});}async get_state(t){const i=this.#c.get(t),s=k(this.root,t);return !i&&!s?null:i?await i():s?Promise.resolve({value:s.props.props.value}):null}async render_previously_invisible_children(t){const i=k(this.root,t);i&&(!this.#n.has(i.id)&&!C(i,this.#n)||(V(i,this.#n,true),G(i,this.#t.api_url)));}}function V(e,t,i=false){if(e.props.shared_props.visible=t.has(e.id)?true:e.props.shared_props.visible,e.type==="tabs"){const s=e.props.props.selected??e.props.props.initial_tabs?.[0]?.id;e.children.forEach(r=>{r.type==="tabitem"&&(r.props.props.id===s||r.id===s)&&V(r,t,false);});}else e.type==="accordion"&&e.props.props.open===false&&!i||e.children.forEach(s=>{V(s,t,false);});}function C(e,t){for(const i of e.children)if(t.has(i.id)||C(i,t))return  true;return  false}function G(e,t){e.props.shared_props.visible&&!e.component&&(e.component=ds(e.type,e.component_class_id,t)),e.children.forEach(i=>G(i,t));}function et(e,t,i){return t?t.reduce((s,r)=>(s[r]=async(...n)=>(n.length===1&&(n=n[0]),await i.component_server(e,r,n)),s),{}):{}}function J(e){const t={},i={};for(const s in e)if(s==="id"||s==="autoscroll")i[s]=e[s];else if(u.includes(s)){const r=s;t[r]=e[s];}else i[s]=e[s];return {shared_props:t,props:i}}function it(e,t,i,s,r,n={}){const{shared_props:p,props:a}=J(t);p.server=et(e,t.server_fns,s);for(const l in n)if(u.includes(l)){const h=l;p[h]=n[l];}else a[l]=n[l];return p.client=s,p.id=e,p.interactive=_s(e,p.interactive,a.value,i),p.load_component=(l,h,c)=>ds(l,c||"",r,h),p.visible=p.visible===void 0?true:p.visible,p.loading_status={},{shared_props:p,props:a}}function Z(e,t){if(e.props.shared_props.visible&&!e.component){const i=ds(e.type,e.component_class_id,t),s={...e,component:i.component,children:[]};return e.children&&(s.children=e.children.map(r=>Z(r,t))),s}else return e}function st(e,t,i){return e.id==t&&(e.props.shared_props.visible=i),e}function H(e,t){t.delete(e.id),e.children&&e.children.forEach(i=>H(i,t));}function rt(e,t){return e.props.shared_props.visible!==true&&H(e,t),e}function z(e,t){return e.props.shared_props.visible===true&&(t.add(e.id),e.props.shared_props.visible=false),e.children.forEach(i=>{z(i,t);}),e}function nt(e,t,i){return e.type==="accordion"&&e.props.props.open===false&&(H(e,t),e.children&&e.children.forEach(s=>{z(s,i);})),e.type==="tabs"&&e.children.forEach(s=>{s.type==="tabitem"&&s.props.props.id!==(e.props.props.selected||e.props.props.initial_tabs[0].id)&&(H(s,t),z(s,i));}),e}function T(e,t){if(e.type==="tabs"&&e.id in t){const i=t[e.id].sort((s,r)=>s.order-r.order);e.props.props.initial_tabs=i;}else e.type==="tabitem"&&(e.props.props.component_id=e.id);return e}function K(e,t,i,s){if(i!==null&&e.type==="tabitem"){i in t||(t[i]=[]),"id"in e.props.props||(e.props.props.id=e.id);const r=e.props.props.i18n,n=e.props.shared_props.label;t[i].push({label:r?r(n):n,id:e.props.props.id,elem_id:e.props.shared_props.elem_id,visible:e.props.shared_props.visible,interactive:e.props.shared_props.interactive,scale:e.props.shared_props.scale||null,component_id:e.id}),e.props.props.order=s;}e.children&&e.children.forEach((r,n)=>{K(r,t,e.type==="tabs"?e.id:null,e.type==="tabs"?n:null);});}function W(e,t){function i(s){"children"in s&&s.children.length>0&&s.children?.forEach(r=>K(r,t,s.type==="tabs"?s.id:null,null));}return i(e)}function k(e,t){if(e.id===t)return e;if(e.children)for(const i of e.children){const s=k(i,t);if(s)return s}return null}function N(e,t){if(e.children)for(const i of e.children){if(i.id===t)return e;const s=N(i,t);if(s)return s}return null}

export { ht as AppTree, ct as Embed };
//# sourceMappingURL=index-CF7WUfN6.js.map
