import{p as j,i as b,g as O,r as X}from"./i18n-Dnhn5Rxr.js";import{R as w,ae as P,w as r,T as k,a5 as p,x as f,u as y,S as $,a as D,X as v,W as I,v as q,y as A}from"./index-DWyDLubb.js";import{G as F}from"./utils.svelte-CCyS_0CY.js";import{S as H}from"./index-CglBvmLb.js";import"./StreamingBar.svelte_svelte_type_style_lang-Y9omZ2gK.js";import{C as J}from"./Code-BLWhl1y6.js";import{C as W}from"./Check-DUAHzS2-.js";import{C as K}from"./Copy-ChCbTvli.js";import{I as E}from"./ScrollFade.svelte_svelte_type_style_lang-DPHOQHBm.js";import{D as M}from"./Download-Di2PsS6O.js";import{D as N}from"./DownloadLink-TGTaev7f.js";import{I as Q}from"./IconButtonWrapper-D0s9l4wW.js";import{B as V}from"./Block-J4oodUWp.js";import{B as Y}from"./BlockLabel-CZd21Hkw.js";import{E as Z}from"./Empty-BIB2W5at.js";import{C as L}from"./Code-Bg0YpSHl.js";import{default as Le}from"./Example-C7q4tFc2.js";import"./clone-BkeCM4Nl.js";import"./Clear-BF6j078A.js";import"./html-Ih_5QVTo.js";import"./index-B_pwUImq.js";import"./snippet-BWgYNF9D.js";/* empty css                                              */function ee(c,t){w(t,!0);let a=y(!1),e;function n(){f(a,!0),e&&clearTimeout(e),e=setTimeout(()=>{f(a,!1)},2e3)}async function o(){"clipboard"in navigator&&(await navigator.clipboard.writeText(t.value),n())}P(()=>{e&&clearTimeout(e)});{let i=p(()=>r(a)?W:K);E(c,{get Icon(){return r(i)},label:"Copy",onclick:o})}k()}function te(c,t){w(t,!0);let a=p(()=>e(t.language));function e(m){return{py:"py",python:"py",md:"md",markdown:"md",json:"json",html:"html",css:"css",js:"js",javascript:"js",ts:"ts",typescript:"ts",yaml:"yaml",yml:"yml",dockerfile:"dockerfile",sh:"sh",shell:"sh",r:"r",c:"c",cpp:"cpp",latex:"tex"}[m]||"txt"}let n=y(!1),o;function i(){f(n,!0),o&&clearTimeout(o),o=setTimeout(()=>{f(n,!1)},2e3)}let d=p(()=>URL.createObjectURL(new Blob([t.value])));P(()=>{o&&clearTimeout(o)}),N(c,{get download(){return`file.${r(a)??""}`},get href(){return r(d)},onclick:i,children:(m,_)=>{{let g=p(()=>r(n)?W:M);E(m,{get Icon(){return r(g)},label:"Download"})}},$$slots:{default:!0}}),k()}var re=I("<!> <!>",1);function ae(c,t){w(t,!0);let a=j(t,"buttons",3,null),e=j(t,"on_custom_button_click",3,null);Q(c,{get buttons(){return a()},get on_custom_button_click(){return e()},children:(n,o)=>{var i=re(),d=$(i);{var m=s=>{te(s,{get value(){return t.value},get language(){return t.language}})};b(d,s=>{a()?.some(u=>typeof u=="string"&&u==="download")&&s(m)})}var _=v(d,2);{var g=s=>{ee(s,{get value(){return t.value}})};b(_,s=>{a()?.some(u=>typeof u=="string"&&u==="copy")&&s(g)})}D(n,i)},$$slots:{default:!0}}),k()}var oe=I("<!> <!>",1),se=I("<!> <!> <!>",1);function Ie(c,t){w(t,!0);const a=X(t,["$$slots","$$events","$$legacy"]),e=new F(a);let n=e.shared.theme==="dark",o=p(()=>e.shared.label||e.i18n("code.code")),i=y(q(e.props.value)),d=y(!0);A(()=>{if(r(d)){f(d,!1);return}r(i)!=e.props.value&&(f(i,e.props.value,!0),e.dispatch("change"))});{let m=p(()=>e.props.max_lines&&"fit-content");V(c,{get height(){return r(m)},variant:"solid",padding:!1,get elem_id(){return e.shared.elem_id},get elem_classes(){return e.shared.elem_classes},get visible(){return e.shared.visible},get scale(){return e.shared.scale},get min_width(){return e.shared.min_width},children:(_,g)=>{var s=se(),u=$(s);H(u,O({get autoscroll(){return e.shared.autoscroll},get i18n(){return e.i18n}},()=>e.shared.loading_status,{on_clear_status:()=>e.dispatch("clear_status",e.shared.loading_status)}));var T=v(u,2);{var R=l=>{Y(l,{get Icon(){return L},get show_label(){return e.shared.show_label},get label(){return r(o)},float:!1})};b(T,l=>{e.shared.show_label&&l(R)})}var S=v(T,2);{var G=l=>{Z(l,{unpadded_box:!0,size:"large",children:(h,x)=>{L(h)},$$slots:{default:!0}})},U=l=>{var h=oe(),x=$(h);{let B=p(()=>e.props.buttons??["copy","download"]);ae(x,{get language(){return e.props.language},get value(){return e.props.value},get buttons(){return r(B)},on_custom_button_click:C=>{e.dispatch("custom_button_click",{id:C})}})}var z=v(x,2);{let B=p(()=>!e.shared.interactive);J(z,{get language(){return e.props.language},get lines(){return e.props.lines},get max_lines(){return e.props.max_lines},get dark_mode(){return n},get wrap_lines(){return e.props.wrap_lines},get show_line_numbers(){return e.props.show_line_numbers},get autocomplete(){return e.props.autocomplete},get readonly(){return r(B)},onblur:()=>e.dispatch("blur"),onfocus:()=>e.dispatch("focus"),oninput:()=>e.dispatch("input"),get value(){return e.props.value},set value(C){e.props.value=C}})}D(l,h)};b(S,l=>{!e.props.value&&!e.shared.interactive?l(G):l(U,!1)})}D(_,s)},$$slots:{default:!0}})}k()}export{J as BaseCode,ee as BaseCopy,te as BaseDownload,Le as BaseExample,ae as BaseWidget,Ie as default};
