const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.api-Dv1ZVczm.js","assets/editor.api2-BM_YT0wu.js","assets/chunk-DECur_0Z.js","assets/editor-DV6jjE6F.css","assets/editor-DKgfVINf.css","assets/go.contribution-BmlX-a-9.js","assets/preload-helper-DoS0eHac.js","assets/_.contribution-CaUqztrQ.js","assets/toggleHighContrast-CYWWoXog.js","assets/toggleHighContrast-BBlRgZ6L.css","assets/handlebars-d5Fb_oR7.js","assets/html.contribution-Baf-XjFx.js","assets/monaco.contribution-BNCqMH44.js","assets/markdown.contribution-FtzundBn.js","assets/yaml.contribution-BN-iiJx2.js","assets/es-fZtL7B9U.js","assets/clsx-D9aGYY3V.js","assets/react-CO2uhaBc.js","assets/es-Ddhai3Z6.css"])))=>i.map(i=>d[i]); import{r as e}from"./chunk-DECur_0Z.js";import{t}from"./react-CO2uhaBc.js";import{An as n,Dn as r,En as i,Mn as a,Nn as o,On as s,Tn as c,Zp as l,jn as u,kn as d,wn as f}from"./messages-BLwDcEAr.js";import{i as p,t as m}from"./button-C0SPdqvs.js";import{n as h,r as g,t as _}from"./tabs-CHANRHQO.js";import{t as v}from"./preload-helper-DoS0eHac.js";import{t as y}from"./createLucideIcon-Br0Bd5k2.js";import{c as b,i as x,o as S,r as C,s as w,t as T}from"./dialog-iqE0q8bN.js";var E=y(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),D=y(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),O=y(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),k=y(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),A=e(t(),1),j={base:`vs`,inherit:!0,rules:[{token:``,foreground:`383a42`},{token:`attribute.name`,foreground:`986801`},{token:`attribute.name.html`,foreground:`986801`},{token:`attribute.value`,foreground:`50a14f`},{token:`attribute.value.html`,foreground:`50a14f`},{token:`comment`,foreground:`a0a1a7`,fontStyle:`italic`},{token:`comment.content`,foreground:`a0a1a7`,fontStyle:`italic`},{token:`comment.content.handlebars`,foreground:`a0a1a7`,fontStyle:`italic`},{token:`comment.content.html`,foreground:`a0a1a7`,fontStyle:`italic`},{token:`comment.html`,foreground:`a0a1a7`,fontStyle:`italic`},{token:`constant`,foreground:`986801`},{token:`delimiter`,foreground:`383a42`},{token:`delimiter.bracket`,foreground:`383a42`},{token:`delimiter.handlebars`,foreground:`0184bc`},{token:`delimiter.html`,foreground:`383a42`},{token:`delimiter.parenthesis`,foreground:`383a42`},{token:`delimiter.square`,foreground:`383a42`},{token:`identifier`,foreground:`383a42`},{token:`identifier.go`,foreground:`383a42`},{token:`keyword.flow.go`,foreground:`a626a4`},{token:`keyword.helper.handlebars`,foreground:`a626a4`},{token:`keyword.operator.go`,foreground:`0184bc`},{token:`keyword`,foreground:`a626a4`},{token:`metatag.content.html`,foreground:`383a42`},{token:`metatag.html`,foreground:`a626a4`},{token:`metatag`,foreground:`a626a4`},{token:`number.float.go`,foreground:`986801`},{token:`number.hex.go`,foreground:`986801`},{token:`number`,foreground:`986801`},{token:`operator`,foreground:`0184bc`},{token:`predefined`,foreground:`4078f2`},{token:`regexp`,foreground:`50a14f`},{token:`string.escape`,foreground:`0184bc`},{token:`string.escape.go`,foreground:`0184bc`},{token:`string.key.json`,foreground:`e45649`},{token:`string.value.json`,foreground:`50a14f`},{token:`string`,foreground:`50a14f`},{token:`tag.html`,foreground:`e45649`},{token:`tag`,foreground:`e45649`},{token:`type.identifier.go`,foreground:`c18401`},{token:`type`,foreground:`c18401`},{token:`variable.go`,foreground:`383a42`},{token:`variable.parameter.handlebars`,foreground:`4078f2`}],colors:{"editor.background":`#fafafa`,"editor.foreground":`#383a42`,"editor.lineHighlightBackground":`#f2f3f580`,"editor.selectionBackground":`#c8d3f566`,"editorCursor.foreground":`#526fff`,"editorGutter.background":`#fafafa`,"editorLineNumber.activeForeground":`#383a42`,"editorLineNumber.foreground":`#a0a1a7`}},M={base:`vs-dark`,inherit:!0,rules:[{token:``,foreground:`abb2bf`},{token:`attribute.name`,foreground:`d19a66`},{token:`attribute.name.html`,foreground:`d19a66`},{token:`attribute.value`,foreground:`98c379`},{token:`attribute.value.html`,foreground:`98c379`},{token:`comment`,foreground:`5c6370`,fontStyle:`italic`},{token:`comment.content`,foreground:`5c6370`,fontStyle:`italic`},{token:`comment.content.handlebars`,foreground:`5c6370`,fontStyle:`italic`},{token:`comment.content.html`,foreground:`5c6370`,fontStyle:`italic`},{token:`comment.html`,foreground:`5c6370`,fontStyle:`italic`},{token:`constant`,foreground:`d19a66`},{token:`delimiter`,foreground:`abb2bf`},{token:`delimiter.bracket`,foreground:`abb2bf`},{token:`delimiter.handlebars`,foreground:`56b6c2`},{token:`delimiter.html`,foreground:`abb2bf`},{token:`delimiter.parenthesis`,foreground:`abb2bf`},{token:`delimiter.square`,foreground:`abb2bf`},{token:`identifier`,foreground:`abb2bf`},{token:`identifier.go`,foreground:`abb2bf`},{token:`keyword.flow.go`,foreground:`c678dd`},{token:`keyword.helper.handlebars`,foreground:`c678dd`},{token:`keyword.operator.go`,foreground:`56b6c2`},{token:`keyword`,foreground:`c678dd`},{token:`metatag.content.html`,foreground:`abb2bf`},{token:`metatag.html`,foreground:`c678dd`},{token:`metatag`,foreground:`c678dd`},{token:`number.float.go`,foreground:`d19a66`},{token:`number.hex.go`,foreground:`d19a66`},{token:`number`,foreground:`d19a66`},{token:`operator`,foreground:`56b6c2`},{token:`predefined`,foreground:`61afef`},{token:`regexp`,foreground:`98c379`},{token:`string.escape`,foreground:`56b6c2`},{token:`string.escape.go`,foreground:`56b6c2`},{token:`string.key.json`,foreground:`e06c75`},{token:`string.value.json`,foreground:`98c379`},{token:`string`,foreground:`98c379`},{token:`tag.html`,foreground:`e06c75`},{token:`tag`,foreground:`e06c75`},{token:`type.identifier.go`,foreground:`e5c07b`},{token:`type`,foreground:`e5c07b`},{token:`variable.go`,foreground:`abb2bf`},{token:`variable.parameter.handlebars`,foreground:`61afef`}],colors:{"editor.background":`#282c34`,"editor.foreground":`#abb2bf`,"editor.lineHighlightBackground":`#2c313c`,"editor.selectionBackground":`#3e4451`,"editorCursor.foreground":`#528bff`,"editorGutter.background":`#282c34`,"editorLineNumber.activeForeground":`#abb2bf`,"editorLineNumber.foreground":`#5c6370`}},N=new Set,P={go:`Go`,gotemplate:`Go Template`,html:`HTML`,json:`JSON`,markdown:`Markdown`,plaintext:`Plain Text`,yaml:`YAML`},F=globalThis,I=l();function L({autoFocus:e,autoFormat:t,className:n,disabled:r,language:i,onChange:a,placeholder:o,value:s}){let c=(0,A.useRef)(null),l=(0,A.useRef)(null),u=(0,A.useRef)(null),d=(0,A.useRef)(s),f=(0,A.useRef)(a),m=(0,A.useId)(),[h,g]=(0,A.useState)(!1),[_,y]=(0,A.useState)(!0);(0,A.useEffect)(()=>{f.current=a},[a]),(0,A.useEffect)(()=>{let n=c.current;if(!n)return;let a=n,o=!1,s;async function p(){y(!0);let[n,{default:c}]=await Promise.all([v(()=>import(`./editor.api-Dv1ZVczm.js`),__vite__mapDeps([0,1,2,3])),v(()=>import(`./editor.worker-DCurFCio.js`),[]),v(()=>Promise.resolve({}),__vite__mapDeps([4]))]),[p,h]=await Promise.all([B(i)?v(()=>import(`./html.worker-BXRdYPFS.js`).then(e=>e.default),[]):Promise.resolve(void 0),V(i)?v(()=>import(`./json.worker-BHONpNZS.js`).then(e=>e.default),[]):Promise.resolve(void 0)]);if(o||(z({EditorWorker:c,HtmlWorker:p,JsonWorker:h}),await H(n,i),o))return;U(n);let _=n.editor.create(a,{automaticLayout:!1,contextmenu:!0,cursorBlinking:`smooth`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace`,fontSize:13,folding:!0,glyphMargin:!1,language:i,lineDecorationsWidth:10,lineNumbers:`on`,minimap:{enabled:!1},model:n.editor.createModel(d.current,i,n.Uri.parse(`inmemory://editor/${m}`)),padding:{bottom:12,top:12},readOnly:r,renderLineHighlight:r?`none`:`line`,scrollBeyondLastLine:!1,scrollbar:{horizontalScrollbarSize:10,verticalScrollbarSize:10},"semanticHighlighting.enabled":!0,tabSize:2,theme:W(),wordWrap:`on`});l.current=_,u.current=n,y(!1);let b=[_.onDidChangeModelContent(()=>{let e=_.getValue();d.current=e,f.current?.(e)}),_.onDidFocusEditorWidget(()=>g(!0)),_.onDidBlurEditorWidget(()=>{g(!1),t&&!r&&R(_,d,f).catch(()=>{})})],x=new ResizeObserver(()=>_.layout());x.observe(a);let S=new MutationObserver(()=>{n.editor.setTheme(W())});S.observe(document.documentElement,{attributeFilter:[`class`,`data-mode`],attributes:!0}),e&&_.focus(),s=()=>{x.disconnect(),S.disconnect();for(let e of b)e.dispose();_.getModel()?.dispose(),_.dispose(),l.current=null,u.current=null}}return p(),()=>{o=!0,s?.()}},[e,t,r,i,m]),(0,A.useEffect)(()=>{let e=l.current;!e||s===d.current||(d.current=s,e.setValue(s))},[s]),(0,A.useEffect)(()=>{let e=l.current;e&&e.updateOptions({readOnly:r,renderLineHighlight:r?`none`:`line`})},[r]),(0,A.useEffect)(()=>{let e=l.current,t=u.current;if(!e)return;let n=e.getModel();n&&t&&t.editor.setModelLanguage(n,i)},[i]);let b=!!(o&&!s&&!h);return(0,I.jsxs)(`div`,{className:p(`relative size-full min-w-0 bg-background text-sm`,n),children:[(0,I.jsx)(`div`,{className:`size-full`,ref:c}),_?(0,I.jsx)(`div`,{className:`absolute inset-0 bg-background/80`}):null,b?(0,I.jsx)(`div`,{className:`pointer-events-none absolute top-3 left-[4.1rem] select-none whitespace-pre-line text-muted-foreground text-sm`,children:o}):null]})}async function R(e,t,n){await e.getAction(`editor.action.formatDocument`)?.run();let r=e.getValue();r!==t.current&&(t.current=r,n.current?.(r))}function z({EditorWorker:e,HtmlWorker:t,JsonWorker:n}){F.MonacoEnvironment={getWorker:(r,i)=>i===`json`&&n?new n:(i===`html`||i===`handlebars`)&&t?new t:new e}}function B(e){return e===`html`||e===`gotemplate`}function V(e){return e===`json`}async function H(e,t){if(!N.has(t)){switch(t){case`go`:await v(()=>import(`./go.contribution-BmlX-a-9.js`),__vite__mapDeps([5,6,7,1,2,3,8,9]));break;case`gotemplate`:{let{conf:t,language:n}=await v(async()=>{let{conf:e,language:t}=await import(`./handlebars-d5Fb_oR7.js`);return{conf:e,language:t}},__vite__mapDeps([10,1,2,3,8,9]));e.languages.register({aliases:[`Go Template`,`gotemplate`],extensions:[`.gotmpl`,`.tmpl`],id:`gotemplate`}),e.languages.setLanguageConfiguration(`gotemplate`,t),e.languages.setMonarchTokensProvider(`gotemplate`,n);break}case`html`:await v(()=>import(`./html.contribution-Baf-XjFx.js`),__vite__mapDeps([11,6,7,1,2,3,8,9]));break;case`json`:await v(()=>import(`./monaco.contribution-BNCqMH44.js`),__vite__mapDeps([12,6,1,2,3,8,9]));break;case`markdown`:await v(()=>import(`./markdown.contribution-FtzundBn.js`),__vite__mapDeps([13,6,7,1,2,3,8,9]));break;case`yaml`:await v(()=>import(`./yaml.contribution-BN-iiJx2.js`),__vite__mapDeps([14,6,7,1,2,3,8,9]));break;default:break}N.add(t)}}function U(e){e.editor.defineTheme(`one-light-pro`,j),e.editor.defineTheme(`one-dark-pro`,M)}function W(){return G()?`one-dark-pro`:`one-light-pro`}function G(){if(typeof document>`u`)return!1;let e=document.documentElement;return e.dataset.mode?e.dataset.mode===`dark`:e.classList.contains(`dark`)}function K(e,t){return t?e===`markdown`?`markdown`:e===`html`?`html`:null:null}function q(e,t){return` ${e} `}var J=(0,A.lazy)(async()=>({default:(await v(()=>import(`./es-fZtL7B9U.js`),__vite__mapDeps([15,2,16,17,18]))).XMarkdown}));function Y({autoFocus:e=!1,autoFormat:t=!1,className:n,defaultView:r=`editor`,disabled:i=!1,editorClassName:a,language:o=`plaintext`,markdownPreview:s=!0,onChange:c,placeholder:l,preview:u,previewClassName:d,toolbarExample:f,toolbarHelp:m,value:h=``}){let g=(0,A.useRef)(null),[_,v]=(0,A.useState)(!1),[y,b]=(0,A.useState)(!1),[x,S]=(0,A.useState)(!1),C=K(o,s),[w,T]=(0,A.useState)(r);(0,A.useEffect)(()=>{let e=()=>{v(G())};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributeFilter:[`class`,`data-mode`],attributes:!0}),()=>t.disconnect()},[]),(0,A.useEffect)(()=>{if(!y)return;let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),b(!1))};return document.addEventListener(`keydown`,t,!0),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t,!0)}},[y]);let E=()=>{let e=g.current;S(!!e?.closest(`[data-slot="dialog-content"]`)),b(e=>!e)},D=e=>{y&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),b(!1))},O=(0,I.jsx)(L,{autoFocus:e,autoFormat:t,className:a,disabled:i,language:o,onChange:c,placeholder:l,value:h}),k=!!(C||u),j=u?(0,I.jsx)(`div`,{className:p(`h-full overflow-auto px-4 py-3`,d),children:u.content}):(0,I.jsx)(Q,{isDark:_,mode:C,previewClassName:d,value:h});return(0,I.jsx)(`div`,{className:p(`flex h-64 flex-col overflow-hidden rounded-sm border border-border/80 bg-background shadow-none transition-[color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/40`,i&&`opacity-70`,n,y&&`fixed z-[60] h-[calc(100svh-2rem)] max-h-none w-[calc(100vw-2rem)] rounded-sm border bg-background shadow-none focus-within:ring-0`,y&&x?`top-[calc(-50svh+50%+1rem)] left-[calc(-50vw+50%+1rem)]`:`inset-4`),onKeyDownCapture:D,ref:g,children:k?(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsx)(X,{disabled:i,isFullscreen:y,language:o,onFullscreenToggle:E,onUseExample:c,onViewChange:T,preview:!0,previewLabel:u?.label,toolbarExample:f,toolbarHelp:m,view:w}),w===`split`?(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 divide-y sm:grid-cols-2 sm:divide-x sm:divide-y-0`,children:[(0,I.jsx)(`div`,{className:`min-h-0`,children:O}),(0,I.jsx)(`div`,{className:`min-h-0`,children:j})]}):(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:w===`preview`?j:O})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{disabled:i,isFullscreen:y,language:o,onFullscreenToggle:E,onUseExample:c,toolbarExample:f,toolbarHelp:m}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1`,children:O})]})})}function X({disabled:e=!1,isFullscreen:t,language:i,onFullscreenToggle:c,onUseExample:l,onViewChange:f,preview:p=!1,previewLabel:v,toolbarExample:y,toolbarHelp:b,view:x=`editor`}){return(0,I.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-3 border-b bg-background px-2`,children:[(0,I.jsx)(`div`,{className:`px-2 font-medium text-muted-foreground text-xs`,children:P[i]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[y?(0,I.jsxs)(m,{className:`h-8 px-2 text-muted-foreground`,disabled:e||!l,onClick:()=>l?.(y.value),size:`sm`,type:`button`,variant:`ghost`,children:[(0,I.jsx)(D,{}),y.label??o()]}):null,b?(0,I.jsx)(Z,{help:b}):null,(0,I.jsxs)(m,{"aria-label":t?n():u(),className:`h-8 px-2 text-muted-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),c())},onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),c()},size:`sm`,type:`button`,variant:`ghost`,children:[t?(0,I.jsx)(k,{}):(0,I.jsx)(O,{}),t?n():a()]}),p?(0,I.jsx)(_,{className:`gap-0`,onValueChange:e=>f?.(e),value:x,children:(0,I.jsxs)(h,{className:`h-8`,variant:`line`,children:[(0,I.jsx)(g,{value:`editor`,children:d()}),(0,I.jsx)(g,{value:`preview`,children:v??s()}),(0,I.jsx)(g,{value:`split`,children:r()})]})}):null]})]})}function Z({help:e}){return(0,I.jsxs)(T,{children:[(0,I.jsx)(b,{asChild:!0,children:(0,I.jsxs)(m,{"aria-label":e.label??i(),className:`h-8 px-2 text-muted-foreground`,size:`sm`,type:`button`,variant:`ghost`,children:[(0,I.jsx)(E,{}),e.label??c()]})}),(0,I.jsxs)(C,{className:`max-h-[90svh] overflow-y-auto sm:max-w-3xl`,children:[(0,I.jsxs)(S,{children:[(0,I.jsx)(w,{children:e.title}),e.description?(0,I.jsx)(x,{children:e.description}):null]}),e.content]})]})}function Q({isDark:e,mode:t,previewClassName:n,value:r}){return t===`html`?(0,I.jsx)(`iframe`,{className:p(`h-full w-full bg-background`,n),sandbox:``,srcDoc:q(r,e),title:f()}):(0,I.jsx)(`div`,{className:p(`h-full overflow-auto px-4 py-3`,n),children:(0,I.jsx)(A.Suspense,{fallback:null,children:(0,I.jsx)(J,{content:r,openLinksInNewTab:!0})})})}export{Y as ClientEditor};