@confidencesystemsinc/sdk 1.7.5 → 1.7.6

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/index.cjs CHANGED
@@ -603,4 +603,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
603
603
  `||s===`\r
604
604
  `?r.push(Lo()):s===" "?r.push(na()):r.push(rt(s))}this.insertNodes(r)}insertText(t){const n=this.anchor,r=this.focus,o=this.format,i=this.style;let s=n,a=r;!this.isCollapsed()&&r.isBefore(n)&&(s=r,a=n),s.type==="element"&&(function(m,y,v,b){const A=m.getNode(),w=A.getChildAtIndex(m.offset),_=rt();if(_.setFormat(v),_.setStyle(b),Bd(w))w.splice(0,0,[_]);else{const E=Ye(A)?Tt().append(_):_;w===null?A.append(E):w.insertBefore(E)}m.is(y)&&y.set(_.__key,0,"text"),m.set(_.__key,0,"text")})(s,a,o,i),a.type==="element"&&$o(a,Yt(nr(a,"next")));const l=s.offset;let c=a.offset;const u=this.getNodes(),f=u.length;let d=u[0];X(d)||U(26);const h=d.getTextContent().length,p=d.getParentOrThrow();let g=u[f-1];if(f===1&&a.type==="element"&&(c=h,a.set(s.key,c,"text")),this.isCollapsed()&&l===h&&(Wn(d)||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let m=d.getNextSibling();if(X(m)&&m.canInsertTextBefore()&&!Wn(m)||(m=rt(),m.setFormat(o),m.setStyle(i),p.canInsertTextAfter()?d.insertAfter(m):p.insertAfter(m)),m.select(0,0),d=m,t!=="")return void this.insertText(t)}else if(this.isCollapsed()&&l===0&&(Wn(d)||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let m=d.getPreviousSibling();if(X(m)&&!Wn(m)||(m=rt(),m.setFormat(o),p.canInsertTextBefore()?d.insertBefore(m):p.insertBefore(m)),m.select(),d=m,t!=="")return void this.insertText(t)}else if(d.isSegmented()&&l!==h){const m=rt(d.getTextContent());m.setFormat(o),d.replace(m),d=m}else if(!this.isCollapsed()&&t!==""){const m=g.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||R(m)&&(!m.canInsertTextBefore()||!m.canInsertTextAfter()))return this.insertText(""),Jb(this.anchor,this.focus,null),void this.insertText(t)}if(f===1){if(wo(d)){const b=rt(t);return b.select(),void d.replace(b)}const m=d.getFormat(),y=d.getStyle();if(l!==c||m===o&&y===i){if(Zb(d)){const b=rt(t);return b.setFormat(o),b.setStyle(i),b.select(),void d.replace(b)}}else{if(d.getTextContent()!==""){const b=rt(t);if(b.setFormat(o),b.setStyle(i),b.select(),l===0)d.insertBefore(b,!1);else{const[A]=d.splitText(l);A.insertAfter(b,!1)}return void(b.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=t.length))}d.setFormat(o),d.setStyle(i)}const v=c-l;d=d.spliceText(l,v,t,!0),d.getTextContent()===""?d.remove():this.anchor.type==="text"&&(d.isComposing()?this.anchor.offset-=t.length:(this.format=m,this.style=y))}else{const m=new Set([...d.getParentKeys(),...g.getParentKeys()]),y=R(d)?d:d.getParentOrThrow();let v=R(g)?g:g.getParentOrThrow(),b=g;if(!y.is(v)&&v.isInline())do b=v,v=v.getParentOrThrow();while(v.isInline());if(a.type==="text"&&(c!==0||g.getTextContent()==="")||a.type==="element"&&g.getIndexWithinParent()<c)if(X(g)&&!wo(g)&&c!==g.getTextContentSize()){if(g.isSegmented()){const S=rt(g.getTextContent());g.replace(S),g=S}Ye(a.getNode())||a.type!=="text"||(g=g.spliceText(0,c,"")),m.add(g.__key)}else{const S=g.getParentOrThrow();S.canBeEmpty()||S.getChildrenSize()!==1?g.remove():S.remove()}else m.add(g.__key);const A=v.getChildren(),w=new Set(u),_=y.is(v),E=y.isInline()&&d.getNextSibling()===null?y:d;for(let S=A.length-1;S>=0;S--){const O=A[S];if(O.is(d)||R(O)&&O.isParentOf(d))break;O.isAttached()&&(!w.has(O)||O.is(b)?_||E.insertAfter(O,!1):O.remove())}if(!_){let S=v,O=null;for(;S!==null;){const P=S.getChildren(),I=P.length;(I===0||P[I-1].is(O))&&(m.delete(S.__key),O=S),S=S.getParent()}}if(wo(d))if(l===h)d.select();else{const S=rt(t);S.select(),d.replace(S)}else d=d.spliceText(l,h-l,t,!0),d.getTextContent()===""?d.remove():d.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=t.length);for(let S=1;S<f;S++){const O=u[S],P=O.__key;m.has(P)||O.remove()}}}removeText(){const t=Z()===this;qa(this,C6(dg(this))),t&&Z()!==this&&Pt(this)}formatText(t,n=null){if(this.isCollapsed())return this.toggleFormat(t),void ft(null);const r=this.getNodes(),o=[];for(const A of r)X(A)&&o.push(A);const i=A=>{r.forEach(w=>{if(R(w)){const _=w.getFormatFlags(t,A);w.setTextFormat(_)}})},s=o.length;if(s===0)return this.toggleFormat(t),ft(null),void i(n);const a=this.anchor,l=this.focus,c=this.isBackward(),u=c?l:a,f=c?a:l;let d=0,h=o[0],p=u.type==="element"?0:u.offset;if(u.type==="text"&&p===h.getTextContentSize()&&(d=1,h=o[1],p=0),h==null)return;const g=h.getFormatFlags(t,n);i(g);const m=s-1;let y=o[m];const v=f.type==="text"?f.offset:y.getTextContentSize();if(h.is(y)){if(p===v)return;if(Wn(h)||p===0&&v===h.getTextContentSize())h.setFormat(g);else{const A=h.splitText(p,v),w=p===0?A[0]:A[1];w.setFormat(g),u.type==="text"&&u.set(w.__key,0,"text"),f.type==="text"&&f.set(w.__key,v-p,"text")}return void(this.format=g)}p===0||Wn(h)||([,h]=h.splitText(p),p=0),h.setFormat(g);const b=y.getFormatFlags(t,g);v>0&&(v===y.getTextContentSize()||Wn(y)||([y]=y.splitText(v)),y.setFormat(b));for(let A=d+1;A<m;A++){const w=o[A],_=w.getFormatFlags(t,b);w.setFormat(_)}u.type==="text"&&u.set(h.__key,p,"text"),f.type==="text"&&f.set(y.__key,v,"text"),this.format=g|b}insertNodes(t){if(t.length===0)return;if(this.isCollapsed()||this.removeText(),this.anchor.key==="root"){this.insertParagraph();const p=Z();return $(p)||U(134),p.insertNodes(t)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=at(n,yr),o=t[t.length-1];if(R(r)&&"__language"in r){if("__language"in t[0])this.insertText(t[0].getTextContent());else{const p=Zc(this);r.splice(p,0,t),o.selectEnd()}return}if(!t.some(p=>(R(p)||Te(p))&&!p.isInline())){R(r)||U(211,n.constructor.name,n.getType());const p=Zc(this);return r.splice(p,0,t),void o.selectEnd()}const i=(function(p){const g=Tt();let m=null;for(let y=0;y<p.length;y++){const v=p[y],b=xo(v);if(b||Te(v)&&v.isInline()||R(v)&&v.isInline()||X(v)||v.isParentRequired()){if(m===null&&(m=v.createParentElementNode(),g.append(m),b))continue;m!==null&&m.append(v)}else g.append(v),m=null}return g})(t),s=i.getLastDescendant(),a=i.getChildren(),l=!R(r)||!r.isEmpty()?this.insertParagraph():null,c=a[a.length-1];let u=a[0];var f;R(f=u)&&yr(f)&&!f.isEmpty()&&R(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(R(r)||U(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=a[1]),u&&(r===null&&U(212,n.constructor.name,n.getType()),(function(p,g){const m=g.getParentOrThrow().getLastChild();let y=g;const v=[g];for(;y!==m;)y.getNextSibling()||U(140),y=y.getNextSibling(),v.push(y);let b=p;for(const A of v)b=b.insertAfter(A)})(r,u));const d=at(s,yr);l&&R(d)&&(l.canMergeWhenEmpty()||yr(c))&&(d.append(...l.getChildren()),l.remove()),R(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=R(r)?r.getLastChild():null;xo(h)&&d!==r&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){const s=Tt();return We().splice(this.anchor.offset,0,[s]),s.select(),s}const t=Zc(this),n=at(this.anchor.getNode(),yr);R(n)||U(213);const r=n.getChildAtIndex(t),o=r?[r,...r.getNextSiblings()]:[],i=n.insertNewAfter(this,!1);return i?(i.append(...o),i.selectStart(),i):null}insertLineBreak(t){const n=Lo();if(this.insertNodes([n]),t){const r=n.getParentOrThrow(),o=n.getIndexWithinParent();r.select(o,o)}}extract(){const t=[...this.getNodes()],n=t.length;let r=t[0],o=t[n-1];const[i,s]=Of(this),a=this.isBackward(),[l,c]=a?[this.focus,this.anchor]:[this.anchor,this.focus],[u,f]=a?[s,i]:[i,s];if(n===0)return[];if(n===1){if(X(r)&&!this.isCollapsed()){const d=r.splitText(u,f),h=u===0?d[0]:d[1];return h?(l.set(h.getKey(),0,"text"),c.set(h.getKey(),h.getTextContentSize(),"text"),[h]):[]}return[r]}if(X(r)&&(u===r.getTextContentSize()?t.shift():u!==0&&([,r]=r.splitText(u),t[0]=r,l.set(r.getKey(),0,"text"))),X(o)){const d=o.getTextContent().length;f===0?t.pop():f!==d&&([o]=o.splitText(f),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,n,r){if(Ym(this,t,n,r))return;const o=t==="move",i=Re(),s=en(Xt(i));if(!s)return;const a=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(l===null||a===null||!R(c)||c.isInline()||c.canBeEmpty()||Rf(a,i,l),this.dirty){let u=Do(i,this.anchor.key),f=Do(i,this.focus.key);this.anchor.type==="text"&&(u=Di(u)),this.focus.type==="text"&&(f=Di(f)),u&&f&&rx(s,u,this.anchor.offset,f,this.focus.offset)}if((function(u,f,d,h){u.modify(f,d,h)})(s,t,n?"backward":"forward",r),s.rangeCount>0){const u=s.getRangeAt(0),f=this.anchor.getNode(),d=Ye(f)?f:a6(f);if(this.applyDOMRange(u),this.dirty=!0,!o){const h=this.getNodes(),p=[];let g=!1;for(let m=0;m<h.length;m++){const y=h[m];Lf(y,d)?p.push(y):g=!0}if(g&&p.length>0)if(n){const m=p[0];R(m)?m.selectStart():m.getParentOrThrow().selectStart()}else{const m=p[p.length-1];R(m)?m.selectEnd():m.getParentOrThrow().selectEnd()}s.anchorNode===u.startContainer&&s.anchorOffset===u.startOffset||(function(m){const y=m.focus,v=m.anchor,b=v.key,A=v.offset,w=v.type;v.set(y.key,y.offset,y.type,!0),y.set(b,A,w,!0)})(this)}}r==="lineboundary"&&Ym(this,t,n,r,"decorators")}forwardDeletion(t,n,r){if(!r&&(t.type==="element"&&R(n)&&t.offset===n.getChildrenSize()||t.type==="text"&&t.offset===n.getTextContentSize())){const o=n.getParent(),i=n.getNextSibling()||(o===null?null:o.getNextSibling());if(R(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(t){const n=this.isCollapsed();if(this.isCollapsed()){const r=this.anchor;let o=r.getNode();if(this.forwardDeletion(r,o,t))return;const i=rh(nr(r,t?"previous":"next"));if(i.getTextSlices().every(a=>a===null||a.distance===0)){let a={type:"initial"};for(const l of i.iterNodeCarets("shadowRoot"))if(Tn(l)){if(!l.origin.isInline()){if(l.origin.isShadowRoot()){if(a.type==="merge-block")break;if(R(i.anchor.origin)&&i.anchor.origin.isEmpty()){const c=Yt(l);qa(this,Fr(c,c)),i.anchor.origin.remove()}return}a.type!=="merge-next-block"&&a.type!=="merge-block"||(a={block:a.block,caret:l,type:"merge-block"})}}else{if(a.type==="merge-block")break;if(ji(l)){if(R(l.origin)){if(l.origin.isInline()){if(!l.origin.isParentOf(i.anchor.origin))break}else a={block:l.origin,type:"merge-next-block"};continue}if(Te(l.origin)){if(!l.origin.isIsolated())if(a.type==="merge-next-block"&&(l.origin.isKeyboardSelectable()||!l.origin.isInline())&&R(i.anchor.origin)&&i.anchor.origin.isEmpty()){i.anchor.origin.remove();const c=nx();c.add(l.origin.getKey()),Pt(c)}else l.origin.remove();return}break}}if(a.type==="merge-block"){const{caret:l,block:c}=a;return qa(this,Fr(!l.origin.isEmpty()&&c.isEmpty()?oh(xt(c,l.direction)):i.anchor,l)),this.removeText()}}const s=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&r.offset===0&&Bm(this,r.getNode()))return}else{const a=s.type==="text"?s.getNode():null;if(o=r.type==="text"?r.getNode():null,a!==null&&a.isSegmented()){const l=s.offset,c=a.getTextContentSize();if(a.is(o)||t&&l!==c||!t&&l!==0)return void Wm(a,t,l)}else if(o!==null&&o.isSegmented()){const l=r.offset,c=o.getTextContentSize();if(o.is(a)||t&&l!==0||!t&&l!==c)return void Wm(o,t,l)}(function(l,c){const u=l.anchor,f=l.focus,d=u.getNode(),h=f.getNode();if(d===h&&u.type==="text"&&f.type==="text"){const p=u.offset,g=f.offset,m=p<g,y=m?p:g,v=m?g:p,b=v-1;y!==b&&(function(A){return!(Ax(A)||H3(A))})(d.getTextContent().slice(y,v))&&(c?f.set(f.key,b,f.type):u.set(u.key,b,u.type))}})(this,t)}}if(this.removeText(),t&&!n&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const r=this.anchor.getNode();r.isEmpty()&&Ye(r.getParent())&&r.getPreviousSibling()===null&&Bm(this,r)}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText()}deleteWord(t){if(this.isCollapsed()){const n=this.anchor,r=n.getNode();if(this.forwardDeletion(n,r,t))return;this.modify("extend",t,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function ot(e){return e instanceof Jl}function Um(e){const t=e.offset;if(e.type==="text")return t;const n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function Of(e){const t=e.getStartEndPoints();if(t===null)return[0,0];const[n,r]=t;return n.type==="element"&&r.type==="element"&&n.key===r.key&&n.offset===r.offset?[0,0]:[Um(n),Um(r)]}function Bm(e,t){for(let n=t;n;n=n.getParent()){if(R(n)){if(n.collapseAtStart(e))return!0;if(jt(n))break}if(n.getPreviousSibling())break}return!1}const H3=(()=>{try{const e=new RegExp("\\p{Emoji}","u"),t=e.test.bind(e);if(t("❤️")&&t("#️⃣")&&t("👍"))return t}catch{}return()=>!1})();function Wm(e,t,n){const r=e,o=r.getTextContent().split(/(?=\s)/g),i=o.length;let s=0,a=0;for(let c=0;c<i;c++){const u=c===i-1;if(a=s,s+=o[c].length,t&&s===n||s>n||u){o.splice(c,1),u&&(a=void 0);break}}const l=o.join("").trim();l===""?r.remove():(r.setTextContent(l),r.select(a,a))}function Km(e,t,n,r){let o,i=t;if(pt(e)){let s=!1;const a=e.childNodes,l=a.length,c=r._blockCursorElement;i===l&&(s=!0,i=l-1);let u=a[i],f=!1;if(u===c)u=a[i+1],f=!0;else if(c!==null){const d=c.parentNode;e===d&&t>Array.prototype.indexOf.call(d.children,c)&&i--}if(o=ci(u),X(o))i=Pr(o,s?"next":"previous");else{let d=ci(e);if(d===null)return null;if(R(d)){const h=r.getElementByKey(d.getKey());h===null&&U(214),[d,i]=d.getDOMSlot(h).resolveChildIndex(d,h,e,t),R(d)||U(215),s&&i>=d.getChildrenSize()&&(i=Math.max(0,d.getChildrenSize()-1));let g=d.getChildAtIndex(i);if(R(g)&&(function(m,y,v){const b=m.getParent();return v===null||b===null||!b.canBeEmpty()||b!==v.getNode()})(g,0,n)){const m=s?g.getLastDescendant():g.getFirstDescendant();m===null?d=g:(g=m,d=R(g)?g:g.getParentOrThrow()),i=0}X(g)?(o=g,d=null,i=Pr(g,s?"next":"previous")):g!==d&&s&&!f&&(R(d)||U(216),i=Math.min(d.getChildrenSize(),i+1))}else{const h=d.getIndexWithinParent();i=t===0&&Te(d)&&ci(e)===d?h:h+1,d=d.getParentOrThrow()}if(R(d))return Pn(d.__key,i,"element")}}else o=ci(e);return X(o)?Pn(o.__key,Pr(o,i,"clamp"),"text"):null}function Hm(e,t,n){const r=e.offset,o=e.getNode();if(r===0){const i=o.getPreviousSibling(),s=o.getParent();if(t){if((n||!t)&&i===null&&R(s)&&s.isInline()){const a=s.getPreviousSibling();X(a)&&e.set(a.__key,a.getTextContent().length,"text")}}else R(i)&&!n&&i.isInline()?e.set(i.__key,i.getChildrenSize(),"element"):X(i)&&e.set(i.__key,i.getTextContent().length,"text")}else if(r===o.getTextContent().length){const i=o.getNextSibling(),s=o.getParent();if(t&&R(i)&&i.isInline())e.set(i.__key,0,"element");else if((n||t)&&i===null&&R(s)&&s.isInline()&&!s.canInsertTextAfter()){const a=s.getNextSibling();X(a)&&e.set(a.__key,0,"text")}}}function Jb(e,t,n){if(e.type==="text"&&t.type==="text"){const r=e.isBefore(t),o=e.is(t);Hm(e,r,o),Hm(t,!r,o),o&&t.set(e.key,e.offset,e.type);const i=Re();if(i.isComposing()&&i._compositionKey!==e.key&&$(n)){const s=n.anchor,a=n.focus;e.set(s.key,s.offset,s.type,!0),t.set(a.key,a.offset,a.type,!0)}}}function Xb(e,t,n,r,o,i){if(e===null||n===null||!ia(o,e,n))return null;const s=Km(e,t,$(i)?i.anchor:null,o);if(s===null)return null;const a=Km(n,r,$(i)?i.focus:null,o);if(a===null)return null;if(s.type==="element"&&a.type==="element"){const l=ci(e),c=ci(n);if(Te(l)&&Te(c))return null}return Jb(s,a,i),[s,a]}function Pf(e){return R(e)&&!e.isInline()}function ex(e,t,n,r,o,i){const s=Wr(),a=new Wo(Pn(e,t,o),Pn(n,r,i),0,"");return a.dirty=!0,s._selection=a,a}function tx(){const e=Pn("root",0,"element"),t=Pn("root",0,"element");return new Wo(e,t,0,"")}function nx(){return new Jl(new Set)}function jd(e,t,n,r){const o=n._window;if(o===null)return null;const i=r||o.event,s=i?i.type:void 0,a=s==="selectionchange",l=!df&&(a||s==="beforeinput"||s==="compositionstart"||s==="compositionend"||s==="click"&&i&&i.detail===3||s==="drop"||s===void 0);let c,u,f,d;if($(e)&&!l)return e.clone();if(t===null)return null;if(c=t.anchorNode,u=t.focusNode,f=t.anchorOffset,d=t.focusOffset,(a||s===void 0)&&$(e)&&!ia(n,c,u))return e.clone();const h=Xb(c,f,u,d,n,e);if(h===null)return null;const[p,g]=h;return new Wo(p,g,$(e)?e.format:0,$(e)?e.style:"")}function Z(){return Wr()._selection}function Gi(){return Re()._editorState._selection}function ml(e,t,n,r=1){const o=e.anchor,i=e.focus,s=o.getNode(),a=i.getNode();if(!t.is(s)&&!t.is(a))return;const l=t.__key;if(e.isCollapsed()){const c=o.offset;if(n<=c&&r>0||n<c&&r<0){const u=Math.max(0,c+r);o.set(l,u,"element"),i.set(l,u,"element"),qm(e)}}else{const c=e.isBackward(),u=c?i:o,f=u.getNode(),d=c?o:i,h=d.getNode();if(t.is(f)){const p=u.offset;(n<=p&&r>0||n<p&&r<0)&&u.set(l,Math.max(0,p+r),"element")}if(t.is(h)){const p=d.offset;(n<=p&&r>0||n<p&&r<0)&&d.set(l,Math.max(0,p+r),"element")}}qm(e)}function qm(e){const t=e.anchor,n=t.offset,r=e.focus,o=r.offset,i=t.getNode(),s=r.getNode();if(e.isCollapsed()){if(!R(i))return;const a=i.getChildrenSize(),l=n>=a,c=l?i.getChildAtIndex(a-1):i.getChildAtIndex(n);if(X(c)){let u=0;l&&(u=c.getTextContentSize()),t.set(c.__key,u,"text"),r.set(c.__key,u,"text")}return}if(R(i)){const a=i.getChildrenSize(),l=n>=a,c=l?i.getChildAtIndex(a-1):i.getChildAtIndex(n);if(X(c)){let u=0;l&&(u=c.getTextContentSize()),t.set(c.__key,u,"text")}}if(R(s)){const a=s.getChildrenSize(),l=o>=a,c=l?s.getChildAtIndex(a-1):s.getChildAtIndex(o);if(X(c)){let u=0;l&&(u=c.getTextContentSize()),r.set(c.__key,u,"text")}}}function gl(e,t,n,r,o){let i=null,s=0,a=null;r!==null?(i=r.__key,X(r)?(s=r.getTextContentSize(),a="text"):R(r)&&(s=r.getChildrenSize(),a="element")):o!==null&&(i=o.__key,X(o)?a="text":R(o)&&(a="element")),i!==null&&a!==null?e.set(i,s,a):(s=t.getIndexWithinParent(),s===-1&&(s=n.getChildrenSize()),e.set(n.__key,s,"element"))}function Vm(e,t,n,r,o){e.type==="text"?e.set(n,e.offset+(t?0:o),"text"):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,"element")}function rx(e,t,n,r,o){try{e.setBaseAndExtent(t,n,r,o)}catch{}}function q3(e,t,n,r,o,i,s){const a=r.anchorNode,l=r.focusNode,c=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(o.has(L3)&&f!==i||f!==null&&Hd(f))return;if(!$(t))return void(e!==null&&ia(n,a,l)&&r.removeAllRanges());const d=t.anchor,h=t.focus,p=d.key,g=h.key,m=Do(n,p),y=Do(n,g),v=d.offset,b=h.offset,A=t.format,w=t.style,_=t.isCollapsed();let E=m,S=y,O=!1;if(d.type==="text"){E=Di(m);const Y=d.getNode();O=Y.getFormat()!==A||Y.getStyle()!==w}else $(e)&&e.anchor.type==="text"&&(O=!0);var P,I,W,j,z;if(h.type==="text"&&(S=Di(y)),E!==null&&S!==null&&(_&&(e===null||O||$(e)&&(e.format!==A||e.style!==w))&&(P=A,I=w,W=v,j=p,z=performance.now(),Bb=[P,I,W,j,z]),c!==v||u!==b||a!==E||l!==S||r.type==="Range"&&_||(f!==null&&i.contains(f)||o.has(F3)||i.focus({preventScroll:!0}),d.type==="element"))){if(rx(r,E,v,S,b),!o.has(R3)&&t.isCollapsed()&&i!==null&&i===document.activeElement){const Y=$(t)&&t.anchor.type==="element"?E.childNodes[v]||null:r.rangeCount>0?r.getRangeAt(0):null;if(Y!==null){let Q;if(Y instanceof Text){const oe=document.createRange();oe.selectNode(Y),Q=oe.getBoundingClientRect()}else Q=Y.getBoundingClientRect();(function(oe,M,re){const L=Sx(re),F=Zd(L);if(L===null||F===null)return;let{top:K,bottom:B}=M,J=0,V=0,ee=re;for(;ee!==null;){const te=ee===L.body;if(te)J=0,V=Xt(oe).innerHeight;else{const ye=ee.getBoundingClientRect();J=ye.top,V=ye.bottom}let pe=0;if(K<J?pe=-(J-K):B>V&&(pe=B-V),pe!==0)if(te)F.scrollBy(0,pe);else{const ye=ee.scrollTop;ee.scrollTop+=pe;const me=ee.scrollTop-ye;K-=me,B-=me}if(te)break;ee=sa(ee)}})(n,Q,i)}}_f=!0}}function ox(e){let t=Z()||Gi();t===null&&(t=We().selectEnd()),t.insertNodes(e)}function Zc(e){let t=e;e.isCollapsed()||t.removeText();const n=Z();$(n)&&(t=n),$(t)||U(161);const r=t.anchor;let o=r.getNode(),i=r.offset;for(;!yr(o);){const s=o;if([o,i]=V3(o,i),s.is(o))break}return i}function V3(e,t){const n=e.getParent();if(!n){const o=Tt();return We().append(o),o.select(),[We(),0]}if(X(e)){const o=e.splitText(t);if(o.length===0)return[n,e.getIndexWithinParent()];const i=t===0?0:1;return[n,o[0].getIndexWithinParent()+i]}if(!R(e)||t===0)return[n,e.getIndexWithinParent()];const r=e.getChildAtIndex(t);if(r){const o=new Wo(Pn(e.__key,t,"element"),Pn(e.__key,t,"element"),0,""),i=e.insertNewAfter(o);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function Ym(e,t,n,r,o="decorators-and-blocks"){if(t==="move"&&r==="character"&&!e.isCollapsed()){const[u,f]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return f.set(u.key,u.offset,u.type),!0}const i=nr(e.focus,n?"previous":"next"),s=r==="lineboundary",a=t==="move";let l=i,c=o==="decorators-and-blocks";if(!Mx(l)){for(const u of l){c=!1;const{origin:f}=u;if(!Te(f)||f.isIsolated()||(l=u,!s||!f.isInline()))break}if(c)for(const u of rh(i).iterNodeCarets(t==="extend"?"shadowRoot":"root")){if(Tn(u))u.origin.isInline()||(l=u);else{if(R(u.origin))continue;Te(u.origin)&&!u.origin.isInline()&&(l=u)}break}}if(l===i)return!1;if(a&&!s&&Te(l.origin)&&l.origin.isKeyboardSelectable()){const u=nx();return u.add(l.origin.getKey()),Pt(u),!0}return l=Yt(l),a&&$o(e.anchor,l),$o(e.focus,l),c||!s}let it=null,st=null,Ft=!1,Jc=!1,Ka=0;const Qm={characterData:!0,childList:!0,subtree:!0};function ra(){return Ft||it!==null&&it._readOnly}function vt(){Ft&&U(13)}function ix(){Ka>99&&U(14)}function Wr(){return it===null&&U(195,sx()),it}function Re(){return st===null&&U(196,sx()),st}function sx(){let e=0;const t=new Set,n=Ro.version;if(typeof window<"u")for(const o of document.querySelectorAll("[contenteditable]")){const i=ec(o);if(qd(i))e++;else if(i){let s=String(i.constructor.version||"<0.17.1");s===n&&(s+=" (separately built, likely a bundler configuration issue)"),t.add(s)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(", ")}`),r}function Y3(){return st}function Gm(e,t,n){const r=t.__type,o=px(e,r);let i=n.get(r);i===void 0&&(i=Array.from(o.transforms),n.set(r,i));const s=i.length;for(let a=0;a<s&&(i[a](t),t.isAttached());a++);}function Zm(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function ax(e,t){if(!t)return;const n=e._updateTags;let r=t;Array.isArray(t)||(r=[t]);for(const o of r)n.add(o)}function Q3(e){return zd(e,Re()._nodes)}function zd(e,t){const n=e.type,r=t.get(n);r===void 0&&U(17,n);const o=r.klass;e.type!==o.getType()&&U(18,o.name);const i=o.importJSON(e),s=e.children;if(R(i)&&Array.isArray(s))for(let a=0;a<s.length;a++){const l=zd(s[a],t);i.append(l)}return i}function Jm(e,t,n){const r=it,o=Ft,i=st;it=t,Ft=!0,st=e;try{return n()}finally{it=r,Ft=o,st=i}}function Qn(e,t){const n=e._pendingEditorState,r=e._rootElement,o=e._headless||r===null;if(n===null)return;const i=e._editorState,s=i._selection,a=n._selection,l=e._dirtyType!==0,c=it,u=Ft,f=st,d=e._updating,h=e._observer;let p=null;if(e._pendingEditorState=null,e._editorState=n,!o&&l&&h!==null){st=e,it=n,Ft=!1,e._updating=!0;try{const _=e._dirtyType,E=e._dirtyElements,S=e._dirtyLeaves;h.disconnect(),p=h3(i,n,e,_,E,S)}catch(_){if(_ instanceof Error&&e._onError(_),Jc)throw _;return dx(e,null,r,n),yb(e),e._dirtyType=2,Jc=!0,Qn(e,i),void(Jc=!1)}finally{h.observe(r,Qm),e._updating=d,it=c,Ft=u,st=f}}n._readOnly||(n._readOnly=!0);const g=e._dirtyLeaves,m=e._dirtyElements,y=e._normalizedNodes,v=e._updateTags,b=e._deferred;l&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements=new Map,e._normalizedNodes=new Set,e._updateTags=new Set),(function(_,E){const S=_._decorators;let O=_._pendingDecorators||S;const P=E._nodeMap;let I;for(I in O)P.has(I)||(O===S&&(O=xx(_)),delete O[I])})(e,n);const A=o?null:en(Xt(e));if(e._editable&&A!==null&&(l||a===null||a.dirty||!a.is(s))&&r!==null&&!v.has(D3)){st=e,it=n;try{if(h!==null&&h.disconnect(),l||a===null||a.dirty){const _=e._blockCursorElement;_!==null&&Rf(_,e,r),q3(s,a,e,A,v,r)}(function(_,E,S){let O=_._blockCursorElement;if($(S)&&S.isCollapsed()&&S.anchor.type==="element"&&E.contains(document.activeElement)){const P=S.anchor,I=P.getNode(),W=P.offset;let j=!1,z=null;if(W===I.getChildrenSize())eu(I.getChildAtIndex(W-1))&&(j=!0);else{const Y=I.getChildAtIndex(W);if(Y!==null&&eu(Y)){const Q=Y.getPreviousSibling();(Q===null||eu(Q))&&(j=!0,z=_.getElementByKey(Y.__key))}}if(j){const Y=_.getElementByKey(I.__key);return O===null&&(_._blockCursorElement=O=(function(Q){const oe=Q.theme,M=document.createElement("div");M.contentEditable="false",M.setAttribute("data-lexical-cursor","true");let re=oe.blockCursor;if(re!==void 0){if(typeof re=="string"){const L=db(re);re=oe.blockCursor=L}re!==void 0&&M.classList.add(...re)}return M})(_._config)),E.style.caretColor="transparent",void(z===null?Y.appendChild(O):Y.insertBefore(O,z))}}O!==null&&Rf(O,_,E)})(e,r,a)}finally{h!==null&&h.observe(r,Qm),st=f,it=c}}p!==null&&(function(_,E,S,O,P){const I=Array.from(_._listeners.mutation),W=I.length;for(let j=0;j<W;j++){const[z,Y]=I[j];for(const Q of Y){const oe=E.get(Q);oe!==void 0&&z(oe,{dirtyLeaves:O,prevEditorState:P,updateTags:S})}}})(e,p,v,g,i),$(a)||a===null||s!==null&&s.is(a)||e.dispatchCommand(Ql,void 0);const w=e._pendingDecorators;w!==null&&(e._decorators=w,e._pendingDecorators=null,As("decorator",e,!0,w)),(function(_,E,S){const O=ng(E),P=ng(S);O!==P&&As("textcontent",_,!0,P)})(e,t||i,n),As("update",e,!0,{dirtyElements:m,dirtyLeaves:g,editorState:n,mutatedNodes:p,normalizedNodes:y,prevEditorState:t||i,tags:v}),(function(_,E){if(_._deferred=[],E.length!==0){const S=_._updating;_._updating=!0;try{for(let O=0;O<E.length;O++)E[O]()}finally{_._updating=S}}})(e,b),(function(_){const E=_._updates;if(E.length!==0){const S=E.shift();if(S){const[O,P]=S;Xl(_,O,P)}}})(e)}function As(e,t,n,...r){const o=t._updating;t._updating=n;try{const i=Array.from(t._listeners[e]);for(let s=0;s<i.length;s++)i[s].apply(null,r)}finally{t._updating=o}}function Xm(e,t){const n=e._updates;let r=t||!1;for(;n.length!==0;){const o=n.shift();if(o){const[i,s]=o,a=e._pendingEditorState;let l;s!==void 0&&(l=s.onUpdate,s.skipTransforms&&(r=!0),s.discrete&&(a===null&&U(191),a._flushSync=!0),l&&e._deferred.push(l),ax(e,s.tag)),a==null?Xl(e,i,s):i()}}return r}function Xl(e,t,n){const r=e._updateTags;let o,i=!1,s=!1;n!==void 0&&(o=n.onUpdate,ax(e,n.tag),i=n.skipTransforms||!1,s=n.discrete||!1),o&&e._deferred.push(o);const a=e._editorState;let l=e._pendingEditorState,c=!1;(l===null||l._readOnly)&&(l=e._pendingEditorState=cx(l||a),c=!0),l._flushSync=s;const u=it,f=Ft,d=st,h=e._updating;it=l,Ft=!1,e._updating=!0,st=e;const p=e._headless||e.getRootElement()===null;Wd(null);try{c&&(p?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=(function(v,b){const A=v.getEditorState()._selection,w=en(Xt(v));return $(A)||A==null?jd(A,w,v,b):A.clone()})(e,n&&n.event||null));const m=e._compositionKey;t(),i=Xm(e,i),(function(v,b){const A=b.getEditorState()._selection,w=v._selection;if($(w)){const _=w.anchor,E=w.focus;let S;if(_.type==="text"&&(S=_.getNode(),S.selectionTransform(A,w)),E.type==="text"){const O=E.getNode();S!==O&&O.selectionTransform(A,w)}}})(l,e),e._dirtyType!==0&&(i?(function(v,b){const A=b._dirtyLeaves,w=v._nodeMap;for(const _ of A){const E=w.get(_);X(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Nm(E)}})(l,e):(function(v,b){const A=b._dirtyLeaves,w=b._dirtyElements,_=v._nodeMap,E=Sr(),S=new Map;let O=A,P=O.size,I=w,W=I.size;for(;P>0||W>0;){if(P>0){b._dirtyLeaves=new Set;for(const j of O){const z=_.get(j);X(z)&&z.isAttached()&&z.isSimpleText()&&!z.isUnmergeable()&&Nm(z),z!==void 0&&Zm(z,E)&&Gm(b,z,S),A.add(j)}if(O=b._dirtyLeaves,P=O.size,P>0){Ka++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map,I.delete("root")&&I.set("root",!0);for(const j of I){const z=j[0],Y=j[1];if(w.set(z,Y),!Y)continue;const Q=_.get(z);Q!==void 0&&Zm(Q,E)&&Gm(b,Q,S)}O=b._dirtyLeaves,P=O.size,I=b._dirtyElements,W=I.size,Ka++}b._dirtyLeaves=A,b._dirtyElements=w})(l,e),Xm(e),(function(v,b,A,w){const _=v._nodeMap,E=b._nodeMap,S=[];for(const[O]of w){const P=E.get(O);P!==void 0&&(P.isAttached()||(R(P)&&pb(P,O,_,E,S,w),_.has(O)||w.delete(O),S.push(O)))}for(const O of S)E.delete(O);for(const O of A){const P=E.get(O);P===void 0||P.isAttached()||(_.has(O)||A.delete(O),E.delete(O))}})(a,l,e._dirtyLeaves,e._dirtyElements)),m!==e._compositionKey&&(l._flushSync=!0);const y=l._selection;if($(y)){const v=l._nodeMap,b=y.anchor.key,A=y.focus.key;v.get(b)!==void 0&&v.get(A)!==void 0||U(19)}else ot(y)&&y._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&e._onError(m),e._pendingEditorState=a,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void Qn(e)}finally{it=u,Ft=f,st=d,e._updating=h,Ka=0}e._dirtyType!==0||e._deferred.length>0||(function(m,y){const v=y.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1})(l,e)?l._flushSync?(l._flushSync=!1,Qn(e)):c&&t6(()=>{Qn(e)}):(l._flushSync=!1,c&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function kn(e,t,n){st===e&&n===void 0?t():Xl(e,t,n)}class Cs{constructor(t,n,r){D(this,"element");D(this,"before");D(this,"after");this.element=t,this.before=n||null,this.after=r||null}withBefore(t){return new Cs(this.element,t,this.after)}withAfter(t){return new Cs(this.element,this.before,t)}withElement(t){return this.element===t?this:new Cs(t,this.before,this.after)}insertChild(t){const n=this.before||this.getManagedLineBreak();return n!==null&&n.parentElement!==this.element&&U(222),this.element.insertBefore(t,n),this}removeChild(t){return t.parentElement!==this.element&&U(223),this.element.removeChild(t),this}replaceChild(t,n){return n.parentElement!==this.element&&U(224),this.element.replaceChild(t,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(t===null)this.removeManagedLineBreak();else{const n=t==="decorator"&&(ta||Vi||ea);this.insertManagedLineBreak(n)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const n=this.element,r=t.nodeName==="IMG"?t.nextSibling:null;r&&n.removeChild(r),n.removeChild(t),n.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const n=this.getManagedLineBreak();if(n){if(t===(n.nodeName==="IMG"))return;this.removeManagedLineBreak()}const r=this.element,o=this.before,i=document.createElement("br");if(r.insertBefore(i,o),t){const s=document.createElement("img");s.setAttribute("data-lexical-linebreak","true"),s.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",s.alt="",r.insertBefore(s,i),r.__lexicalLineBreak=s}else r.__lexicalLineBreak=i}getFirstChildOffset(){let t=0;for(let n=this.after;n!==null;n=n.previousSibling)t++;return t}resolveChildIndex(t,n,r,o){if(r===this.element){const l=this.getFirstChildOffset();return[t,Math.min(l+t.getChildrenSize(),Math.max(l,o))]}const i=eg(n,r);i.push(o);const s=eg(n,this.element);let a=t.getIndexWithinParent();for(let l=0;l<s.length;l++){const c=i[l],u=s[l];if(c===void 0||c<u)break;if(c>u){a+=1;break}}return[t.getParentOrThrow(),a]}}function eg(e,t){const n=[];let r=t;for(;r!==e&&r!==null;r=r.parentNode){let o=0;for(let i=r.previousSibling;i!==null;i=i.previousSibling)o++;n.push(o)}return r!==e&&U(225),n.reverse()}class Mn extends ln{constructor(n){super(n);D(this,"__first");D(this,"__last");D(this,"__size");D(this,"__format");D(this,"__style");D(this,"__indent");D(this,"__dir");D(this,"__textFormat");D(this,"__textStyle");this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(n){super.afterCloneFrom(n),this.__key===n.__key&&(this.__first=n.__first,this.__last=n.__last,this.__size=n.__size),this.__indent=n.__indent,this.__format=n.__format,this.__style=n.__style,this.__dir=n.__dir,this.__textFormat=n.__textFormat,this.__textStyle=n.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const n=this.getFormat();return t3[n]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const n=[];let r=this.getFirstChild();for(;r!==null;)n.push(r),r=r.getNextSibling();return n}getChildrenKeys(){const n=[];let r=this.getFirstChild();for(;r!==null;)n.push(r.__key),r=r.getNextSibling();return n}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const n=Re()._dirtyElements;return n!==null&&n.has(this.__key)}isLastChild(){const n=this.getLatest(),r=this.getParentOrThrow().getLastChild();return r!==null&&r.is(n)}getAllTextNodes(){const n=[];let r=this.getFirstChild();for(;r!==null;){if(X(r)&&n.push(r),R(r)){const o=r.getAllTextNodes();n.push(...o)}r=r.getNextSibling()}return n}getFirstDescendant(){let n=this.getFirstChild();for(;R(n);){const r=n.getFirstChild();if(r===null)break;n=r}return n}getLastDescendant(){let n=this.getLastChild();for(;R(n);){const r=n.getLastChild();if(r===null)break;n=r}return n}getDescendantByIndex(n){const r=this.getChildren(),o=r.length;if(n>=o){const s=r[o-1];return R(s)&&s.getLastDescendant()||s||null}const i=r[n];return R(i)&&i.getFirstDescendant()||i||null}getFirstChild(){const n=this.getLatest().__first;return n===null?null:Xe(n)}getFirstChildOrThrow(){const n=this.getFirstChild();return n===null&&U(45,this.__key),n}getLastChild(){const n=this.getLatest().__last;return n===null?null:Xe(n)}getLastChildOrThrow(){const n=this.getLastChild();return n===null&&U(96,this.__key),n}getChildAtIndex(n){const r=this.getChildrenSize();let o,i;if(n<r/2){for(o=this.getFirstChild(),i=0;o!==null&&i<=n;){if(i===n)return o;o=o.getNextSibling(),i++}return null}for(o=this.getLastChild(),i=r-1;o!==null&&i>=n;){if(i===n)return o;o=o.getPreviousSibling(),i--}return null}getTextContent(){let n="";const r=this.getChildren(),o=r.length;for(let i=0;i<o;i++){const s=r[i];n+=s.getTextContent(),R(s)&&i!==o-1&&!s.isInline()&&(n+=Dr)}return n}getTextContentSize(){let n=0;const r=this.getChildren(),o=r.length;for(let i=0;i<o;i++){const s=r[i];n+=s.getTextContentSize(),R(s)&&i!==o-1&&!s.isInline()&&(n+=2)}return n}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(n){if(n!==""){const r=wm[n];return(this.getFormat()&r)!==0}return!1}hasTextFormat(n){const r=Po[n];return(this.getTextFormat()&r)!==0}getFormatFlags(n,r){return yl(this.getLatest().__textFormat,n,r)}getTextStyle(){return this.getLatest().__textStyle}select(n,r){vt();const o=Z();let i=n,s=r;const a=this.getChildrenSize();if(!this.canBeEmpty()){if(n===0&&r===0){const c=this.getFirstChild();if(X(c)||R(c))return c.select(0,0)}else if(!(n!==void 0&&n!==a||r!==void 0&&r!==a)){const c=this.getLastChild();if(X(c)||R(c))return c.select()}}i===void 0&&(i=a),s===void 0&&(s=a);const l=this.__key;return $(o)?(o.anchor.set(l,i,"element"),o.focus.set(l,s,"element"),o.dirty=!0,o):ex(l,i,l,s,"element","element")}selectStart(){const n=this.getFirstDescendant();return n?n.selectStart():this.select()}selectEnd(){const n=this.getLastDescendant();return n?n.selectEnd():this.select()}clear(){const n=this.getWritable();return this.getChildren().forEach(r=>r.remove()),n}append(...n){return this.splice(this.getChildrenSize(),0,n)}setDirection(n){const r=this.getWritable();return r.__dir=n,r}setFormat(n){return this.getWritable().__format=n!==""?wm[n]:0,this}setStyle(n){return this.getWritable().__style=n||"",this}setTextFormat(n){const r=this.getWritable();return r.__textFormat=n,r}setTextStyle(n){const r=this.getWritable();return r.__textStyle=n,r}setIndent(n){return this.getWritable().__indent=n,this}splice(n,r,o){pl(this)&&U(324,this.__key,this.__type);const i=this.getChildrenSize(),s=this.getWritable();n+r<=i||U(226,String(n),String(r),String(i));const a=s.__key,l=[],c=[],u=this.getChildAtIndex(n+r);let f=null,d=i-r+o.length;if(n!==0)if(n===i)f=this.getLastChild();else{const p=this.getChildAtIndex(n);p!==null&&(f=p.getPreviousSibling())}if(r>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let g=0;g<r;g++){p===null&&U(100);const m=p.getNextSibling(),y=p.__key;Ao(p.getWritable()),c.push(y),p=m}}let h=f;for(const p of o){h!==null&&p.is(h)&&(f=h=h.getPreviousSibling());const g=p.getWritable();g.__parent===a&&d--,Ao(g);const m=p.__key;if(h===null)s.__first=m,g.__prev=null;else{const y=h.getWritable();y.__next=m,g.__prev=y.__key}p.__key===a&&U(76),g.__parent=a,l.push(m),h=p}if(n+r===i)h!==null&&(h.getWritable().__next=null,s.__last=h.__key);else if(u!==null){const p=u.getWritable();if(h!==null){const g=h.getWritable();p.__prev=h.__key,g.__next=u.__key}else p.__prev=null}if(s.__size=d,c.length){const p=Z();if($(p)){const g=new Set(c),m=new Set(l),{anchor:y,focus:v}=p;tg(y,g,m)&&gl(y,y.getNode(),this,f,u),tg(v,g,m)&&gl(v,v.getNode(),this,f,u),d!==0||this.canBeEmpty()||jt(this)||this.remove()}}return s}getDOMSlot(n){return new Cs(n)}exportDOM(n){const{element:r}=super.exportDOM(n);if(pt(r)){const o=this.getIndent();o>0&&(r.style.paddingInlineStart=40*o+"px");const i=this.getDirection();i&&(r.dir=i)}return{element:r}}exportJSON(){const n={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},r=this.getTextFormat(),o=this.getTextStyle();return r===0&&o===""||jt(this)||this.getChildren().some(X)||(r!==0&&(n.textFormat=r),o!==""&&(n.textStyle=o)),n}updateFromJSON(n){return super.updateFromJSON(n).setFormat(n.format).setIndent(n.indent).setDirection(n.direction).setTextFormat(n.textFormat||0).setTextStyle(n.textStyle||"")}insertNewAfter(n,r){return null}canIndent(){return!0}collapseAtStart(n){return!1}excludeFromCopy(n){return!1}canReplaceWith(n){return!0}canInsertAfter(n){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(n){return!1}extractWithChild(n,r,o){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(n,r){const o=this.getDOMSlot(n);let i=o.getFirstChild();for(let s=this.getFirstChild();s;s=s.getNextSibling()){const a=r.getElementByKey(s.getKey());a!==null&&(i==null?(o.insertChild(a),i=a):i!==a&&o.replaceChild(a,i),i=i.nextSibling)}}}function R(e){return e instanceof Mn}function tg(e,t,n){let r=e.getNode();for(;r;){const o=r.__key;if(t.has(o)&&!n.has(o))return!0;r=r.getParent()}return!1}class lx extends ln{decorate(t,n){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Te(e){return e instanceof lx}class Zi extends Mn{constructor(){super("root");D(this,"__cachedText");this.__cachedText=null}static getType(){return"root"}static clone(){return new Zi}getTopLevelElementOrThrow(){U(51)}getTextContent(){const n=this.__cachedText;return!ra()&&Re()._dirtyType!==0||n===null?super.getTextContent():n}remove(){U(52)}replace(n){U(53)}insertBefore(n){U(54)}insertAfter(n){U(55)}updateDOM(n,r){return!1}splice(n,r,o){for(const i of o)R(i)||Te(i)||U(282);return super.splice(n,r,o)}static importJSON(n){return We().updateFromJSON(n)}collapseAtStart(){return!0}}function Ye(e){return e instanceof Zi}function cx(e){return new oa(new Map(e._nodeMap))}function $d(){return new oa(new Map([["root",new Zi]]))}function ux(e){const t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&U(130,n.name),R(e)){const r=t.children;Array.isArray(r)||U(59,n.name);const o=e.getChildren();for(let i=0;i<o.length;i++){const s=ux(o[i]);r.push(s)}}return t}function G3(e){return e instanceof oa}class oa{constructor(t,n){D(this,"_nodeMap");D(this,"_selection");D(this,"_flushSync");D(this,"_readOnly");this._nodeMap=t,this._selection=n||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(t,n){return Jm(n&&n.editor||null,this,t)}clone(t){const n=new oa(this._nodeMap,t===void 0?this._selection:t);return n._readOnly=!0,n}toJSON(){return Jm(null,this,()=>({root:ux(We())}))}}class Ud extends Mn{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class Ji extends Mn{static getType(){return"paragraph"}static clone(t){return new Ji(t.__key)}createDOM(t){const n=document.createElement("p"),r=vi(t.theme,"paragraph");return r!==void 0&&n.classList.add(...r),n}updateDOM(t,n,r){return!1}static importDOM(){return{p:t=>({conversion:Z3,priority:0})}}exportDOM(t){const{element:n}=super.exportDOM(t);if(pt(n)){this.isEmpty()&&n.append(document.createElement("br"));const r=this.getFormatType();r&&(n.style.textAlign=r)}return{element:n}}static importJSON(t){return Tt().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(t.textFormat===void 0||t.textStyle===void 0){const n=this.getChildren().find(X);n?(t.textFormat=n.getFormat(),t.textStyle=n.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,n){const r=Tt();r.setTextFormat(t.format),r.setTextStyle(t.style);const o=this.getDirection();return r.setDirection(o),r.setFormat(this.getFormatType()),r.setStyle(this.getStyle()),this.insertAfter(r,n),r}collapseAtStart(){const t=this.getChildren();if(t.length===0||X(t[0])&&t[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 Z3(e){const t=Tt();return e.style&&(t.setFormat(e.style.textAlign),d6(e,t)),{node:t}}function Tt(){return Kr(new Ji)}function Bd(e){return e instanceof Ji}const we=0,Gn=1,J3=3,fx=4;function dx(e,t,n,r){const o=e._keyToDOMMap;o.clear(),e._editorState=$d(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;const i=e._observer;i!==null&&(i.disconnect(),e._observer=null),t!==null&&(t.textContent=""),n!==null&&(n.textContent="",o.set("root",n))}function X3(e){const t=new Set,n=new Set;let r=e;for(;r;){const{ownNodeConfig:o}=rc(r),i=r.transform;if(!n.has(i)){n.add(i);const s=r.transform();s&&t.add(s)}if(o){const s=o.$transform;s&&t.add(s),r=o.extends}else{const s=Object.getPrototypeOf(r);r=s.prototype instanceof ln&&s!==ln?s:void 0}}return t}function hx(e){const t=e||{},n=Y3(),r=t.theme||{},o=e===void 0?n:t.parentEditor||null,i=t.disableEvents||!1,s=$d(),a=t.namespace||(o!==null?o._config.namespace:Cx()),l=t.editorState,c=[Zi,Br,Yi,Qi,Ji,Ud,...t.nodes||[]],{onError:u,html:f}=t,d=t.editable===void 0||t.editable;let h;if(e===void 0&&n!==null)h=n._nodes;else{h=new Map;for(let g=0;g<c.length;g++){let m=c[g],y=null,v=null;if(typeof m!="function"){const w=m;m=w.replace,y=w.with,v=w.withKlass||null}rc(m);const b=m.getType(),A=X3(m);h.set(b,{exportDOM:f&&f.export?f.export.get(m):void 0,klass:m,replace:y,replaceWithKlass:v,sharedNodeState:l3(c[g]),transforms:A})}}const p=new Ro(s,o,h,{disableEvents:i,namespace:a,theme:r},u||console.error,(function(g,m){const y=new Map,v=new Set,b=A=>{Object.keys(A).forEach(w=>{let _=y.get(w);_===void 0&&(_=[],y.set(w,_)),_.push(A[w])})};return g.forEach(A=>{const w=A.klass.importDOM;if(w==null||v.has(w))return;v.add(w);const _=w.call(A.klass);_!==null&&b(_)}),m&&b(m),y})(h,f?f.import:void 0),d,e);return l!==void 0&&(p._pendingEditorState=l,p._dirtyType=2),(function(g){g.registerCommand(_b,S3,we),g.registerCommand(Eb,k3,we),g.registerCommand(Sb,T3,we),g.registerCommand(kb,N3,we),g.registerCommand(Tb,O3,we)})(p),p}class Ro{constructor(t,n,r,o,i,s,a,l){D(this,"_headless");D(this,"_parentEditor");D(this,"_rootElement");D(this,"_editorState");D(this,"_pendingEditorState");D(this,"_compositionKey");D(this,"_deferred");D(this,"_keyToDOMMap");D(this,"_updates");D(this,"_updating");D(this,"_listeners");D(this,"_commands");D(this,"_nodes");D(this,"_decorators");D(this,"_pendingDecorators");D(this,"_config");D(this,"_dirtyType");D(this,"_cloneNotNeeded");D(this,"_dirtyLeaves");D(this,"_dirtyElements");D(this,"_normalizedNodes");D(this,"_updateTags");D(this,"_observer");D(this,"_key");D(this,"_onError");D(this,"_htmlConversions");D(this,"_window");D(this,"_editable");D(this,"_blockCursorElement");D(this,"_createEditorArgs");this._createEditorArgs=l,this._parentEditor=n,this._rootElement=null,this._editorState=t,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=o,this._nodes=r,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,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=Cx(),this._onError=i,this._htmlConversions=s,this._editable=a,this._headless=n!==null&&n._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(t){const n=this._listeners.update;return n.add(t),()=>{n.delete(t)}}registerEditableListener(t){const n=this._listeners.editable;return n.add(t),()=>{n.delete(t)}}registerDecoratorListener(t){const n=this._listeners.decorator;return n.add(t),()=>{n.delete(t)}}registerTextContentListener(t){const n=this._listeners.textcontent;return n.add(t),()=>{n.delete(t)}}registerRootListener(t){const n=this._listeners.root;return t(this._rootElement,null),n.add(t),()=>{t(null,this._rootElement),n.delete(t)}}registerCommand(t,n,r){r===void 0&&U(35);const o=this._commands;o.has(t)||o.set(t,[new Set,new Set,new Set,new Set,new Set]);const i=o.get(t);i===void 0&&U(36,String(t));const s=i[r];return s.add(n),()=>{s.delete(n),i.every(a=>a.size===0)&&o.delete(t)}}registerMutationListener(t,n,r){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;let s=i.get(n);s===void 0&&(s=new Set,i.set(n,s)),s.add(o);const a=r&&r.skipInitialization;return a!==void 0&&a||this.initializeMutationListener(n,o),()=>{s.delete(o),s.size===0&&i.delete(n)}}getRegisteredNode(t){const n=this._nodes.get(t.getType());return n===void 0&&U(37,t.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,n){const r=this._editorState,o=cg(r).get(n.getType());if(!o)return;const i=new Map;for(const s of o.keys())i.set(s,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:r,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,n){const r=this.getRegisteredNode(t);return r.transforms.add(n),r}registerNodeTransform(t,n){const r=this.registerNodeTransformToKlass(t,n),o=[r],i=r.replaceWithKlass;if(i!=null){const s=this.registerNodeTransformToKlass(i,n);o.push(s)}return(function(s,a){const l=cg(s.getEditorState()),c=[];for(const u of a){const f=l.get(u);f&&c.push(f)}c.length!==0&&s.update(()=>{for(const u of c)for(const f of u.keys()){const d=Xe(f);d&&d.markDirty()}},s._pendingEditorState===null?{tag:bo}:void 0)})(this,o.map(s=>s.klass.getType())),()=>{o.forEach(s=>s.transforms.delete(n))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,n){return ie(this,t,n)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const n=this._rootElement;if(t!==n){const r=vi(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,dx(this,n,t,o),n!==null&&(this._config.disableEvents||P3(n),r!=null&&n.classList.remove(...r)),t!==null){const i=Zd(t),s=t.style;s.userSelect="text",s.whiteSpace="pre-wrap",s.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=2,yb(this),this._updateTags.add(bo),Qn(this),this._config.disableEvents||(function(a,l){const c=a.ownerDocument;Cf.set(a,c);const u=dl.get(c)??0;u<1&&c.addEventListener("selectionchange",Vb),dl.set(c,u+1),a.__lexicalEditor=l;const f=qb(a);for(let d=0;d<Af.length;d++){const[h,p]=Af[d],g=typeof p=="function"?m=>{Dm(m)||(Rm(m),(l.isEditable()||h==="click")&&p(m,l))}:m=>{if(Dm(m))return;Rm(m);const y=l.isEditable();switch(h){case"cut":return y&&ie(l,Dd,m);case"copy":return ie(l,Zl,m);case"paste":return y&&ie(l,Gl,m);case"dragstart":return y&&ie(l,jb,m);case"dragover":return y&&ie(l,zb,m);case"dragend":return y&&ie(l,x3,m);case"focus":return y&&ie(l,C3,m);case"blur":return y&&ie(l,_3,m);case"drop":return y&&ie(l,Fb,m)}};a.addEventListener(h,g),f.push(()=>{a.removeEventListener(h,g)})}})(t,this),r!=null&&t.classList.add(...r)}else this._window=null,this._updateTags.add(bo),Qn(this);As("root",this,!1,t,n)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(t,n){t.isEmpty()&&U(38);let r=t;r._readOnly&&(r=cx(t),r._selection=t._selection?t._selection.clone():null),gb(this);const o=this._pendingEditorState,i=this._updateTags,s=n!==void 0?n.tag:null;o===null||o.isEmpty()||(s!=null&&i.add(s),Qn(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,s!=null&&i.add(s),this._updating||Qn(this)}parseEditorState(t,n){return(function(r,o,i){const s=$d(),a=it,l=Ft,c=st,u=o._dirtyElements,f=o._dirtyLeaves,d=o._cloneNotNeeded,h=o._dirtyType;o._dirtyElements=new Map,o._dirtyLeaves=new Set,o._cloneNotNeeded=new Set,o._dirtyType=0,it=s,Ft=!1,st=o,Wd(null);try{const p=o._nodes;zd(r.root,p),i&&i(),s._readOnly=!0}catch(p){p instanceof Error&&o._onError(p)}finally{o._dirtyElements=u,o._dirtyLeaves=f,o._cloneNotNeeded=d,o._dirtyType=h,it=a,Ft=l,st=c}return s})(typeof t=="string"?JSON.parse(t):t,this,n)}read(t){return Qn(this),this.getEditorState().read(t,{editor:this})}update(t,n){(function(r,o,i){r._updating?r._updates.push([o,i]):Xl(r,o,i)})(this,t,n)}focus(t,n={}){const r=this._rootElement;r!==null&&(r.setAttribute("autocapitalize","off"),kn(this,()=>{const o=Z(),i=We();o!==null?o.dirty||Pt(o.clone()):i.getChildrenSize()!==0&&(n.defaultSelection==="rootStart"?i.selectStart():i.selectEnd()),i6("focus"),s6(()=>{r.removeAttribute("autocapitalize"),t&&t()})}),this._pendingEditorState===null&&r.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;t!==null&&t.blur();const n=en(this._window);n!==null&&n.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,As("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}D(Ro,"version");Ro.version="0.39.0+prod.esm";let Mf=null;function Wd(e){Mf=e}let e6=1;function px(e,t){const n=Kd(e,t);return n===void 0&&U(30,t),n}function Kd(e,t){return e._nodes.get(t)}const t6=typeof queueMicrotask=="function"?queueMicrotask:e=>{Promise.resolve().then(e)};function mx(e){return Te(Fi(e))}function Hd(e){const t=document.activeElement;if(!pt(t))return!1;const n=t.nodeName;return Te(Fi(e))&&(n==="INPUT"||n==="TEXTAREA"||t.contentEditable==="true"&&ec(t)==null)}function ia(e,t,n){const r=e.getRootElement();try{return r!==null&&r.contains(t)&&r.contains(n)&&t!==null&&!Hd(t)&&gx(t)===e}catch{return!1}}function qd(e){return e instanceof Ro}function gx(e){let t=e;for(;t!=null;){const n=ec(t);if(qd(n))return n;t=sa(t)}return null}function ec(e){return e?e.__lexicalEditor:null}function wo(e){return Zb(e)||e.isToken()}function Wn(e){return wo(e)||e.isSegmented()}function cr(e){return Xi(e)&&e.nodeType===3}function yx(e){return Xi(e)&&e.nodeType===9}function Di(e){let t=e;for(;t!=null;){if(cr(t))return t;t=t.firstChild}return null}function yl(e,t,n){const r=Po[t];if(n!==null&&(e&r)===(n&r))return e;let o=e^r;return t==="subscript"?o&=-65:t==="superscript"?o&=-33:t==="lowercase"?(o&=-513,o&=-1025):t==="uppercase"?(o&=-257,o&=-1025):t==="capitalize"&&(o&=-257,o&=-513),o}function vx(e){return X(e)||xo(e)||Te(e)}function n6(e,t){const n=(function(){const s=Mf;return Mf=null,s})();if((t=t||n&&n.__key)!=null)return void(e.__key=t);vt(),ix();const r=Re(),o=Wr(),i=""+e6++;o._nodeMap.set(i,e),R(e)?r._dirtyElements.set(i,!0):r._dirtyLeaves.add(i),r._cloneNotNeeded.add(i),r._dirtyType=1,e.__key=i}function Ao(e){const t=e.getParent();if(t!==null){const n=e.getWritable(),r=t.getWritable(),o=e.getPreviousSibling(),i=e.getNextSibling(),s=i!==null?i.__key:null,a=o!==null?o.__key:null,l=o!==null?o.getWritable():null,c=i!==null?i.getWritable():null;o===null&&(r.__first=s),i===null&&(r.__last=a),l!==null&&(l.__next=s),c!==null&&(c.__prev=a),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function vl(e){ix(),pl(e)&&U(323,e.__key,e.__type);const t=e.getLatest(),n=t.__parent,r=Wr(),o=Re(),i=r._nodeMap,s=o._dirtyElements;n!==null&&(function(l,c,u){let f=l;for(;f!==null;){if(u.has(f))return;const d=c.get(f);if(d===void 0)break;u.set(f,!1),f=d.__parent}})(n,i,s);const a=t.__key;o._dirtyType=1,R(e)?s.set(a,!0):o._dirtyLeaves.add(a)}function ft(e){vt();const t=Re(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){const r=Xe(n);r!==null&&r.getWritable()}if(e!==null){const r=Xe(e);r!==null&&r.getWritable()}}}function Sr(){return ra()?null:Re()._compositionKey}function Xe(e,t){const n=(t||Wr())._nodeMap.get(e);return n===void 0?null:n}function bx(e,t){const n=tc(e,Re());return n!==void 0?Xe(n,t):null}function tc(e,t){return e[`__lexicalKey_${t._key}`]}function Fi(e,t){let n=e;for(;n!=null;){const r=bx(n,t);if(r!==null)return r;n=sa(n)}return null}function xx(e){const t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function ng(e){return e.read(()=>We().getTextContent())}function We(){return wx(Wr())}function wx(e){return e._nodeMap.get("root")}function Pt(e){vt();const t=Wr();e!==null&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function ci(e){const t=Re(),n=(function(r,o){let i=r;for(;i!=null;){const s=tc(i,o);if(s!==void 0)return s;i=sa(i)}return null})(e,t);return n===null?e===t.getRootElement()?Xe("root"):null:Xe(n)}function Ax(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function Vd(e){const t=[];let n=e;for(;n!==null;)t.push(n),n=n._parentEditor;return t}function Cx(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function _x(e){return cr(e)?e.nodeValue:null}function Yd(e,t,n){const r=en(Xt(t));if(r===null)return;const o=r.anchorNode;let{anchorOffset:i,focusOffset:s}=r;if(o!==null){let a=_x(o);const l=Fi(o);if(a!==null&&X(l)){if(a===Vl&&n){const c=n.length;a=n,i=c,s=c}a!==null&&Qd(l,a,i,s,e)}}}function Qd(e,t,n,r,o){let i=e;if(i.isAttached()&&(o||!i.isDirty())){const s=i.isComposing();let a=t;(s||o)&&t[t.length-1]===Vl&&(a=t.slice(0,-1));const l=i.getTextContent();if(o||a!==l){if(a===""){if(ft(null),ea||Vi||ta)i.remove();else{const g=Re();setTimeout(()=>{g.update(()=>{i.isAttached()&&i.remove()})},20)}return}const c=i.getParent(),u=Gi(),f=i.getTextContentSize(),d=Sr(),h=i.getKey();if(i.isToken()||d!==null&&h===d&&!s||$(u)&&(c!==null&&!c.canInsertTextBefore()&&u.anchor.offset===0||u.anchor.key===e.__key&&u.anchor.offset===0&&!i.canInsertTextBefore()&&!s||u.focus.key===e.__key&&u.focus.offset===f&&!i.canInsertTextAfter()&&!s))return void i.markDirty();const p=Z();if(!$(p)||n===null||r===null)return void rg(i,a,p);if(p.setTextNodeRange(i,n,i,r),i.isSegmented()){const g=rt(i.getTextContent());i.replace(g),i=g}rg(i,a,p)}}}function rg(e,t,n){if(e.setTextContent(t),$(n)){const r=e.getKey();for(const o of["anchor","focus"]){const i=n[o];i.type==="text"&&i.key===r&&(i.offset=Pr(e,i.offset,"clamp"))}}}function ka(e,t,n){const r=t[n]||!1;return r==="any"||r===e[n]}function r6(e,t){return ka(e,t,"altKey")&&ka(e,t,"ctrlKey")&&ka(e,t,"shiftKey")&&ka(e,t,"metaKey")}function Ie(e,t,n){return r6(e,n)&&e.key.toLowerCase()===t.toLowerCase()}const Un={ctrlKey:!sn,metaKey:sn},og={altKey:sn,ctrlKey:!sn};function ig(e){return e.key==="Backspace"}function sg(e){return Ie(e,"a",Un)}function o6(e){const t=We();if($(e)){const n=e.anchor,r=e.focus,o=n.getNode().getTopLevelElementOrThrow().getParentOrThrow();return n.set(o.getKey(),0,"element"),r.set(o.getKey(),o.getChildrenSize(),"element"),Ri(e),e}{const n=t.select(0,t.getChildrenSize());return Pt(Ri(n)),n}}function vi(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});const n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;const o=e[t];if(typeof o=="string"){const i=db(o);return n[t]=i,i}return o}function Gd(e,t,n,r,o){if(n.size===0)return;const i=r.__type,s=r.__key,a=t.get(i);a===void 0&&U(33,i);const l=a.klass;let c=e.get(l);c===void 0&&(c=new Map,e.set(l,c));const u=c.get(s),f=u==="destroyed"&&o==="created";(u===void 0||f)&&c.set(s,f?"updated":o)}function ag(e,t,n){const r=e.getParent();let o=n,i=e;return r!==null&&(t&&n===0?(o=i.getIndexWithinParent(),i=r):t||n!==i.getChildrenSize()||(o=i.getIndexWithinParent()+1,i=r)),i.getChildAtIndex(t?o-1:o)}function If(e,t){const n=e.offset;if(e.type==="element")return ag(e.getNode(),t,n);{const r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){const o=t?r.getPreviousSibling():r.getNextSibling();return o===null?ag(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):o}}return null}function Ex(e){const t=Xt(e).event,n=t&&t.inputType;return n==="insertFromPaste"||n==="insertFromPasteAsQuotation"}function ie(e,t,n){return(function(r,o,i){const s=Vd(r);for(let a=4;a>=0;a--)for(let l=0;l<s.length;l++){const c=s[l],u=c._commands.get(o);if(u!==void 0){const f=u[a];if(f!==void 0){const d=Array.from(f),h=d.length;let p=!1;if(kn(c,()=>{for(let g=0;g<h;g++)if(d[g](i,r))return void(p=!0)}),p)return p}}}return!1})(e,t,n)}function nc(e){return!Ye(e)&&!e.isLastChild()&&!e.isInline()}function Do(e,t){const n=e._keyToDOMMap.get(t);return n===void 0&&U(75,t),n}function sa(e){const t=e.assignedSlot||e.parentElement;return Df(t)?t.host:t}function Sx(e){return yx(e)?e:pt(e)?e.ownerDocument:null}function i6(e){vt(),Re()._updateTags.add(e)}function s6(e){vt(),Re()._deferred.push(e)}function Lf(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function Zd(e){const t=Sx(e);return t?t.defaultView:null}function Xt(e){const t=e._window;return t===null&&U(78),t}function a6(e){let t=e.getParentOrThrow();for(;t!==null;){if(jt(t))return t;t=t.getParentOrThrow()}return t}function jt(e){return Ye(e)||R(e)&&e.isShadowRoot()}function Kr(e){const t=Re(),n=e.getType(),r=Kd(t,n);r===void 0&&U(200,e.constructor.name,n);const{replace:o,replaceWithKlass:i}=r;if(o!==null){const s=o(e),a=s.constructor;return i!==null?s instanceof i||U(201,i.name,i.getType(),a.name,a.getType(),e.constructor.name,n):s instanceof e.constructor&&a!==e.constructor||U(202,a.name,a.getType(),e.constructor.name,n),s.__key===e.__key&&U(203,e.constructor.name,n,a.name,a.getType()),s}return e}function Xc(e,t){!Ye(e.getParent())||R(t)||Te(t)||U(99)}function l6(e){const t=Xe(e);return t===null&&U(63,e),t}function eu(e){return(Te(e)||R(e)&&!e.canBeEmpty())&&!e.isInline()}function Rf(e,t,n){n.style.removeProperty("caret-color"),t._blockCursorElement=null;const r=e.parentElement;r!==null&&r.removeChild(e)}function en(e){return dn?(e||window).getSelection():null}function c6(e){const t=Zd(e);return t?t.getSelection():null}function kx(e){return pt(e)&&e.tagName==="A"}function pt(e){return Xi(e)&&e.nodeType===1}function Xi(e){return typeof e=="object"&&e!==null&&"nodeType"in e&&typeof e.nodeType=="number"}function Df(e){return Xi(e)&&e.nodeType===11}function Ff(e){const t=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return e.nodeName.match(t)!==null}function bl(e){const t=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return e.nodeName.match(t)!==null}function yr(e){if(Te(e)&&!e.isInline())return!0;if(!R(e)||jt(e))return!1;const t=e.getFirstChild(),n=t===null||xo(t)||X(t)||t.isInline();return!e.isInline()&&e.canBeEmpty()!==!1&&n}function Jd(){return Re()}const lg=new WeakMap,u6=new Map;function cg(e){if(!e._readOnly&&e.isEmpty())return u6;e._readOnly||U(192);let t=lg.get(e);return t||(t=(function(n){const r=new Map;for(const[o,i]of n._nodeMap){const s=i.__type;let a=r.get(s);a||(a=new Map,r.set(s,a)),a.set(o,i)}return r})(e),lg.set(e,t)),t}function Tx(e){const t=e.constructor.clone(e);return t.afterCloneFrom(e),t}function f6(e){return(t=Tx(e))[Yb]=!0,t;var t}function d6(e,t){const n=parseInt(e.style.paddingInlineStart,10)||0,r=Math.round(n/40);t.setIndent(r)}function h6(e){return e.__lexicalUnmanaged===!0}function fs(e,t){return(function(n,r){return Object.prototype.hasOwnProperty.call(n,r)})(e,t)&&e[t]!==ln[t]}function rc(e){const t=Am in e.prototype?e.prototype[Am]():void 0,n=(function(s){if(!(s===ln||s.prototype instanceof ln)){let a="<unknown>",l="<unknown>";try{a=s.getType()}catch{}try{Ro.version&&(l=JSON.parse(Ro.version))}catch{}U(290,s.name,a,l)}return s===lx||s===Mn||s===ln})(e),r=!n&&fs(e,"getType")?e.getType():void 0;let o,i=r;if(t)if(r)o=t[r];else for(const[s,a]of Object.entries(t))i=s,o=a;if(!n&&i&&(fs(e,"getType")||(e.getType=()=>i),fs(e,"clone")||(e.clone=s=>(Wd(s),new e)),fs(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(s=>new e().updateFromJSON(s))),!fs(e,"importDOM")&&o)){const{importDOM:s}=o;s&&(e.importDOM=()=>s)}return{ownNodeConfig:o,ownNodeType:i}}const at=(e,t)=>{let n=e;for(;n!=null&&!Ye(n);){if(t(n))return n;n=n.getParent()}return null},p6={next:"previous",previous:"next"};class Xd{constructor(t){D(this,"origin");this.origin=t}[Symbol.iterator](){return Nx({hasNext:ji,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return xt(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return xt(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,n){const r=this.getNodeAtCaret();return t.is(this.origin)||t.is(r)||(r===null?this.insert(t):r.replace(t,n)),this}splice(t,n,r="next"){const o=r===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),a=new Map;for(let l=i.getAdjacentCaret();l!==null&&a.size<t;l=l.getAdjacentCaret()){const c=l.origin.getWritable();a.set(c.getKey(),c)}for(const l of o){if(a.size>0){const c=i.getNodeAtCaret();if(c){if(a.delete(c.getKey()),a.delete(l.getKey()),!(c.is(l)||i.origin.is(l))){const u=l.getParent();u&&u.is(s)&&l.remove(),c.replace(l)}}else c===null&&U(263,Array.from(a).join(" "))}else i.insert(l);i=xt(l,this.direction)}for(const l of a.values())l.remove();return this}}class zs extends Xd{constructor(){super(...arguments);D(this,"type","child")}getLatest(){const n=this.origin.getLatest();return n===this.origin?this:un(n,this.direction)}getParentCaret(n="root"){return xt(eh(this.getParentAtCaret(),n),this.direction)}getFlipped(){const n=es(this.direction);return xt(this.getNodeAtCaret(),n)||un(this.origin,n)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(n){return n instanceof zs&&this.direction===n.direction&&this.origin.is(n.origin)}isSamePointCaret(n){return this.isSameNodeCaret(n)}}const m6={root:Ye,shadowRoot:jt};function es(e){return p6[e]}function eh(e,t="root"){return m6[t](e)?null:e}class Fo extends Xd{constructor(){super(...arguments);D(this,"type","sibling")}getLatest(){const n=this.origin.getLatest();return n===this.origin?this:xt(n,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return R(this.origin)?un(this.origin,this.direction):null}getParentCaret(n="root"){return xt(eh(this.getParentAtCaret(),n),this.direction)}getFlipped(){const n=es(this.direction);return xt(this.getNodeAtCaret(),n)||un(this.origin.getParentOrThrow(),n)}isSamePointCaret(n){return n instanceof Fo&&this.direction===n.direction&&this.origin.is(n.origin)}isSameNodeCaret(n){return(n instanceof Fo||n instanceof jo)&&this.direction===n.direction&&this.origin.is(n.origin)}}class jo extends Xd{constructor(n,r){super(n);D(this,"type","text");D(this,"offset");this.offset=r}getLatest(){const n=this.origin.getLatest();return n===this.origin?this:zo(n,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(n="root"){return xt(eh(this.getParentAtCaret(),n),this.direction)}getFlipped(){return zo(this.origin,es(this.direction),this.offset)}isSamePointCaret(n){return n instanceof jo&&this.direction===n.direction&&this.origin.is(n.origin)&&this.offset===n.offset}isSameNodeCaret(n){return(n instanceof Fo||n instanceof jo)&&this.direction===n.direction&&this.origin.is(n.origin)}getSiblingCaret(){return xt(this.origin,this.direction)}}function Or(e){return e instanceof jo}function ji(e){return e instanceof Fo}function Tn(e){return e instanceof zs}const g6={next:class extends jo{constructor(){super(...arguments);D(this,"direction","next")}getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends jo{constructor(){super(...arguments);D(this,"direction","previous")}getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},y6={next:class extends Fo{constructor(){super(...arguments);D(this,"direction","next")}getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Fo{constructor(){super(...arguments);D(this,"direction","previous")}getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},v6={next:class extends zs{constructor(){super(...arguments);D(this,"direction","next")}getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends zs{constructor(){super(...arguments);D(this,"direction","previous")}getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function xt(e,t){return e?new y6[t](e):null}function zo(e,t,n){return e?new g6[t](e,Pr(e,n)):null}function Pr(e,t,n="error"){const r=e.getTextContentSize();let o=t==="next"?r:t==="previous"?0:t;return(o<0||o>r)&&(n!=="clamp"&&ub(284,String(t),String(r),e.getKey()),o=o<0?0:r),o}function ug(e,t){return new x6(e,t)}function un(e,t){return R(e)?new v6[t](e):null}function b6(e){return e&&e.getChildCaret()||e}function th(e){return e&&b6(e.getAdjacentCaret())}class nh{constructor(t,n,r){D(this,"type","node-caret-range");D(this,"direction");D(this,"anchor");D(this,"focus");this.anchor=t,this.focus=n,this.direction=r}getLatest(){const t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new nh(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=o=>{const i=this[o].getLatest();return Or(i)?(function(s,a){const{direction:l,origin:c}=s,u=Pr(c,a==="focus"?es(l):l);return ug(s,u-s.offset)})(i,o):null},n=t("anchor"),r=t("focus");if(n&&r){const{caret:o}=n,{caret:i}=r;if(o.isSameNodeCaret(i))return[ug(o,i.offset-o.offset),null]}return[n,r]}iterNodeCarets(t="root"){const n=Or(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),r=this.focus.getLatest(),o=Or(r),i=s=>s.isSameNodeCaret(r)?null:th(s)||s.getParentCaret(t);return Nx({hasNext:s=>s!==null&&!(o&&r.isSameNodeCaret(s)),initial:n.isSameNodeCaret(r)?null:i(n),map:s=>s,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class x6{constructor(t,n){D(this,"type","slice");D(this,"caret");D(this,"distance");this.caret=t,this.distance=n}getSliceIndices(){const{distance:t,caret:{offset:n}}=this,r=n+t;return r<n?[r,n]:[n,r]}getTextContent(){const[t,n]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,n)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:n}}=this,[r,o]=this.getSliceIndices(),i=t.getTextContent();return zo(t.setTextContent(i.slice(0,r)+i.slice(o)),n,r)}}function rh(e){return Fr(e,xt(We(),e.direction))}function w6(e){return Fr(e,e)}function Fr(e,t){return e.direction!==t.direction&&U(265),new nh(e,t,e.direction)}function Nx(e){const{initial:t,hasNext:n,step:r,map:o}=e;let i=t;return{[Symbol.iterator](){return this},next(){if(!n(i))return{done:!0,value:void 0};const s={done:!1,value:o(i)};return i=r(i),s}}}function Ox(e,t){const n=Ha(e.origin,t.origin);switch(n===null&&U(275,e.origin.getKey(),t.origin.getKey()),n.type){case"same":{const r=e.type==="text",o=t.type==="text";return r&&o?(function(i,s){return Math.sign(i-s)})(e.offset,t.offset):e.type===t.type?0:r?-1:o?1:e.type==="child"?-1:1}case"ancestor":return e.type==="child"?-1:1;case"descendant":return t.type==="child"?1:-1;case"branch":return Px(n)}}function Px(e){const{a:t,b:n}=e,r=t.__key,o=n.__key;let i=t,s=n;for(;i&&s;i=i.getNextSibling(),s=s.getNextSibling()){if(i.__key===o)return-1;if(s.__key===r)return 1}return i===null?1:-1}function Ta(e,t){return t.is(e)}function fg(e){return R(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function Ha(e,t){if(e.is(t))return{commonAncestor:e,type:"same"};const n=new Map;for(let[r,o]=fg(e);r;o=r,r=r.getParent())n.set(r,o);for(let[r,o]=fg(t);r;o=r,r=r.getParent()){const i=n.get(r);if(i!==void 0)return i===null?(Ta(e,r)||U(276),{commonAncestor:r,type:"ancestor"}):o===null?(Ta(t,r)||U(277),{commonAncestor:r,type:"descendant"}):((R(i)||Ta(e,i))&&(R(o)||Ta(t,o))&&r.is(i.getParent())&&r.is(o.getParent())||U(278),{a:i,b:o,commonAncestor:r,type:"branch"})}return null}function nr(e,t){const{type:n,key:r,offset:o}=e,i=l6(e.key);return n==="text"?(X(i)||U(266,i.getType(),r),zo(i,t,o)):(R(i)||U(267,i.getType(),r),_6(i,e.offset,t))}function $o(e,t){const{origin:n,direction:r}=t,o=r==="next";Or(t)?e.set(n.getKey(),t.offset,"text"):ji(t)?X(n)?e.set(n.getKey(),Pr(n,r),"text"):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+(o?1:0),"element"):(Tn(t)&&R(n)||U(268),e.set(n.getKey(),o?0:n.getChildrenSize(),"element"))}function A6(e){const t=Z(),n=$(t)?t:tx();return qa(n,e),Pt(n),n}function qa(e,t){$o(e.anchor,t.anchor),$o(e.focus,t.focus)}function dg(e){const{anchor:t,focus:n}=e,r=nr(t,"next"),o=nr(n,"next"),i=Ox(r,o)<=0?"next":"previous";return Fr(zi(r,i),zi(o,i))}function oh(e){const{direction:t,origin:n}=e,r=xt(n,es(t)).getNodeAtCaret();return r?xt(r,t):un(n.getParentOrThrow(),t)}function hg(e,t="root"){const n=[e];for(let r=Tn(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(oh(r));return n}function tu(e){return!!e&&e.origin.isAttached()}function C6(e,t="removeEmptySlices"){if(e.isCollapsed())return e;const n="root",r="next";let o=t;const i=Ix(e,r),s=hg(i.anchor,n),a=hg(i.focus.getFlipped(),n),l=new Set,c=[];for(const p of i.iterNodeCarets(n))if(Tn(p))l.add(p.origin.getKey());else if(ji(p)){const{origin:g}=p;R(g)&&!l.has(g.getKey())||c.push(g)}for(const p of c)p.remove();for(const p of i.getTextSlices()){if(!p)continue;const{origin:g}=p.caret,m=g.getTextContentSize(),y=oh(xt(g,r)),v=g.getMode();if(Math.abs(p.distance)===m&&o==="removeEmptySlices"||v==="token"&&p.distance!==0)y.remove();else if(p.distance!==0){o="removeEmptySlices";let b=p.removeTextSlice();const A=p.caret.origin;if(v==="segmented"){const w=b.origin,_=rt(w.getTextContent()).setStyle(w.getStyle()).setFormat(w.getFormat());y.replaceOrInsert(_),b=zo(_,r,b.offset)}A.is(s[0].origin)&&(s[0]=b),A.is(a[0].origin)&&(a[0]=b.getFlipped())}}let u,f;for(const p of s)if(tu(p)){u=Yt(p);break}for(const p of a)if(tu(p)){f=Yt(p);break}const d=(function(p,g,m){if(!p||!g)return null;const y=p.getParentAtCaret(),v=g.getParentAtCaret();if(!y||!v)return null;const b=y.getParents().reverse();b.push(y);const A=v.getParents().reverse();A.push(v);const w=Math.min(b.length,A.length);let _;for(_=0;_<w&&b[_]===A[_];_++);const E=(P,I)=>{let W;for(let j=_;j<P.length;j++){const z=P[j];if(jt(z))return;!W&&I(z)&&(W=z)}return W},S=E(b,yr),O=S&&E(A,P=>m.has(P.getKey())&&yr(P));return S&&O?[S,O]:null})(u,f,l);if(d){const[p,g]=d;un(p,"previous").splice(0,g.getChildren()),g.remove()}const h=[u,f,...s,...a].find(tu);if(h)return w6(zi(Yt(h),e.direction));U(269,JSON.stringify(s.map(p=>p.origin.__key)))}function Yt(e){const t=(function(o){let i=o;for(;Tn(i);){const s=th(i);if(!Tn(s))break;i=s}return i})(e.getLatest()),{direction:n}=t;if(X(t.origin))return Or(t)?t:zo(t.origin,n,n);const r=t.getAdjacentCaret();return ji(r)&&X(r.origin)?zo(r.origin,n,es(n)):t}function Mx(e){return Or(e)&&e.offset!==Pr(e.origin,e.direction)}function zi(e,t){return e.direction===t?e:e.getFlipped()}function Ix(e,t){return e.direction===t?e:Fr(zi(e.focus,t),zi(e.anchor,t))}function _6(e,t,n){let r=un(e,"next");for(let o=0;o<t;o++){const i=r.getAdjacentCaret();if(i===null)break;r=i}return zi(r,n)}function E6(...e){return e}function S6(e,t){if(!t||e===t)return e;for(const n in t)if(e[n]!==t[n])return{...e,...t};return e}const Lx=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,k6=Lx?T.useLayoutEffect:T.useEffect,Na={tag:bo};function T6({initialConfig:e,children:t}){const n=T.useMemo(()=>{const{theme:r,namespace:o,nodes:i,onError:s,editorState:a,html:l}=e,c=UT(null,r),u=hx({editable:e.editable,html:l,namespace:o,nodes:i,onError:f=>s(f,u),theme:r});return(function(f,d){if(d!==null){if(d===void 0)f.update(()=>{const h=We();if(h.isEmpty()){const p=Tt();h.append(p);const g=Lx?document.activeElement:null;(Z()!==null||g!==null&&g===f.getRootElement())&&p.select()}},Na);else if(d!==null)switch(typeof d){case"string":{const h=f.parseEditorState(d);f.setEditorState(h,Na);break}case"object":f.setEditorState(d,Na);break;case"function":f.update(()=>{We().isEmpty()&&d(f)},Na)}}})(u,a),[u,c]},[]);return k6(()=>{const r=e.editable,[o]=n;o.setEditable(r===void 0||r)},[]),x.jsx(cb.Provider,{value:n,children:t})}const N6=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function O6(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function P6(){return(function(e){const[t]=ht(),n=T.useMemo(()=>e(t),[t,e]),[r,o]=T.useState(()=>n.initialValueFn()),i=T.useRef(r);return N6(()=>{const{initialValueFn:s,subscribe:a}=n,l=s();return i.current!==l&&(i.current=l,o(l)),a(c=>{i.current=c,o(c)})},[n,e]),r})(O6)}function M6(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const jf=new Map;function Rx(e){const t={};if(!e)return t;const n=e.split(";");for(const r of n)if(r!==""){const[o,i]=r.split(/:([^]+)/);o&&i&&(t[o.trim()]=i.trim())}return t}function pg(e){let t=jf.get(e);return t===void 0&&(t=Rx(e),jf.set(e,t)),t}function Dx(e){const t=Jd().getElementByKey(e.getKey());if(t===null)return null;const n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function Fx(e){return Dx(Ye(e)?e:e.getParentOrThrow())}function mg(e){const t=Fx(e);return t!==null&&t.direction==="rtl"}function jx(e,t,n="self"){const r=e.getStartEndPoints();if(t.isSelected(e)&&!Wn(t)&&r!==null){const[o,i]=r,s=e.isBackward(),a=o.getNode(),l=i.getNode(),c=t.is(a),u=t.is(l);if(c||u){const[f,d]=Of(e),h=a.is(l),p=t.is(s?l:a),g=t.is(s?a:l);let m,y=0;h?(y=f>d?d:f,m=f>d?f:d):p?(y=s?d:f,m=void 0):g&&(y=0,m=s?f:d);const v=t.__text.slice(y,m);v!==t.__text&&(n==="clone"&&(t=f6(t)),t.__text=v)}}return t}function gg(e){if(e.type==="text")return e.offset===e.getNode().getTextContentSize();const t=e.getNode();return R(t)||M6(177),e.offset===t.getChildrenSize()}function I6(e){const t=e.getStyle(),n=Rx(t);jf.set(t,n)}function zx(e){const t=$x(e);return t!==null&&t.writingMode==="vertical-rl"}function $x(e){const t=e.anchor.getNode();return R(t)?Dx(t):Fx(t)}function yg(e,t){let n=zx(e)?!t:t;Ux(e)&&(n=!n);const r=nr(e.focus,n?"previous":"next");if(Mx(r))return!1;for(const o of rh(r)){if(Tn(o))return!o.origin.isInline();if(!R(o.origin)){if(Te(o.origin))return!0;break}}return!1}function L6(e,t,n,r){e.modify(t?"extend":"move",n,r)}function Ux(e){const t=$x(e);return t!==null&&t.direction==="rtl"}function vg(e,t,n){const r=Ux(e);let o;o=zx(e)||r?!n:n,L6(e,t,o,"character")}function R6(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Bx=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,D6=Bx&&"documentMode"in document?document.documentMode:null;!(!Bx||!("InputEvent"in window)||D6)&&"getTargetRanges"in new window.InputEvent("input");function Wx(...e){const t=[];for(const n of e)if(n&&typeof n=="string")for(const[r]of n.matchAll(/\S+/g))t.push(r);return t}function fn(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function ih(e,...t){const n=Wx(...t);n.length>0&&e.classList.add(...n)}function Kx(e,...t){const n=Wx(...t);n.length>0&&e.classList.remove(...n)}function F6(e,t){let n=e;for(;n!=null;){if(n instanceof t)return n;n=n.getParent()}return null}function j6(e){const t=at(e,n=>R(n)&&!n.isInline());return R(t)||R6(4,e.__key),t}function kr(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}const z6=Symbol.for("preact-signals");function oc(){if(Mr>1)return void Mr--;let e,t=!1;for(;_s!==void 0;){let n=_s;for(_s=void 0,zf++;n!==void 0;){const r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Hx(n))try{n.c()}catch(o){t||(e=o,t=!0)}n=r}}if(zf=0,Mr--,t)throw e}function $6(e){if(Mr>0)return e();Mr++;try{return e()}finally{oc()}}let Pe,_s;function bg(e){const t=Pe;Pe=void 0;try{return e()}finally{Pe=t}}let Mr=0,zf=0,Va=0;function xg(e){if(Pe===void 0)return;let t=e.n;return t===void 0||t.t!==Pe?(t={i:0,S:e,p:Pe.s,n:void 0,t:Pe,e:void 0,x:void 0,r:t},Pe.s!==void 0&&(Pe.s.n=t),Pe.s=t,e.n=t,32&Pe.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Pe.s,t.n=void 0,Pe.s.n=t,Pe.s=t),t):void 0}function _t(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}function U6(e,t){return new _t(e,t)}function Hx(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function wg(e){for(let t=e.s;t!==void 0;t=t.n){const n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function qx(e){let t,n=e.s;for(;n!==void 0;){const r=n.p;n.i===-1?(n.S.U(n),r!==void 0&&(r.n=n.n),n.n!==void 0&&(n.n.p=r)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=r}e.s=t}function ti(e,t){_t.call(this,void 0),this.x=e,this.s=void 0,this.g=Va-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}function Vx(e){const t=e.u;if(e.u=void 0,typeof t=="function"){Mr++;const n=Pe;Pe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,sh(e),r}finally{Pe=n,oc()}}}function sh(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Vx(e)}function B6(e){if(Pe!==this)throw new Error("Out-of-order effect");qx(this),Pe=e,this.f&=-2,8&this.f&&sh(this),oc()}function ai(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=t==null?void 0:t.name}function $s(e,t){const n=new ai(e,t);try{n.c()}catch(o){throw n.d(),o}const r=n.d.bind(n);return r[Symbol.dispose]=r,r}function Yx(e,t={}){const n={};for(const r in e){const o=t[r],i=U6(o===void 0?e[r]:o);n[r]=i}return n}_t.prototype.brand=z6,_t.prototype.h=function(){return!0},_t.prototype.S=function(e){const t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t!==void 0?t.e=e:bg(()=>{var n;(n=this.W)==null||n.call(this)}))},_t.prototype.U=function(e){if(this.t!==void 0){const t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&bg(()=>{var r;(r=this.Z)==null||r.call(this)}))}},_t.prototype.subscribe=function(e){return $s(()=>{const t=this.value,n=Pe;Pe=void 0;try{e(t)}finally{Pe=n}},{name:"sub"})},_t.prototype.valueOf=function(){return this.value},_t.prototype.toString=function(){return this.value+""},_t.prototype.toJSON=function(){return this.value},_t.prototype.peek=function(){const e=Pe;Pe=void 0;try{return this.value}finally{Pe=e}},Object.defineProperty(_t.prototype,"value",{get(){const e=xg(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(zf>100)throw new Error("Cycle detected");this.v=e,this.i++,Va++,Mr++;try{for(let t=this.t;t!==void 0;t=t.x)t.t.N()}finally{oc()}}}}),ti.prototype=new _t,ti.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Va))return!0;if(this.g=Va,this.f|=1,this.i>0&&!Hx(this))return this.f&=-2,!0;const e=Pe;try{wg(this),Pe=this;const t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Pe=e,qx(this),this.f&=-2,!0},ti.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let t=this.s;t!==void 0;t=t.n)t.S.S(t)}_t.prototype.S.call(this,e)},ti.prototype.U=function(e){if(this.t!==void 0&&(_t.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let t=this.s;t!==void 0;t=t.n)t.S.U(t)}},ti.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(ti.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const e=xg(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),ai.prototype.c=function(){const e=this.S();try{if(8&this.f||this.x===void 0)return;const t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}},ai.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Vx(this),wg(this),Mr++;const e=Pe;return Pe=this,B6.bind(this,e)},ai.prototype.N=function(){2&this.f||(this.f|=2,this.o=_s,_s=this)},ai.prototype.d=function(){this.f|=8,1&this.f||sh(this)},ai.prototype.dispose=function(){this.d()};function W6(e){return(typeof e.nodes=="function"?e.nodes():e.nodes)||[]}function Fe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Qx(e,t){if(e&&t&&!Array.isArray(t)&&typeof e=="object"&&typeof t=="object"){const n=e,r=t;for(const o in r)n[o]=Qx(n[o],r[o]);return e}return t}const ah=0,$f=1,Gx=2,nu=3,Oa=4,ni=5,ru=6,ds=7;function ou(e){return e.id===ah}function Zx(e){return e.id===Gx}function K6(e){return(function(t){return t.id===$f})(e)||Fe(305,String(e.id),String($f)),Object.assign(e,{id:Gx})}const H6=new Set;class q6{constructor(t,n){D(this,"builder");D(this,"configs");D(this,"_dependency");D(this,"_peerNameSet");D(this,"extension");D(this,"state");D(this,"_signal");this.builder=t,this.extension=n,this.configs=new Set,this.state={id:ah}}mergeConfigs(){let t=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):S6;for(const r of this.configs)t=n(t,r);return t}init(t){const n=this.state;Zx(n)||Fe(306,String(n.id));const r={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},o={...r,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=(function(a,l,c){return Object.assign(a,{config:l,id:nu,registerState:c})})(n,this.mergeConfigs(),r);let s;this.state=i,this.extension.init&&(s=this.extension.init(t,i.config,r)),this.state=(function(a,l,c){return Object.assign(a,{id:Oa,initResult:l,registerState:c})})(i,s,o)}build(t){const n=this.state;let r;n.id!==Oa&&Fe(307,String(n.id),String(ni)),this.extension.build&&(r=this.extension.build(t,n.config,n.registerState));const o={...n.registerState,getOutput:()=>r,getSignal:this.getSignal.bind(this)};this.state=(function(i,s,a){return Object.assign(i,{id:ni,output:s,registerState:a})})(n,r,o)}register(t,n){this._signal=n;const r=this.state;r.id!==ni&&Fe(308,String(r.id),String(ni));const o=this.extension.register&&this.extension.register(t,r.config,r.registerState);return this.state=(function(i){return Object.assign(i,{id:ru})})(r),()=>{const i=this.state;i.id!==ds&&Fe(309,String(r.id),String(ds)),this.state=(function(s){return Object.assign(s,{id:ni})})(i),o&&o()}}afterRegistration(t){const n=this.state;let r;return n.id!==ru&&Fe(310,String(n.id),String(ru)),this.extension.afterRegistration&&(r=this.extension.afterRegistration(t,n.config,n.registerState)),this.state=(function(o){return Object.assign(o,{id:ds})})(n),r}getSignal(){return this._signal===void 0&&Fe(311),this._signal}getInitResult(){this.extension.init===void 0&&Fe(312,this.extension.name);const t=this.state;return(function(n){return n.id>=Oa})(t)||Fe(313,String(t.id),String(Oa)),t.initResult}getInitPeer(t){const n=this.builder.extensionNameMap.get(t);return n?n.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return(function(n){return n.id>=nu})(t)||Fe(314,String(t.id),String(nu)),{config:t.config}}getPeer(t){const n=this.builder.extensionNameMap.get(t);return n?n.getExtensionDependency():void 0}getInitDependency(t){const n=this.builder.getExtensionRep(t);return n===void 0&&Fe(315,this.extension.name,t.name),n.getExtensionInitDependency()}getDependency(t){const n=this.builder.getExtensionRep(t);return n===void 0&&Fe(315,this.extension.name,t.name),n.getExtensionDependency()}getState(){const t=this.state;return(function(n){return n.id>=ds})(t)||Fe(316,String(t.id),String(ds)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||H6}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([n])=>n)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(n){return n.id>=ni})(t)||Fe(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const Ag={tag:bo};function V6(){const e=We();e.isEmpty()&&e.append(Tt())}const Y6={config:{setOptions:Ag,updateOptions:Ag},init:({$initialEditorState:e=V6})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){const o=r.getInitResult();if(!o.initialized){o.initialized=!0;const{$initialEditorState:i}=o;if(G3(i))e.setEditorState(i,n);else if(typeof i=="function")e.update(()=>{i(e)},t);else if(i&&(typeof i=="string"||typeof i=="object")){const s=e.parseEditorState(i);e.setEditorState(s,n)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[Zi,Br,Yi,Qi,Ji]},Cg=Symbol.for("@lexical/extension/LexicalBuilder");function _g(){}function Q6(e){throw e}function Pa(e){return Array.isArray(e)?e:[e]}const iu="0.39.0+prod.esm";class bi{constructor(t){D(this,"roots");D(this,"extensionNameMap");D(this,"outgoingConfigEdges");D(this,"incomingEdges");D(this,"conflicts");D(this,"_sortedExtensionReps");D(this,"PACKAGE_VERSION");this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=iu,this.roots=t;for(const n of t)this.addExtension(n)}static fromExtensions(t){const n=[Pa(Y6)];for(const r of t)n.push(Pa(r));return new bi(n)}static maybeFromEditor(t){const n=t[Cg];return n&&(n.PACKAGE_VERSION!==iu&&Fe(292,n.PACKAGE_VERSION,iu),n instanceof bi||Fe(293)),n}static fromEditor(t){const n=bi.maybeFromEditor(t);return n===void 0&&Fe(294),n}constructEditor(){const{$initialEditorState:t,onError:n,...r}=this.buildCreateEditorArgs(),o=Object.assign(hx({...r,...n?{onError:i=>{n(i,o)}}:{}}),{[Cg]:this});for(const i of this.sortedExtensionReps())i.build(o);return o}buildEditor(){let t=_g;function n(){try{t()}finally{t=_g}}const r=Object.assign(this.constructEditor(),{dispose:n,[Symbol.dispose]:n});return t=fn(this.registerEditor(r),()=>r.setRootElement(null)),r}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const n=this.extensionNameMap.get(t.name);if(n)return n.extension!==t&&Fe(295,t.name),n}addEdge(t,n,r){const o=this.outgoingConfigEdges.get(t);o?o.set(n,r):this.outgoingConfigEdges.set(t,new Map([[n,r]]));const i=this.incomingEdges.get(n);i?i.add(t):this.incomingEdges.set(n,new Set([t]))}addExtension(t){this._sortedExtensionReps!==void 0&&Fe(296);const n=Pa(t),[r]=n;typeof r.name!="string"&&Fe(297,typeof r.name);let o=this.extensionNameMap.get(r.name);if(o!==void 0&&o.extension!==r&&Fe(298,r.name),!o){o=new q6(this,r),this.extensionNameMap.set(r.name,o);const i=this.conflicts.get(r.name);typeof i=="string"&&Fe(299,r.name,i);for(const s of r.conflictsWith||[])this.extensionNameMap.has(s)&&Fe(299,r.name,s),this.conflicts.set(s,r.name);for(const s of r.dependencies||[]){const a=Pa(s);this.addEdge(r.name,a[0].name,a.slice(1)),this.addExtension(a)}for(const[s,a]of r.peerDependencies||[])this.addEdge(r.name,s,a?[a]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],n=(r,o)=>{let i=r.state;if(Zx(i))return;const s=r.extension.name;var a;ou(i)||Fe(300,s,o||"[unknown]"),ou(a=i)||Fe(304,String(a.id),String(ah)),i=Object.assign(a,{id:$f}),r.state=i;const l=this.outgoingConfigEdges.get(s);if(l)for(const c of l.keys()){const u=this.extensionNameMap.get(c);u&&n(u,s)}i=K6(i),r.state=i,t.push(r)};for(const r of this.extensionNameMap.values())ou(r.state)&&n(r);for(const r of t)for(const[o,i]of this.outgoingConfigEdges.get(r.extension.name)||[])if(i.length>0){const s=this.extensionNameMap.get(o);if(s)for(const a of i)s.configs.add(a)}for(const[r,...o]of this.roots)if(o.length>0){const i=this.extensionNameMap.get(r.name);i===void 0&&Fe(301,r.name);for(const s of o)i.configs.add(s)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const n=this.sortedExtensionReps(),r=new AbortController,o=[()=>r.abort()],i=r.signal;for(const s of n){const a=s.register(t,i);a&&o.push(a)}for(const s of n){const a=s.afterRegistration(t);a&&o.push(a)}return fn(...o)}buildCreateEditorArgs(){const t={},n=new Set,r=new Map,o=new Map,i={},s={},a=this.sortedExtensionReps();for(const u of a){const{extension:f}=u;if(f.onError!==void 0&&(t.onError=f.onError),f.disableEvents!==void 0&&(t.disableEvents=f.disableEvents),f.parentEditor!==void 0&&(t.parentEditor=f.parentEditor),f.editable!==void 0&&(t.editable=f.editable),f.namespace!==void 0&&(t.namespace=f.namespace),f.$initialEditorState!==void 0&&(t.$initialEditorState=f.$initialEditorState),f.nodes)for(const d of W6(f)){if(typeof d!="function"){const h=r.get(d.replace);h&&Fe(302,f.name,d.replace.name,h.extension.name),r.set(d.replace,u)}n.add(d)}if(f.html){if(f.html.export)for(const[d,h]of f.html.export.entries())o.set(d,h);f.html.import&&Object.assign(i,f.html.import)}f.theme&&Qx(s,f.theme)}Object.keys(s).length>0&&(t.theme=s),n.size&&(t.nodes=[...n]);const l=Object.keys(i).length>0,c=o.size>0;(l||c)&&(t.html={},l&&(t.html.import=i),c&&(t.html.export=o));for(const u of a)u.init(t);return t.onError||(t.onError=Q6),t}}function G6(e,t){const n=bi.fromEditor(e).extensionNameMap.get(t);return n?n.getExtensionDependency():void 0}const Z6={name:"@lexical/react/ReactProvider"};function J6(){return We().getTextContent()}function X6(e,t=!0){if(e)return!1;let n=J6();return t&&(n=n.trim()),n===""}function eN(e){if(!X6(e,!1))return!1;const t=We().getChildren(),n=t.length;if(n>1)return!1;for(let r=0;r<n;r++){const o=t[r];if(Te(o))return!1;if(R(o)){if(!Bd(o)||o.__indent!==0)return!1;const i=o.getChildren(),s=i.length;for(let a=0;a<s;a++){const l=i[r];if(!X(l))return!1}}}return!0}function Jx(e){return()=>eN(e)}function tN(e){const t=window.location.origin,n=r=>{if(r.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const i=r.data;if(typeof i=="string"){let s;try{s=JSON.parse(i)}catch{return}if(s&&s.protocol==="nuanria_messaging"&&s.type==="request"){const a=s.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[c,u,f,d,h]=l;e.update(()=>{const p=Z();if($(p)){const g=p.anchor;let m=g.getNode(),y=0,v=0;if(X(m)&&c>=0&&u>=0&&(y=c,v=c+u,p.setTextNodeRange(m,y,m,v)),y===v&&f===""||(p.insertRawText(f),m=g.getNode()),X(m)){y=d,v=d+h;const b=m.getTextContentSize();y=y>b?b:y,v=v>b?b:v,p.setTextNodeRange(m,y,m,v)}r.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",n,!0),()=>{window.removeEventListener("message",n,!0)}}function Xx(e,t){const n=yx(t)?t.body.childNodes:t.childNodes;let r=[];const o=[];for(const i of n)if(!n1.has(i.nodeName)){const s=r1(i,e,o,!1);s!==null&&(r=r.concat(s))}return(function(i){for(const s of i)s.getNextSibling()instanceof Ud&&s.insertAfter(Lo());for(const s of i){const a=s.getChildren();for(const l of a)s.insertBefore(l);s.remove()}})(o),r}function e1(e,t){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 n=document.createElement("div"),r=We().getChildren();for(let o=0;o<r.length;o++)t1(e,r[o],n,t);return n.innerHTML}function t1(e,t,n,r=null){let o=r===null||t.isSelected(r);const i=R(t)&&t.excludeFromCopy("html");let s=t;r!==null&&X(t)&&(s=jx(r,t,"clone"));const a=R(s)?s.getChildren():[],l=Kd(e,s.getType());let c;c=l&&l.exportDOM!==void 0?l.exportDOM(e,s):s.exportDOM(e);const{element:u,after:f}=c;if(!u)return!1;const d=document.createDocumentFragment();for(let h=0;h<a.length;h++){const p=a[h],g=t1(e,p,d,r);!o&&R(t)&&g&&t.extractWithChild(p,r,"html")&&(o=!0)}if(o&&!i){if((pt(u)||Df(u))&&u.append(d),n.append(u),f){const h=f.call(s,u);h&&(Df(u)?u.replaceChildren(h):u.replaceWith(h))}}else n.append(d);return o}const n1=new Set(["STYLE","SCRIPT"]);function r1(e,t,n,r,o=new Map,i){let s=[];if(n1.has(e.nodeName))return s;let a=null;const l=(function(p,g){const{nodeName:m}=p,y=g._htmlConversions.get(m.toLowerCase());let v=null;if(y!==void 0)for(const b of y){const A=b(p);A!==null&&(v===null||(v.priority||0)<=(A.priority||0))&&(v=A)}return v!==null?v.conversion:null})(e,t),c=l?l(e):null;let u=null;if(c!==null){u=c.after;const p=c.node;if(a=Array.isArray(p)?p[p.length-1]:p,a!==null){for(const[,g]of o)if(a=g(a,i),!a)break;a&&s.push(...Array.isArray(p)?p:[a])}c.forChild!=null&&o.set(e.nodeName,c.forChild)}const f=e.childNodes;let d=[];const h=(a==null||!jt(a))&&(a!=null&&Pf(a)||r);for(let p=0;p<f.length;p++)d.push(...r1(f[p],t,n,h,new Map(o),a));return u!=null&&(d=u(d)),bl(e)&&(d=nN(e,d,h?()=>{const p=new Ud;return n.push(p),p}:Tt)),a==null?d.length>0?s=s.concat(d):bl(e)&&(function(p){return p.nextSibling==null||p.previousSibling==null?!1:Ff(p.nextSibling)&&Ff(p.previousSibling)})(e)&&(s=s.concat(Lo())):R(a)&&a.append(...d),s}function nN(e,t,n){const r=e.style.textAlign,o=[];let i=[];for(let s=0;s<t.length;s++){const a=t[s];if(Pf(a))r&&!a.getFormat()&&a.setFormat(r),o.push(a);else if(i.push(a),s===t.length-1||s<t.length-1&&Pf(t[s+1])){const l=n();l.setFormat(r),l.append(...i),o.push(l),i=[]}}return o}function xl(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function rN(e,t=Z()){return t==null&&xl(166),$(t)&&t.isCollapsed()||t.getNodes().length===0?"":e1(e,t)}function oN(e,t=Z()){return t==null&&xl(166),$(t)&&t.isCollapsed()||t.getNodes().length===0?null:JSON.stringify(iN(e,t))}function Eg(e,t,n){const r=e.getData("application/x-lexical-editor");if(r)try{const a=JSON.parse(r);if(a.namespace===n._config.namespace&&Array.isArray(a.nodes))return Sg(n,sN(a.nodes),t)}catch(a){console.error(a)}const o=e.getData("text/html"),i=e.getData("text/plain");if(o&&i!==o)try{const a=new DOMParser().parseFromString((function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:c=>c}).createHTML(l):l})(o),"text/html");return Sg(n,Xx(n,a),t)}catch(a){console.error(a)}const s=i||e.getData("text/uri-list");if(s!=null)if($(t)){const a=s.split(/(\r?\n|\t)/);a[a.length-1]===""&&a.pop();for(let l=0;l<a.length;l++){const c=Z();if($(c)){const u=a[l];u===`
605
605
  `||u===`\r
606
- `?c.insertParagraph():u===" "?c.insertNodes([na()]):c.insertText(u)}}}else t.insertRawText(s)}function Sg(e,t,n){e.dispatchCommand(p3,{nodes:t,selection:n})||(n.insertNodes(t),(function(r){if($(r)&&r.isCollapsed()){const o=r.anchor;let i=null;const s=nr(o,"previous");if(s)if(Or(s))i=s.origin;else{const a=Fr(s,un(We(),"next").getFlipped());for(const l of a){if(X(l.origin)){i=l.origin;break}if(R(l.origin)&&!l.origin.isInline())break}}if(i&&X(i)){const a=i.getFormat(),l=i.getStyle();r.format===a&&r.style===l||(r.format=a,r.style=l,r.dirty=!0)}}})(n))}function o1(e,t,n,r=[]){let o=t===null||n.isSelected(t);const i=R(n)&&n.excludeFromCopy("html");let s=n;t!==null&&X(s)&&(s=jx(t,s,"clone"));const a=R(s)?s.getChildren():[],l=(function(c){const u=c.exportJSON(),f=c.constructor;if(u.type!==f.getType()&&xl(58,f.name),R(c)){const d=u.children;Array.isArray(d)||xl(59,f.name)}return u})(s);X(s)&&s.getTextContentSize()===0&&(o=!1);for(let c=0;c<a.length;c++){const u=a[c],f=o1(e,t,u,l.children);!o&&R(n)&&f&&n.extractWithChild(u,t,"clone")&&(o=!0)}if(o&&!i)r.push(l);else if(Array.isArray(l.children))for(let c=0;c<l.children.length;c++){const u=l.children[c];r.push(u)}return o}function iN(e,t){const n=[],r=We().getChildren();for(let o=0;o<r.length;o++)o1(e,t,r[o],n);return{namespace:e._config.namespace,nodes:n}}function sN(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n],o=Q3(r);X(o)&&I6(o),t.push(o)}return t}let ri=null;async function kg(e,t,n){if(ri!==null)return!1;if(t!==null)return new Promise((c,u)=>{e.update(()=>{c(Tg(e,t,n))})});const r=e.getRootElement(),o=e._window||window,i=o.document,s=en(o);if(r===null||s===null)return!1;const a=i.createElement("span");a.style.cssText="position: fixed; top: -1000px;",a.append(i.createTextNode("#")),r.append(a);const l=new Range;return l.setStart(a,0),l.setEnd(a,1),s.removeAllRanges(),s.addRange(l),new Promise((c,u)=>{const f=e.registerCommand(Zl,d=>(kr(d,ClipboardEvent)&&(f(),ri!==null&&(o.clearTimeout(ri),ri=null),c(Tg(e,d,n))),!0),fx);ri=o.setTimeout(()=>{f(),ri=null,c(!1)},50),i.execCommand("copy"),a.remove()})}function Tg(e,t,n){if(n===void 0){const o=en(e._window),i=Z();if(!i||i.isCollapsed()||!o)return!1;const s=o.anchorNode,a=o.focusNode;if(s!==null&&a!==null&&!ia(e,s,a))return!1;n=aN(i)}t.preventDefault();const r=t.clipboardData;return r!==null&&(lN(r,n),!0)}const i1=[["text/html",rN],["application/x-lexical-editor",oN]];function aN(e=Z()){const t={"text/plain":e?e.getTextContent():""};if(e){const n=Jd();for(const[r,o]of i1){const i=o(n,e);i!==null&&(t[r]=i)}}return t}function lN(e,t){for(const[n]of i1)t[n]===void 0&&e.setData(n,"");for(const n in t){const r=t[n];r!==void 0&&e.setData(n,r)}}function Ng(e,t){if(document.caretRangeFromPoint!==void 0){const n=document.caretRangeFromPoint(e,t);return n===null?null:{node:n.startContainer,offset:n.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const n=document.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}}return null}const Ko=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cN=Ko&&"documentMode"in document?document.documentMode:null,uN=Ko&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),fN=!(!Ko||!("InputEvent"in window)||cN)&&"getTargetRanges"in new window.InputEvent("input"),dN=Ko&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Og=Ko&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,hN=Ko&&/^(?=.*Chrome).*/i.test(navigator.userAgent),pN=Ko&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&uN&&!hN,Pg=he("DRAG_DROP_PASTE_FILE");function Ma(e){let t=null;if(kr(e,DragEvent)?t=e.dataTransfer:kr(e,ClipboardEvent)&&(t=e.clipboardData),t===null)return[!1,[],!1];const n=t.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(t.files),o]}function Mg(e){const t=Z();if(!$(t))return!1;const n=new Set,r=t.getNodes();for(let o=0;o<r.length;o++){const i=r[o],s=i.getKey();if(n.has(s))continue;const a=at(i,c=>R(c)&&!c.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!n.has(l)&&(n.add(l),e(a))}return n.size>0}function Ig(e){const t=Fi(e);return Te(t)}function su(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function mN(e){return fn(e.registerCommand(Md,t=>{const n=Z();return!!ot(n)&&(n.clear(),!0)},we),e.registerCommand(vo,t=>{const n=Z();return $(n)?(n.deleteCharacter(t),!0):!!ot(n)&&(n.deleteNodes(),!0)},we),e.registerCommand(Rs,t=>{const n=Z();return!!$(n)&&(n.deleteWord(t),!0)},we),e.registerCommand(Ds,t=>{const n=Z();return!!$(n)&&(n.deleteLine(t),!0)},we),e.registerCommand(gi,t=>{const n=Z();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;const r=t.dataTransfer;if(r!=null)Eg(r,n,e);else if($(n)){const o=t.data;return o&&n.insertText(o),!0}}return!0},we),e.registerCommand(xf,()=>{const t=Z();return!!$(t)&&(t.removeText(),!0)},we),e.registerCommand(_n,t=>{const n=Z();return!!$(n)&&(n.formatText(t),!0)},we),e.registerCommand(b3,t=>{const n=Z();if(!$(n)&&!ot(n))return!1;const r=n.getNodes();for(const o of r){const i=at(o,s=>R(s)&&!s.isInline());i!==null&&i.setFormat(t)}return!0},we),e.registerCommand(mi,t=>{const n=Z();return!!$(n)&&(n.insertLineBreak(t),!0)},we),e.registerCommand(Ls,()=>{const t=Z();return!!$(t)&&(t.insertParagraph(),!0)},we),e.registerCommand(y3,()=>(ox([na()]),!0),we),e.registerCommand(v3,()=>Mg(t=>{const n=t.getIndent();t.setIndent(n+1)}),we),e.registerCommand(Mm,()=>Mg(t=>{const n=t.getIndent();n>0&&t.setIndent(Math.max(0,n-1))}),we),e.registerCommand(Pb,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}else if($(n)){const r=If(n.focus,!0);if(!t.shiftKey&&Te(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},we),e.registerCommand(Mb,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectNext(0,0),!0}else if($(n)){if((function(o){const i=o.focus;return i.key==="root"&&i.offset===We().getChildrenSize()})(n))return t.preventDefault(),!0;const r=If(n.focus,!1);if(!t.shiftKey&&Te(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},we),e.registerCommand(Ob,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),mg(r[0])?r[0].selectNext(0,0):r[0].selectPrevious(),!0}if(!$(n))return!1;if(yg(n,!0)){const r=t.shiftKey;return t.preventDefault(),vg(n,r,!0),!0}return!1},we),e.registerCommand(Nb,t=>{const n=Z();if(ot(n)){const o=n.getNodes();if(o.length>0)return t.preventDefault(),mg(o[0])?o[0].selectPrevious():o[0].selectNext(0,0),!0}if(!$(n))return!1;const r=t.shiftKey;return!!yg(n,!1)&&(t.preventDefault(),vg(n,r,!1),!0)},we),e.registerCommand(Lb,t=>{if(Ig(t.target))return!1;const n=Z();if($(n)){if((function(r){if(!r.isCollapsed())return!1;const{anchor:o}=r;if(o.offset!==0)return!1;const i=o.getNode();if(Ye(i))return!1;const s=j6(i);return s.getIndent()>0&&(s.is(i)||i.is(s.getFirstDescendant()))})(n))return t.preventDefault(),e.dispatchCommand(Mm,void 0);if(Og&&navigator.language==="ko-KR")return!1}else if(!ot(n))return!1;return t.preventDefault(),e.dispatchCommand(vo,!0)},we),e.registerCommand(Rb,t=>{if(Ig(t.target))return!1;const n=Z();return!(!$(n)&&!ot(n))&&(t.preventDefault(),e.dispatchCommand(vo,!1))},we),e.registerCommand(Fs,t=>{const n=Z();if(!$(n))return!1;if(su(n),t!==null){if((Og||dN||pN)&&fN)return!1;if(t.preventDefault(),t.shiftKey)return e.dispatchCommand(mi,!1)}return e.dispatchCommand(Ls,void 0)},we),e.registerCommand(Rd,()=>{const t=Z();return!!$(t)&&(e.blur(),!0)},we),e.registerCommand(Fb,t=>{const[,n]=Ma(t);if(n.length>0){const o=Ng(t.clientX,t.clientY);if(o!==null){const{offset:i,node:s}=o,a=Fi(s);if(a!==null){const l=tx();if(X(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const u=a.getParentOrThrow().getKey(),f=a.getIndexWithinParent()+1;l.anchor.set(u,f,"element"),l.focus.set(u,f,"element")}const c=Ri(l);Pt(c)}e.dispatchCommand(Pg,n)}return t.preventDefault(),!0}const r=Z();return!!$(r)},we),e.registerCommand(jb,t=>{const[n]=Ma(t),r=Z();return!(n&&!$(r))},we),e.registerCommand(zb,t=>{const[n]=Ma(t),r=Z();if(n&&!$(r))return!1;const o=Ng(t.clientX,t.clientY);if(o!==null){const i=Fi(o.node);Te(i)&&t.preventDefault()}return!0},we),e.registerCommand(wf,()=>(o6(),!0),we),e.registerCommand(Zl,t=>(kg(e,kr(t,ClipboardEvent)?t:null),!0),we),e.registerCommand(Dd,t=>((async function(n,r){await kg(r,kr(n,ClipboardEvent)?n:null),r.update(()=>{const o=Z();$(o)?o.removeText():ot(o)&&o.getNodes().forEach(i=>i.remove())})})(t,e),!0),we),e.registerCommand(Gl,t=>{const[,n,r]=Ma(t);return n.length>0&&!r?(e.dispatchCommand(Pg,n),!0):Xi(t.target)&&Hd(t.target)?!1:Z()!==null&&((function(o,i){o.preventDefault(),i.update(()=>{const s=Z(),a=kr(o,InputEvent)||kr(o,KeyboardEvent)?null:o.clipboardData;a!=null&&s!==null&&Eg(a,s,i)},{tag:I3})})(t,e),!0)},we),e.registerCommand(Ib,t=>{const n=Z();return $(n)&&su(n),!1},we),e.registerCommand(Db,t=>{const n=Z();return $(n)&&su(n),!1},we))}function gN(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const lh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function yN({editor:e,ErrorBoundary:t}){return(function(n,r){const[o,i]=T.useState(()=>n.getDecorators());return lh(()=>n.registerDecoratorListener(s=>{Nn.flushSync(()=>{i(s)})}),[n]),T.useEffect(()=>{i(n.getDecorators())},[n]),T.useMemo(()=>{const s=[],a=Object.keys(o);for(let l=0;l<a.length;l++){const c=a[l],u=x.jsx(r,{onError:d=>n._onError(d),children:x.jsx(T.Suspense,{fallback:null,children:o[c]})}),f=n.getElementByKey(c);f!==null&&s.push(Nn.createPortal(u,f,c))}return s},[r,o,n])})(e,t)}function vN({editor:e,ErrorBoundary:t}){return(function(n){const r=bi.maybeFromEditor(n);if(r&&r.hasExtensionByName(Z6.name)){for(const o of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(o)&&gN(320,o);return!0}return!1})(e)?null:x.jsx(yN,{editor:e,ErrorBoundary:t})}function Lg(e){return e.getEditorState().read(Jx(e.isComposing()))}function bN({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){const[r]=ht();return(function(o){lh(()=>fn(mN(o),tN(o)),[o])})(r),x.jsxs(x.Fragment,{children:[e,x.jsx(xN,{content:t}),x.jsx(vN,{editor:r,ErrorBoundary:n})]})}function xN({content:e}){const[t]=ht(),n=(function(o){const[i,s]=T.useState(()=>Lg(o));return lh(()=>{function a(){const l=Lg(o);s(l)}return a(),fn(o.registerUpdateListener(()=>{a()}),o.registerEditableListener(()=>{a()}))},[o]),i})(t),r=P6();return n?typeof e=="function"?e(r):e:null}function wN(e,t,n,r,o){if(e===null||n.size===0&&r.size===0&&!o)return 0;const i=t._selection,s=e._selection;if(o)return 1;if(!($(i)&&$(s)&&s.isCollapsed()&&i.isCollapsed()))return 0;const a=(function(y,v,b){const A=y._nodeMap,w=[];for(const _ of v){const E=A.get(_);E!==void 0&&w.push(E)}for(const[_,E]of b){if(!E)continue;const S=A.get(_);S===void 0||Ye(S)||w.push(S)}return w})(t,n,r);if(a.length===0)return 0;if(a.length>1){const y=t._nodeMap,v=y.get(i.anchor.key),b=y.get(s.anchor.key);return v&&b&&!e._nodeMap.has(v.__key)&&X(v)&&v.__text.length===1&&i.anchor.offset===1?2:0}const l=a[0],c=e._nodeMap.get(l.__key);if(!X(c)||!X(l)||c.__mode!==l.__mode)return 0;const u=c.__text,f=l.__text;if(u===f)return 0;const d=i.anchor,h=s.anchor;if(d.key!==h.key||d.type!=="text")return 0;const p=d.offset,g=h.offset,m=f.length-u.length;return m===1&&g===p-1?2:m===-1&&g===p+1?3:m===-1&&g===p?4:0}function AN(e,t){let n=Date.now(),r=0;return(o,i,s,a,l,c)=>{const u=Date.now();if(c.has(Nf))return r=0,n=u,2;const f=wN(o,i,a,l,e.isComposing()),d=(()=>{const h=s===null||s.editor===e,p=c.has(M3);if(!p&&h&&c.has(bo))return 0;if(o===null)return 1;const g=i._selection;if(!(a.size>0||l.size>0))return g!==null?0:2;const m=typeof t=="number"?t:t.peek();return p===!1&&f!==0&&f===r&&u<n+m&&h||a.size===1&&(function(y,v,b){const A=v._nodeMap.get(y),w=b._nodeMap.get(y),_=v._selection,E=b._selection;return!($(_)&&$(E)&&_.anchor.type==="element"&&_.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!X(A)||!X(w)||A.__parent!==w.__parent)&&JSON.stringify(v.read(()=>A.exportJSON()))===JSON.stringify(b.read(()=>w.exportJSON()))})(Array.from(a)[0],o,i)?0:1})();return n=u,r=f,d}}function Rg(e){e.undoStack=[],e.redoStack=[],e.current=null}function s1(e,t,n){const r=AN(e,n);return fn(e.registerCommand(Id,()=>((function(i,s){const a=s.redoStack,l=s.undoStack;if(l.length!==0){const c=s.current,u=l.pop();c!==null&&(a.push(c),i.dispatchCommand(Ca,!0)),l.length===0&&i.dispatchCommand(_a,!1),s.current=u||null,u&&u.editor.setEditorState(u.editorState,{tag:Nf})}})(e,t),!0),we),e.registerCommand(Ld,()=>((function(i,s){const a=s.redoStack,l=s.undoStack;if(a.length!==0){const c=s.current;c!==null&&(l.push(c),i.dispatchCommand(_a,!0));const u=a.pop();a.length===0&&i.dispatchCommand(Ca,!1),s.current=u||null,u&&u.editor.setEditorState(u.editorState,{tag:Nf})}})(e,t),!0),we),e.registerCommand(w3,()=>(Rg(t),!1),we),e.registerCommand(A3,()=>(Rg(t),e.dispatchCommand(Ca,!1),e.dispatchCommand(_a,!1),!0),we),e.registerUpdateListener(({editorState:i,prevEditorState:s,dirtyLeaves:a,dirtyElements:l,tags:c})=>{const u=t.current,f=t.redoStack,d=t.undoStack,h=u===null?null:u.editorState;if(u!==null&&i===h)return;const p=r(s,i,u,a,l,c);if(p===1)f.length!==0&&(t.redoStack=[],e.dispatchCommand(Ca,!1)),u!==null&&(d.push({...u}),e.dispatchCommand(_a,!0));else if(p===2)return;t.current={editor:e,editorState:i}}))}function a1(){return{current:null,redoStack:[],undoStack:[]}}const au={build:(e,{delay:t,createInitialHistoryState:n,disabled:r})=>Yx({delay:t,disabled:r,historyState:n(e)}),config:{createInitialHistoryState:a1,delay:300,disabled:typeof window>"u"},name:"@lexical/history/History",register:(e,t,n)=>{const r=n.getOutput();return $s(()=>r.disabled.value?void 0:s1(e,r.historyState.value,r.delay))}};E6(au,{createInitialHistoryState:()=>{throw new Error("SharedHistory did not inherit parent history")},disabled:!0});function CN({delay:e,externalHistoryState:t}){const[n]=ht();return(function(r,o,i=1e3){const s=T.useMemo(()=>o||a1(),[o]);T.useEffect(()=>s1(r,s,i),[i,r,s])})(n,t,e),null}const l1=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function _N({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:o,ariaErrorMessage:i,ariaExpanded:s,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:c,ariaMultiline:u,ariaOwns:f,ariaRequired:d,autoCapitalize:h,className:p,id:g,role:m="textbox",spellCheck:y=!0,style:v,tabIndex:b,"data-testid":A,...w},_){const[E,S]=T.useState(e.isEditable()),O=T.useCallback(I=>{I&&I.ownerDocument&&I.ownerDocument.defaultView?e.setRootElement(I):e.setRootElement(null)},[e]),P=T.useMemo(()=>(function(...I){return W=>{for(const j of I)typeof j=="function"?j(W):j!=null&&(j.current=W)}})(_,O),[O,_]);return l1(()=>(S(e.isEditable()),e.registerEditableListener(I=>{S(I)})),[e]),x.jsx("div",{"aria-activedescendant":E?t:void 0,"aria-autocomplete":E?n:"none","aria-controls":E?r:void 0,"aria-describedby":o,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":E&&m==="combobox"?!!s:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":c,"aria-multiline":u,"aria-owns":E?f:void 0,"aria-readonly":!E||void 0,"aria-required":d,autoCapitalize:h,className:p,contentEditable:E,"data-testid":A,id:g,ref:P,role:m,spellCheck:y,style:v,tabIndex:b,...w})}const EN=T.forwardRef(_N);function Dg(e){return e.getEditorState().read(Jx(e.isComposing()))}const SN=T.forwardRef(kN);function kN(e,t){const{placeholder:n,...r}=e,[o]=ht();return x.jsxs(x.Fragment,{children:[x.jsx(EN,{editor:o,...r,ref:t}),n!=null&&x.jsx(TN,{editor:o,content:n})]})}function TN({content:e,editor:t}){const n=(function(s){const[a,l]=T.useState(()=>Dg(s));return l1(()=>{function c(){const u=Dg(s);l(u)}return c(),fn(s.registerUpdateListener(()=>{c()}),s.registerEditableListener(()=>{c()}))},[s]),a})(t),[r,o]=T.useState(t.isEditable());if(T.useLayoutEffect(()=>(o(t.isEditable()),t.registerEditableListener(s=>{o(s)})),[t]),!n)return null;let i=null;return typeof e=="function"?i=e(r):e!==null&&(i=e),i===null?null:x.jsx("div",{"aria-hidden":!0,children:i})}const NN=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function ON({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){const[r]=ht();return NN(()=>{if(n)return r.registerUpdateListener(({editorState:o,dirtyElements:i,dirtyLeaves:s,prevEditorState:a,tags:l})=>{t&&i.size===0&&s.size===0||e&&l.has(bo)||a.isEmpty()||n(o,r,l)})},[r,e,t,n]),null}const PN=T.createContext(null),lu={didCatch:!1,error:null};class MN extends T.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=lu}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var r,o;const{error:n}=this.state;n!==null&&((o=(r=this.props).onReset)==null||o.call(r,{args:t,reason:"imperative-api"}),this.setState(lu))}componentDidCatch(t,n){var r,o;(o=(r=this.props).onError)==null||o.call(r,t,n)}componentDidUpdate(t,n){var i,s;const{didCatch:r}=this.state,{resetKeys:o}=this.props;r&&n.error!==null&&IN(t.resetKeys,o)&&((s=(i=this.props).onReset)==null||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(lu))}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=T.createElement(r,l);else if(o!==void 0)a=o;else throw s}return T.createElement(PN.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function IN(e=[],t=[]){return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function LN({children:e,onError:t}){return x.jsx(MN,{fallback:x.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:t,children:e})}const RN={paragraph:"m-0",list:{ol:"list-decimal pl-4",ul:"list-disc pl-4"},text:{bold:"font-semibold",italic:"italic",underline:"underline",strikethrough:"line-through",code:"font-mono"},link:"text-blue-600 hover:text-blue-600 underline cursor-pointer"};function Tr(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Uf(e){let t=1,n=e.getParent();for(;n!=null;){if(ke(n)){const r=n.getParent();if(be(r)){t++,n=r.getParent();continue}Tr(40)}return t}return t}function Bf(e){let t=e.getParent();be(t)||Tr(40);let n=t;for(;n!==null;)n=n.getParent(),be(n)&&(t=n);return t}function c1(e){let t=[];const n=e.getChildren().filter(ke);for(let r=0;r<n.length;r++){const o=n[r],i=o.getFirstChild();be(i)?t=t.concat(c1(i)):t.push(o)}return t}function wn(e){return ke(e)&&be(e.getFirstChild())}function Fg(e){return Zt().append(e)}function u1(e,t){return ke(e)&&(t.length===0||t.length===1&&e.is(t[0])&&e.getChildrenSize()===0)}function jg(e){const t=Z();if(t!==null){let n=t.getNodes();if($(t)){const o=t.getStartEndPoints();o===null&&Tr(143);const[i]=o,s=i.getNode(),a=s.getParent();if(jt(s)){const l=s.getFirstChild();if(l)n=l.selectStart().getNodes();else{const c=Tt();s.append(c),n=c.select().getNodes()}}else if(u1(s,n)){const l=Bt(e);if(jt(a)){s.replace(l);const c=Zt();R(s)&&(c.setFormat(s.getFormatType()),c.setIndent(s.getIndent())),l.append(c)}else if(ke(s)){const c=s.getParentOrThrow();Uo(l,c.getChildren()),c.replace(l)}return}}const r=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(R(i)&&i.isEmpty()&&!ke(i)&&!r.has(i.getKey())){zg(i,e);continue}let s=vx(i)?i.getParent():ke(i)&&i.isEmpty()?i:null;for(;s!=null;){const a=s.getKey();if(be(s)){if(!r.has(a)){const l=Bt(e);Uo(l,s.getChildren()),s.replace(l),r.add(a)}break}{const l=s.getParent();if(jt(l)&&!r.has(a)){r.add(a),zg(s,e);break}s=l}}}}}function Uo(e,t){e.splice(e.getChildrenSize(),0,t)}function zg(e,t){if(be(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),o=Zt();let i;if(Uo(o,e.getChildren()),be(n)&&t===n.getListType())n.append(o),be(r)&&t===r.getListType()&&(Uo(n,r.getChildren()),r.remove()),i=n;else if(be(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(o),i=r;else{const s=Bt(t);s.append(o),e.replace(s),i=s}return o.setFormat(e.getFormatType()),o.setIndent(e.getIndent()),e.remove(),i}function ch(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&wn(n)&&wn(r)&&(ch(n.getFirstChild(),r.getFirstChild()),r.remove());const o=t.getChildren();o.length>0&&e.append(...o),t.remove()}function DN(){const e=Z();if($(e)){const t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(u1(r,n))t.add(Bf(r));else for(let o=0;o<n.length;o++){const i=n[o];if(vx(i)){const s=F6(i,ts);s!=null&&t.add(Bf(s))}}for(const o of t){let i=o;const s=c1(o);for(const a of s){const l=Tt().setTextStyle(e.style).setTextFormat(e.format);Uo(l,a.getChildren()),i.insertAfter(l),i=l,a.__key===e.anchor.key&&$o(e.anchor,Yt(un(l,"next"))),a.__key===e.focus.key&&$o(e.focus,Yt(un(l,"next"))),a.remove()}o.remove()}}}function f1(e){const t=e.getListType()!=="check";let n=e.getStart();for(const r of e.getChildren())ke(r)&&(r.getValue()!==n&&r.setValue(n),t&&r.getLatest().__checked!=null&&r.setChecked(void 0),be(r.getFirstChild())||n++)}function FN(e){const t=new Set;if(wn(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),o=e.getPreviousSibling();if(wn(r)&&wn(o)){const i=o.getFirstChild();if(be(i)){i.append(e);const s=r.getFirstChild();be(s)&&(Uo(i,s.getChildren()),r.remove(),t.add(r.getKey()))}}else if(wn(r)){const i=r.getFirstChild();if(be(i)){const s=i.getFirstChild();s!==null&&s.insertBefore(e)}}else if(wn(o)){const i=o.getFirstChild();be(i)&&i.append(e)}else if(be(n)){const i=Zt().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),s=Bt(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());i.append(s),s.append(e),o?o.insertAfter(i):r?r.insertBefore(i):n.append(i)}}function jN(e){if(wn(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(be(n?n.getParent():void 0)&&ke(n)&&be(t)){const r=t?t.getFirstChild():void 0,o=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(o))n.insertAfter(e),t.isEmpty()&&n.remove();else{const i=t.getListType(),s=Zt(),a=Bt(i);s.append(a),e.getPreviousSiblings().forEach(u=>a.append(u));const l=Zt(),c=Bt(i);l.append(c),Uo(c,e.getNextSiblings()),n.insertBefore(s),n.insertAfter(l),n.replace(e)}}}function zN(){const e=Z();if(!$(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();if(!ke(t)||t.getChildrenSize()!==0)return!1;const n=Bf(t),r=t.getParent();be(r)||Tr(40);const o=r.getParent();let i;if(jt(o))i=Tt(),n.insertAfter(i);else{if(!ke(o))return!1;i=Zt(),o.insertAfter(i)}i.setTextStyle(e.style).setTextFormat(e.format).select();const s=t.getNextSiblings();if(s.length>0){const a=Bt(r.getListType());if(ke(i)){const l=Zt();l.append(a),i.insertAfter(l)}else i.insertAfter(a);a.append(...s)}return(function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const c=l.getParent();if(c==null||!ke(c)&&!be(c))break;l=c}l.remove()})(t),!0}function wl(...e){const t=[];for(const n of e)if(n&&typeof n=="string")for(const[r]of n.matchAll(/\S+/g))t.push(r);return t}class ts extends Mn{constructor(n=1,r=void 0,o){super(o);D(this,"__value");D(this,"__checked");this.__value=n===void 0?1:n,this.__checked=r}$config(){return this.config("listitem",{$transform:n=>{if(n.__checked==null)return;const r=n.getParent();be(r)&&r.getListType()!=="check"&&n.getChecked()!=null&&n.setChecked(void 0)},extends:Mn,importDOM:{li:()=>({conversion:$N,priority:0})}})}afterCloneFrom(n){super.afterCloneFrom(n),this.__value=n.__value,this.__checked=n.__checked}createDOM(n){const r=document.createElement("li");return this.updateListItemDOM(null,r,n),r}updateListItemDOM(n,r,o){(function(a,l,c){const u=l.getParent();!be(u)||u.getListType()!=="check"||be(l.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&l.__checked===c.__checked||a.setAttribute("aria-checked",l.getChecked()?"true":"false"))})(r,this,n),r.value=this.__value,(function(a,l,c){const u=[],f=[],d=l.list,h=d?d.listitem:void 0;let p;if(d&&d.nested&&(p=d.nested.listitem),h!==void 0&&u.push(...wl(h)),d){const g=c.getParent(),m=be(g)&&g.getListType()==="check",y=c.getChecked();m&&!y||f.push(d.listitemUnchecked),m&&y||f.push(d.listitemChecked),m&&u.push(y?d.listitemChecked:d.listitemUnchecked)}if(p!==void 0){const g=wl(p);c.getChildren().some(m=>be(m))?u.push(...g):f.push(...g)}f.length>0&&Kx(a,...f),u.length>0&&ih(a,...u)})(r,o.theme,this);const i=n?n.__style:"",s=this.__style;i!==s&&(s===""?r.removeAttribute("style"):r.style.cssText=s),(function(a,l,c){const u=pg(l.__textStyle);for(const f in u)a.style.setProperty(`--listitem-marker-${f}`,u[f]);if(c)for(const f in pg(c.__textStyle))f in u||a.style.removeProperty(`--listitem-marker-${f}`)})(r,this,n)}updateDOM(n,r,o){const i=r;return this.updateListItemDOM(n,i,o),!1}updateFromJSON(n){return super.updateFromJSON(n).setValue(n.value).setChecked(n.checked)}exportDOM(n){const r=this.createDOM(n._config),o=this.getFormatType();o&&(r.style.textAlign=o);const i=this.getDirection();return i&&(r.dir=i),{element:r}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...n){for(let r=0;r<n.length;r++){const o=n[r];if(R(o)&&this.canMergeWith(o)){const i=o.getChildren();this.append(...i),o.remove()}else super.append(o)}return this}replace(n,r){if(ke(n))return super.replace(n);this.setIndent(0);const o=this.getParentOrThrow();if(!be(o))return n;if(o.__first===this.getKey())o.insertBefore(n);else if(o.__last===this.getKey())o.insertAfter(n);else{const i=Bt(o.getListType());let s=this.getNextSibling();for(;s;){const a=s;s=s.getNextSibling(),i.append(a)}o.insertAfter(n),n.insertAfter(i)}return r&&(R(n)||Tr(139),this.getChildren().forEach(i=>{n.append(i)})),this.remove(),o.getChildrenSize()===0&&o.remove(),n}insertAfter(n,r=!0){const o=this.getParentOrThrow();if(be(o)||Tr(39),ke(n))return super.insertAfter(n,r);const i=this.getNextSiblings();if(o.insertAfter(n,r),i.length!==0){const s=Bt(o.getListType());i.forEach(a=>s.append(a)),n.insertAfter(s,r)}return n}remove(n){const r=this.getPreviousSibling(),o=this.getNextSibling();super.remove(n),r&&o&&wn(r)&&wn(o)&&(ch(r.getFirstChild(),o.getFirstChild()),o.remove())}insertNewAfter(n,r=!0){const o=Zt().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(o,r),o}collapseAtStart(n){const r=Tt();this.getChildren().forEach(a=>r.append(a));const o=this.getParentOrThrow(),i=o.getParentOrThrow(),s=ke(i);if(o.getChildrenSize()===1)if(s)o.remove(),i.select();else{o.insertBefore(r),o.remove();const a=n.anchor,l=n.focus,c=r.getKey();a.type==="element"&&a.getNode().is(this)&&a.set(c,a.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(c,l.offset,"element")}else o.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(n){const r=this.getWritable();return r.__value=n,r}getChecked(){const n=this.getLatest();let r;const o=this.getParent();return be(o)&&(r=o.getListType()),r==="check"?!!n.__checked:void 0}setChecked(n){const r=this.getWritable();return r.__checked=n,r}toggleChecked(){const n=this.getWritable();return n.setChecked(!n.__checked)}getIndent(){const n=this.getParent();if(n===null||!this.isAttached())return this.getLatest().__indent;let r=n.getParentOrThrow(),o=0;for(;ke(r);)r=r.getParentOrThrow().getParentOrThrow(),o++;return o}setIndent(n){typeof n!="number"&&Tr(117),(n=Math.floor(n))>=0||Tr(199);let r=this.getIndent();for(;r!==n;)r<n?(FN(this),r++):(jN(this),r--);return this}canInsertAfter(n){return ke(n)}canReplaceWith(n){return ke(n)}canMergeWith(n){return ke(n)||Bd(n)}extractWithChild(n,r){if(!$(r))return!1;const o=r.anchor.getNode(),i=r.focus.getNode();return this.isParentOf(o)&&this.isParentOf(i)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Bt("bullet")}canMergeWhenEmpty(){return!0}}function $N(e){if(e.classList.contains("task-list-item")){for(const n of e.children)if(n.tagName==="INPUT")return $g(n)}if(e.classList.contains("joplin-checkbox")){for(const n of e.children)if(n.classList.contains("checkbox-wrapper")&&n.children.length>0&&n.children[0].tagName==="INPUT")return $g(n.children[0])}const t=e.getAttribute("aria-checked");return{node:Zt(t==="true"||t!=="false"&&void 0)}}function $g(e){return e.getAttribute("type")!=="checkbox"?{node:null}:{node:Zt(e.hasAttribute("checked"))}}function Zt(e){return Kr(new ts(void 0,e))}function ke(e){return e instanceof ts}class aa extends Mn{constructor(n="number",r=1,o){super(o);D(this,"__tag");D(this,"__start");D(this,"__listType");const i=BN[n]||n;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=r}$config(){return this.config("list",{$transform:n=>{(function(r){const o=r.getNextSibling();be(o)&&r.getListType()===o.getListType()&&ch(r,o)})(n),f1(n)},extends:Mn,importDOM:{ol:()=>({conversion:Bg,priority:0}),ul:()=>({conversion:Bg,priority:0})}})}afterCloneFrom(n){super.afterCloneFrom(n),this.__listType=n.__listType,this.__tag=n.__tag,this.__start=n.__start}getTag(){return this.getLatest().__tag}setListType(n){const r=this.getWritable();return r.__listType=n,r.__tag=n==="number"?"ol":"ul",r}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(n){const r=this.getWritable();return r.__start=n,r}createDOM(n,r){const o=this.__tag,i=document.createElement(o);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,Ug(i,n.theme,this),i}updateDOM(n,r,o){return n.__tag!==this.__tag||n.__listType!==this.__listType||(Ug(r,o.theme,this),!1)}updateFromJSON(n){return super.updateFromJSON(n).setListType(n.listType).setStart(n.start)}exportDOM(n){const r=this.createDOM(n._config,n);return pt(r)&&(this.__start!==1&&r.setAttribute("start",String(this.__start)),this.__listType==="check"&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(n,r,o){let i=o;for(let s=0;s<o.length;s++){const a=o[s];ke(a)||(i===o&&(i=[...o]),i[s]=Zt().append(!R(a)||be(a)||a.isInline()?a:rt(a.getTextContent())))}return super.splice(n,r,i)}extractWithChild(n){return ke(n)}}function Ug(e,t,n){const r=[],o=[],i=t.list;if(i!==void 0){const s=i[`${n.__tag}Depth`]||[],a=Uf(n)-1,l=a%s.length,c=s[l],u=i[n.__tag];let f;const d=i.nested,h=i.checklist;if(d!==void 0&&d.list&&(f=d.list),u!==void 0&&r.push(u),h!==void 0&&n.__listType==="check"&&r.push(h),c!==void 0){r.push(...wl(c));for(let p=0;p<s.length;p++)p!==l&&o.push(n.__tag+p)}if(f!==void 0){const p=wl(f);a>1?r.push(...p):o.push(...p)}}o.length>0&&Kx(e,...o),r.length>0&&ih(e,...r)}function UN(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(ke(r)){t.push(r);const o=r.getChildren();o.length>1&&o.forEach(i=>{be(i)&&t.push(Fg(i))})}else t.push(Fg(r))}return t}function Bg(e){const t=e.nodeName.toLowerCase();let n=null;return t==="ol"?n=Bt("number",e.start):t==="ul"&&(n=(function(r){if(r.getAttribute("__lexicallisttype")==="check"||r.classList.contains("contains-task-list")||r.getAttribute("data-is-checklist")==="1")return!0;for(const o of r.childNodes)if(pt(o)&&o.hasAttribute("aria-checked"))return!0;return!1})(e)?Bt("check"):Bt("bullet")),{after:UN,node:n}}const BN={ol:"number",ul:"bullet"};function Bt(e="number",t=1){return Kr(new aa(e,t))}function be(e){return e instanceof aa}const WN=he("UPDATE_LIST_START_COMMAND"),d1=he("INSERT_UNORDERED_LIST_COMMAND"),h1=he("INSERT_ORDERED_LIST_COMMAND"),Wf=he("REMOVE_LIST_COMMAND");function KN(e){return fn(e.registerCommand(h1,()=>(jg("number"),!0),Gn),e.registerCommand(WN,t=>{const{listNodeKey:n,newStart:r}=t,o=Xe(n);return!!be(o)&&(o.getListType()==="number"&&(o.setStart(r),f1(o)),!0)},Gn),e.registerCommand(d1,()=>(jg("bullet"),!0),Gn),e.registerCommand(Wf,()=>(DN(),!0),Gn),e.registerCommand(Ls,()=>zN(),Gn),e.registerNodeTransform(ts,t=>{const n=t.getFirstChild();if(n){if(X(n)){const r=n.getStyle(),o=n.getFormat();t.getTextStyle()!==r&&t.setTextStyle(r),t.getTextFormat()!==o&&t.setTextFormat(o)}}else{const r=Z();$(r)&&(r.style!==t.getTextStyle()||r.format!==t.getTextFormat())&&r.isCollapsed()&&t.is(r.anchor.getNode())&&t.setTextStyle(r.style).setTextFormat(r.format)}}),e.registerNodeTransform(Br,t=>{const n=t.getParent();if(ke(n)&&t.is(n.getFirstChild())){const r=t.getStyle(),o=t.getFormat();r===n.getTextStyle()&&o===n.getTextFormat()||n.setTextStyle(r).setTextFormat(o)}}))}function HN(e){const t=n=>{const r=n.getParent();if(be(n.getFirstChild())||!be(r))return;const o=at(n,i=>ke(i)&&be(i.getParent())&&ke(i.getPreviousSibling()));if(o===null&&n.getIndent()>0)n.setIndent(0);else if(ke(o)){const i=o.getPreviousSibling();if(ke(i)){const s=(function(l){let c=l,u=c.getFirstChild();for(;be(u);){const f=u.getLastChild();if(!ke(f))break;c=f,u=c.getFirstChild()}return c})(i),a=s.getParent();if(be(a)){const l=Uf(a);l+1<Uf(r)&&n.setIndent(l)}}}};return e.registerNodeTransform(aa,n=>{const r=[n];for(;r.length>0;){const o=r.shift();if(be(o)){for(const i of o.getChildren())if(ke(i)){t(i);const s=i.getFirstChild();be(s)&&r.push(s)}}}})}const qN=new Set(["http:","https:","mailto:","sms:","tel:"]);class Ho extends Mn{constructor(n="",r={},o){super(o);D(this,"__url");D(this,"__target");D(this,"__rel");D(this,"__title");const{target:i=null,rel:s=null,title:a=null}=r;this.__url=n,this.__target=i,this.__rel=s,this.__title=a}static getType(){return"link"}static clone(n){return new Ho(n.__url,{rel:n.__rel,target:n.__target,title:n.__title},n.__key)}createDOM(n){const r=document.createElement("a");return this.updateLinkDOM(null,r,n),ih(r,n.theme.link),r}updateLinkDOM(n,r,o){if(kx(r)){n&&n.__url===this.__url||(r.href=this.sanitizeUrl(this.__url));for(const i of["target","rel","title"]){const s=`__${i}`,a=this[s];n&&n[s]===a||(a?r[i]=a:r.removeAttribute(i))}}}updateDOM(n,r,o){return this.updateLinkDOM(n,r,o),!1}static importDOM(){return{a:n=>({conversion:VN,priority:1})}}static importJSON(n){return Co().updateFromJSON(n)}updateFromJSON(n){return super.updateFromJSON(n).setURL(n.url).setRel(n.rel||null).setTarget(n.target||null).setTitle(n.title||null)}sanitizeUrl(n){n=Hg(n);try{const r=new URL(Hg(n));if(!qN.has(r.protocol))return"about:blank"}catch{return n}return n}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(n){const r=this.getWritable();return r.__url=n,r}getTarget(){return this.getLatest().__target}setTarget(n){const r=this.getWritable();return r.__target=n,r}getRel(){return this.getLatest().__rel}setRel(n){const r=this.getWritable();return r.__rel=n,r}getTitle(){return this.getLatest().__title}setTitle(n){const r=this.getWritable();return r.__title=n,r}insertNewAfter(n,r=!0){const o=Co(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(o,r),o}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(n,r,o){if(!$(r))return!1;const i=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(i)&&this.isParentOf(s)&&r.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function VN(e){let t=null;if(kx(e)){const n=e.textContent;(n!==null&&n!==""||e.children.length>0)&&(t=Co(e.getAttribute("href")||"",{rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")}))}return{node:t}}function Co(e="",t){return Kr(new Ho(e,t))}function ut(e){return e instanceof Ho}class ic extends Ho{constructor(n="",r={},o){super(n,r,o);D(this,"__isUnlinked");this.__isUnlinked=r.isUnlinked!==void 0&&r.isUnlinked!==null&&r.isUnlinked}static getType(){return"autolink"}static clone(n){return new ic(n.__url,{isUnlinked:n.__isUnlinked,rel:n.__rel,target:n.__target,title:n.__title},n.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(n){const r=this.getWritable();return r.__isUnlinked=n,r}createDOM(n){return this.__isUnlinked?document.createElement("span"):super.createDOM(n)}updateDOM(n,r,o){return super.updateDOM(n,r,o)||n.__isUnlinked!==this.__isUnlinked}static importJSON(n){return Wg().updateFromJSON(n)}updateFromJSON(n){return super.updateFromJSON(n).setIsUnlinked(n.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(n,r=!0){const o=this.getParentOrThrow().insertNewAfter(n,r);if(R(o)){const i=Wg(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return o.append(i),i}return null}}function Wg(e="",t){return Kr(new ic(e,t))}function so(e){return e instanceof ic}const $i=he("TOGGLE_LINK_COMMAND");function Kg(e,t){if(e.type==="element"){const n=e.getNode();return R(n)||(function(r,...o){const i=new URL("https://lexical.dev/docs/error"),s=new URLSearchParams;s.append("code",r);for(const a of o)s.append("v",a);throw i.search=s.toString(),Error(`Minified Lexical error #${r}; visit ${i.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(252),n.getChildren()[e.offset+t]||null}return null}function cu(e,t={}){let n;if(e&&typeof e=="object"){const{url:u,...f}=e;n=u,t={...f,...t}}else n=e;const{target:r,title:o}=t,i=t.rel===void 0?"noreferrer":t.rel,s=Z();if(s===null||!$(s)&&!ot(s))return;if(ot(s)){const u=s.getNodes();return u.length===0?void 0:void u.forEach(f=>{if(n===null){const d=at(f,h=>!so(h)&&ut(h));d&&(d.insertBefore(f),d.getChildren().length===0&&d.remove())}else{const d=at(f,h=>!so(h)&&ut(h));if(d)d.setURL(n),r!==void 0&&d.setTarget(r),i!==void 0&&d.setRel(i);else{const h=Co(n,{rel:i,target:r});f.insertBefore(h),h.append(f)}}})}const a=s.extract();if(n===null){const u=new Set;return void a.forEach(f=>{const d=f.getParent();if(ut(d)&&!so(d)){const h=d.getKey();if(u.has(h))return;(function(p,g){const m=new Set(g.filter(E=>p.isParentOf(E)).map(E=>E.getKey())),y=p.getChildren(),v=y.filter(E=>m.has(E.getKey()));if(v.length===y.length)return y.forEach(E=>p.insertBefore(E)),void p.remove();const b=y.findIndex(E=>m.has(E.getKey())),A=y.findLastIndex(E=>m.has(E.getKey())),w=b===0,_=A===y.length-1;if(w)v.forEach(E=>p.insertBefore(E));else if(_)for(let E=v.length-1;E>=0;E--)p.insertAfter(v[E]);else{for(let S=v.length-1;S>=0;S--)p.insertAfter(v[S]);const E=y.slice(A+1);if(E.length>0){const S=Co(p.getURL(),{rel:p.getRel(),target:p.getTarget(),title:p.getTitle()});v[v.length-1].insertAfter(S),E.forEach(O=>S.append(O))}}})(d,a),u.add(h)}})}const l=new Set,c=u=>{l.has(u.getKey())||(l.add(u.getKey()),u.setURL(n),r!==void 0&&u.setTarget(r),i!==void 0&&u.setRel(i),o!==void 0&&u.setTitle(o))};if(a.length===1){const u=a[0],f=at(u,ut);if(f!==null)return c(f)}(function(u){const f=Z();if(!$(f))return u();const d=Ri(f),h=d.isBackward(),p=Kg(d.anchor,h?-1:0),g=Kg(d.focus,h?0:-1);if(u(),p||g){const m=Z();if($(m)){const y=m.clone();if(p){const v=p.getParent();v&&y.anchor.set(v.getKey(),p.getIndexWithinParent()+(h?1:0),"element")}if(g){const v=g.getParent();v&&y.focus.set(v.getKey(),g.getIndexWithinParent()+(h?0:1),"element")}Pt(Ri(y))}}})(()=>{let u=null;for(const f of a){if(!f.isAttached())continue;const d=at(f,ut);if(d){c(d);continue}if(R(f)){if(!f.isInline())continue;if(ut(f)){if(!(so(f)||u!==null&&u.getParentOrThrow().isParentOf(f))){c(f),u=f;continue}for(const p of f.getChildren())f.insertBefore(p);f.remove();continue}}const h=f.getPreviousSibling();ut(h)&&h.is(u)?h.append(f):(u=Co(n,{rel:i,target:r,title:o}),f.insertAfter(u),u.append(f))}})}const YN=/^\+?[0-9\s()-]{5,}$/;function Hg(e){return e.match(/^[a-z][a-z0-9+.-]*:/i)||e.match(/^[/#.]/)?e:e.includes("@")?`mailto:${e}`:YN.test(e)?`tel:${e}`:`https://${e}`}function QN(e,t){return fn($s(()=>e.registerCommand($i,n=>{const r=t.validateUrl.peek(),o=t.attributes.peek();if(n===null)return cu(null),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(cu(n,o),!0);{const{url:i,target:s,rel:a,title:l}=n;return cu(i,{...o,rel:a,target:s,title:l}),!0}},Gn)),$s(()=>{const n=t.validateUrl.value;if(!n)return;const r=t.attributes.value;return e.registerCommand(Gl,o=>{const i=Z();if(!$(i)||i.isCollapsed()||!kr(o,ClipboardEvent)||o.clipboardData===null)return!1;const s=o.clipboardData.getData("text");return!!n(s)&&!i.getNodes().some(a=>R(a))&&(e.dispatchCommand($i,{...r,url:s}),o.preventDefault(),!0)},Gn)}))}function GN({commentType:e,onCommentTypeChange:t,isCommentTypeEditable:n=!0,actions:r,setIsLinkEditMode:o,onAddAttachments:i}){const[s]=ht(),[a,l]=T.useState({bold:!1,italic:!1,underline:!1,strikethrough:!1,code:!1}),[c,u]=T.useState(null),f=T.useRef(null),d=T.useRef(null),h=uh[e];T.useLayoutEffect(()=>s.registerUpdateListener(({editorState:v})=>{v.read(()=>{const b=Z();if(!$(b))return;l({bold:b.hasFormat("bold"),italic:b.hasFormat("italic"),underline:b.hasFormat("underline"),strikethrough:b.hasFormat("strikethrough"),code:b.hasFormat("code")});let A=b.anchor.getNode(),w=null;for(;A;){if(be(A)){const _=A.getListType();w=_==="bullet"||_==="number"?_:null;break}if(ke(A)){A=A.getParent();continue}A=A.getParent()}u(w)})}),[s]);const p=v=>{s.dispatchCommand(_n,v)},g=()=>{c!=="bullet"?s.dispatchCommand(d1,void 0):s.dispatchCommand(Wf,void 0)},m=()=>{c!=="number"?s.dispatchCommand(h1,void 0):s.dispatchCommand(Wf,void 0)},y=()=>{s.update(()=>{const v=Z();if(!$(v))return;["bold","italic","underline","strikethrough","code"].forEach(A=>{v.hasFormat(A)&&s.dispatchCommand(_n,A)})})};return x.jsxs("div",{className:Ee("flex items-center w-full",r?"justify-between":"justify-end"),children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(ff,{placement:"top-start",minWidth:"fit-content",title:"text formatting menu",trigger:x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",children:x.jsx(Ce,{icon:E4})}),children:x.jsxs("ul",{className:"flex items-start flex-col",children:[x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Bold",onClick:()=>p("bold"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.bold?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:y4,className:"mr-2"}),"Bold"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Italic",onClick:()=>p("italic"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.italic?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:x4,className:"mr-2"}),"Italic"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Underline",onClick:()=>p("underline"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.underline?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:g4,className:"mr-2"}),"Underline"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Strikethrough",onClick:()=>p("strikethrough"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.strikethrough?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:m4,className:"mr-2"}),"Strikethrough"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Monospace",onClick:()=>p("code"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.code?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:A4,className:"mr-2"}),"Monospace"]})}),x.jsx("hr",{className:"w-full border-gray-200"}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Clear formatting",onClick:y,className:"cursor-pointer w-full h-full justify-start text-left p-2 text-gray-400 hover:text-gray-400 hover:bg-gray-100",children:[x.jsx(Ce,{icon:b4,className:"mr-2"}),"Clear formatting"]})})]})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format bullet list",onClick:g,children:x.jsx(Ce,{icon:S4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format numbered list",onClick:m,children:x.jsx(Ce,{icon:w4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format link",onClick:()=>{o(!0),s.dispatchCommand($i,"https://")},children:x.jsx(Ce,{icon:_4})}),i&&x.jsxs(x.Fragment,{children:[x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Add image",className:"border-l-1 border-gray-200 rounded-none",onClick:()=>{var v;(v=f.current)==null||v.click()},children:x.jsx(Ce,{icon:v4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Add file",onClick:()=>{var v;(v=d.current)==null||v.click()},children:x.jsx(Ce,{icon:C4})})]}),n&&x.jsx(ff,{placement:"top-end",title:"comment type menu",trigger:x.jsx(je,{category:"link",size:"smallCollapse",className:`${h.iconColor} border-l-1 border-gray-200 rounded-none`,children:x.jsx(Ce,{icon:h.icon})}),children:x.jsx("ul",{className:"flex items-center justify-between gap-2 p-3",children:m1.map(v=>x.jsx("li",{children:x.jsx(je,{category:"link",size:"none",title:v.title,className:Ee(v.color,e===v.type?v.color:"text-gray-400"),onClick:()=>t==null?void 0:t(v.type),children:x.jsx(Ce,{icon:v.icon})})},v.type))})})]}),r,x.jsx("input",{type:"file",hidden:!0,id:"image-input",multiple:!0,ref:f,accept:"image/*",onChange:v=>{const b=v.target.files;b&&(i==null||i(b))}}),x.jsx("input",{type:"file",hidden:!0,id:"file-input",multiple:!0,ref:d,accept:"*",onChange:v=>{const b=v.target.files;b&&(i==null||i(b))}})]})}function ZN({hasStrictIndent:e=!1}){const[t]=ht();return T.useEffect(()=>{if(!t.hasNodes([aa,ts]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[t]),T.useEffect(()=>{if(e)return HN(t)},[t,e]),(function(n){T.useEffect(()=>KN(n),[n])})(t),null}function JN({validateUrl:e,attributes:t}){const[n]=ht();return T.useEffect(()=>{if(!n.hasNodes([Ho]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),T.useEffect(()=>QN(n,Yx({attributes:t,validateUrl:e})),[n,e,t]),null}const XN=new Set(["http:","https:","mailto:","sms:","tel:"]);function qg(e){try{const t=new URL(e);if(!XN.has(t.protocol))return"about:blank"}catch{return e}return e}function Vg(e,t,n,r=10,o=5){const i=n.parentElement;if(e===null||!i){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}const s=t.getBoundingClientRect(),a=n.getBoundingClientRect(),l=i.getBoundingClientRect();let c=e.top-r,u=e.left-o;c<l.top&&(c+=s.height+e.height+r*2),u+s.width>l.right&&(u=l.right-s.width-o),c-=a.top,u-=a.left,t.style.opacity="1",t.style.transform=`translate(${u}px, ${c}px)`}function Al(e){const t=e.anchor,n=e.focus,r=e.anchor.getNode(),o=e.focus.getNode();return r===o?r:e.isBackward()?gg(n)?r:o:gg(t)?r:o}function e5({editor:e,isLink:t,setIsLink:n,anchorElem:r,isLinkEditMode:o,setIsLinkEditMode:i}){const s=T.useRef(null),[a,l]=T.useState(""),[c,u]=T.useState("https://"),[f,d]=T.useState(null),h=T.useCallback(()=>{var w,_;const m=Z();if($(m)){const E=Al(m),S=at(E,ut);S?l(S.getURL()):ut(E)?l(E.getURL()):l(""),o&&u(a)}else if(ot(m)){const E=m.getNodes();if(E.length>0){const S=E[0],O=S.getParent();ut(O)?l(O.getURL()):ut(S)?l(S.getURL()):l(""),o&&u(a)}}const y=s.current,v=en(e._window),b=document.activeElement;if(y===null)return;const A=e.getRootElement();if(m!==null&&A!==null&&e.isEditable()){let E;if(ot(m)){const S=m.getNodes();if(S.length>0){const O=e.getElementByKey(S[0].getKey());O&&(E=O.getBoundingClientRect())}}else v!==null&&A.contains(v.anchorNode)&&(E=(_=(w=v.focusNode)==null?void 0:w.parentElement)==null?void 0:_.getBoundingClientRect());E&&(E.y+=40,Vg(E,y,r)),d(m)}else(!b||b.className!=="link-input")&&(A!==null&&Vg(null,y,r),d(null),i(!1),l(""));return!0},[r,e,i,o,a]);T.useEffect(()=>{const m=r.parentElement,y=()=>{e.getEditorState().read(()=>{h()})};return window.addEventListener("resize",y),m&&m.addEventListener("scroll",y),()=>{window.removeEventListener("resize",y),m&&m.removeEventListener("scroll",y)}},[r.parentElement,e,h]),T.useEffect(()=>fn(e.registerUpdateListener(({editorState:m})=>{m.read(()=>{h()})}),e.registerCommand(Ql,()=>(h(),!0),Gn),e.registerCommand(Rd,()=>t?(n(!1),!0):!1,J3)),[e,h,n,t]),T.useEffect(()=>{e.getEditorState().read(()=>{h()})},[e,h]),T.useEffect(()=>{const m=s.current;if(m===null)return;const y=v=>{!m.contains(v.relatedTarget)&&t&&(n(!1),i(!1))};return m.addEventListener("focusout",y),()=>{m.removeEventListener("focusout",y)}},[n,i,t]);const p=m=>{m.key==="Enter"?g(m):m.key==="Escape"&&(m.preventDefault(),i(!1))},g=m=>{m.preventDefault(),f!==null&&(a!==""&&e.update(()=>{e.dispatchCommand($i,qg(c));const y=Z();if($(y)){const v=Al(y).getParent();if(so(v)){const b=Co(v.getURL(),{rel:v.__rel,target:v.__target,title:v.__title});v.replace(b,!0)}}}),u("https://"),i(!1))};return x.jsx("div",{ref:s,className:"absolute flex top-0 left-0 shadow-lg bg-white z-10 rounded-sm w-full max-w-400",children:t?o?x.jsxs("div",{className:"flex justify-between w-full items-center p-2",children:[x.jsx(ky,{containerClassName:"px-0 mr-2",autoFocus:!0,className:"mt-0",value:c,onChange:m=>{u(m.target.value)},onKeyDown:m=>{p(m)}}),x.jsxs("div",{className:"flex justify-center items-center gap-4",children:[x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>{i(!1)},children:x.jsx(Ce,{icon:Dl})}),x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:g,children:x.jsx(Ce,{icon:Fy})})]})]}):x.jsxs("div",{className:"flex justify-between w-full items-center p-2",children:[x.jsx("a",{href:qg(a),target:"_blank",rel:"noopener noreferrer",children:a}),x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>{u(a),i(!0)},children:x.jsx(Ce,{icon:WC})}),x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>e.dispatchCommand($i,null),children:x.jsx(Ce,{icon:e_})})]})]}):null})}function t5(e,t,n,r){const[o,i]=T.useState(e),[s,a]=T.useState(!1);return T.useEffect(()=>{function l(){const c=Z();if($(c)){const u=Al(c),f=at(u,ut),d=at(u,so);if(!(f||d)){a(!1);return}const h=c.getNodes().filter(p=>!xo(p)).find(p=>{const g=at(p,ut),m=at(p,so);return f&&!f.is(g)||g&&!g.is(f)||d&&!d.is(m)||m&&(!m.is(d)||m.getIsUnlinked())});a(!h)}else if(ot(c)){const u=c.getNodes();if(u.length===0){a(!1);return}const f=u[0],d=f.getParent();ut(d)||ut(f)?a(!0):a(!1)}}return fn(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{l()})}),e.registerCommand(Ql,(c,u)=>(l(),i(u),!1),fx),e.registerCommand(Md,c=>{const u=Z();if($(u)){const f=Al(u),d=at(f,ut);if(ut(d)&&(c.metaKey||c.ctrlKey))return window.open(d.getURL(),"_blank"),!0}return!1},Gn))},[e]),Nn.createPortal(x.jsx(e5,{editor:o,isLink:s,anchorElem:t,setIsLink:a,isLinkEditMode:n,setIsLinkEditMode:r}),t)}function n5({anchorElem:e=document.body,isLinkEditMode:t,setIsLinkEditMode:n}){const[r]=ht();return t5(r,e,t,n)}const r5=({url:e,onDelete:t})=>x.jsxs("div",{className:"relative",children:[x.jsx("img",{src:e,alt:"Thumbnail",width:75,height:75,className:"w-[75px] h-[75px] object-cover rounded-lg border border-gray-200"}),x.jsx(je,{size:"smallCollapse",title:"Delete attachment",onClick:t,className:"absolute top-1 left-1 w-[20px] h-[20px] rounded-full",color:"secondary",children:x.jsx(Ce,{icon:Dy})})]}),o5=({onRemoveFile:e,type:t,label:n})=>{const r=t.toLowerCase(),o=Pv(r);return x.jsxs("div",{className:"relative flex items-center justify-center rounded border border-gray-200",children:[x.jsx(je,{size:"smallCollapse",color:"secondary",className:"absolute top-1 left-1 w-[20px] h-[20px] rounded-full",title:"Remove file",onClick:e,children:x.jsx(Ce,{icon:Dy})}),x.jsxs("div",{className:"flex items-center justify-center mx-2",children:[x.jsx("span",{className:"text-primary-600 my-2",children:x.jsx(Ce,{icon:o,size:"3x",className:"text-primary-600"})}),x.jsx("span",{className:"font-bold p-2",children:n})]})]})},i5=({clearKey:e})=>{const[t]=ht(),n=T.useRef(e);return T.useEffect(()=>{n.current!==e&&(t.update(()=>{We().clear()}),n.current=e)},[e,t]),null},s5=({isOpen:e})=>{const[t]=ht(),n=T.useRef(!1);return T.useEffect(()=>{if(!e){n.current=!1;return}if(n.current)return;const r=()=>{const o=t.getRootElement();if(!o){requestAnimationFrame(r);return}n.current=!0;const i=window.scrollX,s=window.scrollY;try{o.focus({preventScroll:!0})}catch{o.focus()}requestAnimationFrame(()=>window.scrollTo(i,s)),setTimeout(()=>window.scrollTo(i,s),0)};r()},[t,e]),null},a5=({initialValue:e})=>{const[t]=ht(),n=T.useCallback((o,i)=>{const a=new DOMParser().parseFromString(i,"text/html");return Xx(o,a)},[]),r=T.useRef(!1);return T.useEffect(()=>{!r.current&&e&&(t.update(()=>{We().clear(),ox(n(t,e))}),r.current=!0)},[t,e,n]),null},l5=({onChange:e})=>{const[t]=ht();return x.jsx(ON,{onChange:n=>{n.read(()=>{const r=e1(t,null);e(r)})}})},c5=({onAddAttachments:e})=>{const[t]=ht();return T.useEffect(()=>{if(!e)return;const n=t.getRootElement();if(!n)return;const r=o=>{const i=o.clipboardData;if(!i)return;const s=i.items;let a=!1;for(let l=0;l<s.length;l++){const c=s[l];if(c.kind==="file"&&c.type.startsWith("image/")){a=!0;break}}if(a){for(let l=0;l<s.length;l++){const c=s[l];if(c.kind==="file"&&c.type.startsWith("image/")){const u=c.getAsFile();if(u){const f=Date.now(),d=u.type.split("/")[1]||"png",h=`image_${f}.${d}`,p=new File([u],h,{type:u.type});e==null||e([p])}}}o.preventDefault(),o.stopPropagation()}};return n.addEventListener("paste",r,!0),()=>{n.removeEventListener("paste",r,!0)}},[t,e]),null},u5=({onSubmit:e})=>{const[t]=ht();return T.useEffect(()=>{if(e)return t.registerCommand(Fs,n=>n&&!n.shiftKey?(n.preventDefault(),e(),!0):!1,1)},[t,e]),null},f5=({setIsLinkEditMode:e})=>{const[t]=ht();return T.useEffect(()=>{const n=t.getRootElement();if(!n)return;const r=o=>{const i=o.metaKey||o.ctrlKey,s=o.key==="k"||o.key==="K";i&&s&&t.getEditorState().read(()=>{const a=Z();$(a)&&!a.isCollapsed()&&(o.preventDefault(),e(!0),t.dispatchCommand($i,"https://"))})};return n.addEventListener("keydown",r),()=>{n.removeEventListener("keydown",r)}},[t,e]),null};function p1({attachments:e,clearKey:t=0,inputFieldClassName:n="",containerClassName:r="",initialValue:o,onChange:i,commentType:s,onCommentTypeChange:a,isCommentTypeEditable:l=!0,actions:c,onAddAttachments:u,onRemoveAttachment:f,onSubmit:d,isOpen:h}){const p={namespace:"comment-editor",theme:RN,nodes:[aa,ts,Ho],onError:w=>{console.error(w)}},[g,m]=T.useState(null),[y,v]=T.useState(!1),b=w=>{w!==null&&m(w)},A=uh[s];return x.jsx("div",{className:r,children:x.jsxs(T6,{initialConfig:p,children:[x.jsxs("div",{className:"relative",children:[x.jsx(bN,{contentEditable:x.jsx("div",{ref:b,children:x.jsx(SN,{className:Ee("p-3 outline-none border-0 w-full border-t border-gray-200 rounded-none border-l-3",A.bg,A.border,A.fontColor,n)})}),placeholder:x.jsx("div",{className:"absolute top-3 left-4 text-gray-400 pointer-events-none",children:"Type comment…"}),ErrorBoundary:LN}),x.jsx(ZN,{}),x.jsx(JN,{}),g&&x.jsx(n5,{anchorElem:g,isLinkEditMode:y,setIsLinkEditMode:v}),x.jsx(CN,{}),x.jsx(a5,{initialValue:o}),x.jsx(l5,{onChange:i}),x.jsx(u5,{onSubmit:d}),x.jsx(f5,{setIsLinkEditMode:v}),x.jsx(i5,{clearKey:t}),x.jsx(c5,{onAddAttachments:u}),x.jsx(s5,{isOpen:h})]}),e&&e.length>0&&x.jsx("div",{className:"flex flex-wrap justify-start gap-2 p-4",children:e.map(w=>md(w.type)?x.jsx(r5,{url:w.url,onDelete:()=>f==null?void 0:f(w.originFile)},w.originFile.name):x.jsx(o5,{type:w.type,label:w.name,onRemoveFile:()=>f==null?void 0:f(w.originFile)},w.originFile.name))}),x.jsx("div",{className:"border-t border-gray-200 p-2 flex justify-end",children:x.jsx(GN,{commentType:s,onCommentTypeChange:a,isCommentTypeEditable:l,actions:c,setIsLinkEditMode:v,onAddAttachments:u})})]})})}const d5=({asset:e,onSetActiveSrc:t})=>x.jsxs("div",{className:"relative border border-gray-200 rounded-md h-[110px] w-full hover:border-primary-500",children:[x.jsx("img",{src:$a(e),onClick:()=>t($a(e)),onKeyDown:n=>{n.key==="Enter"&&t($a(e))},alt:e.name,className:"w-full h-full object-cover rounded-md object-center cursor-zoom-in"}),(e==null?void 0:e.uploading)&&x.jsx("div",{className:"absolute bottom-2 w-full max-w-md mx-auto px-2",children:x.jsx("div",{className:"relative h-2 overflow-hidden rounded-full bg-gray-200",children:x.jsx("div",{className:"absolute left-0 top-0 h-full w-1/3 rounded-full bg-blue-500 animate-progress"})})})]}),h5=({asset:e})=>{var r,o;const t=((o=(r=e==null?void 0:e.mimeType)==null?void 0:r.split("/").pop())==null?void 0:o.toLowerCase())||"",n=Pv(t);return x.jsxs("div",{className:"flex gap-2",children:[(e==null?void 0:e.uploading)&&x.jsx("div",{className:"flex items-center justify-center",children:x.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-gray-300 border-t-blue-500 animate-spin"})}),x.jsx(Ce,{icon:n,size:"lg",className:"text-primary-600"}),x.jsx("a",{href:$a(e),className:"text-sm text-blue-600 underline",download:!0,target:"_blank",rel:"noopener noreferrer",children:e.name})]})},p5=({commentType:e=dt.INFO,author:t,username:n,comment:r,createdDate:o,onDelete:i,onEdit:s,hasAssets:a,taskAssets:l,taskVerified:c})=>{const f={[dt.INFO]:{bg:"bg-primary-100",border:"border-primary-200",icon:Ly,iconColor:"text-primary-600 hover:text-primary-600",text:"text-primary-900"},[dt.WARNING]:{bg:"bg-warning-100",border:"border-warning-200",icon:Oy,iconColor:"text-warning-600 hover:text-warning-600",text:"text-warning-900"},[dt.DANGER]:{bg:"bg-danger-100",border:"border-danger-200",icon:jy,iconColor:"text-danger-600 hover:text-danger-600",text:"text-danger-900"},[dt.SUCCESS]:{bg:"bg-success-100",border:"border-success-200",icon:My,iconColor:"text-success-600 hover:text-success-600",text:"text-success-900"}}[e],d=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(o||"")).replace(",",""),[h,p]=T.useState(!1),[g,m]=T.useState(zc(r)),[y,v]=T.useState(e),[b,A]=T.useState(""),w=()=>{p(!0)},_=()=>{const O=of.sanitize(g);s(O,y),p(!1)},E=O=>{const P=of.sanitize(g);v(O),s(P,O),p(!1)},S=()=>{p(!1)};return x.jsxs("div",{className:"flex items-start space-x-4 w-full",children:[x.jsx(jT,{alt:t}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:`border ${f.border} rounded-sm ${f.bg} shadow-sm flex flex-col items-start justify-between w-full`,children:[x.jsx("div",{className:"p-3 flex flex-col items-start justify-between w-full",children:x.jsxs("div",{className:"w-full",children:[x.jsxs("div",{className:"flex items-center mb-2 justify-between",children:[x.jsxs("div",{children:[x.jsx(Ce,{icon:f.icon,size:"lg",className:`mr-2 ${f.iconColor}`}),x.jsx("span",{className:`font-semibold text-sm ${f.text}`,children:t})]}),x.jsx($T,{commentType:e,taskVerified:c,isUsernameAuthor:n.trim()===t.trim(),onEdit:w,onSaveCommentType:E,onDelete:i})]}),h?x.jsx(p1,{inputFieldClassName:"bg-white border-0 rounded-sm",containerClassName:"bg-white border-0 rounded-sm",onChange:m,commentType:e,isCommentTypeEditable:!1,initialValue:zc(r),actions:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(je,{category:"outline",size:"smallCollapse",color:"secondary",onClick:S,title:"Cancel edit",children:"Cancel"}),x.jsx(je,{category:"solid",size:"smallCollapse",color:"primary",onClick:_,title:"Save edit",disabled:Ua(g),children:"Save"})]})}):x.jsx("div",{className:`text-sm ${f.text}`,dangerouslySetInnerHTML:{__html:zc(r)}})]})}),a&&l&&(l==null?void 0:l.length)>0&&x.jsx("div",{className:`${f.border} border-t w-full p-2 flex gap-2 flex-wrap`,children:l.map(O=>x.jsx(T.Fragment,{children:md(O.mimeType)?x.jsx(d5,{asset:O,onSetActiveSrc:A}):x.jsx(h5,{asset:O})},O.assetId))})]}),x.jsxs("div",{className:"flex gap-2 my-1",children:[o&&x.jsx("time",{dateTime:o,className:"text-xs text-gray-500 opacity-60",children:d}),c&&x.jsxs("span",{className:"text-xs text-success-600 font-semibold flex items-center gap-1",children:[x.jsx(Ce,{icon:Iy}),"Comment Required"]})]})]}),x.jsx(bT,{plugins:[DT],open:!!b,zoom:{maxZoomPixelRatio:2},close:()=>A(""),styles:{root:{zIndex:9999999999}},carousel:{finite:!0,preload:0},controller:{closeOnBackdropClick:!0},slides:[{src:b}]})]})},uh={[dt.INFO]:{icon:r_,bg:"bg-primary-100",border:"border-l-primary-500",iconColor:"text-primary-600 hover:text-primary-700",fontColor:"text-primary-900"},[dt.WARNING]:{icon:KC,bg:"bg-warning-100",border:"border-l-warning-500",iconColor:"text-warning-600 hover:text-warning-700",fontColor:"text-warning-900"},[dt.DANGER]:{icon:s_,bg:"bg-danger-100",border:"border-l-danger-500",iconColor:"text-danger-600 hover:text-danger-700",fontColor:"text-danger-900"},[dt.SUCCESS]:{icon:Iy,bg:"bg-success-100",border:"border-l-success-500",iconColor:"text-success-600 hover:text-success-700",fontColor:"text-success-900"}},m1=Object.entries(uh).map(([e,t])=>({type:e,icon:t.icon,color:t.iconColor,title:`Change comment type to ${e}`})),m5=({comments:e,onClose:t,isOpen:n,taskName:r,taskInstanceId:o,isLoading:i,playbookInstanceId:s,taskVerification:a})=>{const[l,c]=T.useState(""),[u,f]=T.useState(dt.INFO),[d,h]=T.useState(0),[p,g]=T.useState([]),m=T.useRef(null),{username:y}=g1(),{manageComment:v}=ak({playbookInstanceId:s}),b=()=>{const P=p.length,W=p.some(z=>!md(z.mimeType))?"Attachment":"Image",j=P>1?"s":"";return`<p class="m-0"><span style="white-space: pre-wrap;">${W}${j} added.</span></p>`},A=P=>{const I=Array.from(P).map((W,j)=>J4(W,p.length+j+1));g(W=>[...W,...I])},w=P=>{g(I=>I.filter(W=>W.originFile!==P))},_=P=>{f(P)},E=async()=>{if(!p.length&&Ua(l)||!o)return;p.length>0&&g([]);const P=of.sanitize(l);c(""),h(I=>I+1),await v({action:"add",comment:p.length>0&&Ua(l)?b():P,username:y||"",commentType:u,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,hasAssets:p.length>0,taskInstanceId:o,taskVerified:a,attachments:p}),f(dt.INFO)},S=async P=>{o&&await v({username:y||"",action:"delete",taskVerified:!1,taskInstanceId:o,commentId:P})},O=async({commentId:P,comment:I,commentType:W,hasAssets:j,isAlreadyVerified:z})=>{o&&await v({action:"edit",username:y||"",...I&&{comment:I},taskInstanceId:o,commentId:P,hasAssets:j,taskVerified:z,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,commentType:W})};return T.useLayoutEffect(()=>{m.current&&n&&!i&&e.length>0&&(m.current.scrollTop=m.current.scrollHeight)},[n,i,e.length]),x.jsxs("div",{className:Ee("transition-all duration-300 fixed bg-white right-0 bottom-0 h-[100vh] z-[9999999998] flex flex-col min-w-[270px] max-w-[420px] w-[calc(100vw-1rem)] border border-gray-200 rounded-t-sm overflow-hidden",n?"translate-y-0 opacity-100":"translate-y-full opacity-0 pointer-events-none"),children:[x.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-200 px-2 py-4 w-full",children:[x.jsx("h6",{className:"font-semibold text-gray-900 truncate max-w-[300px]",children:r}),x.jsx(je,{color:"grayLight",size:"smallCollapse",rounded:"none",title:"Close comment box",onClick:t,children:x.jsx(Ce,{icon:Dl,className:"size-4 text-gray-300"})})]}),x.jsxs("div",{ref:m,className:"flex flex-col flex-1 overflow-y-auto",children:[x.jsxs("div",{className:"flex flex-col justify-end flex-1 gap-4 p-4 pb-[102px]",children:[i&&x.jsx("div",{className:"flex flex-col gap-3",children:[1,2,3].map(P=>x.jsx("div",{className:"h-16 animate-pulse rounded-lg bg-gray-100"},P))}),(e==null?void 0:e.length)>0&&!i&&e.map(P=>x.jsx(p5,{username:y||"",onDelete:()=>S(P.commentId),onEdit:(I,W)=>O({commentId:P.commentId,comment:I,commentType:W,hasAssets:P.hasAssets,isAlreadyVerified:P.taskVerified}),...P},P.commentId)),(e==null?void 0:e.length)===0&&!i&&x.jsxs("div",{className:"flex flex-1 flex-col items-center justify-end gap-3 text-center mb-1",children:[x.jsx("img",{src:G4,className:"opacity-70",alt:"Empty"}),x.jsx("p",{className:"text-gray-400",children:"There is no discussion in this Task."})]})]}),x.jsx(p1,{attachments:p,onChange:c,containerClassName:"fixed bottom-0 left-0 right-0 bg-white",clearKey:d,commentType:u,onCommentTypeChange:_,onAddAttachments:A,onRemoveAttachment:w,onSubmit:E,isOpen:n,actions:x.jsx(je,{category:"link",size:"normalCollapse",title:"Send comment",onClick:E,disabled:Ua(l)&&p.length===0,children:x.jsx(Ce,{icon:k4})})})]})]})},Kf=T.createContext({comments:[],openTaskDetails:null,username:void 0,setOpenTaskDetails:()=>{},prefetchQuery:e=>{}}),g1=()=>{if(!T.useContext(Kf))throw new Error("useCommentContext must be used within a CommentProvider");return T.useContext(Kf)},g5=({playbookInstanceId:e,children:t,username:n})=>{const[r,o]=T.useState({taskInstanceId:null,taskName:"",taskVerification:!1}),{taskInstanceId:i,taskName:s,taskVerification:a}=r||{taskInstanceId:null,taskName:"",taskVerification:!1},{comments:l,isLoading:c,prefetchQuery:u}=rk({taskInstanceId:i||0,enabled:i!==null,username:n});return x.jsxs(Kf.Provider,{value:{comments:l,openTaskDetails:r,setOpenTaskDetails:o,prefetchQuery:u,username:n},children:[t,Nn.createPortal(x.jsxs("div",{id:"cnfdnc-comment-box-root",children:[x.jsx("style",{children:qs}),x.jsx("div",{className:"confidence-playbook",children:x.jsx(m5,{playbookInstanceId:e,comments:l,onClose:()=>o(null),isOpen:!!i,taskName:s,taskInstanceId:i,isLoading:c,taskVerification:a})})]}),T4)]})},y5={[Be.OPEN]:"border-[#C1C5C8] bg-[#F0F1F2]",[Be.IN_PROGRESS]:"bg-[#E6F2FF] border-[#94C8FF]",[Be.IN_REVIEW]:"bg-[#EAF6EC] border-[#A5DAB1]",[Be.COMPLETED]:"bg-[#EAF6EC] border-[#A5DAB1]"},Bn={PHOTO:"photo",SCREENSHOT:"screenshot",COMMENT:"comment",NO_VERIFICATION:null},v5=({task:e,step:t,playbookType:n,onButtonClick:r,viewMode:o="card",canStart:i=!1,isExpanded:s=!1,toggleExpanded:a,playbookId:l,taskStyle:c,listStickyTopBase:u})=>{const[f,d]=T.useState(!1),{taskDetails:h,prefetchQuery:p}=OS({taskId:e.taskId,playbookId:l,enabled:s}),{setOpenTaskDetails:g,prefetchQuery:m}=g1(),{buttons:y}=zw({taskStatus:e.workflowStatus,canStart:i}),v=T.useMemo(()=>e.imageRequired===0?Bn.NO_VERIFICATION:e.imageRequired===1?Bn.SCREENSHOT:e.imageRequired===2?Bn.PHOTO:e.imageRequired===4?Bn.COMMENT:null,[e.imageRequired]),b=async A=>{try{d(!0),await r(A)}finally{d(!1)}};if(o==="list"){const A=T.useMemo(()=>e.workflowStatus===Be.COMPLETED?"success":e.workflowStatus===Be.IN_PROGRESS?"primary":"default",[e.workflowStatus]),w=T.useMemo(()=>{const _=[];return y.forEach(E=>{E==="START"&&_.push({id:"START",color:"primary",action:"Start",to:Be.IN_PROGRESS}),E==="COMPLETE"&&(!e.taskVerified&&v===Bn.COMMENT&&_.push({id:"ADD_COMMENT",color:"danger",action:"Add Comment",to:"Required"}),_.push({id:"COMPLETE",color:"success",action:"Complete",to:Be.COMPLETED,disabled:!e.taskVerified&&v===Bn.COMMENT}))}),_},[y,v,e.taskVerified]);return x.jsxs("div",{className:Ee("flex flex-col"),children:[x.jsxs("div",{className:Ee("flex items-center gap-3 p-2 border-gray-200",e.sequenceOrder>0&&"border-t",s&&"bg-white rounded-md border border-t-none shadow-sm sticky"),style:{top:s?u:0},children:[x.jsx("div",{className:"text-gray-200 text-base",children:e.sequenceOrder+1}),x.jsx("div",{onClick:()=>{a==null||a(!s)},onMouseOver:p,className:Ee("flex-1 truncate cursor-pointer",s&&"font-medium",e.workflowStatus===Be.COMPLETED&&"text-secondary-400 line-through"),style:{color:e.workflowStatus===Be.IN_PROGRESS&&(c==null?void 0:c.titleColor)||"#1C232D"},children:e.taskInstanceName}),x.jsx(a4,{taskVerified:e.taskVerified,verificationType:v,title:e.workflowStatus,variant:A,transitions:w,onClick:_=>{if(_===ui.ADD_COMMENT){g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!0});return}r(_)}}),x.jsx(Yp,{onMouseOver:()=>m(e.taskInstanceId),commentsCount:(e==null?void 0:e.numberOfComments)||0,commentType:(e==null?void 0:e.recentCommentType)||dt.INFO,onClick:()=>g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!1})})]}),(h==null?void 0:h.description)&&x.jsx("div",{className:Ee(!s&&"hidden","border-gray-200 border p-2 mx-4 mb-4 border-t-none -mt-[1px] bg-gray-100 rounded-b-md"),children:x.jsx(Vp,{description:(h==null?void 0:h.description)||""})})]})}return x.jsxs("div",{className:Ss("flex items-stretch rounded-sm overflow-hidden border",y5[e.workflowStatus]),children:[x.jsx(f4,{playbookType:n,status:e.workflowStatus,step:t}),x.jsxs("div",{className:"flex w-full flex-col overflow-x-hidden flex-1 p-2",children:[n==="Sequential"&&x.jsx("div",{className:"-mb-3 self-end pr-2 pt-2",children:x.jsx(h4,{status:e.workflowStatus})}),x.jsxs("div",{className:"space-y-2 divide-y divide-black/10 flex flex-col flex-1",children:[x.jsx("div",{className:Ee("text-lg font-medium flex-1 pb-1"),style:{color:e.workflowStatus==="Completed"?"#1C232D":(c==null?void 0:c.titleColor)||"#1C232D"},children:e.taskInstanceName}),v?x.jsxs("div",{className:"flex items-center gap-2 text-sm pb-2",children:[x.jsx(Ce,{icon:Py,className:"size-4"}),x.jsxs("div",{children:[x.jsx("span",{className:"font-medium",children:v===Bn.PHOTO?"Photo":v===Bn.SCREENSHOT?"Screenshot":"Comment"})," ","required"]})]}):x.jsx(x.Fragment,{})]}),(h==null?void 0:h.description)&&x.jsx("div",{className:Ee(!s&&"hidden"),children:x.jsx(Vp,{description:(h==null?void 0:h.description)||""})}),(y.length>0||e.hasDescription)&&x.jsxs("div",{className:"flex items-center justify-end gap-4 border-t border-black/10 pt-2",children:[x.jsx("div",{className:"flex-1",children:x.jsx(PS,{buttons:y,onButtonClick:b,disabled:f})}),x.jsx(Yp,{onMouseOver:()=>m(e.taskInstanceId),commentsCount:(e==null?void 0:e.numberOfComments)||0,commentType:(e==null?void 0:e.recentCommentType)||dt.INFO,onClick:()=>g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!1})}),a&&x.jsx(je,{size:"smallCollapse",onMouseOver:p,category:"link",onClick:()=>{a()},title:s?"Hide task description":"Show task description",children:x.jsx(Ce,{icon:Ry,className:Ss("cursor-pointer text-[#0069D9]",s?"rotate-180":"")})})]})]})]})},y1=T.forwardRef(({title:e,className:t,playbookStyle:n,...r},o)=>{var i,s,a;return x.jsx("div",{ref:o,className:Ee("border-b border-gray-200 flex items-center",t),style:{backgroundColor:((i=n==null?void 0:n.whiteLabel)==null?void 0:i.titleBackgroundColor)||"#f8f9fa"},...r,children:x.jsx("div",{className:Ee("text-xl min-h-16 p-4 font-medium flex-1",{"text-dark":!((s=n==null?void 0:n.whiteLabel)!=null&&s.titleTextColor)}),style:{color:(a=n==null?void 0:n.whiteLabel)==null?void 0:a.titleTextColor},children:e})})});y1.displayName="PlaybookHeader";const b5=({playbookInstanceId:e,playbookMode:t,playbookStyle:n})=>{const{playbook:r,actions:o}=Fw(e);if(!r)return x.jsx("div",{});const i=async(s,a)=>{var l;if(s===ui.COMPLETE){const c=(l=r.tasks.find(u=>u.taskInstanceId===a))==null?void 0:l.sequenceOrder;if(c===void 0){console.error("Task not found in playbook");return}return o.completeTask(a,c)}if(s===ui.START)return o.startTask(a)};return x.jsx("div",{className:"confidence-playbook",children:x.jsx(v1,{playbook:r,playbookMode:t,onTaskButtonClick:i,playbookStyle:n})})},x5=({className:e,children:t,numberOfTasks:n,playbookMode:r})=>x.jsxs("div",{className:Ee("w-full p-4",e),children:[n&&x.jsxs("div",{className:Ee(r==="card"&&"mb-4"),children:[x.jsx("span",{className:"font-medium",children:"Tasks"})," (",n,")"]}),x.jsx("div",{className:Ee(r==="card"&&"space-y-4"),children:t})]}),v1=({playbook:e,playbookMode:t,onTaskButtonClick:n,playbookStyle:r})=>{var m,y,v,b,A;const{playbookInstanceName:o,tasks:i}=e,s=T.useRef(null),[a,l]=T.useState(0),[c,u]=T.useState(!0),f=()=>{u(!c)},{isTaskExpanded:d,toggleTaskExpanded:h,isAtLeastOneTaskExpanded:p}=T0(e.playbookInstanceId,{onTaskExpanded:()=>{var w;l(((w=s.current)==null?void 0:w.offsetHeight)||0)}});T.useEffect(()=>{if(p){if(!s.current)throw new Error("Playbook header ref is not set");new ResizeObserver(_=>{var E;for(const S of _)S.contentRect&&l(((E=s.current)==null?void 0:E.offsetHeight)||0)}).observe(s.current)}return()=>{s.current&&new ResizeObserver(()=>{}).unobserve(s.current)}},[p]);const g=T.useMemo(()=>{const w=i.filter(_=>_.workflowStatus===Be.COMPLETED).sort((_,E)=>E.sequenceOrder-_.sequenceOrder)[0];return w?w.sequenceOrder+1:0},[i]);return x.jsxs("div",{className:Ee(!(r!=null&&r.overlay)&&"min-h-screen",(r==null?void 0:r.overlay)&&"fixed bottom-0 z-[9999999997] flex","transition-all duration-300 ease-in-out "),...(r==null?void 0:r.overlay)&&{style:{width:"100%",maxWidth:c?((m=r.overlay.size)==null?void 0:m.width)||450:"2.25rem",height:((y=r.overlay.size)==null?void 0:y.height)||"calc(100vh - 4rem)",maxHeight:"calc(100vh - 4rem)",right:((v=r.overlay.offset)==null?void 0:v.right)!==void 0?r.overlay.offset.right:r.overlay.position==="right"?32:void 0,left:((b=r.overlay.offset)==null?void 0:b.left)!==void 0?r.overlay.offset.left:r.overlay.position==="left"?32:void 0}},children:[(r==null?void 0:r.overlay)&&x.jsx("div",{onClick:f,className:Ee("size-9 relative p-1 top-3 z-[9999999997] border-none rounded-l-sm cursor-pointer"),style:{backgroundColor:((A=r==null?void 0:r.whiteLabel)==null?void 0:A.primaryColor)||"#007BFF",boxShadow:"0px 3px 3px 0px #00000040"},children:x.jsx("img",{src:h0,alt:"Confidence Logo",className:"w-full h-full object-contain"})}),x.jsxs("div",{className:Ee("flex flex-col flex-1 bg-gray-50",(r==null?void 0:r.overlay)&&"border border-gray-200 shadow-2xl rounded-t-sm overflow-y-auto"),children:[x.jsx(y1,{title:o,className:Ee("top-0 sticky z-2"),playbookStyle:r,ref:s}),x.jsx(x5,{playbookMode:t,numberOfTasks:e.numberofTasks,children:i.map((w,_)=>{var E;return x.jsx(v5,{task:w,step:_+1,viewMode:t,playbookId:e.playbookId,canStart:w.sequenceOrder===g,onButtonClick:S=>n(S,w.taskInstanceId),playbookType:"Non-Sequential",taskStyle:{titleColor:(E=r==null?void 0:r.whiteLabel)==null?void 0:E.primaryColor},isExpanded:d(w.taskInstanceId),toggleExpanded:()=>h(w.taskInstanceId),listStickyTopBase:a||104},w.taskId)})})]})]})},w5=({email:e,playbookId:t,playbookMode:n,playbookStyle:r,bank:o="public-sdk",timezone:i="America/Los_Angeles",persistKey:s})=>{const[a,l]=T.useState(null);return T.useEffect(()=>{(async()=>{const c=H0(t,s);if(c&&c.email===e){l(c.playbookInstanceId);return}const{playbookInstanceId:u,errorCode:f,details:d,message:h}=await N0({bank:o,email:e,timezone:i,playbookUid:t})||{};if(f)throw new Error(`Error initiating playbook: ${h} (Code: ${f}) - Details: ${d}`);K0(t,u,e,s),l(u)})()},[]),a?x.jsx(Hr,{playbookInstanceId:a,playbookMode:n,playbookStyle:r,username:e}):null},A5=({playbookId:e,playbookMode:t="list",playbookStyle:n,btnLabel:r="Start Playbook",btnColor:o="primary",persistKey:i})=>{const[s,a]=T.useState(null),[l,c]=T.useState(void 0);return T.useEffect(()=>{const u=H0(e,i);u&&(a(u.playbookInstanceId),c(u.email))},[e,i]),x.jsxs(x.Fragment,{children:[x.jsxs(Cl.div,{children:[x.jsx(FC,{playbookId:e,disabled:!!s,onInitiated:(u,f)=>{K0(e,u,f,i),a(u),c(f)},btnLabel:r,btnColor:o}),x.jsx("style",{type:"text/css",children:qs})]}),s&&x.jsx(Hr,{playbookInstanceId:s,playbookMode:t,playbookStyle:n,username:l})]})},Hr=({playbookInstanceId:e,playbookMode:t,playbookStyle:n,username:r})=>(console.log("Starting ConfidencePlaybook with instance ID:",e,r),x.jsx(S0,{children:x.jsx(g5,{playbookInstanceId:e,username:r,children:x.jsx(b5,{playbookInstanceId:e,playbookMode:t,playbookStyle:n})})}));Hr.Context=S0;Hr.View=v1;Hr.AutoInstantiated=w5;Hr.WithInstantiateButton=A5;const b1=e=>Nn.createPortal(x.jsxs(Cl.div,{style:{position:"relative",zIndex:2147483646},children:[x.jsx("style",{children:qs}),x.jsx(Hr,{...e})]}),document.body),C5=e=>Nn.createPortal(x.jsxs(Cl.div,{style:{position:"relative",zIndex:2147483646},children:[x.jsx("style",{children:qs}),x.jsx(Hr.AutoInstantiated,{...e})]}),document.body);b1.AutoInstantiated=C5;exports.ConfidencePlaybook=b1;
606
+ `?c.insertParagraph():u===" "?c.insertNodes([na()]):c.insertText(u)}}}else t.insertRawText(s)}function Sg(e,t,n){e.dispatchCommand(p3,{nodes:t,selection:n})||(n.insertNodes(t),(function(r){if($(r)&&r.isCollapsed()){const o=r.anchor;let i=null;const s=nr(o,"previous");if(s)if(Or(s))i=s.origin;else{const a=Fr(s,un(We(),"next").getFlipped());for(const l of a){if(X(l.origin)){i=l.origin;break}if(R(l.origin)&&!l.origin.isInline())break}}if(i&&X(i)){const a=i.getFormat(),l=i.getStyle();r.format===a&&r.style===l||(r.format=a,r.style=l,r.dirty=!0)}}})(n))}function o1(e,t,n,r=[]){let o=t===null||n.isSelected(t);const i=R(n)&&n.excludeFromCopy("html");let s=n;t!==null&&X(s)&&(s=jx(t,s,"clone"));const a=R(s)?s.getChildren():[],l=(function(c){const u=c.exportJSON(),f=c.constructor;if(u.type!==f.getType()&&xl(58,f.name),R(c)){const d=u.children;Array.isArray(d)||xl(59,f.name)}return u})(s);X(s)&&s.getTextContentSize()===0&&(o=!1);for(let c=0;c<a.length;c++){const u=a[c],f=o1(e,t,u,l.children);!o&&R(n)&&f&&n.extractWithChild(u,t,"clone")&&(o=!0)}if(o&&!i)r.push(l);else if(Array.isArray(l.children))for(let c=0;c<l.children.length;c++){const u=l.children[c];r.push(u)}return o}function iN(e,t){const n=[],r=We().getChildren();for(let o=0;o<r.length;o++)o1(e,t,r[o],n);return{namespace:e._config.namespace,nodes:n}}function sN(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n],o=Q3(r);X(o)&&I6(o),t.push(o)}return t}let ri=null;async function kg(e,t,n){if(ri!==null)return!1;if(t!==null)return new Promise((c,u)=>{e.update(()=>{c(Tg(e,t,n))})});const r=e.getRootElement(),o=e._window||window,i=o.document,s=en(o);if(r===null||s===null)return!1;const a=i.createElement("span");a.style.cssText="position: fixed; top: -1000px;",a.append(i.createTextNode("#")),r.append(a);const l=new Range;return l.setStart(a,0),l.setEnd(a,1),s.removeAllRanges(),s.addRange(l),new Promise((c,u)=>{const f=e.registerCommand(Zl,d=>(kr(d,ClipboardEvent)&&(f(),ri!==null&&(o.clearTimeout(ri),ri=null),c(Tg(e,d,n))),!0),fx);ri=o.setTimeout(()=>{f(),ri=null,c(!1)},50),i.execCommand("copy"),a.remove()})}function Tg(e,t,n){if(n===void 0){const o=en(e._window),i=Z();if(!i||i.isCollapsed()||!o)return!1;const s=o.anchorNode,a=o.focusNode;if(s!==null&&a!==null&&!ia(e,s,a))return!1;n=aN(i)}t.preventDefault();const r=t.clipboardData;return r!==null&&(lN(r,n),!0)}const i1=[["text/html",rN],["application/x-lexical-editor",oN]];function aN(e=Z()){const t={"text/plain":e?e.getTextContent():""};if(e){const n=Jd();for(const[r,o]of i1){const i=o(n,e);i!==null&&(t[r]=i)}}return t}function lN(e,t){for(const[n]of i1)t[n]===void 0&&e.setData(n,"");for(const n in t){const r=t[n];r!==void 0&&e.setData(n,r)}}function Ng(e,t){if(document.caretRangeFromPoint!==void 0){const n=document.caretRangeFromPoint(e,t);return n===null?null:{node:n.startContainer,offset:n.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const n=document.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}}return null}const Ko=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cN=Ko&&"documentMode"in document?document.documentMode:null,uN=Ko&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),fN=!(!Ko||!("InputEvent"in window)||cN)&&"getTargetRanges"in new window.InputEvent("input"),dN=Ko&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Og=Ko&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,hN=Ko&&/^(?=.*Chrome).*/i.test(navigator.userAgent),pN=Ko&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&uN&&!hN,Pg=he("DRAG_DROP_PASTE_FILE");function Ma(e){let t=null;if(kr(e,DragEvent)?t=e.dataTransfer:kr(e,ClipboardEvent)&&(t=e.clipboardData),t===null)return[!1,[],!1];const n=t.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(t.files),o]}function Mg(e){const t=Z();if(!$(t))return!1;const n=new Set,r=t.getNodes();for(let o=0;o<r.length;o++){const i=r[o],s=i.getKey();if(n.has(s))continue;const a=at(i,c=>R(c)&&!c.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!n.has(l)&&(n.add(l),e(a))}return n.size>0}function Ig(e){const t=Fi(e);return Te(t)}function su(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function mN(e){return fn(e.registerCommand(Md,t=>{const n=Z();return!!ot(n)&&(n.clear(),!0)},we),e.registerCommand(vo,t=>{const n=Z();return $(n)?(n.deleteCharacter(t),!0):!!ot(n)&&(n.deleteNodes(),!0)},we),e.registerCommand(Rs,t=>{const n=Z();return!!$(n)&&(n.deleteWord(t),!0)},we),e.registerCommand(Ds,t=>{const n=Z();return!!$(n)&&(n.deleteLine(t),!0)},we),e.registerCommand(gi,t=>{const n=Z();if(typeof t=="string")n!==null&&n.insertText(t);else{if(n===null)return!1;const r=t.dataTransfer;if(r!=null)Eg(r,n,e);else if($(n)){const o=t.data;return o&&n.insertText(o),!0}}return!0},we),e.registerCommand(xf,()=>{const t=Z();return!!$(t)&&(t.removeText(),!0)},we),e.registerCommand(_n,t=>{const n=Z();return!!$(n)&&(n.formatText(t),!0)},we),e.registerCommand(b3,t=>{const n=Z();if(!$(n)&&!ot(n))return!1;const r=n.getNodes();for(const o of r){const i=at(o,s=>R(s)&&!s.isInline());i!==null&&i.setFormat(t)}return!0},we),e.registerCommand(mi,t=>{const n=Z();return!!$(n)&&(n.insertLineBreak(t),!0)},we),e.registerCommand(Ls,()=>{const t=Z();return!!$(t)&&(t.insertParagraph(),!0)},we),e.registerCommand(y3,()=>(ox([na()]),!0),we),e.registerCommand(v3,()=>Mg(t=>{const n=t.getIndent();t.setIndent(n+1)}),we),e.registerCommand(Mm,()=>Mg(t=>{const n=t.getIndent();n>0&&t.setIndent(Math.max(0,n-1))}),we),e.registerCommand(Pb,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}else if($(n)){const r=If(n.focus,!0);if(!t.shiftKey&&Te(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},we),e.registerCommand(Mb,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectNext(0,0),!0}else if($(n)){if((function(o){const i=o.focus;return i.key==="root"&&i.offset===We().getChildrenSize()})(n))return t.preventDefault(),!0;const r=If(n.focus,!1);if(!t.shiftKey&&Te(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},we),e.registerCommand(Ob,t=>{const n=Z();if(ot(n)){const r=n.getNodes();if(r.length>0)return t.preventDefault(),mg(r[0])?r[0].selectNext(0,0):r[0].selectPrevious(),!0}if(!$(n))return!1;if(yg(n,!0)){const r=t.shiftKey;return t.preventDefault(),vg(n,r,!0),!0}return!1},we),e.registerCommand(Nb,t=>{const n=Z();if(ot(n)){const o=n.getNodes();if(o.length>0)return t.preventDefault(),mg(o[0])?o[0].selectPrevious():o[0].selectNext(0,0),!0}if(!$(n))return!1;const r=t.shiftKey;return!!yg(n,!1)&&(t.preventDefault(),vg(n,r,!1),!0)},we),e.registerCommand(Lb,t=>{if(Ig(t.target))return!1;const n=Z();if($(n)){if((function(r){if(!r.isCollapsed())return!1;const{anchor:o}=r;if(o.offset!==0)return!1;const i=o.getNode();if(Ye(i))return!1;const s=j6(i);return s.getIndent()>0&&(s.is(i)||i.is(s.getFirstDescendant()))})(n))return t.preventDefault(),e.dispatchCommand(Mm,void 0);if(Og&&navigator.language==="ko-KR")return!1}else if(!ot(n))return!1;return t.preventDefault(),e.dispatchCommand(vo,!0)},we),e.registerCommand(Rb,t=>{if(Ig(t.target))return!1;const n=Z();return!(!$(n)&&!ot(n))&&(t.preventDefault(),e.dispatchCommand(vo,!1))},we),e.registerCommand(Fs,t=>{const n=Z();if(!$(n))return!1;if(su(n),t!==null){if((Og||dN||pN)&&fN)return!1;if(t.preventDefault(),t.shiftKey)return e.dispatchCommand(mi,!1)}return e.dispatchCommand(Ls,void 0)},we),e.registerCommand(Rd,()=>{const t=Z();return!!$(t)&&(e.blur(),!0)},we),e.registerCommand(Fb,t=>{const[,n]=Ma(t);if(n.length>0){const o=Ng(t.clientX,t.clientY);if(o!==null){const{offset:i,node:s}=o,a=Fi(s);if(a!==null){const l=tx();if(X(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const u=a.getParentOrThrow().getKey(),f=a.getIndexWithinParent()+1;l.anchor.set(u,f,"element"),l.focus.set(u,f,"element")}const c=Ri(l);Pt(c)}e.dispatchCommand(Pg,n)}return t.preventDefault(),!0}const r=Z();return!!$(r)},we),e.registerCommand(jb,t=>{const[n]=Ma(t),r=Z();return!(n&&!$(r))},we),e.registerCommand(zb,t=>{const[n]=Ma(t),r=Z();if(n&&!$(r))return!1;const o=Ng(t.clientX,t.clientY);if(o!==null){const i=Fi(o.node);Te(i)&&t.preventDefault()}return!0},we),e.registerCommand(wf,()=>(o6(),!0),we),e.registerCommand(Zl,t=>(kg(e,kr(t,ClipboardEvent)?t:null),!0),we),e.registerCommand(Dd,t=>((async function(n,r){await kg(r,kr(n,ClipboardEvent)?n:null),r.update(()=>{const o=Z();$(o)?o.removeText():ot(o)&&o.getNodes().forEach(i=>i.remove())})})(t,e),!0),we),e.registerCommand(Gl,t=>{const[,n,r]=Ma(t);return n.length>0&&!r?(e.dispatchCommand(Pg,n),!0):Xi(t.target)&&Hd(t.target)?!1:Z()!==null&&((function(o,i){o.preventDefault(),i.update(()=>{const s=Z(),a=kr(o,InputEvent)||kr(o,KeyboardEvent)?null:o.clipboardData;a!=null&&s!==null&&Eg(a,s,i)},{tag:I3})})(t,e),!0)},we),e.registerCommand(Ib,t=>{const n=Z();return $(n)&&su(n),!1},we),e.registerCommand(Db,t=>{const n=Z();return $(n)&&su(n),!1},we))}function gN(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const lh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function yN({editor:e,ErrorBoundary:t}){return(function(n,r){const[o,i]=T.useState(()=>n.getDecorators());return lh(()=>n.registerDecoratorListener(s=>{Nn.flushSync(()=>{i(s)})}),[n]),T.useEffect(()=>{i(n.getDecorators())},[n]),T.useMemo(()=>{const s=[],a=Object.keys(o);for(let l=0;l<a.length;l++){const c=a[l],u=x.jsx(r,{onError:d=>n._onError(d),children:x.jsx(T.Suspense,{fallback:null,children:o[c]})}),f=n.getElementByKey(c);f!==null&&s.push(Nn.createPortal(u,f,c))}return s},[r,o,n])})(e,t)}function vN({editor:e,ErrorBoundary:t}){return(function(n){const r=bi.maybeFromEditor(n);if(r&&r.hasExtensionByName(Z6.name)){for(const o of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(o)&&gN(320,o);return!0}return!1})(e)?null:x.jsx(yN,{editor:e,ErrorBoundary:t})}function Lg(e){return e.getEditorState().read(Jx(e.isComposing()))}function bN({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){const[r]=ht();return(function(o){lh(()=>fn(mN(o),tN(o)),[o])})(r),x.jsxs(x.Fragment,{children:[e,x.jsx(xN,{content:t}),x.jsx(vN,{editor:r,ErrorBoundary:n})]})}function xN({content:e}){const[t]=ht(),n=(function(o){const[i,s]=T.useState(()=>Lg(o));return lh(()=>{function a(){const l=Lg(o);s(l)}return a(),fn(o.registerUpdateListener(()=>{a()}),o.registerEditableListener(()=>{a()}))},[o]),i})(t),r=P6();return n?typeof e=="function"?e(r):e:null}function wN(e,t,n,r,o){if(e===null||n.size===0&&r.size===0&&!o)return 0;const i=t._selection,s=e._selection;if(o)return 1;if(!($(i)&&$(s)&&s.isCollapsed()&&i.isCollapsed()))return 0;const a=(function(y,v,b){const A=y._nodeMap,w=[];for(const _ of v){const E=A.get(_);E!==void 0&&w.push(E)}for(const[_,E]of b){if(!E)continue;const S=A.get(_);S===void 0||Ye(S)||w.push(S)}return w})(t,n,r);if(a.length===0)return 0;if(a.length>1){const y=t._nodeMap,v=y.get(i.anchor.key),b=y.get(s.anchor.key);return v&&b&&!e._nodeMap.has(v.__key)&&X(v)&&v.__text.length===1&&i.anchor.offset===1?2:0}const l=a[0],c=e._nodeMap.get(l.__key);if(!X(c)||!X(l)||c.__mode!==l.__mode)return 0;const u=c.__text,f=l.__text;if(u===f)return 0;const d=i.anchor,h=s.anchor;if(d.key!==h.key||d.type!=="text")return 0;const p=d.offset,g=h.offset,m=f.length-u.length;return m===1&&g===p-1?2:m===-1&&g===p+1?3:m===-1&&g===p?4:0}function AN(e,t){let n=Date.now(),r=0;return(o,i,s,a,l,c)=>{const u=Date.now();if(c.has(Nf))return r=0,n=u,2;const f=wN(o,i,a,l,e.isComposing()),d=(()=>{const h=s===null||s.editor===e,p=c.has(M3);if(!p&&h&&c.has(bo))return 0;if(o===null)return 1;const g=i._selection;if(!(a.size>0||l.size>0))return g!==null?0:2;const m=typeof t=="number"?t:t.peek();return p===!1&&f!==0&&f===r&&u<n+m&&h||a.size===1&&(function(y,v,b){const A=v._nodeMap.get(y),w=b._nodeMap.get(y),_=v._selection,E=b._selection;return!($(_)&&$(E)&&_.anchor.type==="element"&&_.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!X(A)||!X(w)||A.__parent!==w.__parent)&&JSON.stringify(v.read(()=>A.exportJSON()))===JSON.stringify(b.read(()=>w.exportJSON()))})(Array.from(a)[0],o,i)?0:1})();return n=u,r=f,d}}function Rg(e){e.undoStack=[],e.redoStack=[],e.current=null}function s1(e,t,n){const r=AN(e,n);return fn(e.registerCommand(Id,()=>((function(i,s){const a=s.redoStack,l=s.undoStack;if(l.length!==0){const c=s.current,u=l.pop();c!==null&&(a.push(c),i.dispatchCommand(Ca,!0)),l.length===0&&i.dispatchCommand(_a,!1),s.current=u||null,u&&u.editor.setEditorState(u.editorState,{tag:Nf})}})(e,t),!0),we),e.registerCommand(Ld,()=>((function(i,s){const a=s.redoStack,l=s.undoStack;if(a.length!==0){const c=s.current;c!==null&&(l.push(c),i.dispatchCommand(_a,!0));const u=a.pop();a.length===0&&i.dispatchCommand(Ca,!1),s.current=u||null,u&&u.editor.setEditorState(u.editorState,{tag:Nf})}})(e,t),!0),we),e.registerCommand(w3,()=>(Rg(t),!1),we),e.registerCommand(A3,()=>(Rg(t),e.dispatchCommand(Ca,!1),e.dispatchCommand(_a,!1),!0),we),e.registerUpdateListener(({editorState:i,prevEditorState:s,dirtyLeaves:a,dirtyElements:l,tags:c})=>{const u=t.current,f=t.redoStack,d=t.undoStack,h=u===null?null:u.editorState;if(u!==null&&i===h)return;const p=r(s,i,u,a,l,c);if(p===1)f.length!==0&&(t.redoStack=[],e.dispatchCommand(Ca,!1)),u!==null&&(d.push({...u}),e.dispatchCommand(_a,!0));else if(p===2)return;t.current={editor:e,editorState:i}}))}function a1(){return{current:null,redoStack:[],undoStack:[]}}const au={build:(e,{delay:t,createInitialHistoryState:n,disabled:r})=>Yx({delay:t,disabled:r,historyState:n(e)}),config:{createInitialHistoryState:a1,delay:300,disabled:typeof window>"u"},name:"@lexical/history/History",register:(e,t,n)=>{const r=n.getOutput();return $s(()=>r.disabled.value?void 0:s1(e,r.historyState.value,r.delay))}};E6(au,{createInitialHistoryState:()=>{throw new Error("SharedHistory did not inherit parent history")},disabled:!0});function CN({delay:e,externalHistoryState:t}){const[n]=ht();return(function(r,o,i=1e3){const s=T.useMemo(()=>o||a1(),[o]);T.useEffect(()=>s1(r,s,i),[i,r,s])})(n,t,e),null}const l1=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function _N({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:o,ariaErrorMessage:i,ariaExpanded:s,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:c,ariaMultiline:u,ariaOwns:f,ariaRequired:d,autoCapitalize:h,className:p,id:g,role:m="textbox",spellCheck:y=!0,style:v,tabIndex:b,"data-testid":A,...w},_){const[E,S]=T.useState(e.isEditable()),O=T.useCallback(I=>{I&&I.ownerDocument&&I.ownerDocument.defaultView?e.setRootElement(I):e.setRootElement(null)},[e]),P=T.useMemo(()=>(function(...I){return W=>{for(const j of I)typeof j=="function"?j(W):j!=null&&(j.current=W)}})(_,O),[O,_]);return l1(()=>(S(e.isEditable()),e.registerEditableListener(I=>{S(I)})),[e]),x.jsx("div",{"aria-activedescendant":E?t:void 0,"aria-autocomplete":E?n:"none","aria-controls":E?r:void 0,"aria-describedby":o,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":E&&m==="combobox"?!!s:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":c,"aria-multiline":u,"aria-owns":E?f:void 0,"aria-readonly":!E||void 0,"aria-required":d,autoCapitalize:h,className:p,contentEditable:E,"data-testid":A,id:g,ref:P,role:m,spellCheck:y,style:v,tabIndex:b,...w})}const EN=T.forwardRef(_N);function Dg(e){return e.getEditorState().read(Jx(e.isComposing()))}const SN=T.forwardRef(kN);function kN(e,t){const{placeholder:n,...r}=e,[o]=ht();return x.jsxs(x.Fragment,{children:[x.jsx(EN,{editor:o,...r,ref:t}),n!=null&&x.jsx(TN,{editor:o,content:n})]})}function TN({content:e,editor:t}){const n=(function(s){const[a,l]=T.useState(()=>Dg(s));return l1(()=>{function c(){const u=Dg(s);l(u)}return c(),fn(s.registerUpdateListener(()=>{c()}),s.registerEditableListener(()=>{c()}))},[s]),a})(t),[r,o]=T.useState(t.isEditable());if(T.useLayoutEffect(()=>(o(t.isEditable()),t.registerEditableListener(s=>{o(s)})),[t]),!n)return null;let i=null;return typeof e=="function"?i=e(r):e!==null&&(i=e),i===null?null:x.jsx("div",{"aria-hidden":!0,children:i})}const NN=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?T.useLayoutEffect:T.useEffect;function ON({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){const[r]=ht();return NN(()=>{if(n)return r.registerUpdateListener(({editorState:o,dirtyElements:i,dirtyLeaves:s,prevEditorState:a,tags:l})=>{t&&i.size===0&&s.size===0||e&&l.has(bo)||a.isEmpty()||n(o,r,l)})},[r,e,t,n]),null}const PN=T.createContext(null),lu={didCatch:!1,error:null};class MN extends T.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=lu}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var r,o;const{error:n}=this.state;n!==null&&((o=(r=this.props).onReset)==null||o.call(r,{args:t,reason:"imperative-api"}),this.setState(lu))}componentDidCatch(t,n){var r,o;(o=(r=this.props).onError)==null||o.call(r,t,n)}componentDidUpdate(t,n){var i,s;const{didCatch:r}=this.state,{resetKeys:o}=this.props;r&&n.error!==null&&IN(t.resetKeys,o)&&((s=(i=this.props).onReset)==null||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(lu))}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=T.createElement(r,l);else if(o!==void 0)a=o;else throw s}return T.createElement(PN.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function IN(e=[],t=[]){return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function LN({children:e,onError:t}){return x.jsx(MN,{fallback:x.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:t,children:e})}const RN={paragraph:"m-0",list:{ol:"list-decimal pl-4",ul:"list-disc pl-4"},text:{bold:"font-semibold",italic:"italic",underline:"underline",strikethrough:"line-through",code:"font-mono"},link:"text-blue-600 hover:text-blue-600 underline cursor-pointer"};function Tr(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const o of t)r.append("v",o);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Uf(e){let t=1,n=e.getParent();for(;n!=null;){if(ke(n)){const r=n.getParent();if(be(r)){t++,n=r.getParent();continue}Tr(40)}return t}return t}function Bf(e){let t=e.getParent();be(t)||Tr(40);let n=t;for(;n!==null;)n=n.getParent(),be(n)&&(t=n);return t}function c1(e){let t=[];const n=e.getChildren().filter(ke);for(let r=0;r<n.length;r++){const o=n[r],i=o.getFirstChild();be(i)?t=t.concat(c1(i)):t.push(o)}return t}function wn(e){return ke(e)&&be(e.getFirstChild())}function Fg(e){return Zt().append(e)}function u1(e,t){return ke(e)&&(t.length===0||t.length===1&&e.is(t[0])&&e.getChildrenSize()===0)}function jg(e){const t=Z();if(t!==null){let n=t.getNodes();if($(t)){const o=t.getStartEndPoints();o===null&&Tr(143);const[i]=o,s=i.getNode(),a=s.getParent();if(jt(s)){const l=s.getFirstChild();if(l)n=l.selectStart().getNodes();else{const c=Tt();s.append(c),n=c.select().getNodes()}}else if(u1(s,n)){const l=Bt(e);if(jt(a)){s.replace(l);const c=Zt();R(s)&&(c.setFormat(s.getFormatType()),c.setIndent(s.getIndent())),l.append(c)}else if(ke(s)){const c=s.getParentOrThrow();Uo(l,c.getChildren()),c.replace(l)}return}}const r=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(R(i)&&i.isEmpty()&&!ke(i)&&!r.has(i.getKey())){zg(i,e);continue}let s=vx(i)?i.getParent():ke(i)&&i.isEmpty()?i:null;for(;s!=null;){const a=s.getKey();if(be(s)){if(!r.has(a)){const l=Bt(e);Uo(l,s.getChildren()),s.replace(l),r.add(a)}break}{const l=s.getParent();if(jt(l)&&!r.has(a)){r.add(a),zg(s,e);break}s=l}}}}}function Uo(e,t){e.splice(e.getChildrenSize(),0,t)}function zg(e,t){if(be(e))return e;const n=e.getPreviousSibling(),r=e.getNextSibling(),o=Zt();let i;if(Uo(o,e.getChildren()),be(n)&&t===n.getListType())n.append(o),be(r)&&t===r.getListType()&&(Uo(n,r.getChildren()),r.remove()),i=n;else if(be(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(o),i=r;else{const s=Bt(t);s.append(o),e.replace(s),i=s}return o.setFormat(e.getFormatType()),o.setIndent(e.getIndent()),e.remove(),i}function ch(e,t){const n=e.getLastChild(),r=t.getFirstChild();n&&r&&wn(n)&&wn(r)&&(ch(n.getFirstChild(),r.getFirstChild()),r.remove());const o=t.getChildren();o.length>0&&e.append(...o),t.remove()}function DN(){const e=Z();if($(e)){const t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(u1(r,n))t.add(Bf(r));else for(let o=0;o<n.length;o++){const i=n[o];if(vx(i)){const s=F6(i,ts);s!=null&&t.add(Bf(s))}}for(const o of t){let i=o;const s=c1(o);for(const a of s){const l=Tt().setTextStyle(e.style).setTextFormat(e.format);Uo(l,a.getChildren()),i.insertAfter(l),i=l,a.__key===e.anchor.key&&$o(e.anchor,Yt(un(l,"next"))),a.__key===e.focus.key&&$o(e.focus,Yt(un(l,"next"))),a.remove()}o.remove()}}}function f1(e){const t=e.getListType()!=="check";let n=e.getStart();for(const r of e.getChildren())ke(r)&&(r.getValue()!==n&&r.setValue(n),t&&r.getLatest().__checked!=null&&r.setChecked(void 0),be(r.getFirstChild())||n++)}function FN(e){const t=new Set;if(wn(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),o=e.getPreviousSibling();if(wn(r)&&wn(o)){const i=o.getFirstChild();if(be(i)){i.append(e);const s=r.getFirstChild();be(s)&&(Uo(i,s.getChildren()),r.remove(),t.add(r.getKey()))}}else if(wn(r)){const i=r.getFirstChild();if(be(i)){const s=i.getFirstChild();s!==null&&s.insertBefore(e)}}else if(wn(o)){const i=o.getFirstChild();be(i)&&i.append(e)}else if(be(n)){const i=Zt().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),s=Bt(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());i.append(s),s.append(e),o?o.insertAfter(i):r?r.insertBefore(i):n.append(i)}}function jN(e){if(wn(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(be(n?n.getParent():void 0)&&ke(n)&&be(t)){const r=t?t.getFirstChild():void 0,o=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(o))n.insertAfter(e),t.isEmpty()&&n.remove();else{const i=t.getListType(),s=Zt(),a=Bt(i);s.append(a),e.getPreviousSiblings().forEach(u=>a.append(u));const l=Zt(),c=Bt(i);l.append(c),Uo(c,e.getNextSiblings()),n.insertBefore(s),n.insertAfter(l),n.replace(e)}}}function zN(){const e=Z();if(!$(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();if(!ke(t)||t.getChildrenSize()!==0)return!1;const n=Bf(t),r=t.getParent();be(r)||Tr(40);const o=r.getParent();let i;if(jt(o))i=Tt(),n.insertAfter(i);else{if(!ke(o))return!1;i=Zt(),o.insertAfter(i)}i.setTextStyle(e.style).setTextFormat(e.format).select();const s=t.getNextSiblings();if(s.length>0){const a=Bt(r.getListType());if(ke(i)){const l=Zt();l.append(a),i.insertAfter(l)}else i.insertAfter(a);a.append(...s)}return(function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const c=l.getParent();if(c==null||!ke(c)&&!be(c))break;l=c}l.remove()})(t),!0}function wl(...e){const t=[];for(const n of e)if(n&&typeof n=="string")for(const[r]of n.matchAll(/\S+/g))t.push(r);return t}class ts extends Mn{constructor(n=1,r=void 0,o){super(o);D(this,"__value");D(this,"__checked");this.__value=n===void 0?1:n,this.__checked=r}$config(){return this.config("listitem",{$transform:n=>{if(n.__checked==null)return;const r=n.getParent();be(r)&&r.getListType()!=="check"&&n.getChecked()!=null&&n.setChecked(void 0)},extends:Mn,importDOM:{li:()=>({conversion:$N,priority:0})}})}afterCloneFrom(n){super.afterCloneFrom(n),this.__value=n.__value,this.__checked=n.__checked}createDOM(n){const r=document.createElement("li");return this.updateListItemDOM(null,r,n),r}updateListItemDOM(n,r,o){(function(a,l,c){const u=l.getParent();!be(u)||u.getListType()!=="check"||be(l.getFirstChild())?(a.removeAttribute("role"),a.removeAttribute("tabIndex"),a.removeAttribute("aria-checked")):(a.setAttribute("role","checkbox"),a.setAttribute("tabIndex","-1"),c&&l.__checked===c.__checked||a.setAttribute("aria-checked",l.getChecked()?"true":"false"))})(r,this,n),r.value=this.__value,(function(a,l,c){const u=[],f=[],d=l.list,h=d?d.listitem:void 0;let p;if(d&&d.nested&&(p=d.nested.listitem),h!==void 0&&u.push(...wl(h)),d){const g=c.getParent(),m=be(g)&&g.getListType()==="check",y=c.getChecked();m&&!y||f.push(d.listitemUnchecked),m&&y||f.push(d.listitemChecked),m&&u.push(y?d.listitemChecked:d.listitemUnchecked)}if(p!==void 0){const g=wl(p);c.getChildren().some(m=>be(m))?u.push(...g):f.push(...g)}f.length>0&&Kx(a,...f),u.length>0&&ih(a,...u)})(r,o.theme,this);const i=n?n.__style:"",s=this.__style;i!==s&&(s===""?r.removeAttribute("style"):r.style.cssText=s),(function(a,l,c){const u=pg(l.__textStyle);for(const f in u)a.style.setProperty(`--listitem-marker-${f}`,u[f]);if(c)for(const f in pg(c.__textStyle))f in u||a.style.removeProperty(`--listitem-marker-${f}`)})(r,this,n)}updateDOM(n,r,o){const i=r;return this.updateListItemDOM(n,i,o),!1}updateFromJSON(n){return super.updateFromJSON(n).setValue(n.value).setChecked(n.checked)}exportDOM(n){const r=this.createDOM(n._config),o=this.getFormatType();o&&(r.style.textAlign=o);const i=this.getDirection();return i&&(r.dir=i),{element:r}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...n){for(let r=0;r<n.length;r++){const o=n[r];if(R(o)&&this.canMergeWith(o)){const i=o.getChildren();this.append(...i),o.remove()}else super.append(o)}return this}replace(n,r){if(ke(n))return super.replace(n);this.setIndent(0);const o=this.getParentOrThrow();if(!be(o))return n;if(o.__first===this.getKey())o.insertBefore(n);else if(o.__last===this.getKey())o.insertAfter(n);else{const i=Bt(o.getListType());let s=this.getNextSibling();for(;s;){const a=s;s=s.getNextSibling(),i.append(a)}o.insertAfter(n),n.insertAfter(i)}return r&&(R(n)||Tr(139),this.getChildren().forEach(i=>{n.append(i)})),this.remove(),o.getChildrenSize()===0&&o.remove(),n}insertAfter(n,r=!0){const o=this.getParentOrThrow();if(be(o)||Tr(39),ke(n))return super.insertAfter(n,r);const i=this.getNextSiblings();if(o.insertAfter(n,r),i.length!==0){const s=Bt(o.getListType());i.forEach(a=>s.append(a)),n.insertAfter(s,r)}return n}remove(n){const r=this.getPreviousSibling(),o=this.getNextSibling();super.remove(n),r&&o&&wn(r)&&wn(o)&&(ch(r.getFirstChild(),o.getFirstChild()),o.remove())}insertNewAfter(n,r=!0){const o=Zt().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(o,r),o}collapseAtStart(n){const r=Tt();this.getChildren().forEach(a=>r.append(a));const o=this.getParentOrThrow(),i=o.getParentOrThrow(),s=ke(i);if(o.getChildrenSize()===1)if(s)o.remove(),i.select();else{o.insertBefore(r),o.remove();const a=n.anchor,l=n.focus,c=r.getKey();a.type==="element"&&a.getNode().is(this)&&a.set(c,a.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(c,l.offset,"element")}else o.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(n){const r=this.getWritable();return r.__value=n,r}getChecked(){const n=this.getLatest();let r;const o=this.getParent();return be(o)&&(r=o.getListType()),r==="check"?!!n.__checked:void 0}setChecked(n){const r=this.getWritable();return r.__checked=n,r}toggleChecked(){const n=this.getWritable();return n.setChecked(!n.__checked)}getIndent(){const n=this.getParent();if(n===null||!this.isAttached())return this.getLatest().__indent;let r=n.getParentOrThrow(),o=0;for(;ke(r);)r=r.getParentOrThrow().getParentOrThrow(),o++;return o}setIndent(n){typeof n!="number"&&Tr(117),(n=Math.floor(n))>=0||Tr(199);let r=this.getIndent();for(;r!==n;)r<n?(FN(this),r++):(jN(this),r--);return this}canInsertAfter(n){return ke(n)}canReplaceWith(n){return ke(n)}canMergeWith(n){return ke(n)||Bd(n)}extractWithChild(n,r){if(!$(r))return!1;const o=r.anchor.getNode(),i=r.focus.getNode();return this.isParentOf(o)&&this.isParentOf(i)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Bt("bullet")}canMergeWhenEmpty(){return!0}}function $N(e){if(e.classList.contains("task-list-item")){for(const n of e.children)if(n.tagName==="INPUT")return $g(n)}if(e.classList.contains("joplin-checkbox")){for(const n of e.children)if(n.classList.contains("checkbox-wrapper")&&n.children.length>0&&n.children[0].tagName==="INPUT")return $g(n.children[0])}const t=e.getAttribute("aria-checked");return{node:Zt(t==="true"||t!=="false"&&void 0)}}function $g(e){return e.getAttribute("type")!=="checkbox"?{node:null}:{node:Zt(e.hasAttribute("checked"))}}function Zt(e){return Kr(new ts(void 0,e))}function ke(e){return e instanceof ts}class aa extends Mn{constructor(n="number",r=1,o){super(o);D(this,"__tag");D(this,"__start");D(this,"__listType");const i=BN[n]||n;this.__listType=i,this.__tag=i==="number"?"ol":"ul",this.__start=r}$config(){return this.config("list",{$transform:n=>{(function(r){const o=r.getNextSibling();be(o)&&r.getListType()===o.getListType()&&ch(r,o)})(n),f1(n)},extends:Mn,importDOM:{ol:()=>({conversion:Bg,priority:0}),ul:()=>({conversion:Bg,priority:0})}})}afterCloneFrom(n){super.afterCloneFrom(n),this.__listType=n.__listType,this.__tag=n.__tag,this.__start=n.__start}getTag(){return this.getLatest().__tag}setListType(n){const r=this.getWritable();return r.__listType=n,r.__tag=n==="number"?"ol":"ul",r}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(n){const r=this.getWritable();return r.__start=n,r}createDOM(n,r){const o=this.__tag,i=document.createElement(o);return this.__start!==1&&i.setAttribute("start",String(this.__start)),i.__lexicalListType=this.__listType,Ug(i,n.theme,this),i}updateDOM(n,r,o){return n.__tag!==this.__tag||n.__listType!==this.__listType||(Ug(r,o.theme,this),!1)}updateFromJSON(n){return super.updateFromJSON(n).setListType(n.listType).setStart(n.start)}exportDOM(n){const r=this.createDOM(n._config,n);return pt(r)&&(this.__start!==1&&r.setAttribute("start",String(this.__start)),this.__listType==="check"&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(n,r,o){let i=o;for(let s=0;s<o.length;s++){const a=o[s];ke(a)||(i===o&&(i=[...o]),i[s]=Zt().append(!R(a)||be(a)||a.isInline()?a:rt(a.getTextContent())))}return super.splice(n,r,i)}extractWithChild(n){return ke(n)}}function Ug(e,t,n){const r=[],o=[],i=t.list;if(i!==void 0){const s=i[`${n.__tag}Depth`]||[],a=Uf(n)-1,l=a%s.length,c=s[l],u=i[n.__tag];let f;const d=i.nested,h=i.checklist;if(d!==void 0&&d.list&&(f=d.list),u!==void 0&&r.push(u),h!==void 0&&n.__listType==="check"&&r.push(h),c!==void 0){r.push(...wl(c));for(let p=0;p<s.length;p++)p!==l&&o.push(n.__tag+p)}if(f!==void 0){const p=wl(f);a>1?r.push(...p):o.push(...p)}}o.length>0&&Kx(e,...o),r.length>0&&ih(e,...r)}function UN(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(ke(r)){t.push(r);const o=r.getChildren();o.length>1&&o.forEach(i=>{be(i)&&t.push(Fg(i))})}else t.push(Fg(r))}return t}function Bg(e){const t=e.nodeName.toLowerCase();let n=null;return t==="ol"?n=Bt("number",e.start):t==="ul"&&(n=(function(r){if(r.getAttribute("__lexicallisttype")==="check"||r.classList.contains("contains-task-list")||r.getAttribute("data-is-checklist")==="1")return!0;for(const o of r.childNodes)if(pt(o)&&o.hasAttribute("aria-checked"))return!0;return!1})(e)?Bt("check"):Bt("bullet")),{after:UN,node:n}}const BN={ol:"number",ul:"bullet"};function Bt(e="number",t=1){return Kr(new aa(e,t))}function be(e){return e instanceof aa}const WN=he("UPDATE_LIST_START_COMMAND"),d1=he("INSERT_UNORDERED_LIST_COMMAND"),h1=he("INSERT_ORDERED_LIST_COMMAND"),Wf=he("REMOVE_LIST_COMMAND");function KN(e){return fn(e.registerCommand(h1,()=>(jg("number"),!0),Gn),e.registerCommand(WN,t=>{const{listNodeKey:n,newStart:r}=t,o=Xe(n);return!!be(o)&&(o.getListType()==="number"&&(o.setStart(r),f1(o)),!0)},Gn),e.registerCommand(d1,()=>(jg("bullet"),!0),Gn),e.registerCommand(Wf,()=>(DN(),!0),Gn),e.registerCommand(Ls,()=>zN(),Gn),e.registerNodeTransform(ts,t=>{const n=t.getFirstChild();if(n){if(X(n)){const r=n.getStyle(),o=n.getFormat();t.getTextStyle()!==r&&t.setTextStyle(r),t.getTextFormat()!==o&&t.setTextFormat(o)}}else{const r=Z();$(r)&&(r.style!==t.getTextStyle()||r.format!==t.getTextFormat())&&r.isCollapsed()&&t.is(r.anchor.getNode())&&t.setTextStyle(r.style).setTextFormat(r.format)}}),e.registerNodeTransform(Br,t=>{const n=t.getParent();if(ke(n)&&t.is(n.getFirstChild())){const r=t.getStyle(),o=t.getFormat();r===n.getTextStyle()&&o===n.getTextFormat()||n.setTextStyle(r).setTextFormat(o)}}))}function HN(e){const t=n=>{const r=n.getParent();if(be(n.getFirstChild())||!be(r))return;const o=at(n,i=>ke(i)&&be(i.getParent())&&ke(i.getPreviousSibling()));if(o===null&&n.getIndent()>0)n.setIndent(0);else if(ke(o)){const i=o.getPreviousSibling();if(ke(i)){const s=(function(l){let c=l,u=c.getFirstChild();for(;be(u);){const f=u.getLastChild();if(!ke(f))break;c=f,u=c.getFirstChild()}return c})(i),a=s.getParent();if(be(a)){const l=Uf(a);l+1<Uf(r)&&n.setIndent(l)}}}};return e.registerNodeTransform(aa,n=>{const r=[n];for(;r.length>0;){const o=r.shift();if(be(o)){for(const i of o.getChildren())if(ke(i)){t(i);const s=i.getFirstChild();be(s)&&r.push(s)}}}})}const qN=new Set(["http:","https:","mailto:","sms:","tel:"]);class Ho extends Mn{constructor(n="",r={},o){super(o);D(this,"__url");D(this,"__target");D(this,"__rel");D(this,"__title");const{target:i=null,rel:s=null,title:a=null}=r;this.__url=n,this.__target=i,this.__rel=s,this.__title=a}static getType(){return"link"}static clone(n){return new Ho(n.__url,{rel:n.__rel,target:n.__target,title:n.__title},n.__key)}createDOM(n){const r=document.createElement("a");return this.updateLinkDOM(null,r,n),ih(r,n.theme.link),r}updateLinkDOM(n,r,o){if(kx(r)){n&&n.__url===this.__url||(r.href=this.sanitizeUrl(this.__url));for(const i of["target","rel","title"]){const s=`__${i}`,a=this[s];n&&n[s]===a||(a?r[i]=a:r.removeAttribute(i))}}}updateDOM(n,r,o){return this.updateLinkDOM(n,r,o),!1}static importDOM(){return{a:n=>({conversion:VN,priority:1})}}static importJSON(n){return Co().updateFromJSON(n)}updateFromJSON(n){return super.updateFromJSON(n).setURL(n.url).setRel(n.rel||null).setTarget(n.target||null).setTitle(n.title||null)}sanitizeUrl(n){n=Hg(n);try{const r=new URL(Hg(n));if(!qN.has(r.protocol))return"about:blank"}catch{return n}return n}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(n){const r=this.getWritable();return r.__url=n,r}getTarget(){return this.getLatest().__target}setTarget(n){const r=this.getWritable();return r.__target=n,r}getRel(){return this.getLatest().__rel}setRel(n){const r=this.getWritable();return r.__rel=n,r}getTitle(){return this.getLatest().__title}setTitle(n){const r=this.getWritable();return r.__title=n,r}insertNewAfter(n,r=!0){const o=Co(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(o,r),o}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(n,r,o){if(!$(r))return!1;const i=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(i)&&this.isParentOf(s)&&r.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function VN(e){let t=null;if(kx(e)){const n=e.textContent;(n!==null&&n!==""||e.children.length>0)&&(t=Co(e.getAttribute("href")||"",{rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")}))}return{node:t}}function Co(e="",t){return Kr(new Ho(e,t))}function ut(e){return e instanceof Ho}class ic extends Ho{constructor(n="",r={},o){super(n,r,o);D(this,"__isUnlinked");this.__isUnlinked=r.isUnlinked!==void 0&&r.isUnlinked!==null&&r.isUnlinked}static getType(){return"autolink"}static clone(n){return new ic(n.__url,{isUnlinked:n.__isUnlinked,rel:n.__rel,target:n.__target,title:n.__title},n.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(n){const r=this.getWritable();return r.__isUnlinked=n,r}createDOM(n){return this.__isUnlinked?document.createElement("span"):super.createDOM(n)}updateDOM(n,r,o){return super.updateDOM(n,r,o)||n.__isUnlinked!==this.__isUnlinked}static importJSON(n){return Wg().updateFromJSON(n)}updateFromJSON(n){return super.updateFromJSON(n).setIsUnlinked(n.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(n,r=!0){const o=this.getParentOrThrow().insertNewAfter(n,r);if(R(o)){const i=Wg(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return o.append(i),i}return null}}function Wg(e="",t){return Kr(new ic(e,t))}function so(e){return e instanceof ic}const $i=he("TOGGLE_LINK_COMMAND");function Kg(e,t){if(e.type==="element"){const n=e.getNode();return R(n)||(function(r,...o){const i=new URL("https://lexical.dev/docs/error"),s=new URLSearchParams;s.append("code",r);for(const a of o)s.append("v",a);throw i.search=s.toString(),Error(`Minified Lexical error #${r}; visit ${i.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(252),n.getChildren()[e.offset+t]||null}return null}function cu(e,t={}){let n;if(e&&typeof e=="object"){const{url:u,...f}=e;n=u,t={...f,...t}}else n=e;const{target:r,title:o}=t,i=t.rel===void 0?"noreferrer":t.rel,s=Z();if(s===null||!$(s)&&!ot(s))return;if(ot(s)){const u=s.getNodes();return u.length===0?void 0:void u.forEach(f=>{if(n===null){const d=at(f,h=>!so(h)&&ut(h));d&&(d.insertBefore(f),d.getChildren().length===0&&d.remove())}else{const d=at(f,h=>!so(h)&&ut(h));if(d)d.setURL(n),r!==void 0&&d.setTarget(r),i!==void 0&&d.setRel(i);else{const h=Co(n,{rel:i,target:r});f.insertBefore(h),h.append(f)}}})}const a=s.extract();if(n===null){const u=new Set;return void a.forEach(f=>{const d=f.getParent();if(ut(d)&&!so(d)){const h=d.getKey();if(u.has(h))return;(function(p,g){const m=new Set(g.filter(E=>p.isParentOf(E)).map(E=>E.getKey())),y=p.getChildren(),v=y.filter(E=>m.has(E.getKey()));if(v.length===y.length)return y.forEach(E=>p.insertBefore(E)),void p.remove();const b=y.findIndex(E=>m.has(E.getKey())),A=y.findLastIndex(E=>m.has(E.getKey())),w=b===0,_=A===y.length-1;if(w)v.forEach(E=>p.insertBefore(E));else if(_)for(let E=v.length-1;E>=0;E--)p.insertAfter(v[E]);else{for(let S=v.length-1;S>=0;S--)p.insertAfter(v[S]);const E=y.slice(A+1);if(E.length>0){const S=Co(p.getURL(),{rel:p.getRel(),target:p.getTarget(),title:p.getTitle()});v[v.length-1].insertAfter(S),E.forEach(O=>S.append(O))}}})(d,a),u.add(h)}})}const l=new Set,c=u=>{l.has(u.getKey())||(l.add(u.getKey()),u.setURL(n),r!==void 0&&u.setTarget(r),i!==void 0&&u.setRel(i),o!==void 0&&u.setTitle(o))};if(a.length===1){const u=a[0],f=at(u,ut);if(f!==null)return c(f)}(function(u){const f=Z();if(!$(f))return u();const d=Ri(f),h=d.isBackward(),p=Kg(d.anchor,h?-1:0),g=Kg(d.focus,h?0:-1);if(u(),p||g){const m=Z();if($(m)){const y=m.clone();if(p){const v=p.getParent();v&&y.anchor.set(v.getKey(),p.getIndexWithinParent()+(h?1:0),"element")}if(g){const v=g.getParent();v&&y.focus.set(v.getKey(),g.getIndexWithinParent()+(h?0:1),"element")}Pt(Ri(y))}}})(()=>{let u=null;for(const f of a){if(!f.isAttached())continue;const d=at(f,ut);if(d){c(d);continue}if(R(f)){if(!f.isInline())continue;if(ut(f)){if(!(so(f)||u!==null&&u.getParentOrThrow().isParentOf(f))){c(f),u=f;continue}for(const p of f.getChildren())f.insertBefore(p);f.remove();continue}}const h=f.getPreviousSibling();ut(h)&&h.is(u)?h.append(f):(u=Co(n,{rel:i,target:r,title:o}),f.insertAfter(u),u.append(f))}})}const YN=/^\+?[0-9\s()-]{5,}$/;function Hg(e){return e.match(/^[a-z][a-z0-9+.-]*:/i)||e.match(/^[/#.]/)?e:e.includes("@")?`mailto:${e}`:YN.test(e)?`tel:${e}`:`https://${e}`}function QN(e,t){return fn($s(()=>e.registerCommand($i,n=>{const r=t.validateUrl.peek(),o=t.attributes.peek();if(n===null)return cu(null),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(cu(n,o),!0);{const{url:i,target:s,rel:a,title:l}=n;return cu(i,{...o,rel:a,target:s,title:l}),!0}},Gn)),$s(()=>{const n=t.validateUrl.value;if(!n)return;const r=t.attributes.value;return e.registerCommand(Gl,o=>{const i=Z();if(!$(i)||i.isCollapsed()||!kr(o,ClipboardEvent)||o.clipboardData===null)return!1;const s=o.clipboardData.getData("text");return!!n(s)&&!i.getNodes().some(a=>R(a))&&(e.dispatchCommand($i,{...r,url:s}),o.preventDefault(),!0)},Gn)}))}function GN({commentType:e,onCommentTypeChange:t,isCommentTypeEditable:n=!0,actions:r,setIsLinkEditMode:o,onAddAttachments:i}){const[s]=ht(),[a,l]=T.useState({bold:!1,italic:!1,underline:!1,strikethrough:!1,code:!1}),[c,u]=T.useState(null),f=T.useRef(null),d=T.useRef(null),h=uh[e];T.useLayoutEffect(()=>s.registerUpdateListener(({editorState:v})=>{v.read(()=>{const b=Z();if(!$(b))return;l({bold:b.hasFormat("bold"),italic:b.hasFormat("italic"),underline:b.hasFormat("underline"),strikethrough:b.hasFormat("strikethrough"),code:b.hasFormat("code")});let A=b.anchor.getNode(),w=null;for(;A;){if(be(A)){const _=A.getListType();w=_==="bullet"||_==="number"?_:null;break}if(ke(A)){A=A.getParent();continue}A=A.getParent()}u(w)})}),[s]);const p=v=>{s.dispatchCommand(_n,v)},g=()=>{c!=="bullet"?s.dispatchCommand(d1,void 0):s.dispatchCommand(Wf,void 0)},m=()=>{c!=="number"?s.dispatchCommand(h1,void 0):s.dispatchCommand(Wf,void 0)},y=()=>{s.update(()=>{const v=Z();if(!$(v))return;["bold","italic","underline","strikethrough","code"].forEach(A=>{v.hasFormat(A)&&s.dispatchCommand(_n,A)})})};return x.jsxs("div",{className:Ee("flex items-center w-full",r?"justify-between":"justify-end"),children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(ff,{placement:"top-start",minWidth:"fit-content",title:"text formatting menu",trigger:x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",children:x.jsx(Ce,{icon:E4})}),children:x.jsxs("ul",{className:"flex items-start flex-col",children:[x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Bold",onClick:()=>p("bold"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.bold?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:y4,className:"mr-2"}),"Bold"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Italic",onClick:()=>p("italic"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.italic?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:x4,className:"mr-2"}),"Italic"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Underline",onClick:()=>p("underline"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.underline?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:g4,className:"mr-2"}),"Underline"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Strikethrough",onClick:()=>p("strikethrough"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.strikethrough?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:m4,className:"mr-2"}),"Strikethrough"]})}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Monospace",onClick:()=>p("code"),className:Ee("cursor-pointer w-full h-full justify-start text-left p-2 hover:bg-gray-100",a.code?"text-white bg-primary-600 hover:bg-primary-700":"text-gray-400 hover:text-gray-400"),children:[x.jsx(Ce,{icon:A4,className:"mr-2"}),"Monospace"]})}),x.jsx("hr",{className:"w-full border-gray-200"}),x.jsx("li",{className:"flex items-center w-full",children:x.jsxs("button",{type:"button",title:"Clear formatting",onClick:y,className:"cursor-pointer w-full h-full justify-start text-left p-2 text-gray-400 hover:text-gray-400 hover:bg-gray-100",children:[x.jsx(Ce,{icon:b4,className:"mr-2"}),"Clear formatting"]})})]})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format bullet list",onClick:g,children:x.jsx(Ce,{icon:S4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format numbered list",onClick:m,children:x.jsx(Ce,{icon:w4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Format link",onClick:()=>{o(!0),s.dispatchCommand($i,"https://")},children:x.jsx(Ce,{icon:_4})}),i&&x.jsxs(x.Fragment,{children:[x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Add image",className:"border-l-1 border-gray-200 rounded-none",onClick:()=>{var v;(v=f.current)==null||v.click()},children:x.jsx(Ce,{icon:v4})}),x.jsx(je,{category:"link",size:"smallCollapse",color:"gray400",title:"Add file",onClick:()=>{var v;(v=d.current)==null||v.click()},children:x.jsx(Ce,{icon:C4})})]}),n&&x.jsx(ff,{placement:"top-end",title:"comment type menu",trigger:x.jsx(je,{category:"link",size:"smallCollapse",className:`${h.iconColor} border-l-1 border-gray-200 rounded-none`,children:x.jsx(Ce,{icon:h.icon})}),children:x.jsx("ul",{className:"flex items-center justify-between gap-2 p-3",children:m1.map(v=>x.jsx("li",{children:x.jsx(je,{category:"link",size:"none",title:v.title,className:Ee(v.color,e===v.type?v.color:"text-gray-400"),onClick:()=>t==null?void 0:t(v.type),children:x.jsx(Ce,{icon:v.icon})})},v.type))})})]}),r,x.jsx("input",{type:"file",hidden:!0,id:"image-input",multiple:!0,ref:f,accept:"image/*",onChange:v=>{const b=v.target.files;b&&(i==null||i(b))}}),x.jsx("input",{type:"file",hidden:!0,id:"file-input",multiple:!0,ref:d,accept:"*",onChange:v=>{const b=v.target.files;b&&(i==null||i(b))}})]})}function ZN({hasStrictIndent:e=!1}){const[t]=ht();return T.useEffect(()=>{if(!t.hasNodes([aa,ts]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[t]),T.useEffect(()=>{if(e)return HN(t)},[t,e]),(function(n){T.useEffect(()=>KN(n),[n])})(t),null}function JN({validateUrl:e,attributes:t}){const[n]=ht();return T.useEffect(()=>{if(!n.hasNodes([Ho]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),T.useEffect(()=>QN(n,Yx({attributes:t,validateUrl:e})),[n,e,t]),null}const XN=new Set(["http:","https:","mailto:","sms:","tel:"]);function qg(e){try{const t=new URL(e);if(!XN.has(t.protocol))return"about:blank"}catch{return e}return e}function Vg(e,t,n,r=10,o=5){const i=n.parentElement;if(e===null||!i){t.style.opacity="0",t.style.transform="translate(-10000px, -10000px)";return}const s=t.getBoundingClientRect(),a=n.getBoundingClientRect(),l=i.getBoundingClientRect();let c=e.top-r,u=e.left-o;c<l.top&&(c+=s.height+e.height+r*2),u+s.width>l.right&&(u=l.right-s.width-o),c-=a.top,u-=a.left,t.style.opacity="1",t.style.transform=`translate(${u}px, ${c}px)`}function Al(e){const t=e.anchor,n=e.focus,r=e.anchor.getNode(),o=e.focus.getNode();return r===o?r:e.isBackward()?gg(n)?r:o:gg(t)?r:o}function e5({editor:e,isLink:t,setIsLink:n,anchorElem:r,isLinkEditMode:o,setIsLinkEditMode:i}){const s=T.useRef(null),[a,l]=T.useState(""),[c,u]=T.useState("https://"),[f,d]=T.useState(null),h=T.useCallback(()=>{var w,_;const m=Z();if($(m)){const E=Al(m),S=at(E,ut);S?l(S.getURL()):ut(E)?l(E.getURL()):l(""),o&&u(a)}else if(ot(m)){const E=m.getNodes();if(E.length>0){const S=E[0],O=S.getParent();ut(O)?l(O.getURL()):ut(S)?l(S.getURL()):l(""),o&&u(a)}}const y=s.current,v=en(e._window),b=document.activeElement;if(y===null)return;const A=e.getRootElement();if(m!==null&&A!==null&&e.isEditable()){let E;if(ot(m)){const S=m.getNodes();if(S.length>0){const O=e.getElementByKey(S[0].getKey());O&&(E=O.getBoundingClientRect())}}else v!==null&&A.contains(v.anchorNode)&&(E=(_=(w=v.focusNode)==null?void 0:w.parentElement)==null?void 0:_.getBoundingClientRect());E&&(E.y+=40,Vg(E,y,r)),d(m)}else(!b||b.className!=="link-input")&&(A!==null&&Vg(null,y,r),d(null),i(!1),l(""));return!0},[r,e,i,o,a]);T.useEffect(()=>{const m=r.parentElement,y=()=>{e.getEditorState().read(()=>{h()})};return window.addEventListener("resize",y),m&&m.addEventListener("scroll",y),()=>{window.removeEventListener("resize",y),m&&m.removeEventListener("scroll",y)}},[r.parentElement,e,h]),T.useEffect(()=>fn(e.registerUpdateListener(({editorState:m})=>{m.read(()=>{h()})}),e.registerCommand(Ql,()=>(h(),!0),Gn),e.registerCommand(Rd,()=>t?(n(!1),!0):!1,J3)),[e,h,n,t]),T.useEffect(()=>{e.getEditorState().read(()=>{h()})},[e,h]),T.useEffect(()=>{const m=s.current;if(m===null)return;const y=v=>{!m.contains(v.relatedTarget)&&t&&(n(!1),i(!1))};return m.addEventListener("focusout",y),()=>{m.removeEventListener("focusout",y)}},[n,i,t]);const p=m=>{m.key==="Enter"?g(m):m.key==="Escape"&&(m.preventDefault(),i(!1))},g=m=>{m.preventDefault(),f!==null&&(a!==""&&e.update(()=>{e.dispatchCommand($i,qg(c));const y=Z();if($(y)){const v=Al(y).getParent();if(so(v)){const b=Co(v.getURL(),{rel:v.__rel,target:v.__target,title:v.__title});v.replace(b,!0)}}}),u("https://"),i(!1))};return x.jsx("div",{ref:s,className:"absolute flex top-0 left-0 shadow-lg bg-white z-10 rounded-sm w-full max-w-400",children:t?o?x.jsxs("div",{className:"flex justify-between w-full items-center p-2",children:[x.jsx(ky,{containerClassName:"px-0 mr-2",autoFocus:!0,className:"mt-0",value:c,onChange:m=>{u(m.target.value)},onKeyDown:m=>{p(m)}}),x.jsxs("div",{className:"flex justify-center items-center gap-4",children:[x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>{i(!1)},children:x.jsx(Ce,{icon:Dl})}),x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:g,children:x.jsx(Ce,{icon:Fy})})]})]}):x.jsxs("div",{className:"flex justify-between w-full items-center p-2",children:[x.jsx("a",{href:qg(a),target:"_blank",rel:"noopener noreferrer",children:a}),x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>{u(a),i(!0)},children:x.jsx(Ce,{icon:WC})}),x.jsx(je,{size:"none",category:"link",color:"gray400",tabIndex:0,onMouseDown:m=>m.preventDefault(),onClick:()=>e.dispatchCommand($i,null),children:x.jsx(Ce,{icon:e_})})]})]}):null})}function t5(e,t,n,r){const[o,i]=T.useState(e),[s,a]=T.useState(!1);return T.useEffect(()=>{function l(){const c=Z();if($(c)){const u=Al(c),f=at(u,ut),d=at(u,so);if(!(f||d)){a(!1);return}const h=c.getNodes().filter(p=>!xo(p)).find(p=>{const g=at(p,ut),m=at(p,so);return f&&!f.is(g)||g&&!g.is(f)||d&&!d.is(m)||m&&(!m.is(d)||m.getIsUnlinked())});a(!h)}else if(ot(c)){const u=c.getNodes();if(u.length===0){a(!1);return}const f=u[0],d=f.getParent();ut(d)||ut(f)?a(!0):a(!1)}}return fn(e.registerUpdateListener(({editorState:c})=>{c.read(()=>{l()})}),e.registerCommand(Ql,(c,u)=>(l(),i(u),!1),fx),e.registerCommand(Md,c=>{const u=Z();if($(u)){const f=Al(u),d=at(f,ut);if(ut(d)&&(c.metaKey||c.ctrlKey))return window.open(d.getURL(),"_blank"),!0}return!1},Gn))},[e]),Nn.createPortal(x.jsx(e5,{editor:o,isLink:s,anchorElem:t,setIsLink:a,isLinkEditMode:n,setIsLinkEditMode:r}),t)}function n5({anchorElem:e=document.body,isLinkEditMode:t,setIsLinkEditMode:n}){const[r]=ht();return t5(r,e,t,n)}const r5=({url:e,onDelete:t})=>x.jsxs("div",{className:"relative",children:[x.jsx("img",{src:e,alt:"Thumbnail",width:75,height:75,className:"w-[75px] h-[75px] object-cover rounded-lg border border-gray-200"}),x.jsx(je,{size:"smallCollapse",title:"Delete attachment",onClick:t,className:"absolute top-1 left-1 w-[20px] h-[20px] rounded-full",color:"secondary",children:x.jsx(Ce,{icon:Dy})})]}),o5=({onRemoveFile:e,type:t,label:n})=>{const r=t.toLowerCase(),o=Pv(r);return x.jsxs("div",{className:"relative flex items-center justify-center rounded border border-gray-200",children:[x.jsx(je,{size:"smallCollapse",color:"secondary",className:"absolute top-1 left-1 w-[20px] h-[20px] rounded-full",title:"Remove file",onClick:e,children:x.jsx(Ce,{icon:Dy})}),x.jsxs("div",{className:"flex items-center justify-center mx-2",children:[x.jsx("span",{className:"text-primary-600 my-2",children:x.jsx(Ce,{icon:o,size:"3x",className:"text-primary-600"})}),x.jsx("span",{className:"font-bold p-2",children:n})]})]})},i5=({clearKey:e})=>{const[t]=ht(),n=T.useRef(e);return T.useEffect(()=>{n.current!==e&&(t.update(()=>{We().clear()}),n.current=e)},[e,t]),null},s5=({isOpen:e})=>{const[t]=ht(),n=T.useRef(!1);return T.useEffect(()=>{if(!e){n.current=!1;return}if(n.current)return;const r=()=>{const o=t.getRootElement();if(!o){requestAnimationFrame(r);return}n.current=!0;const i=window.scrollX,s=window.scrollY;try{o.focus({preventScroll:!0})}catch{o.focus()}requestAnimationFrame(()=>window.scrollTo(i,s)),setTimeout(()=>window.scrollTo(i,s),0)};r()},[t,e]),null},a5=({initialValue:e})=>{const[t]=ht(),n=T.useCallback((o,i)=>{const a=new DOMParser().parseFromString(i,"text/html");return Xx(o,a)},[]),r=T.useRef(!1);return T.useEffect(()=>{!r.current&&e&&(t.update(()=>{We().clear(),ox(n(t,e))}),r.current=!0)},[t,e,n]),null},l5=({onChange:e})=>{const[t]=ht();return x.jsx(ON,{onChange:n=>{n.read(()=>{const r=e1(t,null);e(r)})}})},c5=({onAddAttachments:e})=>{const[t]=ht();return T.useEffect(()=>{if(!e)return;const n=t.getRootElement();if(!n)return;const r=o=>{const i=o.clipboardData;if(!i)return;const s=i.items;let a=!1;for(let l=0;l<s.length;l++){const c=s[l];if(c.kind==="file"&&c.type.startsWith("image/")){a=!0;break}}if(a){for(let l=0;l<s.length;l++){const c=s[l];if(c.kind==="file"&&c.type.startsWith("image/")){const u=c.getAsFile();if(u){const f=Date.now(),d=u.type.split("/")[1]||"png",h=`image_${f}.${d}`,p=new File([u],h,{type:u.type});e==null||e([p])}}}o.preventDefault(),o.stopPropagation()}};return n.addEventListener("paste",r,!0),()=>{n.removeEventListener("paste",r,!0)}},[t,e]),null},u5=({onSubmit:e})=>{const[t]=ht();return T.useEffect(()=>{if(e)return t.registerCommand(Fs,n=>n&&!n.shiftKey?(n.preventDefault(),e(),!0):!1,1)},[t,e]),null},f5=({setIsLinkEditMode:e})=>{const[t]=ht();return T.useEffect(()=>{const n=t.getRootElement();if(!n)return;const r=o=>{const i=o.metaKey||o.ctrlKey,s=o.key==="k"||o.key==="K";i&&s&&t.getEditorState().read(()=>{const a=Z();$(a)&&!a.isCollapsed()&&(o.preventDefault(),e(!0),t.dispatchCommand($i,"https://"))})};return n.addEventListener("keydown",r),()=>{n.removeEventListener("keydown",r)}},[t,e]),null};function p1({attachments:e,clearKey:t=0,inputFieldClassName:n="",containerClassName:r="",initialValue:o,onChange:i,commentType:s,onCommentTypeChange:a,isCommentTypeEditable:l=!0,actions:c,onAddAttachments:u,onRemoveAttachment:f,onSubmit:d,isOpen:h}){const p={namespace:"comment-editor",theme:RN,nodes:[aa,ts,Ho],onError:w=>{console.error(w)}},[g,m]=T.useState(null),[y,v]=T.useState(!1),b=w=>{w!==null&&m(w)},A=uh[s];return x.jsx("div",{className:r,children:x.jsxs(T6,{initialConfig:p,children:[x.jsxs("div",{className:"relative",children:[x.jsx(bN,{contentEditable:x.jsx("div",{ref:b,children:x.jsx(SN,{className:Ee("p-3 outline-none border-0 w-full border-t border-gray-200 rounded-none border-l-3",A.bg,A.border,A.fontColor,n)})}),placeholder:x.jsx("div",{className:"absolute top-3 left-4 text-gray-400 pointer-events-none",children:"Type comment…"}),ErrorBoundary:LN}),x.jsx(ZN,{}),x.jsx(JN,{}),g&&x.jsx(n5,{anchorElem:g,isLinkEditMode:y,setIsLinkEditMode:v}),x.jsx(CN,{}),x.jsx(a5,{initialValue:o}),x.jsx(l5,{onChange:i}),x.jsx(u5,{onSubmit:d}),x.jsx(f5,{setIsLinkEditMode:v}),x.jsx(i5,{clearKey:t}),x.jsx(c5,{onAddAttachments:u}),x.jsx(s5,{isOpen:h})]}),e&&e.length>0&&x.jsx("div",{className:"flex flex-wrap justify-start gap-2 p-4",children:e.map(w=>md(w.type)?x.jsx(r5,{url:w.url,onDelete:()=>f==null?void 0:f(w.originFile)},w.originFile.name):x.jsx(o5,{type:w.type,label:w.name,onRemoveFile:()=>f==null?void 0:f(w.originFile)},w.originFile.name))}),x.jsx("div",{className:"border-t border-gray-200 p-2 flex justify-end",children:x.jsx(GN,{commentType:s,onCommentTypeChange:a,isCommentTypeEditable:l,actions:c,setIsLinkEditMode:v,onAddAttachments:u})})]})})}const d5=({asset:e,onSetActiveSrc:t})=>x.jsxs("div",{className:"relative border border-gray-200 rounded-md h-[110px] w-full hover:border-primary-500",children:[x.jsx("img",{src:$a(e),onClick:()=>t($a(e)),onKeyDown:n=>{n.key==="Enter"&&t($a(e))},alt:e.name,className:"w-full h-full object-cover rounded-md object-center cursor-zoom-in"}),(e==null?void 0:e.uploading)&&x.jsx("div",{className:"absolute bottom-2 w-full max-w-md mx-auto px-2",children:x.jsx("div",{className:"relative h-2 overflow-hidden rounded-full bg-gray-200",children:x.jsx("div",{className:"absolute left-0 top-0 h-full w-1/3 rounded-full bg-blue-500 animate-progress"})})})]}),h5=({asset:e})=>{var r,o;const t=((o=(r=e==null?void 0:e.mimeType)==null?void 0:r.split("/").pop())==null?void 0:o.toLowerCase())||"",n=Pv(t);return x.jsxs("div",{className:"flex gap-2",children:[(e==null?void 0:e.uploading)&&x.jsx("div",{className:"flex items-center justify-center",children:x.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-gray-300 border-t-blue-500 animate-spin"})}),x.jsx(Ce,{icon:n,size:"lg",className:"text-primary-600"}),x.jsx("a",{href:$a(e),className:"text-sm text-blue-600 underline",download:!0,target:"_blank",rel:"noopener noreferrer",children:e.name})]})},p5=({commentType:e=dt.INFO,author:t,username:n,comment:r,createdDate:o,onDelete:i,onEdit:s,hasAssets:a,taskAssets:l,taskVerified:c})=>{const f={[dt.INFO]:{bg:"bg-primary-100",border:"border-primary-200",icon:Ly,iconColor:"text-primary-600 hover:text-primary-600",text:"text-primary-900"},[dt.WARNING]:{bg:"bg-warning-100",border:"border-warning-200",icon:Oy,iconColor:"text-warning-600 hover:text-warning-600",text:"text-warning-900"},[dt.DANGER]:{bg:"bg-danger-100",border:"border-danger-200",icon:jy,iconColor:"text-danger-600 hover:text-danger-600",text:"text-danger-900"},[dt.SUCCESS]:{bg:"bg-success-100",border:"border-success-200",icon:My,iconColor:"text-success-600 hover:text-success-600",text:"text-success-900"}}[e],d=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(o||"")).replace(",",""),[h,p]=T.useState(!1),[g,m]=T.useState(zc(r)),[y,v]=T.useState(e),[b,A]=T.useState(""),w=()=>{p(!0)},_=()=>{const O=of.sanitize(g);s(O,y),p(!1)},E=O=>{const P=of.sanitize(g);v(O),s(P,O),p(!1)},S=()=>{p(!1)};return x.jsxs("div",{className:"flex items-start space-x-4 w-full",children:[x.jsx(jT,{alt:t}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:`border ${f.border} rounded-sm ${f.bg} shadow-sm flex flex-col items-start justify-between w-full`,children:[x.jsx("div",{className:"p-3 flex flex-col items-start justify-between w-full",children:x.jsxs("div",{className:"w-full",children:[x.jsxs("div",{className:"flex items-center mb-2 justify-between",children:[x.jsxs("div",{children:[x.jsx(Ce,{icon:f.icon,size:"lg",className:`mr-2 ${f.iconColor}`}),x.jsx("span",{className:`font-semibold text-sm ${f.text}`,children:t})]}),x.jsx($T,{commentType:e,taskVerified:c,isUsernameAuthor:n.trim()===t.trim(),onEdit:w,onSaveCommentType:E,onDelete:i})]}),h?x.jsx(p1,{inputFieldClassName:"bg-white border-0 rounded-sm",containerClassName:"bg-white border-0 rounded-sm",onChange:m,commentType:e,isCommentTypeEditable:!1,initialValue:zc(r),actions:x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(je,{category:"outline",size:"smallCollapse",color:"secondary",onClick:S,title:"Cancel edit",children:"Cancel"}),x.jsx(je,{category:"solid",size:"smallCollapse",color:"primary",onClick:_,title:"Save edit",disabled:Ua(g),children:"Save"})]})}):x.jsx("div",{className:`text-sm ${f.text}`,dangerouslySetInnerHTML:{__html:zc(r)}})]})}),a&&l&&(l==null?void 0:l.length)>0&&x.jsx("div",{className:`${f.border} border-t w-full p-2 flex gap-2 flex-wrap`,children:l.map(O=>x.jsx(T.Fragment,{children:md(O.mimeType)?x.jsx(d5,{asset:O,onSetActiveSrc:A}):x.jsx(h5,{asset:O})},O.assetId))})]}),x.jsxs("div",{className:"flex gap-2 my-1",children:[o&&x.jsx("time",{dateTime:o,className:"text-xs text-gray-500 opacity-60",children:d}),c&&x.jsxs("span",{className:"text-xs text-success-600 font-semibold flex items-center gap-1",children:[x.jsx(Ce,{icon:Iy}),"Comment Required"]})]})]}),x.jsx(bT,{plugins:[DT],open:!!b,zoom:{maxZoomPixelRatio:2},close:()=>A(""),styles:{root:{zIndex:9999999999}},carousel:{finite:!0,preload:0},controller:{closeOnBackdropClick:!0},slides:[{src:b}]})]})},uh={[dt.INFO]:{icon:r_,bg:"bg-primary-100",border:"border-l-primary-500",iconColor:"text-primary-600 hover:text-primary-700",fontColor:"text-primary-900"},[dt.WARNING]:{icon:KC,bg:"bg-warning-100",border:"border-l-warning-500",iconColor:"text-warning-600 hover:text-warning-700",fontColor:"text-warning-900"},[dt.DANGER]:{icon:s_,bg:"bg-danger-100",border:"border-l-danger-500",iconColor:"text-danger-600 hover:text-danger-700",fontColor:"text-danger-900"},[dt.SUCCESS]:{icon:Iy,bg:"bg-success-100",border:"border-l-success-500",iconColor:"text-success-600 hover:text-success-700",fontColor:"text-success-900"}},m1=Object.entries(uh).map(([e,t])=>({type:e,icon:t.icon,color:t.iconColor,title:`Change comment type to ${e}`})),m5=({comments:e,onClose:t,isOpen:n,taskName:r,taskInstanceId:o,isLoading:i,playbookInstanceId:s,taskVerification:a})=>{const[l,c]=T.useState(""),[u,f]=T.useState(dt.INFO),[d,h]=T.useState(0),[p,g]=T.useState([]),m=T.useRef(null),{username:y}=g1(),{manageComment:v}=ak({playbookInstanceId:s}),b=()=>{const P=p.length,W=p.some(z=>!md(z.mimeType))?"Attachment":"Image",j=P>1?"s":"";return`<p class="m-0"><span style="white-space: pre-wrap;">${W}${j} added.</span></p>`},A=P=>{const I=Array.from(P).map((W,j)=>J4(W,p.length+j+1));g(W=>[...W,...I])},w=P=>{g(I=>I.filter(W=>W.originFile!==P))},_=P=>{f(P)},E=async()=>{if(!p.length&&Ua(l)||!o)return;p.length>0&&g([]);const P=of.sanitize(l);c(""),h(I=>I+1),await v({action:"add",comment:p.length>0&&Ua(l)?b():P,username:y||"",commentType:u,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,hasAssets:p.length>0,taskInstanceId:o,taskVerified:a,attachments:p}),f(dt.INFO)},S=async P=>{o&&await v({username:y||"",action:"delete",taskVerified:!1,taskInstanceId:o,commentId:P})},O=async({commentId:P,comment:I,commentType:W,hasAssets:j,isAlreadyVerified:z})=>{o&&await v({action:"edit",username:y||"",...I&&{comment:I},taskInstanceId:o,commentId:P,hasAssets:j,taskVerified:z,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,commentType:W})};return T.useLayoutEffect(()=>{m.current&&n&&!i&&e.length>0&&(m.current.scrollTop=m.current.scrollHeight)},[n,i,e.length]),x.jsxs("div",{className:Ee("transition-all duration-300 fixed bg-white right-0 bottom-0 h-[100vh] z-[9999999998] flex flex-col min-w-[270px] max-w-[420px] w-[calc(100vw-1rem)] border border-gray-200 rounded-t-sm overflow-hidden",n?"translate-y-0 opacity-100":"translate-y-full opacity-0 pointer-events-none"),children:[x.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-200 px-2 py-4 w-full",children:[x.jsx("h6",{className:"font-semibold text-gray-900 truncate max-w-[300px]",children:r}),x.jsx(je,{color:"grayLight",size:"smallCollapse",rounded:"none",title:"Close comment box",onClick:t,children:x.jsx(Ce,{icon:Dl,className:"size-4 text-gray-300"})})]}),x.jsxs("div",{ref:m,className:"flex flex-col flex-1 overflow-y-auto",children:[x.jsxs("div",{className:"flex flex-col justify-end flex-1 gap-4 p-4 pb-[102px]",children:[i&&x.jsx("div",{className:"flex flex-col gap-3",children:[1,2,3].map(P=>x.jsx("div",{className:"h-16 animate-pulse rounded-lg bg-gray-100"},P))}),(e==null?void 0:e.length)>0&&!i&&e.map(P=>x.jsx(p5,{username:y||"",onDelete:()=>S(P.commentId),onEdit:(I,W)=>O({commentId:P.commentId,comment:I,commentType:W,hasAssets:P.hasAssets,isAlreadyVerified:P.taskVerified}),...P},P.commentId)),(e==null?void 0:e.length)===0&&!i&&x.jsxs("div",{className:"flex flex-1 flex-col items-center justify-end gap-3 text-center mb-1",children:[x.jsx("img",{src:G4,className:"opacity-70",alt:"Empty"}),x.jsx("p",{className:"text-gray-400",children:"There is no discussion in this Task."})]})]}),x.jsx(p1,{attachments:p,onChange:c,containerClassName:"fixed bottom-0 left-0 right-0 bg-white",clearKey:d,commentType:u,onCommentTypeChange:_,onAddAttachments:A,onRemoveAttachment:w,onSubmit:E,isOpen:n,actions:x.jsx(je,{category:"link",size:"normalCollapse",title:"Send comment",onClick:E,disabled:Ua(l)&&p.length===0,children:x.jsx(Ce,{icon:k4})})})]})]})},Kf=T.createContext({comments:[],openTaskDetails:null,username:void 0,setOpenTaskDetails:()=>{},prefetchQuery:e=>{}}),g1=()=>{if(!T.useContext(Kf))throw new Error("useCommentContext must be used within a CommentProvider");return T.useContext(Kf)},g5=({playbookInstanceId:e,children:t,username:n})=>{const[r,o]=T.useState({taskInstanceId:null,taskName:"",taskVerification:!1}),{taskInstanceId:i,taskName:s,taskVerification:a}=r||{taskInstanceId:null,taskName:"",taskVerification:!1},{comments:l,isLoading:c,prefetchQuery:u}=rk({taskInstanceId:i||0,enabled:i!==null,username:n});return x.jsxs(Kf.Provider,{value:{comments:l,openTaskDetails:r,setOpenTaskDetails:o,prefetchQuery:u,username:n},children:[t,Nn.createPortal(x.jsxs("div",{id:"cnfdnc-comment-box-root",children:[x.jsx("style",{children:qs}),x.jsx("div",{className:"confidence-playbook",children:x.jsx(m5,{playbookInstanceId:e,comments:l,onClose:()=>o(null),isOpen:!!i,taskName:s,taskInstanceId:i,isLoading:c,taskVerification:a})})]}),T4)]})},y5={[Be.OPEN]:"border-[#C1C5C8] bg-[#F0F1F2]",[Be.IN_PROGRESS]:"bg-[#E6F2FF] border-[#94C8FF]",[Be.IN_REVIEW]:"bg-[#EAF6EC] border-[#A5DAB1]",[Be.COMPLETED]:"bg-[#EAF6EC] border-[#A5DAB1]"},Bn={PHOTO:"photo",SCREENSHOT:"screenshot",COMMENT:"comment",NO_VERIFICATION:null},v5=({task:e,step:t,playbookType:n,onButtonClick:r,viewMode:o="card",canStart:i=!1,isExpanded:s=!1,toggleExpanded:a,playbookId:l,taskStyle:c,listStickyTopBase:u})=>{const[f,d]=T.useState(!1),{taskDetails:h,prefetchQuery:p}=OS({taskId:e.taskId,playbookId:l,enabled:s}),{setOpenTaskDetails:g,prefetchQuery:m}=g1(),{buttons:y}=zw({taskStatus:e.workflowStatus,canStart:i}),v=T.useMemo(()=>e.imageRequired===0?Bn.NO_VERIFICATION:e.imageRequired===1?Bn.SCREENSHOT:e.imageRequired===2?Bn.PHOTO:e.imageRequired===4?Bn.COMMENT:null,[e.imageRequired]),b=async A=>{try{d(!0),await r(A)}finally{d(!1)}};if(o==="list"){const A=T.useMemo(()=>e.workflowStatus===Be.COMPLETED?"success":e.workflowStatus===Be.IN_PROGRESS?"primary":"default",[e.workflowStatus]),w=T.useMemo(()=>{const _=[];return y.forEach(E=>{E==="START"&&_.push({id:"START",color:"primary",action:"Start",to:Be.IN_PROGRESS}),E==="COMPLETE"&&(!e.taskVerified&&v===Bn.COMMENT&&_.push({id:"ADD_COMMENT",color:"danger",action:"Add Comment",to:"Required"}),_.push({id:"COMPLETE",color:"success",action:"Complete",to:Be.COMPLETED,disabled:!e.taskVerified&&v===Bn.COMMENT}))}),_},[y,v,e.taskVerified]);return x.jsxs("div",{className:Ee("flex flex-col"),children:[x.jsxs("div",{className:Ee("flex items-center gap-3 p-2 border-gray-200",e.sequenceOrder>0&&"border-t",s&&"bg-white rounded-md border border-t-none shadow-sm sticky"),style:{top:s?u:0},children:[x.jsx("div",{className:"text-gray-200 text-base",children:e.sequenceOrder+1}),x.jsx("div",{onClick:()=>{a==null||a(!s)},onMouseOver:p,className:Ee("flex-1 truncate cursor-pointer",s&&"font-medium",e.workflowStatus===Be.COMPLETED&&"text-secondary-400 line-through"),style:{color:e.workflowStatus===Be.IN_PROGRESS&&(c==null?void 0:c.titleColor)||"#1C232D"},children:e.taskInstanceName}),x.jsx(a4,{taskVerified:e.taskVerified,verificationType:v,title:e.workflowStatus,variant:A,transitions:w,onClick:_=>{if(_===ui.ADD_COMMENT){g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!0});return}r(_)}}),x.jsx(Yp,{onMouseOver:()=>m(e.taskInstanceId),commentsCount:(e==null?void 0:e.numberOfComments)||0,commentType:(e==null?void 0:e.recentCommentType)||dt.INFO,onClick:()=>g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!1})})]}),(h==null?void 0:h.description)&&x.jsx("div",{className:Ee(!s&&"hidden","border-gray-200 border p-2 mx-4 mb-4 border-t-none -mt-[1px] bg-gray-100 rounded-b-md"),children:x.jsx(Vp,{description:(h==null?void 0:h.description)||""})})]})}return x.jsxs("div",{className:Ss("flex items-stretch rounded-sm overflow-hidden border",y5[e.workflowStatus]),children:[x.jsx(f4,{playbookType:n,status:e.workflowStatus,step:t}),x.jsxs("div",{className:"flex w-full flex-col overflow-x-hidden flex-1 p-2",children:[n==="Sequential"&&x.jsx("div",{className:"-mb-3 self-end pr-2 pt-2",children:x.jsx(h4,{status:e.workflowStatus})}),x.jsxs("div",{className:"space-y-2 divide-y divide-black/10 flex flex-col flex-1",children:[x.jsx("div",{className:Ee("text-lg font-medium flex-1 pb-1"),style:{color:e.workflowStatus==="Completed"?"#1C232D":(c==null?void 0:c.titleColor)||"#1C232D"},children:e.taskInstanceName}),v?x.jsxs("div",{className:"flex items-center gap-2 text-sm pb-2",children:[x.jsx(Ce,{icon:Py,className:"size-4"}),x.jsxs("div",{children:[x.jsx("span",{className:"font-medium",children:v===Bn.PHOTO?"Photo":v===Bn.SCREENSHOT?"Screenshot":"Comment"})," ","required"]})]}):x.jsx(x.Fragment,{})]}),(h==null?void 0:h.description)&&x.jsx("div",{className:Ee(!s&&"hidden"),children:x.jsx(Vp,{description:(h==null?void 0:h.description)||""})}),(y.length>0||e.hasDescription)&&x.jsxs("div",{className:"flex items-center justify-end gap-4 border-t border-black/10 pt-2",children:[x.jsx("div",{className:"flex-1",children:x.jsx(PS,{buttons:y,onButtonClick:b,disabled:f})}),x.jsx(Yp,{onMouseOver:()=>m(e.taskInstanceId),commentsCount:(e==null?void 0:e.numberOfComments)||0,commentType:(e==null?void 0:e.recentCommentType)||dt.INFO,onClick:()=>g({taskInstanceId:e.taskInstanceId,taskName:e.taskInstanceName,taskVerification:!1})}),a&&x.jsx(je,{size:"smallCollapse",onMouseOver:p,category:"link",onClick:()=>{a()},title:s?"Hide task description":"Show task description",children:x.jsx(Ce,{icon:Ry,className:Ss("cursor-pointer text-[#0069D9]",s?"rotate-180":"")})})]})]})]})},y1=T.forwardRef(({title:e,className:t,playbookStyle:n,...r},o)=>{var i,s,a;return x.jsx("div",{ref:o,className:Ee("border-b border-gray-200 flex items-center",t),style:{backgroundColor:((i=n==null?void 0:n.whiteLabel)==null?void 0:i.titleBackgroundColor)||"#f8f9fa"},...r,children:x.jsx("div",{className:Ee("text-xl min-h-16 p-4 font-medium flex-1",{"text-dark":!((s=n==null?void 0:n.whiteLabel)!=null&&s.titleTextColor)}),style:{color:(a=n==null?void 0:n.whiteLabel)==null?void 0:a.titleTextColor},children:e})})});y1.displayName="PlaybookHeader";const b5=({playbookInstanceId:e,playbookMode:t,playbookStyle:n})=>{const{playbook:r,actions:o}=Fw(e);if(!r)return x.jsx("div",{});const i=async(s,a)=>{var l;if(s===ui.COMPLETE){const c=(l=r.tasks.find(u=>u.taskInstanceId===a))==null?void 0:l.sequenceOrder;if(c===void 0){console.error("Task not found in playbook");return}return o.completeTask(a,c)}if(s===ui.START)return o.startTask(a)};return x.jsx("div",{className:"confidence-playbook",children:x.jsx(v1,{playbook:r,playbookMode:t,onTaskButtonClick:i,playbookStyle:n})})},x5=({className:e,children:t,numberOfTasks:n,playbookMode:r})=>x.jsxs("div",{className:Ee("w-full p-4",e),children:[n&&x.jsxs("div",{className:Ee(r==="card"&&"mb-4"),children:[x.jsx("span",{className:"font-medium",children:"Tasks"})," (",n,")"]}),x.jsx("div",{className:Ee(r==="card"&&"space-y-4"),children:t})]}),v1=({playbook:e,playbookMode:t,onTaskButtonClick:n,playbookStyle:r})=>{var m,y,v,b,A;const{playbookInstanceName:o,tasks:i}=e,s=T.useRef(null),[a,l]=T.useState(0),[c,u]=T.useState(!0),f=()=>{u(!c)},{isTaskExpanded:d,toggleTaskExpanded:h,isAtLeastOneTaskExpanded:p}=T0(e.playbookInstanceId,{onTaskExpanded:()=>{var w;l(((w=s.current)==null?void 0:w.offsetHeight)||0)}});T.useEffect(()=>{if(p){if(!s.current)throw new Error("Playbook header ref is not set");new ResizeObserver(_=>{var E;for(const S of _)S.contentRect&&l(((E=s.current)==null?void 0:E.offsetHeight)||0)}).observe(s.current)}return()=>{s.current&&new ResizeObserver(()=>{}).unobserve(s.current)}},[p]);const g=T.useMemo(()=>{const w=i.filter(_=>_.workflowStatus===Be.COMPLETED).sort((_,E)=>E.sequenceOrder-_.sequenceOrder)[0];return w?w.sequenceOrder+1:0},[i]);return x.jsxs("div",{className:Ee(!(r!=null&&r.overlay)&&"min-h-screen",(r==null?void 0:r.overlay)&&"fixed bottom-0 z-[9999999997] flex","transition-all duration-300 ease-in-out "),...(r==null?void 0:r.overlay)&&{style:{width:"100%",maxWidth:c?((m=r.overlay.size)==null?void 0:m.width)||450:"2.25rem",height:((y=r.overlay.size)==null?void 0:y.height)||"calc(100vh - 4rem)",maxHeight:"calc(100vh - 4rem)",right:((v=r.overlay.offset)==null?void 0:v.right)!==void 0?r.overlay.offset.right:r.overlay.position==="right"?32:void 0,left:((b=r.overlay.offset)==null?void 0:b.left)!==void 0?r.overlay.offset.left:r.overlay.position==="left"?32:void 0}},children:[(r==null?void 0:r.overlay)&&x.jsx("div",{onClick:f,className:Ee("size-9 relative p-1 top-3 z-[9999999997] border-none rounded-l-sm cursor-pointer"),style:{backgroundColor:((A=r==null?void 0:r.whiteLabel)==null?void 0:A.primaryColor)||"#007BFF",boxShadow:"0px 3px 3px 0px #00000040"},children:x.jsx("img",{src:h0,alt:"Confidence Logo",className:"w-full h-full object-contain"})}),x.jsxs("div",{className:Ee("flex flex-col flex-1 bg-gray-50",(r==null?void 0:r.overlay)&&"border border-gray-200 shadow-2xl rounded-t-sm overflow-y-auto"),children:[x.jsx(y1,{title:o,className:Ee("top-0 sticky z-2"),playbookStyle:r,ref:s}),x.jsx(x5,{playbookMode:t,numberOfTasks:e.numberofTasks,children:i.map((w,_)=>{var E;return x.jsx(v5,{task:w,step:_+1,viewMode:t,playbookId:e.playbookId,canStart:w.sequenceOrder===g,onButtonClick:S=>n(S,w.taskInstanceId),playbookType:"Non-Sequential",taskStyle:{titleColor:(E=r==null?void 0:r.whiteLabel)==null?void 0:E.primaryColor},isExpanded:d(w.taskInstanceId),toggleExpanded:()=>h(w.taskInstanceId),listStickyTopBase:a||104},w.taskId)})})]})]})},w5=({email:e,playbookId:t,playbookMode:n,playbookStyle:r,bank:o="public-sdk",timezone:i="America/Los_Angeles",persistKey:s})=>{const[a,l]=T.useState(null);return T.useEffect(()=>{(async()=>{const c=H0(t,s);if(c&&c.email===e){l(c.playbookInstanceId);return}const{playbookInstanceId:u,errorCode:f,details:d,message:h}=await N0({bank:o,email:e,timezone:i,playbookUid:t})||{};if(f)throw new Error(`Error initiating playbook: ${h} (Code: ${f}) - Details: ${d}`);if(!u)throw new Error("No playbook instance ID returned from initiation");K0(t,u,e,s),l(u)})()},[]),a?x.jsx(Hr,{playbookInstanceId:a,playbookMode:n,playbookStyle:r,username:e}):null},A5=({playbookId:e,playbookMode:t="list",playbookStyle:n,btnLabel:r="Start Playbook",btnColor:o="primary",persistKey:i})=>{const[s,a]=T.useState(null),[l,c]=T.useState(void 0);return T.useEffect(()=>{const u=H0(e,i);u&&(a(u.playbookInstanceId),c(u.email))},[e,i]),x.jsxs(x.Fragment,{children:[x.jsxs(Cl.div,{children:[x.jsx(FC,{playbookId:e,disabled:!!s,onInitiated:(u,f)=>{K0(e,u,f,i),a(u),c(f)},btnLabel:r,btnColor:o}),x.jsx("style",{type:"text/css",children:qs})]}),s&&x.jsx(Hr,{playbookInstanceId:s,playbookMode:t,playbookStyle:n,username:l})]})},Hr=({playbookInstanceId:e,playbookMode:t,playbookStyle:n,username:r})=>(console.log("Starting ConfidencePlaybook with instance ID:",e,r),x.jsx(S0,{children:x.jsx(g5,{playbookInstanceId:e,username:r,children:x.jsx(b5,{playbookInstanceId:e,playbookMode:t,playbookStyle:n})})}));Hr.Context=S0;Hr.View=v1;Hr.AutoInstantiated=w5;Hr.WithInstantiateButton=A5;const b1=e=>Nn.createPortal(x.jsxs(Cl.div,{style:{position:"relative",zIndex:2147483646},children:[x.jsx("style",{children:qs}),x.jsx(Hr,{...e})]}),document.body),C5=e=>Nn.createPortal(x.jsxs(Cl.div,{style:{position:"relative",zIndex:2147483646},children:[x.jsx("style",{children:qs}),x.jsx(Hr.AutoInstantiated,{...e})]}),document.body);b1.AutoInstantiated=C5;exports.ConfidencePlaybook=b1;
package/dist/index.js CHANGED
@@ -23394,6 +23394,8 @@ const F5 = ({
23394
23394
  throw new Error(
23395
23395
  `Error initiating playbook: ${h} (Code: ${f}) - Details: ${d}`
23396
23396
  );
23397
+ if (!u)
23398
+ throw new Error("No playbook instance ID returned from initiation");
23397
23399
  iy(t, u, e, s), l(u);
23398
23400
  })();
23399
23401
  }, []), a ? /* @__PURE__ */ S(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@confidencesystemsinc/sdk",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",