import{c as M,a as c,d as tt,e as B,s as A,f as S,o as _t}from"./BLoZk-4Q.js";import{f as m,P as F,R as f,U as x,K as l,T as $,t as V,Q,V as rt,as as gt,W as T,X as R,Y as mt,u as bt,bn as yt}from"./CkWh75VR.js";import{I as w,s as k,e as ot,i as it,b as lt,c as J,t as et,a as Mt}from"./Bmr4jBBJ.js";import{l as E,s as N,p as X,i as Z,b as nt,a as at}from"./BIAtSU2q.js";import{c as xt}from"./KAGS2ztk.js";import"./DnbEMVOy.js";import{C as wt}from"./DzYtD4Df.js";import{S as kt}from"./4tZ2hhAR.js";import{X as Et,M as Nt}from"./Dm3B8RZy.js";import{b as St}from"./DppCjq5L.js";import{b as zt}from"./_Q0si_gD.js";function Pt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["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"}]];w(r,N({name:"bold"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Rt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M4 12h8"}],["path",{d:"M4 18V6"}],["path",{d:"M12 18V6"}],["path",{d:"m17 12 3-2v8"}]];w(r,N({name:"heading-1"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Vt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M4 12h8"}],["path",{d:"M4 18V6"}],["path",{d:"M12 18V6"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"}]];w(r,N({name:"heading-2"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Ct(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M4 12h8"}],["path",{d:"M4 18V6"}],["path",{d:"M12 18V6"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"}]];w(r,N({name:"heading-3"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function qt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["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"}]];w(r,N({name:"italic"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Lt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}]];w(r,N({name:"link"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function jt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M10 12h11"}],["path",{d:"M10 18h11"}],["path",{d:"M10 6h11"}],["path",{d:"M4 10h2"}],["path",{d:"M4 6h1v4"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}]];w(r,N({name:"list-ordered"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function At(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M3 12h.01"}],["path",{d:"M3 18h.01"}],["path",{d:"M3 6h.01"}],["path",{d:"M8 12h13"}],["path",{d:"M8 18h13"}],["path",{d:"M8 6h13"}]];w(r,N({name:"list"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Dt(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M5 12h14"}]];w(r,N({name:"minus"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function Ht(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}]];w(r,N({name:"quote"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function It(r,t){const a=E(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const i=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"m9 12 2 2 4-4"}]];w(r,N({name:"square-check"},()=>a,{get iconNode(){return i},children:(o,e)=>{var n=M(),s=m(n);k(s,t,"default",{}),c(o,n)},$$slots:{default:!0}}))}function G(r,t,a,i="text"){const{value:o,selectionStart:e,selectionEnd:n}=r,s=o.slice(e,n);if(s){const p=t+s+a;return{value:o.slice(0,e)+p+o.slice(n),selectionStart:e+t.length,selectionEnd:e+t.length+s.length}}const u=t+i+a;return{value:o.slice(0,e)+u+o.slice(n),selectionStart:e+t.length,selectionEnd:e+t.length+i.length}}function j(r,t){const{value:a,selectionStart:i,selectionEnd:o}=r,e=a.lastIndexOf(`
`,i-1)+1,n=a.indexOf(`
`,o),s=n===-1?a.length:n,u=a.slice(e,s),p=u.split(`
`).map(v=>t+v).join(`
`),b=u.split(`
`).length;return{value:a.slice(0,e)+p+a.slice(s),selectionStart:i+t.length,selectionEnd:o+t.length*b}}function st(r,t,a){const{value:i,selectionStart:o}=r;let e="";o>0&&i[o-1]!==`
`&&(e=`
`),o>1&&i[o-2]!==`
`&&(e=`

`);const n=e+t+`
`,s=a!=null?o+e.length+a:o+n.length;return{value:i.slice(0,o)+n+i.slice(o),selectionStart:s,selectionEnd:s}}function Kt(r,t,a){a(t.value),requestAnimationFrame(()=>{r.selectionStart=t.selectionStart,r.selectionEnd=t.selectionEnd,r.focus()})}var Tt=S('<span class="sep svelte-1w1dn0"></span>'),Bt=S('<span class="tb-label svelte-1w1dn0"> </span>'),Xt=S('<button type="button" class="tb-btn svelte-1w1dn0"><!></button>'),Ft=S("<!> <!>",1),Qt=S('<div class="toolbar svelte-1w1dn0"><div class="toolbar-spacer svelte-1w1dn0"></div> <div class="toolbar-gap svelte-1w1dn0"></div> <div class="toolbar-content svelte-1w1dn0"><div class="toolbar-groups svelte-1w1dn0"></div> <div class="toolbar-actions svelte-1w1dn0"><button type="button" class="btn btn-primary btn-sm"><!> </button> <button type="button" class="btn btn-sm"><!> </button></div></div></div>');function Ut(r,t){F(t,!0);const a=()=>nt(et,"$t",i),[i,o]=at();let e=X(t,"saving",3,!1),n=X(t,"splitRatio",3,.5);const s=[[{action:"h1",icon:Rt,tip:"editor.tip_h1"},{action:"h2",icon:Vt,tip:"editor.tip_h2"},{action:"h3",icon:Ct,tip:"editor.tip_h3"}],[{action:"bold",icon:Pt,tip:"editor.tip_bold"},{action:"italic",icon:qt,tip:"editor.tip_italic"},{action:"code",icon:wt,tip:"editor.tip_code"}],[{action:"hr",icon:Dt,tip:"editor.tip_hr"},{action:"ul",icon:At,tip:"editor.tip_ul"},{action:"ol",icon:jt,tip:"editor.tip_ol"},{action:"quote",icon:Ht,tip:"editor.tip_quote"}],[{action:"checkbox",icon:It,tip:"editor.tip_checkbox"},{action:"link",icon:Lt,tip:"editor.tip_link"},{action:"codeblock",label:"```",tip:"editor.tip_codeblock"}]];var u=Qt(),p=f(u),b=x(p,4),v=f(b);ot(v,21,()=>s,it,(z,d,U)=>{var W=Ft(),O=m(W);{var dt=H=>{var L=Tt();c(H,L)};Z(O,H=>{U>0&&H(dt)})}var ct=x(O,2);ot(ct,17,()=>l(d),it,(H,L)=>{var I=Xt(),vt=f(I);{var ut=P=>{const K=rt(()=>l(L).icon);var Y=M(),ht=m(Y);xt(ht,()=>l(K),($t,ft)=>{ft($t,{size:15,strokeWidth:2})}),c(P,Y)},pt=P=>{var K=Bt(),Y=f(K,!0);$(K),V(()=>A(Y,l(L).label)),c(P,K)};Z(vt,P=>{l(L).icon?P(ut):P(pt,!1)})}$(I),V(P=>lt(I,"title",P),[()=>a()(l(L).tip)]),B("click",I,()=>t.onAction(l(L).action)),c(H,I)}),c(z,W)}),$(v);var g=x(v,2),h=f(g),_=f(h);kt(_,{size:14});var y=x(_);$(h);var C=x(h,2),q=f(C);Et(q,{size:14});var D=x(q);$(C),$(g),$(b),$(u),V((z,d)=>{J(p,`flex-basis: ${n()*100}%;`),h.disabled=e(),A(y,` ${z??""}`),A(D,` ${d??""}`)},[()=>a()("editor.save"),()=>a()("editor.cancel")]),B("click",h,function(...z){var d;(d=t.onSave)==null||d.apply(this,z)}),B("click",C,function(...z){var d;(d=t.onClose)==null||d.apply(this,z)}),c(r,u),Q(),o()}tt(["click"]);var Wt=S('<p class="empty-hint svelte-1g94l1e"> </p>'),Ot=S('<div class="preview-pane svelte-1g94l1e"><div class="pane-header svelte-1g94l1e"> </div> <div class="pane-body svelte-1g94l1e"><!></div></div>');function Yt(r,t){F(t,!0);const a=()=>nt(et,"$t",i),[i,o]=at();let e=X(t,"content",3,"");var n=Ot(),s=f(n),u=f(s,!0);$(s);var p=x(s,2),b=f(p);{var v=_=>{Nt(_,{get content(){return e()}})},g=rt(()=>e().trim()),h=_=>{var y=Wt(),C=f(y,!0);$(y),V(q=>A(C,q),[()=>a()("editor.preview_empty")]),c(_,y)};Z(b,_=>{l(g)?_(v):_(h,!1)})}$(p),$(n),V(_=>A(u,_),[()=>a()("editor.preview")]),c(r,n),Q(),o()}var Gt=S('<div class="editor-pane svelte-oojubp"><div class="pane-header svelte-oojubp"> </div> <textarea class="editor-textarea svelte-oojubp" spellcheck="false"></textarea></div>');function Jt(r,t){F(t,!0);const a=()=>nt(et,"$t",i),[i,o]=at();let e=X(t,"value",15,""),n=X(t,"textareaEl",15,null);function s(g){if(g.key==="Tab"){g.preventDefault();const h=n();if(!h)return;const{selectionStart:_,selectionEnd:y}=h;e(e().slice(0,_)+"	"+e().slice(y)),requestAnimationFrame(()=>{h.selectionStart=h.selectionEnd=_+1})}}var u=Gt(),p=f(u),b=f(p,!0);$(p);var v=x(p,2);gt(v),zt(v,g=>n(g),()=>n()),$(u),V((g,h)=>{A(b,g),lt(v,"placeholder",h)},[()=>a()("editor.source"),()=>a()("editor.placeholder")]),B("keydown",v,s),St(v,e),c(r,u),Q(),o()}tt(["keydown"]);var Zt=S('<div role="separator" aria-orientation="vertical"><div class="handle svelte-1w3avtj"></div></div>');function te(r,t){F(t,!0);let a=T(!1);function i(n){n.preventDefault(),R(a,!0);const s=n.currentTarget.parentElement;if(!s)return;function u(b){const v=s.getBoundingClientRect(),g=b.clientX-v.left,h=Math.min(Math.max(g/v.width,.15),.85);t.onResize(h)}function p(){R(a,!1),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",p)}window.addEventListener("mousemove",u),window.addEventListener("mouseup",p)}var o=Zt();let e;V(()=>e=Mt(o,1,"divider svelte-1w3avtj",null,e,{dragging:l(a)})),B("mousedown",o,i),c(r,o),Q()}tt(["mousedown"]);var ee=S('<div class="md-editor-overlay svelte-h6uur0" role="dialog" aria-modal="true" aria-label="Markdown Editor"><div class="md-editor-modal svelte-h6uur0"><!> <div class="split-container svelte-h6uur0"><div class="split-left svelte-h6uur0"><!></div> <!> <div class="split-right svelte-h6uur0"><!></div></div></div></div>');function pe(r,t){F(t,!0);let a=T(mt(bt(()=>t.content||""))),i=T(!1),o=T(.5),e=T(null);function n(d){if(d.key==="Escape"){t.onClose();return}(d.ctrlKey||d.metaKey)&&d.key==="s"&&(d.preventDefault(),p())}const s={h1:()=>j(l(e),"# "),h2:()=>j(l(e),"## "),h3:()=>j(l(e),"### "),bold:()=>G(l(e),"**","**","bold"),italic:()=>G(l(e),"*","*","italic"),code:()=>G(l(e),"`","`","code"),hr:()=>st(l(e),"---"),ul:()=>j(l(e),"- "),ol:()=>j(l(e),"1. "),quote:()=>j(l(e),"> "),checkbox:()=>j(l(e),"- [ ] "),link:()=>G(l(e),"[","](url)","link text"),codeblock:()=>st(l(e),"```\n\n```",4)};function u(d){if(!l(e))return;const U=s[d];if(!U)return;const W=U();Kt(l(e),W,O=>{R(a,O,!0)})}async function p(){R(i,!0);try{await t.onSave(l(a))}finally{R(i,!1)}}function b(d){R(o,d,!0)}var v=ee();_t("keydown",yt,n);var g=f(v),h=f(g);Ut(h,{get onClose(){return t.onClose},onSave:p,onAction:u,get saving(){return l(i)},get splitRatio(){return l(o)}});var _=x(h,2),y=f(_),C=f(y);Yt(C,{get content(){return l(a)}}),$(y);var q=x(y,2);te(q,{onResize:b});var D=x(q,2),z=f(D);Jt(z,{get value(){return l(a)},set value(d){R(a,d,!0)},get textareaEl(){return l(e)},set textareaEl(d){R(e,d,!0)}}),$(D),$(_),$(g),$(v),V(()=>{J(y,`flex-basis: ${l(o)*100}%;`),J(D,`flex-basis: ${(1-l(o))*100}%;`)}),c(r,v),Q()}export{pe as M};
