import{B as e,E as t,Ft as n,H as r,I as i,It as a,J as o,L as s,M as c,Mt as l,Q as u,R as ee,S as d,V as f,W as p,Z as m,_t as h,at as g,b as _,c as v,d as te,ft as y,g as b,ht as x,jt as ne,l as S,mt as C,ot as re,pt as w,q as T,s as E,st as D,tt as O,x as k,xt as ie}from"./BA99CCI5.js";import"./xihTtKlq.js";import"./DGo8yE5j.js";import{t as A}from"./3rupxGJ5.js";import{t as ae}from"./CCK5X2n32.js";import{t as oe}from"./Bv3FroHu2.js";import{t as se}from"./BHkcdQFQ.js";import{t as ce}from"./r1twnwGx.js";import{t as le}from"./CfXOj6DR.js";import{t as ue}from"./CT9uUPGn.js";import{n as de}from"./DsOfWPM4.js";var j=new Set([`$$slots`,`$$events`,`$$legacy`]);function fe(e,t){let n=v(t,j),r=[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`}]];A(e,S({name:`bold`},()=>n,{get iconNode(){return r}}))}var M=new Set([`$$slots`,`$$events`,`$$legacy`]);function pe(e,t){let n=v(t,M),r=[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`}]];A(e,S({name:`italic`},()=>n,{get iconNode(){return r}}))}var N=new Set([`$$slots`,`$$events`,`$$legacy`]);function me(e,t){let n=v(t,N),r=[[`path`,{d:`M11 5h10`}],[`path`,{d:`M11 12h10`}],[`path`,{d:`M11 19h10`}],[`path`,{d:`M4 4h1v5`}],[`path`,{d:`M4 9h2`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`}]];A(e,S({name:`list-ordered`},()=>n,{get iconNode(){return r}}))}var he=p(`<span class="text-red-500">*</span>`),ge=p(`<label class="block text-sm font-medium text-neutral-900 dark:text-neutral-100"> <!></label>`),_e=p(`<p class="text-xs text-neutral-600 dark:text-neutral-400"> </p>`),ve=p(`<button type="button" class="rounded-md p-1.5 text-neutral-600 transition-colors hover:bg-neutral-200 hover:text-neutral-900 disabled:cursor-not-allowed disabled:opacity-50 dark:text-neutral-400 dark:hover:bg-neutral-700 dark:hover:text-neutral-100"><!></button>`),ye=p(`<!> Edit`,1),be=p(`<!> Preview`,1),xe=p(`<div><div class="flex items-center gap-1"></div> <button type="button"><!></button></div>`),Se=p(`<input type="hidden"/>`),Ce=p(`<div class="prose prose-sm max-w-none rounded-b-xl border border-neutral-300 bg-white px-3 py-2 text-neutral-900 dark:border-neutral-700/60 dark:bg-neutral-800/50 dark:text-neutral-100"></div> <!>`,1),we=p(`<textarea></textarea>`),Te=p(`<input type="text"/>`),Ee=p(`<div class="space-y-2"><!> <!> <div><!> <!></div></div>`);function P(p,v){l(v,!1);let S=x(),T=E(v,`value`,12,``),A=E(v,`placeholder`,8,``),j=E(v,`label`,8,``),M=E(v,`description`,8,``),N=E(v,`rows`,8,8),P=E(v,`multiline`,8,!0),F=E(v,`markdown`,8,!0),I=E(v,`required`,8,!1),L=E(v,`disabled`,8,!1),R=E(v,`name`,8,``),z=E(v,`id`,24,R),B=E(v,`onchange`,8,void 0),V=x(!1),H=x(),U=x();function W(e){let t=e.target;T(t.value),B()?.(T())}function G(e,t=``){let n=P()?u(H):u(U);if(!n)return;let r=n.selectionStart??0,i=n.selectionEnd??0,a=T().substring(r,i),o=T().substring(0,r)+e+a+t+T().substring(i);T(o),B()?.(T()),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(r+e.length,r+e.length+a.length)})}function K(){G(`**`,`**`)}function q(){G(`*`,`*`)}function De(){G("`","`")}function Oe(){let e=P()?u(H):u(U);if(!e)return;let t=e.selectionStart??0,n=e.selectionEnd??0;T().substring(t,n)?G(`[`,`](url)`):G(`[link text](url)`)}function ke(){let e=P()?u(H):u(U);if(!e)return;let t=e.selectionStart??0,n=T().substring(0,t).split(`
`);n[n.length-1].length===0||t===0?G(`- `):G(`
- `)}function Ae(){let e=P()?u(H):u(U);if(!e)return;let t=e.selectionStart??0,n=T().substring(0,t).split(`
`);n[n.length-1].length===0||t===0?G(`1. `):G(`
1. `)}function je(e){return e?de(ue.parse(e)):`<p class="text-neutral-400 dark:text-neutral-500 italic">Nothing to preview</p>`}let Me=[{action:K,icon:fe,title:`Bold (Ctrl+B)`,shortcut:`b`},{action:q,icon:pe,title:`Italic (Ctrl+I)`,shortcut:`i`},{action:De,icon:ae,title:`Code`,shortcut:null},{action:Oe,icon:se,title:`Link`,shortcut:null},{action:ke,icon:ce,title:`Bullet List`,shortcut:null},{action:Ae,icon:me,title:`Numbered List`,shortcut:null}];function J(e){if(F()&&(e.ctrlKey||e.metaKey))switch(e.key.toLowerCase()){case`b`:e.preventDefault(),K();break;case`i`:e.preventDefault(),q()}}g(()=>m(L()),()=>{h(S,L()?`bg-neutral-100 text-neutral-500 cursor-not-allowed dark:bg-neutral-800/40 dark:text-neutral-500`:`bg-white dark:bg-neutral-800/50`)}),re(),te();var Y=Ee(),X=y(Y),Ne=t=>{var n=ge(),i=y(n),o=C(i),s=e=>{var t=he();r(e,t)};e(o,e=>{I()&&e(s)}),a(n),D(()=>{k(n,`for`,z()),f(i,`${j()??``} `)}),r(t,n)};e(X,e=>{j()&&e(Ne)});var Z=C(X,2),Pe=e=>{var t=_e(),n=y(t,!0);a(t),D(()=>f(n,M())),r(e,t)};e(Z,e=>{M()&&e(Pe)});var Q=C(Z,2),$=y(Q),Fe=i=>{var l=xe(),d=y(l);s(d,5,()=>Me,ee,(e,t)=>{var n=ve(),i=y(n);c(i,()=>u(t).icon,(e,t)=>{t(e,{size:16})}),a(n),D(()=>{k(n,`title`,(u(t),O(()=>u(t).title))),n.disabled=L()||u(V)}),o(`click`,n,function(...e){u(t).action?.apply(this,e)}),r(e,n)}),a(d);var f=C(d,2),p=y(f),m=e=>{var t=ye(),i=w(t);le(i,{size:14}),n(),r(e,t)},g=e=>{var t=be(),i=w(t);oe(i,{size:14}),n(),r(e,t)};e(p,e=>{u(V)?e(m):e(g,-1)}),a(f),a(l),D(()=>{t(l,1,`flex items-center justify-between rounded-t-xl border border-neutral-300 bg-neutral-50/80 px-2 py-1 dark:border-neutral-700/60 dark:bg-neutral-800/40 ${u(V)?`border-b-0`:``}`),k(f,`title`,u(V)?`Edit`:`Preview`),t(f,1,`flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors ${u(V)?`bg-neutral-200 text-neutral-900 dark:bg-neutral-700 dark:text-neutral-100`:`text-neutral-600 hover:bg-neutral-200 dark:text-neutral-400 dark:hover:bg-neutral-700`}`)}),o(`click`,f,()=>h(V,!u(V))),r(i,l)};e($,e=>{F()&&e(Fe)});var Ie=C($,2),Le=t=>{var n=Ce(),o=w(n);i(o,()=>(m(T()),O(()=>je(T()))),!0),a(o);var s=C(o,2),c=e=>{var t=Se();_(t),D(()=>{k(t,`name`,R()),d(t,T())}),r(e,t)};e(s,e=>{R()&&e(c)}),r(t,n)},Re=e=>{var n=we();ie(n),b(n,e=>h(H,e),()=>u(H)),D(()=>{k(n,`id`,z()),k(n,`name`,R()),d(n,T()),k(n,`placeholder`,A()),k(n,`rows`,N()),n.disabled=L(),n.required=I(),t(n,1,`${F()?`rounded-t-none rounded-bl-xl border-t-0`:`rounded-tl-xl rounded-tr-xl rounded-bl-xl`} block w-full border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 transition-colors focus:outline-none dark:border-neutral-700/60 dark:text-neutral-50 dark:placeholder-neutral-500 ${u(S)??``}`)}),o(`input`,n,W),o(`keydown`,n,J),r(e,n)},ze=e=>{var n=Te();_(n),b(n,e=>h(U,e),()=>u(U)),D(()=>{k(n,`id`,z()),k(n,`name`,R()),d(n,T()),k(n,`placeholder`,A()),n.disabled=L(),n.required=I(),t(n,1,`${F()?`rounded-t-none rounded-bl-xl border-t-0`:`rounded-tl-xl rounded-tr-xl rounded-bl-xl`} block w-full border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 transition-colors focus:outline-none dark:border-neutral-700/60 dark:text-neutral-50 dark:placeholder-neutral-500 ${u(S)??``}`)}),o(`input`,n,W),o(`keydown`,n,J),r(e,n)};e(Ie,e=>{u(V)&&F()?e(Le):P()?e(Re,1):e(ze,-1)}),a(Q),a(Y),r(p,Y),ne()}T([`click`,`input`,`keydown`]);export{P as t};