import './async-D55cHugf.js';
import { h as head, a as attr, e as ensure_array_like, b as store_get, c as spread_props, u as unsubscribe_stores, d as bind_props, f as attr_class, g as attr_style } from './index-u8mz_F03.js';
import { r as run } from './legacy-server-CxBQ4HtA.js';
import { g as getContext } from './context-CBkBucIx.js';
import { Embed as ct, AppTree as ht } from './index-CF7WUfN6.js';
import { l as ls, p as ps, g as gs } from './2-BLdXJizP.js';
import { e, s } from './dev-fallback-Bc5Ork7Y.js';
import { A } from './client-6TQ9sIPg.js';
import { a } from './index5-BoOEKc6P.js';
import { d as derived, w as writable, g as get } from './index-Cg-Pg6j3.js';
import { V, U } from './state.svelte-CyN-p1Tk.js';
import { d, k } from './utils.svelte-B2py64Fz.js';
import { o } from './BaseForm-AADCIM1D.js';
import { e as et } from './Textbox-DO7UelKj.js';
import { G } from './Block-DZmzQwnI.js';
import { q } from './Button-C_X4rUwO.js';
import { y } from './Index.svelte_svelte_type_style_lang-DXpx_9zF.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import { h as html } from './html-CfyvkLET.js';
import './index-server-CQz6EZl_.js';
import './exports-Caq1H35p.js';
import './index50-G3WrDDFf.js';
import 'path';
import 'url';
import 'fs';
import './index3-Df92vI-L.js';
import './IconButton-BRnu7KaR.js';
import './Clear-D7Yjckqz.js';
import './clone-Yk88IHKV.js';
import './BlockTitle-BnJIYf6a.js';
import './Info-DU6zbiUl.js';
import './Check-C7_ZsXgh.js';
import './Copy-B8YOhH7c.js';
import './Send-C1RPCeF6.js';
import './Square-CDuLMWYC.js';
import './IconButtonWrapper-CjFRPb3y.js';
import './Image-CuPo5pWT.js';

