1import{u as p,v as u,w as d,x as l,y as m,z as y}from"./index-BkylzejB.js";import{s as g}from"./clone-IGppQJ7B.js";import{$ as b}from"./i18n-eTakDDhg.js";const f="__i18n__",w=["label","info","placeholder","description","title","value"];class _ extends Error{constructor(e){super(e),this.name="ShareError"}}async function O(s,e){if(window.__gradio_space__==null)throw new _("Must be on Spaces to share.");let r,t,o;{let c;if(typeof s=="object"&&s.url)c=s.url;else if(typeof s=="string")c=s;else throw new Error("Invalid data format for URL type");const h=await fetch(c);r=await h.blob(),t=h.headers.get("content-type")||"",o=h.headers.get("content-disposition")||""}const i=new File([r],o,{type:t}),n=await fetch("https://huggingface.co/uploads",{method:"POST",body:i,headers:{"Content-Type":i.type,"X-Requested-With":"XMLHttpRequest"}});if(!n.ok){if(n.headers.get("content-type")?.includes("application/json")){const c=await n.json();throw new _(`Upload failed: ${c.error}`)}throw new _("Upload failed.")}return await n.text()}function R(s){s.addEventListener("click",e);async function e(r){const t=r.composedPath(),[o]=t.filter(i=>i?.tagName==="BUTTON"&&i.classList.contains("copy_code_button"));if(o){let i=function(h){h.style.opacity="1",setTimeout(()=>{h.style.opacity="0"},2e3)};r.stopImmediatePropagation();const n=o.parentElement.innerText.trim(),a=Array.from(o.children)[1];await k(n)&&i(a)}}return{destroy(){s.removeEventListener("click",e)}}}async function k(s){let e=!1;if("clipboard"in navigator)await navigator.clipboard.writeText(s),e=!0;else{const r=document.createElement("textarea");r.value=s,r.style.position="absolute",r.style.left="-999999px",document.body.prepend(r),r.select();try{document.execCommand("copy"),e=!0}catch(t){console.error(t),e=!1}finally{r.remove()}}return e}const S=s=>{const e=Math.floor(s/3600),r=Math.floor(s%3600/60),t=Math.round(s)%60,o=`${r<10?"0":""}${r}`,i=`${t<10?"0":""}${t}`;return e>0?`${e}:${o}:${i}`:`${r}:${i}`},x=["elem_id","elem_classes","visible","interactive","server_fns","server","id","target","theme_mode","version","root","autoscroll","max_file_size","formatter","client","load_component","scale","min_width","theme","padding","loading_status","label","show_label","validation_error","show_progress","api_prefix","container","attached_events","register_component","dispatcher"];function $(s){return typeof s=="string"&&s.includes(f)}function j(s,e){const r=s.indexOf(f);if(r===-1)return s;const t=r+f.length,o=s.indexOf("}",t)+1;if(o===0)return s;try{const i=JSON.parse(s.slice(t,o));if(i?.key){const n=e(i.key),a=n!==i.key?n:i.key;return s.slice(0,r)+a+s.slice(o)}}catch{}return s}class L{load_component;#t=p(u({}));get shared(){return d(this.#t)}set shared(e){l(this.#t,e,!0)}#e=p(u({}));get props(){return d(this.#e)}set props(e){l(this.#e,e,!0)}#s=p(e=>e);get i18n(){return d(this.#s)}set i18n(e){l(this.#s,e,!0)}translatable_props={};dispatcher;last_update=null;shared_props=x;mounted=!1;old_value;register_component;constructor(e,r){for(const t in e.shared_props)this.shared[t]=e.shared_props[t];for(const t in e.props)this.props[t]=e.props[t];if(r)for(const t in r)this.props[t]===void 0&&(this.props[t]=r[t]);this.i18n=this.props.i18n??(t=>t);for(const t of w)this.shared[t]=this._translate_and_store("shared",t,e.shared_props[t]),this.props[t]=this._translate_and_store("props",t,e.props[t]);this.load_component=this.shared.load_component,this.register_component=this.shared.register_component||(()=>{}),this.dispatcher=this.shared.dispatcher||(()=>{}),this.register_component(e.shared_props.id,this.set_data.bind(this),this.get_data.bind(this)),m(()=>{for(const t in e.shared_props)this._is_i18n_managed(`shared.${t}`,e.shared_props[t])||(this.shared[t]=e.shared_props[t]);for(const t in e.props)this._is_i18n_managed(`props.${t}`,e.props[t])||(this.props[t]=e.props[t]);this.register_component(e.shared_props.id,this.set_data.bind(this),this.get_data.bind(this)),y(()=>{this.shared.id=e.shared_props.id})}),Object.keys(this.translatable_props).length>0&&b.subscribe(()=>{for(const[t,o]of Object.entries(this.translatable_props)){const[i,n]=t.split("."),a=this.i18n(o);i==="shared"?this.shared[n]=a:this.props[n]=a}})}_is_i18n_managed(e,r){const t=this.translatable_props[e];return t?r===t?!0:(delete this.translatable_props[e],!1):!1}_translate_and_store(e,r,t){if(typeof t!="string")return t;const o=this.i18n(t);return o!==t&&(this.translatable_props[`${e}.${r}`]=t),o}
1dispatch(e,r){this.dispatcher(this.shared.id,e,r)}async get_data(){return g(this.props)}update(e){this.set_data(e)}set_data(e){for(const r in e){const t=e[r],o=$(t)?this._translate_and_store(this.shared_props.includes(r)?"shared":"props",r,t):t;if(this.shared_props.includes(r)){const i=r;this.shared[i]=o;continue}this.props[r]=o}}watch_for_change(){m(()=>{this.mounted||(this.old_value=this.props.value,this.mounted=!0),this.old_value!=this.props.value&&(this.old_value=this.props.value,this.dispatch("change"))})}}const A=s=>typeof s=="number"?s+"px":s;function H(s){if(!s)return!1;const e=s.scrollHeight>s.clientHeight,r=s.scrollTop>=s.scrollHeight-s.clientHeight-1;return e&&!r}export{L as G,f as I,_ as S,R as a,x as b,A as c,S as f,H as s,j as t,O as u};
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.