@qwanyx/stack 0.2.59 → 0.2.60
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.
- package/dist/components/ImageNode.d.ts +5 -3
- package/dist/index.cjs.js +5 -5
- package/dist/index.esm.js +87 -62
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ImageNode for Lexical
|
|
3
3
|
* Allows embedding images in the rich text editor
|
|
4
|
+
* Uses DecoratorNode to render React components properly
|
|
4
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
5
7
|
import { DecoratorNode, DOMConversionMap, DOMExportOutput, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
6
8
|
export interface ImagePayload {
|
|
7
9
|
src: string;
|
|
@@ -15,7 +17,7 @@ export type SerializedImageNode = Spread<{
|
|
|
15
17
|
width?: number;
|
|
16
18
|
height?: number;
|
|
17
19
|
}, SerializedLexicalNode>;
|
|
18
|
-
export declare class ImageNode extends DecoratorNode<
|
|
20
|
+
export declare class ImageNode extends DecoratorNode<React.ReactElement> {
|
|
19
21
|
__src: string;
|
|
20
22
|
__altText: string;
|
|
21
23
|
__width?: number;
|
|
@@ -28,8 +30,8 @@ export declare class ImageNode extends DecoratorNode<null> {
|
|
|
28
30
|
static importDOM(): DOMConversionMap | null;
|
|
29
31
|
exportDOM(): DOMExportOutput;
|
|
30
32
|
createDOM(): HTMLElement;
|
|
31
|
-
updateDOM(
|
|
32
|
-
decorate():
|
|
33
|
+
updateDOM(): boolean;
|
|
34
|
+
decorate(): React.ReactElement;
|
|
33
35
|
}
|
|
34
36
|
export declare function $createImageNode(payload: ImagePayload): ImageNode;
|
|
35
37
|
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|
package/dist/index.cjs.js
CHANGED
|
@@ -70,12 +70,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
70
70
|
`||i===`\r
|
|
71
71
|
`?n.push(mr()):i===" "?n.push(_n()):n.push(Ue(i))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,o=this.style;let i=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(i=n,l=t),i.type==="element"&&function(b,C,v,E){const D=b.getNode(),k=D.getChildAtIndex(b.offset),y=Ue(),_=Ze(D)?ze().append(y):y;y.setFormat(v),y.setStyle(E),k===null?D.append(_):k.insertBefore(_),b.is(C)&&C.set(y.__key,0,"text"),b.set(y.__key,0,"text")}(i,l,s,o);const a=i.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];z(f)||M(26);const h=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=h,l.set(i.key,u,"text")),this.isCollapsed()&&a===h&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let b=f.getNextSibling();if(z(b)&&b.canInsertTextBefore()&&!ar(b)||(b=Ue(),b.setFormat(s),b.setStyle(o),g.canInsertTextAfter()?f.insertAfter(b):g.insertAfter(b)),b.select(0,0),f=b,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let b=f.getPreviousSibling();if(z(b)&&!ar(b)||(b=Ue(),b.setFormat(s),g.canInsertTextBefore()?f.insertBefore(b):g.insertBefore(b)),b.select(),f=b,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==h){const b=Ue(f.getTextContent());b.setFormat(s),f.replace(b),f=b}else if(!this.isCollapsed()&&e!==""){const b=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||F(b)&&(!b.canInsertTextBefore()||!b.canInsertTextAfter()))return this.insertText(""),ia(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const E=Ue(e);return E.select(),void f.replace(E)}const b=f.getFormat(),C=f.getStyle();if(a!==u||b===s&&C===o){if(kc(f)){const E=Ue(e);return E.setFormat(s),E.setStyle(o),E.select(),void f.replace(E)}}else{if(f.getTextContent()!==""){const E=Ue(e);if(E.setFormat(s),E.setStyle(o),E.select(),a===0)f.insertBefore(E,!1);else{const[D]=f.splitText(a);D.insertAfter(E,!1)}return void(E.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(o)}const v=u-a;f=f.spliceText(a,v,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=b,this.style=C))}else{const b=new Set([...f.getParentKeys(),...m.getParentKeys()]),C=F(f)?f:f.getParentOrThrow();let v=F(m)?m:m.getParentOrThrow(),E=m;if(!C.is(v)&&v.isInline())do E=v,v=v.getParentOrThrow();while(v.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(z(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const S=Ue(m.getTextContent());m.replace(S),m=S}Ze(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),b.add(m.__key)}else{const S=m.getParentOrThrow();S.canBeEmpty()||S.getChildrenSize()!==1?m.remove():S.remove()}else b.add(m.__key);const D=v.getChildren(),k=new Set(c),y=C.is(v),_=C.isInline()&&f.getNextSibling()===null?C:f;for(let S=D.length-1;S>=0;S--){const A=D[S];if(A.is(f)||F(A)&&A.isParentOf(f))break;A.isAttached()&&(!k.has(A)||A.is(E)?y||_.insertAfter(A,!1):A.remove())}if(!y){let S=v,A=null;for(;S!==null;){const I=S.getChildren(),B=I.length;(B===0||I[B-1].is(A))&&(b.delete(S.__key),A=S),S=S.getParent()}}if(f.isToken())if(a===h)f.select();else{const S=Ue(e);S.select(),f.replace(S)}else f=f.spliceText(a,h-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let S=1;S<d;S++){const A=c[S],I=A.__key;b.has(I)||A.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,o=this.isBackward()?e:t;let i=s.getNode(),l=o.getNode();const a=Ur(i,Yt),u=Ur(l,Yt);z(i)&&i.isToken()&&s.offset<i.getTextContentSize()&&(s.offset=0),o.offset>0&&z(l)&&l.isToken()&&(o.offset=l.getTextContentSize()),n.forEach(d=>{en(i,d)||en(l,d)||d.getKey()===i.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&ar(d)){const h=Ue(d.getTextContent());return h.setFormat(d.getFormat()),h.setStyle(d.getStyle()),d.replace(h)}};if(i===l&&z(i)){const d=Math.abs(t.offset-e.offset);return i.spliceText(s.offset,d,"",!0),void c(i,d)}if(z(i)){const d=i.getTextContentSize()-s.offset;i.spliceText(s.offset,d,""),i=c(i,d)||i}z(l)&&(l.spliceText(0,o.offset,""),l=c(l,o.offset)||l),i.isAttached()&&z(i)?i.selectEnd():l.isAttached()&&z(l)&&l.selectStart(),F(a)&&F(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),o.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void Ve(null);const n=this.getNodes(),s=[];for(const D of n)z(D)&&s.push(D);const o=D=>{n.forEach(k=>{if(Lr(k)){const y=k.getFormatFlags(e,D);k.setTextFormat(y)}})},i=s.length;if(i===0)return this.toggleFormat(e),Ve(null),void o(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,h=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===h.getTextContentSize()&&(f=1,h=s[1],g=0),h==null)return;const m=h.getFormatFlags(e,t);o(m);const b=i-1;let C=s[b];const v=d.type==="text"?d.offset:C.getTextContentSize();if(h.is(C)){if(g===v)return;if(ar(h)||g===0&&v===h.getTextContentSize())h.setFormat(m);else{const D=h.splitText(g,v),k=g===0?D[0]:D[1];k.setFormat(m),c.type==="text"&&c.set(k.__key,0,"text"),d.type==="text"&&d.set(k.__key,v-g,"text")}return void(this.format=m)}g===0||ar(h)||([,h]=h.splitText(g),g=0),h.setFormat(m);const E=C.getFormatFlags(e,m);v>0&&(v===C.getTextContentSize()||ar(C)||([C]=C.splitText(v)),C.setFormat(E));for(let D=f+1;D<b;D++){const k=s[D],y=k.getFormatFlags(e,E);k.setFormat(y)}c.type==="text"&&c.set(h.__key,g,"text"),d.type==="text"&&d.set(C.__key,v,"text"),this.format=m|E}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=V();return P(g)||M(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=Ur(t,Yt),s=e[e.length-1];if(F(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=Os(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(F(g)||_e(g))&&!g.isInline())){F(n)||M(211,t.constructor.name,t.getType());const g=Os(this);return n.splice(g,0,e),void s.selectEnd()}const o=function(g){const m=ze();let b=null;for(let C=0;C<g.length;C++){const v=g[C],E=fr(v);if(E||_e(v)&&v.isInline()||F(v)&&v.isInline()||z(v)||v.isParentRequired()){if(b===null&&(b=v.createParentElementNode(),m.append(b),E))continue;b!==null&&b.append(v)}else m.append(v),b=null}return m}(e),i=o.getLastDescendant(),l=o.getChildren(),a=!F(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;F(d=c)&&Yt(d)&&!d.isEmpty()&&F(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(F(n)||M(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&M(212,t.constructor.name,t.getType()),function(g,m,b){const C=m.getParentOrThrow().getLastChild();let v=m;const E=[m];for(;v!==C;)v.getNextSibling()||M(140),v=v.getNextSibling(),E.push(v);let D=g;for(const k of E)D=D.insertAfter(k)}(n,c));const f=Ur(i,Yt);a&&F(f)&&(a.canMergeWhenEmpty()||Yt(u))&&(f.append(...a.getChildren()),a.remove()),F(n)&&n.isEmpty()&&n.remove(),i.selectEnd();const h=F(n)?n.getLastChild():null;fr(h)&&f!==n&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){const i=ze();return Be().splice(this.anchor.offset,0,[i]),i.select(),i}const e=Os(this),t=Ur(this.anchor.getNode(),Yt);F(t)||M(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],o=t.insertNewAfter(this,!1);return o?(o.append(...s),o.selectStart(),o):null}insertLineBreak(e){const t=mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,o=this.focus;let i=e[0],l=e[n];const[a,u]=ni(this);if(t===0)return[];if(t===1){if(z(i)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,h=i.splitText(d,f),g=d===0?h[0]:h[1];return g!=null?[g]:[]}return[i]}const c=s.isBefore(o);if(z(i)){const d=c?a:u;d===i.getTextContentSize()?e.shift():d!==0&&([,i]=i.splitText(d),e[0]=i)}if(z(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,o=this.anchor,i=e==="move",l=un(s,t);if(_e(l)&&!l.isIsolated()){if(i&&l.isKeyboardSelectable()){const h=So();return h.add(l.__key),void Lt(h)}const f=t?l.getPreviousSibling():l.getNextSibling();if(z(f)){const h=f.__key,g=t?f.getTextContent().length:0;return s.set(h,g,"text"),void(i&&o.set(h,g,"text"))}{const h=l.getParentOrThrow();let g,m;return F(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=h.__key,t||g++),s.set(m,g,"element"),void(i&&o.set(m,g,"element"))}}const a=je(),u=ht(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!F(l)||l.isInline()||l.canBeEmpty()||Bi(c,a,d),function(f,h,g,m){f.modify(h,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),h=this.anchor.getNode(),g=Ze(h)?h:cc(h);if(this.applyDOMRange(f),this.dirty=!0,!i){const m=this.getNodes(),b=[];let C=!1;for(let v=0;v<m.length;v++){const E=m[v];en(E,g)?b.push(E):C=!0}if(C&&b.length>0)if(t){const v=b[0];F(v)?v.selectStart():v.getParentOrThrow().selectStart()}else{const v=b[b.length-1];F(v)?v.selectEnd():v.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(v){const E=v.focus,D=v.anchor,k=D.key,y=D.offset,_=D.type;Xt(D,E.key,E.offset,E.type),Xt(E,k,y,_),v._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&F(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),o=t.getNextSibling()||(s===null?null:s.getNextSibling());if(F(o)&&o.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const o=this.focus,i=un(o,e);if(_e(i)&&!i.isIsolated()){if(i.isKeyboardSelectable()&&F(s)&&s.getChildrenSize()===0){s.remove();const l=So();l.add(i.__key),Lt(l)}else i.remove(),je().dispatchCommand(di,void 0);return}if(!e&&F(i)&&F(s)&&s.isEmpty())return s.remove(),void i.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=o.type==="text"?o.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=o.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Co(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Co(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,f=c.getNode(),h=d.getNode();if(f===h&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,b=g<m,C=b?g:m,v=b?m:g,E=v-1;C!==E&&(Il(f.getTextContent().slice(C,v))||(u?d.offset=E:c.offset=E))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&Ze(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Nt(r){return r instanceof ms}function vo(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function ni(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[vo(t),vo(n)]}function Co(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),o=s.length;let i=0,l=0;for(let u=0;u<o;u++){const c=u===o-1;if(l=i,i+=s[u].length,e&&i===t||i>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function wo(r,e,t,n){let s,o=e;if(r.nodeType===gn){let i=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;o===a&&(i=!0,o=a-1);let c=l[o],d=!1;if(c===u)c=l[o+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&o--}if(s=Er(c),z(s))o=no(s,i);else{let f=Er(r);if(f===null)return null;if(F(f)){const h=n.getElementByKey(f.getKey());h===null&&M(214),[f,o]=f.getDOMSlot(h).resolveChildIndex(f,h,r,e),F(f)||M(215),i&&o>=f.getChildrenSize()&&(o=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(o);if(F(m)&&function(b,C,v){const E=b.getParent();return v===null||E===null||!E.canBeEmpty()||E!==v.getNode()}(m,0,t)){const b=i?m.getLastDescendant():m.getFirstDescendant();b===null?f=m:(m=b,f=F(m)?m:m.getParentOrThrow()),o=0}z(m)?(s=m,f=null,o=no(m,i)):m!==f&&i&&!d&&(F(f)||M(216),o=Math.min(f.getChildrenSize(),o+1))}else{const h=f.getIndexWithinParent();o=e===0&&_e(f)&&Er(r)===f?h:h+1,f=f.getParentOrThrow()}if(F(f))return Pt(f.__key,o,"element")}}else s=Er(r);return z(s)?Pt(s.__key,o,"text"):null}function Do(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const o=s.getPreviousSibling(),i=s.getParent();if(e){if((t||!e)&&o===null&&F(i)&&i.isInline()){const l=i.getPreviousSibling();z(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else F(o)&&!t&&o.isInline()?(r.key=o.__key,r.offset=o.getChildrenSize(),r.type="element"):z(o)&&(r.key=o.__key,r.offset=o.getTextContent().length)}else if(n===s.getTextContent().length){const o=s.getNextSibling(),i=s.getParent();if(e&&F(o)&&o.isInline())r.key=o.__key,r.offset=0,r.type="element";else if((t||e)&&o===null&&F(i)&&i.isInline()&&!i.canInsertTextAfter()){const l=i.getNextSibling();z(l)&&(r.key=l.__key,r.offset=0)}}}function ia(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);Do(r,n,s),Do(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const o=je();if(o.isComposing()&&o._compositionKey!==r.key&&P(t)){const i=t.anchor,l=t.focus;Xt(r,i.key,i.offset,i.type),Xt(e,l.key,l.offset,l.type)}}}function oa(r,e,t,n,s,o){if(r===null||t===null||!mn(s,r,t))return null;const i=wo(r,e,P(o)?o.anchor:null,s);if(i===null)return null;const l=wo(t,n,P(o)?o.focus:null,s);if(l===null)return null;if(i.type==="element"&&l.type==="element"){const a=Er(r),u=Er(t);if(_e(a)&&_e(u))return null}return ia(i,l,o),[i,l]}function si(r){return F(r)&&!r.isInline()}function la(r,e,t,n,s,o){const i=Vt(),l=new ir(Pt(r,e,s),Pt(t,n,o),0,"");return l.dirty=!0,i._selection=l,l}function Tc(){const r=Pt("root",0,"element"),e=Pt("root",0,"element");return new ir(r,e,0,"")}function So(){return new ms(new Set)}function Li(r,e,t,n){const s=t._window;if(s===null)return null;const o=n||s.event,i=o?o.type:void 0,l=i==="selectionchange",a=!Ws&&(l||i==="beforeinput"||i==="compositionstart"||i==="compositionend"||i==="click"&&o&&o.detail===3||i==="drop"||i===void 0);let u,c,d,f;if(P(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&P(r)&&!mn(t,u,c))return r.clone();const h=oa(u,d,c,f,t,r);if(h===null)return null;const[g,m]=h;return new ir(g,m,P(r)?r.format:0,P(r)?r.style:"")}function V(){return Vt()._selection}function vn(){return je()._editorState._selection}function es(r,e,t,n=1){const s=r.anchor,o=r.focus,i=s.getNode(),l=o.getNode();if(!e.is(i)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),o.set(a,c,"element"),Eo(r)}}else{const u=r.isBackward(),c=u?o:s,d=c.getNode(),f=u?s:o,h=f.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(h)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}Eo(r)}function Eo(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,o=e.getNode(),i=n.getNode();if(r.isCollapsed()){if(!F(o))return;const l=o.getChildrenSize(),a=t>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(F(o)){const l=o.getChildrenSize(),a=t>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(F(i)){const l=i.getChildrenSize(),a=s>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(s);if(z(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function ts(r,e,t,n,s){let o=null,i=0,l=null;n!==null?(o=n.__key,z(n)?(i=n.getTextContentSize(),l="text"):F(n)&&(i=n.getChildrenSize(),l="element")):s!==null&&(o=s.__key,z(s)?l="text":F(s)&&(l="element")),o!==null&&l!==null?r.set(o,i,l):(i=e.getIndexWithinParent(),i===-1&&(i=t.getChildrenSize()),r.set(t.__key,i,"element"))}function ko(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Bc(r,e,t,n,s,o,i){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==o||d!==null&&Di(d))return;if(!P(e))return void(r!==null&&mn(t,l,a)&&n.removeAllRanges());const f=e.anchor,h=e.focus,g=f.key,m=h.key,b=Hn(t,g),C=Hn(t,m),v=f.offset,E=h.offset,D=e.format,k=e.style,y=e.isCollapsed();let _=b,S=C,A=!1;if(f.type==="text"){_=Gn(b);const $=f.getNode();A=$.getFormat()!==D||$.getStyle()!==k}else P(r)&&r.anchor.type==="text"&&(A=!0);var I,B,N,j,L;if(h.type==="text"&&(S=Gn(C)),_!==null&&S!==null&&(y&&(r===null||A||P(r)&&(r.format!==D||r.style!==k))&&(I=D,B=k,N=v,j=g,L=performance.now(),Xl=[I,B,N,j,L]),u!==v||c!==E||l!==_||a!==S||n.type==="Range"&&y||(d!==null&&o.contains(d)||o.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(_,v,S,E)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&o!==null&&o===document.activeElement){const $=e instanceof ir&&e.anchor.type==="element"?_.childNodes[v]||null:n.rangeCount>0?n.getRangeAt(0):null;if($!==null){let X;if($ instanceof Text){const ce=document.createRange();ce.selectNode($),X=ce.getBoundingClientRect()}else X=$.getBoundingClientRect();(function(ce,ve,le){const Le=le.ownerDocument,me=Le.defaultView;if(me===null)return;let{top:he,bottom:ye}=ve,xe=0,Se=0,pe=le;for(;pe!==null;){const Ce=pe===Le.body;if(Ce)xe=0,Se=hs(ce).innerHeight;else{const ae=pe.getBoundingClientRect();xe=ae.top,Se=ae.bottom}let Ne=0;if(he<xe?Ne=-(xe-he):ye>Se&&(Ne=ye-Se),Ne!==0)if(Ce)me.scrollBy(0,Ne);else{const ae=pe.scrollTop;pe.scrollTop+=Ne;const Re=pe.scrollTop-ae;he-=Re,ye-=Re}if(Ce)break;pe=yn(pe)}})(t,X,o)}}ei=!0}}function aa(r){let e=V()||vn();e===null&&(e=Be().selectEnd()),e.insertNodes(r)}function Os(r){let e=r;r.isCollapsed()||e.removeText();const t=V();P(t)&&(e=t),P(e)||M(161);const n=e.anchor;let s=n.getNode(),o=n.offset;for(;!Yt(s);)[s,o]=Nc(s,o);return o}function Nc(r,e){const t=r.getParent();if(!t){const s=ze();return Be().append(s),s.select(),[Be(),0]}if(z(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const o=e===0?0:1;return[t,s[0].getIndexWithinParent()+o]}if(!F(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new ir(Pt(r.__key,e,"element"),Pt(r.__key,e,"element"),0,""),o=r.insertNewAfter(s);o&&o.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let Ge=null,Ke=null,st=!1,Ms=!1,On=0;const Ao={characterData:!0,childList:!0,subtree:!0};function Cn(){return st||Ge!==null&&Ge._readOnly}function nt(){st&&M(13)}function ua(){On>99&&M(14)}function Vt(){return Ge===null&&M(195,ca()),Ge}function je(){return Ke===null&&M(196,ca()),Ke}function ca(){let r=0;const e=new Set,t=xs.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const o=cs(s);if(Si(o))r++;else if(o){let i=String(o.constructor.version||"<0.17.1");i===t&&(i+=" (separately built, likely a bundler configuration issue)"),e.add(i)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Fc(){return Ke}function To(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&M(30,a),u}(r,n);let o=t.get(n);o===void 0&&(o=Array.from(s.transforms),t.set(n,o));const i=o.length;for(let l=0;l<i&&(o[l](e),e.isAttached());l++);}function Bo(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function da(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function jc(r){return Ri(r,je()._nodes)}function Ri(r,e){const t=r.type,n=e.get(t);n===void 0&&M(17,t);const s=n.klass;r.type!==s.getType()&&M(18,s.name);const o=s.importJSON(r),i=r.children;if(F(o)&&Array.isArray(i))for(let l=0;l<i.length;l++){const a=Ri(i[l],e);o.append(a)}return o}function No(r,e,t){const n=Ge,s=st,o=Ke;Ge=e,st=!0,Ke=r;try{return t()}finally{Ge=n,st=s,Ke=o}}function er(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const o=r._editorState,i=o._selection,l=t._selection,a=r._dirtyType!==hr,u=Ge,c=st,d=Ke,f=r._updating,h=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&h!==null){Ke=r,Ge=t,st=!1,r._updating=!0;try{const y=r._dirtyType,_=r._dirtyElements,S=r._dirtyLeaves;h.disconnect(),g=bc(o,t,r,y,_,S)}catch(y){if(y instanceof Error&&r._onError(y),Ms)throw y;return ya(r,null,n,t),Fl(r),r._dirtyType=Fr,Ms=!0,er(r,o),void(Ms=!1)}finally{h.observe(n,Ao),r._updating=f,Ge=u,st=c,Ke=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,b=r._dirtyElements,C=r._normalizedNodes,v=r._updateTags,E=r._deferred;a&&(r._dirtyType=hr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(y,_){const S=y._decorators;let A=y._pendingDecorators||S;const I=_._nodeMap;let B;for(B in A)I.has(B)||(A===S&&(A=Ol(y)),delete A[B])}(r,t);const D=s?null:ht(r._window);if(r._editable&&D!==null&&(a||l===null||l.dirty)){Ke=r,Ge=t;try{if(h!==null&&h.disconnect(),a||l===null||l.dirty){const y=r._blockCursorElement;y!==null&&Bi(y,r,n),Bc(i,l,r,D,v,n)}dc(r,n,l),h!==null&&h.observe(n,Ao)}finally{Ke=d,Ge=u}}g!==null&&function(y,_,S,A,I){const B=Array.from(y._listeners.mutation),N=B.length;for(let j=0;j<N;j++){const[L,$]=B[j],X=_.get($);X!==void 0&&L(X,{dirtyLeaves:A,prevEditorState:I,updateTags:S})}}(r,g,v,m,o),P(l)||l===null||i!==null&&i.is(l)||r.dispatchCommand(di,void 0);const k=r._pendingDecorators;k!==null&&(r._decorators=k,r._pendingDecorators=null,nn("decorator",r,!0,k)),function(y,_,S){const A=ro(_),I=ro(S);A!==I&&nn("textcontent",y,!0,I)}(r,e||o,t),nn("update",r,!0,{dirtyElements:b,dirtyLeaves:m,editorState:t,normalizedNodes:C,prevEditorState:e||o,tags:v}),function(y,_){if(y._deferred=[],_.length!==0){const S=y._updating;y._updating=!0;try{for(let A=0;A<_.length;A++)_[A]()}finally{y._updating=S}}}(r,E),function(y){const _=y._updates;if(_.length!==0){const S=_.shift();if(S){const[A,I]=S;ha(y,A,I)}}}(r)}function nn(r,e,t,...n){const s=e._updating;e._updating=t;try{const o=Array.from(e._listeners[r]);for(let i=0;i<o.length;i++)o[i].apply(null,n)}finally{e._updating=s}}function fa(r,e,t){if(r._updating===!1||Ke!==r){let s=!1;return r.update(()=>{s=fa(r,e,t)}),s}const n=Ei(r);for(let s=4;s>=0;s--)for(let o=0;o<n.length;o++){const i=n[o]._commands.get(e);if(i!==void 0){const l=i[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function Fo(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[o,i]=s;let l;if(i!==void 0){if(l=i.onUpdate,i.skipTransforms&&(n=!0),i.discrete){const a=r._pendingEditorState;a===null&&M(191),a._flushSync=!0}l&&r._deferred.push(l),da(r,i.tag)}o()}}return n}function ha(r,e,t){const n=r._updateTags;let s,o=!1,i=!1;t!==void 0&&(s=t.onUpdate,da(r,t.tag),o=t.skipTransforms||!1,i=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=ga(a||l),u=!0),a._flushSync=i;const c=Ge,d=st,f=Ke,h=r._updating;Ge=a,st=!1,r._updating=!0,Ke=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(C){const v=C.getEditorState()._selection,E=ht(C._window);return P(v)||v==null?Li(v,E,C,null):v.clone()}(r));const m=r._compositionKey;e(),o=Fo(r,o),function(C,v){const E=v.getEditorState()._selection,D=C._selection;if(P(D)){const k=D.anchor,y=D.focus;let _;if(k.type==="text"&&(_=k.getNode(),_.selectionTransform(E,D)),y.type==="text"){const S=y.getNode();_!==S&&S.selectionTransform(E,D)}}}(a,r),r._dirtyType!==hr&&(o?function(C,v){const E=v._dirtyLeaves,D=C._nodeMap;for(const k of E){const y=D.get(k);z(y)&&y.isAttached()&&y.isSimpleText()&&!y.isUnmergeable()&&eo(y)}}(a,r):function(C,v){const E=v._dirtyLeaves,D=v._dirtyElements,k=C._nodeMap,y=Zt(),_=new Map;let S=E,A=S.size,I=D,B=I.size;for(;A>0||B>0;){if(A>0){v._dirtyLeaves=new Set;for(const N of S){const j=k.get(N);z(j)&&j.isAttached()&&j.isSimpleText()&&!j.isUnmergeable()&&eo(j),j!==void 0&&Bo(j,y)&&To(v,j,_),E.add(N)}if(S=v._dirtyLeaves,A=S.size,A>0){On++;continue}}v._dirtyLeaves=new Set,v._dirtyElements=new Map;for(const N of I){const j=N[0],L=N[1];if(j!=="root"&&!L)continue;const $=k.get(j);$!==void 0&&Bo($,y)&&To(v,$,_),D.set(j,L)}S=v._dirtyLeaves,A=S.size,I=v._dirtyElements,B=I.size,On++}v._dirtyLeaves=E,v._dirtyElements=D}(a,r),Fo(r),function(C,v,E,D){const k=C._nodeMap,y=v._nodeMap,_=[];for(const[S]of D){const A=y.get(S);A!==void 0&&(A.isAttached()||(F(A)&&Ul(A,S,k,y,_,D),k.has(S)||D.delete(S),_.push(S)))}for(const S of _)y.delete(S);for(const S of E){const A=y.get(S);A===void 0||A.isAttached()||(k.has(S)||E.delete(S),y.delete(S))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const b=a._selection;if(P(b)){const C=a._nodeMap,v=b.anchor.key,E=b.focus.key;C.get(v)!==void 0&&C.get(E)!==void 0||M(19)}else Nt(b)&&b._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Fr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void er(r)}finally{Ge=c,st=d,Ke=f,r._updating=h,On=0}r._dirtyType!==hr||function(m,b){const C=b.getEditorState()._selection,v=m._selection;if(v!==null){if(v.dirty||!v.is(C))return!0}else if(C!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,er(r)):u&&ic(()=>{er(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function at(r,e,t){r._updating?r._updates.push([e,t]):ha(r,e,t)}class sn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new sn(this.element,e,this.after)}withAfter(e){return new sn(this.element,this.before,e)}withElement(e){return new sn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&M(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&M(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&M(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(pn||as);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,o=document.createElement("br");if(n.insertBefore(o,s),e){const i=document.createElement("img");i.setAttribute("data-lexical-linebreak","true"),i.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",i.alt="",n.insertBefore(i,o),n.__lexicalLineBreak=i}else n.__lexicalLineBreak=o}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const o=jo(t,n);o.push(s);const i=jo(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<i.length;a++){const u=o[a],c=i[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function jo(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let o=n.previousSibling;o!==null;o=n.previousSibling)s++;t.push(s)}return n!==r&&M(225),t.reverse()}class Ht extends gs{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Ju[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=je()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(z(t)&&e.push(t),F(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;F(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;F(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const o=t[n-1];return F(o)&&o.getLastDescendant()||o||null}const s=t[e];return F(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:Qe(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&M(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:Qe(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&M(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContent(),F(o)&&s!==n-1&&!o.isInline()&&(e+=Gt)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContentSize(),F(o)&&s!==n-1&&!o.isInline()&&(e+=Gt.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Yi[e];return!!(this.getFormat()&t)}return!1}select(e,t){nt();const n=V();let s=e,o=t;const i=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(z(a)||F(a))return a.select(0,0)}else if(!(e!==void 0&&e!==i||t!==void 0&&t!==i)){const a=this.getLastChild();if(z(a)||F(a))return a.select()}}s===void 0&&(s=i),o===void 0&&(o=i);const l=this.__key;return P(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,o,"element"),n.dirty=!0,n):la(l,s,l,o,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Yi[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,o=this.getChildrenSize(),i=this.getWritable();e+t<=o||M(226,String(e),String(t),String(o));const l=i.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=o-t+s;if(e!==0)if(e===o)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&M(100);const b=g.getNextSibling(),C=g.__key;dr(g.getWritable()),u.push(C),g=b}}let h=d;for(let g=0;g<s;g++){const m=n[g];h!==null&&m.is(h)&&(d=h=h.getPreviousSibling());const b=m.getWritable();b.__parent===l&&f--,dr(b);const C=m.__key;if(h===null)i.__first=C,b.__prev=null;else{const v=h.getWritable();v.__next=C,b.__prev=v.__key}m.__key===l&&M(76),b.__parent=l,a.push(C),h=m}if(e+t===o)h!==null&&(h.getWritable().__next=null,i.__last=h.__key);else if(c!==null){const g=c.getWritable();if(h!==null){const m=h.getWritable();g.__prev=h.__key,m.__next=c.__key}else g.__prev=null}if(i.__size=f,u.length){const g=V();if(P(g)){const m=new Set(u),b=new Set(a),{anchor:C,focus:v}=g;Lo(C,m,b)&&ts(C,C.getNode(),this,d,c),Lo(v,m,b)&&ts(v,v.getNode(),this,d,c),f!==0||this.canBeEmpty()||Rt(this)||this.remove()}}return i}getDOMSlot(e){return new sn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let o=this.getFirstChild();o;o=o.getNextSibling()){const i=t.getElementByKey(o.getKey());i!==null&&(s==null?(n.insertChild(i),s=i):s!==i&&n.replaceChild(i,s),s=s.nextSibling)}}}function F(r){return r instanceof Ht}function Lo(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class pa extends gs{constructor(e){super(e)}decorate(e,t){M(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function _e(r){return r instanceof pa}class wn extends Ht{static getType(){return"root"}static clone(){return new wn}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){M(51)}getTextContent(){const e=this.__cachedText;return!Cn()&&je()._dirtyType!==hr||e===null?super.getTextContent():e}remove(){M(52)}replace(e){M(53)}insertBefore(e){M(54)}insertAfter(e){M(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];F(n)||_e(n)||M(56)}return super.append(...e)}static importJSON(e){const t=Be();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function Ze(r){return r instanceof wn}function ga(r){return new ys(new Map(r._nodeMap))}function Pi(){return new ys(new Map([["root",new wn]]))}function ma(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&M(130,t.name),F(r)){const n=e.children;Array.isArray(n)||M(59,t.name);const s=r.getChildren();for(let o=0;o<s.length;o++){const i=ma(s[o]);n.push(i)}}return e}class ys{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return No(t&&t.editor||null,this,e)}clone(e){const t=new ys(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return No(null,this,()=>({root:ma(Be())}))}}class Oi extends Ht{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class Pr extends Ht{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=pr[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Kn(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new Pr(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=Zr(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Lc,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ze();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=ze();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||z(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function Lc(r){const e=ze();return r.style&&(e.setFormat(r.style.textAlign),Fi(r,e)),{node:e}}function ze(){return Ot(new Pr)}function Lr(r){return r instanceof Pr}const fe=0,kr=1,Rc=4;function ya(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=Pi(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=hr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const o=r._observer;o!==null&&(o.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Pc(r){const e=r||{},t=Fc(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,o=e.disableEvents||!1,i=Pi(),l=e.namespace||(s!==null?s._config.namespace:$l()),a=e.editorState,u=[wn,Rr,xn,bn,Pr,Oi,...e.nodes||[]],{onError:c,html:d}=e,f=e.editable===void 0||e.editable;let h;if(r===void 0&&t!==null)h=t._nodes;else{h=new Map;for(let m=0;m<u.length;m++){let b=u[m],C=null,v=null;if(typeof b!="function"){const y=b;b=y.replace,C=y.with,v=y.withKlass||null}const E=b.getType(),D=b.transform(),k=new Set;D!==null&&k.add(D),h.set(E,{exportDOM:d&&d.export?d.export.get(b):void 0,klass:b,replace:C,replaceWithKlass:v,transforms:k})}}const g=new xs(i,s,h,{disableEvents:o,namespace:l,theme:n},c||console.error,function(m,b){const C=new Map,v=new Set,E=D=>{Object.keys(D).forEach(k=>{let y=C.get(k);y===void 0&&(y=[],C.set(k,y)),y.push(D[k])})};return m.forEach(D=>{const k=D.klass.importDOM;if(k==null||v.has(k))return;v.add(k);const y=k.call(D.klass);y!==null&&E(y)}),b&&E(b),C}(h,d?d.import:void 0),f);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Fr),g}class xs{constructor(e,t,n,s,o,i,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=hr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=$l(),this._onError=o,this._htmlConversions=i,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&M(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=s.get(e);o===void 0&&M(36,String(e));const i=o[n];return i.add(t),()=>{i.delete(t),o.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,o=this._listeners.mutation;o.set(t,s);const i=n&&n.skipInitialization;return i!==void 0&&i||this.initializeMutationListener(t,s),()=>{o.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&M(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=gc(n).get(t.getType());if(!s)return;const o=new Map;for(const i of s.keys())o.set(i,"created");o.size>0&&e(o,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],o=n.replaceWithKlass;if(o!=null){const a=this.registerNodeTransformToKlass(o,t);s.push(a)}var i,l;return i=this,l=e.getType(),at(i,()=>{const a=Vt();if(a.isEmpty())return;if(l==="root")return void Be().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},i._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return G(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=Zr(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,ya(this,t,e,s),t!==null&&(this._config.disableEvents||_c(t),n!=null&&t.classList.remove(...n)),e!==null){const o=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),i=e.style;i.userSelect="text",i.whiteSpace="pre-wrap",i.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=o,this._dirtyType=Fr,Fl(this),this._updateTags.add("history-merge"),er(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Zn.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",ra),Zn.set(u,(c||0)+1),l.__lexicalEditor=a;const d=ta(l);for(let f=0;f<Zs.length;f++){const[h,g]=Zs[f],m=typeof g=="function"?b=>{mo(b)||(go(b),(a.isEditable()||h==="click")&&g(b,a))}:b=>{if(mo(b))return;go(b);const C=a.isEditable();switch(h){case"cut":return C&&G(a,pi,b);case"copy":return G(a,ls,b);case"paste":return C&&G(a,os,b);case"dragstart":return C&&G(a,Dl,b);case"dragover":return C&&G(a,Sl,b);case"dragend":return C&&G(a,Fu,b);case"focus":return C&&G(a,Ru,b);case"blur":return C&&G(a,Pu,b);case"drop":return C&&G(a,wl,b)}};l.addEventListener(h,m),d.push(()=>{l.removeEventListener(h,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;nn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&M(38);let n=e;n._readOnly&&(n=ga(e),n._selection=e._selection?e._selection.clone():null),Nl(this);const s=this._pendingEditorState,o=this._updateTags,i=t!==void 0?t.tag:null;s===null||s.isEmpty()||(i!=null&&o.add(i),er(this)),this._pendingEditorState=n,this._dirtyType=Fr,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&o.add(i),this._updating||er(this)}parseEditorState(e,t){return function(n,s,o){const i=Pi(),l=Ge,a=st,u=Ke,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,h=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,Ge=i,st=!1,Ke=s;try{const g=s._nodes;Ri(n.root,g),o&&o(),i._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=f,s._dirtyType=h,Ge=l,st=a,Ke=u}return i}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return er(this),this.getEditorState().read(e,{editor:this})}update(e,t){at(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),at(this,()=>{const s=V(),o=Be();s!==null?s.dirty=!0:o.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?o.selectStart():o.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=ht(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,nn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}xs.version="0.21.0+prod.esm";const xa=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Oc=xa?w.useLayoutEffect:w.useEffect,Nn={tag:"history-merge"};function Mc({initialConfig:r,children:e}){const t=w.useMemo(()=>{const{theme:n,namespace:s,nodes:o,onError:i,editorState:l,html:a}=r,u=Cu(null,n),c=Pc({editable:r.editable,html:a,namespace:s,nodes:o,onError:d=>i(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const h=Be();if(h.isEmpty()){const g=ze();h.append(g);const m=xa?document.activeElement:null;(V()!==null||m!==null&&m===d.getRootElement())&&g.select()}},Nn);else if(f!==null)switch(typeof f){case"string":{const h=d.parseEditorState(f);d.setEditorState(h,Nn);break}case"object":d.setEditorState(f,Nn);break;case"function":d.update(()=>{Be().isEmpty()&&f(d)},Nn)}}}(c,l),[c,u]},[]);return Oc(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),p.jsx(pl.Provider,{value:t,children:e})}const Ic=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function $c(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function zc(){return function(r){const[e]=wt(),t=w.useMemo(()=>r(e),[e,r]),[n,s]=w.useState(()=>t.initialValueFn()),o=w.useRef(n);return Ic(()=>{const{initialValueFn:i,subscribe:l}=t,a=i();return o.current!==a&&(o.current=a,s(a)),l(u=>{o.current=u,s(u)})},[t,r]),n}($c)}function qc(){return Be().getTextContent()}function Uc(r,e=!0){if(r)return!1;let t=qc();return e&&(t=t.trim()),t===""}function Wc(r){if(!Uc(r,!1))return!1;const e=Be().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(_e(s))return!1;if(F(s)){if(!Lr(s)||s.__indent!==0)return!1;const o=s.getChildren(),i=o.length;for(let l=0;l<i;l++){const a=o[n];if(!z(a))return!1}}}return!0}function ba(r){return()=>Wc(r)}function Gc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Gc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Kc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vc=Kc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Hc=new Map;function Jc(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,o]=n.split(/:([^]+)/);s&&o&&(e[s.trim()]=o.trim())}return e}function _a(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,o=r.isBackward(),i=n.getNode(),l=s.getNode(),a=e.is(i),u=e.is(l);if(a||u){const[c,d]=ni(r),f=i.is(l),h=e.is(o?l:i),g=e.is(o?i:l);let m,b=0;return f?(b=c>d?d:c,m=c>d?c:d):h?(b=o?d:c,m=void 0):g&&(b=0,m=o?c:d),e.__text=e.__text.slice(b,m),e}}return e}function Qc(r){const e=r.getStyle(),t=Jc(e);Hc.set(e,t)}function Yc(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const i=e(),l=Be(),a=l.getFirstChild();return void(a?a.replace(i,!0):l.append(i))}const s=r.getNodes(),o=n!==null&&function(i,l){let a=i;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),Oo);o&&s.indexOf(o)===-1&&s.push(o);for(let i=0;i<s.length;i++){const l=s[i];if(!Oo(l))continue;F(l)||Vc(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function Ro(r,e){const t=un(r.focus,e);return _e(t)&&!t.isIsolated()||F(t)&&!t.isInline()&&!t.canBeEmpty()}function Xc(r,e,t,n){r.modify(e?"extend":"move",t,n)}function Zc(r){const e=r.anchor.getNode();return(Ze(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function Po(r,e,t){const n=Zc(r);Xc(r,e,t?!n:n,"character")}function Oo(r){if(_e(r)||!F(r)||Rt(r))return!1;const e=r.getFirstChild(),t=e===null||fr(e)||z(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function ed(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var td=ed(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const va=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,rd=va&&"documentMode"in document?document.documentMode:null;!(!va||!("InputEvent"in window)||rd)&&"getTargetRanges"in new window.InputEvent("input");function Ca(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function xr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function Dn(r,...e){const t=Ca(...e);t.length>0&&r.classList.add(...t)}function wa(r,...e){const t=Ca(...e);t.length>0&&r.classList.remove(...t)}function nd(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function sd(r){const e=bs(r,t=>F(t)&&!t.isInline());return F(e)||td(4,r.__key),e}const bs=(r,e)=>{let t=r;for(;t!==Be()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function tr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function id(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const o=n.data;if(typeof o=="string"){let i;try{i=JSON.parse(o)}catch{return}if(i&&i.protocol==="nuanria_messaging"&&i.type==="request"){const l=i.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,f,h,g]=a;r.update(()=>{const m=V();if(P(m)){const b=m.anchor;let C=b.getNode(),v=0,E=0;if(z(C)&&u>=0&&c>=0&&(v=u,E=u+c,m.setTextNodeRange(C,v,C,E)),v===E&&d===""||(m.insertRawText(d),C=b.getNode()),z(C)){v=f,E=f+h;const D=C.getTextContentSize();v=v>D?D:v,E=E>D?D:E,m.setTextNodeRange(C,v,C,E)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Da(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let o=0;o<t.length;o++){const i=t[o];if(!ka.has(i.nodeName)){const l=Aa(i,r,s,!1);l!==null&&(n=n.concat(l))}}return function(o){for(const i of o)i.getNextSibling()instanceof Oi&&i.insertAfter(mr());for(const i of o){const l=i.getChildren();for(const a of l)i.insertBefore(a);i.remove()}}(s),n}function Sa(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Be().getChildren();for(let s=0;s<n.length;s++)Ea(r,n[s],t,e);return t.innerHTML}function Ea(r,e,t,n=null){let s=n===null||e.isSelected(n);const o=F(e)&&e.excludeFromCopy("html");let i=e;if(n!==null){let h=Ni(e);h=z(h)&&n!==null?_a(n,h):h,i=h}const l=F(i)?i.getChildren():[],a=r._nodes.get(i.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,i):i.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let h=0;h<l.length;h++){const g=l[h],m=Ea(r,g,f,n);!s&&F(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!o){if((Kt(c)||uo(c))&&c.append(f),t.append(c),d){const h=d.call(i,c);h&&(uo(c)?c.replaceChildren(h):c.replaceWith(h))}}else t.append(f);return s}const ka=new Set(["STYLE","SCRIPT"]);function Aa(r,e,t,n,s=new Map,o){let i=[];if(ka.has(r.nodeName))return i;let l=null;const a=function(g,m){const{nodeName:b}=g,C=m._htmlConversions.get(b.toLowerCase());let v=null;if(C!==void 0)for(const E of C){const D=E(g);D!==null&&(v===null||(v.priority||0)<=(D.priority||0))&&(v=D)}return v!==null?v.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,o),!l)break;l&&i.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const h=(l==null||!Rt(l))&&(l!=null&&si(l)||n);for(let g=0;g<d.length;g++)f.push(...Aa(d[g],e,t,h,new Map(s),l));return c!=null&&(f=c(f)),Jn(r)&&(f=od(r,f,h?()=>{const g=new Oi;return t.push(g),g}:ze)),l==null?f.length>0?i=i.concat(f):Jn(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Gs(g.nextSibling)&&Gs(g.previousSibling)}(r)&&(i=i.concat(mr())):F(l)&&l.append(...f),i}function od(r,e,t){const n=r.style.textAlign,s=[];let o=[];for(let i=0;i<e.length;i++){const l=e[i];if(si(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(o.push(l),i===e.length-1||i<e.length-1&&si(e[i+1])){const a=t();a.setFormat(n),a.append(...o),s.push(a),o=[]}}return s}function ld(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rs=ld(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function ad(r,e=V()){return e==null&&rs(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sa(r,e)}function ud(r,e=V()){return e==null&&rs(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(cd(r,e))}function Mo(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const i=JSON.parse(n);if(i.namespace===t._config.namespace&&Array.isArray(i.nodes))return Io(t,dd(i.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const i=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return Io(t,Da(t,i),e)}catch{}const o=r.getData("text/plain")||r.getData("text/uri-list");if(o!=null)if(P(e)){const i=o.split(/(\r?\n|\t)/);i[i.length-1]===""&&i.pop();for(let l=0;l<i.length;l++){const a=V();if(P(a)){const u=i[l];u===`
|
|
72
72
|
`||u===`\r
|
|
73
|
-
`?a.insertParagraph():u===" "?a.insertNodes([_n()]):a.insertText(u)}}}else e.insertRawText(o)}function Io(r,e,t){r.dispatchCommand(wu,{nodes:e,selection:t})||t.insertNodes(e)}function Ta(r,e,t,n=[]){let s=e===null||t.isSelected(e);const o=F(t)&&t.excludeFromCopy("html");let i=t;if(e!==null){let u=Ni(t);u=z(u)&&e!==null?_a(e,u):u,i=u}const l=F(i)?i.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&rs(58,d.name),F(u)){const f=c.children;Array.isArray(f)||rs(59,d.name)}return c}(i);if(z(i)){const u=i.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Ta(r,e,c,a.children);!s&&F(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!o)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function cd(r,e){const t=[],n=Be().getChildren();for(let s=0;s<n.length;s++)Ta(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function dd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=jc(n);z(s)&&Qc(s),e.push(s)}return e}let wr=null;async function $o(r,e,t){if(wr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(zo(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,o=ht(r._window);if(n===null||o===null)return!1;const i=s.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(s.createTextNode("#")),n.append(i);const l=new Range;return l.setStart(i,0),l.setEnd(i,1),o.removeAllRanges(),o.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ls,d=>(tr(d,ClipboardEvent)&&(c(),wr!==null&&(window.clearTimeout(wr),wr=null),a(zo(r,d,t))),!0),Rc);wr=window.setTimeout(()=>{c(),wr=null,a(!1)},50),s.execCommand("copy"),i.remove()})}function zo(r,e,t){if(t===void 0){const s=ht(r._window);if(!s)return!1;const o=s.anchorNode,i=s.focusNode;if(o!==null&&i!==null&&!mn(r,o,i))return!1;const l=V();if(l===null)return!1;t=hd(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(pd(n,t),!0)}const fd=[["text/html",ad],["application/x-lexical-editor",ud]];function hd(r=V()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=hc();for(const[n,s]of fd){const o=s(t,r);o!==null&&(e[n]=o)}}return e}function pd(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function qo(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const Or=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,gd=Or&&"documentMode"in document?document.documentMode:null,md=!(!Or||!("InputEvent"in window)||gd)&&"getTargetRanges"in new window.InputEvent("input"),yd=Or&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Uo=Or&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,xd=Or&&/^(?=.*Chrome).*/i.test(navigator.userAgent),bd=Or&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!xd,Wo=hn();class _s extends Ht{static getType(){return"quote"}static clone(e){return new _s(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return Dn(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:_d,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Mi();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=ze(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=ze();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function Mi(){return Ot(new _s)}class vs extends Ht{static getType(){return"heading"}static clone(e){return new vs(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const o=s[t];Dn(n,o)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Dr,priority:0}),h2:e=>({conversion:Dr,priority:0}),h3:e=>({conversion:Dr,priority:0}),h4:e=>({conversion:Dr,priority:0}),h5:e=>({conversion:Dr,priority:0}),h6:e=>({conversion:Dr,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Go(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Go(e)?{conversion:t=>({node:Jr("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Jr(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),o=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?ze():Jr(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,t),n===0&&!this.isEmpty()&&e){const l=ze();l.select(),this.replace(l,!0)}return o}collapseAtStart(){const e=this.isEmpty()?ze():Jr(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function Go(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Dr(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=Jr(e),r.style!==null&&(Fi(r,t),t.setFormat(r.style.textAlign))),{node:t}}function _d(r){const e=Mi();return r.style!==null&&(e.setFormat(r.style.textAlign),Fi(r,e)),{node:e}}function Jr(r){return Ot(new vs(r))}function Fn(r){let e=null;if(tr(r,DragEvent)?e=r.dataTransfer:tr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function Ko(r){const e=V();if(!P(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const o=n[s],i=o.getKey();if(t.has(i))continue;const l=bs(o,u=>F(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function jn(r){const e=jr(r);return _e(e)}function vd(r){return xr(r.registerCommand(gl,e=>{const t=V();return!!Nt(t)&&(t.clear(),!0)},0),r.registerCommand(cr,e=>{const t=V();return!!P(t)&&(t.deleteCharacter(e),!0)},fe),r.registerCommand(ln,e=>{const t=V();return!!P(t)&&(t.deleteWord(e),!0)},fe),r.registerCommand(an,e=>{const t=V();return!!P(t)&&(t.deleteLine(e),!0)},fe),r.registerCommand(Tr,e=>{const t=V();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)Mo(n,t,r);else if(P(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},fe),r.registerCommand(qs,()=>{const e=V();return!!P(e)&&(e.removeText(),!0)},fe),r.registerCommand(vt,e=>{const t=V();return!!P(t)&&(t.formatText(e),!0)},fe),r.registerCommand(Nu,e=>{const t=V();if(!P(t)&&!Nt(t))return!1;const n=t.getNodes();for(const s of n){const o=bs(s,i=>F(i)&&!i.isInline());o!==null&&o.setFormat(e)}return!0},fe),r.registerCommand(Ar,e=>{const t=V();return!!P(t)&&(t.insertLineBreak(e),!0)},fe),r.registerCommand(on,()=>{const e=V();return!!P(e)&&(e.insertParagraph(),!0)},fe),r.registerCommand(Tu,()=>(aa([_n()]),!0),fe),r.registerCommand(Bu,()=>Ko(e=>{const t=e.getIndent();e.setIndent(t+1)}),fe),r.registerCommand(Qi,()=>Ko(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),fe),r.registerCommand(xl,e=>{const t=V();if(Nt(t)&&!jn(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(P(t)){const n=un(t.focus,!0);if(!e.shiftKey&&_e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},fe),r.registerCommand(bl,e=>{const t=V();if(Nt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(P(t)){if(function(s){const o=s.focus;return o.key==="root"&&o.offset===Be().getChildrenSize()}(t))return e.preventDefault(),!0;const n=un(t.focus,!1);if(!e.shiftKey&&_e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},fe),r.registerCommand(yl,e=>{const t=V();if(Nt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!P(t))return!1;if(Ro(t,!0)){const n=e.shiftKey;return e.preventDefault(),Po(t,n,!0),!0}return!1},fe),r.registerCommand(ml,e=>{const t=V();if(Nt(t)&&!jn(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!P(t))return!1;const n=e.shiftKey;return!!Ro(t,!1)&&(e.preventDefault(),Po(t,n,!1),!0)},fe),r.registerCommand(_l,e=>{if(jn(e.target))return!1;const t=V();if(!P(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!Ze(s)&&sd(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Qi,void 0)):(!Uo||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(cr,!0))},fe),r.registerCommand(Cl,e=>{if(jn(e.target))return!1;const t=V();return!!P(t)&&(e.preventDefault(),r.dispatchCommand(cr,!1))},fe),r.registerCommand($n,e=>{const t=V();if(!P(t))return!1;if(e!==null){if((Uo||yd||bd)&&md)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Ar,!1)}return r.dispatchCommand(on,void 0)},fe),r.registerCommand(vl,()=>{const e=V();return!!P(e)&&(r.blur(),!0)},fe),r.registerCommand(wl,e=>{const[,t]=Fn(e);if(t.length>0){const s=qo(e.clientX,e.clientY);if(s!==null){const{offset:o,node:i}=s,l=jr(i);if(l!==null){const a=Tc();if(z(l))a.anchor.set(l.getKey(),o,"text"),a.focus.set(l.getKey(),o,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=jl(a);Lt(u)}r.dispatchCommand(Wo,t)}return e.preventDefault(),!0}const n=V();return!!P(n)},fe),r.registerCommand(Dl,e=>{const[t]=Fn(e),n=V();return!(t&&!P(n))},fe),r.registerCommand(Sl,e=>{const[t]=Fn(e),n=V();if(t&&!P(n))return!1;const s=qo(e.clientX,e.clientY);if(s!==null){const o=jr(s.node);_e(o)&&e.preventDefault()}return!0},fe),r.registerCommand(Us,()=>(uc(),!0),fe),r.registerCommand(ls,e=>($o(r,tr(e,ClipboardEvent)?e:null),!0),fe),r.registerCommand(pi,e=>(async function(t,n){await $o(n,tr(t,ClipboardEvent)?t:null),n.update(()=>{const s=V();P(s)?s.removeText():Nt(s)&&s.getNodes().forEach(o=>o.remove())})}(e,r),!0),fe),r.registerCommand(os,e=>{const[,t,n]=Fn(e);return t.length>0&&!n?(r.dispatchCommand(Wo,t),!0):Di(e.target)?!1:V()!==null&&(function(s,o){s.preventDefault(),o.update(()=>{const i=V(),l=tr(s,InputEvent)||tr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&i!==null&&Mo(l,i,o)},{tag:"paste"})}(e,r),!0)},fe))}const ii=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Vo(r){return r.getEditorState().read(ba(r.isComposing()))}function Cd({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=wt(),s=function(o,i){const[l,a]=w.useState(()=>o.getDecorators());return ii(()=>o.registerDecoratorListener(u=>{$i.flushSync(()=>{a(u)})}),[o]),w.useEffect(()=>{a(o.getDecorators())},[o]),w.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],h=p.jsx(i,{onError:m=>o._onError(m),children:p.jsx(w.Suspense,{fallback:null,children:l[f]})}),g=o.getElementByKey(f);g!==null&&u.push($i.createPortal(h,g,f))}return u},[i,l,o])}(n,t);return function(o){ii(()=>xr(vd(o),id(o)),[o])}(n),p.jsxs(p.Fragment,{children:[r,p.jsx(wd,{content:e}),s]})}function wd({content:r}){const[e]=wt(),t=function(s){const[o,i]=w.useState(()=>Vo(s));return ii(()=>{function l(){const a=Vo(s);i(a)}return l(),xr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),o}(e),n=zc();return t?typeof r=="function"?r(n):r:null}const Ba=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Dd({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:o,ariaExpanded:i,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:h,className:g,id:m,role:b="textbox",spellCheck:C=!0,style:v,tabIndex:E,"data-testid":D,...k},y){const[_,S]=w.useState(r.isEditable()),A=w.useCallback(B=>{B&&B.ownerDocument&&B.ownerDocument.defaultView?r.setRootElement(B):r.setRootElement(null)},[r]),I=w.useMemo(()=>function(...B){return N=>{B.forEach(j=>{typeof j=="function"?j(N):j!=null&&(j.current=N)})}}(y,A),[A,y]);return Ba(()=>(S(r.isEditable()),r.registerEditableListener(B=>{S(B)})),[r]),p.jsx("div",{"aria-activedescendant":_?e:void 0,"aria-autocomplete":_?t:"none","aria-controls":_?n:void 0,"aria-describedby":s,...o!=null?{"aria-errormessage":o}:{},"aria-expanded":_&&b==="combobox"?!!i:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":_?d:void 0,"aria-readonly":!_||void 0,"aria-required":f,autoCapitalize:h,className:g,contentEditable:_,"data-testid":D,id:m,ref:I,role:_?b:void 0,spellCheck:C,style:v,tabIndex:E,...k})}const Sd=w.forwardRef(Dd);function Ho(r){return r.getEditorState().read(ba(r.isComposing()))}const Ed=w.forwardRef(kd);function kd(r,e){const{placeholder:t,...n}=r,[s]=wt();return p.jsxs(p.Fragment,{children:[p.jsx(Sd,{editor:s,...n,ref:e}),t!=null&&p.jsx(Ad,{editor:s,content:t})]})}function Ad({content:r,editor:e}){const t=function(i){const[l,a]=w.useState(()=>Ho(i));return Ba(()=>{function u(){const c=Ho(i);a(c)}return u(),xr(i.registerUpdateListener(()=>{u()}),i.registerEditableListener(()=>{u()}))},[i]),l}(e),[n,s]=w.useState(e.isEditable());if(w.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(i=>{s(i)})),[e]),!t)return null;let o=null;return typeof r=="function"?o=r(n):r!==null&&(o=r),o===null?null:p.jsx("div",{"aria-hidden":!0,children:o})}const Ln=0,oi=1,li=2,_t=0,Td=1,Jo=2,Bd=3,Nd=4;function Fd(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return _t;const o=e._selection,i=r._selection;if(s)return Td;if(!(P(o)&&P(i)&&i.isCollapsed()&&o.isCollapsed()))return _t;const l=function(C,v,E){const D=C._nodeMap,k=[];for(const y of v){const _=D.get(y);_!==void 0&&k.push(_)}for(const[y,_]of E){if(!_)continue;const S=D.get(y);S===void 0||Ze(S)||k.push(S)}return k}(e,t,n);if(l.length===0)return _t;if(l.length>1){const C=e._nodeMap,v=C.get(o.anchor.key),E=C.get(i.anchor.key);return v&&E&&!r._nodeMap.has(v.__key)&&z(v)&&v.__text.length===1&&o.anchor.offset===1?Jo:_t}const a=l[0],u=r._nodeMap.get(a.__key);if(!z(u)||!z(a)||u.__mode!==a.__mode)return _t;const c=u.__text,d=a.__text;if(c===d)return _t;const f=o.anchor,h=i.anchor;if(f.key!==h.key||f.type!=="text")return _t;const g=f.offset,m=h.offset,b=d.length-c.length;return b===1&&m===g-1?Jo:b===-1&&m===g+1?Bd:b===-1&&m===g?Nd:_t}function jd(r,e){let t=Date.now(),n=_t;return(s,o,i,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=_t,t=c,li;const d=Fd(s,o,l,a,r.isComposing()),f=(()=>{const h=i===null||i.editor===r,g=u.has("history-push");if(!g&&h&&u.has("history-merge"))return Ln;if(s===null)return oi;const m=o._selection;return l.size>0||a.size>0?g===!1&&d!==_t&&d===n&&c<t+e&&h||l.size===1&&function(b,C,v){const E=C._nodeMap.get(b),D=v._nodeMap.get(b),k=C._selection,y=v._selection;return!(P(k)&&P(y)&&k.anchor.type==="element"&&k.focus.type==="element"&&y.anchor.type==="text"&&y.focus.type==="text"||!z(E)||!z(D)||E.__parent!==D.__parent)&&JSON.stringify(C.read(()=>E.exportJSON()))===JSON.stringify(v.read(()=>D.exportJSON()))}(Array.from(l)[0],s,o)?Ln:oi:m!==null?Ln:li})();return t=c,n=d,f}}function Qo(r){r.undoStack=[],r.redoStack=[],r.current=null}function Ld(r,e,t){const n=jd(r,t);return xr(r.registerCommand(fi,()=>(function(o,i){const l=i.redoStack,a=i.undoStack;if(a.length!==0){const u=i.current,c=a.pop();u!==null&&(l.push(u),o.dispatchCommand(kn,!0)),a.length===0&&o.dispatchCommand(An,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),fe),r.registerCommand(hi,()=>(function(o,i){const l=i.redoStack,a=i.undoStack;if(l.length!==0){const u=i.current;u!==null&&(a.push(u),o.dispatchCommand(An,!0));const c=l.pop();l.length===0&&o.dispatchCommand(kn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),fe),r.registerCommand(ju,()=>(Qo(e),!1),fe),r.registerCommand(Lu,()=>(Qo(e),r.dispatchCommand(kn,!1),r.dispatchCommand(An,!1),!0),fe),r.registerUpdateListener(({editorState:o,prevEditorState:i,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,h=c===null?null:c.editorState;if(c!==null&&o===h)return;const g=n(i,o,c,l,a,u);if(g===oi)d.length!==0&&(e.redoStack=[],r.dispatchCommand(kn,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(An,!0));else if(g===li)return;e.current={editor:r,editorState:o}}))}function Rd(){return{current:null,redoStack:[],undoStack:[]}}function Pd({delay:r,externalHistoryState:e}){const[t]=wt();return function(n,s,o=1e3){const i=w.useMemo(()=>s||Rd(),[s]);w.useEffect(()=>Ld(n,i,o),[o,n,i])}(t,e,r),null}const Od=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Md({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=wt();return Od(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:o,dirtyLeaves:i,prevEditorState:l,tags:a})=>{e&&o.size===0&&i.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function ai(r,e){return ai=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},ai(r,e)}var Yo={error:null},Id=function(r){var e,t;function n(){for(var o,i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return(o=r.call.apply(r,[this].concat(l))||this).state=Yo,o.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];o.props.onReset==null||(u=o.props).onReset.apply(u,d),o.reset()},o}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,ai(e,t),n.getDerivedStateFromError=function(o){return{error:o}};var s=n.prototype;return s.reset=function(){this.setState(Yo)},s.componentDidCatch=function(o,i){var l,a;(l=(a=this.props).onError)==null||l.call(a,o,i)},s.componentDidUpdate=function(o,i){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&i.error!==null&&((u=o.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(h,g){return!Object.is(h,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,o.resetKeys,f),this.reset())},s.render=function(){var o=this.state.error,i=this.props,l=i.fallbackRender,a=i.FallbackComponent,u=i.fallback;if(o!==null){var c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(Ds.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return Ds.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(Ds.Component);function $d({children:r,onError:e}){return p.jsx(Id,{fallback:p.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function zd(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ft=zd(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function qd(r){let e=1,t=r.getParent();for(;t!=null;){if(Fe(t)){const n=t.getParent();if(ue(n)){e++,t=n.getParent();continue}Ft(40)}return e}return e}function ui(r){let e=r.getParent();ue(e)||Ft(40);let t=e;for(;t!==null;)t=t.getParent(),ue(t)&&(e=t);return e}function Na(r){let e=[];const t=r.getChildren().filter(Fe);for(let n=0;n<t.length;n++){const s=t[n],o=s.getFirstChild();ue(o)?e=e.concat(Na(o)):e.push(s)}return e}function jt(r){return Fe(r)&&ue(r.getFirstChild())}function Xo(r){return ut().append(r)}function Fa(r,e){return Fe(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Zo(r,e){r.update(()=>{const t=V();if(t!==null){const n=t.getNodes();if(P(t)){const o=t.getStartEndPoints();o===null&&Ft(143);const[i]=o,l=i.getNode(),a=l.getParent();if(Fa(l,n)){const u=it(e);if(Rt(a)){l.replace(u);const c=ut();F(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Fe(l)){const c=l.getParentOrThrow();yr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(!F(i)||!i.isEmpty()||Fe(i)||s.has(i.getKey())){if(Rl(i)){let l=i.getParent();for(;l!=null;){const a=l.getKey();if(ue(l)){if(!s.has(a)){const u=it(e);yr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Rt(u)&&!s.has(a)){s.add(a),el(l,e);break}l=u}}}}else el(i,e)}}})}function yr(r,e){r.splice(r.getChildrenSize(),0,e)}function el(r,e){if(ue(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=ut();let o;if(yr(s,r.getChildren()),ue(t)&&e===t.getListType())t.append(s),ue(n)&&e===n.getListType()&&(yr(t,n.getChildren()),n.remove()),o=t;else if(ue(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),o=n;else{const i=it(e);i.append(s),r.replace(i),o=i}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),o}function Ii(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&jt(t)&&jt(n)&&(Ii(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Ud(r){r.update(()=>{const e=V();if(P(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Fa(s,n))t.add(ui(s));else for(let o=0;o<n.length;o++){const i=n[o];if(Rl(i)){const l=nd(i,br);l!=null&&t.add(ui(l))}}for(const o of t){let i=o;const l=Na(o);for(const a of l){const u=ze();yr(u,a.getChildren()),i.insertAfter(u),i=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}o.remove()}}})}function Wd(r){const e=new Set;if(jt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(jt(n)&&jt(s)){const o=s.getFirstChild();if(ue(o)){o.append(r);const i=n.getFirstChild();ue(i)&&(yr(o,i.getChildren()),n.remove(),e.add(n.getKey()))}}else if(jt(n)){const o=n.getFirstChild();if(ue(o)){const i=o.getFirstChild();i!==null&&i.insertBefore(r)}}else if(jt(s)){const o=s.getFirstChild();ue(o)&&o.append(r)}else if(ue(t)){const o=ut(),i=it(t.getListType());o.append(i),i.append(r),s?s.insertAfter(o):n?n.insertBefore(o):t.append(o)}}function Gd(r){if(jt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(ue(t?t.getParent():void 0)&&Fe(t)&&ue(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const o=e.getListType(),i=ut(),l=it(o);i.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=ut(),u=it(o);a.append(u),yr(u,r.getNextSiblings()),t.insertBefore(i),t.insertAfter(a),t.replace(r)}}}function Kd(){const r=V();if(!P(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Fe(e)||e.getChildrenSize()!==0)return!1;const t=ui(e),n=e.getParent();ue(n)||Ft(40);const s=n.getParent();let o;if(Rt(s))o=ze(),t.insertAfter(o);else{if(!Fe(s))return!1;o=ut(),s.insertAfter(o)}o.select();const i=e.getNextSiblings();if(i.length>0){const l=it(n.getListType());if(Lr(o))o.insertAfter(l);else{const a=ut();a.append(l),o.insertAfter(a)}i.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!Fe(a)&&!ue(a))break;a=u}a.remove()}(e),!0}function ns(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class br extends Ht{static getType(){return"listitem"}static clone(e){return new br(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return ue(n)&&n.getListType()==="check"&&rl(t,this,null),t.value=this.__value,tl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return ue(s)&&s.getListType()==="check"&&rl(t,this,e),t.value=this.__value,tl(t,n.theme,this),!1}static transform(){return e=>{if(Fe(e)||Ft(144),e.__checked==null)return;const t=e.getParent();ue(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Vd,priority:0})}}static importJSON(e){const t=ut();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(F(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Fe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!ue(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=it(n.getListType());let o=this.getNextSibling();for(;o;){const i=o;o=o.getNextSibling(),s.append(i)}n.insertAfter(e),e.insertAfter(s)}return t&&(F(e)||Ft(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(ue(n)||Ft(39),Fe(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const o=it(n.getListType());s.forEach(i=>o.append(i)),e.insertAfter(o,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&jt(t)&&jt(n)&&(Ii(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=ut(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=ze();this.getChildren().forEach(i=>t.append(i));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),o=Fe(s);if(n.getChildrenSize()===1)if(o)n.remove(),s.select();else{n.insertBefore(t),n.remove();const i=e.anchor,l=e.focus,a=t.getKey();i.type==="element"&&i.getNode().is(this)&&i.set(a,i.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return ue(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;Fe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ft(117),(e=Math.floor(e))>=0||Ft(199);let t=this.getIndent();for(;t!==e;)t<e?(Wd(this),t++):(Gd(this),t--);return this}canInsertAfter(e){return Fe(e)}canReplaceWith(e){return Fe(e)}canMergeWith(e){return Lr(e)||Fe(e)}extractWithChild(e,t){if(!P(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return it("bullet")}canMergeWhenEmpty(){return!0}}function tl(r,e,t){const n=[],s=[],o=e.list,i=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),i!==void 0&&n.push(...ns(i)),o){const a=t.getParent(),u=ue(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(o.listitemUnchecked),u&&c||s.push(o.listitemChecked),u&&n.push(c?o.listitemChecked:o.listitemUnchecked)}if(l!==void 0){const a=ns(l);t.getChildren().some(u=>ue(u))?n.push(...a):s.push(...a)}s.length>0&&wa(r,...s),n.length>0&&Dn(r,...n)}function rl(r,e,t,n){ue(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Vd(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Hd(t)}const e=r.getAttribute("aria-checked");return{node:ut(e==="true"||e!=="false"&&void 0)}}function Hd(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:ut(r.hasAttribute("checked"))}}function ut(r){return Ot(new br(void 0,r))}function Fe(r){return r instanceof br}class Mr extends Ht{static getType(){return"list"}static clone(e){const t=e.__listType||il[e.__tag];return new Mr(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=il[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,nl(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(nl(t,n.theme,this),!1)}static transform(){return e=>{ue(e)||Ft(163),function(t){const n=t.getNextSibling();ue(n)&&t.getListType()===n.getListType()&&Ii(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const o of t.getChildren())Fe(o)&&(o.getValue()!==s&&o.setValue(s),n&&o.getLatest().__checked!=null&&o.setChecked(void 0),ue(o.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:sl,priority:0}),ul:()=>({conversion:sl,priority:0})}}static importJSON(e){const t=it(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&Kt(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Fe(n))super.append(n);else{const s=ut();if(ue(n))s.append(n);else if(F(n))if(n.isInline())s.append(n);else{const o=Ue(n.getTextContent());s.append(o)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Fe(e)}}function nl(r,e,t){const n=[],s=[],o=e.list;if(o!==void 0){const i=o[`${t.__tag}Depth`]||[],l=qd(t)-1,a=l%i.length,u=i[a],c=o[t.__tag];let d;const f=o.nested,h=o.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),h!==void 0&&t.__listType==="check"&&n.push(h),u!==void 0){n.push(...ns(u));for(let g=0;g<i.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=ns(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&wa(r,...s),n.length>0&&Dn(r,...n)}function Jd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Fe(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(o=>{ue(o)&&e.push(Xo(o))})}else e.push(Xo(n))}return e}function sl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=it("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(Kt(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?it("check"):it("bullet")),{after:Jd,node:t}}const il={ol:"number",ul:"bullet"};function it(r,e=1){return Ot(new Mr(r,e))}function ue(r){return r instanceof Mr}const ja=hn(),La=hn(),Qd=hn();function Yd(r){return xr(r.registerCommand(La,()=>(Zo(r,"number"),!0),kr),r.registerCommand(ja,()=>(Zo(r,"bullet"),!0),kr),r.registerCommand(Qd,()=>(Ud(r),!0),kr),r.registerCommand(on,()=>!!Kd(),kr))}function Xd(){const[r]=wt();return w.useEffect(()=>{if(!r.hasNodes([Mr,br]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){w.useEffect(()=>Yd(e),[e])}(r),null}const Zd=new Set(["http:","https:","mailto:","sms:","tel:"]);class _r extends Ht{static getType(){return"link"}static clone(e){return new _r(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:o=null,title:i=null}=t;this.__url=e,this.__target=s,this.__rel=o,this.__title=i}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Dn(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,o=this.__target,i=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),o!==e.__target&&(o?t.target=o:t.removeAttribute("target")),i!==e.__rel&&(i?t.rel=i:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ef,priority:1})}}static importJSON(e){const t=ss(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!Zd.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=ss(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!P(t))return!1;const s=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(o)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ef(r){let e=null;if(fc(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=ss(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function ss(r,e){return Ot(new _r(r,e))}function Gr(r){return r instanceof _r}class Sn extends _r{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new Sn(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=ol(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(F(n)){const s=ol(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function ol(r,e){return Ot(new Sn(r,e))}function tf(r){return r instanceof Sn}const ll=hn();function Is(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,o=V();if(!P(o))return;const i=o.extract();if(r===null)i.forEach(l=>{const a=bs(l,u=>!tf(u)&&Gr(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(i.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(i[0],Gr);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;i.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!F(u)||u.isInline())){if(Gr(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=ss(r,{rel:s,target:t,title:n}),Gr(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),Gr(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function rf({validateUrl:r,attributes:e}){const[t]=wt();return w.useEffect(()=>{if(!t.hasNodes([_r]))throw new Error("LinkPlugin: LinkNode not registered on editor");return xr(t.registerCommand(ll,n=>{if(n===null)return Is(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(Is(n,e),!0);{const{url:s,target:o,rel:i,title:l}=n;return Is(s,{...e,rel:i,target:o,title:l}),!0}},kr),r!==void 0?t.registerCommand(os,n=>{const s=V();if(!P(s)||s.isCollapsed()||!tr(n,ClipboardEvent))return!1;const o=n;if(o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return!!r(i)&&!s.getNodes().some(l=>F(l))&&(t.dispatchCommand(ll,{...e,url:i}),n.preventDefault(),!0)},kr):()=>{})},[t,r,e]),null}function nf(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return console.log("[ImageNode] Converting img element, src length:",e.length,"alt:",t),{node:Ra({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}class Cs extends pa{constructor(t,n,s,o,i){super(i);qt(this,"__src");qt(this,"__altText");qt(this,"__width");qt(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=o}static getType(){return"image"}static clone(t){return new Cs(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:o,height:i}=t;return Ra({src:n,altText:s,width:o,height:i})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:nf,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){var n;const t=document.createElement("img");return t.src=this.__src,t.alt=this.__altText,this.__width&&(t.width=this.__width),this.__height&&(t.height=this.__height),t.style.maxWidth="100%",t.style.height="auto",t.style.display="block",t.style.margin="8px 0",t.style.borderRadius="4px",t.style.backgroundColor="red",t.style.minWidth="150px",t.style.minHeight="150px",console.log("[ImageNode] createDOM() - src length:",(n=this.__src)==null?void 0:n.length),t}updateDOM(t){return t.__src!==this.__src}decorate(){return null}}function Ra(r){return new Cs(r.src,r.altText,r.width,r.height)}const sf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},of={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function lf({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:o,aiProcessingAction:i,onAiAction:l,hasContent:a}){const[u]=wt(),[c,d]=w.useState(!1),f=w.useRef(null),h=t||n||s,g=w.useCallback(()=>{u.dispatchCommand(vt,"bold")},[u]),m=w.useCallback(()=>{u.dispatchCommand(vt,"italic")},[u]),b=w.useCallback(()=>{u.dispatchCommand(vt,"underline")},[u]),C=w.useCallback(()=>{u.dispatchCommand(ja,void 0)},[u]),v=w.useCallback(()=>{u.dispatchCommand(La,void 0)},[u]),E=w.useCallback(()=>{u.update(()=>{const _=V();P(_)&&Yc(_,()=>Mi())})},[u]),D={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},k=`
|
|
73
|
+
`?a.insertParagraph():u===" "?a.insertNodes([_n()]):a.insertText(u)}}}else e.insertRawText(o)}function Io(r,e,t){r.dispatchCommand(wu,{nodes:e,selection:t})||t.insertNodes(e)}function Ta(r,e,t,n=[]){let s=e===null||t.isSelected(e);const o=F(t)&&t.excludeFromCopy("html");let i=t;if(e!==null){let u=Ni(t);u=z(u)&&e!==null?_a(e,u):u,i=u}const l=F(i)?i.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&rs(58,d.name),F(u)){const f=c.children;Array.isArray(f)||rs(59,d.name)}return c}(i);if(z(i)){const u=i.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Ta(r,e,c,a.children);!s&&F(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!o)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function cd(r,e){const t=[],n=Be().getChildren();for(let s=0;s<n.length;s++)Ta(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function dd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=jc(n);z(s)&&Qc(s),e.push(s)}return e}let wr=null;async function $o(r,e,t){if(wr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(zo(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,o=ht(r._window);if(n===null||o===null)return!1;const i=s.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(s.createTextNode("#")),n.append(i);const l=new Range;return l.setStart(i,0),l.setEnd(i,1),o.removeAllRanges(),o.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ls,d=>(tr(d,ClipboardEvent)&&(c(),wr!==null&&(window.clearTimeout(wr),wr=null),a(zo(r,d,t))),!0),Rc);wr=window.setTimeout(()=>{c(),wr=null,a(!1)},50),s.execCommand("copy"),i.remove()})}function zo(r,e,t){if(t===void 0){const s=ht(r._window);if(!s)return!1;const o=s.anchorNode,i=s.focusNode;if(o!==null&&i!==null&&!mn(r,o,i))return!1;const l=V();if(l===null)return!1;t=hd(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(pd(n,t),!0)}const fd=[["text/html",ad],["application/x-lexical-editor",ud]];function hd(r=V()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=hc();for(const[n,s]of fd){const o=s(t,r);o!==null&&(e[n]=o)}}return e}function pd(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function qo(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const Or=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,gd=Or&&"documentMode"in document?document.documentMode:null,md=!(!Or||!("InputEvent"in window)||gd)&&"getTargetRanges"in new window.InputEvent("input"),yd=Or&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Uo=Or&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,xd=Or&&/^(?=.*Chrome).*/i.test(navigator.userAgent),bd=Or&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!xd,Wo=hn();class _s extends Ht{static getType(){return"quote"}static clone(e){return new _s(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return Dn(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:_d,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Mi();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=ze(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=ze();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function Mi(){return Ot(new _s)}class vs extends Ht{static getType(){return"heading"}static clone(e){return new vs(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const o=s[t];Dn(n,o)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Dr,priority:0}),h2:e=>({conversion:Dr,priority:0}),h3:e=>({conversion:Dr,priority:0}),h4:e=>({conversion:Dr,priority:0}),h5:e=>({conversion:Dr,priority:0}),h6:e=>({conversion:Dr,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Go(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Go(e)?{conversion:t=>({node:Jr("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&Kt(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Jr(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),o=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?ze():Jr(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,t),n===0&&!this.isEmpty()&&e){const l=ze();l.select(),this.replace(l,!0)}return o}collapseAtStart(){const e=this.isEmpty()?ze():Jr(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function Go(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Dr(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=Jr(e),r.style!==null&&(Fi(r,t),t.setFormat(r.style.textAlign))),{node:t}}function _d(r){const e=Mi();return r.style!==null&&(e.setFormat(r.style.textAlign),Fi(r,e)),{node:e}}function Jr(r){return Ot(new vs(r))}function Fn(r){let e=null;if(tr(r,DragEvent)?e=r.dataTransfer:tr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function Ko(r){const e=V();if(!P(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const o=n[s],i=o.getKey();if(t.has(i))continue;const l=bs(o,u=>F(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function jn(r){const e=jr(r);return _e(e)}function vd(r){return xr(r.registerCommand(gl,e=>{const t=V();return!!Nt(t)&&(t.clear(),!0)},0),r.registerCommand(cr,e=>{const t=V();return!!P(t)&&(t.deleteCharacter(e),!0)},fe),r.registerCommand(ln,e=>{const t=V();return!!P(t)&&(t.deleteWord(e),!0)},fe),r.registerCommand(an,e=>{const t=V();return!!P(t)&&(t.deleteLine(e),!0)},fe),r.registerCommand(Tr,e=>{const t=V();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)Mo(n,t,r);else if(P(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},fe),r.registerCommand(qs,()=>{const e=V();return!!P(e)&&(e.removeText(),!0)},fe),r.registerCommand(vt,e=>{const t=V();return!!P(t)&&(t.formatText(e),!0)},fe),r.registerCommand(Nu,e=>{const t=V();if(!P(t)&&!Nt(t))return!1;const n=t.getNodes();for(const s of n){const o=bs(s,i=>F(i)&&!i.isInline());o!==null&&o.setFormat(e)}return!0},fe),r.registerCommand(Ar,e=>{const t=V();return!!P(t)&&(t.insertLineBreak(e),!0)},fe),r.registerCommand(on,()=>{const e=V();return!!P(e)&&(e.insertParagraph(),!0)},fe),r.registerCommand(Tu,()=>(aa([_n()]),!0),fe),r.registerCommand(Bu,()=>Ko(e=>{const t=e.getIndent();e.setIndent(t+1)}),fe),r.registerCommand(Qi,()=>Ko(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),fe),r.registerCommand(xl,e=>{const t=V();if(Nt(t)&&!jn(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(P(t)){const n=un(t.focus,!0);if(!e.shiftKey&&_e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},fe),r.registerCommand(bl,e=>{const t=V();if(Nt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(P(t)){if(function(s){const o=s.focus;return o.key==="root"&&o.offset===Be().getChildrenSize()}(t))return e.preventDefault(),!0;const n=un(t.focus,!1);if(!e.shiftKey&&_e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},fe),r.registerCommand(yl,e=>{const t=V();if(Nt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!P(t))return!1;if(Ro(t,!0)){const n=e.shiftKey;return e.preventDefault(),Po(t,n,!0),!0}return!1},fe),r.registerCommand(ml,e=>{const t=V();if(Nt(t)&&!jn(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!P(t))return!1;const n=e.shiftKey;return!!Ro(t,!1)&&(e.preventDefault(),Po(t,n,!1),!0)},fe),r.registerCommand(_l,e=>{if(jn(e.target))return!1;const t=V();if(!P(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!Ze(s)&&sd(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Qi,void 0)):(!Uo||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(cr,!0))},fe),r.registerCommand(Cl,e=>{if(jn(e.target))return!1;const t=V();return!!P(t)&&(e.preventDefault(),r.dispatchCommand(cr,!1))},fe),r.registerCommand($n,e=>{const t=V();if(!P(t))return!1;if(e!==null){if((Uo||yd||bd)&&md)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Ar,!1)}return r.dispatchCommand(on,void 0)},fe),r.registerCommand(vl,()=>{const e=V();return!!P(e)&&(r.blur(),!0)},fe),r.registerCommand(wl,e=>{const[,t]=Fn(e);if(t.length>0){const s=qo(e.clientX,e.clientY);if(s!==null){const{offset:o,node:i}=s,l=jr(i);if(l!==null){const a=Tc();if(z(l))a.anchor.set(l.getKey(),o,"text"),a.focus.set(l.getKey(),o,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=jl(a);Lt(u)}r.dispatchCommand(Wo,t)}return e.preventDefault(),!0}const n=V();return!!P(n)},fe),r.registerCommand(Dl,e=>{const[t]=Fn(e),n=V();return!(t&&!P(n))},fe),r.registerCommand(Sl,e=>{const[t]=Fn(e),n=V();if(t&&!P(n))return!1;const s=qo(e.clientX,e.clientY);if(s!==null){const o=jr(s.node);_e(o)&&e.preventDefault()}return!0},fe),r.registerCommand(Us,()=>(uc(),!0),fe),r.registerCommand(ls,e=>($o(r,tr(e,ClipboardEvent)?e:null),!0),fe),r.registerCommand(pi,e=>(async function(t,n){await $o(n,tr(t,ClipboardEvent)?t:null),n.update(()=>{const s=V();P(s)?s.removeText():Nt(s)&&s.getNodes().forEach(o=>o.remove())})}(e,r),!0),fe),r.registerCommand(os,e=>{const[,t,n]=Fn(e);return t.length>0&&!n?(r.dispatchCommand(Wo,t),!0):Di(e.target)?!1:V()!==null&&(function(s,o){s.preventDefault(),o.update(()=>{const i=V(),l=tr(s,InputEvent)||tr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&i!==null&&Mo(l,i,o)},{tag:"paste"})}(e,r),!0)},fe))}const ii=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Vo(r){return r.getEditorState().read(ba(r.isComposing()))}function Cd({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=wt(),s=function(o,i){const[l,a]=w.useState(()=>o.getDecorators());return ii(()=>o.registerDecoratorListener(u=>{$i.flushSync(()=>{a(u)})}),[o]),w.useEffect(()=>{a(o.getDecorators())},[o]),w.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],h=p.jsx(i,{onError:m=>o._onError(m),children:p.jsx(w.Suspense,{fallback:null,children:l[f]})}),g=o.getElementByKey(f);g!==null&&u.push($i.createPortal(h,g,f))}return u},[i,l,o])}(n,t);return function(o){ii(()=>xr(vd(o),id(o)),[o])}(n),p.jsxs(p.Fragment,{children:[r,p.jsx(wd,{content:e}),s]})}function wd({content:r}){const[e]=wt(),t=function(s){const[o,i]=w.useState(()=>Vo(s));return ii(()=>{function l(){const a=Vo(s);i(a)}return l(),xr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),o}(e),n=zc();return t?typeof r=="function"?r(n):r:null}const Ba=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Dd({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:o,ariaExpanded:i,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:h,className:g,id:m,role:b="textbox",spellCheck:C=!0,style:v,tabIndex:E,"data-testid":D,...k},y){const[_,S]=w.useState(r.isEditable()),A=w.useCallback(B=>{B&&B.ownerDocument&&B.ownerDocument.defaultView?r.setRootElement(B):r.setRootElement(null)},[r]),I=w.useMemo(()=>function(...B){return N=>{B.forEach(j=>{typeof j=="function"?j(N):j!=null&&(j.current=N)})}}(y,A),[A,y]);return Ba(()=>(S(r.isEditable()),r.registerEditableListener(B=>{S(B)})),[r]),p.jsx("div",{"aria-activedescendant":_?e:void 0,"aria-autocomplete":_?t:"none","aria-controls":_?n:void 0,"aria-describedby":s,...o!=null?{"aria-errormessage":o}:{},"aria-expanded":_&&b==="combobox"?!!i:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":_?d:void 0,"aria-readonly":!_||void 0,"aria-required":f,autoCapitalize:h,className:g,contentEditable:_,"data-testid":D,id:m,ref:I,role:_?b:void 0,spellCheck:C,style:v,tabIndex:E,...k})}const Sd=w.forwardRef(Dd);function Ho(r){return r.getEditorState().read(ba(r.isComposing()))}const Ed=w.forwardRef(kd);function kd(r,e){const{placeholder:t,...n}=r,[s]=wt();return p.jsxs(p.Fragment,{children:[p.jsx(Sd,{editor:s,...n,ref:e}),t!=null&&p.jsx(Ad,{editor:s,content:t})]})}function Ad({content:r,editor:e}){const t=function(i){const[l,a]=w.useState(()=>Ho(i));return Ba(()=>{function u(){const c=Ho(i);a(c)}return u(),xr(i.registerUpdateListener(()=>{u()}),i.registerEditableListener(()=>{u()}))},[i]),l}(e),[n,s]=w.useState(e.isEditable());if(w.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(i=>{s(i)})),[e]),!t)return null;let o=null;return typeof r=="function"?o=r(n):r!==null&&(o=r),o===null?null:p.jsx("div",{"aria-hidden":!0,children:o})}const Ln=0,oi=1,li=2,_t=0,Td=1,Jo=2,Bd=3,Nd=4;function Fd(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return _t;const o=e._selection,i=r._selection;if(s)return Td;if(!(P(o)&&P(i)&&i.isCollapsed()&&o.isCollapsed()))return _t;const l=function(C,v,E){const D=C._nodeMap,k=[];for(const y of v){const _=D.get(y);_!==void 0&&k.push(_)}for(const[y,_]of E){if(!_)continue;const S=D.get(y);S===void 0||Ze(S)||k.push(S)}return k}(e,t,n);if(l.length===0)return _t;if(l.length>1){const C=e._nodeMap,v=C.get(o.anchor.key),E=C.get(i.anchor.key);return v&&E&&!r._nodeMap.has(v.__key)&&z(v)&&v.__text.length===1&&o.anchor.offset===1?Jo:_t}const a=l[0],u=r._nodeMap.get(a.__key);if(!z(u)||!z(a)||u.__mode!==a.__mode)return _t;const c=u.__text,d=a.__text;if(c===d)return _t;const f=o.anchor,h=i.anchor;if(f.key!==h.key||f.type!=="text")return _t;const g=f.offset,m=h.offset,b=d.length-c.length;return b===1&&m===g-1?Jo:b===-1&&m===g+1?Bd:b===-1&&m===g?Nd:_t}function jd(r,e){let t=Date.now(),n=_t;return(s,o,i,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=_t,t=c,li;const d=Fd(s,o,l,a,r.isComposing()),f=(()=>{const h=i===null||i.editor===r,g=u.has("history-push");if(!g&&h&&u.has("history-merge"))return Ln;if(s===null)return oi;const m=o._selection;return l.size>0||a.size>0?g===!1&&d!==_t&&d===n&&c<t+e&&h||l.size===1&&function(b,C,v){const E=C._nodeMap.get(b),D=v._nodeMap.get(b),k=C._selection,y=v._selection;return!(P(k)&&P(y)&&k.anchor.type==="element"&&k.focus.type==="element"&&y.anchor.type==="text"&&y.focus.type==="text"||!z(E)||!z(D)||E.__parent!==D.__parent)&&JSON.stringify(C.read(()=>E.exportJSON()))===JSON.stringify(v.read(()=>D.exportJSON()))}(Array.from(l)[0],s,o)?Ln:oi:m!==null?Ln:li})();return t=c,n=d,f}}function Qo(r){r.undoStack=[],r.redoStack=[],r.current=null}function Ld(r,e,t){const n=jd(r,t);return xr(r.registerCommand(fi,()=>(function(o,i){const l=i.redoStack,a=i.undoStack;if(a.length!==0){const u=i.current,c=a.pop();u!==null&&(l.push(u),o.dispatchCommand(kn,!0)),a.length===0&&o.dispatchCommand(An,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),fe),r.registerCommand(hi,()=>(function(o,i){const l=i.redoStack,a=i.undoStack;if(l.length!==0){const u=i.current;u!==null&&(a.push(u),o.dispatchCommand(An,!0));const c=l.pop();l.length===0&&o.dispatchCommand(kn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),fe),r.registerCommand(ju,()=>(Qo(e),!1),fe),r.registerCommand(Lu,()=>(Qo(e),r.dispatchCommand(kn,!1),r.dispatchCommand(An,!1),!0),fe),r.registerUpdateListener(({editorState:o,prevEditorState:i,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,h=c===null?null:c.editorState;if(c!==null&&o===h)return;const g=n(i,o,c,l,a,u);if(g===oi)d.length!==0&&(e.redoStack=[],r.dispatchCommand(kn,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(An,!0));else if(g===li)return;e.current={editor:r,editorState:o}}))}function Rd(){return{current:null,redoStack:[],undoStack:[]}}function Pd({delay:r,externalHistoryState:e}){const[t]=wt();return function(n,s,o=1e3){const i=w.useMemo(()=>s||Rd(),[s]);w.useEffect(()=>Ld(n,i,o),[o,n,i])}(t,e,r),null}const Od=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?w.useLayoutEffect:w.useEffect;function Md({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=wt();return Od(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:o,dirtyLeaves:i,prevEditorState:l,tags:a})=>{e&&o.size===0&&i.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function ai(r,e){return ai=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},ai(r,e)}var Yo={error:null},Id=function(r){var e,t;function n(){for(var o,i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return(o=r.call.apply(r,[this].concat(l))||this).state=Yo,o.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];o.props.onReset==null||(u=o.props).onReset.apply(u,d),o.reset()},o}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,ai(e,t),n.getDerivedStateFromError=function(o){return{error:o}};var s=n.prototype;return s.reset=function(){this.setState(Yo)},s.componentDidCatch=function(o,i){var l,a;(l=(a=this.props).onError)==null||l.call(a,o,i)},s.componentDidUpdate=function(o,i){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&i.error!==null&&((u=o.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(h,g){return!Object.is(h,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,o.resetKeys,f),this.reset())},s.render=function(){var o=this.state.error,i=this.props,l=i.fallbackRender,a=i.FallbackComponent,u=i.fallback;if(o!==null){var c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(Ds.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return Ds.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(Ds.Component);function $d({children:r,onError:e}){return p.jsx(Id,{fallback:p.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function zd(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ft=zd(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function qd(r){let e=1,t=r.getParent();for(;t!=null;){if(Fe(t)){const n=t.getParent();if(ue(n)){e++,t=n.getParent();continue}Ft(40)}return e}return e}function ui(r){let e=r.getParent();ue(e)||Ft(40);let t=e;for(;t!==null;)t=t.getParent(),ue(t)&&(e=t);return e}function Na(r){let e=[];const t=r.getChildren().filter(Fe);for(let n=0;n<t.length;n++){const s=t[n],o=s.getFirstChild();ue(o)?e=e.concat(Na(o)):e.push(s)}return e}function jt(r){return Fe(r)&&ue(r.getFirstChild())}function Xo(r){return ut().append(r)}function Fa(r,e){return Fe(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Zo(r,e){r.update(()=>{const t=V();if(t!==null){const n=t.getNodes();if(P(t)){const o=t.getStartEndPoints();o===null&&Ft(143);const[i]=o,l=i.getNode(),a=l.getParent();if(Fa(l,n)){const u=it(e);if(Rt(a)){l.replace(u);const c=ut();F(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Fe(l)){const c=l.getParentOrThrow();yr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(!F(i)||!i.isEmpty()||Fe(i)||s.has(i.getKey())){if(Rl(i)){let l=i.getParent();for(;l!=null;){const a=l.getKey();if(ue(l)){if(!s.has(a)){const u=it(e);yr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Rt(u)&&!s.has(a)){s.add(a),el(l,e);break}l=u}}}}else el(i,e)}}})}function yr(r,e){r.splice(r.getChildrenSize(),0,e)}function el(r,e){if(ue(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=ut();let o;if(yr(s,r.getChildren()),ue(t)&&e===t.getListType())t.append(s),ue(n)&&e===n.getListType()&&(yr(t,n.getChildren()),n.remove()),o=t;else if(ue(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),o=n;else{const i=it(e);i.append(s),r.replace(i),o=i}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),o}function Ii(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&jt(t)&&jt(n)&&(Ii(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Ud(r){r.update(()=>{const e=V();if(P(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Fa(s,n))t.add(ui(s));else for(let o=0;o<n.length;o++){const i=n[o];if(Rl(i)){const l=nd(i,br);l!=null&&t.add(ui(l))}}for(const o of t){let i=o;const l=Na(o);for(const a of l){const u=ze();yr(u,a.getChildren()),i.insertAfter(u),i=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}o.remove()}}})}function Wd(r){const e=new Set;if(jt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(jt(n)&&jt(s)){const o=s.getFirstChild();if(ue(o)){o.append(r);const i=n.getFirstChild();ue(i)&&(yr(o,i.getChildren()),n.remove(),e.add(n.getKey()))}}else if(jt(n)){const o=n.getFirstChild();if(ue(o)){const i=o.getFirstChild();i!==null&&i.insertBefore(r)}}else if(jt(s)){const o=s.getFirstChild();ue(o)&&o.append(r)}else if(ue(t)){const o=ut(),i=it(t.getListType());o.append(i),i.append(r),s?s.insertAfter(o):n?n.insertBefore(o):t.append(o)}}function Gd(r){if(jt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(ue(t?t.getParent():void 0)&&Fe(t)&&ue(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const o=e.getListType(),i=ut(),l=it(o);i.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=ut(),u=it(o);a.append(u),yr(u,r.getNextSiblings()),t.insertBefore(i),t.insertAfter(a),t.replace(r)}}}function Kd(){const r=V();if(!P(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Fe(e)||e.getChildrenSize()!==0)return!1;const t=ui(e),n=e.getParent();ue(n)||Ft(40);const s=n.getParent();let o;if(Rt(s))o=ze(),t.insertAfter(o);else{if(!Fe(s))return!1;o=ut(),s.insertAfter(o)}o.select();const i=e.getNextSiblings();if(i.length>0){const l=it(n.getListType());if(Lr(o))o.insertAfter(l);else{const a=ut();a.append(l),o.insertAfter(a)}i.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!Fe(a)&&!ue(a))break;a=u}a.remove()}(e),!0}function ns(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class br extends Ht{static getType(){return"listitem"}static clone(e){return new br(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return ue(n)&&n.getListType()==="check"&&rl(t,this,null),t.value=this.__value,tl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return ue(s)&&s.getListType()==="check"&&rl(t,this,e),t.value=this.__value,tl(t,n.theme,this),!1}static transform(){return e=>{if(Fe(e)||Ft(144),e.__checked==null)return;const t=e.getParent();ue(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Vd,priority:0})}}static importJSON(e){const t=ut();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(F(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Fe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!ue(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=it(n.getListType());let o=this.getNextSibling();for(;o;){const i=o;o=o.getNextSibling(),s.append(i)}n.insertAfter(e),e.insertAfter(s)}return t&&(F(e)||Ft(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(ue(n)||Ft(39),Fe(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const o=it(n.getListType());s.forEach(i=>o.append(i)),e.insertAfter(o,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&jt(t)&&jt(n)&&(Ii(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=ut(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=ze();this.getChildren().forEach(i=>t.append(i));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),o=Fe(s);if(n.getChildrenSize()===1)if(o)n.remove(),s.select();else{n.insertBefore(t),n.remove();const i=e.anchor,l=e.focus,a=t.getKey();i.type==="element"&&i.getNode().is(this)&&i.set(a,i.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return ue(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;Fe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ft(117),(e=Math.floor(e))>=0||Ft(199);let t=this.getIndent();for(;t!==e;)t<e?(Wd(this),t++):(Gd(this),t--);return this}canInsertAfter(e){return Fe(e)}canReplaceWith(e){return Fe(e)}canMergeWith(e){return Lr(e)||Fe(e)}extractWithChild(e,t){if(!P(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return it("bullet")}canMergeWhenEmpty(){return!0}}function tl(r,e,t){const n=[],s=[],o=e.list,i=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),i!==void 0&&n.push(...ns(i)),o){const a=t.getParent(),u=ue(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(o.listitemUnchecked),u&&c||s.push(o.listitemChecked),u&&n.push(c?o.listitemChecked:o.listitemUnchecked)}if(l!==void 0){const a=ns(l);t.getChildren().some(u=>ue(u))?n.push(...a):s.push(...a)}s.length>0&&wa(r,...s),n.length>0&&Dn(r,...n)}function rl(r,e,t,n){ue(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Vd(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Hd(t)}const e=r.getAttribute("aria-checked");return{node:ut(e==="true"||e!=="false"&&void 0)}}function Hd(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:ut(r.hasAttribute("checked"))}}function ut(r){return Ot(new br(void 0,r))}function Fe(r){return r instanceof br}class Mr extends Ht{static getType(){return"list"}static clone(e){const t=e.__listType||il[e.__tag];return new Mr(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=il[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,nl(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(nl(t,n.theme,this),!1)}static transform(){return e=>{ue(e)||Ft(163),function(t){const n=t.getNextSibling();ue(n)&&t.getListType()===n.getListType()&&Ii(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const o of t.getChildren())Fe(o)&&(o.getValue()!==s&&o.setValue(s),n&&o.getLatest().__checked!=null&&o.setChecked(void 0),ue(o.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:sl,priority:0}),ul:()=>({conversion:sl,priority:0})}}static importJSON(e){const t=it(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&Kt(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Fe(n))super.append(n);else{const s=ut();if(ue(n))s.append(n);else if(F(n))if(n.isInline())s.append(n);else{const o=Ue(n.getTextContent());s.append(o)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Fe(e)}}function nl(r,e,t){const n=[],s=[],o=e.list;if(o!==void 0){const i=o[`${t.__tag}Depth`]||[],l=qd(t)-1,a=l%i.length,u=i[a],c=o[t.__tag];let d;const f=o.nested,h=o.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),h!==void 0&&t.__listType==="check"&&n.push(h),u!==void 0){n.push(...ns(u));for(let g=0;g<i.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=ns(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&wa(r,...s),n.length>0&&Dn(r,...n)}function Jd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Fe(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(o=>{ue(o)&&e.push(Xo(o))})}else e.push(Xo(n))}return e}function sl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=it("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(Kt(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?it("check"):it("bullet")),{after:Jd,node:t}}const il={ol:"number",ul:"bullet"};function it(r,e=1){return Ot(new Mr(r,e))}function ue(r){return r instanceof Mr}const ja=hn(),La=hn(),Qd=hn();function Yd(r){return xr(r.registerCommand(La,()=>(Zo(r,"number"),!0),kr),r.registerCommand(ja,()=>(Zo(r,"bullet"),!0),kr),r.registerCommand(Qd,()=>(Ud(r),!0),kr),r.registerCommand(on,()=>!!Kd(),kr))}function Xd(){const[r]=wt();return w.useEffect(()=>{if(!r.hasNodes([Mr,br]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){w.useEffect(()=>Yd(e),[e])}(r),null}const Zd=new Set(["http:","https:","mailto:","sms:","tel:"]);class _r extends Ht{static getType(){return"link"}static clone(e){return new _r(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:o=null,title:i=null}=t;this.__url=e,this.__target=s,this.__rel=o,this.__title=i}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Dn(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,o=this.__target,i=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),o!==e.__target&&(o?t.target=o:t.removeAttribute("target")),i!==e.__rel&&(i?t.rel=i:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ef,priority:1})}}static importJSON(e){const t=ss(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!Zd.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=ss(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!P(t))return!1;const s=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(o)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ef(r){let e=null;if(fc(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=ss(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function ss(r,e){return Ot(new _r(r,e))}function Gr(r){return r instanceof _r}class Sn extends _r{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new Sn(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=ol(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(F(n)){const s=ol(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function ol(r,e){return Ot(new Sn(r,e))}function tf(r){return r instanceof Sn}const ll=hn();function Is(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,o=V();if(!P(o))return;const i=o.extract();if(r===null)i.forEach(l=>{const a=bs(l,u=>!tf(u)&&Gr(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(i.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(i[0],Gr);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;i.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!F(u)||u.isInline())){if(Gr(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=ss(r,{rel:s,target:t,title:n}),Gr(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),Gr(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function rf({validateUrl:r,attributes:e}){const[t]=wt();return w.useEffect(()=>{if(!t.hasNodes([_r]))throw new Error("LinkPlugin: LinkNode not registered on editor");return xr(t.registerCommand(ll,n=>{if(n===null)return Is(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(Is(n,e),!0);{const{url:s,target:o,rel:i,title:l}=n;return Is(s,{...e,rel:i,target:o,title:l}),!0}},kr),r!==void 0?t.registerCommand(os,n=>{const s=V();if(!P(s)||s.isCollapsed()||!tr(n,ClipboardEvent))return!1;const o=n;if(o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return!!r(i)&&!s.getNodes().some(l=>F(l))&&(t.dispatchCommand(ll,{...e,url:i}),n.preventDefault(),!0)},kr):()=>{})},[t,r,e]),null}function nf(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Ra({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function sf({src:r,alt:e,width:t,height:n}){return p.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class Cs extends pa{constructor(t,n,s,o,i){super(i);qt(this,"__src");qt(this,"__altText");qt(this,"__width");qt(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=o}static getType(){return"image"}static clone(t){return new Cs(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:o,height:i}=t;return Ra({src:n,altText:s,width:o,height:i})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:nf,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return p.jsx(sf,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Ra(r){return new Cs(r.src,r.altText,r.width,r.height)}const of={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},lf={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function af({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:o,aiProcessingAction:i,onAiAction:l,hasContent:a}){const[u]=wt(),[c,d]=w.useState(!1),f=w.useRef(null),h=t||n||s,g=w.useCallback(()=>{u.dispatchCommand(vt,"bold")},[u]),m=w.useCallback(()=>{u.dispatchCommand(vt,"italic")},[u]),b=w.useCallback(()=>{u.dispatchCommand(vt,"underline")},[u]),C=w.useCallback(()=>{u.dispatchCommand(ja,void 0)},[u]),v=w.useCallback(()=>{u.dispatchCommand(La,void 0)},[u]),E=w.useCallback(()=>{u.update(()=>{const _=V();P(_)&&Yc(_,()=>Mi())})},[u]),D={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},k=`
|
|
74
74
|
.mail-editor-toolbar-btn:hover:not(:disabled) {
|
|
75
75
|
background: ${r.border};
|
|
76
76
|
}
|
|
77
|
-
`,y=()=>{setTimeout(()=>{var _;(_=f.current)!=null&&_.contains(document.activeElement)||d(!1)},150)};return p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[p.jsx("style",{children:k}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:D,title:"Bold (Ctrl+B)",children:"B"}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...D,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:{...D,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),p.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:C,disabled:e,style:D,title:"Bullet List",children:p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[p.jsx("circle",{cx:"4",cy:"6",r:"2"}),p.jsx("circle",{cx:"4",cy:"12",r:"2"}),p.jsx("circle",{cx:"4",cy:"18",r:"2"}),p.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:v,disabled:e,style:D,title:"Numbered List",children:p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[p.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),p.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),p.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),p.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),p.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:E,disabled:e,style:D,title:"Quote",children:p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:p.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),h&&p.jsxs("div",{style:{position:"relative"},ref:f,children:[p.jsx("button",{type:"button",onClick:()=>d(!c),disabled:o||!a||e,onBlur:y,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:o||!a?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:o||!a||e?"not-allowed":"pointer",opacity:o||!a?.5:1},children:o?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),i==="restructure"&&"Restructuring...",i==="proofread"&&"Proofreading...",i==="rewrite"&&"Rewriting..."]}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",p.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!o&&p.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Restructure"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Proofread"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function
|
|
78
|
-
`).map(he=>`<p>${he||"<br>"}</p>`).join(""),X=async me=>{const he=L(k);if(!he)return;const ye=me==="restructure"?d:me==="proofread"?f:h;if(ye){S(!0),I(me);try{const xe=await ye(he),Se=$(xe);y(Se),e==null||e(Se),D.current=Date.now(),E(!0)}catch(xe){console.error(`AI ${me} failed:`,xe)}finally{S(!1),I(null)}}},ce=L(k).length>0,ve={namespace:"MailEditor",theme:
|
|
77
|
+
`,y=()=>{setTimeout(()=>{var _;(_=f.current)!=null&&_.contains(document.activeElement)||d(!1)},150)};return p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[p.jsx("style",{children:k}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:D,title:"Bold (Ctrl+B)",children:"B"}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...D,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:{...D,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),p.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:C,disabled:e,style:D,title:"Bullet List",children:p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[p.jsx("circle",{cx:"4",cy:"6",r:"2"}),p.jsx("circle",{cx:"4",cy:"12",r:"2"}),p.jsx("circle",{cx:"4",cy:"18",r:"2"}),p.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:v,disabled:e,style:D,title:"Numbered List",children:p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[p.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),p.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),p.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),p.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),p.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),p.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),p.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:E,disabled:e,style:D,title:"Quote",children:p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:p.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),h&&p.jsxs("div",{style:{position:"relative"},ref:f,children:[p.jsx("button",{type:"button",onClick:()=>d(!c),disabled:o||!a||e,onBlur:y,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:o||!a?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:o||!a||e?"not-allowed":"pointer",opacity:o||!a?.5:1},children:o?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),i==="restructure"&&"Restructuring...",i==="proofread"&&"Proofreading...",i==="rewrite"&&"Rewriting..."]}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",p.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!o&&p.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Restructure"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Proofread"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&p.jsxs("button",{type:"button",onClick:()=>{l==null||l("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:_=>_.currentTarget.style.background="#f3f4f6",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),p.jsxs("div",{children:[p.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),p.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function uf({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=wt(),s=w.useRef(!1);return w.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const o=Be();o.clear();const i=ze();o.append(i),i.select();const a=new DOMParser().parseFromString(r,"text/html"),c=Da(n,a).filter(d=>d.getParent()===null);c.length>0&&aa(c),i.getTextContent()===""&&o.getChildrenSize()>1&&i.remove(),o.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function cf({text:r,trigger:e}){const[t]=wt(),n=w.useRef(void 0);return w.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const o=V();if(P(o))o.insertText(s);else{const i=Be(),l=i.getLastChild();if(l){l.selectEnd();const a=V();P(a)&&a.insertText(s)}else{const a=ze(),u=Ue(s);a.append(u),i.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function df({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return p.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[p.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),p.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Pa({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:o=!1,className:i="",minHeight:l="200px",externalUpdate:a,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:f,onAiRewrite:h,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:b}){const C={...of,...s},[v,E]=w.useState(!1),D=w.useRef(void 0),[k,y]=w.useState(r),[_,S]=w.useState(!1),[A,I]=w.useState(null),B=g??_,N=m??A;w.useEffect(()=>{a!==void 0&&a!==D.current&&(D.current=a,E(!0))},[a]);const j=w.useCallback(()=>{E(!1)},[]),L=me=>me.replace(/<[^>]*>/g,"").trim(),$=me=>me.split(`
|
|
78
|
+
`).map(he=>`<p>${he||"<br>"}</p>`).join(""),X=async me=>{const he=L(k);if(!he)return;const ye=me==="restructure"?d:me==="proofread"?f:h;if(ye){S(!0),I(me);try{const xe=await ye(he),Se=$(xe);y(Se),e==null||e(Se),D.current=Date.now(),E(!0)}catch(xe){console.error(`AI ${me} failed:`,xe)}finally{S(!1),I(null)}}},ce=L(k).length>0,ve={namespace:"MailEditor",theme:lf,onError:me=>{console.error("Lexical error:",me)},nodes:[Mr,br,_r,Sn,vs,_s,Cs],editable:!o},le=w.useCallback((me,he)=>{me.read(()=>{const ye=Sa(he,null);y(ye),e==null||e(ye)})},[e]),Le=`
|
|
79
79
|
.mail-editor-paragraph {
|
|
80
80
|
margin: 0 0 8px 0;
|
|
81
81
|
line-height: 1.5;
|
|
@@ -145,9 +145,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
145
145
|
from { transform: rotate(0deg); }
|
|
146
146
|
to { transform: rotate(360deg); }
|
|
147
147
|
}
|
|
148
|
-
`;return p.jsxs("div",{className:i,style:{border:`1px solid ${C.border}`,borderRadius:"8px",background:C.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[p.jsx("style",{children:Le}),b,p.jsxs(Mc,{initialConfig:ve,children:[p.jsx(
|
|
148
|
+
`;return p.jsxs("div",{className:i,style:{border:`1px solid ${C.border}`,borderRadius:"8px",background:C.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[p.jsx("style",{children:Le}),b,p.jsxs(Mc,{initialConfig:ve,children:[p.jsx(af,{theme:C,disabled:o,onAiRestructure:d,onAiProofread:f,onAiRewrite:h,aiProcessing:B,aiProcessingAction:N,onAiAction:X,hasContent:ce}),p.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:p.jsx(Cd,{contentEditable:p.jsx(Ed,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:C.text}}),placeholder:p.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:$d})}),p.jsx(Xd,{}),p.jsx(rf,{}),p.jsx(Pd,{}),p.jsx(Md,{onChange:le}),p.jsx(uf,{html:v?k:r,isExternalUpdate:v,onImportComplete:j}),p.jsx(cf,{text:u,trigger:c})]}),n&&p.jsx(df,{replyTo:n,theme:C})]})}const ff={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function hf({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:o,onBodyChange:i,externalUpdate:l,insertText:a,insertTextTrigger:u,theme:c={},disabled:d=!1,showCcBcc:f=!1,placeholder:h="Write your message...",className:g="",minHeight:m="200px",sendButtonText:b="Send",hideCancelButton:C=!1,onAiRestructure:v,onAiProofread:E,onAiRewrite:D,renderAboveToolbar:k}){const y={...ff,...c},[_,S]=w.useState(r),[A,I]=w.useState(""),[B,N]=w.useState(""),[j,L]=w.useState(e),[$,X]=w.useState(t),[ce,ve]=w.useState([]),[le,Le]=w.useState(!1),[me,he]=w.useState(""),[ye,xe]=w.useState(f),[Se,pe]=w.useState(!1),Ce=w.useRef(void 0);w.useEffect(()=>{l!==void 0&&l!==Ce.current&&(Ce.current=l,X(t),pe(!0))},[l,t]);const Ne=W=>{X(W),pe(!1),i==null||i(W)},ae=w.useRef(null),[Re,ot]=w.useState(!1),St=W=>{const we=W.target.files;if(we){const ke=Array.from(we);console.log("[MailComposer] Files selected:",ke.map(Ee=>({name:Ee.name,size:Ee.size,type:Ee.type}))),ve(Ee=>[...Ee,...ke])}ae.current&&(ae.current.value="")},Mt=W=>{W.preventDefault(),W.stopPropagation(),ot(!0)},tt=W=>{W.preventDefault(),W.stopPropagation(),ot(!1)},pt=W=>{if(W.preventDefault(),W.stopPropagation(),ot(!1),W.dataTransfer.files&&W.dataTransfer.files.length>0){const we=Array.from(W.dataTransfer.files);console.log("[MailComposer] Files dropped:",we.map(ke=>({name:ke.name,size:ke.size,type:ke.type}))),ve(ke=>[...ke,...we])}else console.log("[MailComposer] Drop event but no files:",W.dataTransfer.types)},ct=W=>W.type.startsWith("image/")?"image":W.type==="application/pdf"?"picture_as_pdf":W.type.includes("spreadsheet")||W.type.includes("excel")?"table_chart":W.type.includes("document")||W.type.includes("word")?"description":"attach_file",Jt=W=>{ve(we=>we.filter((ke,Ee)=>Ee!==W))},It=W=>W<1024?`${W} B`:W<1024*1024?`${(W/1024).toFixed(1)} KB`:`${(W/(1024*1024)).toFixed(1)} MB`,Et=async()=>{if(!_.trim()){he("Recipient email is required");return}if(!j.trim()){he("Subject is required");return}Le(!0),he("");try{const W=await Promise.all(ce.map(async Ee=>{const At=await Ee.arrayBuffer(),Tt=btoa(new Uint8Array(At).reduce(($t,K)=>$t+String.fromCharCode(K),""));return{filename:Ee.name,content_type:Ee.type||"application/octet-stream",data:Tt,size:Ee.size}})),we=$.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ke={to:_.trim(),cc:A.trim()||void 0,bcc:B.trim()||void 0,subject:j.trim(),html:we,attachments:W,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",ke.to,"subject:",ke.subject,"attachmentsCount:",ke.attachments.length),ke.attachments.length>0&&ke.attachments.forEach((Ee,At)=>{var Tt;console.log(`[MailComposer] Attachment ${At+1}:`,Ee.filename,"size:",Ee.size,"type:",Ee.content_type,"data length:",((Tt=Ee.data)==null?void 0:Tt.length)||0)}),await s(ke),S(""),I(""),N(""),L(""),X(""),ve([])}catch(W){he(W instanceof Error?W.message:"Failed to send email")}finally{Le(!1)}},kt={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${y.inputBorder}`,borderRadius:"6px",background:y.inputBackground,color:y.text,outline:"none"},lt={display:"block",fontSize:"12px",fontWeight:500,color:y.textSecondary,marginBottom:"4px",textTransform:"uppercase"},gt=(W,we=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:we?"not-allowed":"pointer",opacity:we?.6:1,background:W?y.buttonPrimary:y.buttonSecondary,color:W?"#ffffff":y.text,display:"flex",alignItems:"center",gap:"8px"});return p.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:y.background},children:[me&&p.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:me}),p.jsxs("div",{children:[p.jsx("label",{style:lt,children:"To"}),p.jsx("input",{type:"email",value:_,onChange:W=>S(W.target.value),placeholder:"recipient@example.com",disabled:d||le,style:kt})]}),!ye&&p.jsx("button",{type:"button",onClick:()=>xe(!0),disabled:d||le,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:y.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),ye&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx("label",{style:lt,children:"CC"}),p.jsx("input",{type:"email",value:A,onChange:W=>I(W.target.value),placeholder:"cc@example.com",disabled:d||le,style:kt})]}),p.jsxs("div",{children:[p.jsx("label",{style:lt,children:"BCC"}),p.jsx("input",{type:"email",value:B,onChange:W=>N(W.target.value),placeholder:"bcc@example.com",disabled:d||le,style:kt})]})]}),p.jsxs("div",{children:[p.jsx("label",{style:lt,children:"Subject"}),p.jsx("input",{type:"text",value:j,onChange:W=>L(W.target.value),placeholder:"Email subject",disabled:d||le,style:kt})]}),p.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:p.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:p.jsx(Pa,{value:$,onChange:Ne,placeholder:h,replyTo:n,theme:y,disabled:d||le,minHeight:m,externalUpdate:Se?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:v,onAiProofread:E,onAiRewrite:D,renderAboveToolbar:k})})}),p.jsxs("div",{children:[p.jsx("label",{style:{...lt,marginBottom:"8px"},children:"Attachments"}),p.jsx("input",{ref:ae,type:"file",multiple:!0,onChange:St,style:{display:"none"}}),p.jsxs("div",{onClick:()=>{var W;return(W=ae.current)==null?void 0:W.click()},onDragOver:Mt,onDragLeave:tt,onDrop:pt,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Re?y.primary:y.border}`,borderRadius:"8px",background:Re?`${y.primary}10`:"transparent",color:Re?y.primary:y.textSecondary,cursor:d||le?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:ce.length>0?"12px":0},children:[p.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Re?"file_download":"attach_file"}),p.jsx("span",{style:{fontSize:"14px"},children:Re?"Drop files here":"Drop files or click to add"})]}),ce.length>0&&p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:ce.map((W,we)=>p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:y.attachmentBackground,borderRadius:"8px"},children:[p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y.textSecondary},children:ct(W)}),p.jsxs("div",{style:{flex:1,minWidth:0},children:[p.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:y.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:W.name}),p.jsx("div",{style:{fontSize:"12px",color:y.textSecondary},children:It(W.size)})]}),p.jsx("button",{type:"button",onClick:()=>Jt(we),disabled:d||le,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:y.textSecondary,display:"flex",borderRadius:"4px"},children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${W.name}-${we}`))})]}),p.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!C&&o&&p.jsx("button",{type:"button",onClick:o,disabled:d||le,style:gt(!1,d||le),children:"Cancel"}),p.jsxs("button",{type:"button",onClick:Et,disabled:d||le||!_.trim()||!j.trim(),style:gt(!0,d||le||!_.trim()||!j.trim()),children:[p.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:le?"spin 1s linear infinite":"none"},children:le?"sync":"send"}),le?"Sending...":b]})]}),p.jsx("style",{children:`
|
|
149
149
|
@keyframes spin {
|
|
150
150
|
from { transform: rotate(0deg); }
|
|
151
151
|
to { transform: rotate(360deg); }
|
|
152
152
|
}
|
|
153
|
-
`})]})}const hf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function pf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...hf,...d},[g,m]=w.useState(!1),[b,C]=w.useState(""),v=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{function B(N){v.current&&!v.current.contains(N.target)&&(m(!1),C(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const D=r.filter(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase().includes(b.toLowerCase()))&&!e.includes(B.id)}),k=s&&b.trim()&&!r.some(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase())===b.toLowerCase()}),y=e.map(B=>r.find(N=>N.id===B)).filter(Boolean),_=w.useCallback(B=>{var N;c>0&&e.length>=c||(t([...e,B]),C(""),c===1?m(!1):(N=E.current)==null||N.focus())},[e,t,c]),S=w.useCallback(B=>{t(e.filter(N=>N!==B))},[e,t]),A=w.useCallback(async()=>{if(!k)return;const B=await(o==null?void 0:o(b.trim()));B&&_(B.id),C("")},[k,b,o,_]),I=w.useCallback(B=>{B.key==="Enter"?(B.preventDefault(),k?A():D.length>0&&_(D[0].id)):B.key==="Backspace"&&!b&&e.length>0?S(e[e.length-1]):B.key==="Escape"&&(m(!1),C(""))},[k,D,b,e,A,_,S]);return p.jsxs("div",{ref:v,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[y.map(B=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:B.color||h.chipBackground,color:B.color?"#fff":h.chipText},children:[B.label,!u&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},B.id)),p.jsx("input",{ref:E,type:"text",value:b,onChange:B=>{C(B.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:y.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:D.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:b?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[D.map(B=>p.jsxs("div",{onClick:()=>_(B.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[B.label,i&&l&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},B.id)),k&&p.jsxs("div",{onClick:A,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:D.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:B=>{B.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:['+ Create "',b.trim(),'"']})]})})]})}function gf({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=w.useState(null),[b,C]=w.useState(null),[v,E]=w.useState(null),D=w.useRef(null),k=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,X)=>s($)-s(X))),N[j.id]=L,N},{}),y=w.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),D.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const X=N.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),C(null),E(null),D.current=null},[]),S=w.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",C(j),E(L)},[]),A=w.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(C(null),E(null))},[]),I=w.useCallback((N,j,L)=>{if(N.preventDefault(),!g)return;const $=D.current;$===j?l==null||l(g,j,L):$&&i(g,$,j,L),m(null),C(null),E(null),D.current=null},[g,i,l]),B=(N,j)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(N=>{const j=k[N.id]||[],L=b===N.id;return p.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:$=>{$.preventDefault(),g&&!L&&C(N.id)},onDragLeave:A,onDrop:$=>I($,N.id,v??j.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(N,j.length):B(N,j.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,X)=>{const ce=t($),ve=g===ce,le=L&&v===X&&!ve;return p.jsxs("div",{children:[le&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:Le=>y(Le,$),onDragEnd:_,onDragOver:Le=>S(Le,N.id,X),onClick:()=>a==null?void 0:a($),className:`cursor-grab active:cursor-grabbing transition-all ${ve?"opacity-50 scale-95":""} ${h}`,children:o($,ve)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),S($,N.id,j.length)},children:L&&v===j.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const mf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function yf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function xf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function bf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function _f({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...mf,...g},{allDayItems:b,timedItems:C}=w.useMemo(()=>{const _=[],S=[];for(const A of r)l(A)?_.push(A):S.push(A);return{allDayItems:_,timedItems:S}},[r,l]),v=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,D=w.useCallback(_=>{const S=o(_);if(!S)return null;const A=yf(S);if(!A)return null;const{hours:I,minutes:B}=A,N=Math.max(t,Math.min(n,I)),j=I<t?0:B,L=(N-t)*s+j/60*s,$=i(_),X=Math.max(20,$/60*s);return{top:L,height:X}},[o,i,t,n,s]),k=w.useMemo(()=>{if(!f||!bf(e))return null;const _=new Date,S=_.getHours(),A=_.getMinutes();return S<t||S>n?null:(S-t)*s+A/60*s},[e,f,t,n,s]),y=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,B=Math.floor(I/60)+t,N=Math.round(I%60/15)*15,j=Math.min(n,Math.max(t,B)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d($)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[b.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:b.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[v.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:xf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<v.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:y}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),C.map(_=>{const S=D(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:A=>{A.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function vf({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:o=!1,maxDuration:i=180}){const l=s==="widget",[a,u]=w.useState("idle"),[c,d]=w.useState(0),[f,h]=w.useState(0),[g,m]=w.useState(!1),[b,C]=w.useState(0),[v,E]=w.useState(null),[D,k]=w.useState(!1),[y,_]=w.useState(null),[S,A]=w.useState(!0),[I,B]=w.useState([]),[N,j]=w.useState({completed:0,total:0}),L=w.useRef(!1),$=w.useRef(!0);w.useEffect(()=>{$.current=S},[S]);const X=w.useRef(null),ce=w.useRef(null),ve=w.useRef(null),le=w.useRef(null),Le=w.useRef(null),me=w.useRef([]),he=w.useRef(null),ye=w.useRef(null),xe=w.useRef(null),Se=w.useRef(null),pe=w.useRef(!1),Ce=w.useRef([]),Ne=w.useRef(null),ae=w.useRef(null),Re=w.useRef([]),ot=w.useRef([]),St=w.useRef("insert"),Mt=w.useRef(!1),tt=w.useRef(0),pt=w.useRef(0),ct=w.useRef(0),Jt=q=>{const T=Math.floor(q/60),H=Math.floor(q%60);return`${T.toString().padStart(2,"0")}:${H.toString().padStart(2,"0")}`},It=async q=>{const T=await q.arrayBuffer(),H=new AudioContext,Q=await H.decodeAudioData(T);return await H.close(),Q},Et=q=>{const T=q.numberOfChannels,H=q.sampleRate,Q=1,O=16,re=O/8,Z=T*re,ee=H*Z,de=q.length*Z,De=new ArrayBuffer(44+de),te=new DataView(De),ne=(Te,be)=>{for(let He=0;He<be.length;He++)te.setUint8(Te+He,be.charCodeAt(He))};ne(0,"RIFF"),te.setUint32(4,36+de,!0),ne(8,"WAVE"),ne(12,"fmt "),te.setUint32(16,16,!0),te.setUint16(20,Q,!0),te.setUint16(22,T,!0),te.setUint32(24,H,!0),te.setUint32(28,ee,!0),te.setUint16(32,Z,!0),te.setUint16(34,O,!0),ne(36,"data"),te.setUint32(40,de,!0);const Ie=[];for(let Te=0;Te<T;Te++)Ie.push(q.getChannelData(Te));let qe=44;for(let Te=0;Te<q.length;Te++)for(let be=0;be<T;be++){const He=Math.max(-1,Math.min(1,Ie[be][Te])),Je=He<0?He*32768:He*32767;te.setInt16(qe,Je,!0),qe+=2}return new Blob([De],{type:"audio/wav"})},kt=async(q,T,H,Q)=>{const O=new AudioContext,re=q.sampleRate,Z=Math.max(q.numberOfChannels,T.numberOfChannels),ee=Math.min(H,q.length),de=Math.max(0,q.length-H),De=Q==="insert"?ee+T.length+de:ee+T.length,te=O.createBuffer(Z,De,re);for(let ne=0;ne<Z;ne++){const Ie=te.getChannelData(ne),qe=ne<q.numberOfChannels?q.getChannelData(ne):q.getChannelData(0);for(let be=0;be<ee;be++)Ie[be]=qe[be];const Te=ne<T.numberOfChannels?T.getChannelData(ne):T.getChannelData(0);for(let be=0;be<T.length;be++)Ie[ee+be]=Te[be];if(Q==="insert")for(let be=0;be<de;be++)Ie[ee+T.length+be]=qe[H+be]}return await O.close(),te},lt=w.useCallback(()=>{const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height,re=Ce.current,Z=f||c||1,ee=a==="recording"?c:b;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const de=8,De="rgba(0, 0, 0, 0.4)",te=T.createLinearGradient(0,0,0,de);te.addColorStop(0,De),te.addColorStop(1,"transparent"),T.fillStyle=te,T.fillRect(0,0,Q,de);const ne=T.createLinearGradient(0,O-de,0,O);ne.addColorStop(0,"transparent"),ne.addColorStop(1,De),T.fillStyle=ne,T.fillRect(0,O-de,Q,de);const Ie=T.createLinearGradient(0,0,de,0);Ie.addColorStop(0,De),Ie.addColorStop(1,"transparent"),T.fillStyle=Ie,T.fillRect(0,0,de,O);const qe=T.createLinearGradient(Q-de,0,Q,0);qe.addColorStop(0,"transparent"),qe.addColorStop(1,De),T.fillStyle=qe,T.fillRect(Q-de,0,de,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const Te=Q/2;if(re.length>0)if(a==="recording")for(let Je=0;Je<re.length;Je++){const dt=re.length-1-Je,zt=Te-dt*4;if(zt<-3||zt>Q)continue;const yt=re[Je]*(O/2-12),x=O/2-yt;T.fillStyle="#10b981",T.fillRect(zt,x,3,yt*2)}else{const Je=Z>0?ee/Z*re.length:0;for(let dt=0;dt<re.length;dt++){const zt=Je-dt,yt=Te-zt*4;if(yt<-3||yt>Q)continue;const x=re[dt]*(O/2-12),R=O/2-x;T.fillStyle=dt<=Je?"#10b981":"#4b5563",T.fillRect(yt,R,3,x*2)}}T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(Te,0),T.lineTo(Te,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText(Jt(ee),Te,O-6),a==="recording"&&(T.fillStyle="#ef4444",T.beginPath(),T.arc(20,20,8,0,Math.PI*2),T.fill(),T.fillStyle="#fff",T.font="10px sans-serif",T.textAlign="left",T.fillText("REC",34,24)),T.textAlign="left"},[a,b,c,f]),gt=()=>{const q=Le.current;if(!q||!pe.current)return;const T=q.frequencyBinCount,H=new Uint8Array(T);q.getByteTimeDomainData(H);let Q=0;for(let Z=0;Z<T;Z++){const ee=(H[Z]-128)/128;Q+=ee*ee}const O=Math.sqrt(Q/T),re=Math.min(1,O*3);Ce.current.push(re),lt(),pe.current&&(ye.current=requestAnimationFrame(gt))},W=async()=>{try{E(null),k(!1),Ne.current===null&&(Ce.current=[]);const q=await navigator.mediaDevices.getUserMedia({audio:!0});ve.current=q;const T=new AudioContext;le.current=T;const H=T.createAnalyser();H.fftSize=2048,Le.current=H,T.createMediaStreamSource(q).connect(H);const O=new MediaRecorder(q);ce.current=O,me.current=[],O.ondataavailable=re=>{re.data.size>0&&me.current.push(re.data)},O.onstop=async()=>{try{if(pe.current=!1,me.current.length===0){E("No audio was recorded. Please try again."),u("idle"),q.getTracks().forEach(te=>te.stop());return}const re=new Blob(me.current,{type:"audio/webm"});let Z,ee;if(Ne.current!==null&&ae.current)try{const te=await It(re),ne=ae.current.sampleRate,Ie=Math.floor(Ne.current*ne),qe=await kt(ae.current,te,Ie,St.current);Z=Et(qe),ee=qe.length/qe.sampleRate,St.current==="insert"&&(Ce.current=[...Ce.current,...ot.current]),Ne.current=null,ae.current=null,Re.current=[],ot.current=[]}catch{Z=re,ee=tt.current>0?tt.current:1}else Z=re,ee=tt.current>0?tt.current:1;if(Se.current=Z,q.getTracks().forEach(te=>te.stop()),$.current&&t){B(te=>[...te,Z]),j(te=>({...te,total:te.total+1})),Se.current=null,Ce.current=[],C(0),h(0),d(0),u("idle");return}const de=URL.createObjectURL(Z),De=new Audio(de);De.ontimeupdate=()=>{C(De.currentTime)},De.onended=()=>{m(!1)},xe.current=De,h(ee),C(ee),u("editing")}catch{E("Failed to process recording"),u("idle")}},O.start(100),pe.current=!0,u("recording"),d(0),tt.current=0,he.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=i&&(ce.current&&ce.current.state!=="inactive"&&ce.current.stop(),pe.current=!1,_(null),he.current&&(clearInterval(he.current),he.current=null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(i/60)} minutes reached.`)},100))},1e3)}catch{E("Could not access microphone. Please allow microphone access.")}},we=()=>{pe.current=!1,k(!1),_(null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),he.current&&(clearInterval(he.current),he.current=null),ce.current&&ce.current.state!=="inactive"&&ce.current.stop()},ke=q=>{const T=X.current;if(!T)return;const H=f||c;if(H<=0)return;const Q=Ce.current;if(Q.length===0)return;const O=T.getBoundingClientRect(),re=q-pt.current,Z=4,ee=O.width/T.width,de=Q.length/H*Z,De=-re/(de*ee),te=ct.current+De,ne=Math.max(0,Math.min(te,H));xe.current&&(xe.current.currentTime=ne),C(ne)},Ee=()=>{xe.current&&(xe.current.currentTime=0),C(0)},At=()=>{const q=f||c;xe.current&&(xe.current.currentTime=q),C(q)},Tt=()=>{const q=xe.current;q&&(g?(q.pause(),C(q.currentTime),m(!1)):(q.currentTime=b,q.play().catch(()=>{}),m(!0)))},$t=async q=>{if(!Se.current){W();return}try{xe.current&&(xe.current.pause(),m(!1)),St.current=q,ae.current=await It(Se.current);const T=f||c;Ne.current=b;const H=T>0?b/T:0,Q=Math.floor(H*Ce.current.length);Re.current=Ce.current.slice(0,Q),ot.current=Ce.current.slice(Q),Ce.current=[...Re.current],W()}catch{E("Failed to prepare recording. Please try again.")}},K=()=>{xe.current&&(xe.current.pause(),xe.current=null),Se.current=null,ae.current=null,Ne.current=null,Re.current=[],m(!1),C(0),h(0),d(0),W()},J=()=>{Se.current?r(Se.current,f||c):alert("No audio recorded yet!")};w.useEffect(()=>{a==="recording"&&X.current&&Le.current&&pe.current&&(ye.current=requestAnimationFrame(gt))},[a]),w.useEffect(()=>{const q=X.current;if(!q)return;const T=()=>{const H=window.devicePixelRatio||1,Q=q.getBoundingClientRect();q.width=Q.width*H,q.height=Q.height*H;const O=q.getContext("2d");O&&O.scale(H,H)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),w.useEffect(()=>{if(a==="idle"){const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const re=8,Z="rgba(0, 0, 0, 0.4)",ee=T.createLinearGradient(0,0,0,re);ee.addColorStop(0,Z),ee.addColorStop(1,"transparent"),T.fillStyle=ee,T.fillRect(0,0,Q,re);const de=T.createLinearGradient(0,O-re,0,O);de.addColorStop(0,"transparent"),de.addColorStop(1,Z),T.fillStyle=de,T.fillRect(0,O-re,Q,re);const De=T.createLinearGradient(0,0,re,0);De.addColorStop(0,Z),De.addColorStop(1,"transparent"),T.fillStyle=De,T.fillRect(0,0,re,O);const te=T.createLinearGradient(Q-re,0,Q,0);te.addColorStop(0,"transparent"),te.addColorStop(1,Z),T.fillStyle=te,T.fillRect(Q-re,0,re,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const ne=Q/2;T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(ne,0),T.lineTo(ne,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText("00:00",ne,O-6)}},[a]);const Ae=w.useCallback(q=>{B(T=>[...T,q]),j(T=>({...T,total:T.total+1}))},[]);if(w.useEffect(()=>{(async()=>{if(L.current||I.length===0||!t)return;L.current=!0;const T=I[0];try{const H=await t(T);H&&n&&n(H)}catch(H){console.error("Transcription failed:",H)}finally{B(H=>H.slice(1)),j(H=>({...H,completed:H.completed+1})),L.current=!1}})()},[I,t,n]),w.useEffect(()=>()=>{pe.current=!1,he.current&&clearInterval(he.current),ye.current&&cancelAnimationFrame(ye.current),ve.current&&ve.current.getTracks().forEach(q=>q.stop()),le.current&&le.current.state!=="closed"&&le.current.close()},[]),w.useEffect(()=>{if(a==="editing"&&g){let q;const T=()=>{const H=xe.current;if(H&&g){const Q=X.current;if(Q){const O=Q.getContext("2d");if(O){const re=Q.getBoundingClientRect(),Z=re.width,ee=re.height,de=Ce.current,De=f||c||1,te=H.currentTime;O.fillStyle="#2d3b35",O.fillRect(0,0,Z,ee);const ne=8,Ie="rgba(0, 0, 0, 0.4)",qe=O.createLinearGradient(0,0,0,ne);qe.addColorStop(0,Ie),qe.addColorStop(1,"transparent"),O.fillStyle=qe,O.fillRect(0,0,Z,ne);const Te=O.createLinearGradient(0,ee-ne,0,ee);Te.addColorStop(0,"transparent"),Te.addColorStop(1,Ie),O.fillStyle=Te,O.fillRect(0,ee-ne,Z,ne);const be=O.createLinearGradient(0,0,ne,0);be.addColorStop(0,Ie),be.addColorStop(1,"transparent"),O.fillStyle=be,O.fillRect(0,0,ne,ee);const He=O.createLinearGradient(Z-ne,0,Z,0);He.addColorStop(0,"transparent"),He.addColorStop(1,Ie),O.fillStyle=He,O.fillRect(Z-ne,0,ne,ee),O.strokeStyle="#5a6b62",O.lineWidth=1,O.beginPath(),O.moveTo(0,ee/2),O.lineTo(Z,ee/2),O.stroke();const Je=Z/2,dt=3,zt=4,yt=De>0?te/De*de.length:0;for(let U=0;U<de.length;U++){const Y=yt-U,oe=Je-Y*zt;if(oe<-dt||oe>Z)continue;const ge=de[U]*(ee/2-12),se=ee/2-ge;O.fillStyle=U<=yt?"#10b981":"#4b5563",O.fillRect(oe,se,dt,ge*2)}O.strokeStyle="#ef4444",O.lineWidth=1,O.beginPath(),O.moveTo(Je,0),O.lineTo(Je,ee),O.stroke(),O.fillStyle="#fff",O.font="bold 18px monospace",O.textAlign="center";const x=Math.floor(te/60),R=Math.floor(te%60);O.fillText(`${x.toString().padStart(2,"0")}:${R.toString().padStart(2,"0")}`,Je,ee-6),O.textAlign="left"}}q=requestAnimationFrame(T)}};return q=requestAnimationFrame(T),()=>cancelAnimationFrame(q)}},[a,g,f,c]),w.useEffect(()=>{a==="editing"&&!g&<()},[a,b,g,lt]),v)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:v}),p.jsx("button",{onClick:()=>{E(null),W()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Pe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Oe={...Pe,opacity:.3,cursor:"not-allowed"},mt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:mt,children:[p.jsx("canvas",{ref:X,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:q=>{if(a==="editing"){Mt.current=!0,pt.current=q.clientX,ct.current=b;const T=Q=>{Mt.current&&ke(Q.clientX)},H=()=>{Mt.current=!1,window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",H)};window.addEventListener("mousemove",T),window.addEventListener("mouseup",H)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(a==="recording"){const q=ce.current;q&&(q.state==="recording"?(q.pause(),k(!0)):q.state==="paused"&&(q.resume(),k(!1)))}else Tt()},disabled:a==="idle",style:a==="idle"?Oe:Pe,title:g||a==="recording"&&!D?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!D?"pause":"play_arrow"})}),p.jsx("button",{onClick:At,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),p.jsx("button",{onClick:()=>{y==="insert"?we():a==="idle"?(_("insert"),W()):a==="editing"&&(_("insert"),$t("insert"))},disabled:a==="recording"&&y!=="insert"||g,style:a==="recording"&&y!=="insert"||g?Oe:Pe,title:y==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{$.current||(y==="mic"?we():a==="idle"?(_("mic"),W()):a==="editing"&&(_("mic"),$t("replace")))},onMouseDown:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onMouseUp:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onMouseLeave:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onTouchStart:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onTouchEnd:()=>{$.current&&a==="recording"&&y==="mic"&&we()},disabled:a==="recording"&&y!=="mic"||g,style:a==="recording"&&y!=="mic"||g?Oe:Pe,title:S?"Hold to record (walkie-talkie)":y==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{y==="startover"?we():a==="editing"&&(_("startover"),K())},disabled:a==="idle"||a==="recording"&&y!=="startover"||g,style:a==="idle"||a==="recording"&&y!=="startover"||g?Oe:Pe,title:y==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[N.total>0&&N.completed<N.total&&p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[p.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),N.completed,"/",N.total]}),t&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[p.jsx("button",{onClick:()=>A(!S),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:S?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:S?"Auto-transcribe ON":"Auto-transcribe OFF",children:p.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:S?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),p.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),p.jsx("button",{onClick:()=>{a==="editing"&&Se.current&&Ae(Se.current)},disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S?"#10b981":"#171717"},children:"subtitles"})})]}),!o&&p.jsx("button",{onClick:J,disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),N.total>0&&N.completed<N.total&&p.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:p.jsx("div",{style:{height:"100%",background:"#10b981",width:`${N.completed/N.total*100}%`,transition:"width 0.3s ease"}})})]})}exports.AnimatedCardFlip=mu;exports.ApiClient=fl;exports.AudioEditor=vf;exports.AuthManager=dl;exports.Card=hu;exports.ComboBox=pf;exports.DataOperations=Rn;exports.Detail=pu;exports.GraphClient=qa;exports.KanbanBoard=gf;exports.Mail=xu;exports.MailClient=cl;exports.MailComposer=ff;exports.MailEditor=Pa;exports.SelectableList=bu;exports.Stack=fu;exports.Timeline=_f;exports.getApiClient=ci;exports.initializeApiClient=au;exports.useMutation=uu;exports.useQuery=hl;
|
|
153
|
+
`})]})}const pf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function gf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const h={...pf,...d},[g,m]=w.useState(!1),[b,C]=w.useState(""),v=w.useRef(null),E=w.useRef(null);w.useEffect(()=>{function B(N){v.current&&!v.current.contains(N.target)&&(m(!1),C(""))}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const D=r.filter(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase().includes(b.toLowerCase()))&&!e.includes(B.id)}),k=s&&b.trim()&&!r.some(B=>{var N;return((N=B.label)==null?void 0:N.toLowerCase())===b.toLowerCase()}),y=e.map(B=>r.find(N=>N.id===B)).filter(Boolean),_=w.useCallback(B=>{var N;c>0&&e.length>=c||(t([...e,B]),C(""),c===1?m(!1):(N=E.current)==null||N.focus())},[e,t,c]),S=w.useCallback(B=>{t(e.filter(N=>N!==B))},[e,t]),A=w.useCallback(async()=>{if(!k)return;const B=await(o==null?void 0:o(b.trim()));B&&_(B.id),C("")},[k,b,o,_]),I=w.useCallback(B=>{B.key==="Enter"?(B.preventDefault(),k?A():D.length>0&&_(D[0].id)):B.key==="Backspace"&&!b&&e.length>0?S(e[e.length-1]):B.key==="Escape"&&(m(!1),C(""))},[k,D,b,e,A,_,S]);return p.jsxs("div",{ref:v,className:f,style:{position:"relative"},children:[a&&p.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:a}),p.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?h.primary:h.border}`,borderRadius:"8px",background:u?h.hoverBackground:h.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[y.map(B=>p.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:B.color||h.chipBackground,color:B.color?"#fff":h.chipText},children:[B.label,!u&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},B.id)),p.jsx("input",{ref:E,type:"text",value:b,onChange:B=>{C(B.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:I,placeholder:y.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),g&&!u&&p.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:D.length===0&&!k?p.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:b?"No matches":"No options available"}):p.jsxs(p.Fragment,{children:[D.map(B=>p.jsxs("div",{onClick:()=>_(B.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[B.label,i&&l&&p.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(B.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},B.id)),k&&p.jsxs("div",{onClick:A,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:D.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:B=>{B.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:['+ Create "',b.trim(),'"']})]})})]})}function mf({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:h=""}){const[g,m]=w.useState(null),[b,C]=w.useState(null),[v,E]=w.useState(null),D=w.useRef(null),k=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,X)=>s($)-s(X))),N[j.id]=L,N},{}),y=w.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),D.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const X=N.target;X.style.opacity="0.5"})},[t,n]),_=w.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),C(null),E(null),D.current=null},[]),S=w.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",C(j),E(L)},[]),A=w.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(C(null),E(null))},[]),I=w.useCallback((N,j,L)=>{if(N.preventDefault(),!g)return;const $=D.current;$===j?l==null||l(g,j,L):$&&i(g,$,j,L),m(null),C(null),E(null),D.current=null},[g,i,l]),B=(N,j)=>p.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&p.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),p.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),p.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return p.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(N=>{const j=k[N.id]||[],L=b===N.id;return p.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:$=>{$.preventDefault(),g&&!L&&C(N.id)},onDragLeave:A,onDrop:$=>I($,N.id,v??j.length),children:[p.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(N,j.length):B(N,j.length)}),p.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,X)=>{const ce=t($),ve=g===ce,le=L&&v===X&&!ve;return p.jsxs("div",{children:[le&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),p.jsx("div",{draggable:!0,onDragStart:Le=>y(Le,$),onDragEnd:_,onDragOver:Le=>S(Le,N.id,X),onClick:()=>a==null?void 0:a($),className:`cursor-grab active:cursor-grabbing transition-all ${ve?"opacity-50 scale-95":""} ${h}`,children:o($,ve)})]},ce)}),p.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),S($,N.id,j.length)},children:L&&v===j.length&&p.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&p.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:p.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&p.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const yf={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function xf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function bf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function _f(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function vf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:h="",theme:g={}}){const m={...yf,...g},{allDayItems:b,timedItems:C}=w.useMemo(()=>{const _=[],S=[];for(const A of r)l(A)?_.push(A):S.push(A);return{allDayItems:_,timedItems:S}},[r,l]),v=w.useMemo(()=>{const _=[];for(let S=t;S<=n;S++)_.push(S);return _},[t,n]),E=(n-t+1)*s,D=w.useCallback(_=>{const S=o(_);if(!S)return null;const A=xf(S);if(!A)return null;const{hours:I,minutes:B}=A,N=Math.max(t,Math.min(n,I)),j=I<t?0:B,L=(N-t)*s+j/60*s,$=i(_),X=Math.max(20,$/60*s);return{top:L,height:X}},[o,i,t,n,s]),k=w.useMemo(()=>{if(!f||!_f(e))return null;const _=new Date,S=_.getHours(),A=_.getMinutes();return S<t||S>n?null:(S-t)*s+A/60*s},[e,f,t,n,s]),y=w.useCallback(_=>{if(!d)return;const S=_.currentTarget.getBoundingClientRect(),I=(_.clientY-S.top)/s*60,B=Math.floor(I/60)+t,N=Math.round(I%60/15)*15,j=Math.min(n,Math.max(t,B)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;d($)},[d,s,t,n]);return p.jsxs("div",{className:h,style:{background:m.background},children:[b.length>0&&p.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[p.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),p.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:b.map(_=>p.jsx("div",{onClick:()=>c==null?void 0:c(_),style:{cursor:c?"pointer":"default"},children:u(_)},a(_)))})]}),p.jsxs("div",{style:{position:"relative",height:E},children:[v.map((_,S)=>p.jsxs("div",{style:{position:"absolute",top:S*s,left:0,right:0},children:[p.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:bf(_)}),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),S<v.length-1&&p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},_)),p.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:y}),k!==null&&p.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[p.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),p.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),C.map(_=>{const S=D(_);return S?p.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:S.top,height:S.height,zIndex:10,cursor:c?"pointer":"default"},onClick:A=>{A.stopPropagation(),c==null||c(_)},children:u(_)},a(_)):null})]})]})}function Cf({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:o=!1,maxDuration:i=180}){const l=s==="widget",[a,u]=w.useState("idle"),[c,d]=w.useState(0),[f,h]=w.useState(0),[g,m]=w.useState(!1),[b,C]=w.useState(0),[v,E]=w.useState(null),[D,k]=w.useState(!1),[y,_]=w.useState(null),[S,A]=w.useState(!0),[I,B]=w.useState([]),[N,j]=w.useState({completed:0,total:0}),L=w.useRef(!1),$=w.useRef(!0);w.useEffect(()=>{$.current=S},[S]);const X=w.useRef(null),ce=w.useRef(null),ve=w.useRef(null),le=w.useRef(null),Le=w.useRef(null),me=w.useRef([]),he=w.useRef(null),ye=w.useRef(null),xe=w.useRef(null),Se=w.useRef(null),pe=w.useRef(!1),Ce=w.useRef([]),Ne=w.useRef(null),ae=w.useRef(null),Re=w.useRef([]),ot=w.useRef([]),St=w.useRef("insert"),Mt=w.useRef(!1),tt=w.useRef(0),pt=w.useRef(0),ct=w.useRef(0),Jt=q=>{const T=Math.floor(q/60),H=Math.floor(q%60);return`${T.toString().padStart(2,"0")}:${H.toString().padStart(2,"0")}`},It=async q=>{const T=await q.arrayBuffer(),H=new AudioContext,Q=await H.decodeAudioData(T);return await H.close(),Q},Et=q=>{const T=q.numberOfChannels,H=q.sampleRate,Q=1,O=16,re=O/8,Z=T*re,ee=H*Z,de=q.length*Z,De=new ArrayBuffer(44+de),te=new DataView(De),ne=(Te,be)=>{for(let He=0;He<be.length;He++)te.setUint8(Te+He,be.charCodeAt(He))};ne(0,"RIFF"),te.setUint32(4,36+de,!0),ne(8,"WAVE"),ne(12,"fmt "),te.setUint32(16,16,!0),te.setUint16(20,Q,!0),te.setUint16(22,T,!0),te.setUint32(24,H,!0),te.setUint32(28,ee,!0),te.setUint16(32,Z,!0),te.setUint16(34,O,!0),ne(36,"data"),te.setUint32(40,de,!0);const Ie=[];for(let Te=0;Te<T;Te++)Ie.push(q.getChannelData(Te));let qe=44;for(let Te=0;Te<q.length;Te++)for(let be=0;be<T;be++){const He=Math.max(-1,Math.min(1,Ie[be][Te])),Je=He<0?He*32768:He*32767;te.setInt16(qe,Je,!0),qe+=2}return new Blob([De],{type:"audio/wav"})},kt=async(q,T,H,Q)=>{const O=new AudioContext,re=q.sampleRate,Z=Math.max(q.numberOfChannels,T.numberOfChannels),ee=Math.min(H,q.length),de=Math.max(0,q.length-H),De=Q==="insert"?ee+T.length+de:ee+T.length,te=O.createBuffer(Z,De,re);for(let ne=0;ne<Z;ne++){const Ie=te.getChannelData(ne),qe=ne<q.numberOfChannels?q.getChannelData(ne):q.getChannelData(0);for(let be=0;be<ee;be++)Ie[be]=qe[be];const Te=ne<T.numberOfChannels?T.getChannelData(ne):T.getChannelData(0);for(let be=0;be<T.length;be++)Ie[ee+be]=Te[be];if(Q==="insert")for(let be=0;be<de;be++)Ie[ee+T.length+be]=qe[H+be]}return await O.close(),te},lt=w.useCallback(()=>{const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height,re=Ce.current,Z=f||c||1,ee=a==="recording"?c:b;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const de=8,De="rgba(0, 0, 0, 0.4)",te=T.createLinearGradient(0,0,0,de);te.addColorStop(0,De),te.addColorStop(1,"transparent"),T.fillStyle=te,T.fillRect(0,0,Q,de);const ne=T.createLinearGradient(0,O-de,0,O);ne.addColorStop(0,"transparent"),ne.addColorStop(1,De),T.fillStyle=ne,T.fillRect(0,O-de,Q,de);const Ie=T.createLinearGradient(0,0,de,0);Ie.addColorStop(0,De),Ie.addColorStop(1,"transparent"),T.fillStyle=Ie,T.fillRect(0,0,de,O);const qe=T.createLinearGradient(Q-de,0,Q,0);qe.addColorStop(0,"transparent"),qe.addColorStop(1,De),T.fillStyle=qe,T.fillRect(Q-de,0,de,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const Te=Q/2;if(re.length>0)if(a==="recording")for(let Je=0;Je<re.length;Je++){const dt=re.length-1-Je,zt=Te-dt*4;if(zt<-3||zt>Q)continue;const yt=re[Je]*(O/2-12),x=O/2-yt;T.fillStyle="#10b981",T.fillRect(zt,x,3,yt*2)}else{const Je=Z>0?ee/Z*re.length:0;for(let dt=0;dt<re.length;dt++){const zt=Je-dt,yt=Te-zt*4;if(yt<-3||yt>Q)continue;const x=re[dt]*(O/2-12),R=O/2-x;T.fillStyle=dt<=Je?"#10b981":"#4b5563",T.fillRect(yt,R,3,x*2)}}T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(Te,0),T.lineTo(Te,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText(Jt(ee),Te,O-6),a==="recording"&&(T.fillStyle="#ef4444",T.beginPath(),T.arc(20,20,8,0,Math.PI*2),T.fill(),T.fillStyle="#fff",T.font="10px sans-serif",T.textAlign="left",T.fillText("REC",34,24)),T.textAlign="left"},[a,b,c,f]),gt=()=>{const q=Le.current;if(!q||!pe.current)return;const T=q.frequencyBinCount,H=new Uint8Array(T);q.getByteTimeDomainData(H);let Q=0;for(let Z=0;Z<T;Z++){const ee=(H[Z]-128)/128;Q+=ee*ee}const O=Math.sqrt(Q/T),re=Math.min(1,O*3);Ce.current.push(re),lt(),pe.current&&(ye.current=requestAnimationFrame(gt))},W=async()=>{try{E(null),k(!1),Ne.current===null&&(Ce.current=[]);const q=await navigator.mediaDevices.getUserMedia({audio:!0});ve.current=q;const T=new AudioContext;le.current=T;const H=T.createAnalyser();H.fftSize=2048,Le.current=H,T.createMediaStreamSource(q).connect(H);const O=new MediaRecorder(q);ce.current=O,me.current=[],O.ondataavailable=re=>{re.data.size>0&&me.current.push(re.data)},O.onstop=async()=>{try{if(pe.current=!1,me.current.length===0){E("No audio was recorded. Please try again."),u("idle"),q.getTracks().forEach(te=>te.stop());return}const re=new Blob(me.current,{type:"audio/webm"});let Z,ee;if(Ne.current!==null&&ae.current)try{const te=await It(re),ne=ae.current.sampleRate,Ie=Math.floor(Ne.current*ne),qe=await kt(ae.current,te,Ie,St.current);Z=Et(qe),ee=qe.length/qe.sampleRate,St.current==="insert"&&(Ce.current=[...Ce.current,...ot.current]),Ne.current=null,ae.current=null,Re.current=[],ot.current=[]}catch{Z=re,ee=tt.current>0?tt.current:1}else Z=re,ee=tt.current>0?tt.current:1;if(Se.current=Z,q.getTracks().forEach(te=>te.stop()),$.current&&t){B(te=>[...te,Z]),j(te=>({...te,total:te.total+1})),Se.current=null,Ce.current=[],C(0),h(0),d(0),u("idle");return}const de=URL.createObjectURL(Z),De=new Audio(de);De.ontimeupdate=()=>{C(De.currentTime)},De.onended=()=>{m(!1)},xe.current=De,h(ee),C(ee),u("editing")}catch{E("Failed to process recording"),u("idle")}},O.start(100),pe.current=!0,u("recording"),d(0),tt.current=0,he.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=i&&(ce.current&&ce.current.state!=="inactive"&&ce.current.stop(),pe.current=!1,_(null),he.current&&(clearInterval(he.current),he.current=null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(i/60)} minutes reached.`)},100))},1e3)}catch{E("Could not access microphone. Please allow microphone access.")}},we=()=>{pe.current=!1,k(!1),_(null),ye.current&&(cancelAnimationFrame(ye.current),ye.current=null),he.current&&(clearInterval(he.current),he.current=null),ce.current&&ce.current.state!=="inactive"&&ce.current.stop()},ke=q=>{const T=X.current;if(!T)return;const H=f||c;if(H<=0)return;const Q=Ce.current;if(Q.length===0)return;const O=T.getBoundingClientRect(),re=q-pt.current,Z=4,ee=O.width/T.width,de=Q.length/H*Z,De=-re/(de*ee),te=ct.current+De,ne=Math.max(0,Math.min(te,H));xe.current&&(xe.current.currentTime=ne),C(ne)},Ee=()=>{xe.current&&(xe.current.currentTime=0),C(0)},At=()=>{const q=f||c;xe.current&&(xe.current.currentTime=q),C(q)},Tt=()=>{const q=xe.current;q&&(g?(q.pause(),C(q.currentTime),m(!1)):(q.currentTime=b,q.play().catch(()=>{}),m(!0)))},$t=async q=>{if(!Se.current){W();return}try{xe.current&&(xe.current.pause(),m(!1)),St.current=q,ae.current=await It(Se.current);const T=f||c;Ne.current=b;const H=T>0?b/T:0,Q=Math.floor(H*Ce.current.length);Re.current=Ce.current.slice(0,Q),ot.current=Ce.current.slice(Q),Ce.current=[...Re.current],W()}catch{E("Failed to prepare recording. Please try again.")}},K=()=>{xe.current&&(xe.current.pause(),xe.current=null),Se.current=null,ae.current=null,Ne.current=null,Re.current=[],m(!1),C(0),h(0),d(0),W()},J=()=>{Se.current?r(Se.current,f||c):alert("No audio recorded yet!")};w.useEffect(()=>{a==="recording"&&X.current&&Le.current&&pe.current&&(ye.current=requestAnimationFrame(gt))},[a]),w.useEffect(()=>{const q=X.current;if(!q)return;const T=()=>{const H=window.devicePixelRatio||1,Q=q.getBoundingClientRect();q.width=Q.width*H,q.height=Q.height*H;const O=q.getContext("2d");O&&O.scale(H,H)};return T(),window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),w.useEffect(()=>{if(a==="idle"){const q=X.current;if(!q)return;const T=q.getContext("2d");if(!T)return;const H=q.getBoundingClientRect(),Q=H.width,O=H.height;T.fillStyle="#2d3b35",T.fillRect(0,0,Q,O);const re=8,Z="rgba(0, 0, 0, 0.4)",ee=T.createLinearGradient(0,0,0,re);ee.addColorStop(0,Z),ee.addColorStop(1,"transparent"),T.fillStyle=ee,T.fillRect(0,0,Q,re);const de=T.createLinearGradient(0,O-re,0,O);de.addColorStop(0,"transparent"),de.addColorStop(1,Z),T.fillStyle=de,T.fillRect(0,O-re,Q,re);const De=T.createLinearGradient(0,0,re,0);De.addColorStop(0,Z),De.addColorStop(1,"transparent"),T.fillStyle=De,T.fillRect(0,0,re,O);const te=T.createLinearGradient(Q-re,0,Q,0);te.addColorStop(0,"transparent"),te.addColorStop(1,Z),T.fillStyle=te,T.fillRect(Q-re,0,re,O),T.strokeStyle="#5a6b62",T.lineWidth=1,T.beginPath(),T.moveTo(0,O/2),T.lineTo(Q,O/2),T.stroke();const ne=Q/2;T.strokeStyle="#ef4444",T.lineWidth=1,T.beginPath(),T.moveTo(ne,0),T.lineTo(ne,O),T.stroke(),T.fillStyle="#fff",T.font="bold 18px monospace",T.textAlign="center",T.fillText("00:00",ne,O-6)}},[a]);const Ae=w.useCallback(q=>{B(T=>[...T,q]),j(T=>({...T,total:T.total+1}))},[]);if(w.useEffect(()=>{(async()=>{if(L.current||I.length===0||!t)return;L.current=!0;const T=I[0];try{const H=await t(T);H&&n&&n(H)}catch(H){console.error("Transcription failed:",H)}finally{B(H=>H.slice(1)),j(H=>({...H,completed:H.completed+1})),L.current=!1}})()},[I,t,n]),w.useEffect(()=>()=>{pe.current=!1,he.current&&clearInterval(he.current),ye.current&&cancelAnimationFrame(ye.current),ve.current&&ve.current.getTracks().forEach(q=>q.stop()),le.current&&le.current.state!=="closed"&&le.current.close()},[]),w.useEffect(()=>{if(a==="editing"&&g){let q;const T=()=>{const H=xe.current;if(H&&g){const Q=X.current;if(Q){const O=Q.getContext("2d");if(O){const re=Q.getBoundingClientRect(),Z=re.width,ee=re.height,de=Ce.current,De=f||c||1,te=H.currentTime;O.fillStyle="#2d3b35",O.fillRect(0,0,Z,ee);const ne=8,Ie="rgba(0, 0, 0, 0.4)",qe=O.createLinearGradient(0,0,0,ne);qe.addColorStop(0,Ie),qe.addColorStop(1,"transparent"),O.fillStyle=qe,O.fillRect(0,0,Z,ne);const Te=O.createLinearGradient(0,ee-ne,0,ee);Te.addColorStop(0,"transparent"),Te.addColorStop(1,Ie),O.fillStyle=Te,O.fillRect(0,ee-ne,Z,ne);const be=O.createLinearGradient(0,0,ne,0);be.addColorStop(0,Ie),be.addColorStop(1,"transparent"),O.fillStyle=be,O.fillRect(0,0,ne,ee);const He=O.createLinearGradient(Z-ne,0,Z,0);He.addColorStop(0,"transparent"),He.addColorStop(1,Ie),O.fillStyle=He,O.fillRect(Z-ne,0,ne,ee),O.strokeStyle="#5a6b62",O.lineWidth=1,O.beginPath(),O.moveTo(0,ee/2),O.lineTo(Z,ee/2),O.stroke();const Je=Z/2,dt=3,zt=4,yt=De>0?te/De*de.length:0;for(let U=0;U<de.length;U++){const Y=yt-U,oe=Je-Y*zt;if(oe<-dt||oe>Z)continue;const ge=de[U]*(ee/2-12),se=ee/2-ge;O.fillStyle=U<=yt?"#10b981":"#4b5563",O.fillRect(oe,se,dt,ge*2)}O.strokeStyle="#ef4444",O.lineWidth=1,O.beginPath(),O.moveTo(Je,0),O.lineTo(Je,ee),O.stroke(),O.fillStyle="#fff",O.font="bold 18px monospace",O.textAlign="center";const x=Math.floor(te/60),R=Math.floor(te%60);O.fillText(`${x.toString().padStart(2,"0")}:${R.toString().padStart(2,"0")}`,Je,ee-6),O.textAlign="left"}}q=requestAnimationFrame(T)}};return q=requestAnimationFrame(T),()=>cancelAnimationFrame(q)}},[a,g,f,c]),w.useEffect(()=>{a==="editing"&&!g&<()},[a,b,g,lt]),v)return p.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[p.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:v}),p.jsx("button",{onClick:()=>{E(null),W()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Pe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Oe={...Pe,opacity:.3,cursor:"not-allowed"},mt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return p.jsxs("div",{style:mt,children:[p.jsx("canvas",{ref:X,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:q=>{if(a==="editing"){Mt.current=!0,pt.current=q.clientX,ct.current=b;const T=Q=>{Mt.current&&ke(Q.clientX)},H=()=>{Mt.current=!1,window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",H)};window.addEventListener("mousemove",T),window.addEventListener("mouseup",H)}}}),p.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[p.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to start",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),p.jsx("button",{onClick:()=>{if(a==="recording"){const q=ce.current;q&&(q.state==="recording"?(q.pause(),k(!0)):q.state==="paused"&&(q.resume(),k(!1)))}else Tt()},disabled:a==="idle",style:a==="idle"?Oe:Pe,title:g||a==="recording"&&!D?"Pause":"Play",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!D?"pause":"play_arrow"})}),p.jsx("button",{onClick:At,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Oe:Pe,title:"Go to end",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),p.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),p.jsx("button",{onClick:()=>{y==="insert"?we():a==="idle"?(_("insert"),W()):a==="editing"&&(_("insert"),$t("insert"))},disabled:a==="recording"&&y!=="insert"||g,style:a==="recording"&&y!=="insert"||g?Oe:Pe,title:y==="insert"?"Stop recording":"Insert recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="insert"?"#ef4444":"#171717"},children:"add"})}),p.jsx("button",{onClick:()=>{$.current||(y==="mic"?we():a==="idle"?(_("mic"),W()):a==="editing"&&(_("mic"),$t("replace")))},onMouseDown:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onMouseUp:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onMouseLeave:()=>{$.current&&a==="recording"&&y==="mic"&&we()},onTouchStart:()=>{$.current&&a==="idle"&&!g&&(_("mic"),W())},onTouchEnd:()=>{$.current&&a==="recording"&&y==="mic"&&we()},disabled:a==="recording"&&y!=="mic"||g,style:a==="recording"&&y!=="mic"||g?Oe:Pe,title:S?"Hold to record (walkie-talkie)":y==="mic"?"Stop recording":"Record",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="mic"?"#ef4444":"#171717"},children:"mic"})}),p.jsx("button",{onClick:()=>{y==="startover"?we():a==="editing"&&(_("startover"),K())},disabled:a==="idle"||a==="recording"&&y!=="startover"||g,style:a==="idle"||a==="recording"&&y!=="startover"||g?Oe:Pe,title:y==="startover"?"Stop recording":"Start over",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:y==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[N.total>0&&N.completed<N.total&&p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[p.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),N.completed,"/",N.total]}),t&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[p.jsx("button",{onClick:()=>A(!S),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:S?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:S?"Auto-transcribe ON":"Auto-transcribe OFF",children:p.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:S?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),p.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),p.jsx("button",{onClick:()=>{a==="editing"&&Se.current&&Ae(Se.current)},disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Transcribe audio",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:S?"#10b981":"#171717"},children:"subtitles"})})]}),!o&&p.jsx("button",{onClick:J,disabled:a!=="editing",style:a!=="editing"?Oe:Pe,title:"Save recording",children:p.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),N.total>0&&N.completed<N.total&&p.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:p.jsx("div",{style:{height:"100%",background:"#10b981",width:`${N.completed/N.total*100}%`,transition:"width 0.3s ease"}})})]})}exports.AnimatedCardFlip=mu;exports.ApiClient=fl;exports.AudioEditor=Cf;exports.AuthManager=dl;exports.Card=hu;exports.ComboBox=gf;exports.DataOperations=Rn;exports.Detail=pu;exports.GraphClient=qa;exports.KanbanBoard=mf;exports.Mail=xu;exports.MailClient=cl;exports.MailComposer=hf;exports.MailEditor=Pa;exports.SelectableList=bu;exports.Stack=fu;exports.Timeline=vf;exports.getApiClient=ci;exports.initializeApiClient=au;exports.useMutation=uu;exports.useQuery=hl;
|
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ var Kt = (r, e, t) => za(r, typeof e != "symbol" ? e + "" : e, t);
|
|
|
4
4
|
import * as Ts from "react";
|
|
5
5
|
import tt, { useState as H, useCallback as re, useEffect as Se, useMemo as Et, useRef as ye, createContext as qa, useContext as Ua, useLayoutEffect as $r, Suspense as Wa, forwardRef as fl } from "react";
|
|
6
6
|
import { flushSync as Ga, createPortal as Va } from "react-dom";
|
|
7
|
-
class
|
|
7
|
+
class wf {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
Kt(this, "config");
|
|
10
10
|
// ===== FILE OPERATIONS =====
|
|
@@ -3950,7 +3950,7 @@ class pu {
|
|
|
3950
3950
|
}
|
|
3951
3951
|
}
|
|
3952
3952
|
let Wn = null;
|
|
3953
|
-
function
|
|
3953
|
+
function Cf(r) {
|
|
3954
3954
|
return Wn = new pu(r), Wn;
|
|
3955
3955
|
}
|
|
3956
3956
|
function gl() {
|
|
@@ -3987,7 +3987,7 @@ function gu(r, e, t = {}) {
|
|
|
3987
3987
|
refetch: h
|
|
3988
3988
|
};
|
|
3989
3989
|
}
|
|
3990
|
-
function
|
|
3990
|
+
function Df(r, e = "POST", t = {}) {
|
|
3991
3991
|
const { onSuccess: n, onError: s } = t, [o, i] = H(null), [l, a] = H(!1), [u, c] = H(null), d = re(
|
|
3992
3992
|
async (h) => {
|
|
3993
3993
|
a(!0), c(null);
|
|
@@ -4741,7 +4741,7 @@ class Ls {
|
|
|
4741
4741
|
return t.reduce((n, s) => s(n), e);
|
|
4742
4742
|
}
|
|
4743
4743
|
}
|
|
4744
|
-
function
|
|
4744
|
+
function Af({
|
|
4745
4745
|
endpoint: r,
|
|
4746
4746
|
params: e,
|
|
4747
4747
|
layout: t = "list",
|
|
@@ -4947,7 +4947,7 @@ function Df({
|
|
|
4947
4947
|
] })
|
|
4948
4948
|
] });
|
|
4949
4949
|
}
|
|
4950
|
-
function
|
|
4950
|
+
function Ef({
|
|
4951
4951
|
item: r,
|
|
4952
4952
|
onClick: e,
|
|
4953
4953
|
title: t = (i) => i.title || i.name || i.label || "Untitled",
|
|
@@ -4986,7 +4986,7 @@ function Af({
|
|
|
4986
4986
|
}
|
|
4987
4987
|
);
|
|
4988
4988
|
}
|
|
4989
|
-
function
|
|
4989
|
+
function Sf({
|
|
4990
4990
|
item: r,
|
|
4991
4991
|
onClose: e,
|
|
4992
4992
|
title: t = (o) => o.title || o.name || o.label || "Detail",
|
|
@@ -5040,7 +5040,7 @@ const xu = {
|
|
|
5040
5040
|
medium: "w-48 h-48",
|
|
5041
5041
|
large: "w-64 h-64"
|
|
5042
5042
|
};
|
|
5043
|
-
function
|
|
5043
|
+
function kf({
|
|
5044
5044
|
nodes: r,
|
|
5045
5045
|
cardCount: e = 2,
|
|
5046
5046
|
minInterval: t = 1e3,
|
|
@@ -5234,7 +5234,7 @@ const _u = {
|
|
|
5234
5234
|
primary: "#3b82f6",
|
|
5235
5235
|
danger: "#ef4444"
|
|
5236
5236
|
};
|
|
5237
|
-
function
|
|
5237
|
+
function Tf({
|
|
5238
5238
|
baseUrl: r,
|
|
5239
5239
|
systemId: e,
|
|
5240
5240
|
accountId: t,
|
|
@@ -5588,7 +5588,7 @@ function kf({
|
|
|
5588
5588
|
i && Ce && /* @__PURE__ */ p.jsx("div", { style: { flex: 1, overflowY: "auto" }, children: Te(Ce) })
|
|
5589
5589
|
] });
|
|
5590
5590
|
}
|
|
5591
|
-
function
|
|
5591
|
+
function Bf({
|
|
5592
5592
|
items: r,
|
|
5593
5593
|
renderItem: e,
|
|
5594
5594
|
onSelectionChange: t,
|
|
@@ -11674,7 +11674,7 @@ function rf({ validateUrl: r, attributes: e }) {
|
|
|
11674
11674
|
function nf(r) {
|
|
11675
11675
|
if (r instanceof HTMLImageElement) {
|
|
11676
11676
|
const e = r.getAttribute("src") || "", t = r.getAttribute("alt") || "", n = r.getAttribute("width"), s = r.getAttribute("height");
|
|
11677
|
-
return
|
|
11677
|
+
return { node: Oa({
|
|
11678
11678
|
src: e,
|
|
11679
11679
|
altText: t,
|
|
11680
11680
|
width: n ? parseInt(n, 10) : void 0,
|
|
@@ -11683,6 +11683,24 @@ function nf(r) {
|
|
|
11683
11683
|
}
|
|
11684
11684
|
return null;
|
|
11685
11685
|
}
|
|
11686
|
+
function sf({ src: r, alt: e, width: t, height: n }) {
|
|
11687
|
+
return /* @__PURE__ */ p.jsx(
|
|
11688
|
+
"img",
|
|
11689
|
+
{
|
|
11690
|
+
src: r,
|
|
11691
|
+
alt: e,
|
|
11692
|
+
width: t,
|
|
11693
|
+
height: n,
|
|
11694
|
+
style: {
|
|
11695
|
+
maxWidth: "100%",
|
|
11696
|
+
height: "auto",
|
|
11697
|
+
display: "block",
|
|
11698
|
+
margin: "8px 0",
|
|
11699
|
+
borderRadius: "4px"
|
|
11700
|
+
}
|
|
11701
|
+
}
|
|
11702
|
+
);
|
|
11703
|
+
}
|
|
11686
11704
|
class Ss extends ma {
|
|
11687
11705
|
constructor(t, n, s, o, i) {
|
|
11688
11706
|
super(i);
|
|
@@ -11731,15 +11749,22 @@ class Ss extends ma {
|
|
|
11731
11749
|
return t.setAttribute("src", this.__src), this.__altText && t.setAttribute("alt", this.__altText), this.__width && t.setAttribute("width", String(this.__width)), this.__height && t.setAttribute("height", String(this.__height)), t.style.maxWidth = "100%", t.style.height = "auto", { element: t };
|
|
11732
11750
|
}
|
|
11733
11751
|
createDOM() {
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
return t.src = this.__src, t.alt = this.__altText, this.__width && (t.width = this.__width), this.__height && (t.height = this.__height), t.style.maxWidth = "100%", t.style.height = "auto", t.style.display = "block", t.style.margin = "8px 0", t.style.borderRadius = "4px", t.style.backgroundColor = "red", t.style.minWidth = "150px", t.style.minHeight = "150px", console.log("[ImageNode] createDOM() - src length:", (n = this.__src) == null ? void 0 : n.length), t;
|
|
11752
|
+
const t = document.createElement("span");
|
|
11753
|
+
return t.style.display = "inline-block", t;
|
|
11737
11754
|
}
|
|
11738
|
-
updateDOM(
|
|
11739
|
-
return
|
|
11755
|
+
updateDOM() {
|
|
11756
|
+
return !1;
|
|
11740
11757
|
}
|
|
11741
11758
|
decorate() {
|
|
11742
|
-
return
|
|
11759
|
+
return /* @__PURE__ */ p.jsx(
|
|
11760
|
+
sf,
|
|
11761
|
+
{
|
|
11762
|
+
src: this.__src,
|
|
11763
|
+
alt: this.__altText,
|
|
11764
|
+
width: this.__width,
|
|
11765
|
+
height: this.__height
|
|
11766
|
+
}
|
|
11767
|
+
);
|
|
11743
11768
|
}
|
|
11744
11769
|
}
|
|
11745
11770
|
function Oa(r) {
|
|
@@ -11750,7 +11775,7 @@ function Oa(r) {
|
|
|
11750
11775
|
r.height
|
|
11751
11776
|
);
|
|
11752
11777
|
}
|
|
11753
|
-
const
|
|
11778
|
+
const of = {
|
|
11754
11779
|
background: "#ffffff",
|
|
11755
11780
|
text: "#111827",
|
|
11756
11781
|
textSecondary: "#6b7280",
|
|
@@ -11759,7 +11784,7 @@ const sf = {
|
|
|
11759
11784
|
toolbarBackground: "#f9fafb",
|
|
11760
11785
|
quoteBorder: "#d1d5db",
|
|
11761
11786
|
quoteBackground: "#f3f4f6"
|
|
11762
|
-
},
|
|
11787
|
+
}, lf = {
|
|
11763
11788
|
paragraph: "mail-editor-paragraph",
|
|
11764
11789
|
text: {
|
|
11765
11790
|
bold: "mail-editor-bold",
|
|
@@ -11779,7 +11804,7 @@ const sf = {
|
|
|
11779
11804
|
h3: "mail-editor-h3"
|
|
11780
11805
|
}
|
|
11781
11806
|
};
|
|
11782
|
-
function
|
|
11807
|
+
function af({ theme: r, disabled: e, onAiRestructure: t, onAiProofread: n, onAiRewrite: s, aiProcessing: o, aiProcessingAction: i, onAiAction: l, hasContent: a }) {
|
|
11783
11808
|
const [u] = kt(), [c, d] = tt.useState(!1), f = tt.useRef(null), h = t || n || s, g = re(() => {
|
|
11784
11809
|
u.dispatchCommand(At, "bold");
|
|
11785
11810
|
}, [u]), m = re(() => {
|
|
@@ -12090,7 +12115,7 @@ function lf({ theme: r, disabled: e, onAiRestructure: t, onAiProofread: n, onAiR
|
|
|
12090
12115
|
}
|
|
12091
12116
|
);
|
|
12092
12117
|
}
|
|
12093
|
-
function
|
|
12118
|
+
function uf({ html: r, isExternalUpdate: e, onImportComplete: t }) {
|
|
12094
12119
|
const [n] = kt(), s = tt.useRef(!1);
|
|
12095
12120
|
return Se(() => {
|
|
12096
12121
|
r && (s.current && !e || (s.current = !0, n.update(
|
|
@@ -12108,7 +12133,7 @@ function af({ html: r, isExternalUpdate: e, onImportComplete: t }) {
|
|
|
12108
12133
|
}, 0)));
|
|
12109
12134
|
}, [r, e, n, t]), null;
|
|
12110
12135
|
}
|
|
12111
|
-
function
|
|
12136
|
+
function cf({ text: r, trigger: e }) {
|
|
12112
12137
|
const [t] = kt(), n = tt.useRef(void 0);
|
|
12113
12138
|
return Se(() => {
|
|
12114
12139
|
if (e === void 0 || e === n.current || !r) return;
|
|
@@ -12134,7 +12159,7 @@ function uf({ text: r, trigger: e }) {
|
|
|
12134
12159
|
}, 0));
|
|
12135
12160
|
}, [r, e, t]), null;
|
|
12136
12161
|
}
|
|
12137
|
-
function
|
|
12162
|
+
function df({ replyTo: r, theme: e }) {
|
|
12138
12163
|
const t = (n) => {
|
|
12139
12164
|
try {
|
|
12140
12165
|
return new Date(n).toLocaleString();
|
|
@@ -12188,7 +12213,7 @@ function cf({ replyTo: r, theme: e }) {
|
|
|
12188
12213
|
}
|
|
12189
12214
|
);
|
|
12190
12215
|
}
|
|
12191
|
-
function
|
|
12216
|
+
function ff({
|
|
12192
12217
|
value: r = "",
|
|
12193
12218
|
onChange: e,
|
|
12194
12219
|
placeholder: t = "Write your message...",
|
|
@@ -12207,7 +12232,7 @@ function df({
|
|
|
12207
12232
|
aiProcessingAction: m,
|
|
12208
12233
|
renderAboveToolbar: _
|
|
12209
12234
|
}) {
|
|
12210
|
-
const w = { ...
|
|
12235
|
+
const w = { ...of, ...s }, [v, A] = tt.useState(!1), C = tt.useRef(void 0), [E, y] = tt.useState(r), [b, D] = tt.useState(!1), [S, M] = tt.useState(null), T = g ?? b, B = m ?? S;
|
|
12211
12236
|
tt.useEffect(() => {
|
|
12212
12237
|
a !== void 0 && a !== C.current && (C.current = a, A(!0));
|
|
12213
12238
|
}, [a]);
|
|
@@ -12231,7 +12256,7 @@ function df({
|
|
|
12231
12256
|
}
|
|
12232
12257
|
}, de = j(E).length > 0, Ce = {
|
|
12233
12258
|
namespace: "MailEditor",
|
|
12234
|
-
theme:
|
|
12259
|
+
theme: lf,
|
|
12235
12260
|
onError: (xe) => {
|
|
12236
12261
|
console.error("Lexical error:", xe);
|
|
12237
12262
|
},
|
|
@@ -12335,7 +12360,7 @@ function df({
|
|
|
12335
12360
|
_,
|
|
12336
12361
|
/* @__PURE__ */ p.jsxs(Mc, { initialConfig: Ce, children: [
|
|
12337
12362
|
/* @__PURE__ */ p.jsx(
|
|
12338
|
-
|
|
12363
|
+
af,
|
|
12339
12364
|
{
|
|
12340
12365
|
theme: w,
|
|
12341
12366
|
disabled: o,
|
|
@@ -12375,7 +12400,7 @@ function df({
|
|
|
12375
12400
|
/* @__PURE__ */ p.jsx(Rd, {}),
|
|
12376
12401
|
/* @__PURE__ */ p.jsx(Md, { onChange: ae }),
|
|
12377
12402
|
/* @__PURE__ */ p.jsx(
|
|
12378
|
-
|
|
12403
|
+
uf,
|
|
12379
12404
|
{
|
|
12380
12405
|
html: v ? E : r,
|
|
12381
12406
|
isExternalUpdate: v,
|
|
@@ -12383,19 +12408,19 @@ function df({
|
|
|
12383
12408
|
}
|
|
12384
12409
|
),
|
|
12385
12410
|
/* @__PURE__ */ p.jsx(
|
|
12386
|
-
|
|
12411
|
+
cf,
|
|
12387
12412
|
{
|
|
12388
12413
|
text: u,
|
|
12389
12414
|
trigger: c
|
|
12390
12415
|
}
|
|
12391
12416
|
)
|
|
12392
12417
|
] }),
|
|
12393
|
-
n && /* @__PURE__ */ p.jsx(
|
|
12418
|
+
n && /* @__PURE__ */ p.jsx(df, { replyTo: n, theme: w })
|
|
12394
12419
|
]
|
|
12395
12420
|
}
|
|
12396
12421
|
);
|
|
12397
12422
|
}
|
|
12398
|
-
const
|
|
12423
|
+
const hf = {
|
|
12399
12424
|
background: "#ffffff",
|
|
12400
12425
|
text: "#111827",
|
|
12401
12426
|
textSecondary: "#6b7280",
|
|
@@ -12414,7 +12439,7 @@ const ff = {
|
|
|
12414
12439
|
attachmentBackground: "#f9fafb",
|
|
12415
12440
|
attachmentBorder: "#e5e7eb"
|
|
12416
12441
|
};
|
|
12417
|
-
function
|
|
12442
|
+
function Nf({
|
|
12418
12443
|
to: r = "",
|
|
12419
12444
|
subject: e = "",
|
|
12420
12445
|
body: t = "",
|
|
@@ -12438,7 +12463,7 @@ function Bf({
|
|
|
12438
12463
|
onAiRewrite: C,
|
|
12439
12464
|
renderAboveToolbar: E
|
|
12440
12465
|
}) {
|
|
12441
|
-
const y = { ...
|
|
12466
|
+
const y = { ...hf, ...c }, [b, D] = H(r), [S, M] = H(""), [T, B] = H(""), [F, j] = H(e), [I, X] = H(t), [de, Ce] = H([]), [ae, Oe] = H(!1), [xe, pe] = H(""), [_e, be] = H(f), [ke, ge] = H(!1), De = tt.useRef(void 0);
|
|
12442
12467
|
tt.useEffect(() => {
|
|
12443
12468
|
l !== void 0 && l !== De.current && (De.current = l, X(t), ge(!0));
|
|
12444
12469
|
}, [l, t]);
|
|
@@ -12637,7 +12662,7 @@ function Bf({
|
|
|
12637
12662
|
)
|
|
12638
12663
|
] }),
|
|
12639
12664
|
/* @__PURE__ */ p.jsx("div", { style: { flex: 1, display: "flex", flexDirection: "column", minHeight: 0 }, children: /* @__PURE__ */ p.jsx("div", { style: { flex: 1, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ p.jsx(
|
|
12640
|
-
|
|
12665
|
+
ff,
|
|
12641
12666
|
{
|
|
12642
12667
|
value: I,
|
|
12643
12668
|
onChange: Le,
|
|
@@ -12784,7 +12809,7 @@ function Bf({
|
|
|
12784
12809
|
}
|
|
12785
12810
|
);
|
|
12786
12811
|
}
|
|
12787
|
-
const
|
|
12812
|
+
const pf = {
|
|
12788
12813
|
background: "#ffffff",
|
|
12789
12814
|
text: "#111827",
|
|
12790
12815
|
textSecondary: "#6b7280",
|
|
@@ -12794,7 +12819,7 @@ const hf = {
|
|
|
12794
12819
|
chipText: "#374151",
|
|
12795
12820
|
hoverBackground: "#f9fafb"
|
|
12796
12821
|
};
|
|
12797
|
-
function
|
|
12822
|
+
function Ff({
|
|
12798
12823
|
options: r,
|
|
12799
12824
|
value: e,
|
|
12800
12825
|
onChange: t,
|
|
@@ -12809,7 +12834,7 @@ function Nf({
|
|
|
12809
12834
|
theme: d = {},
|
|
12810
12835
|
className: f = ""
|
|
12811
12836
|
}) {
|
|
12812
|
-
const h = { ...
|
|
12837
|
+
const h = { ...pf, ...d }, [g, m] = H(!1), [_, w] = H(""), v = ye(null), A = ye(null);
|
|
12813
12838
|
Se(() => {
|
|
12814
12839
|
function T(B) {
|
|
12815
12840
|
v.current && !v.current.contains(B.target) && (m(!1), w(""));
|
|
@@ -13040,7 +13065,7 @@ function Nf({
|
|
|
13040
13065
|
)
|
|
13041
13066
|
] });
|
|
13042
13067
|
}
|
|
13043
|
-
function
|
|
13068
|
+
function jf({
|
|
13044
13069
|
items: r,
|
|
13045
13070
|
columns: e,
|
|
13046
13071
|
getItemId: t,
|
|
@@ -13155,7 +13180,7 @@ function Ff({
|
|
|
13155
13180
|
}
|
|
13156
13181
|
);
|
|
13157
13182
|
}
|
|
13158
|
-
const
|
|
13183
|
+
const gf = {
|
|
13159
13184
|
background: "#ffffff",
|
|
13160
13185
|
hourLineColor: "#e5e7eb",
|
|
13161
13186
|
halfHourLineColor: "#f3f4f6",
|
|
@@ -13164,22 +13189,22 @@ const pf = {
|
|
|
13164
13189
|
allDayBackground: "#f9fafb",
|
|
13165
13190
|
allDayBorder: "#e5e7eb"
|
|
13166
13191
|
};
|
|
13167
|
-
function
|
|
13192
|
+
function mf(r) {
|
|
13168
13193
|
const e = r.match(/^(\d{1,2}):(\d{2})$/);
|
|
13169
13194
|
return e ? {
|
|
13170
13195
|
hours: parseInt(e[1], 10),
|
|
13171
13196
|
minutes: parseInt(e[2], 10)
|
|
13172
13197
|
} : null;
|
|
13173
13198
|
}
|
|
13174
|
-
function
|
|
13199
|
+
function yf(r) {
|
|
13175
13200
|
const e = r % 12 || 12, t = r < 12 ? "AM" : "PM";
|
|
13176
13201
|
return `${e} ${t}`;
|
|
13177
13202
|
}
|
|
13178
|
-
function
|
|
13203
|
+
function xf(r) {
|
|
13179
13204
|
const e = /* @__PURE__ */ new Date();
|
|
13180
13205
|
return r.getDate() === e.getDate() && r.getMonth() === e.getMonth() && r.getFullYear() === e.getFullYear();
|
|
13181
13206
|
}
|
|
13182
|
-
function
|
|
13207
|
+
function Lf({
|
|
13183
13208
|
items: r,
|
|
13184
13209
|
date: e,
|
|
13185
13210
|
startHour: t = 7,
|
|
@@ -13196,7 +13221,7 @@ function jf({
|
|
|
13196
13221
|
className: h = "",
|
|
13197
13222
|
theme: g = {}
|
|
13198
13223
|
}) {
|
|
13199
|
-
const m = { ...
|
|
13224
|
+
const m = { ...gf, ...g }, { allDayItems: _, timedItems: w } = Et(() => {
|
|
13200
13225
|
const b = [], D = [];
|
|
13201
13226
|
for (const S of r)
|
|
13202
13227
|
l(S) ? b.push(S) : D.push(S);
|
|
@@ -13210,14 +13235,14 @@ function jf({
|
|
|
13210
13235
|
(b) => {
|
|
13211
13236
|
const D = o(b);
|
|
13212
13237
|
if (!D) return null;
|
|
13213
|
-
const S =
|
|
13238
|
+
const S = mf(D);
|
|
13214
13239
|
if (!S) return null;
|
|
13215
13240
|
const { hours: M, minutes: T } = S, B = Math.max(t, Math.min(n, M)), F = M < t ? 0 : T, j = (B - t) * s + F / 60 * s, I = i(b), X = Math.max(20, I / 60 * s);
|
|
13216
13241
|
return { top: j, height: X };
|
|
13217
13242
|
},
|
|
13218
13243
|
[o, i, t, n, s]
|
|
13219
13244
|
), E = Et(() => {
|
|
13220
|
-
if (!f || !
|
|
13245
|
+
if (!f || !xf(e)) return null;
|
|
13221
13246
|
const b = /* @__PURE__ */ new Date(), D = b.getHours(), S = b.getMinutes();
|
|
13222
13247
|
return D < t || D > n ? null : (D - t) * s + S / 60 * s;
|
|
13223
13248
|
}, [e, f, t, n, s]), y = re(
|
|
@@ -13278,7 +13303,7 @@ function jf({
|
|
|
13278
13303
|
fontSize: "11px",
|
|
13279
13304
|
color: m.hourTextColor
|
|
13280
13305
|
},
|
|
13281
|
-
children:
|
|
13306
|
+
children: yf(b)
|
|
13282
13307
|
}
|
|
13283
13308
|
),
|
|
13284
13309
|
/* @__PURE__ */ p.jsx(
|
|
@@ -13386,7 +13411,7 @@ function jf({
|
|
|
13386
13411
|
] })
|
|
13387
13412
|
] });
|
|
13388
13413
|
}
|
|
13389
|
-
function
|
|
13414
|
+
function Pf({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComplete: n, variant: s = "widget", hideSaveButton: o = !1, maxDuration: i = 180 }) {
|
|
13390
13415
|
const l = s === "widget", [a, u] = H("idle"), [c, d] = H(0), [f, h] = H(0), [g, m] = H(!1), [_, w] = H(0), [v, A] = H(null), [C, E] = H(!1), [y, b] = H(null), [D, S] = H(!0), [M, T] = H([]), [B, F] = H({ completed: 0, total: 0 }), j = ye(!1), I = ye(!0);
|
|
13391
13416
|
Se(() => {
|
|
13392
13417
|
I.current = D;
|
|
@@ -13901,25 +13926,25 @@ function Lf({ onComplete: r, onCancel: e, onTranscribe: t, onTranscriptionComple
|
|
|
13901
13926
|
] });
|
|
13902
13927
|
}
|
|
13903
13928
|
export {
|
|
13904
|
-
|
|
13929
|
+
kf as AnimatedCardFlip,
|
|
13905
13930
|
pu as ApiClient,
|
|
13906
|
-
|
|
13931
|
+
Pf as AudioEditor,
|
|
13907
13932
|
hu as AuthManager,
|
|
13908
|
-
|
|
13909
|
-
|
|
13933
|
+
Ef as Card,
|
|
13934
|
+
Ff as ComboBox,
|
|
13910
13935
|
Ls as DataOperations,
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13936
|
+
Sf as Detail,
|
|
13937
|
+
wf as GraphClient,
|
|
13938
|
+
jf as KanbanBoard,
|
|
13939
|
+
Tf as Mail,
|
|
13915
13940
|
fu as MailClient,
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13941
|
+
Nf as MailComposer,
|
|
13942
|
+
ff as MailEditor,
|
|
13943
|
+
Bf as SelectableList,
|
|
13944
|
+
Af as Stack,
|
|
13945
|
+
Lf as Timeline,
|
|
13921
13946
|
gl as getApiClient,
|
|
13922
|
-
|
|
13923
|
-
|
|
13947
|
+
Cf as initializeApiClient,
|
|
13948
|
+
Df as useMutation,
|
|
13924
13949
|
gu as useQuery
|
|
13925
13950
|
};
|
package/package.json
CHANGED