import{a as e,l as t}from"./preact.module-CNakwbc9.js";import{d as n,l as r,s as i,t as a}from"./hooks.module-BrXTvcfS.js";import{n as o,nt as s}from"./content_renderer-DOj8g78V.js";import{a as c}from"./i18n-BaLR3UdQ.js";import{i as l}from"./toast-C6WyPqyA.js";import{t as u}from"./jsxRuntime.module-Cao1NCKs.js";import{o as d}from"./react_utils-Bz0ffU2Y.js";import{J as f,L as p,it as m}from"./hooks-ClTXKdUl.js";import{a as h}from"./FormList-CnuOJg6b.js";import{i as g,t as _}from"./Button-Du0dYm4Z.js";import{t as v}from"./NoteAutocomplete-Cpc7J_0A.js";import{t as y}from"./FormGroup-DqPd4bBP.js";import{t as b}from"./RenderErrorCard-BOMnYcGq.js";import{t as x}from"./SetupForm-CP7dB0pv.js";n(),t();var S=`HcABDtFCkbFN`,C=`export default function() {
    return <p>Hello world.</p>;
}
`,w=`<p>Hello world.</p>
`;function T(e){let{note:t}=e,[n]=p(t,`renderNote`),[r]=p(t,`disabled:renderNote`);return u(r?D:n?E:O,{...e})}function E({note:t,noteContext:n,ntxId:s}){let c=a(null),[l,p]=i(null);function h(){c&&(p(null),o.render(t,d(c),(e,t)=>p({error:e,noteId:t})))}return r(h,[t]),f(`renderActiveNote`,()=>{n?.isActive()&&h()}),f(`refreshData`,({ntxId:e})=>{e===s&&h()}),f(`entitiesReloaded`,({loadResults:e})=>{e.getAttributeRows().some(e=>e.type===`relation`&&e.name===`renderNote`&&m.isAffecting(e,t))&&h()}),f(`executeWithContentElement`,({resolve:e,ntxId:t})=>{t===s&&e(d(c))}),u(e,{children:[l&&u(b,{error:l.error,noteId:l.noteId}),u(`div`,{ref:c,className:`note-detail-render-content`})]})}function D({note:e}){return u(x,{icon:`bx bx-extension`,inAppHelpPage:S,children:[u(`p`,{children:c(`render.disabled_description`)}),u(_,{text:c(`render.disabled_button_enable`),icon:`bx bx-check-shield`,onClick:()=>m.toggleDangerousAttribute(e,`relation`,`renderNote`,!0),kind:`primary`})]})}function O({note:e}){return u(x,{icon:`bx bx-extension`,inAppHelpPage:S,children:[u(y,{name:`render-target-note`,label:c(`render.setup_title`),children:u(v,{noteIdChanged:t=>{t&&k(e,t)}})}),u(g,{text:c(`render.setup_create_sample_preact`),icon:`bx bxl-react`,onClick:()=>A(e,`text/jsx`,C),children:u(h,{icon:`bx bxl-html5`,onClick:()=>A(e,`text/html`,w),children:c(`render.setup_create_sample_html`)})})]})}async function k(e,t){await m.setRelation(e.noteId,`renderNote`,t)}async function A(e,t,n){let{note:r}=await s.createNote(e.noteId,{type:`code`,mime:t,content:n,activate:!1});r&&(await k(e,r.noteId),l.showMessage(c(`render.setup_sample_created`)))}export{T as default};