@mrakomor/core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ {
2
+ "mrakomor.mjs": "mrakomor.mjs",
3
+ "mrakomor.css": "mrakomor.css"
4
+ }
@@ -0,0 +1 @@
1
+ .molecule__figure{padding:12px 6px;background-color:#f0f0f0}.molecule__figure .image{aspect-ratio:16/9;background-color:#d3d3d3}.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between;.dialog-controls{text-align:right;width:100%;.dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}}.dialog-container{width:100%}}.mrakomor-tooltip{position:absolute;z-index:9100;display:flex;flex-direction:row;align-items:center;gap:2px;background:#1a1a1a;border-radius:6px;padding:4px 6px;box-shadow:0 3px 10px #00000040;pointer-events:all;white-space:nowrap}.mrakomor-tooltip__btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:4px;color:#fff;cursor:pointer;font-size:13px;font-weight:600;min-width:28px;min-height:28px;padding:0 6px;transition:background .1s}.mrakomor-tooltip__btn:hover{background:#ffffff26}.mrakomor-tooltip__btn--active{background:#ffffff40;color:#7dd3fc}.mrakomor-tooltip__separator{width:1px;height:18px;background:#fff3;margin:0 4px;flex-shrink:0}.mrakomor-tools-container,.mrakomor-content{position:relative}.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5,.mrakomor-content p{margin-top:0}.molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth="1"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth="2"]{margin-inline-start:3em}.molecule-list-list li[data-depth="3"]{margin-inline-start:4.5em}.mrakomor-block-element{position:relative;padding-left:52px}.mrakomor-block-gutter{position:absolute;left:0;top:2px;display:flex;align-items:center;gap:2px;opacity:0;transition:opacity .15s ease;pointer-events:all;user-select:none;z-index:1}.mrakomor-block-element:hover .mrakomor-block-gutter,.mrakomor-block-element--active .mrakomor-block-gutter,.mrakomor-block-drag-active .mrakomor-block-gutter{opacity:1}.mrakomor-block-add,.mrakomor-block-drag{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:#9ca3af;cursor:pointer;font-size:18px;line-height:1;transition:background .1s,color .1s}.mrakomor-block-add:hover,.mrakomor-block-drag:hover{background:#0000000f;color:#374151}.mrakomor-block-drag{cursor:grab}.mrakomor-block-element--dragging .mrakomor-block-drag,.mrakomor-block-drag-active .mrakomor-block-drag{cursor:grabbing}.mrakomor-block-element--dragging{opacity:.5}.mrakomor-block-body{min-width:0}.mrakomor-block-drop-indicator{position:absolute;left:52px;right:0;height:2px;background:#3b82f6;border-radius:1px;pointer-events:none;z-index:2}.mrakomor-block-insert-menu{position:absolute;z-index:9200;display:flex;flex-direction:column;gap:2px;min-width:120px;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-block-insert-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-block-insert-menu__item:hover{background:#ffffff26}.link-toolbar{display:flex;flex-direction:column;gap:6px}.link-toolbar__row{display:flex;align-items:center;gap:4px;min-width:0}.link-toolbar__href{flex:1;min-width:0;font-size:13px;color:#1a73e8;text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px}.link-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.link-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555;&:hover{background:#f0f0f0;color:#222}}.link-toolbar__btn--danger{&:hover{color:#d32f2f;background:#fdecea}}.link-toolbar__input{flex:1;min-width:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:13px;outline:none;&:focus{border-color:#1a73e8;box-shadow:0 0 0 2px #1a73e833}}.link-toolbar__select{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 6px;font-size:13px;background:#fff;cursor:pointer}.atom-tts-voice{position:relative;border-radius:2px;display:inline-block}.atom-tts-voice:before{content:attr(data-voice-label);position:absolute;top:-1.1em;left:0;font-size:10px;line-height:1;white-space:nowrap;padding:1px 4px;border-radius:3px;pointer-events:none;font-weight:600}.tts-voice--man{background:#e8f0fe;color:#174ea6}.tts-voice--man:before{background:#1a73e8;color:#fff}.tts-voice--woman{background:#f3e8fd;color:#5e35b1}.tts-voice--woman:before{background:#7b1fa2;color:#fff}.tts-voice-toolbar{display:flex;flex-direction:column;gap:6px}.tts-voice-toolbar__row{display:flex;align-items:center;flex-wrap:wrap;gap:4px;min-width:0}.tts-voice-toolbar__voice{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:12px;background:#fff;color:#333}.tts-voice-toolbar__voice--man{border-color:#1a73e8;color:#174ea6}.tts-voice-toolbar__voice--woman{border-color:#7b1fa2;color:#5e35b1}.tts-voice-toolbar__voice--active{font-weight:600}.tts-voice-toolbar__voice--man.tts-voice-toolbar__voice--active{background:#e8f0fe}.tts-voice-toolbar__voice--woman.tts-voice-toolbar__voice--active{background:#f3e8fd}.tts-voice-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.tts-voice-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.tts-voice-toolbar__btn:hover{background:#f0f0f0;color:#222}.tts-voice-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
@@ -0,0 +1,9 @@
1
+ var Zt=class{next(...t){}error(...t){}complete(...t){}},gt=class{#e=new Set;pipe(...t){return t.reduce((e,n)=>n(e),this)}next(...t){Array.from(this.#e).forEach(e=>{typeof e=="function"?e(...t):e.next(...t)})}error(...t){Array.from(this.#e).forEach(e=>{e?.error?.(...t),this.unsubscribe(e)})}complete(...t){Array.from(this.#e).forEach(e=>{e?.complete?.(...t),this.unsubscribe(e)})}subscribe(t){return this.#e.add(t),{unsubscribe:()=>{this.unsubscribe(t)}}}unsubscribe(t){this.#e.delete(t)}};var Je=Symbol("@esmj/signals:type"),ve=Symbol("@esmj/signals:name"),Le=null;var I=null,oo=0,ro=new Set,ht=!1,Et=[];function O(t){let e=I;I=null;let n=t();return I=e,n}function so(){ht=!1;let t=on();for(let n of t)n.get();let e=Et;Et=[];for(let n of e)n()}function en(){ht||(ht=!0,queueMicrotask(so))}function bt(t){Et.push(t),en()}var tn=Symbol("@esmj/signals:internal observable"),U=Symbol("@esmj/signals:original function"),io=class extends gt{#e=new Set;#o=null;constructor(t){super(),this.#o=t,this.pipe(e=>{let n=e.subscribe.bind(e),o=e.unsubscribe.bind(e);return e.subscribe=r=>{n(r),this.#e.add(r)},e.unsubscribe=r=>{o(r),this.#e.delete(r)},e})}watch(t){if(typeof t.next!="function"&&(t.next=()=>O(()=>{this.#e.add(t),this.#o()}),t.next[U]=void 0),t instanceof ln&&t.next[U]===void 0){let e=t.next.bind(t);t.next=()=>O(()=>{this.#e.add(t),e(),this.#o()}),t.next[U]=e}return this.subscribe(t)}getPending(){let t=[];for(let e of this.#e){if(!e.get[U]){let n=e.get,o=n.bind(e);e.get=()=>O(()=>(this.#e.delete(e),o())),e.get[U]=n}t.push(e)}return t}unwatch(t){return t.next=t.next[U]?t.next[U]:t.next,t.get=t.get[U]?t.get[U]:t.get,this.#e.delete(t),this.unsubscribe(t)}},We=null;function nn(t){We=new io(t)}nn(()=>{en()});function on(){return We.getPending()}function rn(t){return We.watch(t)}function sn(t){return We.unwatch(t)}var V=Symbol("@esmj/signals:no error"),ln=class an extends Zt{#e=!0;#o=!1;#n=null;#t=this.#p();#s=null;#l=null;#c=0;#i=new Map;#r=V;constructor(e,n){super(),this.#s=e,this.#l=n,this.debug=n?.debug,this[Je]="computed",this[ve]=n?.debug??null,this.get=this.get.bind(this),Le?.onComputedCreate?.(this)}#u(){for(let{unsubscribe:e}of this.#t.dependencies.values())e();this.#t.dependencies.clear()}#p(){return{dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#c}getDebugInfo(){return{name:this[ve],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#i.keys()]}}#m(){for(let[e,n]of this.#i)if(e instanceof an&&O(()=>e.get()),e.getRevision()!==n)return!0;return!1}next(){this.#e=!0,this.#n[tn].next()}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=x(this.#a(),this.#l)),(this.#e||this.#r!==V)&&(this.#i.size===0||this.#m()?this.#a():this.#e=!1),I&&I.sourceRevisions.set(this,this.#c),this.#r!==V)throw this.#r;return this.#n.get()}peek(){if(this.#n||(this.#n=x(this.#a(),this.#l)),(this.#e||this.#r!==V)&&(this.#i.size===0||this.#m()?this.#a():this.#e=!1),this.#r!==V)throw this.#r;return this.#n.peek()}#a(){this.#o=!0,this.#e=!1,this.#r=V,Le?.onComputedRun?.(this),this.#u(),this.#t.sourceRevisions.clear();let e=I;I=this.#t;let n;try{n=this.#s()}catch(o){this.#r=o}return I=e,this.#i=this.#t.sourceRevisions,this.#t.sourceRevisions=new Map,this.#o=!1,n instanceof Promise&&(n=n.then(o=>{this.#r=V,this.#n.set(o)}).catch(o=>{this.#r=o})),this.#r===V&&this.#n&&this.#n.set(n),this.#c++,n}destroy(){this.#u(),this.#i.clear(),this.#e=!0,this.#r=V}};function T(t,e){return new ln(t,e)}function G(t,e){let n,{debug:o,...r}=e??{},s=T(()=>{n?.(),n=t()},{equals:()=>!1,...r});s.get(),rn(s);let i=()=>{n?.(),s.destroy(),sn(s)};return i[Symbol.dispose]=i,i[Je]="effect",i[ve]=o??null,i.__RX_COMPUTED__=s,Le?.onEffectCreate?.(i),i}function x(t,e={}){let n=e?.equals??Object.is,o=0,r=new gt;function s(){return I&&(I.dependencies.set(r,r.subscribe(I.observer)),I.sourceRevisions.set(c,o)),t}function i(){return t}function l(u){if(!n(t,u)){let p=t;t=u,o++,Le?.onSignalSet?.(c,p,u),oo>0?ro.add(r):r.next()}return t}function a(){return o}let c={get:s,set:l,peek:i,getRevision:a,[tn]:r,[Je]:"signal",[ve]:e?.debug??null};return Le?.onSignalCreate?.(c),c}function Xe(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var pn=Symbol("node-component"),Qe=Symbol("node-internal"),lo=Symbol("context-id"),fn=Symbol("keep-literal");function dn(t){let e=()=>t;return e[fn]=!0,e}function ce(t){let e=null,n=()=>e,o=s=>(e=s??null,typeof t=="function"&&t(e),e),r={get:n,set:o,[Symbol.toPrimitive](){return e?String(e):""}};return Object.defineProperty(r,"current",{get(){return e},set(s){o(s)},enumerable:!0,configurable:!1}),new Proxy(r,{get(s,i,l){if(Reflect.has(s,i))return Reflect.get(s,i,l);if(!e)return;let a=e[i];return typeof a=="function"?a.bind(e):a},set(s,i,l,a){return Reflect.has(s,i)||!e?Reflect.set(s,i,l,a):(e[i]=l,!0)},has(s,i){return Reflect.has(s,i)||!!e&&i in e}})}var gn=null;function F(){return gn}function et(t){gn=t}function Ie(t){return t[pn]||null}function ao(t,e){t[pn]=e}function Ct(t,e={disposers:[],id:Xe()}){return t?.[Qe]?t[Qe]:(t&&(t[Qe]=e),e)}function co(t){return t[Qe]}function le(t,e){let n=co(t);n||(n=Ct(t)),n.disposers.push(e)}function Re(t,e,n){t.has(e)||t.set(e,[]),t.get(e).push(n)}function ae(t,e){let n=F();et(t);try{return e()}finally{et(n)}}var tt=new Map,Ae=new Map,cn=new Map;function uo(t){let e={};for(let n of Object.keys(t)){let o=t[n];n==="children"?e[n]=o:o?.[fn]?e[n]=o():o!=null&&typeof o.get=="function"?e[n]=o:typeof o=="function"?e[n]=T(o):e[n]=x(o)}return e}function hn(t,e){if(t===e)return!0;if(t==null||e==null||typeof t!="object"||typeof e!="object")return!1;let n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(r=>hn(t[r],e[r]))}function En(t){return{id:lo,defaultValue:t}}function bn(t,e){let n=F();n&&n.contexts.set(t.id,e)}function nt(t){let e=F();return e?.contexts?.has(t.id)?e.contexts.get(t.id):t.defaultValue}function Oe(t){let e=F();if(!e){console.warn("onMount called outside of a component context");return}Re(tt,e.id,t)}function St(t){let e=F();if(!e){console.warn("onUnmount called outside of a component context");return}Re(Ae,e.id,t)}function N(t){bt(()=>{setTimeout(t,0)})}function xt(t){let e=t.componentId,n=tt.get(e);if(n){tt.delete(e);for(let o of n){let r=o();typeof r=="function"&&Re(Ae,e,r)}}}function mo(t){let e=Ae.get(t);if(e){Ae.delete(t);for(let n of e)n()}}function po(t){let e=cn.get(t);if(e){cn.delete(t);for(let n of e)n()}}function ot(t){if(!t)return;let e=Ct(t);if(e?.disposers){for(let o of e.disposers)o();e.disposers=null}let n=Ie(t);if(n&&(mo(n.componentId),po(n.componentId)),t.childNodes){let o=t.firstChild;for(;o;){let r=o.nextSibling;ot(o),o=r}}}function Te(t){return t!=null&&typeof t=="object"&&typeof t.$constructor=="function"}function fo(t){return typeof t=="function"&&typeof t.prototype?.render=="function"}function go(t,e,n){let o=Xe(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let s={...uo(e??{}),children:n},i=F(),l={disposers:[],id:o,contexts:new Map(i?.contexts)};et(l);let a;if(fo(t)){r.ClassConstructor=t;let u=new t(s);r.classInstance=u,typeof u.onMount=="function"&&Re(tt,o,()=>{u.onMount?.()}),typeof u.onUnmount=="function"&&Re(Ae,o,()=>{u.onUnmount?.()}),a=u.render()}else a=t(s);et(i);let c=ho(a);return r.element=c,Ct(c,l),c instanceof Node&&ao(c,r),c}};return r}function yn(t,e){let n=e.$constructor();n instanceof Node&&t.appendChild(n),queueMicrotask(()=>{xt(e)})}function ho(t){return t instanceof Node?t:Te(t)?t.$constructor():typeof t=="string"||typeof t=="number"?document.createTextNode(String(t)):document.createTextNode("")}var Eo={className:"class",htmlFor:"for",tabIndex:"tabindex",readOnly:"readonly",autoComplete:"autocomplete"},un=new Set(["value","defaultValue","checked","selected","indeterminate"]);function Ze(t){return t!=null&&typeof t=="object"&&typeof t.get=="function"&&!(t instanceof Node)}function f(t,e,n){if(typeof t=="function")return go(t,e||{},n);typeof t!="string"&&(n=e,e=t,t="div"),e=e||{};let o=document.createElement(t);return e.id&&o.setAttribute("id",e.id),bo(o,e),Cn(o,yo(n)),o}function yt(t,e){e instanceof DocumentFragment?t.replaceChildren(e):t.innerHTML=e??""}function bo(t,e){let n=F();for(let[o,r]of Reflect.ownKeys(e).map(s=>[s,e[s]]))if(o!=="id"){if(o=Eo[o]??o,o==="$ref"){typeof r=="function"?r(t):typeof r=="object"&&r!==null&&(r.current=t);continue}if(o==="$dangerouslySetInnerHTML"){if(Ze(r)){let s=G(()=>{ae(n,()=>{yt(t,r.get())})});le(t,s)}else if(typeof r=="function"){let s=G(()=>{ae(n,()=>{yt(t,r())})});le(t,s)}else yt(t,r);continue}if(o==="style"){if(Ze(r)){let s=G(()=>{ae(n,()=>{Object.assign(t.style,r.get())})});le(t,s)}else typeof r=="object"&&r!==null?Object.assign(t.style,r):t.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let s=o.slice(2).toLowerCase();t.addEventListener(s,r);continue}if(Ze(r)||typeof r=="function"){let s=o,i=G(()=>{ae(n,()=>{let l=typeof r=="function"?r():r.get();un.has(s)?t[s]=l??"":l==null||l===!1?t.removeAttribute(s):t.setAttribute(s,l)})});le(t,i);continue}un.has(o)||typeof o=="symbol"?t[o]=r??"":r==null?t.removeAttribute(o):t.setAttribute(o,r)}}function yo(t){return t==null?[]:Array.isArray(t)?t.flat(Number.POSITIVE_INFINITY):[t]}function Cn(t,e){for(let n of e)Co(t,n)}function Co(t,e){if(!(e==null||e===!1||e===!0)){if(e instanceof Node){t.appendChild(e);return}if(typeof e=="string"||typeof e=="number"){t.appendChild(document.createTextNode(String(e)));return}if(typeof e=="function"){mn(t,e);return}if(Te(e)){yn(t,e);return}if(Ze(e)){mn(t,()=>e.get());return}if(Array.isArray(e)){Cn(t,e);return}t.appendChild(document.createTextNode(String(e)))}}function mn(t,e){let n=F(),o=document.createComment("");t.appendChild(o);let r=null,s=G(()=>{ae(n,()=>{let i=e(),l;i instanceof Node?l=i:i==null||i===!1||i===!0?l=null:l=document.createTextNode(String(i)),r&&(ot(r),r.remove()),l&&o.after(l),r=l??null})});le(t,s)}function rt(t,e,n){let o=document.createElement("span");o.style.display="contents",o.setAttribute("data-each",Xe());let r=F(),s=[],i=new Map,l=T(()=>t()),a=G(()=>{let c=l.get(),u=c.map((E,g)=>e(E,g)),p=new Map(s.map(E=>[E.key,E])),d=[];for(let E=0;E<c.length;E++){let g=u[E],y=c[E],C=p.get(g);if(C)i.get(g).set(y),d.push(C),p.delete(g);else{let _=x(y,{equals:hn});i.set(g,_);let S={..._,set(){}},P={key:g,element:null},B;ae(r,()=>{if(B=n(S,E),B instanceof Node)P.element=B;else if(Te(B)){let qe=B.$constructor();P.element=qe instanceof Node?qe:null,queueMicrotask(()=>xt(B))}}),d.push(P)}}for(let[E,g]of p)g.element&&(ot(g.element),g.element.remove()),i.delete(E);let b=o.childNodes;for(let E=0;E<d.length;E++){let g=d[E];if(!g.element)continue;let y=b[E];y!==g.element&&o.insertBefore(g.element,y||null)}s=d});return le(o,a),o}function ue(t,e){let n=null;if(Te(e)?(n=e.$constructor(),queueMicrotask(()=>xt(e))):e instanceof Node?n=e:n=document.createTextNode(String(e)),n instanceof HTMLElement){let o=T(()=>!!t());G(()=>{n.style.display=o.get()?"":"none"})}return n}function L(t,e){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("mount: container not found");t.innerHTML="",Te(e)?yn(t,e):e instanceof Node?t.appendChild(e):t.appendChild(document.createTextNode(String(e)))}function Sn(t){if(typeof t=="string"&&(t=document.querySelector(t)),!t)throw new Error("unmount: container not found");ot(t),t.innerHTML=""}var me=class{constructor(t){this.props=t}};var So=".molecule__figure{padding:12px 6px;background-color:#f0f0f0}.molecule__figure .image{aspect-ratio:16/9;background-color:#d3d3d3}.namespace-unknown-unknowncomponent{background-color:#f0f0f0;padding:12px 0;margin-bottom:8px}.dialog[open]{background-color:#fff;border:1px solid black;border-radius:8px;box-shadow:0 0 5px #0000001a;padding:12px;display:flex;flex-flow:row wrap;justify-content:space-between;.dialog-controls{text-align:right;width:100%;.dialog-button-close{background-color:#f0f0f0;border:1px solid black;border-radius:4px;color:#000;cursor:pointer;display:inline-block;font-size:14px;margin-right:1px;padding:4px 8px;text-align:center}}.dialog-container{width:100%}}.mrakomor-tooltip{position:absolute;z-index:9100;display:flex;flex-direction:row;align-items:center;gap:2px;background:#1a1a1a;border-radius:6px;padding:4px 6px;box-shadow:0 3px 10px #00000040;pointer-events:all;white-space:nowrap}.mrakomor-tooltip__btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:4px;color:#fff;cursor:pointer;font-size:13px;font-weight:600;min-width:28px;min-height:28px;padding:0 6px;transition:background .1s}.mrakomor-tooltip__btn:hover{background:#ffffff26}.mrakomor-tooltip__btn--active{background:#ffffff40;color:#7dd3fc}.mrakomor-tooltip__separator{width:1px;height:18px;background:#fff3;margin:0 4px;flex-shrink:0}.mrakomor-tools-container,.mrakomor-content{position:relative}.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5,.mrakomor-content p{margin-top:0}.molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth=\"1\"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth=\"2\"]{margin-inline-start:3em}.molecule-list-list li[data-depth=\"3\"]{margin-inline-start:4.5em}.mrakomor-block-element{position:relative;padding-left:52px}.mrakomor-block-gutter{position:absolute;left:0;top:2px;display:flex;align-items:center;gap:2px;opacity:0;transition:opacity .15s ease;pointer-events:all;user-select:none;z-index:1}.mrakomor-block-element:hover .mrakomor-block-gutter,.mrakomor-block-element--active .mrakomor-block-gutter,.mrakomor-block-drag-active .mrakomor-block-gutter{opacity:1}.mrakomor-block-add,.mrakomor-block-drag{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:#9ca3af;cursor:pointer;font-size:18px;line-height:1;transition:background .1s,color .1s}.mrakomor-block-add:hover,.mrakomor-block-drag:hover{background:#0000000f;color:#374151}.mrakomor-block-drag{cursor:grab}.mrakomor-block-element--dragging .mrakomor-block-drag,.mrakomor-block-drag-active .mrakomor-block-drag{cursor:grabbing}.mrakomor-block-element--dragging{opacity:.5}.mrakomor-block-body{min-width:0}.mrakomor-block-drop-indicator{position:absolute;left:52px;right:0;height:2px;background:#3b82f6;border-radius:1px;pointer-events:none;z-index:2}.mrakomor-block-insert-menu{position:absolute;z-index:9200;display:flex;flex-direction:column;gap:2px;min-width:120px;background:#1a1a1a;border-radius:6px;padding:4px;box-shadow:0 3px 10px #00000040;pointer-events:all}.mrakomor-block-insert-menu__item{display:flex;align-items:center;width:100%;padding:6px 10px;border:none;border-radius:4px;background:transparent;color:#fff;cursor:pointer;font-size:13px;font-weight:600;text-align:left;transition:background .1s}.mrakomor-block-insert-menu__item:hover{background:#ffffff26}.link-toolbar{display:flex;flex-direction:column;gap:6px}.link-toolbar__row{display:flex;align-items:center;gap:4px;min-width:0}.link-toolbar__href{flex:1;min-width:0;font-size:13px;color:#1a73e8;text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px}.link-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.link-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555;&:hover{background:#f0f0f0;color:#222}}.link-toolbar__btn--danger{&:hover{color:#d32f2f;background:#fdecea}}.link-toolbar__input{flex:1;min-width:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:13px;outline:none;&:focus{border-color:#1a73e8;box-shadow:0 0 0 2px #1a73e833}}.link-toolbar__select{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 6px;font-size:13px;background:#fff;cursor:pointer}.atom-tts-voice{position:relative;border-radius:2px;display:inline-block}.atom-tts-voice:before{content:attr(data-voice-label);position:absolute;top:-1.1em;left:0;font-size:10px;line-height:1;white-space:nowrap;padding:1px 4px;border-radius:3px;pointer-events:none;font-weight:600}.tts-voice--man{background:#e8f0fe;color:#174ea6}.tts-voice--man:before{background:#1a73e8;color:#fff}.tts-voice--woman{background:#f3e8fd;color:#5e35b1}.tts-voice--woman:before{background:#7b1fa2;color:#fff}.tts-voice-toolbar{display:flex;flex-direction:column;gap:6px}.tts-voice-toolbar__row{display:flex;align-items:center;flex-wrap:wrap;gap:4px;min-width:0}.tts-voice-toolbar__voice{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:12px;background:#fff;color:#333}.tts-voice-toolbar__voice--man{border-color:#1a73e8;color:#174ea6}.tts-voice-toolbar__voice--woman{border-color:#7b1fa2;color:#5e35b1}.tts-voice-toolbar__voice--active{font-weight:600}.tts-voice-toolbar__voice--man.tts-voice-toolbar__voice--active{background:#e8f0fe}.tts-voice-toolbar__voice--woman.tts-voice-toolbar__voice--active{background:#f3e8fd}.tts-voice-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.tts-voice-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.tts-voice-toolbar__btn:hover{background:#f0f0f0;color:#222}.tts-voice-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea} ",xn=So;var xo={abortEarly:!0};function Nt(t,e){if(!e)return t;let n=t?.cause?.key?`${e}.${t.cause.key}`:`${e}`;return{message:`Error parsing key "${n}": ${t.message}`,cause:{key:n}}}function Nn(t,e,n){if(t.errors?.length)for(let o=0;o<t.errors.length;o++)e.push(Nt(t.errors[o],n))}function vt(t){return t?.abortEarly!==void 0?t:xo}var Me=t=>typeof t=="string"||t instanceof String,kt=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),_t=t=>t===!0||t===!1,ko=t=>t instanceof Date&&!Number.isNaN(t.getTime()),_o=t=>typeof t=="function",No=t=>Array.isArray(t),vn=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function Ln(t,e){let n=D(vn,{...e,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(t).map(([o,r])=>`${o}: ${r._getDescription()}`).join(", ")} })`,R(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:l}=vt(s);if(i.success===!1)return i;let a={},c=[];for(let u in t){let p=t[u]._parse(i.data[u],s);if(p.success)a[u]=p.data;else{if(p=p,l!==!1){let d=Nt(p.error,u);return{success:!1,error:d,errors:[d]}}Nn(p,c,u)}}return c.length>0?{success:!1,error:c[0],errors:c}:{success:!0,data:a}}),n}function Lt(t){return D(Me,{...t,type:"string"})}function Rt(t){return D(kt,{...t,type:"number"})}function At(t){return D(_t,{...t,type:"boolean"})}function It(t){return D(ko,{...t,type:"date"})}function Rn(t){return D(_o,{...t,type:"function"})}function An(t,e){let n=i=>t.includes(i),o=i=>`Invalid ${r} value. Expected ${t.map(l=>`"${l}"`).join(" | ")}, received "${i}".`,r="enum",s=D(n,{message:o,...e,type:r});return s._getDescription=()=>`enum(${t.map(i=>`"${i}"`).join(" | ")})`,s}function In(t,e){let n=D(No,{...e,type:"array"});return n._getDescription=()=>`array(${t._getDescription()})`,R(n,"_parse",(o,r,s)=>{let i=o(r,s),{abortEarly:l}=vt(s);if(i.success===!1)return i;let a=[],c=[];for(let u=0;u<i.data.length;u++){let p=t._parse(i.data[u],s);if(p.success)a.push(p.data);else{if(p=p,l!==!1){let d=Nt(p.error,u);return{success:!1,error:d,errors:[d]}}Nn(p,c,u)}}return c.length>0?{success:!1,error:c[0],errors:c}:{success:!0,data:a}}),n}function On(){return D(()=>!0)}function pe(t,e){return R(e,"_parse",(n,o)=>(o=t(o),n(o))),e}function Tn(t,e){return D(n=>{for(let o=0;o<t.length;o++){let r=t[o]._parse(n);if(r.success)return r}return!1},{message:n=>`Invalid union value. Expected the value to match one of the schemas:${t.map((o,r)=>` ${r+1}. ${o._getDescription()}`).join(",")} but received "${typeof n}" with value: ${vn(n)?JSON.stringify(n):`"${n}"`}`,...e,type:"union"})}function Mn(t,e){let n=D(o=>o===t,{message:o=>e?.message?typeof e.message=="function"?e.message(o):e.message:`Expected literal value "${t}", received "${o}"`,name:e?.name,type:"literal"});return n._getDescription=()=>`literal("${t}")`,n}var wn={boolean(t){let e=t?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return pe(n=>{let o;return Me(n)&&(o=n.toLowerCase()),o==="true"||o==="yes"||o==="on"||o==="1"||n===1?!0:o==="false"||o==="no"||o==="off"||o==="0"||n===0?!1:n},At({...t,message:e}))},number(t){let e=t?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return pe(n=>{if(_t(n))return Number(n);if(Me(n)){let o=n.trim();if(o==="")return n;let r=Number(o);if(Number.isFinite(r))return r}return n},Rt({...t,message:e}))},string(t){let e=t?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return pe(n=>_t(n)||kt(n)&&Number.isFinite(n)?String(n):n,Lt({...t,message:e}))},date(t){let e=t?.message??(n=>`Cannot cast "${n}" to a valid date.`);return pe(n=>{let o;return Me(n)&&(o=n.trim()),kt(n)&&Number.isFinite(n)||o?new Date(o??n):n},It({...t,message:e}))},json(t,e){let n=e?.message??(o=>`Cannot parse "${o}" as JSON.`);return R(t,"_parse",(o,r)=>{if(Me(r))try{r=JSON.parse(r)}catch{let s={message:typeof n=="function"?n(r):n};return{success:!1,error:s,errors:[s]}}return o(r)}),t}},m={object:Ln,string:Lt,number:Rt,boolean:At,date:It,function:Rn,enum:An,array:In,any:On,preprocess:pe,union:Tn,literal:Mn,coerce:{},cast:wn};function kn(t){return e=>`The value "${e}" must be type of ${t} but is type of "${typeof e}".`}function R(t,e,n){let o=t[e];t[e]=(...r)=>n(o,...r)}function D(t,{type:e="any",name:n,message:o}={}){o=o||kn(e);let r={name:n,message:o,type:e},s={_getName(){return n},_getType(){return e},_getDescription(){return this._getName()??this._getType()},_parse(i,l){let a=t(i);if(a===!0)return{success:!0,data:i};if(typeof a=="object"&&a?.success===!0)return a;let c={message:typeof o=="function"?o(i):o};return{success:!1,error:c,errors:[c]}},parse(i,l){let a=s._parse(i,l);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(i,l){return s._parse(i,l)},transform(i){return R(this,"_parse",(l,a,c)=>{let u=l(a,c);return u.success&&(u.data=i(u.data)),u}),this},optional(){return R(this,"_parse",(i,l,a)=>{let c=i(l,a);return!c.success&&l===void 0&&(c.data=void 0,c.success=!0),c}),this},nullable(){return R(this,"_parse",(i,l,a)=>{let c=i(l,a);return!c.success&&l===null&&(c.data=null,c.success=!0),c}),this},nullish(){return R(this,"_parse",(i,l,a)=>{let c=i(l,a);return!c.success&&l==null&&(c.success=!0,c.data=l),c}),this},default(i){return R(this,"_parse",(l,a,c)=>(a===void 0&&(a=typeof i=="function"?i():i),l(a,c))),this},catch(i){return R(this,"_parse",(l,a,c)=>{let u=l(a,c);return u.success?u:{success:!0,data:typeof i=="function"?i({input:a,error:u.error}):i}}),this},pipe(i){return R(this,"_parse",(l,a,c)=>{let u=l(a,c);return u.success?i._parse(u.data,c):u}),this},refine(i,{message:l,type:a}={}){return a&&(l=l||kn(a),e=a),R(this,"_parse",(c,u,p)=>{let d=c(u,p),{abortEarly:b}=vt(p);if(!d.success)return d;let E=i(d.data);if(E===!0||typeof E=="object"&&E?.success===!0)return d;let g={message:typeof l=="function"?l(u):l};return{success:!1,error:g,errors:[g]}}),this}};return _n.length>0?_n.reduce((i,l)=>l(i,t,r)??i,s):s}var _n=[];var Ot=wt(),Tt=wt(),Pn=wt(),vo=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function wt(){return Math.floor(Math.random()*16777215)}function Lo(){return Tt=(Tt+1)%16777215,Tt}function k(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=Lo(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,Ot>>16&255,Ot>>8&255,Ot&255,Pn>>8&255,Pn&255,e>>16&255,e>>8&255,e&255),o="";for(let r=0;r<n.length;r++)o+=vo[n.charCodeAt(r)];return o}var we=Symbol("block-element"),Pt=Symbol("block-element-body"),M=Symbol("selectable-element");function j(t){let e=t.startContainer;for(;e&&e[we]===void 0;)e=e.parentElement;return e}function Ro(t){if(!t)return null;let e=t.startContainer;for(e?.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e[M]===void 0;)e=e.parentElement;return e??null}function Dn(t,e){let n=document.createRange(),o=0,r=!1;n.setStart(t,0);function s(i){if(i.nodeType===Node.TEXT_NODE)o+i.length>=e?(n.setStart(i,e-o),n.collapse(!0),r=!0):o+=i.length;else for(let l of i.childNodes){if(r)break;s(l)}}s(t),Io(n)}function Bt(){return window.getSelection()}function v(){let t=Bt();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function it(){let t=v();t.collapse(!0);let e=t.startContainer,n=j(t),o=J(n),r=!1;return Array.from(o?.childNodes??[]).reduce((i,l)=>r?i:l===e||l.contains(e)?(r=!0,i):i+l.textContent.length,t.startOffset)}var ne=null;function Pe(){ne=jt()}function Dt(){ne&&Kt(ne)}function jn(){ne={start:ne.end,end:ne.end,element:ne.element},Dt()}function Ao(t,e){let n=Ro(e);return n||(J(t)??t?.childNodes?.[0]??null)}function st(t,e,n){let o=!1;return Array.from(t?.childNodes??[]).reduce((r,s)=>o?r:s===e||s.contains(e)?(o=!0,r):r+s.textContent.length,n)}function Bn(t){let e=t;for(e?.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e[M]===void 0;)e=e.parentElement;return e??null}function jt(){let t=v();if(!t)return null;let e=j(t),n=Ao(e,t);return{start:st(n,t.startContainer,t.startOffset),end:st(n,t.endContainer,t.endOffset),element:e,selectableElement:n}}function Kn(t=v()){if(!t||t.collapsed)return null;let e=fe(t.startContainer),n=fe(t.endContainer);if(!e||!n)return null;let o=Bn(t.startContainer)??J(e),r=Bn(t.endContainer)??J(n);return{startBlock:e,endBlock:n,startOffset:st(o,t.startContainer,t.startOffset),endOffset:st(r,t.endContainer,t.endOffset)}}function Kt(t){if(!t)return;let{start:e,end:n,element:o,selectableElement:r}=t,s=r?.isConnected&&r||J(o)||o?.childNodes?.[0];if(!s)return;let i=Mt(s,e),l=Mt(s,n),a=document.createRange();a.setStart(i.startContainer,i.startOffset),a.setEnd(l.endContainer,l.endOffset);let c=Bt();c.removeAllRanges(),c.addRange(a)}function Io(t){if(!t)return;let e=Bt();t.collapse(!0),e.removeAllRanges(),e.addRange(t)}function Mt(t,e){let n=document.createRange();n.selectNode(t),n.setStart(t,0);let o=0,r=[t];for(;r.length>0;){let s=r.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(o+i>=e)return n.setEnd(s,e-o),n.setStart(s,e-o),n;o+=i}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)r.push(s.childNodes[i])}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function oe(t,e){let n=Mt(t,e),o=window.getSelection();o.removeAllRanges(),o.addRange(n)}function J(t){if(!t)return null;let e=re(t);return e?.firstElementChild??e?.firstChild}function de(t){return!t||!t[we]?null:Ie(J(t))?.classInstance}function fe(t){let e=t;for(;e;){if(e[we])return e;e=e.parentElement}return null}function re(t){if(!t)return null;for(let e of t.children)if(e[Pt])return e;return null}var ge=En();var lt=class extends me{constructor(e){super(e);let{state:n,observeDOMChanges:o=!0}=e??{};this.state=n,this.element=null,this.mrakomor=nt(ge),this._stale=!1,this._observer=null,this._observeDOMChanges=o}static get NAMESPACE(){return"namespace.AbstractComponent"}static getStateSchema(){return m.object({component:m.string().default(this.NAMESPACE),properties:m.object().default({}),settings:m.object().default({})}).default({})}static getPropsSchema(){return m.object({state:this.getStateSchema(),observeDOMChanges:m.boolean().default(!0)}).default({})}parseFromHTML(e){return this.constructor.getStateSchema(e).parse()}getState(){if(this._stale){let e=this.element;return this.parseFromHTML(e)}return this.state.peek()}onMount(){this.element&&this._observeDOMChanges&&(this._observer=new MutationObserver(()=>{this._stale=!0}),this._observer.observe(this.element,{subtree:!0,characterData:!0,characterDataOldValue:!0,childList:!0,attributes:!0,attributeOldValue:!0}))}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null,this._stale=!1)}};var K=class extends lt{static get NAMESPACE(){return"namespace.block.BlockComponent"}static get LABEL(){return""}static get tooltipConfig(){return{inlineStyles:[],entityRanges:[],blockTransforms:[]}}onKeydown(e){}getFormattingTarget(e){return null}};function Oo(t,e){let n=new Set([0,e]);for(let o of t)n.add(o.offset),n.add(o.offset+o.length);return[...n].sort((o,r)=>o-r)}function $n(t,e,n){return t.filter(o=>o.offset<=e&&o.offset+o.length>=n)}function To(t,e,n,{inlineStyleComponents:o,entityRangeComponents:r}){let s=t;for(let i of e){let l=o.find(a=>a.match(i));l&&(s=f(l,{},s))}for(let i of n){let l=r.find(a=>a.match(i));l&&(s=f(l,i,s))}return s}function he(t,{inlineStyleComponents:e,entityRangeComponents:n}){let o=document.createDocumentFragment(),r=t.properties.text||"",s=t.properties.inlineStyleRanges??[],i=t.properties.entityRanges??[];if(r===""||r===`
2
+ `)return o;let l=Oo([...s,...i],r.length);for(let a=0;a<l.length-1;a+=1){let c=l[a],u=l[a+1];if(c>=u)continue;let p=r.slice(c,u),d=To(p,$n(s,c,u),$n(i,c,u),{inlineStyleComponents:e,entityRangeComponents:n});L(o,d)}return o}function z(t,e,n,{inlineStyleComponents:o,entityRangeComponents:r}){let s=n;for(let i of t){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let l=o.find(c=>c.match(i));if(l){let c=i.textContent.length;e.properties.inlineStyleRanges.push({style:l.style,offset:s,length:c}),s=z(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}let a=r.find(c=>c.match(i));if(a){let c=i.textContent.length;e.properties.entityRanges.push({...a.getStateSchema(i).parse(),offset:s,length:c}),s=z(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r});continue}s=z(i.childNodes,e,s,{inlineStyleComponents:o,entityRangeComponents:r})}return s}function $t(t,e){return{state:{...t,properties:{...e.properties,...t.properties,text:t.properties.text+e.properties.text,inlineStyleRanges:[...t.properties.inlineStyleRanges??[],...(e.properties.inlineStyleRanges??[]).map(n=>({...n,offset:n.offset+t.properties.text.length}))],entityRanges:[...t.properties.entityRanges??[],...(e.properties.entityRanges??[]).map(n=>({...n,offset:n.offset+t.properties.text.length}))]},settings:{...e.settings,...t.settings}},cursor:t.properties.text.length}}function Hn(t,{startIndex:e,endIndex:n,startOffset:o,endOffset:r}){let s=[...t],i=s[e],l=s[n],{originalLineState:a}=W(i,o),{newLineState:c}=W(l,r),{state:u,cursor:p}=$t(a,c);return s.splice(e,n-e+1,u),{content:s,cursor:p,resultIndex:e}}function W(t,e){let n=structuredClone(t),o=structuredClone(t);return n.properties.text=t.properties.text.slice(0,e),o.properties.text=t.properties.text.slice(e),n.properties.inlineStyleRanges=(t.properties.inlineStyleRanges??[]).filter(r=>r.offset<e).map(r=>({...r,length:Math.min(r.length,e-r.offset)})),o.properties.inlineStyleRanges=(t.properties.inlineStyleRanges??[]).filter(r=>r.offset+r.length>e).map(r=>({...r,offset:Math.max(0,r.offset-e),length:r.offset+r.length-Math.max(r.offset,e)})),n.properties.entityRanges=(t.properties.entityRanges??[]).filter(r=>r.offset<e).map(r=>({...r,length:Math.min(r.length,e-r.offset)})),o.properties.entityRanges=(t.properties.entityRanges??[]).filter(r=>r.offset+r.length>e).map(r=>({...r,offset:Math.max(0,r.offset-e),length:r.offset+r.length-Math.max(r.offset,e)})),o.componentId=k(),{originalLineState:n,newLineState:o}}function at(t,e){let n=document.createRange();n.selectNodeContents(t),n.setEnd(e.startContainer,e.startOffset);let o=document.createRange();return o.setStart(e.startContainer,e.startOffset),o.setEnd(e.endContainer,e.endOffset),{offset:n.toString().length,length:o.toString().length}}function Mo(t,{style:e,offset:n,length:o}){let r=t??[],s=n+o,i=r.find(l=>l.style===e&&l.offset<=n&&l.offset+l.length>=s);return i?r.filter(l=>l!==i):[...r,{style:e,offset:n,length:o}]}function wo(t,e){let n=t??[],o=e?.length??0,r=e?.offset??0,s=e?.entity?.type,i=r+o,l=n.find(a=>{let c=a.offset,u=a.offset+a.length;return r>=c&&i<=u});return l?l.entity?.type===s?n.filter(a=>a!==l):null:o===0?null:[...n,e]}function Un(t,e,{style:n,range:o}){if(!t||!e?.element||!o)return null;let r=e.read(t);if(r?.inlineStyleRanges===void 0)return null;let{offset:s,length:i}=at(e.element,o);return i===0?null:(e.write(t,{inlineStyleRanges:Mo(r.inlineStyleRanges??[],{style:n,offset:s,length:i})}),t)}function Vn(t,e,{state:n,namespace:o,range:r}){if(!t||!e?.element||!r)return null;let s=e.read(t);if(s?.entityRanges===void 0)return null;let i={...n,entity:{type:o,...n?.entity},...at(e.element,r)},l=wo(s.entityRanges??[],i);return l===null?null:(e.write(t,{entityRanges:l}),t)}var A=class t extends K{static get NAMESPACE(){return"molecule.paragraph.Paragraph"}static get LABEL(){return"P"}static get tooltipConfig(){return{inlineStyles:["BOLD","ITALIC","UNDERLINE","SUPERSCRIPT","SUBSCRIPT"],entityRanges:["atom.link.Link","atom.tts.Voice"],blockTransforms:["molecule.headline.H1","molecule.headline.H2","molecule.headline.H3","molecule.headline.H4","molecule.headline.H5"]}}constructor(e){super(e)}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(e){return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({entityRanges:m.array(m.object({entity:m.object({type:m.string(),data:m.any()}),length:m.number(),offset:m.number()})).default([]),inlineStyleRanges:m.array(m.object({length:m.number(),offset:m.number(),style:m.string()})).default([]),text:m.string().default(e?.innerText??e?.textContent??"")}).default({}),settings:m.object({}).default({})}).default({})}parseFromHTML(e){if(!e)return this.constructor.getStateSchema(e).parse();let n=structuredClone(this.constructor.getStateSchema(e).parse());return z(e.childNodes,n,0,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()}),n}_buildContent(e){return he(e,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return f("p",{className:e,"data-componentid":this.state.peek().componentId,contentEditable:!0,[M]:!0,$ref:n=>{this.element=n},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),o=n.properties?.text??"";return o===""||o===`
3
+ `?"<br>":O(()=>this._buildContent(n))}})}getFormattingTarget(e){return this.element?{element:this.element,read(n){return{inlineStyleRanges:n.properties?.inlineStyleRanges,entityRanges:n.properties?.entityRanges}},write(n,{inlineStyleRanges:o,entityRanges:r}){o!==void 0&&(n.properties.inlineStyleRanges=o),r!==void 0&&(n.properties.entityRanges=r)}}:null}onKeydown(e){if(e.key!=="Enter")return;e.preventDefault(),e.stopPropagation();let n=it(this.element),o=this.getState(),{originalLineState:r,newLineState:s}=W(o,n),i=v();this.mrakomor.command.insertBlockElement({range:i,cursor:0,newLineState:s,originalLineState:r,namespace:t.NAMESPACE})}};function Ht(){return{resolveConfig:t=>(t.blockComponents.push(A),t),resolveComponent:t=>{if(t===A.NAMESPACE)return A}}}var X=class extends K{static get NAMESPACE(){return"molecule.external.ExternalComponent"}static getStateSchema(e){return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({}).default({}),settings:m.object({}).default({})}).default({})}constructor(e){super(e),this.root=null}getState(){return this.state.peek()}onMount(){}onUnmount(){}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return f("div",{className:e,contentEditable:!1,style:"position: relative;",$ref:this.element,"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[f("div",{$ref:o=>{this.root=o},style:"display: block;",contentEditable:!1}),f("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:!0,[M]:!0},document.createTextNode("\xA0"))])}onKeydown(e){if(e.key!=="Backspace"&&e.key!=="ArrowUp"&&e.key!=="ArrowDown"&&(e.preventDefault(),e.stopPropagation()),e.key==="Enter"){let n=v();this.mrakomor.command.insertBlockElement({range:n,cursor:0,newLineState:this.mrakomor.normalizeComponentState(A.getStateSchema().parse({})),namespace:A.NAMESPACE})}}};var $=class extends K{constructor(e){super(e),this._level=1}static get tooltipConfig(){return{inlineStyles:[],entityRanges:[],blockTransforms:["molecule.paragraph.Paragraph","molecule.headline.H2","molecule.headline.H3","molecule.headline.H4","molecule.headline.H5"]}}static getStateSchema(e){return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({text:m.string().default(e?.textContent??e?.innerText??"")}).default({}),settings:m.object({}).default({})}).default({})}parseFromHTML(e){return e?structuredClone(this.constructor.getStateSchema(e).parse()):this.constructor.getStateSchema(e).parse()}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return f(`h${this._level}`,{className:e,"data-componentid":this.state.peek().componentId,contentEditable:!0,[M]:!0,$ref:n=>{this.element=n},$dangerouslySetInnerHTML:()=>{let o=this.state.get().properties?.text??"";return o===""||o===`
4
+ `?"<br>":o}})}onKeydown(e){if(e.key!=="Enter")return;e.preventDefault(),e.stopPropagation();let n=it(this.element),o=this.getState(),{originalLineState:r,newLineState:s}=W(o,n),i=v();this.mrakomor.command.insertBlockElement({range:i,cursor:0,newLineState:s,originalLineState:r,namespace:A.NAMESPACE})}},Be=class extends ${static get NAMESPACE(){return"molecule.headline.H1"}static get LABEL(){return"H1"}constructor(e){super(e),this._level=1}},De=class extends ${static get NAMESPACE(){return"molecule.headline.H2"}static get LABEL(){return"H2"}constructor(e){super(e),this._level=2}},je=class extends ${static get NAMESPACE(){return"molecule.headline.H3"}static get LABEL(){return"H3"}constructor(e){super(e),this._level=3}},Ke=class extends ${static get NAMESPACE(){return"molecule.headline.H4"}static get LABEL(){return"H4"}constructor(e){super(e),this._level=4}},$e=class extends ${static get NAMESPACE(){return"molecule.headline.H5"}static get LABEL(){return"H5"}constructor(e){super(e),this._level=5}};function Po(){return{resolveConfig:t=>(t.blockComponents.push(Be,De,je,Ke,$e),t),resolveComponent:t=>{if(t===Be.NAMESPACE)return Be;if(t===De.NAMESPACE)return De;if(t===je.NAMESPACE)return je;if(t===Ke.NAMESPACE)return Ke;if(t===$e.NAMESPACE)return $e}}}var He=class extends X{static get NAMESPACE(){return"namespace.unknown.UnknownComponent"}onMount(){let e=f("div",{style:"user-select: none;",contentEditable:!1},()=>`Unknown component: ${this.state.get().component}`);L(this.root,e)}onUnmount(){this.root.innerHTML=""}};function Gn({mrakomor:t}){let e=t.get();return bn(ge,e),Oe(()=>{e._onMount()}),St(()=>{e._onUnmount()}),f("div",{id:e._id,className:"mrakomor-editor",contentEditable:!0},[f("div",{className:"mrakomor-tools-container",style:{width:"100%",height:"100%"}}),f("div",{className:"mrakomor-content",style:{contenteditable:!0,spellcheck:!0,outline:"none"}},[rt(()=>e._getContentState(),n=>n.componentId,(n,o)=>f(()=>{let r;Oe(()=>{r.getNodeComponent=()=>Ie(J(r)),e._setBlockElement(r,o)}),St(()=>{e._removeBlockElement(r)});let s=e.resolveComponent(n.get().component,n),i=e.wrapBlockElement(s);return f("div",{className:"mrakomor-block-element",[we]:!0,$ref:l=>{r=l}},i)}))])])}var Ee=class extends me{static get nodeName(){return"span"}static get NAMESPACE(){return"namespace.EntityRangeElement"}static match(e){return e?.nodeName===this.nodeName.toUpperCase()||e?.entity?.type===this.NAMESPACE}static getStateSchema(e){return m.any()}constructor(e){super(e),this.mrakomor=nt(ge),this.element=ce(null)}render(){return f(this.constructor.nodeName,{},this.props.children)}};var Bo='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';var Do='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';var se=class extends Ee{static get nodeName(){return"a"}static get NAMESPACE(){return"atom.link.Link"}static getStateSchema(e){let n;if(e&&e.getAttribute("data-state"))try{n=JSON.parse(e.getAttribute("data-state"))}catch{}return m.object({entity:m.object({type:m.string().default(this.NAMESPACE),data:m.object({href:m.string().default(n?.entity?.data?.href??e?.href??""),target:m.string().default(n?.entity?.data?.target??e?.target??"")}).default({})}).default({}),length:m.number().default(n?.length??0),offset:m.number().default(n?.offset??0)}).default({})}constructor(e){super(e),this.input=ce(n=>N(()=>{n.focus()}))}#e({entity:e,length:n,offset:o}){return f("div",{className:"link-toolbar"},[f("div",{className:"link-toolbar__row",style:{display:"flex"}},[f("button",{className:"link-toolbar__btn",title:"Copy URL",$dangerouslySetInnerHTML:Bo,onClick:()=>navigator.clipboard?.writeText(e.peek()?.data?.href??"")}),f("input",{type:"text",$ref:this.input,value:e.peek()?.data?.href??"",defaultValue:e.peek()?.data?.href??"",onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),r.stopPropagation(),this.mrakomor.command.closeDialog())},onInput:r=>{let s=r.currentTarget.value;e.set({...e.peek(),data:{...e.peek()?.data,href:s}})}}),f("select",{value:e.peek()?.data?.target??"",onChange:r=>{e.set({...e.peek(),data:{...e.peek()?.data,target:r.currentTarget.value}})}},[f("option",{value:"",selected:e.peek()?.data?.target===""},""),f("option",{value:"_self",selected:e.peek()?.data?.target==="_self"},"_self"),f("option",{value:"_blank",selected:e.peek()?.data?.target==="_blank"},"_blank"),f("option",{value:"_parent",selected:e.peek()?.data?.target==="_parent"},"_parent"),f("option",{value:"_top",selected:e.peek()?.data?.target==="_top"},"_top")]),f("span",{className:"link-toolbar__sep"}),f("button",{className:"link-toolbar__btn link-toolbar__btn--danger",title:"Remove link",$dangerouslySetInnerHTML:Do,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:e.peek(),length:n.peek(),offset:o.peek()},blockElement:fe(this.element)})}})])])}onMount(){let{entity:e}=this.props;e.peek()?.data?.href||this.mrakomor.command.openDialog({element:this.element,children:this.#e(this.props)})}render(){let{entity:e,length:n,offset:o,children:r}=this.props;return f("a",{href:()=>e.get()?.data?.href??"",target:()=>e.get()?.data?.target||null,$ref:this.element,onClick:s=>{s.ctrlKey||s.metaKey||N(()=>{Pe(),this.mrakomor.command.openDialog({element:this.element,children:this.#e({entity:e,length:n,offset:o})})})},"data-state":()=>JSON.stringify({entity:e.get(),length:n.get(),offset:o.get()})},r)}};function Ut({mrakomor:t}){return{resolveConfig:e=>(e.entityRanges.push(se),e),resolveComponent:e=>{if(e===se.NAMESPACE)return se},onKeyDown(e){e.key==="k"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.stopPropagation(),t.command.insertEntityRange({namespace:se.NAMESPACE}))}}}var Q=class extends ${static getStateSchema(e){return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({text:m.string().default(e?.textContent??e?.innerText??""),entityRanges:m.array(m.object({entity:m.object({type:m.string(),data:m.any()}),length:m.number(),offset:m.number()})).transform(n=>n.filter(o=>o.entity.type==="atom.tts.Voice")).default([])}).default({}),settings:m.object({}).default({})}).default({})}getInlineStyleComponents(){return[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(e){let n=super.parseFromHTML(e);return e&&z(e.childNodes,n,0,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()}),n}_buildContent(e){return he(e,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}getFormattingTarget(e){return this.element?{element:this.element,read(n){return{inlineStyleRanges:n.properties?.inlineStyleRanges,entityRanges:n.properties?.entityRanges}},write(n,{inlineStyleRanges:o,entityRanges:r}){o!==void 0&&(n.properties.inlineStyleRanges=o),r!==void 0&&(n.properties.entityRanges=r)}}:null}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return f(`h${this._level}`,{className:e,"data-componentid":this.state.peek().componentId,contentEditable:!0,[M]:!0,$ref:n=>{this.element=n},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),o=n.properties?.text??"";return o===""||o===`
5
+ `?"<br>":O(()=>this._buildContent(n))}})}},Ue=class extends Q{static get NAMESPACE(){return"molecule.headline.H1"}static get LABEL(){return"H1"}constructor(e){super(e),this._level=1}},Ve=class extends Q{static get NAMESPACE(){return"molecule.headline.H2"}static get LABEL(){return"H2"}constructor(e){super(e),this._level=2}},Ge=class extends Q{static get NAMESPACE(){return"molecule.headline.H3"}static get LABEL(){return"H3"}constructor(e){super(e),this._level=3}},Fe=class extends Q{static get NAMESPACE(){return"molecule.headline.H4"}static get LABEL(){return"H4"}constructor(e){super(e),this._level=4}},ze=class extends Q{static get NAMESPACE(){return"molecule.headline.H5"}static get LABEL(){return"H5"}constructor(e){super(e),this._level=5}};function Vt(){return{resolveConfig:t=>(t.blockComponents.push(Ue,Ve,Ge,Fe,ze),t),resolveComponent:t=>{if(t===Ue.NAMESPACE)return Ue;if(t===Ve.NAMESPACE)return Ve;if(t===Ge.NAMESPACE)return Ge;if(t===Fe.NAMESPACE)return Fe;if(t===ze.NAMESPACE)return ze}}}var be=class extends A{static getStateSchema(e){return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({entityRanges:m.array(m.object({entity:m.object({type:m.string(),data:m.any()}),length:m.number(),offset:m.number()})).transform(n=>n.filter(o=>o.entity.type==="atom.tts.Voice")).default([]),inlineStyleRanges:m.preprocess(()=>[],m.array()).default([]),text:m.string().default(e?.innerText??e?.textContent??"")}).default({}),settings:m.object({}).default({})}).default({})}getInlineStyleComponents(){return[]}};function jo(){return{resolveConfig:t=>(t.blockComponents.push(be),t),resolveComponent:t=>{if(t===be.NAMESPACE)return be}}}var Gt=[{id:"Jarda",label:"Voice Jarda",gender:"man"},{id:"Pavel",label:"Voice Pavel",gender:"man"},{id:"Radek",label:"Voice Radek",gender:"man"},{id:"Magda",label:"Voice Magda",gender:"woman"},{id:"Marketa",label:"Voice Marketa",gender:"woman"},{id:"Silva",label:"Voice Silva",gender:"woman"}],Ko='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';function Fn(t){return Gt.find(e=>e.id===t)??Gt[0]}var ye=class extends Ee{static get NAMESPACE(){return"atom.tts.Voice"}static get LABEL(){return"VOICE"}static match(e){return e?.entity?.type===this.NAMESPACE||e?.nodeName==="SPAN"&&e?.getAttribute?.("data-entity-type")===this.NAMESPACE}static getStateSchema(e){let n;if(e?.getAttribute?.("data-state"))try{n=JSON.parse(e.getAttribute("data-state"))}catch{}let o=n?.entity?.data?.voice??e?.getAttribute?.("data-voice")??"";return m.object({entity:m.object({type:m.string().default(this.NAMESPACE),data:m.object({voice:m.string().default(o)}).default({})}).default({}),length:m.number().default(n?.length??0),offset:m.number().default(n?.offset??0)}).default({})}#e({entity:e,length:n,offset:o}){let r=e.peek()?.data?.voice??"";return f("div",{className:"tts-voice-toolbar"},[f("div",{className:"tts-voice-toolbar__row"},[...Gt.map(s=>f("button",{type:"button",className:`tts-voice-toolbar__voice tts-voice-toolbar__voice--${s.gender}${r===s.id?" tts-voice-toolbar__voice--active":""}`,title:s.label,onClick:()=>{e.set({...e.peek(),data:{voice:s.id}}),this.mrakomor.command.closeDialog()}},s.label)),f("span",{className:"tts-voice-toolbar__sep"}),f("button",{type:"button",className:"tts-voice-toolbar__btn tts-voice-toolbar__btn--danger",title:"Remove TTS voice",$dangerouslySetInnerHTML:Ko,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:e.peek(),length:n.peek(),offset:o.peek()},blockElement:fe(this.element)})}})])])}#o(e){this.mrakomor.command.openDialog({element:this.element,children:this.#e(e)})}onMount(){let{entity:e}=this.props;e.peek()?.data?.voice||this.#o(this.props)}render(){let{entity:e,length:n,offset:o,children:r}=this.props;return f("span",{className:()=>{let s=e.get()?.data?.voice??"";return`atom-tts-voice tts-voice--${Fn(s||"man1").gender}`},"data-entity-type":this.constructor.NAMESPACE,"data-voice":()=>e.get()?.data?.voice??"","data-voice-label":()=>{let s=e.get()?.data?.voice??"";return s?Fn(s).label:""},$ref:this.element,onClick:s=>{s.preventDefault(),this.#o({entity:e,length:n,offset:o})},"data-state":()=>JSON.stringify({entity:e.get(),length:n.get(),offset:o.get()})},r)}};function Ft(){return{resolveConfig:t=>(t.entityRanges.push(ye),t),resolveComponent:t=>{if(t===ye.NAMESPACE)return ye}}}var w=class extends me{static get nodeName(){return"span"}static get style(){return"SPAN"}static match(e){return e.nodeName===this.nodeName.toUpperCase()||e.style===this.style}getState(){return{style:this.constructor.style}}render(){return f(this.constructor.nodeName,{},this.props.children)}};var Ce=class extends w{static get nodeName(){return"b"}static get style(){return"BOLD"}static get LABEL(){return f("b",{},"B")}static match(e){return e.nodeName==="strong"?!0:super.match(e)}};var Se=class extends w{static get nodeName(){return"i"}static get style(){return"ITALIC"}static get LABEL(){return f("i",{},"I")}};var xe=class extends w{static get nodeName(){return"u"}static get style(){return"UNDERLINE"}static get LABEL(){return f("u",{},"U")}};var ke=class extends w{static get nodeName(){return"sup"}static get style(){return"SUPERSCRIPT"}static get LABEL(){return f("sup",{},"Sup")}};var _e=class extends w{static get nodeName(){return"sub"}static get style(){return"SUBSCRIPT"}static get LABEL(){return f("sub",{},"Sub")}};var H=Symbol("result-key"),ct=Symbol("stopped-event");function zn(t,e){let n=!!e.name,o=e[H]||"result",r=o.includes("."),s={error:null,context:{},[H]:o,...e,[o]:n?void 0:ie(e,o),name:t,[ct]:!1,defaultPrevented:!1};return r&&($o(s,o),s[o]=n?void 0:ie(e,o)),s.stopPropagation=()=>{s[ct]=!0},s.preventDefault=()=>{s.defaultPrevented=!0},s}function ie(t,e){return e===""?t:e.split(".").reduce((o,r)=>o?.[r]??void 0,t)}function zt(t,e,n){let o=e.split("."),r=o.pop(),s=ie(t,o.join("."));return s[r]=n}function $o(t,e){let n=e.split(".");n.pop(),n.reduce((o,r)=>o[r]=o[r]??{},t)}var Ye=class{constructor({logger:e,debug:n}={}){this._logger=e??console,this._debug=n??!1,this._events=new Map,this.addListener=this.on,this.removeListener=this.off}emit(e,n={}){let o=this.listeners(e),r=zn(e,n),s=null,i=null;this._debug&&(typeof this._debug=="function"?this._debug(e,r):this._logger.debug(`Event name: ${e}, event: ${r}`));for(let l of o){if(s&&(s=s.then(a=>(zt(r,r[H],a??ie(r,r[H])),r[ct]?ie(r,r[H]):l(r)))),!s){if(r[ct])return r;i=l(r)}i instanceof Promise&&!s?s=i:zt(r,r[H],i??ie(r,r[H]))}return s?s.then(l=>(zt(r,r[H],l??ie(r,r[H])),r)):r}emitParallel(e,n={}){let o=this.listeners(e),r=zn(e,n);return Promise.all(o.map(async s=>await s(r))).then(s=>(r[r[H]]=s,r)).catch(s=>{throw r.error=s,s})}listeners(e){return this._events.has(e)?[...this._events.get(e)]:[]}removeAllListeners(e){return e?this.listeners(e).forEach(n=>this.off(e,n)):Array.from(this._events.keys()).forEach(n=>this.removeAllListeners(n))}_addListener(e,n,o){return this._events.has(e)||this._events.set(e,[]),this._events.get(e)[o](n),()=>{this.off(e,n)}}on(e,n){if(typeof n!="function")throw new TypeError("The listener must be a function");return this._addListener(e,n,"push")}prependListener(e,n){return this._addListener(e,n,"unshift")}_addListenerOnce(e,n,o){let r=this[o](e,s=>(r(),n(s)))}once(e,n){return this._addListenerOnce(e,n,"on")}prependOnceListener(e,n){return this._addListenerOnce(e,n,"prependListener")}off(e,n){if(this._events.has(e)){let o=this._events.get(e),r=o.indexOf(n);o.splice(r,1)}}};var xi=new Ye,h={INSERT_BLOCK_ELEMENT:"insert-block-component",REPLACE_BLOCK_ELEMENT:"replace-block-component",REMOVE_BLOCK_ELEMENT:"remove-block-component",MERGE_BLOCK_ELEMENT:"merge-block-component",INSERT_ENTITY_RANGE:"insert-entity-range",REMOVE_ENTITY_RANGE:"remove-entity-range",INSERT_INLINE_STYLE_RANGE:"insert-inline-style-range",REMOVE_INLINE_STYLE_RANGE:"remove-inline-style-range",KEYDOWN:"input:keydown",CLICK:"input:click",SELECTION_CHANGE:"input:selection-change",OPEN_TOOLTIP:"open-tooltip",CLOSE_TOOLTIP:"close-tooltip",TRANSFORM_BLOCK_ELEMENT:"transform-block-element",MOVE_BLOCK_ELEMENT:"move-block-element",TOOLBAR:"toolbar"};function Yn(){let t=new Ye;return{emitter:t,command:{insertBlockElement(e,n){t.emit(h.INSERT_BLOCK_ELEMENT,{...e,options:n})},replaceBlockElement(e,n){t.emit(h.REPLACE_BLOCK_ELEMENT,{...e,options:n})},removeBlockElement(e,n){t.emit(h.REMOVE_BLOCK_ELEMENT,{...e,options:n})},mergeBlockElement(e,n){t.emit(h.MERGE_BLOCK_ELEMENT,{...e,options:n})},insertEntityRange(e,n){t.emit(h.INSERT_ENTITY_RANGE,{...e,options:n})},removeEntityRange(e,n){t.emit(h.REMOVE_ENTITY_RANGE,{...e,options:n})},insertInlineStyleRange(e,n){t.emit(h.INSERT_INLINE_STYLE_RANGE,{...e,options:n})},removeInlineStyleRange(e,n){t.emit(h.REMOVE_INLINE_STYLE_RANGE,{...e,options:n})},openTooltip(e,n){t.emit(h.OPEN_TOOLTIP,{...e,options:n})},closeTooltip(e){t.emit(h.CLOSE_TOOLTIP,{options:e})},transformBlockElement(e,n){t.emit(h.TRANSFORM_BLOCK_ELEMENT,{...e,options:n})},moveBlockElement(e,n){t.emit(h.MOVE_BLOCK_ELEMENT,{...e,options:n})},toolbar({open:e,posX:n,posY:o}){t.emit(h.TOOLBAR,{open:e,posX:n,posY:o})}}}}var qn="mrakomor.dialog.Dialog";function ut({open:t,positionX:e,positionY:n,block:o,dialogRef:r}){let s=T(()=>({position:"absolute",zIndex:"9000",top:`${n.get()}px`,left:`${e.get()}px`,background:"#fff",border:"1px solid #ccc",borderRadius:"4px",padding:"8px 10px",boxShadow:"0 2px 8px rgba(0,0,0,.15)",minWidth:"220px"}));return ue(()=>t.get(),f("div",{className:"mrakomor-dialog-container",contenteditable:!1,style:s,$ref:r},()=>o.get()))}ut.NAMESPACE=qn;function Yt({mrakomor:t}){let e=null,n=x(!1),o=x(0),r=x(0),s=x(null),i=null,l=null,a=null,c=null,u=null,p=null;function d(){n.set(!1),jn(),i=null}return{resolveComponent(b){if(b===qn)return ut},registerEvents(){h.OPEN_DIALOG="open-dialog",h.CLOSE_DIALOG="close-dialog"},registerCommands(b){b.command.openDialog=(E,g)=>{b.emitter.emit(h.OPEN_DIALOG,{...E,options:g})},b.command.closeDialog=()=>{console.log("CLOSE_DIALOG",h.CLOSE_DIALOG),b.emitter.emit(h.CLOSE_DIALOG)}},registerHandlers(){a=t.emitter.on(h.OPEN_DIALOG,({children:b,element:E})=>{s.set(b??f("div",{},"Empty dialog")),n.set(!0),i=E,N(()=>{let y=t.getRoot().getBoundingClientRect(),C=i.getBoundingClientRect(),_=l?l.offsetHeight:40;o.set(C.left-y.left),r.set(C.top-y.top-_-12)})}),c=t.emitter.on(h.CLOSE_DIALOG,d),u=t.emitter.on(h.KEYDOWN,b=>{b.key==="Escape"&&n.peek()===!0&&t.command.closeDialog()}),p=t.emitter.on(h.CLICK,b=>{n.peek()===!0&&l&&!l.contains(b.target)&&i&&!i.contains(b.target)&&d()})},onMount(){let b=t.getRoot()?.querySelector(".mrakomor-tools-container");if(!b)return;let E=document.createElement("div");E.className="mrakomor-dialog-plugin-container",b.append(E),e=L(E,f(ut,{open:n,positionX:o,positionY:r,block:s,dialogRef:g=>{l=g}}))},onUnmount(){e?.(),a?.(),c?.(),u?.(),p?.(),e=null,a=null,c=null,u=null,p=null}}}function Jn({mrakomor:t,open:e,tooltipElement:n}){let o=x(0),r=x(0),s=x([]),i=null,l=null;function a(){e.set(!1),i=null,l=null}Oe(()=>{let u=t.emitter.on(h.OPEN_TOOLTIP,({element:E,actions:g})=>{i=E,l=jt(),s.set(g??[]),e.set(!0),N(()=>{let C=t.getRoot().getBoundingClientRect(),_=E.getBoundingClientRect(),S=n?n.offsetHeight:40;o.set(_.left-C.left),r.set(_.top-C.top-S-12)})}),p=t.emitter.on(h.CLOSE_TOOLTIP,a),d=t.emitter.on(h.KEYDOWN,E=>{e.peek()===!0&&a()}),b=t.emitter.on(h.CLICK,E=>{e.peek()===!0&&n.current&&!n.current.contains(E.target)&&i&&!i.contains(E.target)&&a()});return()=>{u(),p(),d(),b()}});let c=T(()=>({left:`${o.get()}px`,top:`${r.get()}px`}));return ue(()=>e.get(),f("div",{className:"mrakomor-tooltip",contenteditable:!1,style:c,$ref:n},()=>Ho(s.get(),t,l)))}function Ho(t,e,n){if(!t.length)return null;let o=null,r=[];for(let s of t){o!==null&&s.group!==o&&r.push(f("span",{className:"mrakomor-tooltip__separator"})),o=s.group;let i=s.label,l=typeof i=="string"?i:typeof i=="function"?f(i,{}):i;r.push(f("button",{type:"button",className:["mrakomor-tooltip__btn",s.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:s.title??"",onClick:a=>{a.preventDefault(),Kt(n),s.onAction(e)}},l))}return f("span",{style:"display: contents"},r)}function qt({mrakomor:t}){let e=null,n=!1,o=x(!1),r=ce(null);function s(u){let p=t.getConfig(),d=p.inlineStyles,b=p.entityRanges,E=p.blockComponents;return{inlineStyles:d,entityRanges:b,blockTransforms:E}}function i(u,p,d,b,E){let g=[],y=t.getConfig()?.inlineStyles??[],C=t.getConfig()?.entityRanges??[],_=E?.read?.(p)??{inlineStyleRanges:p?.properties?.inlineStyleRanges,entityRanges:p?.properties?.entityRanges},S=E?.element??d,P=_?.inlineStyleRanges??[],{offset:B,length:qe}=at(S,b),no=B+qe;for(let ee of u.inlineStyles){let te=typeof ee=="string"?ee:ee.style,Y=y.find(q=>q.style===te);if(!Y)continue;let Ne=P.some(q=>q.style===te&&q.offset<no&&q.offset+q.length>B);g.push({label:Y.LABEL??te,title:te.charAt(0)+te.slice(1).toLowerCase(),group:"inline",active:()=>Ne,onAction:q=>{Pe(),q.command.insertInlineStyleRange({style:Y.style}),N(()=>{Dt()})}})}for(let ee of u.entityRanges){let te=typeof ee=="string"?ee:ee.NAMESPACE,Y=C.find(Ne=>Ne.NAMESPACE===te);Y&&g.push({label:Y.LABEL??"\u{1F517}",title:Y.NAMESPACE,group:"inline",active:()=>!1,onAction:Ne=>{Pe(),Ne.command.insertEntityRange({namespace:Y.NAMESPACE,blockElement:d})}})}return g}function l(u){return{label:u.LABEL??u.NAMESPACE,title:u.LABEL??u.NAMESPACE,group:"transform",active:()=>!0,onAction:()=>{}}}function a(u,p,d){let b=[];for(let E of u.blockTransforms){let g=typeof E=="string"?E:E.NAMESPACE;if(g===d.NAMESPACE)continue;let y=t.resolveComponentConstructor(g);y&&b.push({label:y.LABEL??g,title:`Convert to ${y.LABEL??g}`,group:"transform",active:()=>!1,onAction:C=>{C.command.transformBlockElement({blockElement:p,namespace:g})}})}return b}function c(){if(n)return;let u=window.getSelection(),p=t.getRoot();if(!u||u.rangeCount===0){t.command.closeTooltip();return}let d=u.getRangeAt(0);if(!p.contains(d.commonAncestorContainer)){t.command.closeTooltip();return}if(d.startContainer===r.current&&o.peek()===!0)return;let b=j(d);if(!b){t.command.closeTooltip();return}let E=de(b);if(!E){t.command.closeTooltip();return}let g=E.constructor,y=s(g),C=E.getState(),_=E.getFormattingTarget?.(d)??null,S;if(!d.collapsed){if(S=[l(g),...a(y,b,g),...i(y,C,b,d,_)],S.length===0){t.command.closeTooltip();return}t.command.openTooltip({element:b,actions:S})}}return{registerCommands(u){u.command.openTooltip=(p,d)=>{console.trace("OPEN_TOOLTIP"),u.emitter.emit(h.OPEN_TOOLTIP,{...p,options:d})},u.command.closeTooltip=p=>{u.emitter.emit(h.CLOSE_TOOLTIP,{options:p})}},registerListeners(){t.emitter.on(h.SELECTION_CHANGE,c),h.OPEN_DIALOG&&t.emitter.on(h.OPEN_DIALOG,()=>{n=!0,o.peek()===!0&&t.command.closeTooltip()}),h.CLOSE_DIALOG&&t.emitter.on(h.CLOSE_DIALOG,()=>{n=!1})},onMount(){let u=t.getRoot().querySelector(".mrakomor-tools-container");if(!u)return;let p=document.createElement("div");p.className="mrakomor-tooltip-plugin-container",u.append(p),L(p,f(Jn,{mrakomor:dn(t),tooltipElement:r,open:o}))},onUnmount(){t.emitter.off(h.SELECTION_CHANGE,c)}}}var Uo=f("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0},[f("circle",{cx:4,cy:3,r:1.2}),f("circle",{cx:10,cy:3,r:1.2}),f("circle",{cx:4,cy:7,r:1.2}),f("circle",{cx:10,cy:7,r:1.2}),f("circle",{cx:4,cy:11,r:1.2}),f("circle",{cx:10,cy:11,r:1.2})]);function Vo(t,e){for(let n=0;n<e.length;n++){let o=e[n].getBoundingClientRect();if(t<o.top+o.height/2)return n}return e.length}function Go(t,e,n,o){if(!t||!e)return;if(n>=o.length){let l=o[o.length-1];if(!l){t.style.display="none";return}let a=e.getBoundingClientRect(),c=l.getBoundingClientRect();t.style.display="block",t.style.top=`${c.bottom-a.top}px`;return}let r=o[n],s=e.getBoundingClientRect(),i=r.getBoundingClientRect();t.style.display="block",t.style.top=`${i.top-s.top}px`}function Wn(){return f("div",{className:"mrakomor-block-gutter",contentEditable:!1},[f("button",{type:"button",className:"mrakomor-block-add","aria-label":"Insert block",contentEditable:!1},"+"),f("button",{type:"button",className:"mrakomor-block-drag","aria-label":"Drag to reorder",contentEditable:!1},Uo)])}function Jt({mrakomor:t}){let e=null,n=null,o=null,r=null;function s(){n?.blockElement&&n.blockElement.classList.remove("mrakomor-block-element--active","mrakomor-block-element--dragging"),n?.handle&&n.handle.releasePointerCapture?.(n.pointerId),e&&(e.style.display="none"),document.body.classList.remove("mrakomor-block-drag-active"),n=null}function i(p){if(!n||p.pointerId!==n.pointerId)return;let d=t.getRoot()?.querySelector(".mrakomor-content");if(!d)return;let b=[...d.querySelectorAll(".mrakomor-block-element")],E=Vo(p.clientY,b);n.targetIndex=E,Go(e,d,E,b)}function l(p){if(!n||p.pointerId!==n.pointerId)return;let{blockElement:d,targetIndex:b}=n;s(),t.command.moveBlockElement({blockElement:d,targetIndex:b})}function a(p){let d=p.target.closest?.(".mrakomor-block-drag");if(!d)return;p.preventDefault(),p.stopPropagation();let b=d.closest(".mrakomor-block-element");if(!b)return;n&&s();let E=t._getBlockElementIndex(b);if(E===-1)return;let g=p.pointerId??1;d.setPointerCapture?.(g),b.classList.add("mrakomor-block-element--active","mrakomor-block-element--dragging"),document.body.classList.add("mrakomor-block-drag-active"),n={blockElement:b,pointerId:g,handle:d,fromIndex:E,targetIndex:E}}function c(p){i({pointerId:n?.pointerId??1,clientY:p.clientY})}function u(p){l({pointerId:n?.pointerId??1})}return{wrapBlockElement(p){return[f(Wn),f("div",{className:"mrakomor-block-body",[Pt]:!0},p)]},registerHandlers(){o=t.emitter.on(h.CLICK,p=>{let d=p.target?.closest?.(".mrakomor-block-add");if(!d)return;p.preventDefault?.(),p.stopPropagation?.();let b=d.closest(".mrakomor-block-element");b&&t.command.openBlockInsertMenu({blockElement:b,anchorRect:d.getBoundingClientRect()})}),r=t.emitter.on(h.KEYDOWN,p=>{p.key==="Escape"&&n&&s()})},onMount(){document.addEventListener("pointerdown",a,!0),document.addEventListener("mousedown",a,!0);let p=t.getRoot()?.querySelector(".mrakomor-content");p&&(e=document.createElement("div"),e.className="mrakomor-block-drop-indicator",e.style.display="none",p.append(e)),document.addEventListener("pointermove",i),document.addEventListener("pointerup",l),document.addEventListener("pointercancel",l),document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},onUnmount(){s(),e?.remove(),e=null,document.removeEventListener("pointerdown",a,!0),document.removeEventListener("mousedown",a,!0),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",l),document.removeEventListener("pointercancel",l),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u),o?.(),r?.(),o=null,r=null}}}var Fo=["molecule.paragraph.Paragraph","molecule.headline.H1","molecule.headline.H2","molecule.headline.H3","molecule.headline.H4","molecule.headline.H5","molecule.figure.Figure"];function zo(t){let e=t.getConfig()?.insertableBlocks??[],n=(t.getConfig()?.blockComponents??[]).map(l=>l.NAMESPACE),o=t.getConfig()?.blockInsertVariants??[],r=new Set(o.map(l=>l.namespace)),s=new Set,i=[];for(let l of o)i.push({namespace:l.namespace,label:l.label,settings:l.settings});for(let l of[...e,...n]){if(s.has(l)||r.has(l))continue;s.add(l);let a=t.resolveComponentConstructor(l);a&&i.push({namespace:l,label:a.LABEL??l})}return i}function Yo(t){if(!t.length)return null;let e=t.map(n=>f("button",{type:"button",className:"mrakomor-block-insert-menu__item",title:n.label,"data-namespace":n.namespace,"data-settings":n.settings?JSON.stringify(n.settings):void 0},n.label));return f("span",{style:"display: contents"},e)}function Xn({open:t,positionX:e,positionY:n,items:o,menuRef:r}){let s=T(()=>({left:`${e.get()}px`,top:`${n.get()}px`}));return ue(()=>t.get(),f("div",{className:"mrakomor-block-insert-menu",contenteditable:!1,style:s,$ref:r},()=>Yo(o.get())))}function Wt({mrakomor:t}){let e=null,n=null,o=null,r=x(!1),s=x(0),i=x(0),l=x([]),a=null,c=null,u=null,p=null,d=null;function b(){r.set(!1),o&&o.classList.remove("mrakomor-block-element--active"),o=null}function E(g){let y=g.dataset.namespace;if(y)return y;let C=g.textContent.trim();return(t.getConfig()?.insertableBlocks??[]).find(S=>(t.resolveComponentConstructor(S)?.LABEL??S)===C)}return{resolveConfig(g){return{...g,insertableBlocks:g.insertableBlocks??Fo}},registerEvents(){h.OPEN_BLOCK_INSERT_MENU="open-block-insert-menu",h.CLOSE_BLOCK_INSERT_MENU="close-block-insert-menu"},registerCommands(g){g.command.openBlockInsertMenu=({blockElement:y,anchorRect:C})=>{g.emitter.emit(h.OPEN_BLOCK_INSERT_MENU,{blockElement:y,anchorRect:C})},g.command.closeBlockInsertMenu=()=>{g.emitter.emit(h.CLOSE_BLOCK_INSERT_MENU)}},registerHandlers(){a=t.emitter.on(h.OPEN_BLOCK_INSERT_MENU,({blockElement:g,anchorRect:y})=>{o&&o.classList.remove("mrakomor-block-element--active"),o=g,g?.classList.add("mrakomor-block-element--active"),l.set(zo(t)),r.set(!0),N(()=>{let _=t.getRoot().getBoundingClientRect(),S=n?.offsetHeight??200,P=y.top-_.top,B=y.bottom-_.top;s.set(y.left-_.left),P>S+8?i.set(P-S-4):i.set(B+4)})}),c=t.emitter.on(h.CLOSE_BLOCK_INSERT_MENU,b),u=t.emitter.on(h.KEYDOWN,g=>{g.key==="Escape"&&r.peek()===!0&&b()}),p=t.emitter.on(h.CLICK,g=>{r.peek()===!0&&n&&!n.contains(g.target)&&o&&!o.contains(g.target)&&b()}),d=t.emitter.on(h.CLICK,g=>{let y=g.target?.closest?.(".mrakomor-block-insert-menu__item");if(!y||!o)return;g.preventDefault?.(),g.stopPropagation?.();let C=E(y);if(!C)return;let _=t.resolveComponentConstructor(C);if(!_)return;let S;if(y.dataset.settings)try{S=JSON.parse(y.dataset.settings)}catch{S=void 0}let P=_.getStateSchema().parse({componentId:k(),component:C,...S?{settings:S}:{}});t.command.insertBlockElement({blockElement:o,namespace:C,newLineState:P,cursor:0}),t.command.closeBlockInsertMenu()})},onMount(){let g=t.getRoot()?.querySelector(".mrakomor-tools-container");if(!g)return;let y=document.createElement("div");y.className="mrakomor-block-insert-menu-container",g.append(y),e=L(y,f(Xn,{open:r,positionX:s,positionY:i,items:l,menuRef:C=>{n=C}}))},onUnmount(){e?.(),a?.(),c?.(),u?.(),p?.(),d?.(),e=null,a=null,c=null,u=null,p=null,d=null,n=null,o=null}}}function mt(t,e){if(!t||!e)return null;let n=e.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n!==t;){if(n.nodeName==="LI"&&t.contains(n))return n;n=n.parentElement}return null}function pt(t,e){if(!e)return-1;let n=e.getAttribute?.("data-item-index");if(n!=null&&n!==""){let o=Number(n);if(!Number.isNaN(o))return o}return[...t.querySelectorAll("li")].indexOf(e)}function Xt(t,e){if(!t||!e)return 0;let n=e.cloneRange();n.collapse(!0);let o=document.createRange();return o.selectNodeContents(t),o.setEnd(n.startContainer,n.startOffset),o.toString().length}function Qn(t,e){let n={properties:{text:t.text??"",inlineStyleRanges:t.inlineStyleRanges??[],entityRanges:t.entityRanges??[]}},{originalLineState:o,newLineState:r}=W(n,e);return{before:{componentId:t.componentId,depth:t.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]},after:{componentId:k(),depth:t.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]}}}function Zn(t,e){return he({properties:{text:t?.text??"",inlineStyleRanges:t?.inlineStyleRanges??[],entityRanges:t?.entityRanges??[]}},e)}function eo(t,e){let n=Number(t.getAttribute("data-depth")??0)||0,o=t.innerText??t.textContent??"";o===`
6
+ `&&(o="");let r={properties:{text:o,inlineStyleRanges:[],entityRanges:[]}};z(t.childNodes,r,0,e);let s=r.properties.text;return s===`
7
+ `&&(s=""),{componentId:t.getAttribute("data-componentid")||void 0,depth:n,text:s,inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var ft=t=>m.object({componentId:m.string().default(()=>t?.getAttribute?.("data-componentid")||k()),depth:m.number().default(0),text:m.string().default(""),inlineStyleRanges:m.array(m.object({length:m.number(),offset:m.number(),style:m.string()})).default([]),entityRanges:m.array(m.object({entity:m.object({type:m.string(),data:m.any()}),length:m.number(),offset:m.number()})).default([])}).default({});function qo(t=[]){let e=new Set;return t.map(n=>{if(n?.componentId&&!e.has(n.componentId))return e.add(n.componentId),n;let o=k();return e.add(o),{...n,componentId:o}})}var Z=class extends K{static get NAMESPACE(){return"molecule.list.List"}static get LABEL(){return"List"}static get tooltipConfig(){return{inlineStyles:["BOLD","ITALIC","UNDERLINE","SUPERSCRIPT","SUBSCRIPT"],entityRanges:["atom.link.Link","atom.tts.Person"],blockTransforms:["molecule.paragraph.Paragraph","molecule.headline.H1","molecule.headline.H2","molecule.headline.H3","molecule.headline.H4","molecule.headline.H5"]}}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(e){let n=e?.nodeName==="OL"?"ORDERED":e?.nodeName==="UL"?"UNORDERED":void 0;return m.object({component:m.string().default(this.NAMESPACE),componentId:m.string().default(e?.getAttribute("data-componentid")||k()),properties:m.object({items:m.array(ft()).default([ft().parse()]).transform(qo)}).default({}),settings:m.object({style:m.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}parseFromHTML(e){if(!e)return this.constructor.getStateSchema(e).parse();let n=structuredClone(this.constructor.getStateSchema(e).parse()),o={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},r=[...e.querySelectorAll("li")];return n.properties.items=r.length?r.map(s=>ft(s).parse(eo(s,o))):[ft().parse()],n.settings={...n.settings,style:e.nodeName==="OL"?"ORDERED":e.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}getFormattingTarget(e){let n=e??v(),o=mt(this.element,n);if(!o)return null;let r=pt(this.element,o);return r<0?null:{element:o,read(s){let i=s.properties?.items?.[r];return{inlineStyleRanges:i?.inlineStyleRanges,entityRanges:i?.entityRanges}},write(s,{inlineStyleRanges:i,entityRanges:l}){let a=s.properties?.items?.[r];a&&(i!==void 0&&(a.inlineStyleRanges=i),l!==void 0&&(a.entityRanges=l))}}}_commitState(e){let n=this.mrakomor.getContent(),o=n.findIndex(r=>r.componentId===e.componentId);o!==-1&&(n.splice(o,1,e),this.mrakomor.setContent(n))}_buildItemContent(e){return Zn(e,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let e=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),o=n.settings?.style==="ORDERED"?"ol":"ul";return f(o,{className:e,"data-componentid":n.componentId,$ref:r=>{this.element=r}},rt(()=>this.state.get().properties?.items??[],(r,s)=>r.componentId??String(s),(r,s)=>f("li",{contentEditable:!0,[M]:!0,"data-componentid":()=>r.get().componentId,"data-item-index":()=>{let i=r.get()?.componentId,a=(this.state.get().properties?.items??[]).findIndex(c=>c.componentId===i);return String(a>=0?a:s)},"data-depth":()=>String(r.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let i=r.get(),l=i?.text??"";return l===""||l===`
8
+ `?"<br>":O(()=>this._buildItemContent(i))}})))}onKeydown(e){if(e.key==="Enter"){this.#e(e);return}e.key==="Backspace"&&this.#o(e)}#e(e){e.preventDefault(),e.stopPropagation();let n=v(),o=mt(this.element,n);if(!o)return;let r=pt(this.element,o),s=Xt(o,n),i=this.getState(),l=[...i.properties.items??[]],a=l[r];if(!a)return;let{before:c,after:u}=Qn(a,s);l.splice(r,1,c,u),this._commitState({...i,properties:{...i.properties,items:l}}),N(()=>{let p=this.element?.querySelector(`li[data-item-index="${r+1}"]`);p&&oe(p,0)})}#o(e){let n=v(),o=mt(this.element,n);if(!o)return;let r=pt(this.element,o);if(Xt(o,n)!==0||r<=0)return;let i=this.getState(),l=[...i.properties.items??[]],c=l[r]?.text??"";if(c!==""&&c!==`
9
+ `)return;e.preventDefault(),e.stopPropagation();let u=l[r-1]?.text??"";l.splice(r,1),this._commitState({...i,properties:{...i.properties,items:l}}),N(()=>{let p=this.element?.querySelector(`li[data-item-index="${r-1}"]`);p&&oe(p,u.length)})}};function Qt(){return{resolveConfig:t=>(t.blockComponents.push(Z),t.blockInsertVariants=[...t.blockInsertVariants??[],{label:"UL",namespace:Z.NAMESPACE,settings:{style:"UNORDERED"}},{label:"OL",namespace:Z.NAMESPACE,settings:{style:"ORDERED"}}],t),resolveComponent:t=>{if(t===Z.NAMESPACE)return Z}}}function to(){return{resolveConfig(t){return t},resolveComponent:t=>t===X.NAMESPACE?X:He,onKeyDown(t){}}}function Jo(t){t={...{debug:!1,content:[],plugins:[Ft,Vt,Ht,Qt,Yt,qt,Ut,Jt,Wt,to],blockComponents:[],inlineStyles:[Ce,Se,xe,_e,ke],entityRanges:[],tooltip:{}},...t};let{emitter:n,command:o}=Yn(),r=new dt(n,o,t);r._init();let s=f("style",{},`${xn}`);return document.head.appendChild(s),globalThis.mrakomor=r,r}var dt=class{#e=k();#o=null;#n=[];#t=[];#s={};#l=!1;#c=null;#i=null;#r=x([],{debug:"content"});#u=[];constructor(e,n,o){let{root:r,id:s,content:i}=o;this.#e=s||this.#e,this.#o=r,this.#u=i,this.#t=[],this.#s=o,this.command=n,this.emitter=e,this._mounted=!1}_init(){this.#p(),this.#m(),this.#a(),this.#d(),this.#r=x(this._normalizeContentState(this.#u),{debug:"content"})}#p(){this.#n=this.#s.plugins.map(e=>e?.({config:this.#s,root:this.#o,mrakomor:this}))??[],this.#s=this.#n.reduce((e,n)=>n?.resolveConfig?.(e)??e,this.#s),this.#n.forEach(e=>{e?.registerEvents?.(this)}),this.#n.forEach(e=>{e?.registerHandlers?.(this)}),this.#n.forEach(e=>{e?.registerCommands?.(this)}),this.#n.forEach(e=>{e?.registerListeners?.(this)}),this.#n.forEach(e=>{this.emitter.on(h.KEYDOWN,n=>e?.onKeyDown?.(n))})}#m(){this.emitter.on(h.KEYDOWN,e=>{let n=v();return j(n)?.getNodeComponent?.()?.classInstance?.onKeydown?.(e)}),this.emitter.on(h.KEYDOWN,e=>{let n=v(),o=j(n),r=re(o),s=o?.previousSibling,l=re(s)?.childNodes?.[0]?.contentEditable==="true",a=r?.childNodes?.[0]?.contentEditable==="true";if(e.key==="Backspace"){if(!n?.collapsed){let c=Kn(n);if(c&&c.startBlock!==c.endBlock){let u=this.#t.indexOf(c.startBlock),p=this.#t.indexOf(c.endBlock),d=this.getContent(),b=d[u],E=d[p];if(u>=0&&p>u&&typeof b?.properties?.text=="string"&&typeof E?.properties?.text=="string"){e.preventDefault(),e.stopPropagation();let{content:y,cursor:C,resultIndex:_}=Hn(d,{startIndex:u,endIndex:p,startOffset:c.startOffset,endOffset:c.endOffset});this._setContentState(y.map(S=>this.normalizeComponentState(S))),N(()=>{let S=this.#t[_];S&&typeof C=="number"&&oe(re(S),C)})}}return}if(!l&&n.startOffset===0||o?.textContent==="\xA0"&&!a){e.preventDefault(),e.stopPropagation(),this.command.removeBlockElement({blockElement:s,range:n});return}(l&&n.startOffset===0||s&&o?.textContent===""&&n.startOffset===1)&&(e.preventDefault(),e.stopPropagation(),this.command.mergeBlockElement({blockElement:o,previousBlockElement:s,range:n}))}})}#a(){this.emitter.on(h.INSERT_BLOCK_ELEMENT,e=>{let{blockElement:n,range:o,newLineState:r,originalLineState:s,namespace:i,position:l,cursor:a}=e,c,u;if(l)return;if(n)c=this.#t.indexOf(n),u=c+1;else if(o){let d=j(o);c=this.#t.indexOf(d),u=c+1}let p=this.getContent();s&&p.splice(c,1,this.normalizeComponentState(s)),r&&(r.component=i,p.splice(u,0,this.normalizeComponentState(r))),this._setContentState(p),N(()=>{if(typeof a=="number"&&a===0){let d=re(this.#t[u]);Dn(d,a)}})}),this.emitter.on(h.TRANSFORM_BLOCK_ELEMENT,({blockElement:e,namespace:n})=>{let o=this._getBlockElementIndex(e);if(o===-1)return;let r=this.getContent(),s=r[o],l=this.resolveComponentConstructor(n)?.tooltipConfig??{},a={...s,component:n,componentId:k()};console.log("transformed",a,n),r.splice(o,1,this.normalizeComponentState(a)),this._setContentState(r)}),this.emitter.on(h.MOVE_BLOCK_ELEMENT,e=>{let{blockElement:n,targetIndex:o}=e,r=this.#t.indexOf(n);if(r===-1||typeof o!="number")return;let s=o>r?o-1:o;if(s===r)return;let i=[...this._getContentState()],[l]=i.splice(r,1);i.splice(s,0,l),this._setContentState(i)}),this.emitter.on(h.REMOVE_BLOCK_ELEMENT,e=>{let{blockElement:n,range:o}=e,r=this.#t.indexOf(n);if(r!==-1){let s=this.getContent();s.splice(r,1),this._setContentState(s)}N(()=>{let s=j(o);oe(s,0)})}),this.emitter.on(h.REMOVE_ENTITY_RANGE,e=>{let{state:n,blockElement:o}=e,r=this.#t.indexOf(o),s=this.getContent(),i=structuredClone(s[r]),l=n?.offset,a=n?.length,c=n?.entity?.type;i.properties.entityRanges=(i.properties.entityRanges??[]).filter(u=>!(u?.offset===l&&u?.length===a&&u?.entity?.type===c)),s.splice(r,1,this.normalizeComponentState(i)),this._setContentState(s),this.command.closeDialog?.()}),this.emitter.on(h.INSERT_ENTITY_RANGE,e=>{let{namespace:n,blockElement:o,range:r,state:s}=e;r=r??v(),o=o??j(r);let i=de(o),l=i?.insertEntityRange?.(e);if(e.defaultPrevented){if(l){let d=this.#t.indexOf(o),b=this.getContent();b.splice(d,1,this.normalizeComponentState(l)),this._setContentState(b)}return}let a=i?.getFormattingTarget?.(r);if(!a)return;let c=this.getContent(),u=this.#t.indexOf(o),p=Vn(structuredClone(c[u]),a,{state:s,namespace:n,range:r});p&&(c.splice(u,1,this.normalizeComponentState(p)),this._setContentState(c))}),this.emitter.on(h.INSERT_INLINE_STYLE_RANGE,e=>{let{style:n}=e,o=v(),r=j(o),s=de(r),i=s?.insertInlineStyleRange?.(e);if(e.defaultPrevented){if(i){let p=this.#t.indexOf(r),d=this.getContent();d.splice(p,1,this.normalizeComponentState(i)),this._setContentState(d)}return}let l=s?.getFormattingTarget?.(o);if(!l)return;let a=this.getContent(),c=this.#t.indexOf(r),u=Un(structuredClone(a[c]),l,{style:n,range:o});u&&(a.splice(c,1,this.normalizeComponentState(u)),this._setContentState(a))}),this.emitter.on(h.MERGE_BLOCK_ELEMENT,e=>{let{blockElement:n,previousBlockElement:o}=e,r=this.#t.indexOf(o),s=this.#t.indexOf(n),i=this.getContent(),l=i[s],a=i[r],c=$t(a,l);i.splice(s,1),i.splice(r,1,this.normalizeComponentState(c.state)),this._setContentState(i),N(()=>{typeof c.cursor=="number"&&oe(re(o),c.cursor)})})}#d(){this.#i=new AbortController;let{signal:e}=this.#i;this.#o.addEventListener("keydown",n=>{let{metaKey:o,altKey:r,code:s,ctrlKey:i,key:l,isComposing:a,repeat:c,shiftKey:u,which:p,detail:d,isTrusted:b,target:E}=n,{defaultPrevented:g}=this.emitter.emit(h.KEYDOWN,{metaKey:o,altKey:r,code:s,ctrlKey:i,key:l,isComposing:a,repeat:c,shiftKey:u,which:p,detail:d,isTrusted:b,target:E});if(g){n.preventDefault();return}},{signal:e}),this.#o.addEventListener("click",n=>{let{metaKey:o,altKey:r,ctrlKey:s,button:i,shiftKey:l,which:a,detail:c,isTrusted:u,target:p}=n,{defaultPrevented:d}=this.emitter.emit(h.CLICK,{metaKey:o,altKey:r,ctrlKey:s,button:i,shiftKey:l,which:a,detail:c,isTrusted:u,target:p});if(d){n.preventDefault();return}},{signal:e}),document.addEventListener("selectionchange",n=>{let{metaKey:o,altKey:r,ctrlKey:s,button:i,shiftKey:l,which:a,detail:c,isTrusted:u,target:p}=n,{defaultPrevented:d}=this.emitter.emit(h.SELECTION_CHANGE,{metaKey:o,altKey:r,ctrlKey:s,button:i,shiftKey:l,which:a,detail:c,isTrusted:u,target:p});if(d){n.preventDefault();return}},{signal:e})}getConfig(){return this.#s}wrapBlockElement(e){for(let n of this.#n){let o=n.wrapBlockElement?.(e);if(o)return o}return e}getRoot(){return this.#o}getContent(){let e=this.#t.map(o=>de(o)?.getState()),n=document.querySelector("#prevState");return n&&(n.innerText=JSON.stringify(e,null,2)),e}setContent(e=[]){this._setContentState(this._normalizeContentState(e))}#f(){let e=this.#o?.querySelector?.(".mrakomor-content");e&&(this.#t=[...e.querySelectorAll(".mrakomor-block-element")])}_getContentState(){return this.#r.get()}_setContentState(e=[]){this.#r.set(e),N(()=>{this.#f()})}_normalizeContentState(e=[]){return e.map(n=>structuredClone(this.normalizeComponentState(n)))??[]}_setBlockElement(e,n=this.#t.length){this.#t.splice(n,0,e)}_removeBlockElement(e){this.#t=this.#t.filter(n=>n!==e)}_getBlockElementIndex(e){return this.#t.indexOf(e)}mount(){let e=L(this.#o,f(Gn,{mrakomor:this}));return this.#l=!0,e}unmount(){this.#l&&(this.#l=!1,Sn(this.#o))}_onUnmount(){this.#i?.abort(),this.#n.forEach(e=>{e?.onUnmount?.(this)})}_onMount(){this.#n.forEach(e=>{e?.onMount?.(this)}),N(()=>{this.#f()}),this.emitter.on(h.KEYDOWN,e=>{(e.metaKey||e.ctrlKey)&&e.key==="v"&&(e.preventDefault(),alert("Not supported yet"))})}resolveComponent(e,n){let o=this.resolveComponentConstructor(e);return o?f(o,{state:n}):f(He,{state:n})}resolveComponentConstructor(e){let n=this.#s.blockComponents.find(o=>o.NAMESPACE===e);if(!n){for(let o of this.#n)if(n=o?.resolveComponent?.(e),n)break}return n}normalizeComponentState(e){return this.resolveComponentConstructor(e.component??e?.entity?.type)?.getStateSchema()?.parse(e)}};export{Wn as BlockChrome,Xn as BlockInsertMenu,Ce as Bold,ut as Dialog,$ as HeadlineComponent,Se as Italic,se as LinkEntity,Z as List,dt as Mrakomor,A as Paragraph,_e as Subscript,ke as Superscript,Jn as Tooltip,Q as TtsHeadlineComponent,be as TtsParagraph,ye as TtsVoice,xe as Underline,Jt as blockChromePlugin,Wt as blockInsertMenuPlugin,Jo as createMrakomor,to as defaultMrakomorPlugin,Yt as dialogPlugin,Po as headlinePlugin,Ut as linkEntityPlugin,Qt as listPlugin,Ht as paragraphPlugin,qt as tooltipPlugin,Vt as ttsHeadlinePlugin,jo as ttsParagraphPlugin,Ft as ttsVoicePlugin};
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@mrakomor/core",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "exports": {
6
+ ".": "./build/static/es15/mrakomor.mjs",
7
+ "./style.css": "./build/static/es15/mrakomor.css"
8
+ },
9
+ "files": [
10
+ "build/static/es15"
11
+ ],
12
+ "scripts": {
13
+ "test": "node --test --import=./src/__tests__/setup.mjs 'src/**/__tests__/**/*.test.mjs'",
14
+ "test:watch": "node --test --watch --import=./src/__tests__/setup.mjs 'src/**/__tests__/**/*.test.mjs'",
15
+ "lint": "eslint -c ./.eslintrc.js --ignore-path ./.prettierignore './**/*.{js,jsx}'",
16
+ "dev": "merkur dev",
17
+ "build": "merkur build",
18
+ "start": "merkur start",
19
+ "test:e2e": "playwright test"
20
+ },
21
+ "author": "Miroslav Jancarik",
22
+ "license": "UNLICENSED",
23
+ "bugs": {
24
+ "url": "https://github.com/mjancarik/mrakomor/issues"
25
+ },
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org/",
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ },
32
+ "devDependencies": {
33
+ "@esmj/emitter": "^0.4.3",
34
+ "@esmj/schema": "^0.8.0",
35
+ "@esmj/signals": "^0.4.0",
36
+ "@merkur/cli": "1.0.3",
37
+ "@merkur/core": "1.0.3",
38
+ "@merkur/integration": "1.0.3",
39
+ "@merkur/integration-custom-element": "^1.0.3",
40
+ "@merkur/plugin-component": "1.0.3",
41
+ "@merkur/plugin-error": "1.0.3",
42
+ "@merkur/plugin-event-emitter": "1.0.3",
43
+ "compression": "^1.7.4",
44
+ "config": "^3.3.7",
45
+ "cors": "^2.8.5",
46
+ "cross-env": "^7.0.3",
47
+ "easy-uid": "^2.0.2",
48
+ "express": "^4.17.3",
49
+ "express-static-gzip": "^2.1.5",
50
+ "helmet": "^5.0.2",
51
+ "intersect-objects": "^2.0.0",
52
+ "morgan": "^1.10.0",
53
+ "morphdom": "^2.7.8",
54
+ "@merkur/tools": "1.0.3",
55
+ "@playwright/test": "^1.60.0",
56
+ "@testing-library/dom": "^10.4.0",
57
+ "global-jsdom": "^25.0.0"
58
+ },
59
+ "engines": {
60
+ "node": ">=20.0.0"
61
+ },
62
+ "imports": {
63
+ "#src/*": "./src/*"
64
+ }
65
+ }