const vt=()=>{const s$1=s?A:getContext("__svelte__");return {page:{subscribe:s$1.page.subscribe},navigating:{subscribe:s$1.navigating.subscribe},updated:s$1.updated}},Vt={subscribe(s){return (e?Zt("page"):vt().page).subscribe(s)}};function Zt(s){try{return vt()[s]}catch{throw new Error(`Cannot subscribe to '${s}' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.For more information, see https://svelte.dev/docs/kit/state-management#avoid-shared-state-on-the-server`)}}var Wt=()=>{const s=document.createElement("link");s.href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap",s.rel="stylesheet";const t=document.createElement("link");t.href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600;700&display=swap",t.rel="stylesheet",document.head.appendChild(s),document.head.appendChild(t);},Ht=()=>{const s=document.createElement("div");return s.style.backgroundImage="linear-gradient(to top, #f9fafb, white)",s.style.border="1px solid #e5e7eb",s.style.borderRadius="0.75rem",s.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.1)",s.style.color="#374151",s.style.display="flex",s.style.flexDirection="row",s.style.alignItems="center",s.style.height="40px",s.style.justifyContent="space-between",s.style.overflow="hidden",s.style.position="fixed",s.style.right=".75rem",s.style.top=".75rem",s.style.width="auto",s.style.zIndex="20",s.style.paddingLeft="1rem",s.setAttribute("id","huggingface-space-header"),window.matchMedia("(max-width: 768px)").addEventListener("change",t=>{t.matches?s.style.display="none":s.style.display="flex";}),s},Jt=()=>{const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("xmlns:link","http://www.w3.org/1999/xlink"),s.setAttribute("aria-hidden","true"),s.setAttribute("focusable","false"),s.setAttribute("role","img"),s.setAttribute("width","1em"),s.setAttribute("height","1em"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),s.setAttribute("viewBox","0 0 12 12"),s.setAttribute("fill","currentColor");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M0.375001 10.3828L0.375 1.61719C0.375 1.104 0.816001 0.687501 1.35938 0.687501L10.6406 0.6875C10.9017 0.6875 11.1521 0.785449 11.3367 0.959797C11.5213 1.13415 11.625 1.37062 11.625 1.61719V10.3828C11.625 10.6294 11.5213 10.8659 11.3367 11.0402C11.1521 11.2145 10.9017 11.3125 10.6406 11.3125H1.35938C0.816001 11.3125 0.375001 10.896 0.375001 10.3828ZM1.35938 10.5156H10.6406C10.7183 10.5156 10.7813 10.4561 10.7813 10.3828V4.40625H1.21875V10.3828C1.21875 10.418 1.23356 10.4518 1.25994 10.4767C1.28631 10.5017 1.32208 10.5156 1.35938 10.5156ZM4.61052 6.38251L5.9999 7.69472L7.38927 6.38251C7.44083 6.33007 7.50645 6.29173 7.57913 6.27153C7.6518 6.25134 7.72898 6.25003 7.8024 6.26776C7.87583 6.28549 7.9428 6.3216 7.99628 6.37227C8.04983 6.42295 8.08785 6.48631 8.10645 6.5557C8.12528 6.62497 8.12393 6.69773 8.10263 6.76635C8.0814 6.83497 8.0409 6.8969 7.98555 6.94564L6.29802 8.53936C6.21892 8.61399 6.11169 8.65592 5.9999 8.65592C5.8881 8.65592 5.78087 8.61399 5.70177 8.53936L4.01427 6.94564C3.95874 6.89694 3.91814 6.835 3.89676 6.76633C3.87538 6.69766 3.874 6.62483 3.89277 6.55549C3.91154 6.48615 3.94977 6.42287 4.00343 6.37233C4.05708 6.32179 4.12418 6.28585 4.19765 6.2683C4.27098 6.25054 4.34803 6.25178 4.42068 6.27188C4.49334 6.29198 4.55891 6.3302 4.61052 6.38251Z"),s.appendChild(t),s},Yt=(s,t)=>{const i=document.createElement("div");return i.setAttribute("id","space-header__collapse"),i.style.display="flex",i.style.flexDirection="row",i.style.alignItems="center",i.style.justifyContent="center",i.style.fontSize="16px",i.style.paddingLeft="10px",i.style.paddingRight="10px",i.style.height="40px",i.style.cursor="pointer",i.style.color="#40546e",i.style.transitionDuration="0.1s",i.style.transitionProperty="all",i.style.transitionTimingFunction="ease-in-out",i.appendChild(Jt()),i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),t();}),i.addEventListener("mouseenter",()=>{i.style.color="#213551";}),i.addEventListener("mouseleave",()=>{i.style.color="#40546e";}),i},Kt=s=>{const t=document.createElement("p");return t.style.margin="0",t.style.padding="0",t.style.color="#9ca3af",t.style.fontSize="14px",t.style.fontFamily="Source Sans Pro, sans-serif",t.style.padding="0px 6px",t.style.borderLeft="1px solid #e5e7eb",t.style.marginLeft="4px",t.textContent=(s??0).toString(),t},Qt=()=>{const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("xmlns:link","http://www.w3.org/1999/xlink"),s.setAttribute("aria-hidden","true"),s.setAttribute("focusable","false"),s.setAttribute("role","img"),s.setAttribute("width","1em"),s.setAttribute("height","1em"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),s.setAttribute("viewBox","0 0 32 32"),s.setAttribute("fill","#6b7280");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M22.45,6a5.47,5.47,0,0,1,3.91,1.64,5.7,5.7,0,0,1,0,8L16,26.13,5.64,15.64a5.7,5.7,0,0,1,0-8,5.48,5.48,0,0,1,7.82,0L16,10.24l2.53-2.58A5.44,5.44,0,0,1,22.45,6m0-2a7.47,7.47,0,0,0-5.34,2.24L16,7.36,14.89,6.24a7.49,7.49,0,0,0-10.68,0,7.72,7.72,0,0,0,0,10.82L16,29,27.79,17.06a7.72,7.72,0,0,0,0-10.82A7.49,7.49,0,0,0,22.45,4Z"),s.appendChild(t),s},Xt=s=>{const t=document.createElement("a");return t.setAttribute("href",`https://huggingface.co/spaces/${s.id}`),t.setAttribute("rel","noopener noreferrer"),t.setAttribute("target","_blank"),t.style.border="1px solid #e5e7eb",t.style.borderRadius="6px",t.style.display="flex",t.style.flexDirection="row",t.style.alignItems="center",t.style.margin="0 0 0 12px",t.style.fontSize="14px",t.style.paddingLeft="4px",t.style.textDecoration="none",t.appendChild(Qt()),t.appendChild(Kt(s.likes)),t},$t=(s,t="user")=>{const i=t==="user"?"users":"organizations",e=document.createElement("img");return e.src=`https://huggingface.co/api/${i}/${s}/avatar`,e.style.width="0.875rem",e.style.height="0.875rem",e.style.borderRadius="50%",e.style.flex="none",e.style.marginRight="0.375rem",e},te=s=>{const[t,i]=s.split("/"),e=document.createElement("a");return e.setAttribute("href",`https://huggingface.co/spaces/${s}`),e.setAttribute("rel","noopener noreferrer"),e.setAttribute("target","_blank"),e.style.color="#1f2937",e.style.textDecoration="none",e.style.fontWeight="600",e.style.fontSize="15px",e.style.lineHeight="24px",e.style.flex="none",e.style.fontFamily="IBM Plex Mono, sans-serif",e.addEventListener("mouseover",()=>{e.style.color="#2563eb";}),e.addEventListener("mouseout",()=>{e.style.color="#1f2937";}),e.textContent=i,e},ee=()=>{const s=document.createElement("div");return s.style.marginLeft=".125rem",s.style.marginRight=".125rem",s.style.color="#d1d5db",s.textContent="/",s},se=s=>{const t=document.createElement("a");return t.setAttribute("href",`https://huggingface.co/${s}`),t.setAttribute("rel","noopener noreferrer"),t.setAttribute("target","_blank"),t.style.color="rgb(107, 114, 128)",t.style.textDecoration="none",t.style.fontWeight="400",t.style.fontSize="16px",t.style.lineHeight="24px",t.style.flex="none",t.style.fontFamily="Source Sans Pro, sans-serif",t.addEventListener("mouseover",()=>{t.style.color="#2563eb";}),t.addEventListener("mouseout",()=>{t.style.color="rgb(107, 114, 128)";}),t.textContent=s,t},ie=s=>{const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.alignItems="center",t.style.justifyContent="center",t.style.borderRight="1px solid #e5e7eb",t.style.paddingRight="12px",t.style.height="40px",s.type!=="unknown"&&t.appendChild($t(s.author,s.type)),t.appendChild(se(s.author)),t.appendChild(ee()),t.appendChild(te(s.id)),t.appendChild(Xt(s)),t},ne=s=>{const t=Ht(),i=()=>t.style.display="none";return t.appendChild(ie(s)),t.appendChild(Yt(s,i)),t},mt=async(s,t="user")=>{const i=t==="user"?"users":"organizations";try{return (await fetch(`https://huggingface.co/api/${i}/${s}/avatar`)).ok}catch{return  false}},ae=async s=>{try{return await(await fetch(`https://huggingface.co/api/spaces/${s}`)).json()}catch{return null}},oe=(s,t)=>{if(document.body===null)return console.error("document.body is null");document.body.appendChild(s);};async function re(s,t){if(window===void 0)return console.error("Please run this script in a browser environment");if(Object.values(window.location?.ancestorOrigins??{0:window.document.referrer}).some(u=>new URL(u)?.origin==="https://huggingface.co"))return;Wt();let e;if(typeof s=="string"){if(e=await ae(s),e===null)return console.error("Space not found")}else e=s;const[n,o]=await Promise.all([mt(e.author,"user"),mt(e.author,"org")]);e.type=n?"user":o?"org":"unknown";const l=ne(e);return oe(l),{element:l}}var le=(s,t)=>re(s);function ce(s,t){s.component(i=>{let{node:e,children:n,$$slots:o,$$events:l,...u}=t;i.run([async()=>await e.component,async()=>await e.runtime,()=>null,()=>{}]),i.push("<span></span>");});}function ot(s,t){s.component(i=>{let{node:e,$$slots:n,$$events:o,...l}=t;var u,p=i.run([async()=>u=await e.component]);i.async_block([p[0]],C=>{e&&u?(C.push("<!--[-->"),C.async_block([p[0]],A=>{e.props.shared_props.visible&&!e.runtime?(A.push("<!--[-->"),A.async_block([p[0]],_=>{_.push("<!---->"),u.default?.(_,{shared_props:e.props.shared_props,props:e.props.props,children:w=>{w.async_block([p[0]],y=>{e.children&&e.children.length?(y.push("<!--[-->"),y.push("<!--[-->"),y.async_block([p[0]],E=>{const c=ensure_array_like(e.children);for(let h=0,m=c.length;h<m;h++){let L=c[h];ot(E,{node:L});}}),y.push("<!--]-->")):y.push("<!--[!-->");}),w.push("<!--]-->");},$$slots:{default:true}});})):(A.push("<!--[!-->"),A.async_block([p[0]],_=>{e.props.shared_props.visible&&e.runtime?(_.push("<!--[-->"),_.async_block([p[0]],w=>{ce(w,spread_props([l,{node:e,children:y=>{y.async_block([p[0]],E=>{e.children&&e.children.length?(E.push("<!--[-->"),E.push("<!--[-->"),E.async_block([p[0]],c=>{const h=ensure_array_like(e.children);for(let m=0,L=h.length;m<L;m++){let x=h[m];ot(c,{node:x});}}),E.push("<!--]-->")):E.push("<!--[!-->");}),y.push("<!--]-->");},$$slots:{default:true}}]));})):_.push("<!--[!-->");}),A.push("<!--]-->"));}),C.push("<!--]-->")):C.push("<!--[!-->");}),i.push("<!--]-->");});}function ue(s){if(s==null)return "";const t=String(s),i=get(ls);if(t.includes(d))return k(t,i);const e=i(t);return typeof e=="string"&&e!==t?e:t}const j=derived(ls,()=>ue),de="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='576'%20height='576'%20viewBox='0%200%20576%20576'%20fill='none'%3e%3cpath%20d='M287.5%20229L86%20344.5L287.5%20460L489%20344.5L287.5%20229Z'%20stroke='url(%23paint0_linear_102_7)'%20stroke-width='59'%20stroke-linejoin='round'/%3e%3cpath%20d='M287.5%20116L86%20231.5L287.5%20347L489%20231.5L287.5%20116Z'%20stroke='url(%23paint1_linear_102_7)'%20stroke-width='59'%20stroke-linejoin='round'/%3e%3cpath%20d='M86%20344L288%20229'%20stroke='url(%23paint2_linear_102_7)'%20stroke-width='59'%20stroke-linejoin='bevel'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_102_7'%20x1='60'%20y1='341'%20x2='429.5'%20y2='344'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F9D100'/%3e%3cstop%20offset='1'%20stop-color='%23F97700'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_102_7'%20x1='513.5'%20y1='231'%20x2='143.5'%20y2='231'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F9D100'/%3e%3cstop%20offset='1'%20stop-color='%23F97700'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_102_7'%20x1='60'%20y1='344'%20x2='428.987'%20y2='341.811'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F9D100'/%3e%3cstop%20offset='1'%20stop-color='%23F97700'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",pe="data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M26.9425%202.94265C27.4632%202.42195%2027.4632%201.57773%2026.9425%201.05703C26.4218%200.536329%2025.5776%200.536329%2025.0569%201.05703L22.5713%203.54256C21.1213%202.59333%2019.5367%202.43378%2018.1753%202.64006C16.5495%202.88638%2015.1127%203.66838%2014.3905%204.39053L12.3905%206.39053C12.1405%206.64058%2012%206.97972%2012%207.33334C12%207.68697%2012.1405%208.0261%2012.3905%208.27615L19.7239%2015.6095C20.2446%2016.1302%2021.0888%2016.1302%2021.6095%2015.6095L23.6095%2013.6095C24.3316%2012.8873%2025.1136%2011.4505%2025.36%209.82475C25.5663%208.46312%2025.4066%206.87827%2024.4571%205.42807L26.9425%202.94265Z'%20fill='%233c4555'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.276%2012.9426C12.7967%2012.4219%2012.7967%2011.5777%2012.276%2011.057C11.7553%2010.5363%2010.9111%2010.5363%2010.3904%2011.057L8.66651%2012.7809L8.27615%2012.3905C8.0261%2012.1405%207.68697%2012%207.33334%2012C6.97972%2012%206.64058%2012.1405%206.39053%2012.3905L4.39053%2014.3905C3.66838%2015.1127%202.88638%2016.5495%202.64006%2018.1753C2.43377%2019.5367%202.59333%2021.1214%203.54262%2022.5714L1.05703%2025.057C0.536329%2025.5777%200.536329%2026.4219%201.05703%2026.9426C1.57773%2027.4633%202.42195%2027.4633%202.94265%2026.9426L5.42817%2024.4571C6.87835%2025.4066%208.46315%2025.5663%209.82475%2025.36C11.4505%2025.1136%2012.8873%2024.3316%2013.6095%2023.6095L15.6095%2021.6095C16.1302%2021.0888%2016.1302%2020.2446%2015.6095%2019.7239L15.2188%2019.3332L16.9426%2017.6093C17.4633%2017.0886%2017.4633%2016.2444%2016.9426%2015.7237C16.4219%2015.203%2015.5777%2015.203%2015.057%2015.7237L13.3332%2017.4475L10.5521%2014.6665L12.276%2012.9426Z'%20fill='%23FF7C00'/%3e%3c/svg%3e",_e="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3c!--%20Outer%20gear%20teeth%20(gray)%20--%3e%3cpath%20d='M19.14%2012.94c.04-.3.06-.61.06-.94%200-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24%200-.43.17-.47.41l-.36%202.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47%200-.59.22L2.74%208.87c-.12.21-.08.47.12.61l2.03%201.58c-.05.3-.07.62-.07.94s.02.64.07.94l-2.03%201.58c-.18.14-.23.41-.12.61l1.92%203.32c.12.22.37.29.59.22l2.39-.96c.5.38%201.03.7%201.62.94l.36%202.54c.05.24.24.41.48.41h3.84c.24%200%20.44-.17.47-.41l.36-2.54c.59-.24%201.13-.56%201.62-.94l2.39.96c.22.08.47%200%20.59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12%2015.6c-1.98%200-3.6-1.62-3.6-3.6s1.62-3.6%203.6-3.6%203.6%201.62%203.6%203.6-1.62%203.6-3.6%203.6z'%20fill='%23808080'/%3e%3c!--%20Inner%20circle%20(now%20gray)%20--%3e%3ccircle%20cx='12'%20cy='12'%20r='2.5'%20fill='%23808080'/%3e%3c/svg%3e",he="data:image/svg+xml,%3csvg%20viewBox='0%200%2020%2020'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='%23000000'%3e%3cg%20id='SVGRepo_bgCarrier'%20stroke-width='0'%3e%3c/g%3e%3cg%20id='SVGRepo_tracerCarrier'%20stroke-linecap='round'%20stroke-linejoin='round'%3e%3c/g%3e%3cg%20id='SVGRepo_iconCarrier'%3e%3ctitle%3erecord%20[%23982]%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3c/defs%3e%3cg%20id='Page-1'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Dribbble-Light-Preview'%20transform='translate(-380.000000,%20-3839.000000)'%20fill='%23FF0000'%3e%3cg%20id='icons'%20transform='translate(56.000000,%20160.000000)'%3e%3cpath%20d='M338,3689%20C338,3691.209%20336.209,3693%20334,3693%20C331.791,3693%20330,3691.209%20330,3689%20C330,3686.791%20331.791,3685%20334,3685%20C336.209,3685%20338,3686.791%20338,3689%20M334,3697%20C329.589,3697%20326,3693.411%20326,3689%20C326,3684.589%20329.589,3681%20334,3681%20C338.411,3681%20342,3684.589%20342,3689%20C342,3693.411%20338.411,3697%20334,3697%20M334,3679%20C328.477,3679%20324,3683.477%20324,3689%20C324,3694.523%20328.477,3699%20334,3699%20C339.523,3699%20344,3694.523%20344,3689%20C344,3683.477%20339.523,3679%20334,3679'%20id='record-[%23982]'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",fe=/^'([^]+)'$/,bt=Symbol("NOVALUE");class ge{id;inputs;outputs;cancels;pending=false;trigger_modes;event_args={};targets=[];connection_type;triggers=[];original_trigger_id=null;show_progress_on=null;component_prop_inputs=[];show_progress;functions;constructor(t){this.id=t.id,this.original_trigger_id=t.id,this.inputs=t.inputs,this.outputs=t.outputs,this.connection_type=t.connection,this.show_progress=t.show_progress,this.functions={frontend:t.js?ve(t.js,t.backend_fn,t.inputs.length,t.outputs.length):void 0,backend:t.backend_fn,backend_js:t.js_implementation?new gs(`let result = await (${t.js_implementation})(...arguments);
						return (!Array.isArray(result)) ? [result] : result;`):void 0},this.targets=t.targets,this.cancels=t.cancels,this.trigger_modes=t.trigger_mode,this.show_progress_on=t.show_progress_on||null,this.component_prop_inputs=t.component_prop_inputs||[];for(let i=0;i<t.event_specific_args?.length;i++){const e=t.event_specific_args[i];this.event_args[e]=t[e]??null;}}async run(t,i,e,n){let o=i;return this.functions.backend_js?{type:"data",data:await this.functions.backend_js(...o)}:(this.functions.frontend&&(o=await this.functions.frontend(i)),this.functions.backend?{type:"submit",data:t.submit(this.id,o,e,n,void 0,{"x-gradio-user":"app"})}:this.functions.frontend?{type:"data",data:o}:{type:"void",data:null})}add_trigger(t,i){this.triggers.push([t,i]);}get_triggers(){return {success:this.triggers.filter(([,t])=>t==="success").map(([t])=>t),failure:this.triggers.filter(([,t])=>t==="failure").map(([t])=>t),all:this.triggers.filter(([,t])=>t==="all").map(([t])=>t)}}}class me{dependencies_by_fn=new Map;dependencies_by_event=new Map;render_id_deps=new Map;submissions=new Map;client;queue=new Set;add_to_api_calls;update_state_cb;get_state_cb;rerender_cb;log_cb;on_connection_lost_cb;loading_stati=new V;connection_lost=false;constructor(t,i,e,n,o,l,u,p){this.add_to_api_calls=u,this.log_cb=l,this.update_state_cb=e,this.get_state_cb=n,this.rerender_cb=o,this.on_connection_lost_cb=p,this.client=i,this.reload(t,e,n,o,i);}reload(t,i,e,n,o){const{by_id:l,by_event:u}=this.create(t);this.dependencies_by_event=u,this.dependencies_by_fn=l,this.client=o,this.update_state_cb=i,this.get_state_cb=e,this.rerender_cb=n;for(const[p,C]of this.dependencies_by_fn)for(const[A]of C.targets)this.set_event_args(A,C.event_args);this.register_loading_stati(l);}register_loading_stati(t){for(const[i,e]of t)this.loading_stati.register(e.id,e.show_progress_on||e.outputs,e.inputs,e.show_progress);}clear_loading_status(t){this.loading_stati.clear(t);}async update_loading_stati_state(){for(const[t,i]of Object.entries(this.loading_stati.current))this.update_state_cb(Number(t),{loading_status:i},false);}dispatch_state_change_events(t){if(t.changed_state_ids)for(const i of t.changed_state_ids)this.dependencies_by_event.get("change-"+i)?.forEach(n=>{this.dispatch({type:"fn",fn_index:n.id,target_id:i,event_data:null});});}async dispatch(t){if(this.connection_lost)return;let i;if(t.type==="fn"){const e=this.dependencies_by_fn.get(t.fn_index);e&&(i=[e]);}else i=this.dependencies_by_event.get(`${t.event_name}-${t.target_id}`);for(let e=0;e<(i?.length||0);e++){const n=i?i[e]:void 0;if(n){this.cancel(n.cancels);const o=ye(n.trigger_modes,this.submissions.has(n.id));if(o==="skip")continue;if(o==="defer"){this.queue.add(n.id);continue}n.functions.backend&&(this.loading_stati.update({status:"pending",fn_index:n.id,stream_state:null}),this.update_loading_stati_state());const l=await this.gather_state(n.inputs,n.component_prop_inputs),u=await Promise.all(n.targets.map(([_])=>this.set_event_args(_,n.event_args))),{success:p,failure:C,all:A}=n.get_triggers();try{let _=null;if(t.target_id!==void 0||t.type==="event"?_=t.target_id||null:_=n.original_trigger_id,n.connection_type==="stream"&&this.submissions.has(n.id)){const y=this.submissions.get(n.id);let E={fn_index:n.id,data:l,event_data:t.event_data};y.send_chunk(E),u.forEach(c=>c());continue}this.add_to_api_calls({fn_index:n.id,data:l,event_data:t.event_data,trigger_id:_});const w=await n.run(this.client,l,t.event_data,_);if(w.type==="void")u.forEach(y=>y());else if(w.type==="data")await this.handle_data(n.outputs,w.data),u.forEach(y=>y());else {let y=null;n.connection_type==="stream"&&!this.submissions.has(n.id)&&(y="waiting"),this.submissions.set(n.id,w.data);let E=0;t:for await(const c of w.data)if(E===0&&n.inputs.forEach(h=>{this.update_state_cb(h,{loading_status:{validation_error:null}},!1);}),E+=1,c!==null){if(c.type==="data"&&await this.handle_data(n.outputs,c.data),c.type==="status"){c.original_msg==="process_starts"&&n.connection_type==="stream"&&(y="open");const{fn_index:h,...m}=c;if(c.stage==="complete"){y="closed",p.forEach(L=>{this.dispatch({type:"fn",fn_index:L,event_data:null,target_id:_});}),this.dispatch_state_change_events(c),this.loading_stati.update({...m,status:m.stage,fn_index:n.id,stream_state:y}),this.update_loading_stati_state();break t}else if(c.stage==="generating")this.dispatch_state_change_events(c),this.loading_stati.update({...m,status:m.stage,fn_index:n.id,stream_state:y}),this.update_loading_stati_state();else if(c.stage==="error"){if(c.broken||c.session_not_found){this.connection_lost||(this.connection_lost=!0,this.on_connection_lost_cb()),this.loading_stati.update({status:"complete",fn_index:n.id,stream_state:null}),this.update_loading_stati_state();break t}if(Array.isArray(c?.message)){c.message.forEach((x,O)=>{this.update_state_cb(n.inputs[O],{loading_status:{validation_error:x.is_valid?null:x.message,show_validation_error:!0}},!1);}),n.outputs.forEach(x=>{n.inputs.includes(x)||this.update_state_cb(x,{loading_status:{status:null}},!1);}),u.forEach(x=>x()),this.submissions.delete(n.id),this.queue.has(n.id)&&(this.queue.delete(n.id),this.dispatch(t));return}const L=c?.message?.replace(fe,(x,O)=>O);throw this.log_cb(c?._title??"Error",L||"",h,"error",m.duration,m.visible),new Error("Dependency function failed")}else this.loading_stati.update({...m,status:m.stage,fn_index:n.id,stream_state:y}),this.update_loading_stati_state();}if(c.type==="render"){this.loading_stati.update({status:"complete",fn_index:n.id,stream_state:null}),this.update_loading_stati_state();const{layout:h,components:m,render_id:L,dependencies:x}=c.data;this.rerender_cb(m,h);const{by_id:O,by_event:H}=this.create(x);this.register_loading_stati(O),O.forEach(M=>this.dependencies_by_fn.set(M.id,M)),H.forEach((M,U)=>this.dependencies_by_event.set(U,M));const G=this.render_id_deps.get(L);G&&G.forEach(M=>{O.has(M)||this.dependencies_by_fn.delete(M);}),this.render_id_deps.set(L,new Set(Array.from(O.keys()))),this.register_loading_stati(O);break t}c.type==="log"&&this.handle_log(c);}A.forEach(c=>{this.dispatch({type:"fn",fn_index:c,event_data:null,target_id:_});}),u.forEach(c=>c()),this.submissions.delete(n.id),this.queue.has(n.id)&&(this.queue.delete(n.id),this.dispatch(t));}}catch{this.loading_stati.update({status:"error",fn_index:n.id,eta:0,queue:false,stream_state:null}),this.update_loading_stati_state(),this.submissions.delete(n.id),C.forEach(w=>{this.dispatch({type:"fn",fn_index:w,event_data:null});});}}}}create(t){const i=new Map,e=new Map,n=[];for(const o of t){const l=new ge(o);for(const[u,p]of o.targets)e.has(`${p}-${u}`)||e.set(`${p}-${u}`,[]),e.get(`${p}-${u}`)?.push(l);if(i.set(o.id,l),o.trigger_after!==void 0){const u=o.trigger_only_on_failure?"failure":o.trigger_only_on_success?"success":"all";n.push([o.id,o.trigger_after,u]);}}for(const[o,l,u]of n){const p=i.get(l);p&&(p.add_trigger(o,u),p.original_trigger_id=we(t,l));}return {by_id:i,by_event:e}}handle_log(t){const{title:i,log:e,fn_index:n,level:o,duration:l,visible:u}=t;this.log_cb(i,e,n,o,l,u);}async handle_data(t,i){await Promise.all(t.map(async(e,n)=>{const o=i[n]===void 0?bt:i[n];if(o!==bt)if(be(o)){let l=false,u=null;for(const[p,C]of Object.entries(o))if(p!=="__type__"){if(p==="visible"){l=true,u=C;continue}await this.update_state_cb(t[n],{[p]:C},false);}l&&await this.update_state_cb(t[n],{visible:u},true);}else await this.update_state_cb(e,{value:o},false);}));}async gather_state(t,i=[]){return (await Promise.all(t.map(e=>this.get_state_cb(e)))).map((e,n)=>i.includes(n)?e??null:e?.value??null)}async set_event_args(t,i){let e={};const n=await this.get_state_cb?.(t);if(!n)return ()=>{};for(const[o]of Object.entries(i))e[o]=n?.[o]??null;return Object.keys(i).length===0?()=>{}:(await this.update_state_cb(t,i,false),()=>{this.update_state_cb(t,e,false);})}async cancel(t){if(t)for(const i of t){const e=this.submissions.get(i);if(e){await e.cancel(),this.loading_stati.update({status:"complete",fn_index:i,eta:0,queue:false,stream_state:null}),this.update_loading_stati_state(),this.submissions.delete(i);const{failure:n,all:o}=this.dependencies_by_fn.get(i)?.get_triggers()||{failure:[],all:[]};n.forEach(l=>{this.dispatch({type:"fn",fn_index:l,event_data:null,target_id:i});}),o.forEach(l=>{this.dispatch({type:"fn",fn_index:l,event_data:null,target_id:i});});}}}dispatch_load_events(){this.dependencies_by_fn.forEach(t=>{t.targets.forEach(([i,e])=>{e==="load"&&this.dispatch({type:"fn",fn_index:t.id,event_data:null,target_id:i});});});}get_fns_from_targets(t){const i=[];return this.dependencies_by_event.forEach((e,n)=>{const[,o]=n.split("-");Number(o)===t&&e.forEach(l=>{i.push(l.id);});}),i}close_stream(t){const i=this.get_fns_from_targets(t);for(const e of i){const n=this.submissions.get(e);n&&(n.close_stream(),this.submissions.delete(e)),this.loading_stati.update({status:"complete",fn_index:e,eta:0,queue:false,stream_state:"closed"});}this.update_loading_stati_state();}}function be(s){return typeof s=="object"&&s!==null&&"__type__"in s&&s?.__type__==="update"}function ye(s,t){return t?s==="always_last"?"defer":s==="multiple"?"run":s==="once"?"skip":"run":"run"}function ve(s,t,i,e){const n=t?i===1:e===1;try{return new gs("__fn_args",`  let result = await (${s})(...__fn_args);
  if (typeof result === "undefined") return [];
  return (${n} && !Array.isArray(result)) ? [result] : result;`)}catch(o){throw o}}function we(s,t){let i=new Map,e=t,n=0;for(;n<100;){const o=i.get(e)||s.find(l=>l.id===e);if(!o||(i.set(o.id,o),o.trigger_after===null||o.trigger_after===void 0))break;e=o.trigger_after,n+=1;}return e}function xe(s,t){s.component(i=>{var e;let{root:n,components:o,layout:l,dependencies:u,title:p,target:C,autoscroll:A,footer_links:_,control_page_title:w,app_mode:y,theme_mode:E,app:c,space_id:h,version:m,js:L,fill_height:x,username:O,api_prefix:H,max_file_size:G,initial_layout:M,css:U$1,vibe_mode:q,search_params:V,render_complete:z=false,ready:Q=false,reload_count:J=0,add_new_message:N=void 0}=t;o.forEach(a=>{a.props.i18n||(a.props.i18n=store_get(e??={},"$reactive_formatter",j));});let D=[],T=null;function f(a,g,R){if(g==="share"){const{title:W,description:_t}=R;}else if(g==="error")K("Error",R,-1,g,10,true);else if(g==="warning")K("Warning",R,-1,g,10,true);else if(g==="info")K("Info",R,-1,g,10,true);else if(g==="gradio_expand"||g==="gradio_tab_select"){const W=g==="gradio_expand"?a:R.component_id;S.render_previously_invisible_children(W);}else if(g=="clear_status")S.update_state(a,{loading_status:{}},false),b.clear_loading_status(a);else if(g=="close_stream")b.close_stream(a);else if(g==="custom_button_click"){const W=R.id;P(W,"click",null);}else g==="select"&&a in S.initial_tabs&&(a=R.id),b.dispatch({type:"event",event_name:g,target_id:a,event_data:R});}let S=new ht(o,l,u,{root:n,theme:E,version:m,api_prefix:H,max_file_size:G,autoscroll:A,fill_height:x},c,store_get(e??={},"$reactive_formatter",j),f);function P(a,g,R){b.dispatch({type:"event",event_name:g,target_id:a,event_data:R});}let Z=[],X=null,v=a=>{X=a,Y&&(Z=[...Z,X]);};function d(){D=D.filter(a=>a.type!=="error"),++st,D.push({title:"Connection Lost",message:xt,fn_index:-1,type:"error",id:st,duration:null,visible:true}),T=setInterval(async()=>{try{const a=await c.reconnect();(a==="connected"||a==="changed")&&(clearInterval(T),T=null,window.location.reload());}catch(a){console.debug(a);}},2e3);}let b=new me(u,c,S.update_state.bind(S),S.get_state.bind(S),S.rerender.bind(S),K,v,d),k=350,F=V.get("view")==="api"&&_.includes("api"),B=V.get("view")==="settings",Y=V.get("view")==="api-recorder"&&_.includes("api"),ct=null,$=null;function K(a,g,R,W,_t=10,ht=false){ht&&D.push({title:a,message:g,fn_index:R,type:W,id:++st,duration:_t,visible:ht});}N=K;let st=-1;store_get(e??={},"$reactive_formatter",j)("blocks.long_requests_queue"),store_get(e??={},"$reactive_formatter",j)("blocks.connection_can_break");const xt="Connection to the server was lost. Attempting reconnection...";store_get(e??={},"$reactive_formatter",j)("blocks.waiting_for_inputs");let ut=writable(false);function kt(a){D=D.filter(g=>g.id!==a);}let pt=true,nt;function Et(a){head("zxu34v",a,g=>{w?(g.push("<!--[-->"),g.title(R=>{R.push(`<title>${escape_html(p)}</title>`);})):g.push("<!--[!-->"),g.push("<!--]--> "),U$1?(g.push("<!--[-->"),g.push(`${html(`<style>${ps(U$1,m)}</style>`)}`)):g.push("<!--[!-->"),g.push("<!--]-->");}),a.push(`<div class="wrap svelte-zxu34v"${attr_style("",{"min-height":y?"100%":"auto"})}><main class="contain svelte-zxu34v"${attr_style("",{"flex-grow":y?"1":"auto","margin-right":q?`${k}px`:"0"})}>`),ot(a,{node:S.root}),a.push("<!----></main> "),_.length>0?(a.push("<!--[-->"),a.push('<footer aria-label="Gradio footer navigation" class="svelte-zxu34v">'),_.includes("api")?(a.push("<!--[-->"),a.push('<button class="show-api svelte-zxu34v">'),c.config?.mcp_server?(a.push("<!--[-->"),a.push(`${escape_html(store_get(e??={},"$reactive_formatter",j)("errors.use_via_api_or_mcp"))}`)):(a.push("<!--[!-->"),a.push(`${escape_html(store_get(e??={},"$reactive_formatter",j)("errors.use_via_api"))}`)),a.push(`<!--]--> <img${attr("src",pe)}${attr("alt",store_get(e??={},"$reactive_formatter",j)("common.logo"))} class="svelte-zxu34v"/></button>`)):a.push("<!--[!-->"),a.push("<!--]--> "),_.includes("gradio")?(a.push("<!--[-->"),a.push(`<div class="divider show-api-divider svelte-zxu34v">·</div> <a href="https://gradio.app" class="built-with svelte-zxu34v" target="_blank" rel="noreferrer">${escape_html(store_get(e??={},"$reactive_formatter",j)("common.built_with_gradio"))} <img${attr("src",de)}${attr("alt",store_get(e??={},"$reactive_formatter",j)("common.logo"))} class="svelte-zxu34v"/></a>`)):a.push("<!--[!-->"),a.push(`<!--]--> <button${attr_class("record svelte-zxu34v",void 0,{hidden:!store_get(e??={},"$is_screen_recording",ut)})}>${escape_html(store_get(e??={},"$reactive_formatter",j)("common.stop_recording"))} <img${attr("src",he)}${attr("alt",store_get(e??={},"$reactive_formatter",j)("common.stop_recording"))} class="svelte-zxu34v"/></button> <div class="divider svelte-zxu34v">·</div> `),_.includes("settings")?(a.push("<!--[-->"),a.push(`<div${attr_class("divider svelte-zxu34v",void 0,{hidden:!store_get(e??={},"$is_screen_recording",ut)})}>·</div> <button class="settings svelte-zxu34v">${escape_html(store_get(e??={},"$reactive_formatter",j)("common.settings"))} <img${attr("src",_e)}${attr("alt",store_get(e??={},"$reactive_formatter",j)("common.settings"))} class="svelte-zxu34v"/></button>`)):a.push("<!--[!-->"),a.push("<!--]--></footer>")):a.push("<!--[!-->"),a.push("<!--]--> "),a.push("<!--[!-->"),a.push("<!--]--> "),F&&S.root&&ct||a.push("<!--[!-->"),a.push("<!--]--> "),B&&c.config&&S.root&&$||a.push("<!--[!-->"),a.push("<!--]--> "),a.push("<!--[!-->"),a.push("<!--]--></div> "),D?(a.push("<!--[-->"),U(a,{messages:D,on_close:kt})):a.push("<!--[!-->"),a.push("<!--]-->");}do pt=true,nt=i.copy(),Et(nt);while(!pt);i.subsume(nt),e&&unsubscribe_stores(e),bind_props(t,{ready:Q,reload_count:J,add_new_message:N});});}function Ce(s,t){s.component(i=>{let e=t.root,n=t.auth_message,o$1=t.app_mode,l=t.space_id,u=t.i18n,p="",C="",A=false;const _=async()=>{const c=new FormData;c.append("username",p),c.append("password",C);const h=new URL("login",e.endsWith("/")?e:e+"/").href;let m=await fetch(h,{method:"POST",body:c});m.status===400?(A=true,p="",C=""):m.status==200&&location.reload();};let w=true,y$1;function E(c){c.push(`<div${attr_class("wrap svelte-14xt79u",void 0,{"min-h-screen":o$1})}>`),y(c,{variant:"panel",min_width:480,children:h=>{h.push(`<h2 class="svelte-14xt79u">${escape_html(u("login.login"))}</h2> `),n?(h.push("<!--[-->"),h.push(`<p class="auth svelte-14xt79u">${html(n)}</p>`)):h.push("<!--[!-->"),h.push("<!--]--> "),l?(h.push("<!--[-->"),h.push(`<p class="auth svelte-14xt79u">${escape_html(u("login.enable_cookies"))}</p>`)):h.push("<!--[!-->"),h.push("<!--]--> "),A?(h.push("<!--[-->"),h.push(`<p class="creds svelte-14xt79u">${escape_html(u("login.incorrect_credentials"))}</p>`)):h.push("<!--[!-->"),h.push("<!--]--> "),o(h,{children:m=>{G(m,{children:L=>{et(L,{label:u("login.username"),lines:1,show_label:true,max_lines:1,onsubmit:_,get value(){return p},set value(x){p=x,w=false;}});},$$slots:{default:true}}),m.push("<!----> "),G(m,{children:L=>{et(L,{label:u("login.password"),lines:1,show_label:true,max_lines:1,type:"password",onsubmit:_,get value(){return C},set value(x){C=x,w=false;}});},$$slots:{default:true}}),m.push("<!---->");},$$slots:{default:true}}),h.push("<!----> "),q(h,{size:"lg",variant:"primary",onclick:_,children:m=>{m.push(`<!---->${escape_html(u("login.login"))}`);}}),h.push("<!---->");},$$slots:{default:true}}),c.push("<!----></div>");}do w=true,y$1=i.copy(),E(y$1);while(!w);i.subsume(y$1),bind_props(t,{root:e,auth_message:n,app_mode:o$1,space_id:l,i18n:u});});}function He(s,t){s.component(i=>{var e;let {data:l,autoscroll:u=false,version:p="6-13-0",initial_height:C,app_mode:A=true,is_embed:_=false,theme_mode:w=null,control_page_title:y=true,container:E,space:c}=t;function h(v){let d;const k=new URL(window.location.toString()).searchParams.get("__theme");return d=w||k||"system",d==="dark"||d==="light"?L(v,d):d=m(v),d}function m(v){const d=b();window?.matchMedia("(prefers-color-scheme: dark)")?.addEventListener("change",b);function b(){let k=window?.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light";return L(v,k),k}return d}function L(v,d){const b=_?v.parentElement:document.body,k=_?v:v.parentElement;k.style.background="var(--body-background-fill)",b.classList.add("theme-loaded"),d==="dark"?b.classList.add("dark"):b.classList.remove("dark");}let x;a&&(x=h(document.body));let G="complete",M,U=false,q=false;({subscribe:writable({}).subscribe});let z=l.app;let J=false;a&&l.config&&(window.gradio_config=l.config);let N;let D;async function T(v,d){if(v&&!d&&window.self===window.top){D&&(D.remove(),D=void 0);const b=await le(v);b&&(D=b.element);}}let f=l.config,S=(()=>{if(!a)return f.root;const v=new URL(window.location.toString()),d=new URL(f.root);return new URL(d.pathname,v).toString()})();run(()=>{f?.app_id&&f.app_id;}),run(()=>{N&&J&&(N("Error","Deep link was not valid",-1,"error",10,true),J=false);}),run(()=>{q&&M.dispatchEvent(new CustomEvent("render",{bubbles:true,cancelable:false,composed:true}));}),run(()=>{z?.config&&a&&T(z?.config?.space_id,_);});let P=true,Z;function X(v){head("1gmqcbx",v,d=>{if(d.push(`<link rel="stylesheet"${attr("href",S+"/theme.css?v="+f?.theme_hash)}/> `),f?.stylesheets){d.push("<!--[-->"),d.push("<!--[-->");const b=ensure_array_like(f.stylesheets);for(let k=0,F=b.length;k<F;k++){let B=b[k];B.startsWith("http:")||B.startsWith("https:")?(d.push("<!--[-->"),d.push(`<link rel="stylesheet"${attr("href",B)}/>`)):d.push("<!--[!-->"),d.push("<!--]-->");}d.push("<!--]-->");}else d.push("<!--[!-->");d.push('<!--]--> <link rel="manifest" href="/manifest.json"/>');}),ct(v,{display:E&&_,is_embed:_,info:false,version:p,initial_height:C,space:c,pages:f.pages,current_page:f.current_page,root:f.root,components:f.components,loaded:G==="complete",fill_width:f?.fill_width||false,get wrapper(){return M},set wrapper(d){M=d,P=false;},children:d=>{f?.auth_required?(d.push("<!--[-->"),Ce(d,{auth_message:f.auth_message,root:f.root,space_id:c,app_mode:A,i18n:store_get(e??={},"$_",ls)})):(d.push("<!--[!-->"),f&&z?(d.push("<!--[-->"),xe(d,spread_props([{app:z},f,{fill_height:!_&&f.fill_height,theme_mode:x,control_page_title:y,target:M,autoscroll:u,footer_links:_?[]:f.footer_links,app_mode:A,version:p,search_params:store_get(e??={},"$page",Vt).url.searchParams,initial_layout:l.layout,get ready(){return U},set ready(b){U=b,P=false;},get render_complete(){return q},set render_complete(b){q=b,P=false;},get add_new_message(){return N},set add_new_message(b){N=b,P=false;}}]))):d.push("<!--[!-->"),d.push("<!--]-->")),d.push("<!--]-->");},$$slots:{default:true}});}do P=true,Z=i.copy(),X(Z);while(!P);i.subsume(Z),e&&unsubscribe_stores(e);});}

export { He as default };
//# sourceMappingURL=_page.svelte-BWlVXSOW.js.map
