import{R as _,r as d,j as m,B as F}from"./vendor.e6eaca24.js";import{u as x,b as f,t as b}from"./index.c6944236.js";import{d as h,i as p,f as R}from"./CodeFormatter.cc19f225.js";import{H as N}from"./CodeBox.16e9a888.js";const S="_formatCodeButton_19s96_1";var j={formatCodeButton:S};const P=_.forwardRef((t,i)=>{var c,u;const a=x("submission"),g=!((c=f.userPreference.codeFormatter)==null?void 0:c.disableByDefault),B=((u=f.userPreference.codeFormatter)==null?void 0:u.options)||h,r=p(t.language),s=t.code,e=d.exports.useRef(null),[o,n]=d.exports.useState(g&&r);if(o&&!e.current){const[C,l]=R(s,t.language,B);C?e.current=l:(b.error(a(".failed_to_format",{error:l})),n(!1))}return m(N,{className:t.className,title:t.title,language:t.language,code:o&&e.current!=null?e.current:s,ref:i,children:r&&m(F,{className:j.formatCodeButton,content:a(o?".show_original_code":".format_code"),onClick:()=>n(!o)})})});export{P as F};
