@qwanyx/stack 0.2.117 → 0.2.118
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.js +26 -26
- package/dist/index.esm.js +1439 -1449
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -41,20 +41,20 @@ ${s}
|
|
|
41
41
|
*
|
|
42
42
|
* This source code is licensed under the MIT license found in the
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/var ka;function cf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var U=g&&A[g]||A[m];return typeof U=="function"?U:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var U=arguments.length,ne=new Array(U>1?U-1:0),
|
|
45
|
-
`+
|
|
46
|
-
`),gt=
|
|
47
|
-
`),nt=
|
|
48
|
-
`+
|
|
44
|
+
*/var ka;function cf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var U=g&&A[g]||A[m];return typeof U=="function"?U:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var U=arguments.length,ne=new Array(U>1?U-1:0),ye=1;ye<U;ye++)ne[ye-1]=arguments[ye];S("error",A,ne)}}function S(A,U,ne){{var ye=_.ReactDebugCurrentFrame,$e=ye.getStackAddendum();$e!==""&&(U+="%s",ne=ne.concat([$e]));var qe=ne.map(function(Ie){return String(Ie)});qe.unshift("Warning: "+U),Function.prototype.apply.call(console[A],console,qe)}}var C=!1,k=!1,E=!1,v=!1,T=!1,B;B=Symbol.for("react.module.reference");function j(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||T||A===s||A===u||A===c||v||A===p||C||k||E||typeof A=="object"&&A!==null&&(A.$$typeof===h||A.$$typeof===d||A.$$typeof===o||A.$$typeof===a||A.$$typeof===l||A.$$typeof===B||A.getModuleId!==void 0))}function N(A,U,ne){var ye=A.displayName;if(ye)return ye;var $e=U.displayName||U.name||"";return $e!==""?ne+"("+$e+")":ne}function R(A){return A.displayName||"Context"}function M(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var U=A;return R(U)+".Consumer";case o:var ne=A;return R(ne._context)+".Provider";case l:return N(A,A.render,"ForwardRef");case d:var ye=A.displayName||null;return ye!==null?ye:M(A.type)||"Memo";case h:{var $e=A,qe=$e._payload,Ie=$e._init;try{return M(Ie(qe))}catch{return null}}}return null}var w=Object.assign,D=0,F,I,q,Z,te,W,Q;function H(){}H.__reactDisabledLog=!0;function ie(){{if(D===0){F=console.log,I=console.info,q=console.warn,Z=console.error,te=console.group,W=console.groupCollapsed,Q=console.groupEnd;var A={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}D++}}function ue(){{if(D--,D===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:w({},A,{value:F}),info:w({},A,{value:I}),warn:w({},A,{value:q}),error:w({},A,{value:Z}),group:w({},A,{value:te}),groupCollapsed:w({},A,{value:W}),groupEnd:w({},A,{value:Q})})}D<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=_.ReactCurrentDispatcher,we;function fe(A,U,ne){{if(we===void 0)try{throw Error()}catch($e){var ye=$e.stack.trim().match(/\n( *(at )?)/);we=ye&&ye[1]||""}return`
|
|
45
|
+
`+we+A}}var Ce=!1,O;{var je=typeof WeakMap=="function"?WeakMap:Map;O=new je}function re(A,U){if(!A||Ce)return"";{var ne=O.get(A);if(ne!==void 0)return ne}var ye;Ce=!0;var $e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var qe;qe=de.current,de.current=null,ie();try{if(U){var Ie=function(){throw Error()};if(Object.defineProperty(Ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ie,[])}catch(vt){ye=vt}Reflect.construct(A,[],Ie)}else{try{Ie.call()}catch(vt){ye=vt}A.call(Ie.prototype)}}else{try{throw Error()}catch(vt){ye=vt}A()}}catch(vt){if(vt&&ye&&typeof vt.stack=="string"){for(var Fe=vt.stack.split(`
|
|
46
|
+
`),gt=ye.stack.split(`
|
|
47
|
+
`),nt=Fe.length-1,it=gt.length-1;nt>=1&&it>=0&&Fe[nt]!==gt[it];)it--;for(;nt>=1&&it>=0;nt--,it--)if(Fe[nt]!==gt[it]){if(nt!==1||it!==1)do if(nt--,it--,it<0||Fe[nt]!==gt[it]){var Nt=`
|
|
48
|
+
`+Fe[nt].replace(" at new "," at ");return A.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",A.displayName)),typeof A=="function"&&O.set(A,Nt),Nt}while(nt>=1&&it>=0);break}}}finally{Ce=!1,de.current=qe,ue(),Error.prepareStackTrace=$e}var Or=A?A.displayName||A.name:"",vr=Or?fe(Or):"";return typeof A=="function"&&O.set(A,vr),vr}function Le(A,U,ne){return re(A,!1)}function Me(A){var U=A.prototype;return!!(U&&U.isReactComponent)}function xe(A,U,ne){if(A==null)return"";if(typeof A=="function")return re(A,Me(A));if(typeof A=="string")return fe(A);switch(A){case u:return fe("Suspense");case c:return fe("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return Le(A.render);case d:return xe(A.type,U,ne);case h:{var ye=A,$e=ye._payload,qe=ye._init;try{return xe(qe($e),U,ne)}catch{}}}return""}var Se=Object.prototype.hasOwnProperty,Re={},se=_.ReactDebugCurrentFrame;function ce(A){if(A){var U=A._owner,ne=xe(A.type,A._source,U?U.type:null);se.setExtraStackFrame(ne)}else se.setExtraStackFrame(null)}function $(A,U,ne,ye,$e){{var qe=Function.call.bind(Se);for(var Ie in A)if(qe(A,Ie)){var Fe=void 0;try{if(typeof A[Ie]!="function"){var gt=Error((ye||"React class")+": "+ne+" type `"+Ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}Fe=A[Ie](U,Ie,ye,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(nt){Fe=nt}Fe&&!(Fe instanceof Error)&&(ce($e),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ye||"React class",ne,Ie,typeof Fe),ce(null)),Fe instanceof Error&&!(Fe.message in Re)&&(Re[Fe.message]=!0,ce($e),b("Failed %s type: %s",ne,Fe.message),ce(null))}}}var Ge=Array.isArray;function Ke(A){return Ge(A)}function X(A){{var U=typeof Symbol=="function"&&Symbol.toStringTag,ne=U&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ne}}function K(A){try{return pe(A),!1}catch{return!0}}function pe(A){return""+A}function De(A){if(K(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",X(A)),pe(A)}var Be=_.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Et,ae;function me(A){if(Se.call(A,"ref")){var U=Object.getOwnPropertyDescriptor(A,"ref").get;if(U&&U.isReactWarning)return!1}return A.ref!==void 0}function Ye(A){if(Se.call(A,"key")){var U=Object.getOwnPropertyDescriptor(A,"key").get;if(U&&U.isReactWarning)return!1}return A.key!==void 0}function at(A,U){typeof A.ref=="string"&&Be.current}function He(A,U){{var ne=function(){Et||(Et=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",U))};ne.isReactWarning=!0,Object.defineProperty(A,"key",{get:ne,configurable:!0})}}function Xe(A,U){{var ne=function(){ae||(ae=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",U))};ne.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ne,configurable:!0})}}var br=function(A,U,ne,ye,$e,qe,Ie){var Fe={$$typeof:e,type:A,key:U,ref:ne,props:Ie,_owner:qe};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ye}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:$e}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function J(A,U,ne,ye,$e){{var qe,Ie={},Fe=null,gt=null;ne!==void 0&&(De(ne),Fe=""+ne),Ye(U)&&(De(U.key),Fe=""+U.key),me(U)&&(gt=U.ref,at(U,$e));for(qe in U)Se.call(U,qe)&&!Qe.hasOwnProperty(qe)&&(Ie[qe]=U[qe]);if(A&&A.defaultProps){var nt=A.defaultProps;for(qe in nt)Ie[qe]===void 0&&(Ie[qe]=nt[qe])}if(Fe||gt){var it=typeof A=="function"?A.displayName||A.name||"Unknown":A;Fe&&He(Ie,it),gt&&Xe(Ie,it)}return br(A,Fe,gt,$e,ye,Be.current,Ie)}}var P=_.ReactCurrentOwner,he=_.ReactDebugCurrentFrame;function ge(A){if(A){var U=A._owner,ne=xe(A.type,A._source,U?U.type:null);he.setExtraStackFrame(ne)}else he.setExtraStackFrame(null)}var Y;Y=!1;function Ae(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Ee(){{if(P.current){var A=M(P.current.type);if(A)return`
|
|
49
49
|
|
|
50
|
-
Check the render method of \``+A+"`."}return""}}function Te(A){return""}var
|
|
50
|
+
Check the render method of \``+A+"`."}return""}}function Te(A){return""}var Pe={};function We(A){{var U=Ee();if(!U){var ne=typeof A=="string"?A:A.displayName||A.name;ne&&(U=`
|
|
51
51
|
|
|
52
|
-
Check the top-level render call using <`+ne+">.")}return U}}function ke(A,U){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ne=
|
|
52
|
+
Check the top-level render call using <`+ne+">.")}return U}}function ke(A,U){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ne=We(U);if(Pe[ne])return;Pe[ne]=!0;var ye="";A&&A._owner&&A._owner!==P.current&&(ye=" It was passed a child from "+M(A._owner.type)+"."),ge(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,ye),ge(null)}}function L(A,U){{if(typeof A!="object")return;if(Ke(A))for(var ne=0;ne<A.length;ne++){var ye=A[ne];Ae(ye)&&ke(ye,U)}else if(Ae(A))A._store&&(A._store.validated=!0);else if(A){var $e=x(A);if(typeof $e=="function"&&$e!==A.entries)for(var qe=$e.call(A),Ie;!(Ie=qe.next()).done;)Ae(Ie.value)&&ke(Ie.value,U)}}}function be(A){{var U=A.type;if(U==null||typeof U=="string")return;var ne;if(typeof U=="function")ne=U.propTypes;else if(typeof U=="object"&&(U.$$typeof===l||U.$$typeof===d))ne=U.propTypes;else return;if(ne){var ye=M(U);$(ne,A.props,"prop",ye,A)}else if(U.PropTypes!==void 0&&!Y){Y=!0;var $e=M(U);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",$e||"Unknown")}typeof U.getDefaultProps=="function"&&!U.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _e(A){{for(var U=Object.keys(A.props),ne=0;ne<U.length;ne++){var ye=U[ne];if(ye!=="children"&&ye!=="key"){ge(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ye),ge(null);break}}A.ref!==null&&(ge(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),ge(null))}}var ve={};function Ne(A,U,ne,ye,$e,qe){{var Ie=j(A);if(!Ie){var Fe="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Fe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var gt=Te();gt?Fe+=gt:Fe+=Ee();var nt;A===null?nt="null":Ke(A)?nt="array":A!==void 0&&A.$$typeof===e?(nt="<"+(M(A.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):nt=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",nt,Fe)}var it=J(A,U,ne,$e,qe);if(it==null)return it;if(Ie){var Nt=U.children;if(Nt!==void 0)if(ye)if(Ke(Nt)){for(var Or=0;Or<Nt.length;Or++)L(Nt[Or],A);Object.freeze&&Object.freeze(Nt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else L(Nt,A)}if(Se.call(U,"key")){var vr=M(A),vt=Object.keys(U).filter(function(Rd){return Rd!=="key"}),Si=vt.length>0?"{key: someKey, "+vt.join(": ..., ")+": ...}":"{key: someKey}";if(!ve[vr+Si]){var Md=vt.length>0?"{"+vt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
53
53
|
let props = %s;
|
|
54
54
|
<%s {...props} />
|
|
55
55
|
React keys must be passed directly to JSX without using spread:
|
|
56
56
|
let props = %s;
|
|
57
|
-
<%s key={someKey} {...props} />`,Si,vr,Md,vr),
|
|
57
|
+
<%s key={someKey} {...props} />`,Si,vr,Md,vr),ve[vr+Si]=!0}}return A===n?_e(it):be(it),it}}function st(A,U,ne){return Ne(A,U,ne,!0)}function ct(A,U,ne){return Ne(A,U,ne,!1)}var bt=ct,Xt=st;dn.Fragment=n,dn.jsx=bt,dn.jsxs=Xt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=uf():Vi.exports=cf();var f=Vi.exports;const lu=y.createContext(void 0);function df({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[a,l]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),h=y.useCallback(async k=>{const E=await d.isAdmin(k);l(E)},[d]),p=y.useCallback(()=>{const k=Je.getToken(),E=Je.getUser();k&&E?(o(k),s(E),h(E._id).finally(()=>c(!1))):c(!1)},[h]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(k,E)=>{const v=await d.login(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),m=y.useCallback(async(k,E,v)=>d.register(k,E,v),[d]),x=y.useCallback(async(k,E)=>{const v=await d.verifyEmail(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),_=y.useCallback(async k=>d.requestPasswordReset(k),[d]),b=y.useCallback(async(k,E,v)=>{const T=await d.setPasswordWithCode(k,E,v);return T.success&&T.user&&T.token&&(o(T.token),s(T.user),await h(T.user._id)),T},[d,h]),S=y.useCallback(async k=>d.resendVerificationCode(k),[d]),C=y.useCallback(()=>{d.logout(),s(null),o(null),l(!1)},[d]);return f.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:a,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:_,setPasswordWithCode:b,resendVerificationCode:S,logout:C,refreshUser:p},children:t})}function ff(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const hf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:a="Mot de passe",onForgotPasswordClick:l,onRegisterClick:u,forgotPasswordText:c="Mot de passe oublie ?",registerText:d="Creer un compte",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(!1),v={...hf,...h};async function T(w){w.preventDefault(),E(!0),C("");const D=await r(m,_);D.success?e==null||e():C(D.error||"Connexion impossible"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},M={padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"};return f.jsxs("div",{style:B,className:p,children:[t&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),f.jsxs("form",{onSubmit:T,children:[S&&f.jsx("div",{style:M,children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:S})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:o}),f.jsx("input",{type:"email",value:m,onChange:w=>x(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:a}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsx("button",{type:"submit",disabled:k,style:R,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?i:s}),(l||u)&&f.jsxs("div",{style:{display:"flex",justifyContent:l&&u?"space-between":"center",marginTop:"1rem"},children:[l&&f.jsx("button",{type:"button",onClick:l,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:c}),u&&f.jsx("button",{type:"button",onClick:u,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:d})]})]})]})}function pf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){if(!r)return null;const s={position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},i={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},o={position:"relative",animation:"slideUp 0.2s ease-out"};return f.jsxs("div",{style:s,children:[f.jsx("div",{style:i,onClick:e}),f.jsxs("div",{style:o,children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},onMouseEnter:a=>{a.target.style.color="#4B5563"},onMouseLeave:a=>{a.target.style.color="#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(No,{...n,isModal:!0})]}),f.jsx("style",{children:`
|
|
58
58
|
@keyframes slideUp {
|
|
59
59
|
from {
|
|
60
60
|
opacity: 0;
|
|
@@ -65,7 +65,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
65
65
|
transform: translateY(0);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:h="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(""),[v,T]=y.useState(""),[B,j]=y.useState(""),[N,R]=y.useState(""),[M,w]=y.useState(!1),D={...gf,...g};async function F(H){if(H.preventDefault(),R(""),S!==k){R("Les mots de passe ne correspondent pas");return}if(S.length<8){R("Le mot de passe doit contenir au moins 8 caractères");return}w(!0);const le=await r(_,S,p?{firstName:v,lastName:B}:void 0);le.success?e==null||e(_):R(le.error||"Erreur lors de l'inscription"),w(!1)}const z={backgroundColor:D.backgroundColor,borderRadius:D.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${D.borderColor}`,borderRadius:D.borderRadius,backgroundColor:D.inputBackground,color:D.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},J={display:"block",fontSize:"0.875rem",fontWeight:500,color:D.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:M?D.textMutedColor:D.primaryColor,color:"#ffffff",border:"none",borderRadius:D.borderRadius,fontSize:"1rem",fontWeight:500,cursor:M?"not-allowed":"pointer",transition:"background-color 0.2s"},W={padding:"0.75rem",backgroundColor:D.errorBackgroundColor,border:`1px solid ${D.errorColor}20`,borderRadius:D.borderRadius,marginBottom:"1rem"},G={color:D.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return f.jsxs("div",{style:z,className:m,children:[n&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:D.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),f.jsxs("form",{onSubmit:F,children:[N&&f.jsx("div",{style:W,children:f.jsx("p",{style:{fontSize:"0.875rem",color:D.errorColor,margin:0},children:N})}),p&&f.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:c}),f.jsx("input",{type:"text",value:v,onChange:H=>T(H.target.value),style:q})]}),f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:d}),f.jsx("input",{type:"text",value:B,onChange:H=>j(H.target.value),style:q})]})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:a}),f.jsx("input",{type:"email",value:_,onChange:H=>b(H.target.value),required:!0,style:q})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:l}),f.jsx("input",{type:"password",value:S,onChange:H=>C(H.target.value),required:!0,minLength:8,style:q})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:J,children:u}),f.jsx("input",{type:"password",value:k,onChange:H=>E(H.target.value),required:!0,style:q})]}),f.jsx("button",{type:"submit",disabled:M,style:te,onMouseEnter:H=>{M||(H.target.style.backgroundColor=D.primaryHoverColor)},onMouseLeave:H=>{M||(H.target.style.backgroundColor=D.primaryColor)},children:M?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("span",{style:G,onClick:t,children:h})})]})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:a="Vérifier",loadingText:l="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:h=6,theme:p,className:g="",isModal:m=!1}){const[x,_]=y.useState(Array(h).fill("")),[b,S]=y.useState(""),[C,k]=y.useState(!1),[E,v]=y.useState(!1),[T,B]=y.useState(!1),j=y.useRef([]),N={...mf,...p};y.useEffect(()=>{var W;(W=j.current[0])==null||W.focus()},[]);const R=(W,G)=>{var le;const H=G.replace(/\D/g,"").slice(-1),se=[...x];if(se[W]=H,_(se),S(""),H&&W<h-1&&((le=j.current[W+1])==null||le.focus()),H&&W===h-1){const ue=se.join("");ue.length===h&&D(ue)}},M=(W,G)=>{var H;G.key==="Backspace"&&!x[W]&&W>0&&((H=j.current[W-1])==null||H.focus())},w=W=>{var le;W.preventDefault();const G=W.clipboardData.getData("text").replace(/\D/g,"").slice(0,h),H=[...x];G.split("").forEach((ue,_e)=>{_e<h&&(H[_e]=ue)}),_(H);const se=Math.min(G.length,h)-1;se>=0&&((le=j.current[se])==null||le.focus()),G.length===h&&D(G)};async function D(W){var se;const G=W||x.join("");if(G.length!==h){S("Veuillez entrer le code complet");return}k(!0),S("");const H=await e(r,G);H.success?t==null||t():(S(H.error||"Code invalide"),_(Array(h).fill("")),(se=j.current[0])==null||se.focus()),k(!1)}async function F(){if(!n)return;v(!0),B(!1),S("");const W=await n(r);W.success?(B(!0),setTimeout(()=>B(!1),3e3)):S(W.error||"Erreur lors de l'envoi"),v(!1)}const z={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${N.borderColor}`,borderRadius:N.borderRadius,backgroundColor:N.inputBackground,color:N.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},J={width:"100%",padding:"0.75rem",backgroundColor:C?N.textMutedColor:N.primaryColor,color:"#ffffff",border:"none",borderRadius:N.borderRadius,fontSize:"1rem",fontWeight:500,cursor:C?"not-allowed":"pointer",transition:"background-color 0.2s"},te={color:N.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:z,className:g,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),f.jsx("p",{style:{fontSize:"0.875rem",color:N.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),b&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0,textAlign:"center"},children:b})}),T&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${N.successColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),f.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((W,G)=>f.jsx("input",{ref:H=>{j.current[G]=H},type:"text",inputMode:"numeric",maxLength:1,value:W,onChange:H=>R(G,H.target.value),onKeyDown:H=>M(G,H),onPaste:w,disabled:C,style:{...q,borderColor:W?N.primaryColor:N.borderColor},onFocus:H=>{H.target.style.borderColor=N.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${N.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=W?N.primaryColor:N.borderColor,H.target.style.boxShadow="none"}},G))}),f.jsx("button",{type:"button",onClick:()=>D(),disabled:C||x.join("").length!==h,style:{...J,opacity:x.join("").length!==h?.5:1},children:C?l:a}),n&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:F,disabled:E,style:{...te,opacity:E?.5:1},children:E?c:u})}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[h,p]=y.useState(""),[g,m]=y.useState(""),[x,_]=y.useState(!1),b={...yf,...u};async function S(B){B.preventDefault(),_(!0),m("");const j=await r(h);j.success?e==null||e(h):m(j.error||"Erreur lors de l'envoi"),_(!1)}const C={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},k={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},v={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},T={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:C,className:c,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),f.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),f.jsxs("form",{onSubmit:S,children:[g&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:E,children:a}),f.jsx("input",{type:"email",value:h,onChange:B=>p(B.target.value),required:!0,style:k})]}),f.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:B=>{x||(B.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:B=>{x||(B.target.style.backgroundColor=b.primaryColor)},children:x?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:t,style:T,children:l})})]})]})}const xf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(!1),v={...xf,...h};async function T(w){if(w.preventDefault(),C(""),m!==_){C("Les mots de passe ne correspondent pas");return}if(m.length<8){C("Le mot de passe doit contenir au moins 8 caractères");return}E(!0);const D=await t(r,e,m);D.success?n==null||n():C(D.error||"Erreur lors de la réinitialisation"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},M={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:B,className:p,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&f.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),f.jsxs("form",{onSubmit:T,children:[S&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:S})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:u}),f.jsx("input",{type:"password",value:m,onChange:w=>x(w.target.value),required:!0,minLength:8,style:j})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:c}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j})]}),f.jsx("button",{type:"submit",disabled:k,style:R,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?l:a}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:M,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:h=!1,labels:p={}}){const[g,m]=y.useState(a),[x,_]=y.useState(""),[b,S]=y.useState("");async function C(B,j){const N=await r(B,j);return N.requiresVerification?(_(B),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):N}async function k(B,j,N){const R=await e(B,j,N);return R.success&&(R.requiresVerification?(_(B),m("verify-email")):o==null||o()),R}async function E(B){const j=await n(B);return j.success&&(_(B),m("verify-reset-code")),j}async function v(B,j){return S(j),m("reset-password"),{success:!0}}const T=()=>{switch(g){case"login":return f.jsx(No,{onLogin:C,onSuccess:o,onForgotPasswordClick:()=>m("forgot-password"),onRegisterClick:()=>m("register"),logo:l,theme:u,title:p.loginTitle,className:d,isModal:h});case"register":return f.jsx(uu,{onRegister:k,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:h});case"verify-email":return f.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:h});case"forgot-password":return f.jsx(cu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:h});case"verify-reset-code":return f.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:h});case"reset-password":return f.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:h})}};return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:T()})}function bf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?f.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[f.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),f.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(fu,{...n,isModal:!0})]}),f.jsx("style",{children:`
|
|
68
|
+
`})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:h="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(""),[v,T]=y.useState(""),[B,j]=y.useState(""),[N,R]=y.useState(""),[M,w]=y.useState(!1),D={...gf,...g};async function F(H){if(H.preventDefault(),R(""),S!==k){R("Les mots de passe ne correspondent pas");return}if(S.length<8){R("Le mot de passe doit contenir au moins 8 caractères");return}w(!0);const ue=await r(_,S,p?{firstName:v,lastName:B}:void 0);ue.success?e==null||e(_):R(ue.error||"Erreur lors de l'inscription"),w(!1)}const I={backgroundColor:D.backgroundColor,borderRadius:D.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${D.borderColor}`,borderRadius:D.borderRadius,backgroundColor:D.inputBackground,color:D.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},Z={display:"block",fontSize:"0.875rem",fontWeight:500,color:D.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:M?D.textMutedColor:D.primaryColor,color:"#ffffff",border:"none",borderRadius:D.borderRadius,fontSize:"1rem",fontWeight:500,cursor:M?"not-allowed":"pointer",transition:"background-color 0.2s"},W={padding:"0.75rem",backgroundColor:D.errorBackgroundColor,border:`1px solid ${D.errorColor}20`,borderRadius:D.borderRadius,marginBottom:"1rem"},Q={color:D.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return f.jsxs("div",{style:I,className:m,children:[n&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:D.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),f.jsxs("form",{onSubmit:F,children:[N&&f.jsx("div",{style:W,children:f.jsx("p",{style:{fontSize:"0.875rem",color:D.errorColor,margin:0},children:N})}),p&&f.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:Z,children:c}),f.jsx("input",{type:"text",value:v,onChange:H=>T(H.target.value),style:q})]}),f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:Z,children:d}),f.jsx("input",{type:"text",value:B,onChange:H=>j(H.target.value),style:q})]})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:Z,children:a}),f.jsx("input",{type:"email",value:_,onChange:H=>b(H.target.value),required:!0,style:q})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:Z,children:l}),f.jsx("input",{type:"password",value:S,onChange:H=>C(H.target.value),required:!0,minLength:8,style:q})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:Z,children:u}),f.jsx("input",{type:"password",value:k,onChange:H=>E(H.target.value),required:!0,style:q})]}),f.jsx("button",{type:"submit",disabled:M,style:te,onMouseEnter:H=>{M||(H.target.style.backgroundColor=D.primaryHoverColor)},onMouseLeave:H=>{M||(H.target.style.backgroundColor=D.primaryColor)},children:M?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("span",{style:Q,onClick:t,children:h})})]})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:a="Vérifier",loadingText:l="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:h=6,theme:p,className:g="",isModal:m=!1}){const[x,_]=y.useState(Array(h).fill("")),[b,S]=y.useState(""),[C,k]=y.useState(!1),[E,v]=y.useState(!1),[T,B]=y.useState(!1),j=y.useRef([]),N={...mf,...p};y.useEffect(()=>{var W;(W=j.current[0])==null||W.focus()},[]);const R=(W,Q)=>{var ue;const H=Q.replace(/\D/g,"").slice(-1),ie=[...x];if(ie[W]=H,_(ie),S(""),H&&W<h-1&&((ue=j.current[W+1])==null||ue.focus()),H&&W===h-1){const de=ie.join("");de.length===h&&D(de)}},M=(W,Q)=>{var H;Q.key==="Backspace"&&!x[W]&&W>0&&((H=j.current[W-1])==null||H.focus())},w=W=>{var ue;W.preventDefault();const Q=W.clipboardData.getData("text").replace(/\D/g,"").slice(0,h),H=[...x];Q.split("").forEach((de,we)=>{we<h&&(H[we]=de)}),_(H);const ie=Math.min(Q.length,h)-1;ie>=0&&((ue=j.current[ie])==null||ue.focus()),Q.length===h&&D(Q)};async function D(W){var ie;const Q=W||x.join("");if(Q.length!==h){S("Veuillez entrer le code complet");return}k(!0),S("");const H=await e(r,Q);H.success?t==null||t():(S(H.error||"Code invalide"),_(Array(h).fill("")),(ie=j.current[0])==null||ie.focus()),k(!1)}async function F(){if(!n)return;v(!0),B(!1),S("");const W=await n(r);W.success?(B(!0),setTimeout(()=>B(!1),3e3)):S(W.error||"Erreur lors de l'envoi"),v(!1)}const I={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${N.borderColor}`,borderRadius:N.borderRadius,backgroundColor:N.inputBackground,color:N.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},Z={width:"100%",padding:"0.75rem",backgroundColor:C?N.textMutedColor:N.primaryColor,color:"#ffffff",border:"none",borderRadius:N.borderRadius,fontSize:"1rem",fontWeight:500,cursor:C?"not-allowed":"pointer",transition:"background-color 0.2s"},te={color:N.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:I,className:g,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),f.jsx("p",{style:{fontSize:"0.875rem",color:N.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),b&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0,textAlign:"center"},children:b})}),T&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${N.successColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),f.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((W,Q)=>f.jsx("input",{ref:H=>{j.current[Q]=H},type:"text",inputMode:"numeric",maxLength:1,value:W,onChange:H=>R(Q,H.target.value),onKeyDown:H=>M(Q,H),onPaste:w,disabled:C,style:{...q,borderColor:W?N.primaryColor:N.borderColor},onFocus:H=>{H.target.style.borderColor=N.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${N.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=W?N.primaryColor:N.borderColor,H.target.style.boxShadow="none"}},Q))}),f.jsx("button",{type:"button",onClick:()=>D(),disabled:C||x.join("").length!==h,style:{...Z,opacity:x.join("").length!==h?.5:1},children:C?l:a}),n&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:F,disabled:E,style:{...te,opacity:E?.5:1},children:E?c:u})}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[h,p]=y.useState(""),[g,m]=y.useState(""),[x,_]=y.useState(!1),b={...yf,...u};async function S(B){B.preventDefault(),_(!0),m("");const j=await r(h);j.success?e==null||e(h):m(j.error||"Erreur lors de l'envoi"),_(!1)}const C={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},k={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},v={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},T={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:C,className:c,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),f.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),f.jsxs("form",{onSubmit:S,children:[g&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:E,children:a}),f.jsx("input",{type:"email",value:h,onChange:B=>p(B.target.value),required:!0,style:k})]}),f.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:B=>{x||(B.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:B=>{x||(B.target.style.backgroundColor=b.primaryColor)},children:x?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:t,style:T,children:l})})]})]})}const xf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(!1),v={...xf,...h};async function T(w){if(w.preventDefault(),C(""),m!==_){C("Les mots de passe ne correspondent pas");return}if(m.length<8){C("Le mot de passe doit contenir au moins 8 caractères");return}E(!0);const D=await t(r,e,m);D.success?n==null||n():C(D.error||"Erreur lors de la réinitialisation"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},M={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:B,className:p,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&f.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),f.jsxs("form",{onSubmit:T,children:[S&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:S})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:u}),f.jsx("input",{type:"password",value:m,onChange:w=>x(w.target.value),required:!0,minLength:8,style:j})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:c}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j})]}),f.jsx("button",{type:"submit",disabled:k,style:R,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?l:a}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:M,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:h=!1,labels:p={}}){const[g,m]=y.useState(a),[x,_]=y.useState(""),[b,S]=y.useState("");async function C(B,j){const N=await r(B,j);return N.requiresVerification?(_(B),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):N}async function k(B,j,N){const R=await e(B,j,N);return R.success&&(R.requiresVerification?(_(B),m("verify-email")):o==null||o()),R}async function E(B){const j=await n(B);return j.success&&(_(B),m("verify-reset-code")),j}async function v(B,j){return S(j),m("reset-password"),{success:!0}}const T=()=>{switch(g){case"login":return f.jsx(No,{onLogin:C,onSuccess:o,onForgotPasswordClick:()=>m("forgot-password"),onRegisterClick:()=>m("register"),logo:l,theme:u,title:p.loginTitle,className:d,isModal:h});case"register":return f.jsx(uu,{onRegister:k,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:h});case"verify-email":return f.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:h});case"forgot-password":return f.jsx(cu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:h});case"verify-reset-code":return f.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:h});case"reset-password":return f.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:h})}};return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:T()})}function bf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?f.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[f.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),f.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(fu,{...n,isModal:!0})]}),f.jsx("style",{children:`
|
|
69
69
|
@keyframes authFlowSlideUp {
|
|
70
70
|
from {
|
|
71
71
|
opacity: 0;
|
|
@@ -80,32 +80,32 @@ React keys must be passed directly to JSX without using spread:
|
|
|
80
80
|
flex items-center gap-4 p-4 border-b border-gray-200
|
|
81
81
|
hover:bg-gray-50 transition-colors
|
|
82
82
|
${e?"cursor-pointer":""}
|
|
83
|
-
`,children:[l&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:l,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),a&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Cf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[o&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((a,l)=>{const u=a.value(r);return u==null||u===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:a.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Sf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function kf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var j,N;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const R=Sf(r),M=Math.ceil(R.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:R.slice(0,M).map(w=>w.title),right:R.slice(M).map(w=>w.title)}),[R.slice(0,M),R.slice(M)]}),[l,u]=y.useState(()=>{const R=Ea[s];if(typeof window>"u")return R.base;const M=window.innerWidth;return"lg"in R&&M>=1024?R.lg:M>=768?R.md:M>=640?R.sm:R.base});y.useEffect(()=>{const R=()=>{const M=Ea[s],w=window.innerWidth;"lg"in M&&w>=1024?u(M.lg):w>=768?u(M.md):w>=640?u(M.sm):u(M.base)};return window.addEventListener("resize",R),R(),()=>window.removeEventListener("resize",R)},[s]);const[c,d]=y.useState(0),[h,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(!1),[b,S]=y.useState(!1),[C,k]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const R=setInterval(()=>{m(M=>!M),setTimeout(()=>{d(M=>(M+1)%a[0].length),S(M=>!M)},250)},e+Math.random()*(t-e));return()=>clearInterval(R)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let R=null;const M=setTimeout(()=>{R=setInterval(()=>{_(w=>!w),setTimeout(()=>{p(w=>(w+1)%a[1].length),k(w=>!w)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(M),R&&clearInterval(R)}},[a,e,t]);const E=(j=a[0])==null?void 0:j[c],v=(N=a[1])==null?void 0:N[h];if(r.length===0||!E)return f.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:f.jsx("p",{className:"text-gray-500",children:"No images available"})});const T=i==="2:3"?l*1.5:l,B=(R,M,w)=>f.jsx("div",{className:"relative",style:{width:l,height:T,perspective:"1000px"},onClick:()=>n==null?void 0:n(R),children:f.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${M?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:f.jsxs("div",{className:"w-full h-full",style:{transform:w?"scaleX(-1)":"none"},children:[f.jsx("img",{src:R.data.image,alt:R.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:R.title})})]})})});return f.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[B(E,g,b),v&&B(v,x,C)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const Ef={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Df({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:h,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:_,renderDetail:b,renderActions:S,renderEmpty:C,renderLoading:k,theme:E={}}){const v={...Ef,...E},[T,B]=y.useState([]),[j,N]=y.useState(!1),[R,M]=y.useState(null),[w,D]=y.useState(new Set),[F,z]=y.useState(null),[q,J]=y.useState(null),[te,W]=y.useState(null),[G,H]=y.useState(!1),[se,le]=y.useState(""),ue=l!==void 0?l:se,_e=oe=>{u?u(oe):le(oe)},fe=y.useMemo(()=>{if(!ue.trim())return T;const oe=ue.toLowerCase();return T.filter(pe=>$r(pe.from).toLowerCase().includes(oe)||$r(pe.subject).toLowerCase().includes(oe))},[T,ue]),De=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),O=y.useCallback(async()=>{if(De){N(!0),M(null);try{const oe=await De.listEmails(t,n,s);oe!=null&&oe.messages&&(B(oe.messages),x==null||x(oe.messages))}catch(oe){const pe=oe instanceof Error?oe:new Error("Failed to fetch emails");M(pe.message),m==null||m(pe)}N(!1)}},[De,t,n,s,m,x]);y.useEffect(()=>{B([]),D(new Set),J(null),M(null),l===void 0&&le(""),d&&O()},[s,d]);const Ce=y.useCallback(async oe=>{if(De){J(oe),W(null),H(!0);try{const pe=await De.getEmailParsed(t,oe.uid,s||"INBOX");pe!=null&&pe.body&&W(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}H(!1)}},[De,t,s]),re=y.useCallback(oe=>{h==null||h(oe),o&&Ce(oe)},[h,o,Ce]),Fe=y.useCallback((oe,pe,Ye)=>{if(!i){h==null||h(oe),o&&Ce(oe);return}const at=oe.uid;if(Ye.shiftKey&&F!==null){const Ve=Math.min(F,pe),Xe=Math.max(F,pe),br=T.slice(Ve,Xe+1).map(I=>I.uid),Q=new Set(br);D(Q),p==null||p(Array.from(Q))}else if(Ye.ctrlKey||Ye.metaKey)D(Ve=>{const Xe=new Set(Ve);return Xe.has(at)?Xe.delete(at):Xe.add(at),p==null||p(Array.from(Xe)),Xe}),z(pe);else{const Ve=new Set([at]);D(Ve),z(pe),p==null||p(Array.from(Ve))}},[i,F,T,w,h,p,o]),je=y.useCallback(async()=>{if(!De||w.size===0)return;const oe=s||"INBOX";try{const pe=await De.trashEmails(t,Array.from(w),oe);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){B(at=>at.filter(Ve=>!w.has(Ve.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to move emails to trash")}catch(pe){const Ye=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ye),M(Ye.message),m==null||m(Ye)}},[De,t,w,s,g,m]),ye=y.useCallback(async()=>{if(!De||w.size===0)return;const oe=s||"INBOX";try{const pe=await De.archiveEmails(t,Array.from(w),oe);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){B(at=>at.filter(Ve=>!w.has(Ve.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to archive emails")}catch(pe){const Ye=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ye),M(Ye.message),m==null||m(Ye)}},[De,t,w,s,g,m]),Se=y.useCallback(()=>{if(w.size===T.length)D(new Set),p==null||p([]);else{const oe=new Set(T.map(pe=>pe.uid));D(oe),p==null||p(Array.from(oe))}},[T,w.size,p]),Me=y.useCallback(()=>{D(new Set),p==null||p([])},[p]),Oe={delete:je,archive:ye,refresh:O,selectAll:Se,clearSelection:Me},ge=oe=>{if(!oe)return"";const pe=new Date(oe),Ye=new Date;return pe.toDateString()===Ye.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},L=(oe,pe)=>f.jsx("div",{style:{padding:"12px 16px",background:pe?v.selectedBackground:oe.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:500,color:oe.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:ge(oe.date)})]})}),ze=oe=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(oe.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(oe.from)," • ",new Date(oe.date).toLocaleString()]}),G?f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):te?f.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:te}}):f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),Ke=(oe,pe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[f.jsx("button",{onClick:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:oe.length===T.length?"Deselect All":"Select All"}),oe.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[oe.length," selected"]}),f.jsx("button",{onClick:pe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:pe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:pe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),X=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),Z=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),ce=_||L,we=b||ze,Be=S||Ke,Qe=C||X,Et=k||Z;return j&&T.length===0?f.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:Et()}):f.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:o&&q?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&q?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&Be(Array.from(w),Oe),a&&f.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.background},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:[f.jsx("circle",{cx:"11",cy:"11",r:"8"}),f.jsx("path",{d:"M21 21l-4.35-4.35"})]}),f.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:ue,onChange:oe=>_e(oe.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),ue&&f.jsx("button",{onClick:()=>_e(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:f.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),R&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:R}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:fe.length===0?Qe():fe.map((oe,pe)=>f.jsx("div",{onClick:Ye=>Fe(oe,pe,Ye),onDoubleClick:()=>re(oe),children:ce(oe,w.has(oe.uid))},oe.uid))})]}),o&&q&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:we(q)})]})}function Af({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,h]=y.useState(-1),p=r.filter(C=>u.has(C.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(C=>{c(k=>{const E=new Set(k);return E.has(C)?E.delete(C):E.add(C),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),h(-1),t==null||t([]);else{const C=new Set(r.map(k=>k.id));c(C),r.length>0&&(h(0),n==null||n(r[0],0)),t==null||t(r.map(k=>k.id))}},[r,u.size,t,n]),_=y.useCallback(()=>{if(p.length===0)return;const C=d<=0?p.length-1:d-1;h(C),n==null||n(p[C],C)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const C=d>=p.length-1?0:d+1;h(C),n==null||n(p[C],C)},[p,d,n]),S=y.useCallback(C=>{s==null||s(C,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?h(-1):d>=p.length?h(p.length-1):d<0&&p.length>0&&(h(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${l}`,children:o}):f.jsxs("div",{className:`space-y-2 ${l}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),f.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:r.map(C=>{const k=u.has(C.id),E=(g==null?void 0:g.id)===C.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":k?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(C.id),children:[f.jsx("span",{className:`material-icons text-lg ${k?"text-blue-500":"text-neutral-300"}`,children:k?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(C,k,E)})]},C.id)})}),i.length>0&&u.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(C=>{var E;const k=((E=C.disabled)==null?void 0:E.call(C,p))??!1;return f.jsxs("button",{onClick:()=>S(C.id),disabled:k,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${k?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[C.icon&&f.jsx("span",{className:"material-icons text-sm",children:C.icon}),C.label]},C.id)})})]})}function Tf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Nf=Tf(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Bf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Nf(8),r}function Hn(r){return{}}const Bo={},jf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},Pt={},jo={},Mo={},Mf={},mu={},Rf={},yu={},Ff={},xu={},bu={},Ns={},Lf={},vu={},_u={},wu={},Pf={},If={},zf={},Da={},Cu={},Of={},Su={},ku={},$f={},ii={},Ro={},Yi={},qf={},Uf={},as={},ls={},Wf={},Hf={},Vf={},Ot=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Gf=Ot&&"documentMode"in document?document.documentMode:null,jt=Ot&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),gr=Ot&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!Ot||!("InputEvent"in window)||Gf)&&"getTargetRanges"in new window.InputEvent("input"),oi=Ot&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=Ot&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Kf=Ot&&/Android/.test(navigator.userAgent),Eu=Ot&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Yf=Ot&&Kf&&Eu,Fo=Ot&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,yr=3,Nr=0,Du=1,Zr=2,Qf=0,Jf=1,Xf=2,js=4,Ms=8,Lo=128,Zf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"",nr=`
|
|
83
|
+
`,children:[l&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:l,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),a&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Cf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[o&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((a,l)=>{const u=a.value(r);return u==null||u===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:a.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Sf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function kf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var j,N;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const R=Sf(r),M=Math.ceil(R.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:R.slice(0,M).map(w=>w.title),right:R.slice(M).map(w=>w.title)}),[R.slice(0,M),R.slice(M)]}),[l,u]=y.useState(()=>{const R=Ea[s];if(typeof window>"u")return R.base;const M=window.innerWidth;return"lg"in R&&M>=1024?R.lg:M>=768?R.md:M>=640?R.sm:R.base});y.useEffect(()=>{const R=()=>{const M=Ea[s],w=window.innerWidth;"lg"in M&&w>=1024?u(M.lg):w>=768?u(M.md):w>=640?u(M.sm):u(M.base)};return window.addEventListener("resize",R),R(),()=>window.removeEventListener("resize",R)},[s]);const[c,d]=y.useState(0),[h,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(!1),[b,S]=y.useState(!1),[C,k]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const R=setInterval(()=>{m(M=>!M),setTimeout(()=>{d(M=>(M+1)%a[0].length),S(M=>!M)},250)},e+Math.random()*(t-e));return()=>clearInterval(R)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let R=null;const M=setTimeout(()=>{R=setInterval(()=>{_(w=>!w),setTimeout(()=>{p(w=>(w+1)%a[1].length),k(w=>!w)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(M),R&&clearInterval(R)}},[a,e,t]);const E=(j=a[0])==null?void 0:j[c],v=(N=a[1])==null?void 0:N[h];if(r.length===0||!E)return f.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:f.jsx("p",{className:"text-gray-500",children:"No images available"})});const T=i==="2:3"?l*1.5:l,B=(R,M,w)=>f.jsx("div",{className:"relative",style:{width:l,height:T,perspective:"1000px"},onClick:()=>n==null?void 0:n(R),children:f.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${M?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:f.jsxs("div",{className:"w-full h-full",style:{transform:w?"scaleX(-1)":"none"},children:[f.jsx("img",{src:R.data.image,alt:R.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:R.title})})]})})});return f.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[B(E,g,b),v&&B(v,x,C)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const Ef={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Df({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:h,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:_,renderDetail:b,renderActions:S,renderEmpty:C,renderLoading:k,theme:E={}}){const v={...Ef,...E},[T,B]=y.useState([]),[j,N]=y.useState(!1),[R,M]=y.useState(null),[w,D]=y.useState(new Set),[F,I]=y.useState(null),[q,Z]=y.useState(null),[te,W]=y.useState(null),[Q,H]=y.useState(!1),[ie,ue]=y.useState(""),de=l!==void 0?l:ie,we=ae=>{u?u(ae):ue(ae)},fe=y.useMemo(()=>{if(!de.trim())return T;const ae=de.toLowerCase();return T.filter(me=>$r(me.from).toLowerCase().includes(ae)||$r(me.subject).toLowerCase().includes(ae))},[T,de]),Ce=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),O=y.useCallback(async()=>{if(Ce){N(!0),M(null);try{const ae=await Ce.listEmails(t,n,s);ae!=null&&ae.messages&&(B(ae.messages),x==null||x(ae.messages))}catch(ae){const me=ae instanceof Error?ae:new Error("Failed to fetch emails");M(me.message),m==null||m(me)}N(!1)}},[Ce,t,n,s,m,x]);y.useEffect(()=>{B([]),D(new Set),Z(null),M(null),l===void 0&&ue(""),d&&O()},[s,d]);const je=y.useCallback(async ae=>{if(Ce){Z(ae),W(null),H(!0);try{const me=await Ce.getEmailParsed(t,ae.uid,s||"INBOX");me!=null&&me.body&&W(me.body)}catch(me){console.error("Failed to fetch email body:",me)}H(!1)}},[Ce,t,s]),re=y.useCallback(ae=>{h==null||h(ae),o&&je(ae)},[h,o,je]),Le=y.useCallback((ae,me,Ye)=>{if(!i){h==null||h(ae),o&&je(ae);return}const at=ae.uid;if(Ye.shiftKey&&F!==null){const He=Math.min(F,me),Xe=Math.max(F,me),br=T.slice(He,Xe+1).map(P=>P.uid),J=new Set(br);D(J),p==null||p(Array.from(J))}else if(Ye.ctrlKey||Ye.metaKey)D(He=>{const Xe=new Set(He);return Xe.has(at)?Xe.delete(at):Xe.add(at),p==null||p(Array.from(Xe)),Xe}),I(me);else{const He=new Set([at]);D(He),I(me),p==null||p(Array.from(He))}},[i,F,T,w,h,p,o]),Me=y.useCallback(async()=>{if(!Ce||w.size===0)return;const ae=s||"INBOX";try{const me=await Ce.trashEmails(t,Array.from(w),ae);if(console.log("Trash result:",me),me.success&&me.moved>0){B(at=>at.filter(He=>!w.has(He.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to move emails to trash")}catch(me){const Ye=me instanceof Error?me:new Error("Trash failed");console.error("Trash error:",Ye),M(Ye.message),m==null||m(Ye)}},[Ce,t,w,s,g,m]),xe=y.useCallback(async()=>{if(!Ce||w.size===0)return;const ae=s||"INBOX";try{const me=await Ce.archiveEmails(t,Array.from(w),ae);if(console.log("Archive result:",me),me.success&&me.archived>0){B(at=>at.filter(He=>!w.has(He.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to archive emails")}catch(me){const Ye=me instanceof Error?me:new Error("Archive failed");console.error("Archive error:",Ye),M(Ye.message),m==null||m(Ye)}},[Ce,t,w,s,g,m]),Se=y.useCallback(()=>{if(w.size===T.length)D(new Set),p==null||p([]);else{const ae=new Set(T.map(me=>me.uid));D(ae),p==null||p(Array.from(ae))}},[T,w.size,p]),Re=y.useCallback(()=>{D(new Set),p==null||p([])},[p]),se={delete:Me,archive:xe,refresh:O,selectAll:Se,clearSelection:Re},ce=ae=>{if(!ae)return"";const me=new Date(ae),Ye=new Date;return me.toDateString()===Ye.toDateString()?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):me.toLocaleDateString([],{month:"short",day:"numeric"})},$=(ae,me)=>f.jsx("div",{style:{padding:"12px 16px",background:me?v.selectedBackground:ae.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:500,color:ae.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:ce(ae.date)})]})}),Ge=ae=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(ae.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(ae.from)," • ",new Date(ae.date).toLocaleString()]}),Q?f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):te?f.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:te}}):f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),Ke=(ae,me)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[f.jsx("button",{onClick:me.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:ae.length===T.length?"Deselect All":"Select All"}),ae.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[ae.length," selected"]}),f.jsx("button",{onClick:me.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:me.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:me.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),X=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),K=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),pe=_||$,De=b||Ge,Be=S||Ke,Qe=C||X,Et=k||K;return j&&T.length===0?f.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:Et()}):f.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:o&&q?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&q?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&Be(Array.from(w),se),a&&f.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.background},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:[f.jsx("circle",{cx:"11",cy:"11",r:"8"}),f.jsx("path",{d:"M21 21l-4.35-4.35"})]}),f.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:de,onChange:ae=>we(ae.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),de&&f.jsx("button",{onClick:()=>we(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:f.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),R&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:R}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:fe.length===0?Qe():fe.map((ae,me)=>f.jsx("div",{onClick:Ye=>Le(ae,me,Ye),onDoubleClick:()=>re(ae),children:pe(ae,w.has(ae.uid))},ae.uid))})]}),o&&q&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:De(q)})]})}function Af({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,h]=y.useState(-1),p=r.filter(C=>u.has(C.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(C=>{c(k=>{const E=new Set(k);return E.has(C)?E.delete(C):E.add(C),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),h(-1),t==null||t([]);else{const C=new Set(r.map(k=>k.id));c(C),r.length>0&&(h(0),n==null||n(r[0],0)),t==null||t(r.map(k=>k.id))}},[r,u.size,t,n]),_=y.useCallback(()=>{if(p.length===0)return;const C=d<=0?p.length-1:d-1;h(C),n==null||n(p[C],C)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const C=d>=p.length-1?0:d+1;h(C),n==null||n(p[C],C)},[p,d,n]),S=y.useCallback(C=>{s==null||s(C,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?h(-1):d>=p.length?h(p.length-1):d<0&&p.length>0&&(h(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${l}`,children:o}):f.jsxs("div",{className:`space-y-2 ${l}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),f.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:r.map(C=>{const k=u.has(C.id),E=(g==null?void 0:g.id)===C.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":k?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(C.id),children:[f.jsx("span",{className:`material-icons text-lg ${k?"text-blue-500":"text-neutral-300"}`,children:k?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(C,k,E)})]},C.id)})}),i.length>0&&u.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(C=>{var E;const k=((E=C.disabled)==null?void 0:E.call(C,p))??!1;return f.jsxs("button",{onClick:()=>S(C.id),disabled:k,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${k?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[C.icon&&f.jsx("span",{className:"material-icons text-sm",children:C.icon}),C.label]},C.id)})})]})}function Tf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Nf=Tf(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Bf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Nf(8),r}function Hn(r){return{}}const Bo={},jf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},Pt={},jo={},Mo={},Mf={},mu={},Rf={},yu={},Ff={},xu={},bu={},Ns={},Lf={},vu={},_u={},wu={},Pf={},If={},zf={},Da={},Cu={},Of={},Su={},ku={},$f={},ii={},Ro={},Yi={},qf={},Uf={},as={},ls={},Wf={},Hf={},Vf={},Ot=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Gf=Ot&&"documentMode"in document?document.documentMode:null,jt=Ot&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),gr=Ot&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!Ot||!("InputEvent"in window)||Gf)&&"getTargetRanges"in new window.InputEvent("input"),oi=Ot&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=Ot&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Kf=Ot&&/Android/.test(navigator.userAgent),Eu=Ot&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Yf=Ot&&Kf&&Eu,Fo=Ot&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,yr=3,Nr=0,Du=1,Zr=2,Qf=0,Jf=1,Xf=2,js=4,Ms=8,Lo=128,Zf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"",nr=`
|
|
84
84
|
|
|
85
|
-
`,eh=gr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",th=new RegExp("^[^"+Tu+"]*["+Au+"]"),rh=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},nh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},sh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},ih={normal:0,segmented:2,token:1},oh={[Qf]:"normal",[Xf]:"segmented",[Jf]:"token"};function ah(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=ah(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const lh=100;let Qi=!1,Uo=0;function uh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function ch(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function dh(r,e,t){if(V(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===yr&&t.isAttached()}function fh(r,e,t,n){for(let s=r;s&&!kh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=pt(i,t);if(o)return Ge(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>lh;try{Dt(r,()=>{const s=ae()||function(h){return h.getEditorState().read(()=>{const p=ae();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=r._blockCursorElement;let u=!1,c="";for(let h=0;h<e.length;h++){const p=e[h],g=p.type,m=p.target,x=fh(m,r,a,o);if(!x)continue;const[_,b]=x;if(g==="characterData")n&&ee(b)&&dh(s,m,b)&&ch(m,b,r);else if(g==="childList"){u=!0;const S=p.addedNodes;for(let E=0;E<S.length;E++){const v=S[E],T=Lu(v),B=v.parentNode;if(B!=null&&v!==l&&T===null&&!Bi(v,B,r)){if(gr){const j=v.innerText||v.nodeValue;j&&(c+=j)}B.removeChild(v)}}const C=p.removedNodes,k=C.length;if(k>0){let E=0;for(let v=0;v<k;v++){const T=C[v];(Bi(T,m,r)||l===T)&&(m.appendChild(T),E++)}k!==E&&i.set(_,b)}}}if(i.size>0)for(const[h,p]of i)p.reconcileObservedMutation(h,r);const d=t.takeRecords();if(d.length>0){for(let h=0;h<d.length;h++){const p=d[h],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const _=g[x],b=_.parentNode;b==null||_.nodeName!=="BR"||Bi(_,m,r)||b.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Gt(s)),gr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",uh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=rt()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&ee(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&ee(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),ee(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!$(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let hh=1;const ph=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ge(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function gh(r){return r.nodeType===yr}function Fs(r){let e=r;for(;e!=null;){if(gh(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return ee(r)||Ar(r)||Ge(r)}function mh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=rt(),n=or(),s=""+hh++;n._nodeMap.set(s,r),$(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const a=i.getWritable();a.__prev=o.__key,o.__next=a.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=or(),s=rt(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;for(;d!==null;){if(c.has(d))return;const h=u.get(d);if(h===void 0)break;c.set(d,!1),d=h.__parent}}(t,i,o);const a=e.__key;s._dirtyType=Du,$(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ht(r){wt();const e=rt(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=pt(t);n!==null&&n.getWritable()}if(r!==null){const n=pt(r);n!==null&&n.getWritable()}}}function fr(){return es()?null:rt()._compositionKey}function pt(r,e){const t=(e||or())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,rt());return t!==void 0?pt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ze().getTextContent())}function Ze(){return Iu(or())}function Iu(r){return r._nodeMap.get("root")}function Gt(r){wt();const e=or();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=rt(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?pt("root"):null:pt(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===yr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&ee(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ht(null),oi||Vn||Fo)i.remove();else{const m=rt();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),h=fr(),p=i.getKey();if(i.isToken()||h!==null&&p===h&&!o||V(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=ae();if(!V(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=lt(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function yh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(ee(o)||$(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return jt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function xh(){const r=Ze();Gt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&K(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function ie(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&K(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&K(78),e}function bh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Kt(e))return e;e=e.getParentOrThrow()}return e}function Kt(r){return yt(r)||$(r)&&r.isShadowRoot()}function Qt(r){const e=rt(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&K(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||K(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!yt(r.getParent())||$(e)||Ge(e)||K(99)}function Mi(r){return(Ge(r)||$(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function vh(r,e,t){let n=r._blockCursorElement;if(V(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,h=document.createElement("div");h.contentEditable="false",h.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&h.classList.add(...p)}return h}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Bt(r){return Ot?(r||window).getSelection():null}function _h(r){return ir(r)&&r.tagName==="A"}function ir(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function zs(r){const e=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 r.nodeName.match(e)!==null}function ur(r){if(Ge(r)&&!r.isInline())return!0;if(!$(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function wh(){return rt()}const $a=new WeakMap,Ch=new Map;function Sh(r){if(!r._readOnly&&r.isEmpty())return Ch;r._readOnly||K(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function kh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&($(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let mr,xt,In,fi,Xi,Zi,jr,It,eo,zn,ut="",mt="",qt=null,Mt="",tr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(It.has(r)||xt._keyToDOMMap.delete(r),$(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const Eh="40px";function Hu(r,e){const t=mr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||Eh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=It.get(r);t===void 0&&K(60);const n=t.createDOM(mr,xt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,xt),ee(t)?n.setAttribute("data-lexical-text","true"):Ge(t)&&n.setAttribute("data-lexical-decorator","true"),$(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const h=mt;mt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=h})(qs(t,It),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ut+=nr,tr+=nr)}else{const s=t.getTextContent();if(Ge(t)){const i=t.decorate(xt,mr);i!==null&&Yu(r,i),n.contentEditable="false"}else ee(t)&&(t.isDirectionless()||(mt+=s));ut+=s,tr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ut;ut="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=It.get(r[o]);a!==null&&ee(a)&&(qt===null&&(qt=a.getFormat()),Mt===""&&(Mt=a.getStyle()))}ci(e)&&(ut+=nr),s.element.__lexicalTextContent=ut,ut=i+ut}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ge(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,It);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,th.test(s)?"rtl":rh.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=mr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Dh(r,e,t){const n=mt;var s;mt="",qt=null,Mt="",function(i,o,a){const l=ut,u=i.__size,c=o.__size;ut="";const d=a.element;if(u===1&&c===1){const h=i.__first,p=o.__first;if(h===p)_n(h,d);else{const m=no(h),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${h}}.`;throw new Error(b)}throw _}Os(h,null)}const g=It.get(p);ee(g)&&(qt===null&&(qt=g.getFormat()),Mt===""&&(Mt=g.getStyle()))}else{const h=qs(i,jr),p=qs(o,It);if(h.length!==u&&K(227),p.length!==c&&K(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(h,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,_,b,S){const C=_-1,k=b-1;let E,v,T=S.getFirstChild(),B=0,j=0;for(;B<=C&&j<=k;){const M=m[B],w=x[j];if(M===w)T=Ri(_n(w,S.element)),B++,j++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(M),z=E.has(w);if(F)if(z){const q=Is(xt,w);q===T?T=Ri(_n(w,S.element)):(S.withBefore(T).insertChild(q),_n(w,S.element)),B++,j++}else $s(w,S.withBefore(T)),j++;else T=Ri(no(M)),Os(M,S.element),B++}const D=It.get(w);D!==null&&ee(D)&&(qt===null&&(qt=D.getFormat()),Mt===""&&(Mt=D.getStyle()))}const N=B>C,R=j>k;if(N&&!R){const M=x[k+1],w=M===void 0?null:xt.getElementByKey(M);ro(x,g,j,k,S.withBefore(w))}else R&&!N&&to(m,B,C,S.element)})(o,h,p,u,c,a)}ci(o)&&(ut+=nr),d.__lexicalTextContent=ut,ut=l+ut}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&qt!=null&&qt!==s.__textFormat&&!On&&(s.setTextFormat(qt),s.setTextStyle(Mt)),function(i){tn(i)&&Mt!==""&&Mt!==i.__textStyle&&!On&&i.setTextStyle(Mt)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&K(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=It.get(r);t!==void 0&&n!==void 0||K(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if($(t)){const o=i.__lexicalTextContent;o!==void 0&&(ut+=o,tr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(mt+=a)}else{const o=t.getTextContent();ee(t)&&!t.isDirectionless()&&(mt+=o),tr+=o,ut+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,mr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),Os(r,null),o}if($(t)&&$(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Dh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ut+=nr,tr+=nr)}else{const o=n.getTextContent();if(Ge(n)){const a=n.decorate(xt,mr);a!==null&&Yu(r,a)}else ee(n)&&!n.isDirectionless()&&(mt+=o);ut+=o,tr+=o}if(!On&&yt(n)&&n.__cachedText!==tr){const o=n.getWritable();o.__cachedText=tr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Ah(r,e,t,n,s,i){ut="",tr="",mt="",Wu=n===Zr,_s=null,xt=t,mr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,It=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,It=void 0,mr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const Zt=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!ie(e,Mf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))ie(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ie(e,Rf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))ie(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ie(e,Ff,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))ie(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))ie(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,ie(e,Ns,r);else if(function(a){return a===" "}(t))ie(e,Lf,r);else if(function(a,l){return jt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,ie(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,ie(e,Ns,r);else if(function(a,l,u,c){return jt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?ie(e,vu,r):(r.preventDefault(),ie(e,Er,!0));else if(function(a){return a==="Escape"}(t))ie(e,_u,r);else if(function(a,l,u,c,d){return jt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?ie(e,wu,r):(r.preventDefault(),ie(e,Er,!1));else if(function(a,l,u){return fn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!1);else if(function(a,l){return jt&&l&&fn(a)}(t,i))r.preventDefault(),ie(e,Ln,!0);else if(function(a,l){return jt&&l&&hn(a)}(t,i))r.preventDefault(),ie(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))ie(e,Pf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),ie(e,jo,void 0);else if(function(a,l,u,c){return jt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),ie(e,Mo,void 0);else{const a=e._editorState._selection;a===null||V(a)?!gr&&Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&ie(e,Vf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Dt(e,()=>{Ge(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Dt(e,()=>{const t=ae();if(V(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ht(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||ee(s)&&s.getStyle()!==t.style)&&ie(e,Yr,eh)}})}],["compositionend",function(r,e){gr?gn=!0:Dt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Dt(e,()=>{const t=ae(),n=r.data,s=ec(r);if(n!=null&&V(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&ee(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||ie(e,Yr,n);const c=n.length;gr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ht(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(rt())}),Wr=null}],["click",function(r,e){Dt(e,()=>{const t=ae(),n=Bt(e._window),s=Zn();if(n){if(V(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&Ze().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&($(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===yr)&&Gt(ea(s,n,e,r))}}}ie(e,gu,r)})}],["cut",Zt],["copy",Zt],["dragstart",Zt],["dragover",Zt],["dragend",Zt],["paste",Zt],["focus",Zt],["blur",Zt],["drop",Zt]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||gr&&qu(n)||s!=="insertCompositionText"&&Dt(n,()=>{const o=ae();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!V(p))return;Gt(p.clone())}if(V(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ht(null),Nn=0,setTimeout(()=>{Dt(n,()=>{ht(null)})},so),V(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),ee(g)||K(142),o.style=g.getStyle()}}else{ht(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Yf&&p&&!_&&x||ie(n,Er,!0)}return}}var a;if(!V(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),h=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":ie(n,Yr,t);break;case"insertFromComposition":ht(null),ie(n,Yr,t);break;case"insertLineBreak":ht(null),ie(n,Kr,!1);break;case"insertParagraph":ht(null),Bn&&!Vn?(Bn=!1,ie(n,Kr,!1)):ie(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ie(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||$(p)||$(g)||!p.isToken()||!g.isToken()})(d,h)&&ie(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":ie(n,Ki,t);break;case"deleteContent":ie(n,Er,!1);break;case"deleteWordBackward":ie(n,Fn,!0);break;case"deleteWordForward":ie(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ie(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ie(n,Ln,!1);break;case"formatStrikeThrough":ie(n,Pt,"strikethrough");break;case"formatBold":ie(n,Pt,"bold");break;case"formatItalic":ie(n,Pt,"italic");break;case"formatUnderline":ie(n,Pt,"underline");break;case"historyUndo":ie(n,jo,void 0);break;case"historyRedo":ie(n,Mo,void 0)}else{if(l===`
|
|
86
|
-
`)t.preventDefault(),
|
|
87
|
-
`){const n=
|
|
88
|
-
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Nh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Nh(r){return{node:Mr()}}function Mr(){return Qt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===yr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let a=!1;const l=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(a=!0,l||i.add(...o)):l&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(a&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!l||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||gr){const[a,l,u]=function(c,d){const h=c.length,p=d.length;let g=0,m=0;for(;g<h&&g<p&&c[g]===d[g];)g++;for(;m+g<h&&m+g<p&&c[h-m-1]===d[p-m-1];)m++;return[g,h-g-m,d.slice(g,p-m)]}(o,i);l!==0&&n.deleteData(a,l),n.insertData(a,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return oh[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===fr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,a=document.createElement(o);let l=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(l=document.createElement(i),a.appendChild(l)),Ga(l,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(a.style.cssText=u),a}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,a=Li(0,i),l=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((a===null?u:a)!==(l===null?c:l))return!0;if(a===l&&u!==c){const m=t.firstChild;m==null&&
|
|
85
|
+
`,eh=gr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",th=new RegExp("^[^"+Tu+"]*["+Au+"]"),rh=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},nh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},sh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},ih={normal:0,segmented:2,token:1},oh={[Qf]:"normal",[Xf]:"segmented",[Jf]:"token"};function ah(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var G=ah(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const lh=100;let Qi=!1,Uo=0;function uh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function ch(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function dh(r,e,t){if(V(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===yr&&t.isAttached()}function fh(r,e,t,n){for(let s=r;s&&!kh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=pt(i,t);if(o)return Ve(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>lh;try{Dt(r,()=>{const s=le()||function(h){return h.getEditorState().read(()=>{const p=le();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=r._blockCursorElement;let u=!1,c="";for(let h=0;h<e.length;h++){const p=e[h],g=p.type,m=p.target,x=fh(m,r,a,o);if(!x)continue;const[_,b]=x;if(g==="characterData")n&&ee(b)&&dh(s,m,b)&&ch(m,b,r);else if(g==="childList"){u=!0;const S=p.addedNodes;for(let E=0;E<S.length;E++){const v=S[E],T=Lu(v),B=v.parentNode;if(B!=null&&v!==l&&T===null&&!Bi(v,B,r)){if(gr){const j=v.innerText||v.nodeValue;j&&(c+=j)}B.removeChild(v)}}const C=p.removedNodes,k=C.length;if(k>0){let E=0;for(let v=0;v<k;v++){const T=C[v];(Bi(T,m,r)||l===T)&&(m.appendChild(T),E++)}k!==E&&i.set(_,b)}}}if(i.size>0)for(const[h,p]of i)p.reconcileObservedMutation(h,r);const d=t.takeRecords();if(d.length>0){for(let h=0;h<d.length;h++){const p=d[h],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const _=g[x],b=_.parentNode;b==null||_.nodeName!=="BR"||Bi(_,m,r)||b.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Gt(s)),gr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",uh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=rt()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&ee(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&ee(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),ee(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!z(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let hh=1;const ph=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ve(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function gh(r){return r.nodeType===yr}function Fs(r){let e=r;for(;e!=null;){if(gh(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return ee(r)||Ar(r)||Ve(r)}function mh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=rt(),n=or(),s=""+hh++;n._nodeMap.set(s,r),z(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const a=i.getWritable();a.__prev=o.__key,o.__next=a.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=or(),s=rt(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;for(;d!==null;){if(c.has(d))return;const h=u.get(d);if(h===void 0)break;c.set(d,!1),d=h.__parent}}(t,i,o);const a=e.__key;s._dirtyType=Du,z(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ht(r){wt();const e=rt(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=pt(t);n!==null&&n.getWritable()}if(r!==null){const n=pt(r);n!==null&&n.getWritable()}}}function fr(){return es()?null:rt()._compositionKey}function pt(r,e){const t=(e||or())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,rt());return t!==void 0?pt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ze().getTextContent())}function Ze(){return Iu(or())}function Iu(r){return r._nodeMap.get("root")}function Gt(r){wt();const e=or();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=rt(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?pt("root"):null:pt(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===yr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&ee(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ht(null),oi||Vn||Fo)i.remove();else{const m=rt();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),h=fr(),p=i.getKey();if(i.isToken()||h!==null&&p===h&&!o||V(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=le();if(!V(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=lt(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function yh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(ee(o)||z(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return jt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function xh(){const r=Ze();Gt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&G(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function oe(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&G(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&G(78),e}function bh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Kt(e))return e;e=e.getParentOrThrow()}return e}function Kt(r){return yt(r)||z(r)&&r.isShadowRoot()}function Qt(r){const e=rt(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&G(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||G(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||G(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&G(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!yt(r.getParent())||z(e)||Ve(e)||G(99)}function Mi(r){return(Ve(r)||z(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function vh(r,e,t){let n=r._blockCursorElement;if(V(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,h=document.createElement("div");h.contentEditable="false",h.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&h.classList.add(...p)}return h}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Bt(r){return Ot?(r||window).getSelection():null}function _h(r){return ir(r)&&r.tagName==="A"}function ir(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function zs(r){const e=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 r.nodeName.match(e)!==null}function ur(r){if(Ve(r)&&!r.isInline())return!0;if(!z(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function wh(){return rt()}const $a=new WeakMap,Ch=new Map;function Sh(r){if(!r._readOnly&&r.isEmpty())return Ch;r._readOnly||G(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function kh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&(z(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let mr,xt,In,fi,Xi,Zi,jr,It,eo,zn,ut="",mt="",qt=null,Mt="",tr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(It.has(r)||xt._keyToDOMMap.delete(r),z(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const Eh="40px";function Hu(r,e){const t=mr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||Eh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=It.get(r);t===void 0&&G(60);const n=t.createDOM(mr,xt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,xt),ee(t)?n.setAttribute("data-lexical-text","true"):Ve(t)&&n.setAttribute("data-lexical-decorator","true"),z(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const h=mt;mt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=h})(qs(t,It),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ut+=nr,tr+=nr)}else{const s=t.getTextContent();if(Ve(t)){const i=t.decorate(xt,mr);i!==null&&Yu(r,i),n.contentEditable="false"}else ee(t)&&(t.isDirectionless()||(mt+=s));ut+=s,tr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ut;ut="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=It.get(r[o]);a!==null&&ee(a)&&(qt===null&&(qt=a.getFormat()),Mt===""&&(Mt=a.getStyle()))}ci(e)&&(ut+=nr),s.element.__lexicalTextContent=ut,ut=i+ut}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ve(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,It);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,th.test(s)?"rtl":rh.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=mr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Dh(r,e,t){const n=mt;var s;mt="",qt=null,Mt="",function(i,o,a){const l=ut,u=i.__size,c=o.__size;ut="";const d=a.element;if(u===1&&c===1){const h=i.__first,p=o.__first;if(h===p)_n(h,d);else{const m=no(h),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${h}}.`;throw new Error(b)}throw _}Os(h,null)}const g=It.get(p);ee(g)&&(qt===null&&(qt=g.getFormat()),Mt===""&&(Mt=g.getStyle()))}else{const h=qs(i,jr),p=qs(o,It);if(h.length!==u&&G(227),p.length!==c&&G(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(h,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,_,b,S){const C=_-1,k=b-1;let E,v,T=S.getFirstChild(),B=0,j=0;for(;B<=C&&j<=k;){const M=m[B],w=x[j];if(M===w)T=Ri(_n(w,S.element)),B++,j++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(M),I=E.has(w);if(F)if(I){const q=Is(xt,w);q===T?T=Ri(_n(w,S.element)):(S.withBefore(T).insertChild(q),_n(w,S.element)),B++,j++}else $s(w,S.withBefore(T)),j++;else T=Ri(no(M)),Os(M,S.element),B++}const D=It.get(w);D!==null&&ee(D)&&(qt===null&&(qt=D.getFormat()),Mt===""&&(Mt=D.getStyle()))}const N=B>C,R=j>k;if(N&&!R){const M=x[k+1],w=M===void 0?null:xt.getElementByKey(M);ro(x,g,j,k,S.withBefore(w))}else R&&!N&&to(m,B,C,S.element)})(o,h,p,u,c,a)}ci(o)&&(ut+=nr),d.__lexicalTextContent=ut,ut=l+ut}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&qt!=null&&qt!==s.__textFormat&&!On&&(s.setTextFormat(qt),s.setTextStyle(Mt)),function(i){tn(i)&&Mt!==""&&Mt!==i.__textStyle&&!On&&i.setTextStyle(Mt)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&G(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=It.get(r);t!==void 0&&n!==void 0||G(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if(z(t)){const o=i.__lexicalTextContent;o!==void 0&&(ut+=o,tr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(mt+=a)}else{const o=t.getTextContent();ee(t)&&!t.isDirectionless()&&(mt+=o),tr+=o,ut+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,mr)){const o=$s(r,null);return e===null&&G(62),e.replaceChild(o,i),Os(r,null),o}if(z(t)&&z(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Dh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ut+=nr,tr+=nr)}else{const o=n.getTextContent();if(Ve(n)){const a=n.decorate(xt,mr);a!==null&&Yu(r,a)}else ee(n)&&!n.isDirectionless()&&(mt+=o);ut+=o,tr+=o}if(!On&&yt(n)&&n.__cachedText!==tr){const o=n.getWritable();o.__cachedText=tr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Ah(r,e,t,n,s,i){ut="",tr="",mt="",Wu=n===Zr,_s=null,xt=t,mr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,It=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,It=void 0,mr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&G(75,r),e}const Zt=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!oe(e,Mf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))oe(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))oe(e,Rf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))oe(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))oe(e,Ff,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))oe(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))oe(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,oe(e,Ns,r);else if(function(a){return a===" "}(t))oe(e,Lf,r);else if(function(a,l){return jt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,oe(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,oe(e,Ns,r);else if(function(a,l,u,c){return jt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?oe(e,vu,r):(r.preventDefault(),oe(e,Er,!0));else if(function(a){return a==="Escape"}(t))oe(e,_u,r);else if(function(a,l,u,c,d){return jt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?oe(e,wu,r):(r.preventDefault(),oe(e,Er,!1));else if(function(a,l,u){return fn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!1);else if(function(a,l){return jt&&l&&fn(a)}(t,i))r.preventDefault(),oe(e,Ln,!0);else if(function(a,l){return jt&&l&&hn(a)}(t,i))r.preventDefault(),oe(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,Pt,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,Pt,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,Pt,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))oe(e,Pf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),oe(e,jo,void 0);else if(function(a,l,u,c){return jt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),oe(e,Mo,void 0);else{const a=e._editorState._selection;a===null||V(a)?!gr&&Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&oe(e,Vf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Dt(e,()=>{Ve(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Dt(e,()=>{const t=le();if(V(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ht(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||ee(s)&&s.getStyle()!==t.style)&&oe(e,Yr,eh)}})}],["compositionend",function(r,e){gr?gn=!0:Dt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Dt(e,()=>{const t=le(),n=r.data,s=ec(r);if(n!=null&&V(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&ee(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||oe(e,Yr,n);const c=n.length;gr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ht(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(rt())}),Wr=null}],["click",function(r,e){Dt(e,()=>{const t=le(),n=Bt(e._window),s=Zn();if(n){if(V(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&Ze().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(z(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===yr)&&Gt(ea(s,n,e,r))}}}oe(e,gu,r)})}],["cut",Zt],["copy",Zt],["dragstart",Zt],["dragover",Zt],["dragend",Zt],["paste",Zt],["focus",Zt],["blur",Zt],["drop",Zt]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||gr&&qu(n)||s!=="insertCompositionText"&&Dt(n,()=>{const o=le();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!V(p))return;Gt(p.clone())}if(V(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ht(null),Nn=0,setTimeout(()=>{Dt(n,()=>{ht(null)})},so),V(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),ee(g)||G(142),o.style=g.getStyle()}}else{ht(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Yf&&p&&!_&&x||oe(n,Er,!0)}return}}var a;if(!V(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),h=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":oe(n,Yr,t);break;case"insertFromComposition":ht(null),oe(n,Yr,t);break;case"insertLineBreak":ht(null),oe(n,Kr,!1);break;case"insertParagraph":ht(null),Bn&&!Vn?(Bn=!1,oe(n,Kr,!1)):oe(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":oe(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||z(p)||z(g)||!p.isToken()||!g.isToken()})(d,h)&&oe(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":oe(n,Ki,t);break;case"deleteContent":oe(n,Er,!1);break;case"deleteWordBackward":oe(n,Fn,!0);break;case"deleteWordForward":oe(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":oe(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":oe(n,Ln,!1);break;case"formatStrikeThrough":oe(n,Pt,"strikethrough");break;case"formatBold":oe(n,Pt,"bold");break;case"formatItalic":oe(n,Pt,"italic");break;case"formatUnderline":oe(n,Pt,"underline");break;case"historyUndo":oe(n,jo,void 0);break;case"historyRedo":oe(n,Mo,void 0)}else{if(l===`
|
|
86
|
+
`)t.preventDefault(),oe(n,Kr,!1);else if(l===nr)t.preventDefault(),oe(n,Rn,void 0);else if(l==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else l!=null&&Zu(o,i,l,t.timeStamp,!0)?(t.preventDefault(),oe(n,Yr,l)):Wr=l;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,a=i.getNode(),l=rt(),u=Bt(l._window),c=u!==null?u.anchorNode:null,d=i.key,h=l.getElementByKey(d),p=t.length;return d!==o.key||!ee(a)||(!s&&(!Bs||Ju<n+50)||a.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!a.isComposing()||Cr(a)||a.isDirty()&&p>1||(s||!Bs)&&h!==null&&!a.isComposing()&&c!==Fs(h)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||a.getFormat()!==r.format||a.getStyle()!==r.style||yh(r,a)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===yr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Dt(e,()=>{if(!t)return void Gt(null);if(!Kn(e,n,i))return;const a=le();if(V(a)){const l=a.anchor,u=l.getNode();if(a.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(a.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[h,p,g,m,x]=Xu,_=Ze(),b=e.isComposing()===!1&&_.getTextContent()==="";if(d<x+200&&l.offset===g&&l.key===m)a.format=h,a.style=p;else if(l.type==="text")ee(u)||G(141),a.format=u.getFormat(),a.style=u.getStyle();else if(l.type==="element"&&!b){const S=l.getNode();a.style="",S instanceof on&&S.getChildrenSize()===0?(a.format=S.getTextFormat(),a.style=S.getTextStyle()):a.format=0}}else{const c=l.key,d=a.focus.key,h=a.getNodes(),p=h.length,g=a.isBackward(),m=g?o:s,x=g?s:o,_=g?d:c,b=g?c:d;let S=Zf,C=!1;for(let k=0;k<p;k++){const E=h[k],v=E.getTextContentSize();if(ee(E)&&v!==0&&!(k===0&&E.__key===_&&m===v||k===p-1&&E.__key===b&&x===0)&&(C=!0,S&=E.getFormat(),S===0))break}a.format=C?S:0}}oe(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ht(null),t!==null&&e!=null){if(e===""){const n=pt(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&ee(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
|
|
87
|
+
`){const n=le();if(V(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void oe(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Dt(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==yr||Gt(ea(u,t,n,r))}));const s=Vo(n),i=s[s.length-1],o=i._key,a=Qr.get(o),l=a||i;l!==n&&Wa(t,l,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):a&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Th(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&G(162);const n=t-1;n>=0||G(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const a=Vo(o),l=a[a.length-1]._key;Qr.get(l)===o&&Qr.delete(l)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&G(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){wt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(a){const l=le();if(!V(l)||!z(a))return l;const{anchor:u,focus:c}=l,d=u.getNode(),h=c.getNode();return Tn(d,a)&&u.set(a.__key,0,"element"),Tn(h,a)&&c.set(a.__key,0,"element"),l}(r);let o=!1;if(V(i)&&e){const a=i.anchor,l=i.focus;a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Ut(i)&&e&&r.isSelected()&&r.selectPrevious();if(V(i)&&e&&!o){const a=r.getIndexWithinParent();Dr(r),Ws(i,s,a,-1)}else Dr(r);t||Kt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&yt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){G(64,this.name)}static clone(e){G(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,mh(this,e)}getType(){return this.__type}isInline(){G(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=pt(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||le();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(ee(this))return n;if(V(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Ve(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:pt(e)}getParentOrThrow(){const e=this.getParent();return e===null&&G(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Kt(t))return z(e)||e===this&&Ve(e)||G(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&G(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:pt(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:pt(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();z(this)&&t.unshift(this),z(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let a=0;a<s;a++){const l=t[a];if(o.has(l))return l}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const a=z(i)?t?i.getFirstChild():i.getLastChild():null;if(a!==null){i=a;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(l!==null){i=l;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&G(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=rt()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=pt(this.__key);return e===null&&G(113),e}getWritable(){wt();const e=or(),t=rt(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,a=le();if(a!==null&&a.setCachedNodes(null),o.has(s))return Ps(i),i;const l=Jo(i);return o.add(s),Ps(l),n.set(s,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){G(70)}updateDOM(e,t,n){G(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){G(72)}static importJSON(e){G(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){wt();let n=le();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,a=e.getWritable(),l=this.getParentOrThrow().getWritable(),u=l.__size;Dr(a);const c=s.getPreviousSibling(),d=s.getNextSibling(),h=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?l.__first=o:c.getWritable().__next=o,a.__prev=h,d===null?l.__last=o:d.getWritable().__prev=o,a.__next=p,a.__parent=g,l.__size=u,t&&(z(this)&&z(a)||G(139),this.getChildren().forEach(m=>{a.append(m)})),V(n)){Gt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,a),x.key===i&&Qa(x,a)}return fr()===i&&ht(o),a}insertAfter(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=le();let a=!1,l=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),V(o)){const g=i.__key,m=o.anchor,x=o.focus;a=m.type==="element"&&m.key===g&&m.offset===p+1,l=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,h=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=h,s.__prev=n.__key,s.__parent=n.__parent,t&&V(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;a&&o.anchor.set(g,p+2,"element"),l&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),l=n.__prev,u=this.getIndexWithinParent();o===null?a.__first=i:o.getWritable().__next=i,a.__size++,n.__prev=i,s.__prev=l,s.__next=n.__key,s.__parent=n.__parent;const c=le();return t&&V(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return ot()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(z(n))return n.select();if(!ee(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){wt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(z(n))return n.select(0,0);if(!ee(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
|
|
88
|
+
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Nh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Nh(r){return{node:Mr()}}function Mr(){return Qt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===yr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let a=!1;const l=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(a=!0,l||i.add(...o)):l&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(a&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!l||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||gr){const[a,l,u]=function(c,d){const h=c.length,p=d.length;let g=0,m=0;for(;g<h&&g<p&&c[g]===d[g];)g++;for(;m+g<h&&m+g<p&&c[h-m-1]===d[p-m-1];)m++;return[g,h-g-m,d.slice(g,p-m)]}(o,i);l!==0&&n.deleteData(a,l),n.insertData(a,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return oh[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===fr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,a=document.createElement(o);let l=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(l=document.createElement(i),a.appendChild(l)),Ga(l,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(a.style.cssText=u),a}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,a=Li(0,i),l=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((a===null?u:a)!==(l===null?c:l))return!0;if(a===l&&u!==c){const m=t.firstChild;m==null&&G(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;l!==null&&a!==null&&(d=t.firstChild,d==null&&G(49)),sc(s,d,this);const h=n.theme.text;h!==void 0&&i!==o&&nc(0,i,o,d,h);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Rh,priority:0}),b:()=>({conversion:jh,priority:0}),code:()=>({conversion:lr,priority:0}),em:()=>({conversion:lr,priority:0}),i:()=>({conversion:lr,priority:0}),s:()=>({conversion:lr,priority:0}),span:()=>({conversion:Bh,priority:0}),strong:()=>({conversion:lr,priority:0}),sub:()=>({conversion:lr,priority:0}),sup:()=>({conversion:lr,priority:0}),u:()=>({conversion:lr,priority:0})}}static importJSON(e){const t=lt(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t!==null&&ir(t)||G(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=cs(t,"b")),this.hasFormat("italic")&&(t=cs(t,"i")),this.hasFormat("strikethrough")&&(t=cs(t,"s")),this.hasFormat("underline")&&(t=cs(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format=typeof e=="string"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?nh[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=ih[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){wt();let n=e,s=t;const i=le(),o=this.getTextContent(),a=this.__key;if(typeof o=="string"){const l=o.length;n===void 0&&(n=l),s===void 0&&(s=l)}else n=0,s=0;if(!V(i))return ac(a,n,a,s,"text","text");{const l=fr();l!==i.anchor.key&&l!==i.focus.key||ht(a),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,a=n.length;let l=e;l<0&&(l=a+l,l<0&&(l=0));const u=le();if(s&&V(u)){const d=e+a;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){wt();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=fr(),o=new Set(e),a=[],l=n.length;let u="";for(let k=0;k<l;k++)u!==""&&o.has(k)&&(a.push(u),u=""),u+=n[k];u!==""&&a.push(u);const c=a.length;if(c===0)return[];if(a[0]===n)return[t];const d=a[0],h=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let _=!1;t.isSegmented()?(p=lt(d),p.__format=g,p.__style=m,p.__detail=x,_=!0):(p=t.getWritable(),p.__text=d);const b=le(),S=[p];let C=d.length;for(let k=1;k<c;k++){const E=a[k],v=E.length,T=lt(E).getWritable();T.__format=g,T.__style=m,T.__detail=x;const B=T.__key,j=C+v;if(V(b)){const N=b.anchor,R=b.focus;N.key===s&&N.type==="text"&&N.offset>C&&N.offset<=j&&(N.key=B,N.offset-=C,b.dirty=!0),R.key===s&&R.type==="text"&&R.offset>C&&R.offset<=j&&(R.key=B,R.offset-=C,b.dirty=!0)}i===s&&ht(B),C=j,S.push(T)}if(h!==null){(function(v){const T=v.getPreviousSibling(),B=v.getNextSibling();T!==null&&Ps(T),B!==null&&Ps(B)})(this);const k=h.getWritable(),E=this.getIndexWithinParent();_?(k.splice(E,0,S),this.remove()):k.splice(E,1,S),V(b)&&Ws(b,h,E,c-1)}return S}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||G(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;fr()===s&&ht(n);const a=le();if(V(a)){const d=a.anchor,h=a.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),a.dirty=!0),h!==null&&h.key===s&&(nl(h,t,n,e,o),a.dirty=!0)}const l=e.__text,u=t?l+i:i+l;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Bh(r){return{forChild:Zo(r.style),node:null}}function jh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function Mh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Rh(r){const e=r;r.parentElement===null&&G(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!Mh(i);)o.push(i),i=i.parentNode;const a=s===void 0?i:s;for(let l=0;l<o.length;l++)Ka.set(o[l],a);return a}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const a=n[o];a===`
|
|
89
89
|
`||a===`\r
|
|
90
|
-
`?s.push(Mr()):a===" "?s.push(Xn()):a!==""&&s.push(lt(a))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:lt(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===yr)return t;if(t.nodeName==="BR")return null}}const Fh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function lr(r){const e=Fh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function lt(r=""){return Qt(new sn(r))}function ee(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",a=n.includes("underline"),l=r.verticalAlign;return u=>(ee(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),a&&!u.hasFormat("underline")&&u.toggleFormat("underline"),l!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),l!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){
|
|
91
|
-
`),c=!h.isEmpty();else if(c=!1,ee(h)){let p=h.getTextContent();h===t?h===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=a<l?p.slice(a,l):p.slice(l,a)):p=o?p.slice(a):p.slice(l):h===n&&(p=o?p.slice(0,l):p.slice(0,a)),u+=p}else!
|
|
90
|
+
`?s.push(Mr()):a===" "?s.push(Xn()):a!==""&&s.push(lt(a))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:lt(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===yr)return t;if(t.nodeName==="BR")return null}}const Fh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function lr(r){const e=Fh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function lt(r=""){return Qt(new sn(r))}function ee(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",a=n.includes("underline"),l=r.verticalAlign;return u=>(ee(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),a&&!u.hasFormat("underline")&&u.toggleFormat("underline"),l!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),l!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){G(126)}setDetail(e){G(127)}setMode(e){G(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Qt(new Jn)}function Lh(r){return r instanceof Jn}class Ph{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,i=e.offset;if(z(t)){const o=t.getDescendantByIndex(s);t=o??t}if(z(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=pt(this.key);return e===null&&G(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(fr()===i&&ht(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Yt(r,e,t){return new Ph(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(ee(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!z(e)){const i=e.getNextSibling();if(ee(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(z(e)){const t=e.getLastDescendant();z(t)||ee(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function cr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ut(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new pi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let i;if(ee(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=pt(s);i!==null&&n.push(i)}return es()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function V(r){return r instanceof xr}class xr{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!V(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let a=i.getNode(),l=o.getNode();const u=i.offset,c=o.offset;if(z(a)){const h=a.getDescendantByIndex(u);a=h??a}if(z(l)){let h=l.getDescendantByIndex(c);h!==null&&h!==a&&l.getChildAtIndex(c)===h&&(h=h.getPreviousSibling()),l=h??l}let d;return d=a.is(l)?z(a)&&a.getChildrenSize()>0?[]:[a]:a.getNodesBetween(l),es()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){cr(this.anchor,e.__key,t,"text"),cr(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,i=this.focus,o=s.isBefore(i),[a,l]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const h=e[d];if(z(h)&&!h.isInline())c||(u+=`
|
|
91
|
+
`),c=!h.isEmpty();else if(c=!1,ee(h)){let p=h.getTextContent();h===t?h===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=a<l?p.slice(a,l):p.slice(l,a)):p=o?p.slice(a):p.slice(l):h===n&&(p=o?p.slice(0,l):p.slice(0,a)),u+=p}else!Ve(h)&&!Ar(h)||h===n&&this.isCollapsed()||(u+=h.getTextContent())}return u}applyDOMRange(e){const t=rt(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;cr(this.anchor,i.key,i.offset,i.type),cr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new xr(Yt(e.key,e.offset,e.type),Yt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
|
|
92
92
|
`||o===`\r
|
|
93
|
-
`?n.push(Mr()):o===" "?n.push(Xn()):n.push(lt(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,_,b,S){const C=x.getNode(),k=C.getChildAtIndex(x.offset),E=lt(),v=yt(C)?ot().append(E):E;E.setFormat(b),E.setStyle(S),k===null?C.append(v):k.insertBefore(v),x.is(_)&&_.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let h=c[0];ee(h)||K(26);const p=h.getTextContent().length,g=h.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(h.isSegmented()||h.isToken()||!h.canInsertTextAfter()||!g.canInsertTextAfter()&&h.getNextSibling()===null)){let x=h.getNextSibling();if(ee(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=lt(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?h.insertAfter(x):g.insertAfter(x)),x.select(0,0),h=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&l===0&&(h.isSegmented()||h.isToken()||!h.canInsertTextBefore()||!g.canInsertTextBefore()&&h.getPreviousSibling()===null)){let x=h.getPreviousSibling();if(ee(x)&&!Cr(x)||(x=lt(),x.setFormat(s),g.canInsertTextBefore()?h.insertBefore(x):g.insertBefore(x)),x.select(),h=x,e!=="")return void this.insertText(e)}else if(h.isSegmented()&&l!==p){const x=lt(h.getTextContent());x.setFormat(s),h.replace(x),h=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||$(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(h.isToken()){const S=lt(e);return S.select(),void h.replace(S)}const x=h.getFormat(),_=h.getStyle();if(l!==u||x===s&&_===i){if(Lh(h)){const S=lt(e);return S.setFormat(s),S.setStyle(i),S.select(),void h.replace(S)}}else{if(h.getTextContent()!==""){const S=lt(e);if(S.setFormat(s),S.setStyle(i),S.select(),l===0)h.insertBefore(S,!1);else{const[C]=h.splitText(l);C.insertAfter(S,!1)}return void(S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}h.setFormat(s),h.setStyle(i)}const b=u-l;h=h.spliceText(l,b,e,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(h.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=_))}else{const x=new Set([...h.getParentKeys(),...m.getParentKeys()]),_=$(h)?h:h.getParentOrThrow();let b=$(m)?m:m.getParentOrThrow(),S=m;if(!_.is(b)&&b.isInline())do S=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(ee(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const T=lt(m.getTextContent());m.replace(T),m=T}yt(a.getNode())||a.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const T=m.getParentOrThrow();T.canBeEmpty()||T.getChildrenSize()!==1?m.remove():T.remove()}else x.add(m.__key);const C=b.getChildren(),k=new Set(c),E=_.is(b),v=_.isInline()&&h.getNextSibling()===null?_:h;for(let T=C.length-1;T>=0;T--){const B=C[T];if(B.is(h)||$(B)&&B.isParentOf(h))break;B.isAttached()&&(!k.has(B)||B.is(S)?E||v.insertAfter(B,!1):B.remove())}if(!E){let T=b,B=null;for(;T!==null;){const j=T.getChildren(),N=j.length;(N===0||j[N-1].is(B))&&(x.delete(T.__key),B=T),T=T.getParent()}}if(h.isToken())if(l===p)h.select();else{const T=lt(e);T.select(),h.replace(T)}else h=h.spliceText(l,p-l,e,!0),h.getTextContent()===""?h.remove():h.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let T=1;T<d;T++){const B=c[T],j=B.__key;x.has(j)||B.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),a=i.getNode();const l=pn(o,ur),u=pn(a,ur);ee(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&ee(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,h)=>{if(d.getTextContent()==="")d.remove();else if(h!==0&&Cr(d)){const p=lt(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&ee(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(ee(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}ee(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&ee(o)?o.selectEnd():a.isAttached()&&ee(a)&&a.selectStart(),$(l)&&$(u)&&l!==u&&(l.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ht(null);const n=this.getNodes(),s=[];for(const C of n)ee(C)&&s.push(C);const i=C=>{n.forEach(k=>{if(tn(k)){const E=k.getFormatFlags(e,C);k.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ht(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;let h=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(h=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let _=s[x];const b=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const C=p.splitText(g,b),k=g===0?C[0]:C[1];k.setFormat(m),c.type==="text"&&c.set(k.__key,0,"text"),d.type==="text"&&d.set(k.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const S=_.getFormatFlags(e,m);b>0&&(b===_.getTextContentSize()||Cr(_)||([_]=_.splitText(b)),_.setFormat(S));for(let C=h+1;C<x;C++){const k=s[C],E=k.getFormatFlags(e,S);k.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,b,"text"),this.format=m|S}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ae();return V(g)||K(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,ur),s=e[e.length-1];if($(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>($(g)||Ge(g))&&!g.isInline())){$(n)||K(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=ot();let x=null;for(let _=0;_<g.length;_++){const b=g[_],S=Ar(b);if(S||Ge(b)&&b.isInline()||$(b)&&b.isInline()||ee(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),S))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!$(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;$(d=c)&&ur(d)&&!d.isEmpty()&&$(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&($(n)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let b=m;const S=[m];for(;b!==_;)b.getNextSibling()||K(140),b=b.getNextSibling(),S.push(b);let C=g;for(const k of S)C=C.insertAfter(k)}(n,c));const h=pn(o,ur);l&&$(h)&&(l.canMergeWhenEmpty()||ur(u))&&(h.append(...l.getChildren()),l.remove()),$(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=$(n)?n.getLastChild():null;Ar(p)&&h!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=ot();return Ze().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),ur);$(t)||K(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(ee(o)&&!this.isCollapsed()){const d=l>u?u:l,h=l>u?l:u,p=o.splitText(d,h),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(ee(o)){const d=c?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(ee(a)){const d=a.getTextContent().length,h=c?u:l;h===0?e.pop():h!==d&&([a]=a.splitText(h),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if(Ge(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Gt(p)}const h=t?a.getPreviousSibling():a.getNextSibling();if(ee(h)){const p=h.__key,g=t?h.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=a.getParentOrThrow();let g,m;return $(h)?(m=h.__key,g=t?h.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=rt(),u=Bt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!$(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,d),function(h,p,g,m){h.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const h=u.getRangeAt(0),p=this.anchor.getNode(),g=yt(p)?p:bh(p);if(this.applyDOMRange(h),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let b=0;b<m.length;b++){const S=m[b];Tn(S,g)?x.push(S):_=!0}if(_&&x.length>0)if(t){const b=x[0];$(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];$(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===h.startContainer&&u.anchorOffset===h.startOffset||function(b){const S=b.focus,C=b.anchor,k=C.key,E=C.offset,v=C.type;cr(C,S.key,S.offset,S.type),cr(S,k,E,v),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&$(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if($(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if(Ge(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&$(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Gt(a)}else o.remove(),rt().dispatchCommand(Bo,void 0);return}if(!e&&$(o)&&$(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.focus,h=c.getNode(),p=d.getNode();if(h===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,_=x?g:m,b=x?m:g,S=b-1;_!==S&&(zu(h.getTextContent().slice(_,b))||(u?d.offset=S:c.offset=S))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&yt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ut(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[i+1],d=!0;else if(u!==null){const h=u.parentNode;r===h&&e>Array.prototype.indexOf.call(h.children,u)&&i--}if(s=Hr(c),ee(s))i=Ra(s,o);else{let h=Hr(r);if(h===null)return null;if($(h)){const p=n.getElementByKey(h.getKey());p===null&&K(214),[h,i]=h.getDOMSlot(p).resolveChildIndex(h,p,r,e),$(h)||K(215),o&&i>=h.getChildrenSize()&&(i=Math.max(0,h.getChildrenSize()-1));let m=h.getChildAtIndex(i);if($(m)&&function(x,_,b){const S=x.getParent();return b===null||S===null||!S.canBeEmpty()||S!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?h=m:(m=x,h=$(m)?m:m.getParentOrThrow()),i=0}ee(m)?(s=m,h=null,i=Ra(m,o)):m!==h&&o&&!d&&($(h)||K(216),i=Math.min(h.getChildrenSize(),i+1))}else{const p=h.getIndexWithinParent();i=e===0&&Ge(h)&&Hr(r)===h?p:p+1,h=h.getParentOrThrow()}if($(h))return Yt(h.__key,i,"element")}}else s=Hr(r);return ee(s)?Yt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&$(o)&&o.isInline()){const a=o.getPreviousSibling();ee(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else $(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):ee(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&$(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&$(o)&&o.isInline()&&!o.canInsertTextAfter()){const a=o.getNextSibling();ee(a)&&(r.key=a.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=rt();if(i.isComposing()&&i._compositionKey!==r.key&&V(t)){const o=t.anchor,a=t.focus;cr(r,o.key,o.offset,o.type),cr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,V(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,V(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if(Ge(l)&&Ge(u))return null}return ic(o,a,i),[o,a]}function co(r){return $(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=or(),a=new xr(Yt(r,e,s),Yt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ih(){const r=Yt("root",0,"element"),e=Yt("root",0,"element");return new xr(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,h;if(V(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,h=e.focusOffset,a&&V(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,h,t,r);if(p===null)return null;const[g,m]=p;return new xr(g,m,V(r)?r.format:0,V(r)?r.style:"")}function ae(){return or()._selection}function Zn(){return rt()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(l,c,"element"),i.set(l,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),h=u?s:i,p=h.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=h.offset;(t<=g&&n>0||t<g&&n<0)&&h.set(l,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!$(i))return;const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if($(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if($(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,ee(n)?(o=n.getTextContentSize(),a="text"):$(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,ee(s)?a="text":$(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function zh(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!V(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const h=e.anchor,p=e.focus,g=h.key,m=p.key,x=Is(t,g),_=Is(t,m),b=h.offset,S=p.offset,C=e.format,k=e.style,E=e.isCollapsed();let v=x,T=_,B=!1;if(h.type==="text"){v=Fs(x);const D=h.getNode();B=D.getFormat()!==C||D.getStyle()!==k}else V(r)&&r.anchor.type==="text"&&(B=!0);var j,N,R,M,w;if(p.type==="text"&&(T=Fs(_)),v!==null&&T!==null&&(E&&(r===null||B||V(r)&&(r.format!==C||r.style!==k))&&(j=C,N=k,R=b,M=g,w=performance.now(),Xu=[j,N,R,M,w]),u!==b||c!==S||a!==v||l!==T||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),h.type==="element"))){try{n.setBaseAndExtent(v,b,T,S)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const D=e instanceof xr&&e.anchor.type==="element"?v.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(D!==null){let F;if(D instanceof Text){const z=document.createRange();z.selectNode(D),F=z.getBoundingClientRect()}else F=D.getBoundingClientRect();(function(z,q,J){const te=J.ownerDocument,W=te.defaultView;if(W===null)return;let{top:G,bottom:H}=q,se=0,le=0,ue=J;for(;ue!==null;){const _e=ue===te.body;if(_e)se=0,le=di(z).innerHeight;else{const De=ue.getBoundingClientRect();se=De.top,le=De.bottom}let fe=0;if(G<se?fe=-(se-G):H>le&&(fe=H-le),fe!==0)if(_e)W.scrollBy(0,fe);else{const De=ue.scrollTop;ue.scrollTop+=fe;const O=ue.scrollTop-De;G-=O,H-=O}if(_e)break;ue=Yn(ue)}})(t,F,i)}}oo=!0}}function lc(r){let e=ae()||Zn();e===null&&(e=Ze().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ae();V(t)&&(e=t),V(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!ur(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=ot();return Ze().append(s),s.select(),[Ze(),0]}if(ee(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!$(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new xr(Yt(r.__key,e,"element"),Yt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let dt=null,ft=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||dt!==null&&dt._readOnly}function wt(){St&&K(13)}function uc(){ws>99&&K(14)}function or(){return dt===null&&K(195,cc()),dt}function rt(){return ft===null&&K(196,cc()),ft}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function $h(){return ft}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&K(30,l),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function qh(r){return ta(r,rt()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&K(17,t);const s=n.klass;r.type!==s.getType()&&K(18,s.name);const i=s.importJSON(r),o=r.children;if($(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=dt,s=St,i=ft;dt=e,St=!0,ft=r;try{return t()}finally{dt=n,St=s,ft=i}}function hr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,a=t._selection,l=r._dirtyType!==Nr,u=dt,c=St,d=ft,h=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){ft=r,dt=t,St=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,T=r._dirtyLeaves;p.disconnect(),g=Ah(i,t,r,E,v,T)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,hr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=h,dt=u,St=c,ft=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,b=r._updateTags,S=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,v){const T=E._decorators;let B=E._pendingDecorators||T;const j=v._nodeMap;let N;for(N in B)j.has(N)||(B===T&&(B=Pu(E)),delete B[N])}(r,t);const C=s?null:Bt(r._window);if(r._editable&&C!==null&&(l||a===null||a.dirty)){ft=r,dt=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),zh(o,a,r,C,b,n)}vh(r,n,a),p!==null&&p.observe(n,sl)}finally{ft=d,dt=u}}g!==null&&function(E,v,T,B,j){const N=Array.from(E._listeners.mutation),R=N.length;for(let M=0;M<R;M++){const[w,D]=N[M],F=v.get(D);F!==void 0&&w(F,{dirtyLeaves:B,prevEditorState:j,updateTags:T})}}(r,g,b,m,i),V(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const k=r._pendingDecorators;k!==null&&(r._decorators=k,r._pendingDecorators=null,jn("decorator",r,!0,k)),function(E,v,T){const B=Ma(v),j=Ma(T);B!==j&&jn("textcontent",E,!0,j)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:b}),function(E,v){if(E._deferred=[],v.length!==0){const T=E._updating;E._updating=!0;try{for(let B=0;B<v.length;B++)v[B]()}finally{E._updating=T}}}(r,S),function(E){const v=E._updates;if(v.length!==0){const T=v.shift();if(T){const[B,j]=T;hc(E,B,j)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||ft!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&K(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=dt,d=St,h=ft,p=r._updating;dt=l,St=!1,r._updating=!0,ft=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(_){const b=_.getEditorState()._selection,S=Bt(_._window);return V(b)||b==null?ea(b,S,_,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(_,b){const S=b.getEditorState()._selection,C=_._selection;if(V(C)){const k=C.anchor,E=C.focus;let v;if(k.type==="text"&&(v=k.getNode(),v.selectionTransform(S,C)),E.type==="text"){const T=E.getNode();v!==T&&T.selectionTransform(S,C)}}}(l,r),r._dirtyType!==Nr&&(i?function(_,b){const S=b._dirtyLeaves,C=_._nodeMap;for(const k of S){const E=C.get(k);ee(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(l,r):function(_,b){const S=b._dirtyLeaves,C=b._dirtyElements,k=_._nodeMap,E=fr(),v=new Map;let T=S,B=T.size,j=C,N=j.size;for(;B>0||N>0;){if(B>0){b._dirtyLeaves=new Set;for(const R of T){const M=k.get(R);ee(M)&&M.isAttached()&&M.isSimpleText()&&!M.isUnmergeable()&&Ba(M),M!==void 0&&ol(M,E)&&il(b,M,v),S.add(R)}if(T=b._dirtyLeaves,B=T.size,B>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const R of j){const M=R[0],w=R[1];if(M!=="root"&&!w)continue;const D=k.get(M);D!==void 0&&ol(D,E)&&il(b,D,v),C.set(M,w)}T=b._dirtyLeaves,B=T.size,j=b._dirtyElements,N=j.size,ws++}b._dirtyLeaves=S,b._dirtyElements=C}(l,r),ll(r),function(_,b,S,C){const k=_._nodeMap,E=b._nodeMap,v=[];for(const[T]of C){const B=E.get(T);B!==void 0&&(B.isAttached()||($(B)&&Uu(B,T,k,E,v,C),k.has(T)||C.delete(T),v.push(T)))}for(const T of v)E.delete(T);for(const T of S){const B=E.get(T);B===void 0||B.isAttached()||(k.has(T)||S.delete(T),E.delete(T))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(V(x)){const _=l._nodeMap,b=x.anchor.key,S=x.focus.key;_.get(b)!==void 0&&_.get(S)!==void 0||K(19)}else Ut(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void hr(r)}finally{dt=c,St=d,ft=h,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(_))return!0}else if(_!==null)return!0;return!1}(l,r)?l._flushSync?(l._flushSync=!1,hr(r)):u&&ph(()=>{hr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Dt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&K(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&K(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&K(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&K(225),t.reverse()}class ar extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return sh[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=rt()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(ee(t)&&e.push(t),$(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;$(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;$(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return $(i)&&i.getLastDescendant()||i||null}const s=t[e];return $(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:pt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:pt(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&K(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),$(i)&&s!==n-1&&!i.isInline()&&(e+=nr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),$(i)&&s!==n-1&&!i.isInline()&&(e+=nr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){wt();const n=ae();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(ee(l)||$(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(ee(l)||$(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return V(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||K(226,String(e),String(t),String(i));const a=o.__key,l=[],u=[],c=this.getChildAtIndex(e+t);let d=null,h=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&K(100);const x=g.getNextSibling(),_=g.__key;Dr(g.getWritable()),u.push(_),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===a&&h--,Dr(x);const _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const b=p.getWritable();b.__next=_,x.__prev=b.__key}m.__key===a&&K(76),x.__parent=a,l.push(_),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=h,u.length){const g=ae();if(V(g)){const m=new Set(u),x=new Set(l),{anchor:_,focus:b}=g;cl(_,m,x)&&Hs(_,_.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),h!==0||this.canBeEmpty()||Kt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function $(r){return r instanceof ar}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){K(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ge(r){return r instanceof ra}class ts extends ar{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&rt()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){K(52)}replace(e){K(53)}insertBefore(e){K(54)}insertAfter(e){K(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];$(n)||Ge(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Ze();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),$(r)){const n=e.children;Array.isArray(n)||K(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Ze())}))}}class sa extends ar{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends ar{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Uh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ot();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=ot();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||ee(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function Uh(r){const e=ot();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function ot(){return Qt(new on)}function tn(r){return r instanceof on}const We=0,Vr=1,Wh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Hh(r){const e=r||{},t=$h(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:Ou()),l=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,h=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],_=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,b=E.withKlass||null}const S=x.getType(),C=x.transform(),k=new Set;C!==null&&k.add(C),p.set(S,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:b,transforms:k})}}const g=new mi(o,s,p,{disableEvents:i,namespace:a,theme:n},c||console.error,function(m,x){const _=new Map,b=new Set,S=C=>{Object.keys(C).forEach(k=>{let E=_.get(k);E===void 0&&(E=[],_.set(k,E)),E.push(C[k])})};return m.forEach(C=>{const k=C.klass.importDOM;if(k==null||b.has(k))return;b.add(k);const E=k.call(C.klass);E!==null&&S(E)}),x&&S(x),_}(p,d?d.import:void 0),h);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,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=Ou(),this._onError=i,this._htmlConversions=o,this._editable=a,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&K(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&K(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&K(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Sh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),Dt(o,()=>{const l=or();if(l.isEmpty())return;if(a==="root")return void Ze().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return ie(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Th(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),hr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let h=0;h<io.length;h++){const[p,g]=io[h],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const _=l.isEditable();switch(p){case"cut":return _&&ie(l,Ro,x);case"copy":return ie(l,ii,x);case"paste":return _&&ie(l,si,x);case"dragstart":return _&&ie(l,Su,x);case"dragover":return _&&ie(l,ku,x);case"dragend":return _&&ie(l,$f,x);case"focus":return _&&ie(l,Wf,x);case"blur":return _&&ie(l,Hf,x);case"drop":return _&&ie(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&K(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),hr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||hr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),a=dt,l=St,u=ft,c=s._dirtyElements,d=s._dirtyLeaves,h=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,dt=o,St=!1,ft=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=h,s._dirtyType=p,dt=a,St=l,ft=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return hr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Dt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Dt(this,()=>{const s=ae(),i=Ze();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Gh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Bf(null,n),c=Hh({editable:r.editable,html:l,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,h){if(h!==null){if(h===void 0)d.update(()=>{const p=Ze();if(p.isEmpty()){const g=ot();p.append(g);const m=yc?document.activeElement:null;(ae()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(h!==null)switch(typeof h){case"string":{const p=d.parseEditorState(h);d.setEditorState(p,ds);break}case"object":d.setEditorState(h,ds);break;case"function":d.update(()=>{Ze().isEmpty()&&h(d)},ds)}}}(c,a),[c,u]},[]);return Vh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),f.jsx(pu.Provider,{value:t,children:e})}const Kh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Yh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Qh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Kh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Yh)}function Jh(){return Ze().getTextContent()}function Xh(r,e=!0){if(r)return!1;let t=Jh();return e&&(t=t.trim()),t===""}function Zh(r){if(!Xh(r,!1))return!1;const e=Ze().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ge(s))return!1;if($(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!ee(l))return!1}}}return!0}function xc(r){return()=>Zh(r)}function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rp=tp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const np=new Map;function sp(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),h=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);let m,x=0;return h?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function ip(r){const e=r.getStyle(),t=sp(e);np.set(e,t)}function op(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ze(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;$(a)||rp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return Ge(t)&&!t.isIsolated()||$(t)&&!t.isInline()&&!t.canBeEmpty()}function ap(r,e,t,n){r.modify(e?"extend":"move",t,n)}function lp(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=lp(r);ap(r,e,t?!n:n,"character")}function hl(r){if(Ge(r)||!$(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cp=up(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,dp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||dp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function fp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function hp(r){const e=yi(r,t=>$(t)&&!t.isInline());return $(e)||cp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ze()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function pr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function pp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,h,p,g]=l;r.update(()=>{const m=ae();if(V(m)){const x=m.anchor;let _=x.getNode(),b=0,S=0;if(ee(_)&&u>=0&&c>=0&&(b=u,S=u+c,m.setTextNodeRange(_,b,_,S)),b===S&&d===""||(m.insertRawText(d),_=x.getNode()),ee(_)){b=h,S=h+p;const C=_.getTextContentSize();b=b>C?C:b,S=S>C?C:S,m.setTextNodeRange(_,b,_,S)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Ze().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=$(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=ee(p)&&n!==null?bc(n,p):p,o=p}const a=$(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const h=document.createDocumentFragment();for(let p=0;p<a.length;p++){const g=a[p],m=kc(r,g,h,n);!s&&$(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((ir(c)||Oa(c))&&c.append(h),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(h);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let b=null;if(_!==void 0)for(const S of _){const C=S(g);C!==null&&(b===null||(b.priority||0)<=(C.priority||0))&&(b=C)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let h=[];const p=(a==null||!Kt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)h.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(h=c(h)),zs(r)&&(h=gp(r,h,p?()=>{const g=new sa;return t.push(g),g}:ot)),a==null?h.length>0?o=o.concat(h):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):$(a)&&a.append(...h),o}function gp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function mp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=mp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function yp(r,e=ae()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function xp(r,e=ae()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(bp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,vp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(V(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=ae();if(V(l)){const u=o[a];u===`
|
|
93
|
+
`?n.push(Mr()):o===" "?n.push(Xn()):n.push(lt(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,_,b,S){const C=x.getNode(),k=C.getChildAtIndex(x.offset),E=lt(),v=yt(C)?ot().append(E):E;E.setFormat(b),E.setStyle(S),k===null?C.append(v):k.insertBefore(v),x.is(_)&&_.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let h=c[0];ee(h)||G(26);const p=h.getTextContent().length,g=h.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(h.isSegmented()||h.isToken()||!h.canInsertTextAfter()||!g.canInsertTextAfter()&&h.getNextSibling()===null)){let x=h.getNextSibling();if(ee(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=lt(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?h.insertAfter(x):g.insertAfter(x)),x.select(0,0),h=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&l===0&&(h.isSegmented()||h.isToken()||!h.canInsertTextBefore()||!g.canInsertTextBefore()&&h.getPreviousSibling()===null)){let x=h.getPreviousSibling();if(ee(x)&&!Cr(x)||(x=lt(),x.setFormat(s),g.canInsertTextBefore()?h.insertBefore(x):g.insertBefore(x)),x.select(),h=x,e!=="")return void this.insertText(e)}else if(h.isSegmented()&&l!==p){const x=lt(h.getTextContent());x.setFormat(s),h.replace(x),h=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||z(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(h.isToken()){const S=lt(e);return S.select(),void h.replace(S)}const x=h.getFormat(),_=h.getStyle();if(l!==u||x===s&&_===i){if(Lh(h)){const S=lt(e);return S.setFormat(s),S.setStyle(i),S.select(),void h.replace(S)}}else{if(h.getTextContent()!==""){const S=lt(e);if(S.setFormat(s),S.setStyle(i),S.select(),l===0)h.insertBefore(S,!1);else{const[C]=h.splitText(l);C.insertAfter(S,!1)}return void(S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}h.setFormat(s),h.setStyle(i)}const b=u-l;h=h.spliceText(l,b,e,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(h.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=_))}else{const x=new Set([...h.getParentKeys(),...m.getParentKeys()]),_=z(h)?h:h.getParentOrThrow();let b=z(m)?m:m.getParentOrThrow(),S=m;if(!_.is(b)&&b.isInline())do S=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(ee(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const T=lt(m.getTextContent());m.replace(T),m=T}yt(a.getNode())||a.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const T=m.getParentOrThrow();T.canBeEmpty()||T.getChildrenSize()!==1?m.remove():T.remove()}else x.add(m.__key);const C=b.getChildren(),k=new Set(c),E=_.is(b),v=_.isInline()&&h.getNextSibling()===null?_:h;for(let T=C.length-1;T>=0;T--){const B=C[T];if(B.is(h)||z(B)&&B.isParentOf(h))break;B.isAttached()&&(!k.has(B)||B.is(S)?E||v.insertAfter(B,!1):B.remove())}if(!E){let T=b,B=null;for(;T!==null;){const j=T.getChildren(),N=j.length;(N===0||j[N-1].is(B))&&(x.delete(T.__key),B=T),T=T.getParent()}}if(h.isToken())if(l===p)h.select();else{const T=lt(e);T.select(),h.replace(T)}else h=h.spliceText(l,p-l,e,!0),h.getTextContent()===""?h.remove():h.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let T=1;T<d;T++){const B=c[T],j=B.__key;x.has(j)||B.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),a=i.getNode();const l=pn(o,ur),u=pn(a,ur);ee(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&ee(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,h)=>{if(d.getTextContent()==="")d.remove();else if(h!==0&&Cr(d)){const p=lt(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&ee(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(ee(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}ee(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&ee(o)?o.selectEnd():a.isAttached()&&ee(a)&&a.selectStart(),z(l)&&z(u)&&l!==u&&(l.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ht(null);const n=this.getNodes(),s=[];for(const C of n)ee(C)&&s.push(C);const i=C=>{n.forEach(k=>{if(tn(k)){const E=k.getFormatFlags(e,C);k.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ht(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;let h=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(h=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let _=s[x];const b=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const C=p.splitText(g,b),k=g===0?C[0]:C[1];k.setFormat(m),c.type==="text"&&c.set(k.__key,0,"text"),d.type==="text"&&d.set(k.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const S=_.getFormatFlags(e,m);b>0&&(b===_.getTextContentSize()||Cr(_)||([_]=_.splitText(b)),_.setFormat(S));for(let C=h+1;C<x;C++){const k=s[C],E=k.getFormatFlags(e,S);k.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,b,"text"),this.format=m|S}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=le();return V(g)||G(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,ur),s=e[e.length-1];if(z(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(z(g)||Ve(g))&&!g.isInline())){z(n)||G(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=ot();let x=null;for(let _=0;_<g.length;_++){const b=g[_],S=Ar(b);if(S||Ve(b)&&b.isInline()||z(b)&&b.isInline()||ee(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),S))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!z(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;z(d=c)&&ur(d)&&!d.isEmpty()&&z(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(z(n)||G(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&G(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let b=m;const S=[m];for(;b!==_;)b.getNextSibling()||G(140),b=b.getNextSibling(),S.push(b);let C=g;for(const k of S)C=C.insertAfter(k)}(n,c));const h=pn(o,ur);l&&z(h)&&(l.canMergeWhenEmpty()||ur(u))&&(h.append(...l.getChildren()),l.remove()),z(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=z(n)?n.getLastChild():null;Ar(p)&&h!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=ot();return Ze().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),ur);z(t)||G(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(ee(o)&&!this.isCollapsed()){const d=l>u?u:l,h=l>u?l:u,p=o.splitText(d,h),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(ee(o)){const d=c?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(ee(a)){const d=a.getTextContent().length,h=c?u:l;h===0?e.pop():h!==d&&([a]=a.splitText(h),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if(Ve(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Gt(p)}const h=t?a.getPreviousSibling():a.getNextSibling();if(ee(h)){const p=h.__key,g=t?h.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=a.getParentOrThrow();let g,m;return z(h)?(m=h.__key,g=t?h.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=rt(),u=Bt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!z(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,d),function(h,p,g,m){h.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const h=u.getRangeAt(0),p=this.anchor.getNode(),g=yt(p)?p:bh(p);if(this.applyDOMRange(h),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let b=0;b<m.length;b++){const S=m[b];Tn(S,g)?x.push(S):_=!0}if(_&&x.length>0)if(t){const b=x[0];z(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];z(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===h.startContainer&&u.anchorOffset===h.startOffset||function(b){const S=b.focus,C=b.anchor,k=C.key,E=C.offset,v=C.type;cr(C,S.key,S.offset,S.type),cr(S,k,E,v),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&z(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(z(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if(Ve(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&z(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Gt(a)}else o.remove(),rt().dispatchCommand(Bo,void 0);return}if(!e&&z(o)&&z(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.focus,h=c.getNode(),p=d.getNode();if(h===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,_=x?g:m,b=x?m:g,S=b-1;_!==S&&(zu(h.getTextContent().slice(_,b))||(u?d.offset=S:c.offset=S))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&yt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ut(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[i+1],d=!0;else if(u!==null){const h=u.parentNode;r===h&&e>Array.prototype.indexOf.call(h.children,u)&&i--}if(s=Hr(c),ee(s))i=Ra(s,o);else{let h=Hr(r);if(h===null)return null;if(z(h)){const p=n.getElementByKey(h.getKey());p===null&&G(214),[h,i]=h.getDOMSlot(p).resolveChildIndex(h,p,r,e),z(h)||G(215),o&&i>=h.getChildrenSize()&&(i=Math.max(0,h.getChildrenSize()-1));let m=h.getChildAtIndex(i);if(z(m)&&function(x,_,b){const S=x.getParent();return b===null||S===null||!S.canBeEmpty()||S!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?h=m:(m=x,h=z(m)?m:m.getParentOrThrow()),i=0}ee(m)?(s=m,h=null,i=Ra(m,o)):m!==h&&o&&!d&&(z(h)||G(216),i=Math.min(h.getChildrenSize(),i+1))}else{const p=h.getIndexWithinParent();i=e===0&&Ve(h)&&Hr(r)===h?p:p+1,h=h.getParentOrThrow()}if(z(h))return Yt(h.__key,i,"element")}}else s=Hr(r);return ee(s)?Yt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&z(o)&&o.isInline()){const a=o.getPreviousSibling();ee(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else z(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):ee(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&z(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&z(o)&&o.isInline()&&!o.canInsertTextAfter()){const a=o.getNextSibling();ee(a)&&(r.key=a.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=rt();if(i.isComposing()&&i._compositionKey!==r.key&&V(t)){const o=t.anchor,a=t.focus;cr(r,o.key,o.offset,o.type),cr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,V(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,V(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if(Ve(l)&&Ve(u))return null}return ic(o,a,i),[o,a]}function co(r){return z(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=or(),a=new xr(Yt(r,e,s),Yt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ih(){const r=Yt("root",0,"element"),e=Yt("root",0,"element");return new xr(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,h;if(V(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,h=e.focusOffset,a&&V(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,h,t,r);if(p===null)return null;const[g,m]=p;return new xr(g,m,V(r)?r.format:0,V(r)?r.style:"")}function le(){return or()._selection}function Zn(){return rt()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(l,c,"element"),i.set(l,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),h=u?s:i,p=h.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=h.offset;(t<=g&&n>0||t<g&&n<0)&&h.set(l,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!z(i))return;const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(z(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(z(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,ee(n)?(o=n.getTextContentSize(),a="text"):z(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,ee(s)?a="text":z(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function zh(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!V(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const h=e.anchor,p=e.focus,g=h.key,m=p.key,x=Is(t,g),_=Is(t,m),b=h.offset,S=p.offset,C=e.format,k=e.style,E=e.isCollapsed();let v=x,T=_,B=!1;if(h.type==="text"){v=Fs(x);const D=h.getNode();B=D.getFormat()!==C||D.getStyle()!==k}else V(r)&&r.anchor.type==="text"&&(B=!0);var j,N,R,M,w;if(p.type==="text"&&(T=Fs(_)),v!==null&&T!==null&&(E&&(r===null||B||V(r)&&(r.format!==C||r.style!==k))&&(j=C,N=k,R=b,M=g,w=performance.now(),Xu=[j,N,R,M,w]),u!==b||c!==S||a!==v||l!==T||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),h.type==="element"))){try{n.setBaseAndExtent(v,b,T,S)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const D=e instanceof xr&&e.anchor.type==="element"?v.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(D!==null){let F;if(D instanceof Text){const I=document.createRange();I.selectNode(D),F=I.getBoundingClientRect()}else F=D.getBoundingClientRect();(function(I,q,Z){const te=Z.ownerDocument,W=te.defaultView;if(W===null)return;let{top:Q,bottom:H}=q,ie=0,ue=0,de=Z;for(;de!==null;){const we=de===te.body;if(we)ie=0,ue=di(I).innerHeight;else{const Ce=de.getBoundingClientRect();ie=Ce.top,ue=Ce.bottom}let fe=0;if(Q<ie?fe=-(ie-Q):H>ue&&(fe=H-ue),fe!==0)if(we)W.scrollBy(0,fe);else{const Ce=de.scrollTop;de.scrollTop+=fe;const O=de.scrollTop-Ce;Q-=O,H-=O}if(we)break;de=Yn(de)}})(t,F,i)}}oo=!0}}function lc(r){let e=le()||Zn();e===null&&(e=Ze().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=le();V(t)&&(e=t),V(e)||G(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!ur(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=ot();return Ze().append(s),s.select(),[Ze(),0]}if(ee(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!z(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new xr(Yt(r.__key,e,"element"),Yt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let dt=null,ft=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||dt!==null&&dt._readOnly}function wt(){St&&G(13)}function uc(){ws>99&&G(14)}function or(){return dt===null&&G(195,cc()),dt}function rt(){return ft===null&&G(196,cc()),ft}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function $h(){return ft}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&G(30,l),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function qh(r){return ta(r,rt()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&G(17,t);const s=n.klass;r.type!==s.getType()&&G(18,s.name);const i=s.importJSON(r),o=r.children;if(z(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=dt,s=St,i=ft;dt=e,St=!0,ft=r;try{return t()}finally{dt=n,St=s,ft=i}}function hr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,a=t._selection,l=r._dirtyType!==Nr,u=dt,c=St,d=ft,h=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){ft=r,dt=t,St=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,T=r._dirtyLeaves;p.disconnect(),g=Ah(i,t,r,E,v,T)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,hr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=h,dt=u,St=c,ft=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,b=r._updateTags,S=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,v){const T=E._decorators;let B=E._pendingDecorators||T;const j=v._nodeMap;let N;for(N in B)j.has(N)||(B===T&&(B=Pu(E)),delete B[N])}(r,t);const C=s?null:Bt(r._window);if(r._editable&&C!==null&&(l||a===null||a.dirty)){ft=r,dt=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),zh(o,a,r,C,b,n)}vh(r,n,a),p!==null&&p.observe(n,sl)}finally{ft=d,dt=u}}g!==null&&function(E,v,T,B,j){const N=Array.from(E._listeners.mutation),R=N.length;for(let M=0;M<R;M++){const[w,D]=N[M],F=v.get(D);F!==void 0&&w(F,{dirtyLeaves:B,prevEditorState:j,updateTags:T})}}(r,g,b,m,i),V(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const k=r._pendingDecorators;k!==null&&(r._decorators=k,r._pendingDecorators=null,jn("decorator",r,!0,k)),function(E,v,T){const B=Ma(v),j=Ma(T);B!==j&&jn("textcontent",E,!0,j)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:b}),function(E,v){if(E._deferred=[],v.length!==0){const T=E._updating;E._updating=!0;try{for(let B=0;B<v.length;B++)v[B]()}finally{E._updating=T}}}(r,S),function(E){const v=E._updates;if(v.length!==0){const T=v.shift();if(T){const[B,j]=T;hc(E,B,j)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||ft!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&G(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=dt,d=St,h=ft,p=r._updating;dt=l,St=!1,r._updating=!0,ft=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(_){const b=_.getEditorState()._selection,S=Bt(_._window);return V(b)||b==null?ea(b,S,_,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(_,b){const S=b.getEditorState()._selection,C=_._selection;if(V(C)){const k=C.anchor,E=C.focus;let v;if(k.type==="text"&&(v=k.getNode(),v.selectionTransform(S,C)),E.type==="text"){const T=E.getNode();v!==T&&T.selectionTransform(S,C)}}}(l,r),r._dirtyType!==Nr&&(i?function(_,b){const S=b._dirtyLeaves,C=_._nodeMap;for(const k of S){const E=C.get(k);ee(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(l,r):function(_,b){const S=b._dirtyLeaves,C=b._dirtyElements,k=_._nodeMap,E=fr(),v=new Map;let T=S,B=T.size,j=C,N=j.size;for(;B>0||N>0;){if(B>0){b._dirtyLeaves=new Set;for(const R of T){const M=k.get(R);ee(M)&&M.isAttached()&&M.isSimpleText()&&!M.isUnmergeable()&&Ba(M),M!==void 0&&ol(M,E)&&il(b,M,v),S.add(R)}if(T=b._dirtyLeaves,B=T.size,B>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const R of j){const M=R[0],w=R[1];if(M!=="root"&&!w)continue;const D=k.get(M);D!==void 0&&ol(D,E)&&il(b,D,v),C.set(M,w)}T=b._dirtyLeaves,B=T.size,j=b._dirtyElements,N=j.size,ws++}b._dirtyLeaves=S,b._dirtyElements=C}(l,r),ll(r),function(_,b,S,C){const k=_._nodeMap,E=b._nodeMap,v=[];for(const[T]of C){const B=E.get(T);B!==void 0&&(B.isAttached()||(z(B)&&Uu(B,T,k,E,v,C),k.has(T)||C.delete(T),v.push(T)))}for(const T of v)E.delete(T);for(const T of S){const B=E.get(T);B===void 0||B.isAttached()||(k.has(T)||S.delete(T),E.delete(T))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(V(x)){const _=l._nodeMap,b=x.anchor.key,S=x.focus.key;_.get(b)!==void 0&&_.get(S)!==void 0||G(19)}else Ut(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void hr(r)}finally{dt=c,St=d,ft=h,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(_))return!0}else if(_!==null)return!0;return!1}(l,r)?l._flushSync?(l._flushSync=!1,hr(r)):u&&ph(()=>{hr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Dt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&G(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&G(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&G(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&G(225),t.reverse()}class ar extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return sh[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=rt()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(ee(t)&&e.push(t),z(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;z(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;z(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return z(i)&&i.getLastDescendant()||i||null}const s=t[e];return z(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:pt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&G(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:pt(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&G(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),z(i)&&s!==n-1&&!i.isInline()&&(e+=nr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),z(i)&&s!==n-1&&!i.isInline()&&(e+=nr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){wt();const n=le();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(ee(l)||z(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(ee(l)||z(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return V(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||G(226,String(e),String(t),String(i));const a=o.__key,l=[],u=[],c=this.getChildAtIndex(e+t);let d=null,h=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&G(100);const x=g.getNextSibling(),_=g.__key;Dr(g.getWritable()),u.push(_),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===a&&h--,Dr(x);const _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const b=p.getWritable();b.__next=_,x.__prev=b.__key}m.__key===a&&G(76),x.__parent=a,l.push(_),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=h,u.length){const g=le();if(V(g)){const m=new Set(u),x=new Set(l),{anchor:_,focus:b}=g;cl(_,m,x)&&Hs(_,_.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),h!==0||this.canBeEmpty()||Kt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function z(r){return r instanceof ar}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){G(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ve(r){return r instanceof ra}class ts extends ar{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){G(51)}getTextContent(){const e=this.__cachedText;return!es()&&rt()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){G(52)}replace(e){G(53)}insertBefore(e){G(54)}insertAfter(e){G(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];z(n)||Ve(n)||G(56)}return super.append(...e)}static importJSON(e){const t=Ze();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&G(130,t.name),z(r)){const n=e.children;Array.isArray(n)||G(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Ze())}))}}class sa extends ar{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends ar{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Uh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ot();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=ot();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||ee(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function Uh(r){const e=ot();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function ot(){return Qt(new on)}function tn(r){return r instanceof on}const Ue=0,Vr=1,Wh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Hh(r){const e=r||{},t=$h(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:Ou()),l=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,h=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],_=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,b=E.withKlass||null}const S=x.getType(),C=x.transform(),k=new Set;C!==null&&k.add(C),p.set(S,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:b,transforms:k})}}const g=new mi(o,s,p,{disableEvents:i,namespace:a,theme:n},c||console.error,function(m,x){const _=new Map,b=new Set,S=C=>{Object.keys(C).forEach(k=>{let E=_.get(k);E===void 0&&(E=[],_.set(k,E)),E.push(C[k])})};return m.forEach(C=>{const k=C.klass.importDOM;if(k==null||b.has(k))return;b.add(k);const E=k.call(C.klass);E!==null&&S(E)}),x&&S(x),_}(p,d?d.import:void 0),h);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,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=Ou(),this._onError=i,this._htmlConversions=o,this._editable=a,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&G(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&G(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&G(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Sh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),Dt(o,()=>{const l=or();if(l.isEmpty())return;if(a==="root")return void Ze().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return oe(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Th(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),hr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let h=0;h<io.length;h++){const[p,g]=io[h],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const _=l.isEditable();switch(p){case"cut":return _&&oe(l,Ro,x);case"copy":return oe(l,ii,x);case"paste":return _&&oe(l,si,x);case"dragstart":return _&&oe(l,Su,x);case"dragover":return _&&oe(l,ku,x);case"dragend":return _&&oe(l,$f,x);case"focus":return _&&oe(l,Wf,x);case"blur":return _&&oe(l,Hf,x);case"drop":return _&&oe(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&G(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),hr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||hr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),a=dt,l=St,u=ft,c=s._dirtyElements,d=s._dirtyLeaves,h=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,dt=o,St=!1,ft=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=h,s._dirtyType=p,dt=a,St=l,ft=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return hr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Dt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Dt(this,()=>{const s=le(),i=Ze();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Gh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Bf(null,n),c=Hh({editable:r.editable,html:l,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,h){if(h!==null){if(h===void 0)d.update(()=>{const p=Ze();if(p.isEmpty()){const g=ot();p.append(g);const m=yc?document.activeElement:null;(le()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(h!==null)switch(typeof h){case"string":{const p=d.parseEditorState(h);d.setEditorState(p,ds);break}case"object":d.setEditorState(h,ds);break;case"function":d.update(()=>{Ze().isEmpty()&&h(d)},ds)}}}(c,a),[c,u]},[]);return Vh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),f.jsx(pu.Provider,{value:t,children:e})}const Kh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Yh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Qh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Kh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Yh)}function Jh(){return Ze().getTextContent()}function Xh(r,e=!0){if(r)return!1;let t=Jh();return e&&(t=t.trim()),t===""}function Zh(r){if(!Xh(r,!1))return!1;const e=Ze().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ve(s))return!1;if(z(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!ee(l))return!1}}}return!0}function xc(r){return()=>Zh(r)}function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rp=tp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const np=new Map;function sp(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),h=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);let m,x=0;return h?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function ip(r){const e=r.getStyle(),t=sp(e);np.set(e,t)}function op(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ze(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;z(a)||rp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return Ve(t)&&!t.isIsolated()||z(t)&&!t.isInline()&&!t.canBeEmpty()}function ap(r,e,t,n){r.modify(e?"extend":"move",t,n)}function lp(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=lp(r);ap(r,e,t?!n:n,"character")}function hl(r){if(Ve(r)||!z(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cp=up(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,dp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||dp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function fp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function hp(r){const e=yi(r,t=>z(t)&&!t.isInline());return z(e)||cp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ze()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function pr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function pp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,h,p,g]=l;r.update(()=>{const m=le();if(V(m)){const x=m.anchor;let _=x.getNode(),b=0,S=0;if(ee(_)&&u>=0&&c>=0&&(b=u,S=u+c,m.setTextNodeRange(_,b,_,S)),b===S&&d===""||(m.insertRawText(d),_=x.getNode()),ee(_)){b=h,S=h+p;const C=_.getTextContentSize();b=b>C?C:b,S=S>C?C:S,m.setTextNodeRange(_,b,_,S)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Ze().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=z(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=ee(p)&&n!==null?bc(n,p):p,o=p}const a=z(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const h=document.createDocumentFragment();for(let p=0;p<a.length;p++){const g=a[p],m=kc(r,g,h,n);!s&&z(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((ir(c)||Oa(c))&&c.append(h),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(h);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let b=null;if(_!==void 0)for(const S of _){const C=S(g);C!==null&&(b===null||(b.priority||0)<=(C.priority||0))&&(b=C)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let h=[];const p=(a==null||!Kt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)h.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(h=c(h)),zs(r)&&(h=gp(r,h,p?()=>{const g=new sa;return t.push(g),g}:ot)),a==null?h.length>0?o=o.concat(h):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):z(a)&&a.append(...h),o}function gp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function mp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=mp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function yp(r,e=le()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function xp(r,e=le()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(bp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,vp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(V(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=le();if(V(l)){const u=o[a];u===`
|
|
94
94
|
`||u===`\r
|
|
95
|
-
`?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(jf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=$(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=ee(u)&&e!==null?bc(e,u):u,o=u}const a=$(o)?o.getChildren():[],l=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),$(u)){const h=c.children;Array.isArray(h)||Vs(59,d.name)}return c}(o);if(ee(o)){const u=o.__text;u.length>0?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&$(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function bp(r,e){const t=[],n=Ze().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function vp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=qh(n);ee(s)&&ip(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(pr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Wh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const a=ae();if(a===null)return!1;t=wp(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(Cp(n,t),!0)}const _p=[["text/html",yp],["application/x-lexical-editor",xp]];function wp(r=ae()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=wh();for(const[n,s]of _p){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function Cp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Sp=an&&"documentMode"in document?document.documentMode:null,kp=!(!an||!("InputEvent"in window)||Sp)&&"getTargetRanges"in new window.InputEvent("input"),Ep=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ap=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Dp,vl=Hn();class xi extends ar{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Tp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ia();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=ot(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=ot();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Qt(new xi)}class bi extends ar{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?ot():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=ot();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?ot():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Tp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Qt(new bi(r))}function fs(r){let e=null;if(pr(r,DragEvent)?e=r.dataTransfer:pr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=ae();if(!V(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const a=yi(i,u=>$(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return Ge(e)}function Np(r){return Pr(r.registerCommand(gu,e=>{const t=ae();return!!Ut(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ae();return!!V(t)&&(t.deleteCharacter(e),!0)},We),r.registerCommand(Fn,e=>{const t=ae();return!!V(t)&&(t.deleteWord(e),!0)},We),r.registerCommand(Ln,e=>{const t=ae();return!!V(t)&&(t.deleteLine(e),!0)},We),r.registerCommand(Yr,e=>{const t=ae();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(V(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},We),r.registerCommand(Ki,()=>{const e=ae();return!!V(e)&&(e.removeText(),!0)},We),r.registerCommand(Pt,e=>{const t=ae();return!!V(t)&&(t.formatText(e),!0)},We),r.registerCommand(Of,e=>{const t=ae();if(!V(t)&&!Ut(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>$(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},We),r.registerCommand(Kr,e=>{const t=ae();return!!V(t)&&(t.insertLineBreak(e),!0)},We),r.registerCommand(Rn,()=>{const e=ae();return!!V(e)&&(e.insertParagraph(),!0)},We),r.registerCommand(If,()=>(lc([Xn()]),!0),We),r.registerCommand(zf,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),We),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),We),r.registerCommand(xu,e=>{const t=ae();if(Ut(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(V(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},We),r.registerCommand(bu,e=>{const t=ae();if(Ut(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(V(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ze().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},We),r.registerCommand(yu,e=>{const t=ae();if(Ut(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!V(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},We),r.registerCommand(mu,e=>{const t=ae();if(Ut(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!V(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},We),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ae();if(!V(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&hp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},We),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ae();return!!V(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},We),r.registerCommand(Ns,e=>{const t=ae();if(!V(t))return!1;if(e!==null){if((bl||Ep||Ap)&&kp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},We),r.registerCommand(_u,()=>{const e=ae();return!!V(e)&&(r.blur(),!0)},We),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ih();if(ee(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Gt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ae();return!!V(n)},We),r.registerCommand(Su,e=>{const[t]=fs(e),n=ae();return!(t&&!V(n))},We),r.registerCommand(ku,e=>{const[t]=fs(e),n=ae();if(t&&!V(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ge(i)&&e.preventDefault()}return!0},We),r.registerCommand(Yi,()=>(xh(),!0),We),r.registerCommand(ii,e=>(ml(r,pr(e,ClipboardEvent)?e:null),!0),We),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,pr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ae();V(s)?s.removeText():Ut(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),We),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ae()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ae(),a=pr(s,InputEvent)||pr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},We))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Bp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const h=c[d],p=f.jsx(o,{onError:m=>i._onError(m),children:f.jsx(y.Suspense,{fallback:null,children:a[h]})}),g=i.getElementByKey(h);g!==null&&u.push(ma.createPortal(p,g,h))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Np(i),pp(i)),[i])}(n),f.jsxs(f.Fragment,{children:[r,f.jsx(jp,{content:e}),s]})}function jp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Qh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Mp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:h,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:_=!0,style:b,tabIndex:S,"data-testid":C,...k},E){const[v,T]=y.useState(r.isEditable()),B=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),j=y.useMemo(()=>function(...N){return R=>{N.forEach(M=>{typeof M=="function"?M(R):M!=null&&(M.current=R)})}}(E,B),[B,E]);return Tc(()=>(T(r.isEditable()),r.registerEditableListener(N=>{T(N)})),[r]),f.jsx("div",{"aria-activedescendant":v?e:void 0,"aria-autocomplete":v?t:"none","aria-controls":v?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":v&&x==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":c,"aria-owns":v?d:void 0,"aria-readonly":!v||void 0,"aria-required":h,autoCapitalize:p,className:g,contentEditable:v,"data-testid":C,id:m,ref:j,role:v?x:void 0,spellCheck:_,style:b,tabIndex:S,...k})}const Rp=y.forwardRef(Mp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Fp=y.forwardRef(Lp);function Lp(r,e){const{placeholder:t,...n}=r,[s]=zt();return f.jsxs(f.Fragment,{children:[f.jsx(Rp,{editor:s,...n,ref:e}),t!=null&&f.jsx(Pp,{editor:s,content:t})]})}function Pp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:f.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Rt=0,Ip=1,kl=2,zp=3,Op=4;function $p(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Rt;const i=e._selection,o=r._selection;if(s)return Ip;if(!(V(i)&&V(o)&&o.isCollapsed()&&i.isCollapsed()))return Rt;const a=function(_,b,S){const C=_._nodeMap,k=[];for(const E of b){const v=C.get(E);v!==void 0&&k.push(v)}for(const[E,v]of S){if(!v)continue;const T=C.get(E);T===void 0||yt(T)||k.push(T)}return k}(e,t,n);if(a.length===0)return Rt;if(a.length>1){const _=e._nodeMap,b=_.get(i.anchor.key),S=_.get(o.anchor.key);return b&&S&&!r._nodeMap.has(b.__key)&&ee(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Rt}const l=a[0],u=r._nodeMap.get(l.__key);if(!ee(u)||!ee(l)||u.__mode!==l.__mode)return Rt;const c=u.__text,d=l.__text;if(c===d)return Rt;const h=i.anchor,p=o.anchor;if(h.key!==p.key||h.type!=="text")return Rt;const g=h.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?zp:x===-1&&m===g?Op:Rt}function qp(r,e){let t=Date.now(),n=Rt;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Rt,t=c,po;const d=$p(s,i,a,l,r.isComposing()),h=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return a.size>0||l.size>0?g===!1&&d!==Rt&&d===n&&c<t+e&&p||a.size===1&&function(x,_,b){const S=_._nodeMap.get(x),C=b._nodeMap.get(x),k=_._selection,E=b._selection;return!(V(k)&&V(E)&&k.anchor.type==="element"&&k.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!ee(S)||!ee(C)||S.__parent!==C.__parent)&&JSON.stringify(_.read(()=>S.exportJSON()))===JSON.stringify(b.read(()=>C.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,h}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function Up(r,e,t){const n=qp(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(qf,()=>(El(e),!1),We),r.registerCommand(Uf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),We),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,tags:u})=>{const c=e.current,d=e.redoStack,h=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,a,l,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(h.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Wp(){return{current:null,redoStack:[],undoStack:[]}}function Hp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Wp(),[s]);y.useEffect(()=>Up(n,o,i),[i,n,o])}(t,e,r),null}const Vp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Gp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Vp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Kp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),h=0;h<c;h++)d[h]=arguments[h];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,u,c,d=this.state.error,h=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=h)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,h),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Yp({children:r,onError:e}){return f.jsx(Kp,{fallback:f.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Qp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wt=Qp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Jp(r){let e=1,t=r.getParent();for(;t!=null;){if(tt(t)){const n=t.getParent();if($e(n)){e++,t=n.getParent();continue}Wt(40)}return e}return e}function mo(r){let e=r.getParent();$e(e)||Wt(40);let t=e;for(;t!==null;)t=t.getParent(),$e(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(tt);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();$e(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Ht(r){return tt(r)&&$e(r.getFirstChild())}function Al(r){return At().append(r)}function Bc(r,e){return tt(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ae();if(t!==null){const n=t.getNodes();if(V(t)){const i=t.getStartEndPoints();i===null&&Wt(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=kt(e);if(Kt(l)){a.replace(u);const c=At();$(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(tt(a)){const c=a.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!$(o)||!o.isEmpty()||tt(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if($e(a)){if(!s.has(l)){const u=kt(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Kt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if($e(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=At();let i;if(Rr(s,r.getChildren()),$e(t)&&e===t.getListType())t.append(s),$e(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if($e(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Xp(r){r.update(()=>{const e=ae();if(V(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=fp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=ot();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Zp(r){const e=new Set;if(Ht(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Ht(n)&&Ht(s)){const i=s.getFirstChild();if($e(i)){i.append(r);const o=n.getFirstChild();$e(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Ht(n)){const i=n.getFirstChild();if($e(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Ht(s)){const i=s.getFirstChild();$e(i)&&i.append(r)}else if($e(t)){const i=At(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function eg(r){if(Ht(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if($e(t?t.getParent():void 0)&&tt(t)&&$e(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=At(),a=kt(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=At(),u=kt(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function tg(){const r=ae();if(!V(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!tt(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();$e(n)||Wt(40);const s=n.getParent();let i;if(Kt(s))i=ot(),t.insertAfter(i);else{if(!tt(s))return!1;i=At(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const a=kt(n.getListType());if(tn(i))i.insertAfter(a);else{const l=At();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!tt(l)&&!$e(l))break;l=u}l.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends ar{static getType(){return"listitem"}static clone(e){return new Ir(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return $e(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return $e(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(tt(e)||Wt(144),e.__checked==null)return;const t=e.getParent();$e(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:rg,priority:0})}}static importJSON(e){const t=At();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if($(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(tt(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!$e(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&($(e)||Wt(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if($e(n)||Wt(39),tt(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=At(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=ot();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=tt(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return $e(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;tt(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Wt(117),(e=Math.floor(e))>=0||Wt(199);let t=this.getIndent();for(;t!==e;)t<e?(Zp(this),t++):(eg(this),t--);return this}canInsertAfter(e){return tt(e)}canReplaceWith(e){return tt(e)}canMergeWith(e){return tn(e)||tt(e)}extractWithChild(e,t){if(!V(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return kt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=$e(l)&&l.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(a!==void 0){const l=Gs(a);t.getChildren().some(u=>$e(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){$e(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function rg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return ng(t)}const e=r.getAttribute("aria-checked");return{node:At(e==="true"||e!=="false"&&void 0)}}function ng(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:At(r.hasAttribute("checked"))}}function At(r){return Qt(new Ir(void 0,r))}function tt(r){return r instanceof Ir}class ln extends ar{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{$e(e)||Wt(163),function(t){const n=t.getNextSibling();$e(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())tt(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),$e(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&ir(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(tt(n))super.append(n);else{const s=At();if($e(n))s.append(n);else if($(n))if(n.isInline())s.append(n);else{const i=lt(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return tt(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Jp(t)-1,l=a%o.length,u=o[l],c=i[t.__tag];let d;const h=i.nested,p=i.checklist;if(h!==void 0&&h.list&&(d=h.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function sg(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(tt(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{$e(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(ir(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?kt("check"):kt("bullet")),{after:sg,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Qt(new ln(r,e))}function $e(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),ig=Hn();function og(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(ig,()=>(Xp(r),!0),Vr),r.registerCommand(Rn,()=>!!tg(),Vr))}function ag(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>og(e),[e])}(r),null}const lg=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends ar{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,a=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ug,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!lg.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!V(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ug(r){let e=null;if(_h(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Qt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ns(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if($(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Qt(new ns(r,e))}function cg(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ae();if(!V(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!cg(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.remove()}});else{if(o.length===1){const u=function(c,d){let h=c;for(;h!==null&&h.getParent()!==null&&!d(h);)h=h.getParentOrThrow();return d(h)?h:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!$(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let h=0;h<d.length;h++)l.append(d[h])}u.remove()}else l!==null&&l.append(u)}})}}function dg({validateUrl:r,attributes:e}){const[t]=zt();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ae();if(!V(s)||s.isCollapsed()||!pr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(a=>$(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function fg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function hg({src:r,alt:e,width:t,height:n}){return f.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:fg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(hg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var pg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?pg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
|
|
95
|
+
`?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(jf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=z(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=ee(u)&&e!==null?bc(e,u):u,o=u}const a=z(o)?o.getChildren():[],l=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),z(u)){const h=c.children;Array.isArray(h)||Vs(59,d.name)}return c}(o);if(ee(o)){const u=o.__text;u.length>0?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&z(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function bp(r,e){const t=[],n=Ze().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function vp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=qh(n);ee(s)&&ip(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(pr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Wh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const a=le();if(a===null)return!1;t=wp(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(Cp(n,t),!0)}const _p=[["text/html",yp],["application/x-lexical-editor",xp]];function wp(r=le()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=wh();for(const[n,s]of _p){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function Cp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Sp=an&&"documentMode"in document?document.documentMode:null,kp=!(!an||!("InputEvent"in window)||Sp)&&"getTargetRanges"in new window.InputEvent("input"),Ep=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ap=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Dp,vl=Hn();class xi extends ar{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Tp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ia();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=ot(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=ot();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Qt(new xi)}class bi extends ar{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?ot():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=ot();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?ot():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Tp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Qt(new bi(r))}function fs(r){let e=null;if(pr(r,DragEvent)?e=r.dataTransfer:pr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=le();if(!V(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const a=yi(i,u=>z(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return Ve(e)}function Np(r){return Pr(r.registerCommand(gu,e=>{const t=le();return!!Ut(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=le();return!!V(t)&&(t.deleteCharacter(e),!0)},Ue),r.registerCommand(Fn,e=>{const t=le();return!!V(t)&&(t.deleteWord(e),!0)},Ue),r.registerCommand(Ln,e=>{const t=le();return!!V(t)&&(t.deleteLine(e),!0)},Ue),r.registerCommand(Yr,e=>{const t=le();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(V(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Ue),r.registerCommand(Ki,()=>{const e=le();return!!V(e)&&(e.removeText(),!0)},Ue),r.registerCommand(Pt,e=>{const t=le();return!!V(t)&&(t.formatText(e),!0)},Ue),r.registerCommand(Of,e=>{const t=le();if(!V(t)&&!Ut(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>z(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Ue),r.registerCommand(Kr,e=>{const t=le();return!!V(t)&&(t.insertLineBreak(e),!0)},Ue),r.registerCommand(Rn,()=>{const e=le();return!!V(e)&&(e.insertParagraph(),!0)},Ue),r.registerCommand(If,()=>(lc([Xn()]),!0),Ue),r.registerCommand(zf,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Ue),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Ue),r.registerCommand(xu,e=>{const t=le();if(Ut(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(V(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ve(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Ue),r.registerCommand(bu,e=>{const t=le();if(Ut(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(V(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ze().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ve(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Ue),r.registerCommand(yu,e=>{const t=le();if(Ut(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!V(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Ue),r.registerCommand(mu,e=>{const t=le();if(Ut(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!V(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Ue),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=le();if(!V(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&hp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Ue),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=le();return!!V(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Ue),r.registerCommand(Ns,e=>{const t=le();if(!V(t))return!1;if(e!==null){if((bl||Ep||Ap)&&kp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Ue),r.registerCommand(_u,()=>{const e=le();return!!V(e)&&(r.blur(),!0)},Ue),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ih();if(ee(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Gt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=le();return!!V(n)},Ue),r.registerCommand(Su,e=>{const[t]=fs(e),n=le();return!(t&&!V(n))},Ue),r.registerCommand(ku,e=>{const[t]=fs(e),n=le();if(t&&!V(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ve(i)&&e.preventDefault()}return!0},Ue),r.registerCommand(Yi,()=>(xh(),!0),Ue),r.registerCommand(ii,e=>(ml(r,pr(e,ClipboardEvent)?e:null),!0),Ue),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,pr(t,ClipboardEvent)?t:null),n.update(()=>{const s=le();V(s)?s.removeText():Ut(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Ue),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:le()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=le(),a=pr(s,InputEvent)||pr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},Ue))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Bp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const h=c[d],p=f.jsx(o,{onError:m=>i._onError(m),children:f.jsx(y.Suspense,{fallback:null,children:a[h]})}),g=i.getElementByKey(h);g!==null&&u.push(ma.createPortal(p,g,h))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Np(i),pp(i)),[i])}(n),f.jsxs(f.Fragment,{children:[r,f.jsx(jp,{content:e}),s]})}function jp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Qh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Mp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:h,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:_=!0,style:b,tabIndex:S,"data-testid":C,...k},E){const[v,T]=y.useState(r.isEditable()),B=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),j=y.useMemo(()=>function(...N){return R=>{N.forEach(M=>{typeof M=="function"?M(R):M!=null&&(M.current=R)})}}(E,B),[B,E]);return Tc(()=>(T(r.isEditable()),r.registerEditableListener(N=>{T(N)})),[r]),f.jsx("div",{"aria-activedescendant":v?e:void 0,"aria-autocomplete":v?t:"none","aria-controls":v?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":v&&x==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":c,"aria-owns":v?d:void 0,"aria-readonly":!v||void 0,"aria-required":h,autoCapitalize:p,className:g,contentEditable:v,"data-testid":C,id:m,ref:j,role:v?x:void 0,spellCheck:_,style:b,tabIndex:S,...k})}const Rp=y.forwardRef(Mp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Fp=y.forwardRef(Lp);function Lp(r,e){const{placeholder:t,...n}=r,[s]=zt();return f.jsxs(f.Fragment,{children:[f.jsx(Rp,{editor:s,...n,ref:e}),t!=null&&f.jsx(Pp,{editor:s,content:t})]})}function Pp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:f.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Rt=0,Ip=1,kl=2,zp=3,Op=4;function $p(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Rt;const i=e._selection,o=r._selection;if(s)return Ip;if(!(V(i)&&V(o)&&o.isCollapsed()&&i.isCollapsed()))return Rt;const a=function(_,b,S){const C=_._nodeMap,k=[];for(const E of b){const v=C.get(E);v!==void 0&&k.push(v)}for(const[E,v]of S){if(!v)continue;const T=C.get(E);T===void 0||yt(T)||k.push(T)}return k}(e,t,n);if(a.length===0)return Rt;if(a.length>1){const _=e._nodeMap,b=_.get(i.anchor.key),S=_.get(o.anchor.key);return b&&S&&!r._nodeMap.has(b.__key)&&ee(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Rt}const l=a[0],u=r._nodeMap.get(l.__key);if(!ee(u)||!ee(l)||u.__mode!==l.__mode)return Rt;const c=u.__text,d=l.__text;if(c===d)return Rt;const h=i.anchor,p=o.anchor;if(h.key!==p.key||h.type!=="text")return Rt;const g=h.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?zp:x===-1&&m===g?Op:Rt}function qp(r,e){let t=Date.now(),n=Rt;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Rt,t=c,po;const d=$p(s,i,a,l,r.isComposing()),h=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return a.size>0||l.size>0?g===!1&&d!==Rt&&d===n&&c<t+e&&p||a.size===1&&function(x,_,b){const S=_._nodeMap.get(x),C=b._nodeMap.get(x),k=_._selection,E=b._selection;return!(V(k)&&V(E)&&k.anchor.type==="element"&&k.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!ee(S)||!ee(C)||S.__parent!==C.__parent)&&JSON.stringify(_.read(()=>S.exportJSON()))===JSON.stringify(b.read(()=>C.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,h}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function Up(r,e,t){const n=qp(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ue),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ue),r.registerCommand(qf,()=>(El(e),!1),Ue),r.registerCommand(Uf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Ue),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,tags:u})=>{const c=e.current,d=e.redoStack,h=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,a,l,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(h.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Wp(){return{current:null,redoStack:[],undoStack:[]}}function Hp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Wp(),[s]);y.useEffect(()=>Up(n,o,i),[i,n,o])}(t,e,r),null}const Vp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Gp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Vp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Kp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),h=0;h<c;h++)d[h]=arguments[h];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,u,c,d=this.state.error,h=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=h)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,h),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Yp({children:r,onError:e}){return f.jsx(Kp,{fallback:f.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Qp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wt=Qp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Jp(r){let e=1,t=r.getParent();for(;t!=null;){if(tt(t)){const n=t.getParent();if(Oe(n)){e++,t=n.getParent();continue}Wt(40)}return e}return e}function mo(r){let e=r.getParent();Oe(e)||Wt(40);let t=e;for(;t!==null;)t=t.getParent(),Oe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(tt);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Oe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Ht(r){return tt(r)&&Oe(r.getFirstChild())}function Al(r){return At().append(r)}function Bc(r,e){return tt(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=le();if(t!==null){const n=t.getNodes();if(V(t)){const i=t.getStartEndPoints();i===null&&Wt(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=kt(e);if(Kt(l)){a.replace(u);const c=At();z(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(tt(a)){const c=a.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!z(o)||!o.isEmpty()||tt(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if(Oe(a)){if(!s.has(l)){const u=kt(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Kt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Oe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=At();let i;if(Rr(s,r.getChildren()),Oe(t)&&e===t.getListType())t.append(s),Oe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Oe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Xp(r){r.update(()=>{const e=le();if(V(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=fp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=ot();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Zp(r){const e=new Set;if(Ht(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Ht(n)&&Ht(s)){const i=s.getFirstChild();if(Oe(i)){i.append(r);const o=n.getFirstChild();Oe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Ht(n)){const i=n.getFirstChild();if(Oe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Ht(s)){const i=s.getFirstChild();Oe(i)&&i.append(r)}else if(Oe(t)){const i=At(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function eg(r){if(Ht(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Oe(t?t.getParent():void 0)&&tt(t)&&Oe(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=At(),a=kt(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=At(),u=kt(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function tg(){const r=le();if(!V(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!tt(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Oe(n)||Wt(40);const s=n.getParent();let i;if(Kt(s))i=ot(),t.insertAfter(i);else{if(!tt(s))return!1;i=At(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const a=kt(n.getListType());if(tn(i))i.insertAfter(a);else{const l=At();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!tt(l)&&!Oe(l))break;l=u}l.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends ar{static getType(){return"listitem"}static clone(e){return new Ir(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Oe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Oe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(tt(e)||Wt(144),e.__checked==null)return;const t=e.getParent();Oe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:rg,priority:0})}}static importJSON(e){const t=At();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(z(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(tt(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Oe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(z(e)||Wt(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Oe(n)||Wt(39),tt(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=At(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=ot();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=tt(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Oe(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;tt(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Wt(117),(e=Math.floor(e))>=0||Wt(199);let t=this.getIndent();for(;t!==e;)t<e?(Zp(this),t++):(eg(this),t--);return this}canInsertAfter(e){return tt(e)}canReplaceWith(e){return tt(e)}canMergeWith(e){return tn(e)||tt(e)}extractWithChild(e,t){if(!V(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return kt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=Oe(l)&&l.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(a!==void 0){const l=Gs(a);t.getChildren().some(u=>Oe(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Oe(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function rg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return ng(t)}const e=r.getAttribute("aria-checked");return{node:At(e==="true"||e!=="false"&&void 0)}}function ng(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:At(r.hasAttribute("checked"))}}function At(r){return Qt(new Ir(void 0,r))}function tt(r){return r instanceof Ir}class ln extends ar{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Oe(e)||Wt(163),function(t){const n=t.getNextSibling();Oe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())tt(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Oe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&ir(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(tt(n))super.append(n);else{const s=At();if(Oe(n))s.append(n);else if(z(n))if(n.isInline())s.append(n);else{const i=lt(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return tt(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Jp(t)-1,l=a%o.length,u=o[l],c=i[t.__tag];let d;const h=i.nested,p=i.checklist;if(h!==void 0&&h.list&&(d=h.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function sg(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(tt(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Oe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(ir(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?kt("check"):kt("bullet")),{after:sg,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Qt(new ln(r,e))}function Oe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),ig=Hn();function og(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(ig,()=>(Xp(r),!0),Vr),r.registerCommand(Rn,()=>!!tg(),Vr))}function ag(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>og(e),[e])}(r),null}const lg=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends ar{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,a=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ug,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!lg.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!V(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ug(r){let e=null;if(_h(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Qt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ns(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(z(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Qt(new ns(r,e))}function cg(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=le();if(!V(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!cg(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.remove()}});else{if(o.length===1){const u=function(c,d){let h=c;for(;h!==null&&h.getParent()!==null&&!d(h);)h=h.getParentOrThrow();return d(h)?h:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!z(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let h=0;h<d.length;h++)l.append(d[h])}u.remove()}else l!==null&&l.append(u)}})}}function dg({validateUrl:r,attributes:e}){const[t]=zt();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=le();if(!V(s)||s.isCollapsed()||!pr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(a=>z(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function fg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function hg({src:r,alt:e,width:t,height:n}){return f.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:fg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(hg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var pg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?pg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
|
|
96
96
|
* @license QR Code generator library (TypeScript)
|
|
97
97
|
* Copyright (c) Project Nayuki.
|
|
98
98
|
* SPDX-License-Identifier: MIT
|
|
99
|
-
*/var Fr;(r=>{const e=class Ie{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<Ie.MIN_VERSION||l>Ie.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(l,u){const c=r.QrSegment.makeSegments(l);return Ie.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return Ie.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,h=-1,p=!0){if(!(Ie.MIN_VERSION<=c&&c<=d&&d<=Ie.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const S=Ie.getNumDataCodewords(g,u)*8,C=o.getTotalBits(l,g);if(C<=S){m=C;break}if(g>=d)throw new RangeError("Data too long")}for(const S of[Ie.Ecc.MEDIUM,Ie.Ecc.QUARTILE,Ie.Ecc.HIGH])p&&m<=Ie.getNumDataCodewords(g,S)*8&&(u=S);let x=[];for(const S of l){t(S.mode.modeBits,4,x),t(S.numChars,S.mode.numCharCountBits(g),x);for(const C of S.getData())x.push(C)}s(x.length==m);const _=Ie.getNumDataCodewords(g,u)*8;s(x.length<=_),t(0,Math.min(4,_-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let S=236;x.length<_;S^=253)t(S,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((S,C)=>b[C>>>3]|=S<<7-(C&7)),new Ie(g,u,b,h)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let c=u;for(let h=0;h<10;h++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,n(d,h));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,n(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,n(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,n(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),h=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(l,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(c)),p=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=Ie.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ie.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],h=Ie.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ie.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=Ie.reedSolomonComputeDivisor(h);for(let S=0,C=0;S<d;S++){let k=l.slice(C,C+m-h+(S<g?0:1));C+=k.length;const E=Ie.reedSolomonComputeRemainder(k,_);S<g&&k.push(0),x.push(k.concat(E))}let b=[];for(let S=0;S<x[0].length;S++)x.forEach((C,k)=>{(S!=m-h||k>=g)&&b.push(C[S])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(Ie.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=c-h,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(l){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?l+=Ie.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ie.PENALTY_N3),p=this.modules[h][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ie.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?l+=Ie.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ie.PENALTY_N3),p=this.modules[x][h],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ie.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(l+=Ie.PENALTY_N2)}let u=0;for(const h of this.modules)u=h.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),l+=d*Ie.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<Ie.MIN_VERSION||l>Ie.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(Ie.getNumRawDataModules(l)/8)-Ie.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*Ie.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let h=0;h<u.length;h++)u[h]=Ie.reedSolomonMultiply(u[h],c),h+1<u.length&&(u[h]^=u[h+1]);c=Ie.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const h=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ie.reedSolomonMultiply(p,h))}return c}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class et{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new et(et.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!et.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new et(et.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!et.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new et(et.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:et.isNumeric(l)?[et.makeNumeric(l)]:et.isAlphanumeric(l)?[et.makeAlphanumeric(l)]:[et.makeBytes(et.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,u)}static isNumeric(l){return et.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return et.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const h=d.mode.numCharCountBits(u);if(d.numChars>=1<<h)return 1/0;c+=4+h+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
|
|
99
|
+
*/var Fr;(r=>{const e=class ze{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<ze.MIN_VERSION||l>ze.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(l,u){const c=r.QrSegment.makeSegments(l);return ze.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return ze.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,h=-1,p=!0){if(!(ze.MIN_VERSION<=c&&c<=d&&d<=ze.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const S=ze.getNumDataCodewords(g,u)*8,C=o.getTotalBits(l,g);if(C<=S){m=C;break}if(g>=d)throw new RangeError("Data too long")}for(const S of[ze.Ecc.MEDIUM,ze.Ecc.QUARTILE,ze.Ecc.HIGH])p&&m<=ze.getNumDataCodewords(g,S)*8&&(u=S);let x=[];for(const S of l){t(S.mode.modeBits,4,x),t(S.numChars,S.mode.numCharCountBits(g),x);for(const C of S.getData())x.push(C)}s(x.length==m);const _=ze.getNumDataCodewords(g,u)*8;s(x.length<=_),t(0,Math.min(4,_-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let S=236;x.length<_;S^=253)t(S,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((S,C)=>b[C>>>3]|=S<<7-(C&7)),new ze(g,u,b,h)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let c=u;for(let h=0;h<10;h++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,n(d,h));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,n(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,n(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,n(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),h=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(l,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(c)),p=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=ze.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=ze.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],h=ze.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(ze.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=ze.reedSolomonComputeDivisor(h);for(let S=0,C=0;S<d;S++){let k=l.slice(C,C+m-h+(S<g?0:1));C+=k.length;const E=ze.reedSolomonComputeRemainder(k,_);S<g&&k.push(0),x.push(k.concat(E))}let b=[];for(let S=0;S<x[0].length;S++)x.forEach((C,k)=>{(S!=m-h||k>=g)&&b.push(C[S])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(ze.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=c-h,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(l){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?l+=ze.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*ze.PENALTY_N3),p=this.modules[h][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*ze.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?l+=ze.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*ze.PENALTY_N3),p=this.modules[x][h],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*ze.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(l+=ze.PENALTY_N2)}let u=0;for(const h of this.modules)u=h.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),l+=d*ze.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<ze.MIN_VERSION||l>ze.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(ze.getNumRawDataModules(l)/8)-ze.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*ze.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let h=0;h<u.length;h++)u[h]=ze.reedSolomonMultiply(u[h],c),h+1<u.length&&(u[h]^=u[h+1]);c=ze.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const h=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=ze.reedSolomonMultiply(p,h))}return c}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class et{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new et(et.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!et.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new et(et.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!et.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new et(et.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:et.isNumeric(l)?[et.makeNumeric(l)]:et.isAlphanumeric(l)?[et.makeAlphanumeric(l)]:[et.makeBytes(et.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,u)}static isNumeric(l){return et.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return et.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const h=d.mode.numCharCountBits(u);if(d.numChars>=1<<h)return 1/0;c+=4+h+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
|
|
100
100
|
* @license qrcode.react
|
|
101
101
|
* Copyright (c) Paul O'Shannessy
|
|
102
102
|
* SPDX-License-Identifier: ISC
|
|
103
|
-
*/var gg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",zc="#FFFFFF",Oc="#000000",$c=!1,qc=1,mg=4,yg=0,xg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,a){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===n.length-1){if(!o)return;i===null?t.push(`M${a+e},${s+e} h1v1H${a+e}z`):t.push(`M${i+e},${s+e} h${a+1-i}v1H${i+e}z`);return}o&&i===null&&(i=a)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function bg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*xg),o=s/e,a=(n.width||i)*o,l=(n.height||i)*o,u=n.x==null?r.length/2-a/2:n.x*o,c=n.y==null?r.length/2-l/2:n.y*o,d=n.opacity==null?1:n.opacity;let h=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(a+u-g),_=Math.ceil(l+c-m);h={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:l,w:a,excavation:h,opacity:d,crossOrigin:p}}function vg(r,e){return e!=null?Math.max(Math.floor(e),0):r?mg:yg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:a}){let l=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,gg[e],t,void 0,void 0,a)},[r,e,t,a]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:h}=y.useMemo(()=>{let p=l.getModules();const g=vg(n,s),m=p.length+g*2,x=bg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[l,o,i,n,s]);return{qrcode:l,margin:c,cells:u,numCells:d,calculatedImageSettings:h}}var _g=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),wg=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=zc,fgColor:l=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,marginSize:h,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),b=p==null?void 0:p.src,S=y.useRef(null),C=y.useRef(null),k=y.useCallback(w=>{S.current=w,typeof t=="function"?t(w):t&&(t.current=w)},[t]),[E,v]=y.useState(!1),{margin:T,cells:B,numCells:j,calculatedImageSettings:N}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:h,imageSettings:p,size:i});y.useEffect(()=>{if(S.current!=null){const w=S.current,D=w.getContext("2d");if(!D)return;let F=B;const
|
|
103
|
+
*/var gg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",zc="#FFFFFF",Oc="#000000",$c=!1,qc=1,mg=4,yg=0,xg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,a){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===n.length-1){if(!o)return;i===null?t.push(`M${a+e},${s+e} h1v1H${a+e}z`):t.push(`M${i+e},${s+e} h${a+1-i}v1H${i+e}z`);return}o&&i===null&&(i=a)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function bg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*xg),o=s/e,a=(n.width||i)*o,l=(n.height||i)*o,u=n.x==null?r.length/2-a/2:n.x*o,c=n.y==null?r.length/2-l/2:n.y*o,d=n.opacity==null?1:n.opacity;let h=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(a+u-g),_=Math.ceil(l+c-m);h={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:l,w:a,excavation:h,opacity:d,crossOrigin:p}}function vg(r,e){return e!=null?Math.max(Math.floor(e),0):r?mg:yg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:a}){let l=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,gg[e],t,void 0,void 0,a)},[r,e,t,a]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:h}=y.useMemo(()=>{let p=l.getModules();const g=vg(n,s),m=p.length+g*2,x=bg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[l,o,i,n,s]);return{qrcode:l,margin:c,cells:u,numCells:d,calculatedImageSettings:h}}var _g=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),wg=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=zc,fgColor:l=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,marginSize:h,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),b=p==null?void 0:p.src,S=y.useRef(null),C=y.useRef(null),k=y.useCallback(w=>{S.current=w,typeof t=="function"?t(w):t&&(t.current=w)},[t]),[E,v]=y.useState(!1),{margin:T,cells:B,numCells:j,calculatedImageSettings:N}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:h,imageSettings:p,size:i});y.useEffect(()=>{if(S.current!=null){const w=S.current,D=w.getContext("2d");if(!D)return;let F=B;const I=C.current,q=N!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;q&&N.excavation!=null&&(F=Wc(B,N.excavation));const Z=window.devicePixelRatio||1;w.height=w.width=i*Z;const te=i/j*Z;D.scale(te,te),D.fillStyle=a,D.fillRect(0,0,j,j),D.fillStyle=l,_g?D.fill(new Path2D(Uc(F,T))):B.forEach(function(W,Q){W.forEach(function(H,ie){H&&D.fillRect(ie+T,Q+T,1,1)})}),N&&(D.globalAlpha=N.opacity),q&&D.drawImage(I,N.x+T,N.y+T,N.w,N.h)}}),y.useEffect(()=>{v(!1)},[b]);const R=yo({height:i,width:i},x);let M=null;return b!=null&&(M=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{v(!0)},ref:C,crossOrigin:N==null?void 0:N.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:R,height:i,width:i,ref:k,role:"img"},_)),M)});wg.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=zc,fgColor:l=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,title:h,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:_,numCells:b,calculatedImageSettings:S}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let C=_,k=null;g!=null&&S!=null&&(S.excavation!=null&&(C=Wc(_,S.excavation)),k=y.createElement("image",{href:g.src,height:S.h,width:S.w,x:S.x+x,y:S.y+x,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const E=Uc(C,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!h&&y.createElement("title",null,h),y.createElement("path",{fill:a,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),k)});Vc.displayName="QRCodeSVG";function Cg(r){if(r instanceof HTMLElement&&r.dataset.qrcodeData){const e=r.dataset.qrcodeData,t=r.dataset.qrcodeSize?parseInt(r.dataset.qrcodeSize,10):void 0;return{node:aa({data:e,size:t})}}return null}function Sg({data:r,size:e=150}){return f.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:f.jsx(Vc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);_t(this,"__data");_t(this,"__size");this.__data=t,this.__size=n}static getType(){return"qrcode"}static clone(t){return new un(t.__data,t.__size,t.__key)}static importJSON(t){const{data:n,size:s}=t;return aa({data:n,size:s})}exportJSON(){return{type:"qrcode",version:1,data:this.__data,size:this.__size}}static importDOM(){return{div:t=>t.dataset.qrcodeData?{conversion:Cg,priority:1}:null}}exportDOM(){const t=document.createElement("div");return t.dataset.qrcodeData=this.__data,t.dataset.qrcodeSize=String(this.__size),t.style.display="inline-block",t.style.background="#f9f9f9",t.style.padding="12px",t.style.borderRadius="8px",t.textContent="[QR Code]",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(Sg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function aa(r){return new un(r.data,r.size)}function kg(r){return r instanceof un}const Eg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Dg={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function Ag({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:a,hasContent:l}){const[u]=zt(),[c,d]=y.useState(!1),h=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(Pt,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(Pt,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(Pt,"underline")},[u]),_=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),S=y.useCallback(()=>{u.update(()=>{const v=le();V(v)&&op(v,()=>ia())})},[u]),C={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},k=`
|
|
104
104
|
.mail-editor-toolbar-btn:hover:not(:disabled) {
|
|
105
105
|
background: ${r.border};
|
|
106
106
|
}
|
|
107
|
-
`,E=()=>{setTimeout(()=>{var v;(v=h.current)!=null&&v.contains(document.activeElement)||d(!1)},150)};return f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[f.jsx("style",{children:k}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:C,title:"Bold (Ctrl+B)",children:"B"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...C,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...C,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:C,title:"Bullet List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("circle",{cx:"4",cy:"6",r:"2"}),f.jsx("circle",{cx:"4",cy:"12",r:"2"}),f.jsx("circle",{cx:"4",cy:"18",r:"2"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:C,title:"Numbered List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),f.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),f.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:S,disabled:e,style:C,title:"Quote",children:f.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&f.jsxs("div",{style:{position:"relative"},ref:h,children:[f.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!l||e,onBlur:E,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!l?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!l||e?"not-allowed":"pointer",opacity:i||!l?.5:1},children:i?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&f.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Restructure"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Proofread"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Tg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ze();i.clear();const o=ot();i.append(o),o.select();const l=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,l).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Ng({text:r,trigger:e}){const[t]=zt(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=
|
|
108
|
-
`).map(
|
|
107
|
+
`,E=()=>{setTimeout(()=>{var v;(v=h.current)!=null&&v.contains(document.activeElement)||d(!1)},150)};return f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[f.jsx("style",{children:k}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:C,title:"Bold (Ctrl+B)",children:"B"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...C,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...C,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:C,title:"Bullet List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("circle",{cx:"4",cy:"6",r:"2"}),f.jsx("circle",{cx:"4",cy:"12",r:"2"}),f.jsx("circle",{cx:"4",cy:"18",r:"2"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:C,title:"Numbered List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),f.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),f.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:S,disabled:e,style:C,title:"Quote",children:f.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&f.jsxs("div",{style:{position:"relative"},ref:h,children:[f.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!l||e,onBlur:E,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!l?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!l||e?"not-allowed":"pointer",opacity:i||!l?.5:1},children:i?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&f.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Restructure"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Proofread"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Tg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ze();i.clear();const o=ot();i.append(o),o.select();const l=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,l).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Ng({text:r,trigger:e}){const[t]=zt(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=le();if(V(i))i.insertText(s);else{const o=Ze(),a=o.getLastChild();if(a){a.selectEnd();const l=le();V(l)&&l.insertText(s)}else{const l=ot(),u=lt(s);l.append(u),o.append(l)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Bg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return f.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[f.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),f.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Gc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:a="200px",externalUpdate:l,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const _={...Eg,...s},[b,S]=y.useState(!1),C=y.useRef(void 0),[k,E]=y.useState(r),[v,T]=y.useState(!1),[B,j]=y.useState(null),N=g??v,R=m??B;y.useEffect(()=>{l!==void 0&&l!==C.current&&(C.current=l,S(!0))},[l]);const M=y.useCallback(()=>{S(!1)},[]),w=W=>W.replace(/<[^>]*>/g,"").trim(),D=W=>W.split(`
|
|
108
|
+
`).map(Q=>`<p>${Q||"<br>"}</p>`).join(""),F=async W=>{const Q=w(k);if(!Q)return;const H=W==="restructure"?d:W==="proofread"?h:p;if(H){T(!0),j(W);try{const ie=await H(Q),ue=D(ie);E(ue),e==null||e(ue),C.current=Date.now(),S(!0)}catch(ie){console.error(`AI ${W} failed:`,ie)}finally{T(!1),j(null)}}},I=w(k).length>0,q={namespace:"MailEditor",theme:Dg,onError:W=>{console.error("Lexical error:",W)},nodes:[ln,Ir,zr,ns,bi,xi,vi,un],editable:!i},Z=y.useCallback((W,Q)=>{W.read(()=>{const H=Sc(Q,null);E(H),e==null||e(H)})},[e]),te=`
|
|
109
109
|
.mail-editor-paragraph {
|
|
110
110
|
margin: 0 0 8px 0;
|
|
111
111
|
line-height: 1.5;
|
|
@@ -175,14 +175,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
175
175
|
from { transform: rotate(0deg); }
|
|
176
176
|
to { transform: rotate(360deg); }
|
|
177
177
|
}
|
|
178
|
-
`;return f.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:a},children:[f.jsx("style",{children:te}),x,f.jsxs(Gh,{initialConfig:q,children:[f.jsx(Ag,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:N,aiProcessingAction:R,onAiAction:F,hasContent:z}),f.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Bp,{contentEditable:f.jsx(Fp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:f.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Yp})}),f.jsx(ag,{}),f.jsx(dg,{}),f.jsx(Hp,{}),f.jsx(Gp,{onChange:J}),f.jsx(Tg,{html:b?k:r,isExternalUpdate:b,onImportComplete:M}),f.jsx(Ng,{text:u,trigger:c})]}),n&&f.jsx(Bg,{replyTo:n,theme:_})]})}const jg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function Mg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:a,onBodyChange:l,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:h={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:_=!1,hideSubjectField:b=!1,minHeight:S="200px",hideCancelButton:C=!1,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,onAiGenerate:T,renderAboveToolbar:B,onPickContact:j,initialPrompt:N="",onPromptChange:R,initialAttachments:M,onAttachmentsChange:w}){const D={...jg,...h},[F,z]=y.useState(r),[q,J]=y.useState(e),[te,W]=y.useState(t),[G,H]=y.useState(n),[se,le]=y.useState(s),[ue,_e]=y.useState([]),[fe,De]=y.useState(M||[]),[O,Ce]=y.useState(!1),[re,Fe]=y.useState(""),[je,ye]=y.useState(g||!!e||!!t),[Se,Me]=y.useState("message"),[Oe,ge]=y.useState(N),[L,ze]=y.useState(!1),[Ke,X]=y.useState(!0),[Z,ce]=y.useState(!0);y.useEffect(()=>{z(r)},[r]),y.useEffect(()=>{J(e),e&&ye(!0)},[e]),y.useEffect(()=>{W(t),t&&ye(!0)},[t]),y.useEffect(()=>{ge(N)},[N]),y.useEffect(()=>{De(M||[])},[M]);const we=P=>{ge(P),R==null||R(P)},Be=async P=>new Promise((xe,ve)=>{const be=new FileReader;be.onload=()=>{const Ne=be.result.split(",")[1]||"";xe({filename:P.name,content_type:P.type||"application/octet-stream",data:Ne,size:P.size})},be.onerror=ve,be.readAsDataURL(P)}),Qe=async(P,xe)=>{if(!w)return;const ve=await Promise.all(P.map(Be));w([...xe,...ve])},[Et,oe]=y.useState(!1),pe=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==pe.current&&(pe.current=u,le(s),oe(!0))},[u,s]);const Ye=P=>{le(P),oe(!1),l==null||l(P)},at=y.useRef(null),[Ve,Xe]=y.useState(!1),br=P=>{const xe=P.target.files;if(xe){const ve=Array.from(xe);console.log("[MailComposer] Files selected:",ve.map(be=>({name:be.name,size:be.size,type:be.type}))),_e(be=>{const Ne=[...be,...ve];return Qe(Ne,fe),Ne})}at.current&&(at.current.value="")},Q=P=>{P.preventDefault(),P.stopPropagation(),Xe(!0)},I=P=>{P.preventDefault(),P.stopPropagation(),Xe(!1)},de=P=>{if(P.preventDefault(),P.stopPropagation(),Xe(!1),P.dataTransfer.files&&P.dataTransfer.files.length>0){const xe=Array.from(P.dataTransfer.files);console.log("[MailComposer] Files dropped:",xe.map(ve=>({name:ve.name,size:ve.size,type:ve.type}))),_e(ve=>{const be=[...ve,...xe];return Qe(be,fe),be})}else console.log("[MailComposer] Drop event but no files:",P.dataTransfer.types)},he=P=>P.type.startsWith("image/")?"image":P.type==="application/pdf"?"picture_as_pdf":P.type.includes("spreadsheet")||P.type.includes("excel")?"table_chart":P.type.includes("document")||P.type.includes("word")?"description":"attach_file",Y=P=>{_e(xe=>{const ve=xe.filter((be,Ne)=>Ne!==P);return Qe(ve,fe),ve})},Ae=P=>{De(xe=>{const ve=xe.filter((be,Ne)=>Ne!==P);return Qe(ue,ve),ve})},Ee=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,Te=async()=>{if(!F.trim()){Fe("Recipient email is required");return}if(!G.trim()){Fe("Subject is required");return}Ce(!0),Fe("");try{const P=await Promise.all(ue.map(async be=>{const Ne=await be.arrayBuffer(),st=btoa(new Uint8Array(Ne).reduce((ct,bt)=>ct+String.fromCharCode(bt),""));return{filename:be.name,content_type:be.type||"application/octet-stream",data:st,size:be.size}})),xe=se.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ve={to:F.trim(),cc:q.trim()||void 0,bcc:te.trim()||void 0,subject:G.trim(),html:xe,attachments:[...fe,...P],inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",ve.to,"subject:",ve.subject,"attachmentsCount:",ve.attachments.length),ve.attachments.length>0&&ve.attachments.forEach((be,Ne)=>{var st;console.log(`[MailComposer] Attachment ${Ne+1}:`,be.filename,"size:",be.size,"type:",be.content_type,"data length:",((st=be.data)==null?void 0:st.length)||0)}),await o(ve),z(""),J(""),W(""),H(""),le(""),_e([])}catch(P){Fe(P instanceof Error?P.message:"Failed to send email")}finally{Ce(!1)}},Le={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none"},He={display:"block",fontSize:"12px",fontWeight:500,color:D.textSecondary,marginBottom:"4px",textTransform:"uppercase"},ke=(P,xe=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:xe?"not-allowed":"pointer",opacity:xe?.6:1,background:P?D.buttonPrimary:D.buttonSecondary,color:P?"#ffffff":D.text,display:"flex",alignItems:"center",gap:"8px"});return f.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:D.background},children:[re&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:re}),!_&&f.jsxs("div",{children:[f.jsx("label",{style:He,children:"To"}),f.jsx("input",{type:"email",value:F,onChange:P=>z(P.target.value),placeholder:"recipient@example.com",disabled:p||O,style:Le})]}),!je&&f.jsx("button",{type:"button",onClick:()=>ye(!0),disabled:p||O,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:D.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),je&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{style:He,children:"CC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:q,onChange:P=>J(P.target.value),placeholder:"cc@example.com",disabled:p||O,style:{...Le,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const P=await j("cc");P&&J(xe=>xe?`${xe}, ${P}`:P)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]}),f.jsxs("div",{children:[f.jsx("label",{style:He,children:"BCC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:te,onChange:P=>W(P.target.value),placeholder:"bcc@example.com",disabled:p||O,style:{...Le,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const P=await j("bcc");P&&W(xe=>xe?`${xe}, ${P}`:P)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]})]}),!b&&f.jsxs("div",{children:[f.jsx("label",{style:He,children:"Subject"}),f.jsx("input",{type:"text",value:G,onChange:P=>H(P.target.value),placeholder:"Email subject",disabled:p||O,style:Le})]}),f.jsx("input",{ref:at,type:"file",multiple:!0,onChange:br,style:{display:"none"}}),f.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${D.border}`,marginBottom:"0"},children:[f.jsx("button",{type:"button",onClick:()=>Me("message"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="message"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="message"?D.primary:D.textSecondary,fontWeight:Se==="message"?600:400,cursor:p||O?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),f.jsxs("button",{type:"button",onClick:()=>Me("attachments"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="attachments"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="attachments"?D.primary:D.textSecondary,fontWeight:Se==="attachments"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",ue.length+fe.length>0&&f.jsx("span",{style:{background:D.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:ue.length+fe.length})]}),T&&f.jsx("button",{type:"button",onClick:()=>Me("prompt"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="prompt"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="prompt"?D.primary:D.textSecondary,fontWeight:Se==="prompt"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),Se==="message"&&f.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{type:"button",onClick:()=>{var P;return(P=at.current)==null?void 0:P.click()},disabled:p||O,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),f.jsx("button",{type:"button",onClick:Te,disabled:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?D.textSecondary:D.primary,cursor:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:O?"spin 1s linear infinite":"none"},children:O?"sync":"send"})})]})]}),Se==="message"&&f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Gc,{value:se,onChange:Ye,placeholder:m,replyTo:i,theme:D,disabled:p||O,minHeight:S,externalUpdate:Et?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,renderAboveToolbar:B})})}),Se==="attachments"&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[f.jsxs("div",{onClick:()=>{var P;return(P=at.current)==null?void 0:P.click()},onDragOver:Q,onDragLeave:I,onDrop:de,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Ve?D.primary:D.border}`,borderRadius:"8px",background:Ve?`${D.primary}10`:"transparent",color:Ve?D.primary:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Ve?"file_download":"cloud_upload"}),f.jsx("span",{style:{fontSize:"14px"},children:Ve?"Drop files here":"Drop files or click to add"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:ue.length+fe.length>0?f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[fe.map((P,xe)=>{var ve;return f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:(ve=P.content_type)!=null&&ve.startsWith("image/")?"image":P.content_type==="application/pdf"?"picture_as_pdf":"attach_file"}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.filename}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(P.size)})]}),f.jsx("button",{type:"button",onClick:()=>Ae(xe),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`saved-${P.filename}-${xe}`)}),ue.map((P,xe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:he(P)}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.name}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(P.size)})]}),f.jsx("button",{type:"button",onClick:()=>Y(xe),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${P.name}-${xe}`))]}):f.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:D.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),Se==="prompt"&&T&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[f.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:D.text},children:[f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Ke,onChange:P=>X(P.target.checked),disabled:p||O||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Z,onChange:P=>ce(P.target.checked),disabled:p||O||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),f.jsx("textarea",{value:Oe,onChange:P=>we(P.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||O||L,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none",resize:"none",minHeight:"150px"}}),f.jsxs("button",{type:"button",onClick:async()=>{if(!(!Oe.trim()||!T)){ze(!0);try{const P=await T(Oe,{to:F,subject:G},{useNotes:Ke,addSignature:Z});le(P),Me("message")}catch(P){console.error("AI generation failed:",P)}finally{ze(!1)}}},disabled:p||O||L||!Oe.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||O||L||!Oe.trim()?"not-allowed":"pointer",opacity:p||O||L||!Oe.trim()?.6:1,background:D.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:L?"spin 1s linear infinite":"none"},children:L?"sync":"auto_awesome"}),L?"Génération...":"Générer"]})]}),!C&&a&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{type:"button",onClick:a,disabled:p||O,style:ke(!1,p||O),children:"Cancel"})}),f.jsx("style",{children:`
|
|
178
|
+
`;return f.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:a},children:[f.jsx("style",{children:te}),x,f.jsxs(Gh,{initialConfig:q,children:[f.jsx(Ag,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:N,aiProcessingAction:R,onAiAction:F,hasContent:I}),f.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Bp,{contentEditable:f.jsx(Fp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:f.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Yp})}),f.jsx(ag,{}),f.jsx(dg,{}),f.jsx(Hp,{}),f.jsx(Gp,{onChange:Z}),f.jsx(Tg,{html:b?k:r,isExternalUpdate:b,onImportComplete:M}),f.jsx(Ng,{text:u,trigger:c})]}),n&&f.jsx(Bg,{replyTo:n,theme:_})]})}const jg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function Mg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:a,onBodyChange:l,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:h={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:_=!1,hideSubjectField:b=!1,minHeight:S="200px",hideCancelButton:C=!1,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,onAiGenerate:T,renderAboveToolbar:B,onPickContact:j,initialPrompt:N="",onPromptChange:R,initialAttachments:M,onAttachmentsChange:w}){const D={...jg,...h},[F,I]=y.useState(r),[q,Z]=y.useState(e),[te,W]=y.useState(t),[Q,H]=y.useState(n),[ie,ue]=y.useState(s),[de,we]=y.useState([]),[fe,Ce]=y.useState(M||[]),[O,je]=y.useState(!1),[re,Le]=y.useState(""),[Me,xe]=y.useState(g||!!e||!!t),[Se,Re]=y.useState("message"),[se,ce]=y.useState(N),[$,Ge]=y.useState(!1),[Ke,X]=y.useState(!0),[K,pe]=y.useState(!0);y.useEffect(()=>{I(r)},[r]),y.useEffect(()=>{Z(e),e&&xe(!0)},[e]),y.useEffect(()=>{W(t),t&&xe(!0)},[t]),y.useEffect(()=>{ce(N)},[N]),y.useEffect(()=>{Ce(M||[])},[M]);const De=L=>{ce(L),R==null||R(L)},Be=async L=>new Promise((be,_e)=>{const ve=new FileReader;ve.onload=()=>{const Ne=ve.result.split(",")[1]||"";be({filename:L.name,content_type:L.type||"application/octet-stream",data:Ne,size:L.size})},ve.onerror=_e,ve.readAsDataURL(L)}),Qe=async(L,be)=>{if(!w)return;const _e=await Promise.all(L.map(Be));w([...be,..._e])},[Et,ae]=y.useState(!1),me=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==me.current&&(me.current=u,ue(s),ae(!0))},[u,s]);const Ye=L=>{ue(L),ae(!1),l==null||l(L)},at=y.useRef(null),[He,Xe]=y.useState(!1),br=L=>{const be=L.target.files;if(be){const _e=Array.from(be);console.log("[MailComposer] Files selected:",_e.map(ve=>({name:ve.name,size:ve.size,type:ve.type}))),we(ve=>{const Ne=[...ve,..._e];return Qe(Ne,fe),Ne})}at.current&&(at.current.value="")},J=L=>{L.preventDefault(),L.stopPropagation(),Xe(!0)},P=L=>{L.preventDefault(),L.stopPropagation(),Xe(!1)},he=L=>{if(L.preventDefault(),L.stopPropagation(),Xe(!1),L.dataTransfer.files&&L.dataTransfer.files.length>0){const be=Array.from(L.dataTransfer.files);console.log("[MailComposer] Files dropped:",be.map(_e=>({name:_e.name,size:_e.size,type:_e.type}))),we(_e=>{const ve=[..._e,...be];return Qe(ve,fe),ve})}else console.log("[MailComposer] Drop event but no files:",L.dataTransfer.types)},ge=L=>L.type.startsWith("image/")?"image":L.type==="application/pdf"?"picture_as_pdf":L.type.includes("spreadsheet")||L.type.includes("excel")?"table_chart":L.type.includes("document")||L.type.includes("word")?"description":"attach_file",Y=L=>{we(be=>{const _e=be.filter((ve,Ne)=>Ne!==L);return Qe(_e,fe),_e})},Ae=L=>{Ce(be=>{const _e=be.filter((ve,Ne)=>Ne!==L);return Qe(de,_e),_e})},Ee=L=>L<1024?`${L} B`:L<1024*1024?`${(L/1024).toFixed(1)} KB`:`${(L/(1024*1024)).toFixed(1)} MB`,Te=async()=>{if(!F.trim()){Le("Recipient email is required");return}if(!Q.trim()){Le("Subject is required");return}je(!0),Le("");try{const L=await Promise.all(de.map(async ve=>{const Ne=await ve.arrayBuffer(),st=btoa(new Uint8Array(Ne).reduce((ct,bt)=>ct+String.fromCharCode(bt),""));return{filename:ve.name,content_type:ve.type||"application/octet-stream",data:st,size:ve.size}})),be=ie.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),_e={to:F.trim(),cc:q.trim()||void 0,bcc:te.trim()||void 0,subject:Q.trim(),html:be,attachments:[...fe,...L],inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",_e.to,"subject:",_e.subject,"attachmentsCount:",_e.attachments.length),_e.attachments.length>0&&_e.attachments.forEach((ve,Ne)=>{var st;console.log(`[MailComposer] Attachment ${Ne+1}:`,ve.filename,"size:",ve.size,"type:",ve.content_type,"data length:",((st=ve.data)==null?void 0:st.length)||0)}),await o(_e),I(""),Z(""),W(""),H(""),ue(""),we([])}catch(L){Le(L instanceof Error?L.message:"Failed to send email")}finally{je(!1)}},Pe={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none"},We={display:"block",fontSize:"12px",fontWeight:500,color:D.textSecondary,marginBottom:"4px",textTransform:"uppercase"},ke=(L,be=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:be?"not-allowed":"pointer",opacity:be?.6:1,background:L?D.buttonPrimary:D.buttonSecondary,color:L?"#ffffff":D.text,display:"flex",alignItems:"center",gap:"8px"});return f.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:D.background},children:[re&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:re}),!_&&f.jsxs("div",{children:[f.jsx("label",{style:We,children:"To"}),f.jsx("input",{type:"email",value:F,onChange:L=>I(L.target.value),placeholder:"recipient@example.com",disabled:p||O,style:Pe})]}),!Me&&f.jsx("button",{type:"button",onClick:()=>xe(!0),disabled:p||O,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:D.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),Me&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{style:We,children:"CC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:q,onChange:L=>Z(L.target.value),placeholder:"cc@example.com",disabled:p||O,style:{...Pe,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const L=await j("cc");L&&Z(be=>be?`${be}, ${L}`:L)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]}),f.jsxs("div",{children:[f.jsx("label",{style:We,children:"BCC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:te,onChange:L=>W(L.target.value),placeholder:"bcc@example.com",disabled:p||O,style:{...Pe,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const L=await j("bcc");L&&W(be=>be?`${be}, ${L}`:L)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]})]}),!b&&f.jsxs("div",{children:[f.jsx("label",{style:We,children:"Subject"}),f.jsx("input",{type:"text",value:Q,onChange:L=>H(L.target.value),placeholder:"Email subject",disabled:p||O,style:Pe})]}),f.jsx("input",{ref:at,type:"file",multiple:!0,onChange:br,style:{display:"none"}}),f.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${D.border}`,marginBottom:"0"},children:[f.jsx("button",{type:"button",onClick:()=>Re("message"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="message"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="message"?D.primary:D.textSecondary,fontWeight:Se==="message"?600:400,cursor:p||O?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),f.jsxs("button",{type:"button",onClick:()=>Re("attachments"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="attachments"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="attachments"?D.primary:D.textSecondary,fontWeight:Se==="attachments"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",de.length+fe.length>0&&f.jsx("span",{style:{background:D.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:de.length+fe.length})]}),T&&f.jsx("button",{type:"button",onClick:()=>Re("prompt"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="prompt"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="prompt"?D.primary:D.textSecondary,fontWeight:Se==="prompt"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),Se==="message"&&f.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{type:"button",onClick:()=>{var L;return(L=at.current)==null?void 0:L.click()},disabled:p||O,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),f.jsx("button",{type:"button",onClick:Te,disabled:p||O||!F.trim()||!Q.trim()||!ie.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||O||!F.trim()||!Q.trim()||!ie.replace(/<[^>]*>/g,"").trim()?D.textSecondary:D.primary,cursor:p||O||!F.trim()||!Q.trim()||!ie.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||O||!F.trim()||!Q.trim()||!ie.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:O?"spin 1s linear infinite":"none"},children:O?"sync":"send"})})]})]}),Se==="message"&&f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Gc,{value:ie,onChange:Ye,placeholder:m,replyTo:i,theme:D,disabled:p||O,minHeight:S,externalUpdate:Et?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,renderAboveToolbar:B})})}),Se==="attachments"&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[f.jsxs("div",{onClick:()=>{var L;return(L=at.current)==null?void 0:L.click()},onDragOver:J,onDragLeave:P,onDrop:he,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${He?D.primary:D.border}`,borderRadius:"8px",background:He?`${D.primary}10`:"transparent",color:He?D.primary:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:He?"file_download":"cloud_upload"}),f.jsx("span",{style:{fontSize:"14px"},children:He?"Drop files here":"Drop files or click to add"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:de.length+fe.length>0?f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[fe.map((L,be)=>{var _e;return f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:(_e=L.content_type)!=null&&_e.startsWith("image/")?"image":L.content_type==="application/pdf"?"picture_as_pdf":"attach_file"}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.filename}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(L.size)})]}),f.jsx("button",{type:"button",onClick:()=>Ae(be),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`saved-${L.filename}-${be}`)}),de.map((L,be)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:ge(L)}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.name}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(L.size)})]}),f.jsx("button",{type:"button",onClick:()=>Y(be),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${L.name}-${be}`))]}):f.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:D.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),Se==="prompt"&&T&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[f.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:D.text},children:[f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Ke,onChange:L=>X(L.target.checked),disabled:p||O||$,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:K,onChange:L=>pe(L.target.checked),disabled:p||O||$,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),f.jsx("textarea",{value:se,onChange:L=>De(L.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||O||$,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none",resize:"none",minHeight:"150px"}}),f.jsxs("button",{type:"button",onClick:async()=>{if(!(!se.trim()||!T)){Ge(!0);try{const L=await T(se,{to:F,subject:Q},{useNotes:Ke,addSignature:K});ue(L),Re("message")}catch(L){console.error("AI generation failed:",L)}finally{Ge(!1)}}},disabled:p||O||$||!se.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||O||$||!se.trim()?"not-allowed":"pointer",opacity:p||O||$||!se.trim()?.6:1,background:D.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:$?"spin 1s linear infinite":"none"},children:$?"sync":"auto_awesome"}),$?"Génération...":"Générer"]})]}),!C&&a&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{type:"button",onClick:a,disabled:p||O,style:ke(!1,p||O),children:"Cancel"})}),f.jsx("style",{children:`
|
|
179
179
|
@keyframes spin {
|
|
180
180
|
from { transform: rotate(0deg); }
|
|
181
181
|
to { transform: rotate(360deg); }
|
|
182
182
|
}
|
|
183
|
-
`})]})}const Rg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Fg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:h=""}){const p={...Rg,...d},[g,m]=y.useState(!1),[x,_]=y.useState(""),b=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{function N(R){b.current&&!b.current.contains(R.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),k=s&&x.trim()&&!r.some(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(R=>R.id===N)).filter(Boolean),v=y.useCallback(N=>{var R;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(R=S.current)==null||R.focus())},[e,t,c]),T=y.useCallback(N=>{t(e.filter(R=>R!==N))},[e,t]),B=y.useCallback(async()=>{if(!k)return;const N=await(i==null?void 0:i(x.trim()));N&&v(N.id),_("")},[k,x,i,v]),j=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?B():C.length>0&&v(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?T(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[k,C,x,e,B,v,T]);return f.jsxs("div",{ref:b,className:h,style:{position:"relative"},children:[l&&f.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),f.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),f.jsx("input",{ref:S,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:j,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&f.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!k?f.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):f.jsxs(f.Fragment,{children:[C.map(N=>f.jsxs("div",{onClick:()=>v(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:R=>{R.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:R=>{R.currentTarget.style.background=""},children:[N.label,o&&a&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),a(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:R=>{R.currentTarget.style.opacity="1",R.currentTarget.style.color="#ef4444"},onMouseLeave:R=>{R.currentTarget.style.opacity="0.5",R.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),k&&f.jsxs("div",{onClick:B,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:C.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Lg={background:"#f9fafb",cardBackground:"#ffffff",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#374151"},Kc=y.forwardRef(({filteredOptions:r,search:e,theme:t,maxHeight:n,onCardClick:s},i)=>{const o=y.useRef(null),[a,l]=y.useState(typeof n=="number"?`${n}px`:n);return y.useEffect(()=>{const u=o.current;if(!u)return;const c=u.getBoundingClientRect(),d=window.innerHeight-c.top-16;l(`${Math.max(120,Math.min(d,typeof n=="number"?n:9999))}px`)},[n,r.length]),y.useEffect(()=>{typeof i=="function"?i(o.current):i&&(i.current=o.current)}),f.jsx("div",{ref:o,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:a,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:"8px",background:t.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:r.length===0?f.jsx("div",{style:{padding:"16px",textAlign:"center",color:t.textSecondary,fontSize:"14px"},children:e?`No results for "${e}"`:"No items"}):r.map((u,c)=>f.jsxs("div",{onClick:()=>s(u),style:{padding:"10px 14px",cursor:"pointer",borderBottom:c<r.length-1?`1px solid ${t.border}`:"none",background:t.cardBackground,transition:"background 0.15s",display:"flex",alignItems:"center",gap:"10px"},onMouseEnter:d=>{d.currentTarget.style.background=t.cardHover||"#f3f4f6"},onMouseLeave:d=>{d.currentTarget.style.background=t.cardBackground||"#f9fafb"},children:[u.icon&&f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:u.color||t.textSecondary,flexShrink:0},children:u.icon}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:u.color||t.text,marginBottom:u.notes?"2px":0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),u.notes&&f.jsx("div",{style:{fontSize:"12px",color:t.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.notes})]})]},u.id))})});Kc.displayName="DropdownList";function Pg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Lg,...u},[d,h]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),_=y.useRef(null),b=y.useMemo(()=>e&&r.find(B=>B.id===e)||null,[e,r]),S=y.useMemo(()=>{if(!d.trim())return r;const B=d.toLowerCase();return r.filter(j=>{var N,R;return((N=j.label)==null?void 0:N.toLowerCase().includes(B))||((R=j.notes)==null?void 0:R.toLowerCase().includes(B))})},[r,d]);y.useEffect(()=>{const B=j=>{m.current&&!m.current.contains(j.target)&&g(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const C=B=>{s&&s(B),g(!1),h("")},k=()=>{o&&o(d.trim()||void 0),g(!1),h("")},E=()=>{g(!0)},v=B=>{h(B.target.value),p||g(!0)},T=B=>{B.key==="Enter"?(B.preventDefault(),S.length>0&&s?(s(S[0]),g(!1),h("")):o&&d.trim()&&(o(d.trim()),g(!1),h(""))):B.key==="Escape"&&(g(!1),h(""))};return f.jsxs("div",{ref:m,className:`combostack ${l}`,style:{position:"relative",width:"100%",height:"32px"},children:[f.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",height:"100%"},children:[f.jsx("div",{style:{flex:1,position:"relative"},children:b&&!p?f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px",fontSize:"13px",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,color:c.text,cursor:"pointer",height:"32px",boxSizing:"border-box"},onClick:()=>g(!0),children:[f.jsxs("div",{style:{overflow:"hidden"},children:[f.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.label}),b.notes&&f.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.notes})]}),i&&f.jsx("button",{onClick:B=>{B.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"16px",pointerEvents:"none"},children:"search"}),f.jsx("input",{ref:x,type:"text",value:d,onChange:v,onFocus:E,onKeyDown:T,placeholder:n,style:{width:"100%",height:"32px",padding:"0 12px 0 36px",fontSize:"13px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"8px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&f.jsx("button",{onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",color:c.text,cursor:"pointer",padding:"4px",borderRadius:"4px",transition:"opacity 0.15s",flexShrink:0,opacity:.7},onMouseEnter:B=>{B.currentTarget.style.opacity="1"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.7"},title:`Create ${t||"item"}`,children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"add"})})]}),p&&f.jsx(Kc,{ref:_,filteredOptions:S,search:d,theme:c,maxHeight:a,onCardClick:C})]})}function Ig({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:h="",columnStyle:p,itemClassName:g=""}){const[m,x]=y.useState(null),[_,b]=y.useState(null),[S,C]=y.useState(null),k=y.useRef(null),E=e.reduce((M,w)=>{let D=r.filter(F=>n(F)===w.id);return s&&(D=D.sort((F,z)=>s(F)-s(z))),M[w.id]=D,M},{}),v=y.useCallback((M,w)=>{const D=t(w),F=n(w);x(D),k.current=F,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",D),requestAnimationFrame(()=>{const z=M.target;z.style.opacity="0.5"})},[t,n]),T=y.useCallback(M=>{const w=M.target;w.style.opacity="1",x(null),b(null),C(null),k.current=null},[]),B=y.useCallback((M,w,D)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",b(w),C(D)},[]),j=y.useCallback(M=>{const w=M.relatedTarget;w!=null&&w.closest("[data-kanban-column]")||(b(null),C(null))},[]),N=y.useCallback((M,w,D)=>{if(M.preventDefault(),!m)return;const F=k.current;F===w?a==null||a(m,w,D):F&&o(m,F,w,D),x(null),b(null),C(null),k.current=null},[m,o,a]),R=(M,w)=>f.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[M.color&&f.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:M.color}}),f.jsx("span",{className:"font-medium text-sm text-neutral-700",children:M.label})]}),f.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:w})]});return f.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 h-full ${d}`,style:{alignItems:"flex-start"},children:e.map(M=>{const w=E[M.id]||[],D=_===M.id,F=w.length>0||D;return f.jsxs("div",{"data-kanban-column":M.id,className:`flex-1 min-w-[180px] rounded-xl flex flex-col ${h||"bg-neutral-50"}`,style:{...p,maxHeight:"100%",...F?{}:{}},onDragOver:z=>{z.preventDefault(),m&&!D&&b(M.id)},onDragLeave:j,onDrop:z=>N(z,M.id,S??w.length),children:[f.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,w.length):R(M,w.length)}),f.jsxs("div",{className:`overflow-y-auto p-2 space-y-2 transition-colors ${D?"bg-blue-50":""}`,style:{minHeight:F?100:40},children:[w.map((z,q)=>{const J=t(z),te=m===J,W=D&&S===q&&!te;return f.jsxs("div",{children:[W&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),f.jsx("div",{draggable:!0,onDragStart:G=>v(G,z),onDragEnd:T,onDragOver:G=>B(G,M.id,q),onClick:()=>l==null?void 0:l(z),className:`cursor-grab active:cursor-grabbing transition-all ${te?"opacity-50 scale-95":""} ${g}`,children:i(z,te)})]},J)}),f.jsx("div",{className:"min-h-[40px]",onDragOver:z=>{z.preventDefault(),B(z,M.id,w.length)},children:D&&S===w.length&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),w.length===0&&D&&f.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:f.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&f.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(M)})]},M.id)})})}function Yc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function zg(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function $g(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const qg={"1:1":1,"2:3":1.5,"16:9":.5625};function Qc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Yc(r),o=qg[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return f.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?f.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:f.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Jc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const h=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:f.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[f.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),f.jsxs("div",{style:{position:"relative"},children:[a&&f.jsx("button",{onClick:()=>h("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&f.jsx("button",{onClick:()=>h("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),f.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>f.jsx(Qc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Xc({node:r,onClose:e}){const t=Yc(r),n=zg(r),s=Og(r),i=$g(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),f.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:f.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),f.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[f.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?f.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),f.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:f.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),f.jsxs("div",{style:{padding:"0 32px 32px"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&f.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&f.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&f.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&f.jsxs("div",{style:{marginTop:24},children:[f.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>f.jsxs("div",{children:[f.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),f.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function Ug({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return f.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>f.jsx(Jc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[f.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),f.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&f.jsx(Xc,{node:s,onClose:l})]})}const Wg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Hg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Vg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Gg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Kg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:h=!0,className:p="",theme:g={}}){const m={...Wg,...g},{allDayItems:x,timedItems:_}=y.useMemo(()=>{const v=[],T=[];for(const B of r)a(B)?v.push(B):T.push(B);return{allDayItems:v,timedItems:T}},[r,a]),b=y.useMemo(()=>{const v=[];for(let T=t;T<=n;T++)v.push(T);return v},[t,n]),S=(n-t+1)*s,C=y.useCallback(v=>{const T=i(v);if(!T)return null;const B=Hg(T);if(!B)return null;const{hours:j,minutes:N}=B,R=Math.max(t,Math.min(n,j)),M=j<t?0:N,w=(R-t)*s+M/60*s,D=o(v),F=Math.max(20,D/60*s);return{top:w,height:F}},[i,o,t,n,s]),k=y.useMemo(()=>{if(!h||!Gg(e))return null;const v=new Date,T=v.getHours(),B=v.getMinutes();return T<t||T>n?null:(T-t)*s+B/60*s},[e,h,t,n,s]),E=y.useCallback(v=>{if(!d)return;const T=v.currentTarget.getBoundingClientRect(),j=(v.clientY-T.top)/s*60,N=Math.floor(j/60)+t,R=Math.round(j%60/15)*15,M=Math.min(n,Math.max(t,N)),w=R>=60?0:R,D=`${M.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`;d(D)},[d,s,t,n]);return f.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&f.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[f.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>f.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},l(v)))})]}),f.jsxs("div",{style:{position:"relative",height:S},children:[b.map((v,T)=>f.jsxs("div",{style:{position:"absolute",top:T*s,left:0,right:0},children:[f.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Vg(v)}),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),T<b.length-1&&f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},v)),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),k!==null&&f.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[f.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),f.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(v=>{const T=C(v);return T?f.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:T.top,height:T.height,zIndex:10,cursor:c?"pointer":"default"},onClick:B=>{B.stopPropagation(),c==null||c(v)},children:u(v)},l(v)):null})]})]})}function Zc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180,extraControls:a}){const l=s==="widget",[u,c]=y.useState("idle"),[d,h]=y.useState(0),[p,g]=y.useState(0),[m,x]=y.useState(!1),[_,b]=y.useState(0),[S,C]=y.useState(null),[k,E]=y.useState(!1),[v,T]=y.useState(null),[B,j]=y.useState(!0),[N,R]=y.useState([]),[M,w]=y.useState({completed:0,total:0}),D=y.useRef(!1),F=y.useRef(!0);y.useEffect(()=>{F.current=B},[B]);const z=y.useRef(null),q=y.useRef(null),J=y.useRef(null),te=y.useRef(null),W=y.useRef(null),G=y.useRef([]),H=y.useRef(null),se=y.useRef(null),le=y.useRef(null),ue=y.useRef(null),_e=y.useRef(!1),fe=y.useRef([]),De=y.useRef(null),O=y.useRef(null),Ce=y.useRef([]),re=y.useRef([]),Fe=y.useRef("insert"),je=y.useRef(!1),ye=y.useRef(0),Se=y.useRef(0),Me=y.useRef(0),Oe=Q=>{const I=Math.floor(Q/60),de=Math.floor(Q%60);return`${I.toString().padStart(2,"0")}:${de.toString().padStart(2,"0")}`},ge=async Q=>{const I=await Q.arrayBuffer(),de=new AudioContext,he=await de.decodeAudioData(I);return await de.close(),he},L=Q=>{const I=Q.numberOfChannels,de=Q.sampleRate,he=1,Y=16,Ae=Y/8,Ee=I*Ae,Te=de*Ee,Le=Q.length*Ee,He=new ArrayBuffer(44+Le),ke=new DataView(He),P=(be,Ne)=>{for(let st=0;st<Ne.length;st++)ke.setUint8(be+st,Ne.charCodeAt(st))};P(0,"RIFF"),ke.setUint32(4,36+Le,!0),P(8,"WAVE"),P(12,"fmt "),ke.setUint32(16,16,!0),ke.setUint16(20,he,!0),ke.setUint16(22,I,!0),ke.setUint32(24,de,!0),ke.setUint32(28,Te,!0),ke.setUint16(32,Ee,!0),ke.setUint16(34,Y,!0),P(36,"data"),ke.setUint32(40,Le,!0);const xe=[];for(let be=0;be<I;be++)xe.push(Q.getChannelData(be));let ve=44;for(let be=0;be<Q.length;be++)for(let Ne=0;Ne<I;Ne++){const st=Math.max(-1,Math.min(1,xe[Ne][be])),ct=st<0?st*32768:st*32767;ke.setInt16(ve,ct,!0),ve+=2}return new Blob([He],{type:"audio/wav"})},ze=async(Q,I,de,he)=>{const Y=new AudioContext,Ae=Q.sampleRate,Ee=Math.max(Q.numberOfChannels,I.numberOfChannels),Te=Math.min(de,Q.length),Le=Math.max(0,Q.length-de),He=he==="insert"?Te+I.length+Le:Te+I.length,ke=Y.createBuffer(Ee,He,Ae);for(let P=0;P<Ee;P++){const xe=ke.getChannelData(P),ve=P<Q.numberOfChannels?Q.getChannelData(P):Q.getChannelData(0);for(let Ne=0;Ne<Te;Ne++)xe[Ne]=ve[Ne];const be=P<I.numberOfChannels?I.getChannelData(P):I.getChannelData(0);for(let Ne=0;Ne<I.length;Ne++)xe[Te+Ne]=be[Ne];if(he==="insert")for(let Ne=0;Ne<Le;Ne++)xe[Te+I.length+Ne]=ve[de+Ne]}return await Y.close(),ke},Ke=y.useCallback(()=>{const Q=z.current;if(!Q)return;const I=Q.getContext("2d");if(!I)return;const de=Q.getBoundingClientRect(),he=de.width,Y=de.height,Ae=fe.current,Ee=p||d||1,Te=u==="recording"?d:_;I.fillStyle="#2d3b35",I.fillRect(0,0,he,Y);const Le=8,He="rgba(0, 0, 0, 0.4)",ke=I.createLinearGradient(0,0,0,Le);ke.addColorStop(0,He),ke.addColorStop(1,"transparent"),I.fillStyle=ke,I.fillRect(0,0,he,Le);const P=I.createLinearGradient(0,Y-Le,0,Y);P.addColorStop(0,"transparent"),P.addColorStop(1,He),I.fillStyle=P,I.fillRect(0,Y-Le,he,Le);const xe=I.createLinearGradient(0,0,Le,0);xe.addColorStop(0,He),xe.addColorStop(1,"transparent"),I.fillStyle=xe,I.fillRect(0,0,Le,Y);const ve=I.createLinearGradient(he-Le,0,he,0);ve.addColorStop(0,"transparent"),ve.addColorStop(1,He),I.fillStyle=ve,I.fillRect(he-Le,0,Le,Y),I.strokeStyle="#5a6b62",I.lineWidth=1,I.beginPath(),I.moveTo(0,Y/2),I.lineTo(he,Y/2),I.stroke();const be=he/2;if(Ae.length>0)if(u==="recording")for(let ct=0;ct<Ae.length;ct++){const bt=Ae.length-1-ct,Xt=be-bt*4;if(Xt<-3||Xt>he)continue;const A=Ae[ct]*(Y/2-12),U=Y/2-A;I.fillStyle="#10b981",I.fillRect(Xt,U,3,A*2)}else{const ct=Ee>0?Te/Ee*Ae.length:0;for(let bt=0;bt<Ae.length;bt++){const Xt=ct-bt,A=be-Xt*4;if(A<-3||A>he)continue;const U=Ae[bt]*(Y/2-12),ne=Y/2-U;I.fillStyle=bt<=ct?"#10b981":"#4b5563",I.fillRect(A,ne,3,U*2)}}I.strokeStyle="#ef4444",I.lineWidth=1,I.beginPath(),I.moveTo(be,0),I.lineTo(be,Y),I.stroke(),I.fillStyle="#fff",I.font="bold 18px monospace",I.textAlign="center",I.fillText(Oe(Te),be,Y-6),u==="recording"&&(I.fillStyle="#ef4444",I.beginPath(),I.arc(20,20,8,0,Math.PI*2),I.fill(),I.fillStyle="#fff",I.font="10px sans-serif",I.textAlign="left",I.fillText("REC",34,24)),I.textAlign="left"},[u,_,d,p]),X=()=>{const Q=W.current;if(!Q||!_e.current)return;const I=Q.frequencyBinCount,de=new Uint8Array(I);Q.getByteTimeDomainData(de);let he=0;for(let Ee=0;Ee<I;Ee++){const Te=(de[Ee]-128)/128;he+=Te*Te}const Y=Math.sqrt(he/I),Ae=Math.min(1,Y*3);fe.current.push(Ae),Ke(),_e.current&&(se.current=requestAnimationFrame(X))},Z=async()=>{try{C(null),E(!1),De.current===null&&(fe.current=[]);const Q=await navigator.mediaDevices.getUserMedia({audio:!0});J.current=Q;const I=new AudioContext;te.current=I;const de=I.createAnalyser();de.fftSize=2048,W.current=de,I.createMediaStreamSource(Q).connect(de);const Y=new MediaRecorder(Q);q.current=Y,G.current=[],Y.ondataavailable=Ae=>{Ae.data.size>0&&G.current.push(Ae.data)},Y.onstop=async()=>{try{if(_e.current=!1,G.current.length===0){C("No audio was recorded. Please try again."),c("idle"),Q.getTracks().forEach(ke=>ke.stop());return}const Ae=new Blob(G.current,{type:"audio/webm"});let Ee,Te;if(De.current!==null&&O.current)try{const ke=await ge(Ae),P=O.current.sampleRate,xe=Math.floor(De.current*P),ve=await ze(O.current,ke,xe,Fe.current);Ee=L(ve),Te=ve.length/ve.sampleRate,Fe.current==="insert"&&(fe.current=[...fe.current,...re.current]),De.current=null,O.current=null,Ce.current=[],re.current=[]}catch{Ee=Ae,Te=ye.current>0?ye.current:1}else Ee=Ae,Te=ye.current>0?ye.current:1;if(ue.current=Ee,Q.getTracks().forEach(ke=>ke.stop()),F.current&&t){R(ke=>[...ke,Ee]),w(ke=>({...ke,total:ke.total+1})),ue.current=null,fe.current=[],b(0),g(0),h(0),c("idle");return}const Le=URL.createObjectURL(Ee),He=new Audio(Le);He.ontimeupdate=()=>{b(He.currentTime)},He.onended=()=>{x(!1)},le.current=He,g(Te),b(Te),c("editing")}catch{C("Failed to process recording"),c("idle")}},Y.start(100),_e.current=!0,c("recording"),h(0),ye.current=0,H.current=setInterval(()=>{ye.current+=1,h(ye.current),ye.current>=o&&(q.current&&q.current.state!=="inactive"&&q.current.stop(),_e.current=!1,T(null),H.current&&(clearInterval(H.current),H.current=null),se.current&&(cancelAnimationFrame(se.current),se.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},ce=()=>{_e.current=!1,E(!1),T(null),se.current&&(cancelAnimationFrame(se.current),se.current=null),H.current&&(clearInterval(H.current),H.current=null),q.current&&q.current.state!=="inactive"&&q.current.stop()},we=Q=>{const I=z.current;if(!I)return;const de=p||d;if(de<=0)return;const he=fe.current;if(he.length===0)return;const Y=I.getBoundingClientRect(),Ae=Q-Se.current,Ee=4,Te=Y.width/I.width,Le=he.length/de*Ee,He=-Ae/(Le*Te),ke=Me.current+He,P=Math.max(0,Math.min(ke,de));le.current&&(le.current.currentTime=P),b(P)},Be=()=>{le.current&&(le.current.currentTime=0),b(0)},Qe=()=>{const Q=p||d;le.current&&(le.current.currentTime=Q),b(Q)},Et=()=>{const Q=le.current;Q&&(m?(Q.pause(),b(Q.currentTime),x(!1)):(Q.currentTime=_,Q.play().catch(()=>{}),x(!0)))},oe=async Q=>{if(!ue.current){Z();return}try{le.current&&(le.current.pause(),x(!1)),Fe.current=Q,O.current=await ge(ue.current);const I=p||d;De.current=_;const de=I>0?_/I:0,he=Math.floor(de*fe.current.length);Ce.current=fe.current.slice(0,he),re.current=fe.current.slice(he),fe.current=[...Ce.current],Z()}catch{C("Failed to prepare recording. Please try again.")}},pe=()=>{le.current&&(le.current.pause(),le.current=null),ue.current=null,O.current=null,De.current=null,Ce.current=[],x(!1),b(0),g(0),h(0),Z()},Ye=()=>{ue.current?r(ue.current,p||d):alert("No audio recorded yet!")};y.useEffect(()=>{u==="recording"&&z.current&&W.current&&_e.current&&(se.current=requestAnimationFrame(X))},[u]),y.useEffect(()=>{const Q=z.current;if(!Q)return;const I=()=>{const de=window.devicePixelRatio||1,he=Q.getBoundingClientRect();Q.width=he.width*de,Q.height=he.height*de;const Y=Q.getContext("2d");Y&&Y.scale(de,de)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),y.useEffect(()=>{if(u==="idle"){const Q=z.current;if(!Q)return;const I=Q.getContext("2d");if(!I)return;const de=Q.getBoundingClientRect(),he=de.width,Y=de.height;I.fillStyle="#2d3b35",I.fillRect(0,0,he,Y);const Ae=8,Ee="rgba(0, 0, 0, 0.4)",Te=I.createLinearGradient(0,0,0,Ae);Te.addColorStop(0,Ee),Te.addColorStop(1,"transparent"),I.fillStyle=Te,I.fillRect(0,0,he,Ae);const Le=I.createLinearGradient(0,Y-Ae,0,Y);Le.addColorStop(0,"transparent"),Le.addColorStop(1,Ee),I.fillStyle=Le,I.fillRect(0,Y-Ae,he,Ae);const He=I.createLinearGradient(0,0,Ae,0);He.addColorStop(0,Ee),He.addColorStop(1,"transparent"),I.fillStyle=He,I.fillRect(0,0,Ae,Y);const ke=I.createLinearGradient(he-Ae,0,he,0);ke.addColorStop(0,"transparent"),ke.addColorStop(1,Ee),I.fillStyle=ke,I.fillRect(he-Ae,0,Ae,Y),I.strokeStyle="#5a6b62",I.lineWidth=1,I.beginPath(),I.moveTo(0,Y/2),I.lineTo(he,Y/2),I.stroke();const P=he/2;I.strokeStyle="#ef4444",I.lineWidth=1,I.beginPath(),I.moveTo(P,0),I.lineTo(P,Y),I.stroke(),I.fillStyle="#fff",I.font="bold 18px monospace",I.textAlign="center",I.fillText("00:00",P,Y-6)}},[u]);const at=y.useCallback(Q=>{R(I=>[...I,Q]),w(I=>({...I,total:I.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(D.current||N.length===0||!t)return;D.current=!0;const I=N[0];try{const de=await t(I);de&&n&&n(de)}catch(de){console.error("Transcription failed:",de)}finally{R(de=>de.slice(1)),w(de=>({...de,completed:de.completed+1})),D.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{_e.current=!1,H.current&&clearInterval(H.current),se.current&&cancelAnimationFrame(se.current),J.current&&J.current.getTracks().forEach(Q=>Q.stop()),te.current&&te.current.state!=="closed"&&te.current.close()},[]),y.useEffect(()=>{if(u==="editing"&&m){let Q;const I=()=>{const de=le.current;if(de&&m){const he=z.current;if(he){const Y=he.getContext("2d");if(Y){const Ae=he.getBoundingClientRect(),Ee=Ae.width,Te=Ae.height,Le=fe.current,He=p||d||1,ke=de.currentTime;Y.fillStyle="#2d3b35",Y.fillRect(0,0,Ee,Te);const P=8,xe="rgba(0, 0, 0, 0.4)",ve=Y.createLinearGradient(0,0,0,P);ve.addColorStop(0,xe),ve.addColorStop(1,"transparent"),Y.fillStyle=ve,Y.fillRect(0,0,Ee,P);const be=Y.createLinearGradient(0,Te-P,0,Te);be.addColorStop(0,"transparent"),be.addColorStop(1,xe),Y.fillStyle=be,Y.fillRect(0,Te-P,Ee,P);const Ne=Y.createLinearGradient(0,0,P,0);Ne.addColorStop(0,xe),Ne.addColorStop(1,"transparent"),Y.fillStyle=Ne,Y.fillRect(0,0,P,Te);const st=Y.createLinearGradient(Ee-P,0,Ee,0);st.addColorStop(0,"transparent"),st.addColorStop(1,xe),Y.fillStyle=st,Y.fillRect(Ee-P,0,P,Te),Y.strokeStyle="#5a6b62",Y.lineWidth=1,Y.beginPath(),Y.moveTo(0,Te/2),Y.lineTo(Ee,Te/2),Y.stroke();const ct=Ee/2,bt=3,Xt=4,A=He>0?ke/He*Le.length:0;for(let me=0;me<Le.length;me++){const qe=A-me,Ue=ct-qe*Xt;if(Ue<-bt||Ue>Ee)continue;const Pe=Le[me]*(Te/2-12),Re=Te/2-Pe;Y.fillStyle=me<=A?"#10b981":"#4b5563",Y.fillRect(Ue,Re,bt,Pe*2)}Y.strokeStyle="#ef4444",Y.lineWidth=1,Y.beginPath(),Y.moveTo(ct,0),Y.lineTo(ct,Te),Y.stroke(),Y.fillStyle="#fff",Y.font="bold 18px monospace",Y.textAlign="center";const U=Math.floor(ke/60),ne=Math.floor(ke%60);Y.fillText(`${U.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`,ct,Te-6),Y.textAlign="left"}}Q=requestAnimationFrame(I)}};return Q=requestAnimationFrame(I),()=>cancelAnimationFrame(Q)}},[u,m,p,d]),y.useEffect(()=>{u==="editing"&&!m&&Ke()},[u,_,m,Ke]),S)return f.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[f.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:S}),f.jsx("button",{onClick:()=>{C(null),Z()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ve={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Xe={...Ve,opacity:.3,cursor:"not-allowed"},br=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return f.jsxs("div",{style:br,children:[f.jsx("canvas",{ref:z,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Q=>{if(u==="editing"){je.current=!0,Se.current=Q.clientX,Me.current=_;const I=he=>{je.current&&we(he.clientX)},de=()=>{je.current=!1,window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",de)};window.addEventListener("mousemove",I),window.addEventListener("mouseup",de)}}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{onClick:Be,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:Ve,title:"Go to start",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),f.jsx("button",{onClick:()=>{if(u==="recording"){const Q=q.current;Q&&(Q.state==="recording"?(Q.pause(),E(!0)):Q.state==="paused"&&(Q.resume(),E(!1)))}else Et()},disabled:u==="idle",style:u==="idle"?Xe:Ve,title:m||u==="recording"&&!k?"Pause":"Play",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:m||u==="recording"&&!k?"pause":"play_arrow"})}),f.jsx("button",{onClick:Qe,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:Ve,title:"Go to end",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),f.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),f.jsx("button",{onClick:()=>{v==="insert"?ce():u==="idle"?(T("insert"),Z()):u==="editing"&&(T("insert"),oe("insert"))},disabled:u==="recording"&&v!=="insert"||m,style:u==="recording"&&v!=="insert"||m?Xe:Ve,title:v==="insert"?"Stop recording":"Insert recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="insert"?"#ef4444":"#171717"},children:"add"})}),f.jsx("button",{onClick:()=>{F.current||(v==="mic"?ce():u==="idle"?(T("mic"),Z()):u==="editing"&&(T("mic"),oe("replace")))},onMouseDown:()=>{F.current&&u==="idle"&&!m&&(T("mic"),Z())},onMouseUp:()=>{F.current&&u==="recording"&&v==="mic"&&ce()},onMouseLeave:()=>{F.current&&u==="recording"&&v==="mic"&&ce()},onTouchStart:Q=>{Q.preventDefault(),F.current&&u==="idle"&&!m&&(T("mic"),Z())},onTouchEnd:Q=>{Q.preventDefault(),F.current&&u==="recording"&&v==="mic"&&ce()},disabled:u==="recording"&&v!=="mic"||m,style:u==="recording"&&v!=="mic"||m?Xe:Ve,title:B?"Hold to record (walkie-talkie)":v==="mic"?"Stop recording":"Record",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="mic"?"#ef4444":"#171717"},children:"mic"})}),f.jsx("button",{onClick:()=>{u==="idle"&&!m?(T("round"),Z()):u==="recording"&&v==="round"&&ce()},disabled:u==="editing"||u==="recording"&&v!=="round"||m,style:u==="editing"||u==="recording"&&v!=="round"||m?Xe:{...Ve,width:"28px",height:"28px",borderRadius:"50%",padding:0},title:"Click to record / click to stop",children:f.jsx("span",{style:{display:"block",width:"14px",height:"14px",borderRadius:"50%",background:u==="recording"&&v==="round"?"#171717":"#ef4444",transition:"background 0.15s"}})}),f.jsx("button",{onClick:()=>{v==="startover"?ce():u==="editing"&&(T("startover"),pe())},disabled:u==="idle"||u==="recording"&&v!=="startover"||m,style:u==="idle"||u==="recording"&&v!=="startover"||m?Xe:Ve,title:v==="startover"?"Stop recording":"Start over",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[a,M.total>0&&M.completed<M.total&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[f.jsx("button",{onClick:()=>j(!B),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:B?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:B?"Auto-transcribe ON":"Auto-transcribe OFF",children:f.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:B?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),f.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),f.jsx("button",{onClick:()=>{u==="editing"&&ue.current&&at(ue.current)},disabled:u!=="editing",style:u!=="editing"?Xe:Ve,title:"Transcribe audio",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:B?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&f.jsx("button",{onClick:Ye,disabled:u!=="editing",style:u!=="editing"?Xe:Ve,title:"Save recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&f.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:f.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Yg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,onAudioSave:o,placeholder:a="Type or record...",className:l="",rows:u,llmClient:c,graphClient:d,nodeId:h,audioFilename:p,existingAudio:g,existingVoice:m,onAudioGenerated:x,onGenerateTTS:_,audioUrl:b,voice:S="coral",onVoiceChange:C,generateButton:k,generatePrompt:E,generateSourceText:v,generateSourceError:T}){const[B,j]=y.useState(!1),[N,R]=y.useState(!1),[M,w]=y.useState(!1),[D,F]=y.useState(""),[z,q]=y.useState(!1),[J,te]=y.useState(!1),[W,G]=y.useState(null),[H,se]=y.useState(m||S),[le,ue]=y.useState(g),[_e,fe]=y.useState(Date.now()),De=y.useRef(null),O=y.useRef(null),Ce=!!(c&&d&&h&&p);y.useEffect(()=>{g!==void 0&&ue(g)},[g]),y.useEffect(()=>{m!==void 0&&se(m)},[m]);const re=Ce&&le&&d&&h?`${d.getFileUrl(h,le)}?v=${_e}`:b,Fe=L=>{t(e?`${e}
|
|
183
|
+
`})]})}const Rg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Fg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:h=""}){const p={...Rg,...d},[g,m]=y.useState(!1),[x,_]=y.useState(""),b=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{function N(R){b.current&&!b.current.contains(R.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),k=s&&x.trim()&&!r.some(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(R=>R.id===N)).filter(Boolean),v=y.useCallback(N=>{var R;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(R=S.current)==null||R.focus())},[e,t,c]),T=y.useCallback(N=>{t(e.filter(R=>R!==N))},[e,t]),B=y.useCallback(async()=>{if(!k)return;const N=await(i==null?void 0:i(x.trim()));N&&v(N.id),_("")},[k,x,i,v]),j=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?B():C.length>0&&v(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?T(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[k,C,x,e,B,v,T]);return f.jsxs("div",{ref:b,className:h,style:{position:"relative"},children:[l&&f.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),f.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),f.jsx("input",{ref:S,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:j,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&f.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!k?f.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):f.jsxs(f.Fragment,{children:[C.map(N=>f.jsxs("div",{onClick:()=>v(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:R=>{R.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:R=>{R.currentTarget.style.background=""},children:[N.label,o&&a&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),a(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:R=>{R.currentTarget.style.opacity="1",R.currentTarget.style.color="#ef4444"},onMouseLeave:R=>{R.currentTarget.style.opacity="0.5",R.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),k&&f.jsxs("div",{onClick:B,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:C.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Lg={background:"#f9fafb",cardBackground:"#ffffff",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#374151"},Kc=y.forwardRef(({filteredOptions:r,search:e,theme:t,maxHeight:n,onCardClick:s},i)=>{const o=y.useRef(null),[a,l]=y.useState(typeof n=="number"?`${n}px`:n);return y.useEffect(()=>{const u=o.current;if(!u)return;const c=u.getBoundingClientRect(),d=window.innerHeight-c.top-16;l(`${Math.max(120,Math.min(d,typeof n=="number"?n:9999))}px`)},[n,r.length]),y.useEffect(()=>{typeof i=="function"?i(o.current):i&&(i.current=o.current)}),f.jsx("div",{ref:o,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:a,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:"8px",background:t.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:r.length===0?f.jsx("div",{style:{padding:"16px",textAlign:"center",color:t.textSecondary,fontSize:"14px"},children:e?`No results for "${e}"`:"No items"}):r.map((u,c)=>f.jsxs("div",{onClick:()=>s(u),style:{padding:"10px 14px",cursor:"pointer",borderBottom:c<r.length-1?`1px solid ${t.border}`:"none",background:t.cardBackground,transition:"background 0.15s",display:"flex",alignItems:"center",gap:"10px"},onMouseEnter:d=>{d.currentTarget.style.background=t.cardHover||"#f3f4f6"},onMouseLeave:d=>{d.currentTarget.style.background=t.cardBackground||"#f9fafb"},children:[u.icon&&f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:u.color||t.textSecondary,flexShrink:0},children:u.icon}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:u.color||t.text,marginBottom:u.notes?"2px":0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),u.notes&&f.jsx("div",{style:{fontSize:"12px",color:t.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.notes})]})]},u.id))})});Kc.displayName="DropdownList";function Pg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Lg,...u},[d,h]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),_=y.useRef(null),b=y.useMemo(()=>e&&r.find(B=>B.id===e)||null,[e,r]),S=y.useMemo(()=>{if(!d.trim())return r;const B=d.toLowerCase();return r.filter(j=>{var N,R;return((N=j.label)==null?void 0:N.toLowerCase().includes(B))||((R=j.notes)==null?void 0:R.toLowerCase().includes(B))})},[r,d]);y.useEffect(()=>{const B=j=>{m.current&&!m.current.contains(j.target)&&g(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const C=B=>{s&&s(B),g(!1),h("")},k=()=>{o&&o(d.trim()||void 0),g(!1),h("")},E=()=>{g(!0)},v=B=>{h(B.target.value),p||g(!0)},T=B=>{B.key==="Enter"?(B.preventDefault(),S.length>0&&s?(s(S[0]),g(!1),h("")):o&&d.trim()&&(o(d.trim()),g(!1),h(""))):B.key==="Escape"&&(g(!1),h(""))};return f.jsxs("div",{ref:m,className:`combostack ${l}`,style:{position:"relative",width:"100%",height:"32px"},children:[f.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",height:"100%"},children:[f.jsx("div",{style:{flex:1,position:"relative"},children:b&&!p?f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px",fontSize:"13px",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,color:c.text,cursor:"pointer",height:"32px",boxSizing:"border-box"},onClick:()=>g(!0),children:[f.jsxs("div",{style:{overflow:"hidden"},children:[f.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.label}),b.notes&&f.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.notes})]}),i&&f.jsx("button",{onClick:B=>{B.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"16px",pointerEvents:"none"},children:"search"}),f.jsx("input",{ref:x,type:"text",value:d,onChange:v,onFocus:E,onKeyDown:T,placeholder:n,style:{width:"100%",height:"32px",padding:"0 12px 0 36px",fontSize:"13px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"8px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&f.jsx("button",{onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",color:c.text,cursor:"pointer",padding:"4px",borderRadius:"4px",transition:"opacity 0.15s",flexShrink:0,opacity:.7},onMouseEnter:B=>{B.currentTarget.style.opacity="1"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.7"},title:`Create ${t||"item"}`,children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"add"})})]}),p&&f.jsx(Kc,{ref:_,filteredOptions:S,search:d,theme:c,maxHeight:a,onCardClick:C})]})}function Ig({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:h="",columnStyle:p,itemClassName:g=""}){const[m,x]=y.useState(null),[_,b]=y.useState(null),[S,C]=y.useState(null),k=y.useRef(null),E=e.reduce((M,w)=>{let D=r.filter(F=>n(F)===w.id);return s&&(D=D.sort((F,I)=>s(F)-s(I))),M[w.id]=D,M},{}),v=y.useCallback((M,w)=>{const D=t(w),F=n(w);x(D),k.current=F,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",D),requestAnimationFrame(()=>{const I=M.target;I.style.opacity="0.5"})},[t,n]),T=y.useCallback(M=>{const w=M.target;w.style.opacity="1",x(null),b(null),C(null),k.current=null},[]),B=y.useCallback((M,w,D)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",b(w),C(D)},[]),j=y.useCallback(M=>{const w=M.relatedTarget;w!=null&&w.closest("[data-kanban-column]")||(b(null),C(null))},[]),N=y.useCallback((M,w,D)=>{if(M.preventDefault(),!m)return;const F=k.current;F===w?a==null||a(m,w,D):F&&o(m,F,w,D),x(null),b(null),C(null),k.current=null},[m,o,a]),R=(M,w)=>f.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[M.color&&f.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:M.color}}),f.jsx("span",{className:"font-medium text-sm text-neutral-700",children:M.label})]}),f.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:w})]});return f.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 h-full ${d}`,style:{alignItems:"flex-start"},children:e.map(M=>{const w=E[M.id]||[],D=_===M.id,F=w.length>0||D;return f.jsxs("div",{"data-kanban-column":M.id,className:`flex-1 min-w-[180px] rounded-xl flex flex-col ${h||"bg-neutral-50"}`,style:{...p,maxHeight:"100%",...F?{}:{}},onDragOver:I=>{I.preventDefault(),m&&!D&&b(M.id)},onDragLeave:j,onDrop:I=>N(I,M.id,S??w.length),children:[f.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,w.length):R(M,w.length)}),f.jsxs("div",{className:`overflow-y-auto p-2 space-y-2 transition-colors ${D?"bg-blue-50":""}`,style:{minHeight:F?100:40},children:[w.map((I,q)=>{const Z=t(I),te=m===Z,W=D&&S===q&&!te;return f.jsxs("div",{children:[W&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),f.jsx("div",{draggable:!0,onDragStart:Q=>v(Q,I),onDragEnd:T,onDragOver:Q=>B(Q,M.id,q),onClick:()=>l==null?void 0:l(I),className:`cursor-grab active:cursor-grabbing transition-all ${te?"opacity-50 scale-95":""} ${g}`,children:i(I,te)})]},Z)}),f.jsx("div",{className:"min-h-[40px]",onDragOver:I=>{I.preventDefault(),B(I,M.id,w.length)},children:D&&S===w.length&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),w.length===0&&D&&f.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:f.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&f.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(M)})]},M.id)})})}function Yc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function zg(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function $g(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const qg={"1:1":1,"2:3":1.5,"16:9":.5625};function Qc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Yc(r),o=qg[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return f.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?f.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:f.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Jc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const h=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:f.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[f.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),f.jsxs("div",{style:{position:"relative"},children:[a&&f.jsx("button",{onClick:()=>h("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&f.jsx("button",{onClick:()=>h("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),f.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>f.jsx(Qc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Xc({node:r,onClose:e}){const t=Yc(r),n=zg(r),s=Og(r),i=$g(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),f.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:f.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),f.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[f.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?f.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),f.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:f.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),f.jsxs("div",{style:{padding:"0 32px 32px"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&f.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&f.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&f.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&f.jsxs("div",{style:{marginTop:24},children:[f.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>f.jsxs("div",{children:[f.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),f.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function Ug({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return f.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>f.jsx(Jc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[f.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),f.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&f.jsx(Xc,{node:s,onClose:l})]})}const Wg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Hg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Vg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Gg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Kg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:h=!0,className:p="",theme:g={}}){const m={...Wg,...g},{allDayItems:x,timedItems:_}=y.useMemo(()=>{const v=[],T=[];for(const B of r)a(B)?v.push(B):T.push(B);return{allDayItems:v,timedItems:T}},[r,a]),b=y.useMemo(()=>{const v=[];for(let T=t;T<=n;T++)v.push(T);return v},[t,n]),S=(n-t+1)*s,C=y.useCallback(v=>{const T=i(v);if(!T)return null;const B=Hg(T);if(!B)return null;const{hours:j,minutes:N}=B,R=Math.max(t,Math.min(n,j)),M=j<t?0:N,w=(R-t)*s+M/60*s,D=o(v),F=Math.max(20,D/60*s);return{top:w,height:F}},[i,o,t,n,s]),k=y.useMemo(()=>{if(!h||!Gg(e))return null;const v=new Date,T=v.getHours(),B=v.getMinutes();return T<t||T>n?null:(T-t)*s+B/60*s},[e,h,t,n,s]),E=y.useCallback(v=>{if(!d)return;const T=v.currentTarget.getBoundingClientRect(),j=(v.clientY-T.top)/s*60,N=Math.floor(j/60)+t,R=Math.round(j%60/15)*15,M=Math.min(n,Math.max(t,N)),w=R>=60?0:R,D=`${M.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`;d(D)},[d,s,t,n]);return f.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&f.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[f.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>f.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},l(v)))})]}),f.jsxs("div",{style:{position:"relative",height:S},children:[b.map((v,T)=>f.jsxs("div",{style:{position:"absolute",top:T*s,left:0,right:0},children:[f.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Vg(v)}),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),T<b.length-1&&f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},v)),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),k!==null&&f.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[f.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),f.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(v=>{const T=C(v);return T?f.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:T.top,height:T.height,zIndex:10,cursor:c?"pointer":"default"},onClick:B=>{B.stopPropagation(),c==null||c(v)},children:u(v)},l(v)):null})]})]})}function Zc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180,extraControls:a}){const l=s==="widget",[u,c]=y.useState("idle"),[d,h]=y.useState(0),[p,g]=y.useState(0),[m,x]=y.useState(!1),[_,b]=y.useState(0),[S,C]=y.useState(null),[k,E]=y.useState(!1),[v,T]=y.useState(null),[B,j]=y.useState(!0),[N,R]=y.useState([]),[M,w]=y.useState({completed:0,total:0}),D=y.useRef(!1),F=y.useRef(!0);y.useEffect(()=>{F.current=B},[B]);const I=y.useRef(null),q=y.useRef(null),Z=y.useRef(null),te=y.useRef(null),W=y.useRef(null),Q=y.useRef([]),H=y.useRef(null),ie=y.useRef(null),ue=y.useRef(null),de=y.useRef(null),we=y.useRef(!1),fe=y.useRef([]),Ce=y.useRef(null),O=y.useRef(null),je=y.useRef([]),re=y.useRef([]),Le=y.useRef("insert"),Me=y.useRef(!1),xe=y.useRef(0),Se=y.useRef(0),Re=y.useRef(0),se=J=>{const P=Math.floor(J/60),he=Math.floor(J%60);return`${P.toString().padStart(2,"0")}:${he.toString().padStart(2,"0")}`},ce=async J=>{const P=await J.arrayBuffer(),he=new AudioContext,ge=await he.decodeAudioData(P);return await he.close(),ge},$=J=>{const P=J.numberOfChannels,he=J.sampleRate,ge=1,Y=16,Ae=Y/8,Ee=P*Ae,Te=he*Ee,Pe=J.length*Ee,We=new ArrayBuffer(44+Pe),ke=new DataView(We),L=(ve,Ne)=>{for(let st=0;st<Ne.length;st++)ke.setUint8(ve+st,Ne.charCodeAt(st))};L(0,"RIFF"),ke.setUint32(4,36+Pe,!0),L(8,"WAVE"),L(12,"fmt "),ke.setUint32(16,16,!0),ke.setUint16(20,ge,!0),ke.setUint16(22,P,!0),ke.setUint32(24,he,!0),ke.setUint32(28,Te,!0),ke.setUint16(32,Ee,!0),ke.setUint16(34,Y,!0),L(36,"data"),ke.setUint32(40,Pe,!0);const be=[];for(let ve=0;ve<P;ve++)be.push(J.getChannelData(ve));let _e=44;for(let ve=0;ve<J.length;ve++)for(let Ne=0;Ne<P;Ne++){const st=Math.max(-1,Math.min(1,be[Ne][ve])),ct=st<0?st*32768:st*32767;ke.setInt16(_e,ct,!0),_e+=2}return new Blob([We],{type:"audio/wav"})},Ge=async(J,P,he,ge)=>{const Y=new AudioContext,Ae=J.sampleRate,Ee=Math.max(J.numberOfChannels,P.numberOfChannels),Te=Math.min(he,J.length),Pe=Math.max(0,J.length-he),We=ge==="insert"?Te+P.length+Pe:Te+P.length,ke=Y.createBuffer(Ee,We,Ae);for(let L=0;L<Ee;L++){const be=ke.getChannelData(L),_e=L<J.numberOfChannels?J.getChannelData(L):J.getChannelData(0);for(let Ne=0;Ne<Te;Ne++)be[Ne]=_e[Ne];const ve=L<P.numberOfChannels?P.getChannelData(L):P.getChannelData(0);for(let Ne=0;Ne<P.length;Ne++)be[Te+Ne]=ve[Ne];if(ge==="insert")for(let Ne=0;Ne<Pe;Ne++)be[Te+P.length+Ne]=_e[he+Ne]}return await Y.close(),ke},Ke=y.useCallback(()=>{const J=I.current;if(!J)return;const P=J.getContext("2d");if(!P)return;const he=J.getBoundingClientRect(),ge=he.width,Y=he.height,Ae=fe.current,Ee=p||d||1,Te=u==="recording"?d:_;P.fillStyle="#2d3b35",P.fillRect(0,0,ge,Y);const Pe=8,We="rgba(0, 0, 0, 0.4)",ke=P.createLinearGradient(0,0,0,Pe);ke.addColorStop(0,We),ke.addColorStop(1,"transparent"),P.fillStyle=ke,P.fillRect(0,0,ge,Pe);const L=P.createLinearGradient(0,Y-Pe,0,Y);L.addColorStop(0,"transparent"),L.addColorStop(1,We),P.fillStyle=L,P.fillRect(0,Y-Pe,ge,Pe);const be=P.createLinearGradient(0,0,Pe,0);be.addColorStop(0,We),be.addColorStop(1,"transparent"),P.fillStyle=be,P.fillRect(0,0,Pe,Y);const _e=P.createLinearGradient(ge-Pe,0,ge,0);_e.addColorStop(0,"transparent"),_e.addColorStop(1,We),P.fillStyle=_e,P.fillRect(ge-Pe,0,Pe,Y),P.strokeStyle="#5a6b62",P.lineWidth=1,P.beginPath(),P.moveTo(0,Y/2),P.lineTo(ge,Y/2),P.stroke();const ve=ge/2;if(Ae.length>0)if(u==="recording")for(let ct=0;ct<Ae.length;ct++){const bt=Ae.length-1-ct,Xt=ve-bt*4;if(Xt<-3||Xt>ge)continue;const A=Ae[ct]*(Y/2-12),U=Y/2-A;P.fillStyle="#10b981",P.fillRect(Xt,U,3,A*2)}else{const ct=Ee>0?Te/Ee*Ae.length:0;for(let bt=0;bt<Ae.length;bt++){const Xt=ct-bt,A=ve-Xt*4;if(A<-3||A>ge)continue;const U=Ae[bt]*(Y/2-12),ne=Y/2-U;P.fillStyle=bt<=ct?"#10b981":"#4b5563",P.fillRect(A,ne,3,U*2)}}P.strokeStyle="#ef4444",P.lineWidth=1,P.beginPath(),P.moveTo(ve,0),P.lineTo(ve,Y),P.stroke(),P.fillStyle="#fff",P.font="bold 18px monospace",P.textAlign="center",P.fillText(se(Te),ve,Y-6),u==="recording"&&(P.fillStyle="#ef4444",P.beginPath(),P.arc(20,20,8,0,Math.PI*2),P.fill(),P.fillStyle="#fff",P.font="10px sans-serif",P.textAlign="left",P.fillText("REC",34,24)),P.textAlign="left"},[u,_,d,p]),X=()=>{const J=W.current;if(!J||!we.current)return;const P=J.frequencyBinCount,he=new Uint8Array(P);J.getByteTimeDomainData(he);let ge=0;for(let Ee=0;Ee<P;Ee++){const Te=(he[Ee]-128)/128;ge+=Te*Te}const Y=Math.sqrt(ge/P),Ae=Math.min(1,Y*3);fe.current.push(Ae),Ke(),we.current&&(ie.current=requestAnimationFrame(X))},K=async()=>{try{C(null),E(!1),Ce.current===null&&(fe.current=[]);const J=await navigator.mediaDevices.getUserMedia({audio:!0});Z.current=J;const P=new AudioContext;te.current=P;const he=P.createAnalyser();he.fftSize=2048,W.current=he,P.createMediaStreamSource(J).connect(he);const Y=new MediaRecorder(J);q.current=Y,Q.current=[],Y.ondataavailable=Ae=>{Ae.data.size>0&&Q.current.push(Ae.data)},Y.onstop=async()=>{try{if(we.current=!1,Q.current.length===0){C("No audio was recorded. Please try again."),c("idle"),J.getTracks().forEach(ke=>ke.stop());return}const Ae=new Blob(Q.current,{type:"audio/webm"});let Ee,Te;if(Ce.current!==null&&O.current)try{const ke=await ce(Ae),L=O.current.sampleRate,be=Math.floor(Ce.current*L),_e=await Ge(O.current,ke,be,Le.current);Ee=$(_e),Te=_e.length/_e.sampleRate,Le.current==="insert"&&(fe.current=[...fe.current,...re.current]),Ce.current=null,O.current=null,je.current=[],re.current=[]}catch{Ee=Ae,Te=xe.current>0?xe.current:1}else Ee=Ae,Te=xe.current>0?xe.current:1;if(de.current=Ee,J.getTracks().forEach(ke=>ke.stop()),F.current&&t){R(ke=>[...ke,Ee]),w(ke=>({...ke,total:ke.total+1})),de.current=null,fe.current=[],b(0),g(0),h(0),c("idle");return}const Pe=URL.createObjectURL(Ee),We=new Audio(Pe);We.ontimeupdate=()=>{b(We.currentTime)},We.onended=()=>{x(!1)},ue.current=We,g(Te),b(Te),c("editing")}catch{C("Failed to process recording"),c("idle")}},Y.start(100),we.current=!0,c("recording"),h(0),xe.current=0,H.current=setInterval(()=>{xe.current+=1,h(xe.current),xe.current>=o&&(q.current&&q.current.state!=="inactive"&&q.current.stop(),we.current=!1,T(null),H.current&&(clearInterval(H.current),H.current=null),ie.current&&(cancelAnimationFrame(ie.current),ie.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},pe=()=>{we.current=!1,E(!1),T(null),ie.current&&(cancelAnimationFrame(ie.current),ie.current=null),H.current&&(clearInterval(H.current),H.current=null),q.current&&q.current.state!=="inactive"&&q.current.stop()},De=J=>{const P=I.current;if(!P)return;const he=p||d;if(he<=0)return;const ge=fe.current;if(ge.length===0)return;const Y=P.getBoundingClientRect(),Ae=J-Se.current,Ee=4,Te=Y.width/P.width,Pe=ge.length/he*Ee,We=-Ae/(Pe*Te),ke=Re.current+We,L=Math.max(0,Math.min(ke,he));ue.current&&(ue.current.currentTime=L),b(L)},Be=()=>{ue.current&&(ue.current.currentTime=0),b(0)},Qe=()=>{const J=p||d;ue.current&&(ue.current.currentTime=J),b(J)},Et=()=>{const J=ue.current;J&&(m?(J.pause(),b(J.currentTime),x(!1)):(J.currentTime=_,J.play().catch(()=>{}),x(!0)))},ae=async J=>{if(!de.current){K();return}try{ue.current&&(ue.current.pause(),x(!1)),Le.current=J,O.current=await ce(de.current);const P=p||d;Ce.current=_;const he=P>0?_/P:0,ge=Math.floor(he*fe.current.length);je.current=fe.current.slice(0,ge),re.current=fe.current.slice(ge),fe.current=[...je.current],K()}catch{C("Failed to prepare recording. Please try again.")}},me=()=>{ue.current&&(ue.current.pause(),ue.current=null),de.current=null,O.current=null,Ce.current=null,je.current=[],x(!1),b(0),g(0),h(0),K()},Ye=()=>{de.current?r(de.current,p||d):alert("No audio recorded yet!")};y.useEffect(()=>{u==="recording"&&I.current&&W.current&&we.current&&(ie.current=requestAnimationFrame(X))},[u]),y.useEffect(()=>{const J=I.current;if(!J)return;const P=()=>{const he=window.devicePixelRatio||1,ge=J.getBoundingClientRect();J.width=ge.width*he,J.height=ge.height*he;const Y=J.getContext("2d");Y&&Y.scale(he,he)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]),y.useEffect(()=>{if(u==="idle"){const J=I.current;if(!J)return;const P=J.getContext("2d");if(!P)return;const he=J.getBoundingClientRect(),ge=he.width,Y=he.height;P.fillStyle="#2d3b35",P.fillRect(0,0,ge,Y);const Ae=8,Ee="rgba(0, 0, 0, 0.4)",Te=P.createLinearGradient(0,0,0,Ae);Te.addColorStop(0,Ee),Te.addColorStop(1,"transparent"),P.fillStyle=Te,P.fillRect(0,0,ge,Ae);const Pe=P.createLinearGradient(0,Y-Ae,0,Y);Pe.addColorStop(0,"transparent"),Pe.addColorStop(1,Ee),P.fillStyle=Pe,P.fillRect(0,Y-Ae,ge,Ae);const We=P.createLinearGradient(0,0,Ae,0);We.addColorStop(0,Ee),We.addColorStop(1,"transparent"),P.fillStyle=We,P.fillRect(0,0,Ae,Y);const ke=P.createLinearGradient(ge-Ae,0,ge,0);ke.addColorStop(0,"transparent"),ke.addColorStop(1,Ee),P.fillStyle=ke,P.fillRect(ge-Ae,0,Ae,Y),P.strokeStyle="#5a6b62",P.lineWidth=1,P.beginPath(),P.moveTo(0,Y/2),P.lineTo(ge,Y/2),P.stroke();const L=ge/2;P.strokeStyle="#ef4444",P.lineWidth=1,P.beginPath(),P.moveTo(L,0),P.lineTo(L,Y),P.stroke(),P.fillStyle="#fff",P.font="bold 18px monospace",P.textAlign="center",P.fillText("00:00",L,Y-6)}},[u]);const at=y.useCallback(J=>{R(P=>[...P,J]),w(P=>({...P,total:P.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(D.current||N.length===0||!t)return;D.current=!0;const P=N[0];try{const he=await t(P);he&&n&&n(he)}catch(he){console.error("Transcription failed:",he)}finally{R(he=>he.slice(1)),w(he=>({...he,completed:he.completed+1})),D.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{we.current=!1,H.current&&clearInterval(H.current),ie.current&&cancelAnimationFrame(ie.current),Z.current&&Z.current.getTracks().forEach(J=>J.stop()),te.current&&te.current.state!=="closed"&&te.current.close()},[]),y.useEffect(()=>{if(u==="editing"&&m){let J;const P=()=>{const he=ue.current;if(he&&m){const ge=I.current;if(ge){const Y=ge.getContext("2d");if(Y){const Ae=ge.getBoundingClientRect(),Ee=Ae.width,Te=Ae.height,Pe=fe.current,We=p||d||1,ke=he.currentTime;Y.fillStyle="#2d3b35",Y.fillRect(0,0,Ee,Te);const L=8,be="rgba(0, 0, 0, 0.4)",_e=Y.createLinearGradient(0,0,0,L);_e.addColorStop(0,be),_e.addColorStop(1,"transparent"),Y.fillStyle=_e,Y.fillRect(0,0,Ee,L);const ve=Y.createLinearGradient(0,Te-L,0,Te);ve.addColorStop(0,"transparent"),ve.addColorStop(1,be),Y.fillStyle=ve,Y.fillRect(0,Te-L,Ee,L);const Ne=Y.createLinearGradient(0,0,L,0);Ne.addColorStop(0,be),Ne.addColorStop(1,"transparent"),Y.fillStyle=Ne,Y.fillRect(0,0,L,Te);const st=Y.createLinearGradient(Ee-L,0,Ee,0);st.addColorStop(0,"transparent"),st.addColorStop(1,be),Y.fillStyle=st,Y.fillRect(Ee-L,0,L,Te),Y.strokeStyle="#5a6b62",Y.lineWidth=1,Y.beginPath(),Y.moveTo(0,Te/2),Y.lineTo(Ee,Te/2),Y.stroke();const ct=Ee/2,bt=3,Xt=4,A=We>0?ke/We*Pe.length:0;for(let ye=0;ye<Pe.length;ye++){const $e=A-ye,qe=ct-$e*Xt;if(qe<-bt||qe>Ee)continue;const Ie=Pe[ye]*(Te/2-12),Fe=Te/2-Ie;Y.fillStyle=ye<=A?"#10b981":"#4b5563",Y.fillRect(qe,Fe,bt,Ie*2)}Y.strokeStyle="#ef4444",Y.lineWidth=1,Y.beginPath(),Y.moveTo(ct,0),Y.lineTo(ct,Te),Y.stroke(),Y.fillStyle="#fff",Y.font="bold 18px monospace",Y.textAlign="center";const U=Math.floor(ke/60),ne=Math.floor(ke%60);Y.fillText(`${U.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`,ct,Te-6),Y.textAlign="left"}}J=requestAnimationFrame(P)}};return J=requestAnimationFrame(P),()=>cancelAnimationFrame(J)}},[u,m,p,d]),y.useEffect(()=>{u==="editing"&&!m&&Ke()},[u,_,m,Ke]),S)return f.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[f.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:S}),f.jsx("button",{onClick:()=>{C(null),K()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const He={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Xe={...He,opacity:.3,cursor:"not-allowed"},br=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return f.jsxs("div",{style:br,children:[f.jsx("canvas",{ref:I,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:J=>{if(u==="editing"){Me.current=!0,Se.current=J.clientX,Re.current=_;const P=ge=>{Me.current&&De(ge.clientX)},he=()=>{Me.current=!1,window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",he)};window.addEventListener("mousemove",P),window.addEventListener("mouseup",he)}}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{onClick:Be,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:He,title:"Go to start",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),f.jsx("button",{onClick:()=>{if(u==="recording"){const J=q.current;J&&(J.state==="recording"?(J.pause(),E(!0)):J.state==="paused"&&(J.resume(),E(!1)))}else Et()},disabled:u==="idle",style:u==="idle"?Xe:He,title:m||u==="recording"&&!k?"Pause":"Play",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:m||u==="recording"&&!k?"pause":"play_arrow"})}),f.jsx("button",{onClick:Qe,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:He,title:"Go to end",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),f.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),f.jsx("button",{onClick:()=>{v==="insert"?pe():u==="idle"?(T("insert"),K()):u==="editing"&&(T("insert"),ae("insert"))},disabled:u==="recording"&&v!=="insert"||m,style:u==="recording"&&v!=="insert"||m?Xe:He,title:v==="insert"?"Stop recording":"Insert recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="insert"?"#ef4444":"#171717"},children:"add"})}),f.jsx("button",{onClick:()=>{F.current||(v==="mic"?pe():u==="idle"?(T("mic"),K()):u==="editing"&&(T("mic"),ae("replace")))},onMouseDown:()=>{F.current&&u==="idle"&&!m&&(T("mic"),K())},onMouseUp:()=>{F.current&&u==="recording"&&v==="mic"&&pe()},onMouseLeave:()=>{F.current&&u==="recording"&&v==="mic"&&pe()},onTouchStart:J=>{J.preventDefault(),F.current&&u==="idle"&&!m&&(T("mic"),K())},onTouchEnd:J=>{J.preventDefault(),F.current&&u==="recording"&&v==="mic"&&pe()},disabled:u==="recording"&&v!=="mic"||m,style:u==="recording"&&v!=="mic"||m?Xe:He,title:B?"Hold to record (walkie-talkie)":v==="mic"?"Stop recording":"Record",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="mic"?"#ef4444":"#171717"},children:"mic"})}),f.jsx("button",{onClick:()=>{u==="idle"&&!m?(T("round"),K()):u==="recording"&&v==="round"&&pe()},disabled:u==="editing"||u==="recording"&&v!=="round"||m,style:u==="editing"||u==="recording"&&v!=="round"||m?Xe:{...He,width:"28px",height:"28px",borderRadius:"50%",padding:0},title:"Click to record / click to stop",children:f.jsx("span",{style:{display:"block",width:"14px",height:"14px",borderRadius:"50%",background:u==="recording"&&v==="round"?"#171717":"#ef4444",transition:"background 0.15s"}})}),f.jsx("button",{onClick:()=>{v==="startover"?pe():u==="editing"&&(T("startover"),me())},disabled:u==="idle"||u==="recording"&&v!=="startover"||m,style:u==="idle"||u==="recording"&&v!=="startover"||m?Xe:He,title:v==="startover"?"Stop recording":"Start over",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[a,M.total>0&&M.completed<M.total&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[f.jsx("button",{onClick:()=>j(!B),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:B?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:B?"Auto-transcribe ON":"Auto-transcribe OFF",children:f.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:B?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),f.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),f.jsx("button",{onClick:()=>{u==="editing"&&de.current&&at(de.current)},disabled:u!=="editing",style:u!=="editing"?Xe:He,title:"Transcribe audio",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:B?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&f.jsx("button",{onClick:Ye,disabled:u!=="editing",style:u!=="editing"?Xe:He,title:"Save recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&f.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:f.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Yg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,onAudioSave:o,placeholder:a="Type or record...",className:l="",rows:u,llmClient:c,graphClient:d,nodeId:h,audioFilename:p,existingAudio:g,existingVoice:m,onAudioGenerated:x,onGenerateTTS:_,audioUrl:b,voice:S="coral",onVoiceChange:C,generateButton:k,generatePrompt:E,generateSourceText:v,generateSourceError:T}){const[B,j]=y.useState(!1),[N,R]=y.useState(!1),[M,w]=y.useState(""),[D,F]=y.useState(!1),[I,q]=y.useState(!1),[Z,te]=y.useState(null),[W,Q]=y.useState(m||S),[H,ie]=y.useState(g),[ue,de]=y.useState(Date.now()),we=y.useRef(null),fe=y.useRef(null),Ce=!!(c&&d&&h&&p);y.useEffect(()=>{g!==void 0&&ie(g)},[g]),y.useEffect(()=>{m!==void 0&&Q(m)},[m]);const O=Ce&&H&&d&&h?`${d.getFileUrl(h,H)}?v=${ue}`:b,je=se=>{t(e?`${e}
|
|
184
184
|
|
|
185
|
-
${L}`:L)},je=async L=>{if(!(!(typeof e=="string"?e:"").trim()||B||!s)){j(!0),R(!1);try{const ze=await s(L,e);t(ze)}catch(ze){console.error(`${L} failed:`,ze)}finally{j(!1)}}},ye=()=>{setTimeout(()=>{var L;(L=De.current)!=null&&L.contains(document.activeElement)||R(!1)},150)},Se=async()=>{if(!(!D.trim()||B||!i)){j(!0);try{const L=await i(D,e);t(L),F("")}catch(L){console.error("AI prompt failed:",L)}finally{j(!1)}}},Me=async()=>{if(!(typeof e=="string"?e:"").trim()||z)return;if(!(Ce||_)){console.warn("TTS: No generation mode available",{integratedTTS:Ce,hasCallback:!!_,llmClient:!!c,graphClient:!!d,nodeId:h,audioFilename:p}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}O.current&&(O.current.pause(),O.current.currentTime=0),q(!0);try{if(Ce&&c&&d&&h&&p){console.log("TTS: Generating audio...",{voice:H,textLength:e.length});const ze=await c.tts(e,{voice:H});console.log("TTS: Audio generated, uploading...",{audioLength:ze==null?void 0:ze.length});const Ke=atob(ze),X=new Uint8Array(Ke.length);for(let we=0;we<Ke.length;we++)X[we]=Ke.charCodeAt(we);const Z=new Blob([X],{type:"audio/mpeg"}),ce=new File([Z],p,{type:"audio/mpeg"});await d.uploadFile(h,p,ce),console.log("TTS: Upload complete",{nodeId:h,audioFilename:p}),fe(Date.now()),ue(p),x==null||x(p,H)}else _&&(await _(e,H),fe(Date.now()))}catch(ze){console.error("TTS generation failed:",ze),alert("Erreur TTS: "+(ze instanceof Error?ze.message:"Erreur inconnue"))}finally{q(!1)}},Oe=async()=>{if(!(!c||!E||J)){if(!(v!=null&&v.trim())){G(T||"Le texte source est requis pour la génération.");return}te(!0),G(null);try{const L=await c.chat([{role:"system",content:E},{role:"user",content:v}]);t(L)}catch(L){G(L instanceof Error?L.message:"Erreur de génération")}finally{te(!1)}}},ge=L=>{se(L),C==null||C(L)};return f.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${l}`,children:[f.jsx(Zc,{onComplete:o||(()=>{}),onTranscribe:n,onTranscriptionComplete:Fe,hideSaveButton:!o,variant:"div",extraControls:f.jsxs(f.Fragment,{children:[i&&f.jsx("button",{type:"button",onClick:Se,disabled:B||!D.trim(),style:{padding:"4px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",opacity:B||!D.trim()?.3:1},title:"Envoyer le prompt AI",children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:B?"#9333ea":"#171717"},children:B?"hourglass_empty":"smart_toy"})}),i&&f.jsx("button",{type:"button",onClick:()=>w(!M),style:{padding:"4px 8px",marginRight:"6px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},title:M?"Masquer le prompt":"Afficher le prompt AI",children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#171717",transform:M?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:"chevron_right"})}),s&&f.jsxs("div",{className:"relative",ref:De,style:{display:"inline-flex"},children:[f.jsx("button",{type:"button",onClick:()=>R(!N),disabled:B||!(typeof e=="string"?e:"").trim(),style:{padding:"4px 6px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",gap:"2px",fontSize:"11px",color:"#9333ea",opacity:B||!(typeof e=="string"?e:"").trim()?.4:1},children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"})}),N&&!B&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:ye,children:[f.jsxs("button",{type:"button",onClick:()=>je("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Restructure"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),f.jsxs("button",{type:"button",onClick:()=>je("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Proofread"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),f.jsxs("button",{type:"button",onClick:()=>je("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Rewrite"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})}),i&&M&&f.jsx("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200 px-2",children:f.jsx("textarea",{value:D,onChange:L=>F(L.target.value),onKeyDown:L=>{L.stopPropagation(),L.key==="Enter"&&L.ctrlKey&&(L.preventDefault(),Se())},placeholder:"Instructions AI... (Ctrl+Enter)",disabled:B,rows:3,className:"flex-1 py-2 text-sm border-0 resize-y min-h-[60px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50",autoFocus:!0})}),(r||(typeof e=="string"?e:"").trim()||Ce||_||k)&&f.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),k&&c&&E&&f.jsxs("button",{type:"button",onClick:Oe,disabled:J,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:k.label,children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:J?"hourglass_empty":k.icon||"auto_awesome"}),k.label]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?e:"").trim()&&f.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:f.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),(Ce||_)&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:H,onChange:L=>ge(L.target.value),disabled:z,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(L=>f.jsxs("option",{value:L.id,children:[L.name," - ",L.description]},L.id))}),f.jsx("button",{type:"button",onClick:Me,disabled:z||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:z?"Génération en cours...":"Générer audio TTS",children:f.jsx("span",{className:`material-icons ${z?"animate-pulse text-blue-600":re?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:z?"hourglass_empty":"record_voice_over"})}),re&&f.jsxs(f.Fragment,{children:[f.jsx("audio",{ref:O,src:re,controls:!0,className:"h-6 w-32"},_e),f.jsx("button",{type:"button",onClick:()=>{O.current&&O.current.pause(),ue(void 0),x==null||x("",H)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:f.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]})]})]}),f.jsx("textarea",{value:e,onChange:L=>t(L.target.value),onKeyDown:L=>L.stopPropagation(),placeholder:a,rows:u,disabled:B||J,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),W&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),f.jsx("p",{className:"text-sm text-neutral-600",children:W})]})]}),f.jsx("div",{className:"mt-4 flex justify-end",children:f.jsx("button",{type:"button",onClick:()=>G(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Qg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[h,p]=y.useState(null),[g,m]=y.useState(n),[x,_]=y.useState(0),[b,S]=y.useState({x:0,y:0,width:100,height:100}),[C,k]=y.useState(!1),[E,v]=y.useState(null),[T,B]=y.useState({x:0,y:0}),[j,N]=y.useState({x:0,y:0,width:100,height:100}),R=o==="dark",M=y.useCallback(()=>{const O=u.current;return O?x===90||x===270?{width:O.height,height:O.width}:{width:O.width,height:O.height}:{width:100,height:100}},[x]),w=y.useCallback((O,Ce)=>{const re=O/Ce,Fe=.05;for(const[je,ye]of Object.entries(gs))if(ye!==null&&Math.abs(re-ye)/ye<Fe)return je;return"free"},[]);y.useEffect(()=>{const O=new Image;O.crossOrigin="anonymous",O.onload=()=>{u.current=O;const Ce=w(O.width,O.height);m(Ce),d(!1)},O.onerror=()=>{p("Failed to load image"),d(!1)},O.src=r},[r,w]);const D=y.useCallback(()=>{const{width:O,height:Ce}=M(),re=gs[g];if(re===null){S({x:0,y:0,width:100,height:100});return}const Fe=O/Ce;let je,ye;Fe>re?(ye=100,je=re/Fe*100):(je=100,ye=Fe/re*100);const Se=(100-je)/2,Me=(100-ye)/2;S({x:Se,y:Me,width:je,height:ye})},[g,M]);y.useEffect(()=>{u.current&&D()},[g,x,D]),y.useEffect(()=>{const O=l.current,Ce=u.current;if(!O||!Ce||c)return;const re=O.getContext("2d");if(!re)return;const Fe=a.current;if(!Fe)return;const je=Fe.clientWidth,ye=Fe.clientHeight-140,{width:Se,height:Me}=M(),Oe=Se/Me;let ge,L;je/ye>Oe?(L=Math.min(ye,Me),ge=L*Oe):(ge=Math.min(je,Se),L=ge/Oe),ge>je&&(ge=je,L=ge/Oe),L>ye&&(L=ye,ge=L*Oe),O.width=ge,O.height=L,re.clearRect(0,0,ge,L),re.save(),re.translate(ge/2,L/2),re.rotate(x*Math.PI/180);let ze,Ke;x===90||x===270?(ze=L,Ke=ge):(ze=ge,Ke=L),re.drawImage(Ce,-ze/2,-Ke/2,ze,Ke),re.restore(),re.fillStyle="rgba(0, 0, 0, 0.6)";const X=b.x/100*ge,Z=b.y/100*L,ce=b.width/100*ge,we=b.height/100*L;re.fillRect(0,0,ge,Z),re.fillRect(0,Z+we,ge,L-Z-we),re.fillRect(0,Z,X,we),re.fillRect(X+ce,Z,ge-X-ce,we),re.strokeStyle="#fff",re.lineWidth=2,re.strokeRect(X,Z,ce,we),re.strokeStyle="rgba(255, 255, 255, 0.3)",re.lineWidth=1,re.beginPath(),re.moveTo(X+ce/3,Z),re.lineTo(X+ce/3,Z+we),re.moveTo(X+ce*2/3,Z),re.lineTo(X+ce*2/3,Z+we),re.moveTo(X,Z+we/3),re.lineTo(X+ce,Z+we/3),re.moveTo(X,Z+we*2/3),re.lineTo(X+ce,Z+we*2/3),re.stroke();const Be=14;re.fillStyle="#fff",re.strokeStyle="#333",re.lineWidth=1,[{x:X,y:Z},{x:X+ce,y:Z},{x:X,y:Z+we},{x:X+ce,y:Z+we}].forEach(Et=>{re.fillRect(Et.x-Be/2,Et.y-Be/2,Be,Be),re.strokeRect(Et.x-Be/2,Et.y-Be/2,Be,Be)})},[b,x,c,M]);const F=O=>{const Ce=l.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Fe=(O.clientX-re.left)/re.width*100,je=(O.clientY-re.top)/re.height*100,ye=4,Se=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Me of Se)if(Math.abs(Fe-Me.x)<ye&&Math.abs(je-Me.y)<ye){v(Me.name),B({x:Fe,y:je}),N({...b});return}Fe>=b.x&&Fe<=b.x+b.width&&je>=b.y&&je<=b.y+b.height&&(k(!0),B({x:Fe,y:je}),N({...b}))},z=O=>{const Ce=l.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Fe=(O.clientX-re.left)/re.width*100,je=(O.clientY-re.top)/re.height*100;if(C){const ye=Fe-T.x,Se=je-T.y;let Me=j.x+ye,Oe=j.y+Se;Me=Math.max(0,Math.min(Me,100-j.width)),Oe=Math.max(0,Math.min(Oe,100-j.height)),S({...j,x:Me,y:Oe})}else if(E){const ye=gs[g],{width:Se,height:Me}=M(),Oe=Se/Me,ge=ye?ye/Oe:null;let L={...j};const ze=Fe-T.x,Ke=je-T.y;if(E==="se")L.width=Math.max(10,Math.min(100-L.x,j.width+ze)),ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge)):L.height=Math.max(10,Math.min(100-L.y,j.height+Ke));else if(E==="sw"){const X=-ze,Z=Math.max(10,j.width+X),ce=j.x+j.width-Z;ce>=0&&(L.width=Z,L.x=ce,ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge,L.x=j.x+j.width-L.width)):L.height=Math.max(10,Math.min(100-L.y,j.height+Ke)))}else if(E==="ne")if(L.width=Math.max(10,Math.min(100-L.x,j.width+ze)),ge){const X=L.width/ge,Z=j.y+j.height-X;Z>=0?(L.height=X,L.y=Z):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge)}else{const X=-Ke,Z=Math.max(10,j.height+X),ce=j.y+j.height-Z;ce>=0&&(L.height=Z,L.y=ce)}else if(E==="nw"){const X=-ze,Z=Math.max(10,j.width+X),ce=j.x+j.width-Z;if(ce>=0)if(L.width=Z,L.x=ce,ge){const we=L.width/ge,Be=j.y+j.height-we;Be>=0?(L.height=we,L.y=Be):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge,L.x=j.x+j.width-L.width)}else{const we=-Ke,Be=Math.max(10,j.height+we),Qe=j.y+j.height-Be;Qe>=0&&(L.height=Be,L.y=Qe)}}L.x=Math.max(0,L.x),L.y=Math.max(0,L.y),L.width=Math.min(L.width,100-L.x),L.height=Math.min(L.height,100-L.y),S(L)}},q=()=>{k(!1),v(null)},J=O=>{_(Ce=>O==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const O=u.current;if(!O)return;const{width:Ce,height:re}=M(),Fe=b.x/100*Ce,je=b.y/100*re,ye=b.width/100*Ce,Se=b.height/100*re,Me=document.createElement("canvas"),Oe=Me.getContext("2d");if(!Oe)return;Me.width=ye,Me.height=Se;const ge=document.createElement("canvas"),L=ge.getContext("2d");L&&(ge.width=Ce,ge.height=re,L.save(),L.translate(Ce/2,re/2),L.rotate(x*Math.PI/180),L.drawImage(O,-O.width/2,-O.height/2,O.width,O.height),L.restore(),Oe.drawImage(ge,Fe,je,ye,Se,0,0,ye,Se),Me.toBlob(ze=>{ze&&e(ze)},s,i))},W={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:R?"#1a1a1a":"#f5f5f5",overflow:"hidden"},G={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${R?"#333":"#ddd"}`,background:R?"#242424":"#fff",flexShrink:0},se={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},le={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},ue={...le,background:"#E67E22",color:"#fff"},_e={...le,background:R?"#333":"#e5e5e5",color:R?"#fff":"#333"},fe={padding:"10px",borderRadius:"8px",border:"none",background:R?"#333":"#e5e5e5",color:R?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},De=O=>({padding:"8px 14px",borderRadius:"6px",border:O?"2px solid #E67E22":"2px solid transparent",background:O?"#E67E22":R?"#333":"#e5e5e5",color:O?"#fff":R?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?f.jsx("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:f.jsx("div",{style:{color:R?"#aaa":"#666"},children:"Loading image..."})}):h?f.jsxs("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{color:"#ef4444"},children:h}),t&&f.jsx("button",{onClick:t,style:{..._e,marginTop:"16px"},children:"Close"})]}):f.jsxs("div",{ref:a,style:W,children:[f.jsx("div",{style:G,children:f.jsx("canvas",{ref:l,style:{cursor:C?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:z,onMouseUp:q,onMouseLeave:q})}),f.jsxs("div",{style:H,children:[f.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(O=>f.jsx("button",{onClick:()=>m(O),style:De(g===O),children:O==="free"?"Libre":O},O))}),f.jsxs("div",{style:se,children:[f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>J("left"),style:fe,title:"Rotate left",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),f.jsx("button",{onClick:()=>J("right"),style:fe,title:"Rotate right",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&f.jsx("button",{onClick:t,style:_e,children:"Annuler"}),f.jsx("button",{onClick:te,style:ue,children:"Enregistrer"})]})]})]})]})}var Jg={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Xg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Xg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Zg(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Zg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Jg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function e0(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function t0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function ed(r){var e=_i(r);return(e.local?t0:e0)(e)}function r0(){}function ua(r){return r==null?r0:function(){return this.querySelector(r)}}function n0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Tt(n,this._parents)}function s0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function i0(){return[]}function td(r){return r==null?i0:function(){return this.querySelectorAll(r)}}function o0(r){return function(){return s0(r.apply(this,arguments))}}function a0(r){typeof r=="function"?r=o0(r):r=td(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Tt(n,s)}function rd(r){return function(){return this.matches(r)}}function nd(r){return function(e){return e.matches(r)}}var l0=Array.prototype.find;function u0(r){return function(){return l0.call(this.children,r)}}function c0(){return this.firstElementChild}function d0(r){return this.select(r==null?c0:u0(typeof r=="function"?r:nd(r)))}var f0=Array.prototype.filter;function h0(){return Array.from(this.children)}function p0(r){return function(){return f0.call(this.children,r)}}function g0(r){return this.selectAll(r==null?h0:p0(typeof r=="function"?r:nd(r)))}function m0(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Tt(n,this._parents)}function sd(r){return new Array(r.length)}function y0(){return new Tt(this._enter||this._groups.map(sd),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function x0(r){return function(){return r}}function b0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function v0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,h=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(h[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(h[a])===l&&(s[a]=l)}function _0(r){return r.__data__}function w0(r,e){if(!arguments.length)return Array.from(this,_0);var t=e?v0:b0,n=this._parents,s=this._groups;typeof r!="function"&&(r=x0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],h=d.length,p=C0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),_=l[u]=new Array(h);t(c,d,m,x,_,p,e);for(var b=0,S=0,C,k;b<g;++b)if(C=m[b]){for(b>=S&&(S=b+1);!(k=x[S])&&++S<g;);C._next=k||null}}return o=new Tt(o,n),o._enter=a,o._exit=l,o}function C0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function S0(){return new Tt(this._exit||this._groups.map(sd),this._parents)}function k0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function E0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,h=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(h[g]=p);for(;l<s;++l)a[l]=t[l];return new Tt(a,this._parents)}function D0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function A0(r){r||(r=T0);function e(d,h){return d&&h?r(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Tt(s,this._parents).order()}function T0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function N0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function B0(){return Array.from(this)}function j0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function M0(){let r=0;for(const e of this)++r;return r}function R0(){return!this.node()}function F0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function L0(r){return function(){this.removeAttribute(r)}}function P0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function I0(r,e){return function(){this.setAttribute(r,e)}}function z0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function $0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function q0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?P0:L0:typeof e=="function"?t.local?$0:O0:t.local?z0:I0)(t,e))}function id(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function U0(r){return function(){this.style.removeProperty(r)}}function W0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function H0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function V0(r,e,t){return arguments.length>1?this.each((e==null?U0:typeof e=="function"?H0:W0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||id(r).getComputedStyle(r,null).getPropertyValue(e)}function G0(r){return function(){delete this[r]}}function K0(r,e){return function(){this[r]=e}}function Y0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Q0(r,e){return arguments.length>1?this.each((e==null?G0:typeof e=="function"?Y0:K0)(r,e)):this.node()[r]}function od(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ad(r)}function ad(r){this._node=r,this._names=od(r.getAttribute("class")||"")}ad.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ud(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function J0(r){return function(){ld(this,r)}}function X0(r){return function(){ud(this,r)}}function Z0(r,e){return function(){(e.apply(this,arguments)?ld:ud)(this,r)}}function em(r,e){var t=od(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?Z0:e?J0:X0)(t,e))}function tm(){this.textContent=""}function rm(r){return function(){this.textContent=r}}function nm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function sm(r){return arguments.length?this.each(r==null?tm:(typeof r=="function"?nm:rm)(r)):this.node().textContent}function im(){this.innerHTML=""}function om(r){return function(){this.innerHTML=r}}function am(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function lm(r){return arguments.length?this.each(r==null?im:(typeof r=="function"?am:om)(r)):this.node().innerHTML}function um(){this.nextSibling&&this.parentNode.appendChild(this)}function cm(){return this.each(um)}function dm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fm(){return this.each(dm)}function hm(r){var e=typeof r=="function"?r:ed(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function pm(){return null}function gm(r,e){var t=typeof r=="function"?r:ed(r),n=e==null?pm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function mm(){var r=this.parentNode;r&&r.removeChild(this)}function ym(){return this.each(mm)}function xm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function vm(r){return this.select(r?bm:xm)}function _m(r){return arguments.length?this.property("__data__",r):this.node().__data__}function wm(r){return function(e){r.call(this,e,this.__data__)}}function Cm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Sm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function km(r,e,t){return function(){var n=this.__on,s,i=wm(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function Em(r,e,t){var n=Cm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?km:Sm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function cd(r,e,t){var n=id(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function Dm(r,e){return function(){return cd(this,r,e)}}function Am(r,e){return function(){return cd(this,r,e.apply(this,arguments))}}function Tm(r,e){return this.each((typeof e=="function"?Am:Dm)(r,e))}function*Nm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var dd=[null];function Tt(r,e){this._groups=r,this._parents=e}function ss(){return new Tt([[document.documentElement]],dd)}function Bm(){return this}Tt.prototype=ss.prototype={constructor:Tt,select:n0,selectAll:a0,selectChild:d0,selectChildren:g0,filter:m0,data:w0,enter:y0,exit:S0,join:k0,merge:E0,selection:Bm,order:D0,sort:A0,call:N0,nodes:B0,node:j0,size:M0,empty:R0,each:F0,attr:q0,style:V0,property:Q0,classed:em,text:sm,html:lm,raise:cm,lower:fm,append:hm,insert:gm,remove:ym,clone:vm,datum:_m,on:Em,dispatch:Tm,[Symbol.iterator]:Nm};function Ft(r){return typeof r=="string"?new Tt([[document.querySelector(r)]],[document.documentElement]):new Tt([[r]],dd)}function jm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=jm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function Mm(r){var e=r.document.documentElement,t=Ft(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Rm(r,e){var t=r.document.documentElement,n=Ft(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function fd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fm=/^#([0-9a-f]{3,8})$/,Lm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Pm=new RegExp(`^rgb\\(${Vt},${Vt},${Vt}\\)$`),Im=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),zm=new RegExp(`^rgba\\(${Vt},${Vt},${Vt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Vt},${Vt}\\)$`),$m=new RegExp(`^hsla\\(${qn},${Vt},${Vt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:qm,formatHsl:Um,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function qm(){return this.rgb().formatHex8()}function Um(){return hd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Fm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new Ct(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Lm.exec(r))?new Ct(e[1],e[2],e[3],1):(e=Pm.exec(r))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Im.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=zm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=$m.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new Ct(NaN,NaN,NaN,0):null}function Wl(r){return new Ct(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new Ct(r,e,t,n)}function Wm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new Ct(r.r,r.g,r.b,r.opacity)):new Ct}function wo(r,e,t,n){return arguments.length===1?Wm(r):new Ct(r,e,t,n??1)}function Ct(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(Ct,wo,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ct(Tr(this.r),Tr(this.g),Tr(this.b),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Hm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Hm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Lt(r,e,t,n)}function hd(r){if(r instanceof Lt)return new Lt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Lt;if(r instanceof Lt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Lt(o,a,l,r.opacity)}function Vm(r,e,t,n){return arguments.length===1?hd(r):new Lt(r,e,t,n??1)}function Lt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Lt,Vm,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Lt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Lt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new Ct(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Lt(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const pd=r=>()=>r;function Gm(r,e){return function(t){return r+t*e}}function Km(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Ym(r){return(r=+r)==1?gd:function(e,t){return t-e?Km(e,t,r):pd(isNaN(e)?t:e)}}function gd(r,e){var t=e-r;return t?Gm(r,t):pd(isNaN(r)?e:r)}const Yl=function r(e){var t=Ym(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=gd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function dr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Qm(r){return function(){return r}}function Jm(r){return function(e){return r(e)+""}}function Xm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:dr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Jm(l[0].x):Qm(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function md(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Zm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:md(e.a,e.b,e.c,e.d,e.e,e.f)}function ey(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,md(r.a,r.b,r.c,r.d,r.e,r.f))}function yd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(u,c,d,h){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:dr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function a(u,c,d,h){u!==c?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:dr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function l(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(u,c){var d=[],h=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,h),o(u.rotate,c.rotate,d,h),a(u.skewX,c.skewX,d,h),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,h),u=c=null,function(p){for(var g=-1,m=h.length,x;++g<m;)d[(x=h[g]).i]=x.x(p);return d.join("")}}}var ty=yd(Zm,"px, ","px)","deg)"),ry=yd(ey,", ",")",")"),ny=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function sy(r){return((r=Math.exp(r))-1/r)/2}function iy(r){return((r=Math.exp(2*r))-1)/(r+1)}const oy=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],h=o[2],p=c-a,g=d-l,m=p*p+g*g,x,_;if(m<ny)_=Math.log(h/u)/e,x=function(v){return[a+v*p,l+v*g,u*Math.exp(e*v*_)]};else{var b=Math.sqrt(m),S=(h*h-u*u+n*m)/(2*u*t*b),C=(h*h-u*u-n*m)/(2*h*t*b),k=Math.log(Math.sqrt(S*S+1)-S),E=Math.log(Math.sqrt(C*C+1)-C);_=(E-k)/e,x=function(v){var T=v*_,B=Jl(k),j=u/(t*b)*(B*iy(e*T+k)-sy(k));return[a+j*p,l+j*g,u*B/Jl(e*T+k)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,xd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,bd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(bd(ay),Lr=Wn.now()+wi)}function ay(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=vd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function vd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ly(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{ly()}finally{nn=0,cy(),Lr=0}}function uy(){var r=Wn.now(),e=r-ei;e>xd&&(wi-=e,ei=r)}function cy(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(uy,xd)),nn=1,bd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var dy=la("start","end","cancel","interrupt"),fy=[],_d=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;hy(r,t,{name:e,index:n,group:s,on:dy,tween:fy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_d})}function ha(r,e){var t=$t(r,e);if(t.state>_d)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=$t(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function $t(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function hy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=vd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,h,p;if(t.state!==eu)return l();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(h=t.tween.length),c=0,d=-1;c<h;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),t.state=Do,1),d=-1,h=s.length;++d<h;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),l())}function l(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function py(r){return this.each(function(){Es(this,r)})}function gy(r,e){var t,n;return function(){var s=Jt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function my(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Jt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function yy(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=$t(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?gy:my)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Jt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return $t(s,n).value[e]}}function wd(r,e){var t;return(typeof e=="number"?dr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Xm)(r,e)}function xy(r){return function(){this.removeAttribute(r)}}function by(r){return function(){this.removeAttributeNS(r.space,r.local)}}function vy(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function _y(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function wy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Cy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Sy(r,e){var t=_i(r),n=t==="transform"?ry:wd;return this.attrTween(r,typeof e=="function"?(t.local?Cy:wy)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?by:xy)(t):(t.local?_y:vy)(t,n,e))}function ky(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function Ey(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Ey(r,i)),t}return s._value=e,s}function Ay(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Ty(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?Dy:Ay)(n,e))}function Ny(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function By(r,e){return e=+e,function(){ha(this,r).delay=e}}function jy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ny:By)(e,r)):$t(this.node(),e).delay}function My(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function Ry(r,e){return e=+e,function(){Jt(this,r).duration=e}}function Fy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?My:Ry)(e,r)):$t(this.node(),e).duration}function Ly(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function Py(r){var e=this._id;return arguments.length?this.each(Ly(e,r)):$t(this.node(),e).ease}function Iy(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function zy(r){if(typeof r!="function")throw new Error;return this.each(Iy(this._id,r))}function Oy(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new sr(n,this._parents,this._name,this._id)}function $y(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),h,p=0;p<c;++p)(h=l[p]||u[p])&&(d[p]=h);for(;a<n;++a)o[a]=e[a];return new sr(o,this._parents,this._name,this._id)}function qy(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Uy(r,e,t){var n,s,i=qy(e)?ha:Jt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function Wy(r,e){var t=this._id;return arguments.length<2?$t(this.node(),t).on.on(r):this.each(Uy(t,r,e))}function Hy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Vy(){return this.on("end.remove",Hy(this._id))}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,h=0;h<l;++h)(c=a[h])&&(d=r.call(c,c.__data__,h,a))&&("__data__"in c&&(d.__data__=c.__data__),u[h]=d,Ci(u[h],e,t,h,u,$t(c,t)));return new sr(i,this._parents,e,t)}function Ky(r){var e=this._name,t=this._id;typeof r!="function"&&(r=td(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var h=r.call(c,c.__data__,d,l),p,g=$t(c,t),m=0,x=h.length;m<x;++m)(p=h[m])&&Ci(p,e,t,m,h,g);i.push(h),o.push(c)}return new sr(i,o,e,t)}var Yy=ss.prototype.constructor;function Qy(){return new Yy(this._groups,this._parents)}function Jy(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function Cd(r){return function(){this.style.removeProperty(r)}}function Xy(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function Zy(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function e2(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Jt(this,r),u=l.on,c=l.value[i]==null?a||(a=Cd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function t2(r,e,t){var n=(r+="")=="transform"?ty:wd;return e==null?this.styleTween(r,Jy(r,n)).on("end.style."+r,Cd(r)):typeof e=="function"?this.styleTween(r,Zy(r,n,pa(this,"style."+r,e))).each(e2(this._id,r)):this.styleTween(r,Xy(r,n,e),t).on("end.style."+r,null)}function r2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function n2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&r2(r,o,t)),n}return i._value=e,i}function s2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,n2(r,e,t??""))}function i2(r){return function(){this.textContent=r}}function o2(r){return function(){var e=r(this);this.textContent=e??""}}function a2(r){return this.tween("text",typeof r=="function"?o2(pa(this,"text",r)):i2(r==null?"":r+""))}function l2(r){return function(e){this.textContent=r.call(this,e)}}function u2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&l2(s)),e}return n._value=r,n}function c2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,u2(r))}function d2(){for(var r=this._name,e=this._id,t=Sd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=$t(l,e);Ci(l,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new sr(n,this._parents,r,t)}function f2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={value:function(){--s===0&&i()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var h2=0;function sr(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Sd(){return++h2}var er=ss.prototype;sr.prototype={constructor:sr,select:Gy,selectAll:Ky,selectChild:er.selectChild,selectChildren:er.selectChildren,filter:Oy,merge:$y,selection:Qy,transition:d2,call:er.call,nodes:er.nodes,node:er.node,size:er.size,empty:er.empty,each:er.each,on:Wy,attr:Sy,attrTween:Ty,style:t2,styleTween:s2,text:a2,textTween:c2,remove:Vy,tween:yy,delay:jy,duration:Fy,ease:Py,easeVarying:zy,end:f2,[Symbol.iterator]:er[Symbol.iterator]};function p2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var g2={time:null,delay:0,duration:250,ease:p2};function m2(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function y2(r){var e,t;r instanceof sr?(e=r._id,r=r._name):(e=Sd(),(t=g2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||m2(l,e));return new sr(n,this._parents,r,e)}ss.prototype.interrupt=py;ss.prototype.transition=y2;const bs=r=>()=>r;function x2(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function rr(r,e,t){this.k=r,this.x=e,this.y=t}rr.prototype={constructor:rr,scale:function(r){return r===1?this:new rr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new rr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new rr(1,0,0);rr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function b2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function v2(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function _2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function w2(){return navigator.maxTouchPoints||"ontouchstart"in this}function C2(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function S2(){var r=b2,e=v2,t=C2,n=_2,s=w2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=oy,u=la("start","zoom","end"),c,d,h,p=500,g=150,m=0,x=10;function _(w){w.property("__zoom",ru).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,D,F,z){var q=w.selection?w.selection():w;q.property("__zoom",ru),w!==q?k(w,D,F,z):q.interrupt().each(function(){E(this,arguments).event(z).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},_.scaleBy=function(w,D,F,z){_.scaleTo(w,function(){var q=this.__zoom.k,J=typeof D=="function"?D.apply(this,arguments):D;return q*J},F,z)},_.scaleTo=function(w,D,F,z){_.transform(w,function(){var q=e.apply(this,arguments),J=this.__zoom,te=F==null?C(q):typeof F=="function"?F.apply(this,arguments):F,W=J.invert(te),G=typeof D=="function"?D.apply(this,arguments):D;return t(S(b(J,G),te,W),q,o)},F,z)},_.translateBy=function(w,D,F,z){_.transform(w,function(){return t(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,z)},_.translateTo=function(w,D,F,z,q){_.transform(w,function(){var J=e.apply(this,arguments),te=this.__zoom,W=z==null?C(J):typeof z=="function"?z.apply(this,arguments):z;return t(ri.translate(W[0],W[1]).scale(te.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof F=="function"?-F.apply(this,arguments):-F),J,o)},z,q)};function b(w,D){return D=Math.max(i[0],Math.min(i[1],D)),D===w.k?w:new rr(D,w.x,w.y)}function S(w,D,F){var z=D[0]-F[0]*w.k,q=D[1]-F[1]*w.k;return z===w.x&&q===w.y?w:new rr(w.k,z,q)}function C(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,D,F,z){w.on("start.zoom",function(){E(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(z).end()}).tween("zoom",function(){var q=this,J=arguments,te=E(q,J).event(z),W=e.apply(q,J),G=F==null?C(W):typeof F=="function"?F.apply(q,J):F,H=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),se=q.__zoom,le=typeof D=="function"?D.apply(q,J):D,ue=l(se.invert(G).concat(H/se.k),le.invert(G).concat(H/le.k));return function(_e){if(_e===1)_e=le;else{var fe=ue(_e),De=H/fe[2];_e=new rr(De,G[0]-fe[0]*De,G[1]-fe[1]*De)}te.zoom(null,_e)}})}function E(w,D,F){return!F&&w.__zooming||new v(w,D)}function v(w,D){this.that=w,this.args=D,this.active=0,this.sourceEvent=null,this.extent=e.apply(w,D),this.taps=0}v.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,D){return this.mouse&&w!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var D=Ft(this.that).datum();u.call(w,this.that,new x2(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),D)}};function T(w,...D){if(!r.apply(this,arguments))return;var F=E(this,D).event(w),z=this.__zoom,q=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,n.apply(this,arguments)))),J=wr(w);if(F.wheel)(F.mouse[0][0]!==J[0]||F.mouse[0][1]!==J[1])&&(F.mouse[1]=z.invert(F.mouse[0]=J)),clearTimeout(F.wheel);else{if(z.k===q)return;F.mouse=[J,z.invert(J)],Es(this),F.start()}xn(w),F.wheel=setTimeout(te,g),F.zoom("mouse",t(S(b(z,q),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function B(w,...D){if(h||!r.apply(this,arguments))return;var F=w.currentTarget,z=E(this,D,!0).event(w),q=Ft(w.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",H,!0),J=wr(w,F),te=w.clientX,W=w.clientY;Mm(w.view),Wi(w),z.mouse=[J,this.__zoom.invert(J)],Es(this),z.start();function G(se){if(xn(se),!z.moved){var le=se.clientX-te,ue=se.clientY-W;z.moved=le*le+ue*ue>m}z.event(se).zoom("mouse",t(S(z.that.__zoom,z.mouse[0]=wr(se,F),z.mouse[1]),z.extent,o))}function H(se){q.on("mousemove.zoom mouseup.zoom",null),Rm(se.view,z.moved),xn(se),z.event(se).end()}}function j(w,...D){if(r.apply(this,arguments)){var F=this.__zoom,z=wr(w.changedTouches?w.changedTouches[0]:w,this),q=F.invert(z),J=F.k*(w.shiftKey?.5:2),te=t(S(b(F,J),z,q),e.apply(this,D),o);xn(w),a>0?Ft(this).transition().duration(a).call(k,te,z,w):Ft(this).call(_.transform,te,z,w)}}function N(w,...D){if(r.apply(this,arguments)){var F=w.touches,z=F.length,q=E(this,D,w.changedTouches.length===z).event(w),J,te,W,G;for(Wi(w),te=0;te<z;++te)W=F[te],G=wr(W,this),G=[G,this.__zoom.invert(G),W.identifier],q.touch0?!q.touch1&&q.touch0[2]!==G[2]&&(q.touch1=G,q.taps=0):(q.touch0=G,J=!0,q.taps=1+!!c);c&&(c=clearTimeout(c)),J&&(q.taps<2&&(d=G[0],c=setTimeout(function(){c=null},p)),Es(this),q.start())}}function R(w,...D){if(this.__zooming){var F=E(this,D).event(w),z=w.changedTouches,q=z.length,J,te,W,G;for(xn(w),J=0;J<q;++J)te=z[J],W=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=W:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=W);if(te=F.that.__zoom,F.touch1){var H=F.touch0[0],se=F.touch0[1],le=F.touch1[0],ue=F.touch1[1],_e=(_e=le[0]-H[0])*_e+(_e=le[1]-H[1])*_e,fe=(fe=ue[0]-se[0])*fe+(fe=ue[1]-se[1])*fe;te=b(te,Math.sqrt(_e/fe)),W=[(H[0]+le[0])/2,(H[1]+le[1])/2],G=[(se[0]+ue[0])/2,(se[1]+ue[1])/2]}else if(F.touch0)W=F.touch0[0],G=F.touch0[1];else return;F.zoom("touch",t(S(te,W,G),F.extent,o))}}function M(w,...D){if(this.__zooming){var F=E(this,D).event(w),z=w.changedTouches,q=z.length,J,te;for(Wi(w),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),J=0;J<q;++J)te=z[J],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var W=Ft(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(n=typeof w=="function"?w:bs(+w),_):n},_.filter=function(w){return arguments.length?(r=typeof w=="function"?w:bs(!!w),_):r},_.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:bs(!!w),_):s},_.extent=function(w){return arguments.length?(e=typeof w=="function"?w:bs([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):e},_.scaleExtent=function(w){return arguments.length?(i[0]=+w[0],i[1]=+w[1],_):[i[0],i[1]]},_.translateExtent=function(w){return arguments.length?(o[0][0]=+w[0][0],o[1][0]=+w[1][0],o[0][1]=+w[0][1],o[1][1]=+w[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(w){return arguments.length?(t=w,_):t},_.duration=function(w){return arguments.length?(a=+w,_):a},_.interpolate=function(w){return arguments.length?(l=w,_):l},_.on=function(){var w=u.on.apply(u,arguments);return w===u?_:w},_.clickDistance=function(w){return arguments.length?(m=(w=+w)*w,_):Math.sqrt(m)},_.tapDistance=function(w){return arguments.length?(x=+w,_):x},_}function kd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=S2().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const S={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(S),o==null||o(S)});l.current=x;const _=Ft(a.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{l.current&&l.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=y.useCallback((x,_,b,S=!0)=>{if(!a.current||!l.current)return;const C=Ft(a.current),k=ri.translate(x,_).scale(b);C.call(l.current.transform,k)},[]),h=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,_=50)=>{if(!a.current||!l.current||x.length===0)return;const b=a.current,S=b.clientWidth,C=b.clientHeight;let k=1/0,E=1/0,v=-1/0,T=-1/0;for(const q of x){const J=q.width||200,te=q.height||100;k=Math.min(k,q.x),E=Math.min(E,q.y),v=Math.max(v,q.x+J),T=Math.max(T,q.y+te)}const B=v-k,j=T-E,N=(S-_*2)/B,R=(C-_*2)/j,M=Math.min(N,R,t),w=(k+v)/2,D=(E+T)/2,F=S/2-w*M,z=C/2-D*M;d(F,z,M,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:h,zoomOut:p,resetZoom:g,fitToContent:m}}function Ed(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),h=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((S,C)=>{const k=g.current;return{x:(S-k.x)/k.k,y:(C-k.y)/k.k}},[]),x=y.useCallback((S,C)=>{if(i)return;C.preventDefault(),C.stopPropagation();const k=C.currentTarget,E=parseFloat(k.dataset.x||"0"),v=parseFloat(k.dataset.y||"0");h.current={x:C.clientX,y:C.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},a(S),u(!0),d({x:0,y:0}),t==null||t(S)},[i,m,t]),_=y.useCallback(S=>{if(!l||!o||!h.current)return;const C=g.current,k=h.current,E=S.clientX-k.x,v=S.clientY-k.y,T=E/C.k,B=v/C.k,j=k.nodeX+T,N=k.nodeY+B;p.current={x:j,y:N},d({x:T,y:B}),n==null||n(o,j,N,T,B)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const S=p.current;s==null||s(o,S.x,S.y),a(null),u(!1),d({x:0,y:0}),h.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const S=k=>{_(k)},C=()=>{b()};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",C)}},[l,_,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:_,endDrag:b}}function Dd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?j=>{const N=typeof j=="function"?j(u):j;i==null||i(Array.from(N))}:a,[d,h]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),_=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{_.current=t},[t]);const b=y.useCallback((j,N)=>{const R=x.current;return{x:(j-R.x)/R.k,y:(N-R.y)/R.k}},[]),S=y.useCallback((j,N)=>{const R=_.current.get(j);if(!R)return!1;const M=R.width||200,w=R.height||100;return R.x<N.x+N.width&&R.x+M>N.x&&R.y<N.y+N.height&&R.y+w>N.y},[]),C=y.useCallback(j=>{if(n||j.target.closest("[data-qmap-node]"))return;j.preventDefault();const R=b(j.clientX,j.clientY);m.current=R,h({x:R.x,y:R.y,width:0,height:0}),g(!0),j.shiftKey||c(new Set)},[n,b]),k=y.useCallback(j=>{if(!p||!m.current)return;const N=m.current,R=b(j.clientX,j.clientY),M={x:Math.min(N.x,R.x),y:Math.min(N.y,R.y),width:Math.abs(R.x-N.x),height:Math.abs(R.y-N.y)};h(M);const w=new Set;for(const[D]of _.current)S(D,M)&&w.add(D);c(w)},[p,b,S]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),h(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const j=R=>{k(R)},N=()=>{E()};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",N)}},[p,k,E]);const v=y.useCallback((j,N=!1)=>{c(R=>{const M=new Set(N?R:[]);return R.has(j)&&N?M.delete(j):M.add(j),i==null||i(Array.from(M)),M})},[i]),T=y.useCallback(()=>{const j=new Set(_.current.keys());c(j),i==null||i(Array.from(j))},[i]),B=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:C,updateSelection:k,endSelection:E,toggleSelect:v,selectAll:T,clearSelection:B}}const Ad=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const h=y.useCallback(_=>{i&&_.button===0&&o(e,_)},[e,i,o]),p=y.useCallback(_=>{s||a==null||a(_)},[s,a]),g=y.useCallback(_=>{_.stopPropagation(),l==null||l(_)},[l]),m=y.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u==null||u(_)},[u]),x=t.rotation||0;return f.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:h,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Td(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return E2(n,s);case"bezier":default:return k2(n,s)}}function k2(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function E2(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function D2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,h;return u<c?(d=s.x+(i>0?a:-a),h=s.y+o*a/Math.abs(i)):(h=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:h}}function A2(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function T2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function N2(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function B2(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,a=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+a)}return{x:e,y:t,width:n-e,height:s-t}}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function M2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Nd=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Td(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),h=y.useCallback(()=>{u(!0)},[]),p=y.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return f.jsxs("g",{children:[f.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:h,onMouseLeave:p}),f.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&f.jsx(R2,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function R2({pathD:r,label:e,color:t}){const n=y.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("path",{id:n,d:r})}),f.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:f.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Bd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return f.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:f.jsx("g",{style:{pointerEvents:"auto"},children:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return f.jsx(Nd,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),jd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return f.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),F2=200,L2=100,P2="bezier",I2="#94a3b8",z2=2,O2=.1,$2=4;function q2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=F2,defaultNodeHeight:i=L2,onNodeMove:o,onNodeDrag:a,onNodeClick:l,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:h,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=O2,maxZoom:_=$2,initialTransform:b,defaultEdgeStyle:S=P2,defaultEdgeColor:C=I2,defaultEdgeWidth:k=z2,draggable:E=!0,selectable:v=!0,zoomable:T=!0,pannable:B=!0,className:j="",style:N,background:R="#f8fafc",showGrid:M=!1,gridSize:w=20}){const D=r.data||{positions:{}},F=D.positions||{},z=y.useMemo(()=>{const X=new Map;for(const Z of e){const ce=F[Z._id]||{x:0,y:0};X.set(Z._id,{x:ce.x,y:ce.y,width:ce.width||s,height:ce.height||i,rotation:ce.rotation||0})}return X},[e,F,s,i]),{transform:q,containerRef:J,zoomIn:te,zoomOut:W,resetZoom:G,fitToContent:H}=kd({minZoom:x,maxZoom:_,initialTransform:b||D.transform,zoomable:T,pannable:B,onTransformChange:X=>{m==null||m(X);const Z={...D,transform:X};g==null||g(Z)}}),[se,le]=y.useState(new Map),[ue,_e]=y.useState(new Map),fe=y.useRef(new Map);y.useEffect(()=>{const X=q.k||1,Z=new Map;fe.current.forEach((we,Be)=>{if(we){const Qe=we.getBoundingClientRect();Z.set(Be,{width:Math.round(Qe.width/X),height:Math.round(Qe.height/X)})}}),e.some(we=>{const Be=Z.get(we._id),Qe=ue.get(we._id);return Be?Qe?Be.width!==Qe.width||Be.height!==Qe.height:!0:!1})&&_e(Z)},[e,ue,q.k]);const{draggedNodeId:De,startDrag:O}=Ed({transform:q,disabled:!E,onDragStart:X=>{const Z=z.get(X);Z&&le(new Map([[X,{x:Z.x,y:Z.y}]]))},onDragMove:(X,Z,ce)=>{le(new Map([[X,{x:Z,y:ce}]])),a==null||a(X,Z,ce)},onDragEnd:(X,Z,ce)=>{le(new Map),o==null||o(X,Z,ce)}}),{selectedIds:Ce,selectionBox:re,isSelecting:Fe,startSelection:je,toggleSelect:ye,clearSelection:Se}=Dd({transform:q,nodePositions:z,disabled:!v,controlledSelectedIds:d,onSelectionChange:h}),Me=y.useCallback(X=>{const Z=z.get(X)||{x:0,y:0,width:s,height:i},ce=se.get(X),we=ue.get(X),Be=(we==null?void 0:we.width)||Z.width||s,Qe=(we==null?void 0:we.height)||Z.height||i;return ce?{...Z,x:ce.x,y:ce.y,width:Be,height:Qe}:{...Z,width:Be,height:Qe}},[z,se,ue,s,i]),Oe=y.useMemo(()=>{const X=new Map;for(const Z of z.keys())X.set(Z,Me(Z));return X},[z,Me]),ge=y.useCallback((X,Z)=>{ye(X._id,Z.shiftKey),l==null||l(X,Z)},[ye,l]),L=y.useCallback(X=>{X.target.closest("[data-qmap-node]")||Se()},[Se]),ze=y.useCallback(X=>{X.button===0&&(X.target.closest("[data-qmap-node]")||je(X))},[je]),Ke=M?`
|
|
185
|
+
${se}`:se)},re=async se=>{if(!(!(typeof e=="string"?e:"").trim()||B||!s)){j(!0),R(!1);try{const ce=await s(se,e);t(ce)}catch(ce){console.error(`${se} failed:`,ce)}finally{j(!1)}}},Le=()=>{setTimeout(()=>{var se;(se=we.current)!=null&&se.contains(document.activeElement)||R(!1)},150)},Me=async()=>{if(!(!M.trim()||B||!i)){j(!0);try{const se=await i(M,e);t(se),w("")}catch(se){console.error("AI prompt failed:",se)}finally{j(!1)}}},xe=async()=>{if(!(typeof e=="string"?e:"").trim()||D)return;if(!(Ce||_)){console.warn("TTS: No generation mode available",{integratedTTS:Ce,hasCallback:!!_,llmClient:!!c,graphClient:!!d,nodeId:h,audioFilename:p}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}fe.current&&(fe.current.pause(),fe.current.currentTime=0),F(!0);try{if(Ce&&c&&d&&h&&p){console.log("TTS: Generating audio...",{voice:W,textLength:e.length});const ce=await c.tts(e,{voice:W});console.log("TTS: Audio generated, uploading...",{audioLength:ce==null?void 0:ce.length});const $=atob(ce),Ge=new Uint8Array($.length);for(let K=0;K<$.length;K++)Ge[K]=$.charCodeAt(K);const Ke=new Blob([Ge],{type:"audio/mpeg"}),X=new File([Ke],p,{type:"audio/mpeg"});await d.uploadFile(h,p,X),console.log("TTS: Upload complete",{nodeId:h,audioFilename:p}),de(Date.now()),ie(p),x==null||x(p,W)}else _&&(await _(e,W),de(Date.now()))}catch(ce){console.error("TTS generation failed:",ce),alert("Erreur TTS: "+(ce instanceof Error?ce.message:"Erreur inconnue"))}finally{F(!1)}},Se=async()=>{if(!(!c||!E||I)){if(!(v!=null&&v.trim())){te(T||"Le texte source est requis pour la génération.");return}q(!0),te(null);try{const se=await c.chat([{role:"system",content:E},{role:"user",content:v}]);t(se)}catch(se){te(se instanceof Error?se.message:"Erreur de génération")}finally{q(!1)}}},Re=se=>{Q(se),C==null||C(se)};return f.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${l}`,children:[f.jsx(Zc,{onComplete:o||(()=>{}),onTranscribe:n,onTranscriptionComplete:je,hideSaveButton:!o,variant:"div",extraControls:f.jsxs(f.Fragment,{children:[i&&f.jsx("button",{type:"button",onClick:Me,disabled:B||!M.trim(),style:{padding:"4px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",opacity:B||!M.trim()?.3:1},title:"Envoyer le prompt AI",children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:B?"#9333ea":"#171717"},children:B?"hourglass_empty":"smart_toy"})}),s&&f.jsxs("div",{className:"relative",ref:we,style:{display:"inline-flex"},children:[f.jsx("button",{type:"button",onClick:()=>R(!N),disabled:B||!(typeof e=="string"?e:"").trim(),style:{padding:"4px 8px",marginRight:"6px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",opacity:B||!(typeof e=="string"?e:"").trim()?.4:1},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#171717",transform:N?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:"chevron_right"})}),N&&!B&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:Le,children:[f.jsxs("button",{type:"button",onClick:()=>re("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Restructure"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),f.jsxs("button",{type:"button",onClick:()=>re("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Proofread"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),f.jsxs("button",{type:"button",onClick:()=>re("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Rewrite"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})}),i&&f.jsx("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200 px-2",children:f.jsx("textarea",{value:M,onChange:se=>w(se.target.value),onKeyDown:se=>{se.stopPropagation(),se.key==="Enter"&&se.ctrlKey&&(se.preventDefault(),Me())},placeholder:"Instructions AI... (Ctrl+Enter)",disabled:B,rows:3,className:"flex-1 py-2 text-sm border-0 resize-y min-h-[60px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50",autoFocus:!0})}),(r||(typeof e=="string"?e:"").trim()||Ce||_||k)&&f.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),k&&c&&E&&f.jsxs("button",{type:"button",onClick:Se,disabled:I,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:k.label,children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:I?"hourglass_empty":k.icon||"auto_awesome"}),k.label]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?e:"").trim()&&f.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:f.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),(Ce||_)&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:W,onChange:se=>Re(se.target.value),disabled:D,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(se=>f.jsxs("option",{value:se.id,children:[se.name," - ",se.description]},se.id))}),f.jsx("button",{type:"button",onClick:xe,disabled:D||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:D?"Génération en cours...":"Générer audio TTS",children:f.jsx("span",{className:`material-icons ${D?"animate-pulse text-blue-600":O?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:D?"hourglass_empty":"record_voice_over"})}),O&&f.jsxs(f.Fragment,{children:[f.jsx("audio",{ref:fe,src:O,controls:!0,className:"h-6 w-32"},ue),f.jsx("button",{type:"button",onClick:()=>{fe.current&&fe.current.pause(),ie(void 0),x==null||x("",W)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:f.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]})]})]}),f.jsx("textarea",{value:e,onChange:se=>t(se.target.value),onKeyDown:se=>se.stopPropagation(),placeholder:a,rows:u,disabled:B||I,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),Z&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),f.jsx("p",{className:"text-sm text-neutral-600",children:Z})]})]}),f.jsx("div",{className:"mt-4 flex justify-end",children:f.jsx("button",{type:"button",onClick:()=>te(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Qg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[h,p]=y.useState(null),[g,m]=y.useState(n),[x,_]=y.useState(0),[b,S]=y.useState({x:0,y:0,width:100,height:100}),[C,k]=y.useState(!1),[E,v]=y.useState(null),[T,B]=y.useState({x:0,y:0}),[j,N]=y.useState({x:0,y:0,width:100,height:100}),R=o==="dark",M=y.useCallback(()=>{const O=u.current;return O?x===90||x===270?{width:O.height,height:O.width}:{width:O.width,height:O.height}:{width:100,height:100}},[x]),w=y.useCallback((O,je)=>{const re=O/je,Le=.05;for(const[Me,xe]of Object.entries(gs))if(xe!==null&&Math.abs(re-xe)/xe<Le)return Me;return"free"},[]);y.useEffect(()=>{const O=new Image;O.crossOrigin="anonymous",O.onload=()=>{u.current=O;const je=w(O.width,O.height);m(je),d(!1)},O.onerror=()=>{p("Failed to load image"),d(!1)},O.src=r},[r,w]);const D=y.useCallback(()=>{const{width:O,height:je}=M(),re=gs[g];if(re===null){S({x:0,y:0,width:100,height:100});return}const Le=O/je;let Me,xe;Le>re?(xe=100,Me=re/Le*100):(Me=100,xe=Le/re*100);const Se=(100-Me)/2,Re=(100-xe)/2;S({x:Se,y:Re,width:Me,height:xe})},[g,M]);y.useEffect(()=>{u.current&&D()},[g,x,D]),y.useEffect(()=>{const O=l.current,je=u.current;if(!O||!je||c)return;const re=O.getContext("2d");if(!re)return;const Le=a.current;if(!Le)return;const Me=Le.clientWidth,xe=Le.clientHeight-140,{width:Se,height:Re}=M(),se=Se/Re;let ce,$;Me/xe>se?($=Math.min(xe,Re),ce=$*se):(ce=Math.min(Me,Se),$=ce/se),ce>Me&&(ce=Me,$=ce/se),$>xe&&($=xe,ce=$*se),O.width=ce,O.height=$,re.clearRect(0,0,ce,$),re.save(),re.translate(ce/2,$/2),re.rotate(x*Math.PI/180);let Ge,Ke;x===90||x===270?(Ge=$,Ke=ce):(Ge=ce,Ke=$),re.drawImage(je,-Ge/2,-Ke/2,Ge,Ke),re.restore(),re.fillStyle="rgba(0, 0, 0, 0.6)";const X=b.x/100*ce,K=b.y/100*$,pe=b.width/100*ce,De=b.height/100*$;re.fillRect(0,0,ce,K),re.fillRect(0,K+De,ce,$-K-De),re.fillRect(0,K,X,De),re.fillRect(X+pe,K,ce-X-pe,De),re.strokeStyle="#fff",re.lineWidth=2,re.strokeRect(X,K,pe,De),re.strokeStyle="rgba(255, 255, 255, 0.3)",re.lineWidth=1,re.beginPath(),re.moveTo(X+pe/3,K),re.lineTo(X+pe/3,K+De),re.moveTo(X+pe*2/3,K),re.lineTo(X+pe*2/3,K+De),re.moveTo(X,K+De/3),re.lineTo(X+pe,K+De/3),re.moveTo(X,K+De*2/3),re.lineTo(X+pe,K+De*2/3),re.stroke();const Be=14;re.fillStyle="#fff",re.strokeStyle="#333",re.lineWidth=1,[{x:X,y:K},{x:X+pe,y:K},{x:X,y:K+De},{x:X+pe,y:K+De}].forEach(Et=>{re.fillRect(Et.x-Be/2,Et.y-Be/2,Be,Be),re.strokeRect(Et.x-Be/2,Et.y-Be/2,Be,Be)})},[b,x,c,M]);const F=O=>{const je=l.current;if(!je)return;const re=je.getBoundingClientRect(),Le=(O.clientX-re.left)/re.width*100,Me=(O.clientY-re.top)/re.height*100,xe=4,Se=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Re of Se)if(Math.abs(Le-Re.x)<xe&&Math.abs(Me-Re.y)<xe){v(Re.name),B({x:Le,y:Me}),N({...b});return}Le>=b.x&&Le<=b.x+b.width&&Me>=b.y&&Me<=b.y+b.height&&(k(!0),B({x:Le,y:Me}),N({...b}))},I=O=>{const je=l.current;if(!je)return;const re=je.getBoundingClientRect(),Le=(O.clientX-re.left)/re.width*100,Me=(O.clientY-re.top)/re.height*100;if(C){const xe=Le-T.x,Se=Me-T.y;let Re=j.x+xe,se=j.y+Se;Re=Math.max(0,Math.min(Re,100-j.width)),se=Math.max(0,Math.min(se,100-j.height)),S({...j,x:Re,y:se})}else if(E){const xe=gs[g],{width:Se,height:Re}=M(),se=Se/Re,ce=xe?xe/se:null;let $={...j};const Ge=Le-T.x,Ke=Me-T.y;if(E==="se")$.width=Math.max(10,Math.min(100-$.x,j.width+Ge)),ce?($.height=$.width/ce,$.y+$.height>100&&($.height=100-$.y,$.width=$.height*ce)):$.height=Math.max(10,Math.min(100-$.y,j.height+Ke));else if(E==="sw"){const X=-Ge,K=Math.max(10,j.width+X),pe=j.x+j.width-K;pe>=0&&($.width=K,$.x=pe,ce?($.height=$.width/ce,$.y+$.height>100&&($.height=100-$.y,$.width=$.height*ce,$.x=j.x+j.width-$.width)):$.height=Math.max(10,Math.min(100-$.y,j.height+Ke)))}else if(E==="ne")if($.width=Math.max(10,Math.min(100-$.x,j.width+Ge)),ce){const X=$.width/ce,K=j.y+j.height-X;K>=0?($.height=X,$.y=K):($.y=0,$.height=j.y+j.height,$.width=$.height*ce)}else{const X=-Ke,K=Math.max(10,j.height+X),pe=j.y+j.height-K;pe>=0&&($.height=K,$.y=pe)}else if(E==="nw"){const X=-Ge,K=Math.max(10,j.width+X),pe=j.x+j.width-K;if(pe>=0)if($.width=K,$.x=pe,ce){const De=$.width/ce,Be=j.y+j.height-De;Be>=0?($.height=De,$.y=Be):($.y=0,$.height=j.y+j.height,$.width=$.height*ce,$.x=j.x+j.width-$.width)}else{const De=-Ke,Be=Math.max(10,j.height+De),Qe=j.y+j.height-Be;Qe>=0&&($.height=Be,$.y=Qe)}}$.x=Math.max(0,$.x),$.y=Math.max(0,$.y),$.width=Math.min($.width,100-$.x),$.height=Math.min($.height,100-$.y),S($)}},q=()=>{k(!1),v(null)},Z=O=>{_(je=>O==="right"?(je+90)%360:(je-90+360)%360)},te=()=>{const O=u.current;if(!O)return;const{width:je,height:re}=M(),Le=b.x/100*je,Me=b.y/100*re,xe=b.width/100*je,Se=b.height/100*re,Re=document.createElement("canvas"),se=Re.getContext("2d");if(!se)return;Re.width=xe,Re.height=Se;const ce=document.createElement("canvas"),$=ce.getContext("2d");$&&(ce.width=je,ce.height=re,$.save(),$.translate(je/2,re/2),$.rotate(x*Math.PI/180),$.drawImage(O,-O.width/2,-O.height/2,O.width,O.height),$.restore(),se.drawImage(ce,Le,Me,xe,Se,0,0,xe,Se),Re.toBlob(Ge=>{Ge&&e(Ge)},s,i))},W={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:R?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Q={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${R?"#333":"#ddd"}`,background:R?"#242424":"#fff",flexShrink:0},ie={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},de={...ue,background:"#E67E22",color:"#fff"},we={...ue,background:R?"#333":"#e5e5e5",color:R?"#fff":"#333"},fe={padding:"10px",borderRadius:"8px",border:"none",background:R?"#333":"#e5e5e5",color:R?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Ce=O=>({padding:"8px 14px",borderRadius:"6px",border:O?"2px solid #E67E22":"2px solid transparent",background:O?"#E67E22":R?"#333":"#e5e5e5",color:O?"#fff":R?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?f.jsx("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:f.jsx("div",{style:{color:R?"#aaa":"#666"},children:"Loading image..."})}):h?f.jsxs("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{color:"#ef4444"},children:h}),t&&f.jsx("button",{onClick:t,style:{...we,marginTop:"16px"},children:"Close"})]}):f.jsxs("div",{ref:a,style:W,children:[f.jsx("div",{style:Q,children:f.jsx("canvas",{ref:l,style:{cursor:C?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:I,onMouseUp:q,onMouseLeave:q})}),f.jsxs("div",{style:H,children:[f.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(O=>f.jsx("button",{onClick:()=>m(O),style:Ce(g===O),children:O==="free"?"Libre":O},O))}),f.jsxs("div",{style:ie,children:[f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>Z("left"),style:fe,title:"Rotate left",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),f.jsx("button",{onClick:()=>Z("right"),style:fe,title:"Rotate right",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&f.jsx("button",{onClick:t,style:we,children:"Annuler"}),f.jsx("button",{onClick:te,style:de,children:"Enregistrer"})]})]})]})]})}var Jg={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Xg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Xg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Zg(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Zg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Jg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function e0(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function t0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function ed(r){var e=_i(r);return(e.local?t0:e0)(e)}function r0(){}function ua(r){return r==null?r0:function(){return this.querySelector(r)}}function n0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Tt(n,this._parents)}function s0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function i0(){return[]}function td(r){return r==null?i0:function(){return this.querySelectorAll(r)}}function o0(r){return function(){return s0(r.apply(this,arguments))}}function a0(r){typeof r=="function"?r=o0(r):r=td(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Tt(n,s)}function rd(r){return function(){return this.matches(r)}}function nd(r){return function(e){return e.matches(r)}}var l0=Array.prototype.find;function u0(r){return function(){return l0.call(this.children,r)}}function c0(){return this.firstElementChild}function d0(r){return this.select(r==null?c0:u0(typeof r=="function"?r:nd(r)))}var f0=Array.prototype.filter;function h0(){return Array.from(this.children)}function p0(r){return function(){return f0.call(this.children,r)}}function g0(r){return this.selectAll(r==null?h0:p0(typeof r=="function"?r:nd(r)))}function m0(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Tt(n,this._parents)}function sd(r){return new Array(r.length)}function y0(){return new Tt(this._enter||this._groups.map(sd),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function x0(r){return function(){return r}}function b0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function v0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,h=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(h[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(h[a])===l&&(s[a]=l)}function _0(r){return r.__data__}function w0(r,e){if(!arguments.length)return Array.from(this,_0);var t=e?v0:b0,n=this._parents,s=this._groups;typeof r!="function"&&(r=x0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],h=d.length,p=C0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),_=l[u]=new Array(h);t(c,d,m,x,_,p,e);for(var b=0,S=0,C,k;b<g;++b)if(C=m[b]){for(b>=S&&(S=b+1);!(k=x[S])&&++S<g;);C._next=k||null}}return o=new Tt(o,n),o._enter=a,o._exit=l,o}function C0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function S0(){return new Tt(this._exit||this._groups.map(sd),this._parents)}function k0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function E0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,h=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(h[g]=p);for(;l<s;++l)a[l]=t[l];return new Tt(a,this._parents)}function D0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function A0(r){r||(r=T0);function e(d,h){return d&&h?r(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Tt(s,this._parents).order()}function T0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function N0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function B0(){return Array.from(this)}function j0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function M0(){let r=0;for(const e of this)++r;return r}function R0(){return!this.node()}function F0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function L0(r){return function(){this.removeAttribute(r)}}function P0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function I0(r,e){return function(){this.setAttribute(r,e)}}function z0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function $0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function q0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?P0:L0:typeof e=="function"?t.local?$0:O0:t.local?z0:I0)(t,e))}function id(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function U0(r){return function(){this.style.removeProperty(r)}}function W0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function H0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function V0(r,e,t){return arguments.length>1?this.each((e==null?U0:typeof e=="function"?H0:W0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||id(r).getComputedStyle(r,null).getPropertyValue(e)}function G0(r){return function(){delete this[r]}}function K0(r,e){return function(){this[r]=e}}function Y0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Q0(r,e){return arguments.length>1?this.each((e==null?G0:typeof e=="function"?Y0:K0)(r,e)):this.node()[r]}function od(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ad(r)}function ad(r){this._node=r,this._names=od(r.getAttribute("class")||"")}ad.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ud(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function J0(r){return function(){ld(this,r)}}function X0(r){return function(){ud(this,r)}}function Z0(r,e){return function(){(e.apply(this,arguments)?ld:ud)(this,r)}}function em(r,e){var t=od(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?Z0:e?J0:X0)(t,e))}function tm(){this.textContent=""}function rm(r){return function(){this.textContent=r}}function nm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function sm(r){return arguments.length?this.each(r==null?tm:(typeof r=="function"?nm:rm)(r)):this.node().textContent}function im(){this.innerHTML=""}function om(r){return function(){this.innerHTML=r}}function am(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function lm(r){return arguments.length?this.each(r==null?im:(typeof r=="function"?am:om)(r)):this.node().innerHTML}function um(){this.nextSibling&&this.parentNode.appendChild(this)}function cm(){return this.each(um)}function dm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fm(){return this.each(dm)}function hm(r){var e=typeof r=="function"?r:ed(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function pm(){return null}function gm(r,e){var t=typeof r=="function"?r:ed(r),n=e==null?pm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function mm(){var r=this.parentNode;r&&r.removeChild(this)}function ym(){return this.each(mm)}function xm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function vm(r){return this.select(r?bm:xm)}function _m(r){return arguments.length?this.property("__data__",r):this.node().__data__}function wm(r){return function(e){r.call(this,e,this.__data__)}}function Cm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Sm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function km(r,e,t){return function(){var n=this.__on,s,i=wm(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function Em(r,e,t){var n=Cm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?km:Sm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function cd(r,e,t){var n=id(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function Dm(r,e){return function(){return cd(this,r,e)}}function Am(r,e){return function(){return cd(this,r,e.apply(this,arguments))}}function Tm(r,e){return this.each((typeof e=="function"?Am:Dm)(r,e))}function*Nm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var dd=[null];function Tt(r,e){this._groups=r,this._parents=e}function ss(){return new Tt([[document.documentElement]],dd)}function Bm(){return this}Tt.prototype=ss.prototype={constructor:Tt,select:n0,selectAll:a0,selectChild:d0,selectChildren:g0,filter:m0,data:w0,enter:y0,exit:S0,join:k0,merge:E0,selection:Bm,order:D0,sort:A0,call:N0,nodes:B0,node:j0,size:M0,empty:R0,each:F0,attr:q0,style:V0,property:Q0,classed:em,text:sm,html:lm,raise:cm,lower:fm,append:hm,insert:gm,remove:ym,clone:vm,datum:_m,on:Em,dispatch:Tm,[Symbol.iterator]:Nm};function Ft(r){return typeof r=="string"?new Tt([[document.querySelector(r)]],[document.documentElement]):new Tt([[r]],dd)}function jm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=jm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function Mm(r){var e=r.document.documentElement,t=Ft(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Rm(r,e){var t=r.document.documentElement,n=Ft(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function fd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fm=/^#([0-9a-f]{3,8})$/,Lm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Pm=new RegExp(`^rgb\\(${Vt},${Vt},${Vt}\\)$`),Im=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),zm=new RegExp(`^rgba\\(${Vt},${Vt},${Vt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Vt},${Vt}\\)$`),$m=new RegExp(`^hsla\\(${qn},${Vt},${Vt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:qm,formatHsl:Um,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function qm(){return this.rgb().formatHex8()}function Um(){return hd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Fm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new Ct(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Lm.exec(r))?new Ct(e[1],e[2],e[3],1):(e=Pm.exec(r))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Im.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=zm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=$m.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new Ct(NaN,NaN,NaN,0):null}function Wl(r){return new Ct(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new Ct(r,e,t,n)}function Wm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new Ct(r.r,r.g,r.b,r.opacity)):new Ct}function wo(r,e,t,n){return arguments.length===1?Wm(r):new Ct(r,e,t,n??1)}function Ct(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(Ct,wo,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ct(Tr(this.r),Tr(this.g),Tr(this.b),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Hm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Hm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Lt(r,e,t,n)}function hd(r){if(r instanceof Lt)return new Lt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Lt;if(r instanceof Lt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Lt(o,a,l,r.opacity)}function Vm(r,e,t,n){return arguments.length===1?hd(r):new Lt(r,e,t,n??1)}function Lt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Lt,Vm,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Lt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Lt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new Ct(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Lt(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const pd=r=>()=>r;function Gm(r,e){return function(t){return r+t*e}}function Km(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Ym(r){return(r=+r)==1?gd:function(e,t){return t-e?Km(e,t,r):pd(isNaN(e)?t:e)}}function gd(r,e){var t=e-r;return t?Gm(r,t):pd(isNaN(r)?e:r)}const Yl=function r(e){var t=Ym(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=gd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function dr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Qm(r){return function(){return r}}function Jm(r){return function(e){return r(e)+""}}function Xm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:dr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Jm(l[0].x):Qm(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function md(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Zm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:md(e.a,e.b,e.c,e.d,e.e,e.f)}function ey(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,md(r.a,r.b,r.c,r.d,r.e,r.f))}function yd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(u,c,d,h){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:dr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function a(u,c,d,h){u!==c?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:dr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function l(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(u,c){var d=[],h=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,h),o(u.rotate,c.rotate,d,h),a(u.skewX,c.skewX,d,h),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,h),u=c=null,function(p){for(var g=-1,m=h.length,x;++g<m;)d[(x=h[g]).i]=x.x(p);return d.join("")}}}var ty=yd(Zm,"px, ","px)","deg)"),ry=yd(ey,", ",")",")"),ny=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function sy(r){return((r=Math.exp(r))-1/r)/2}function iy(r){return((r=Math.exp(2*r))-1)/(r+1)}const oy=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],h=o[2],p=c-a,g=d-l,m=p*p+g*g,x,_;if(m<ny)_=Math.log(h/u)/e,x=function(v){return[a+v*p,l+v*g,u*Math.exp(e*v*_)]};else{var b=Math.sqrt(m),S=(h*h-u*u+n*m)/(2*u*t*b),C=(h*h-u*u-n*m)/(2*h*t*b),k=Math.log(Math.sqrt(S*S+1)-S),E=Math.log(Math.sqrt(C*C+1)-C);_=(E-k)/e,x=function(v){var T=v*_,B=Jl(k),j=u/(t*b)*(B*iy(e*T+k)-sy(k));return[a+j*p,l+j*g,u*B/Jl(e*T+k)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,xd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,bd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(bd(ay),Lr=Wn.now()+wi)}function ay(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=vd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function vd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ly(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{ly()}finally{nn=0,cy(),Lr=0}}function uy(){var r=Wn.now(),e=r-ei;e>xd&&(wi-=e,ei=r)}function cy(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(uy,xd)),nn=1,bd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var dy=la("start","end","cancel","interrupt"),fy=[],_d=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;hy(r,t,{name:e,index:n,group:s,on:dy,tween:fy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_d})}function ha(r,e){var t=$t(r,e);if(t.state>_d)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=$t(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function $t(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function hy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=vd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,h,p;if(t.state!==eu)return l();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(h=t.tween.length),c=0,d=-1;c<h;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),t.state=Do,1),d=-1,h=s.length;++d<h;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),l())}function l(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function py(r){return this.each(function(){Es(this,r)})}function gy(r,e){var t,n;return function(){var s=Jt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function my(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Jt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function yy(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=$t(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?gy:my)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Jt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return $t(s,n).value[e]}}function wd(r,e){var t;return(typeof e=="number"?dr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Xm)(r,e)}function xy(r){return function(){this.removeAttribute(r)}}function by(r){return function(){this.removeAttributeNS(r.space,r.local)}}function vy(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function _y(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function wy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Cy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Sy(r,e){var t=_i(r),n=t==="transform"?ry:wd;return this.attrTween(r,typeof e=="function"?(t.local?Cy:wy)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?by:xy)(t):(t.local?_y:vy)(t,n,e))}function ky(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function Ey(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Ey(r,i)),t}return s._value=e,s}function Ay(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Ty(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?Dy:Ay)(n,e))}function Ny(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function By(r,e){return e=+e,function(){ha(this,r).delay=e}}function jy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ny:By)(e,r)):$t(this.node(),e).delay}function My(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function Ry(r,e){return e=+e,function(){Jt(this,r).duration=e}}function Fy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?My:Ry)(e,r)):$t(this.node(),e).duration}function Ly(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function Py(r){var e=this._id;return arguments.length?this.each(Ly(e,r)):$t(this.node(),e).ease}function Iy(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function zy(r){if(typeof r!="function")throw new Error;return this.each(Iy(this._id,r))}function Oy(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new sr(n,this._parents,this._name,this._id)}function $y(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),h,p=0;p<c;++p)(h=l[p]||u[p])&&(d[p]=h);for(;a<n;++a)o[a]=e[a];return new sr(o,this._parents,this._name,this._id)}function qy(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Uy(r,e,t){var n,s,i=qy(e)?ha:Jt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function Wy(r,e){var t=this._id;return arguments.length<2?$t(this.node(),t).on.on(r):this.each(Uy(t,r,e))}function Hy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Vy(){return this.on("end.remove",Hy(this._id))}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,h=0;h<l;++h)(c=a[h])&&(d=r.call(c,c.__data__,h,a))&&("__data__"in c&&(d.__data__=c.__data__),u[h]=d,Ci(u[h],e,t,h,u,$t(c,t)));return new sr(i,this._parents,e,t)}function Ky(r){var e=this._name,t=this._id;typeof r!="function"&&(r=td(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var h=r.call(c,c.__data__,d,l),p,g=$t(c,t),m=0,x=h.length;m<x;++m)(p=h[m])&&Ci(p,e,t,m,h,g);i.push(h),o.push(c)}return new sr(i,o,e,t)}var Yy=ss.prototype.constructor;function Qy(){return new Yy(this._groups,this._parents)}function Jy(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function Cd(r){return function(){this.style.removeProperty(r)}}function Xy(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function Zy(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function e2(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Jt(this,r),u=l.on,c=l.value[i]==null?a||(a=Cd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function t2(r,e,t){var n=(r+="")=="transform"?ty:wd;return e==null?this.styleTween(r,Jy(r,n)).on("end.style."+r,Cd(r)):typeof e=="function"?this.styleTween(r,Zy(r,n,pa(this,"style."+r,e))).each(e2(this._id,r)):this.styleTween(r,Xy(r,n,e),t).on("end.style."+r,null)}function r2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function n2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&r2(r,o,t)),n}return i._value=e,i}function s2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,n2(r,e,t??""))}function i2(r){return function(){this.textContent=r}}function o2(r){return function(){var e=r(this);this.textContent=e??""}}function a2(r){return this.tween("text",typeof r=="function"?o2(pa(this,"text",r)):i2(r==null?"":r+""))}function l2(r){return function(e){this.textContent=r.call(this,e)}}function u2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&l2(s)),e}return n._value=r,n}function c2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,u2(r))}function d2(){for(var r=this._name,e=this._id,t=Sd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=$t(l,e);Ci(l,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new sr(n,this._parents,r,t)}function f2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={value:function(){--s===0&&i()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var h2=0;function sr(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Sd(){return++h2}var er=ss.prototype;sr.prototype={constructor:sr,select:Gy,selectAll:Ky,selectChild:er.selectChild,selectChildren:er.selectChildren,filter:Oy,merge:$y,selection:Qy,transition:d2,call:er.call,nodes:er.nodes,node:er.node,size:er.size,empty:er.empty,each:er.each,on:Wy,attr:Sy,attrTween:Ty,style:t2,styleTween:s2,text:a2,textTween:c2,remove:Vy,tween:yy,delay:jy,duration:Fy,ease:Py,easeVarying:zy,end:f2,[Symbol.iterator]:er[Symbol.iterator]};function p2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var g2={time:null,delay:0,duration:250,ease:p2};function m2(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function y2(r){var e,t;r instanceof sr?(e=r._id,r=r._name):(e=Sd(),(t=g2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||m2(l,e));return new sr(n,this._parents,r,e)}ss.prototype.interrupt=py;ss.prototype.transition=y2;const bs=r=>()=>r;function x2(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function rr(r,e,t){this.k=r,this.x=e,this.y=t}rr.prototype={constructor:rr,scale:function(r){return r===1?this:new rr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new rr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new rr(1,0,0);rr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function b2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function v2(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function _2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function w2(){return navigator.maxTouchPoints||"ontouchstart"in this}function C2(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function S2(){var r=b2,e=v2,t=C2,n=_2,s=w2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=oy,u=la("start","zoom","end"),c,d,h,p=500,g=150,m=0,x=10;function _(w){w.property("__zoom",ru).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,D,F,I){var q=w.selection?w.selection():w;q.property("__zoom",ru),w!==q?k(w,D,F,I):q.interrupt().each(function(){E(this,arguments).event(I).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},_.scaleBy=function(w,D,F,I){_.scaleTo(w,function(){var q=this.__zoom.k,Z=typeof D=="function"?D.apply(this,arguments):D;return q*Z},F,I)},_.scaleTo=function(w,D,F,I){_.transform(w,function(){var q=e.apply(this,arguments),Z=this.__zoom,te=F==null?C(q):typeof F=="function"?F.apply(this,arguments):F,W=Z.invert(te),Q=typeof D=="function"?D.apply(this,arguments):D;return t(S(b(Z,Q),te,W),q,o)},F,I)},_.translateBy=function(w,D,F,I){_.transform(w,function(){return t(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},_.translateTo=function(w,D,F,I,q){_.transform(w,function(){var Z=e.apply(this,arguments),te=this.__zoom,W=I==null?C(Z):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(W[0],W[1]).scale(te.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof F=="function"?-F.apply(this,arguments):-F),Z,o)},I,q)};function b(w,D){return D=Math.max(i[0],Math.min(i[1],D)),D===w.k?w:new rr(D,w.x,w.y)}function S(w,D,F){var I=D[0]-F[0]*w.k,q=D[1]-F[1]*w.k;return I===w.x&&q===w.y?w:new rr(w.k,I,q)}function C(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,D,F,I){w.on("start.zoom",function(){E(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(I).end()}).tween("zoom",function(){var q=this,Z=arguments,te=E(q,Z).event(I),W=e.apply(q,Z),Q=F==null?C(W):typeof F=="function"?F.apply(q,Z):F,H=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),ie=q.__zoom,ue=typeof D=="function"?D.apply(q,Z):D,de=l(ie.invert(Q).concat(H/ie.k),ue.invert(Q).concat(H/ue.k));return function(we){if(we===1)we=ue;else{var fe=de(we),Ce=H/fe[2];we=new rr(Ce,Q[0]-fe[0]*Ce,Q[1]-fe[1]*Ce)}te.zoom(null,we)}})}function E(w,D,F){return!F&&w.__zooming||new v(w,D)}function v(w,D){this.that=w,this.args=D,this.active=0,this.sourceEvent=null,this.extent=e.apply(w,D),this.taps=0}v.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,D){return this.mouse&&w!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var D=Ft(this.that).datum();u.call(w,this.that,new x2(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),D)}};function T(w,...D){if(!r.apply(this,arguments))return;var F=E(this,D).event(w),I=this.__zoom,q=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),Z=wr(w);if(F.wheel)(F.mouse[0][0]!==Z[0]||F.mouse[0][1]!==Z[1])&&(F.mouse[1]=I.invert(F.mouse[0]=Z)),clearTimeout(F.wheel);else{if(I.k===q)return;F.mouse=[Z,I.invert(Z)],Es(this),F.start()}xn(w),F.wheel=setTimeout(te,g),F.zoom("mouse",t(S(b(I,q),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function B(w,...D){if(h||!r.apply(this,arguments))return;var F=w.currentTarget,I=E(this,D,!0).event(w),q=Ft(w.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",H,!0),Z=wr(w,F),te=w.clientX,W=w.clientY;Mm(w.view),Wi(w),I.mouse=[Z,this.__zoom.invert(Z)],Es(this),I.start();function Q(ie){if(xn(ie),!I.moved){var ue=ie.clientX-te,de=ie.clientY-W;I.moved=ue*ue+de*de>m}I.event(ie).zoom("mouse",t(S(I.that.__zoom,I.mouse[0]=wr(ie,F),I.mouse[1]),I.extent,o))}function H(ie){q.on("mousemove.zoom mouseup.zoom",null),Rm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function j(w,...D){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(w.changedTouches?w.changedTouches[0]:w,this),q=F.invert(I),Z=F.k*(w.shiftKey?.5:2),te=t(S(b(F,Z),I,q),e.apply(this,D),o);xn(w),a>0?Ft(this).transition().duration(a).call(k,te,I,w):Ft(this).call(_.transform,te,I,w)}}function N(w,...D){if(r.apply(this,arguments)){var F=w.touches,I=F.length,q=E(this,D,w.changedTouches.length===I).event(w),Z,te,W,Q;for(Wi(w),te=0;te<I;++te)W=F[te],Q=wr(W,this),Q=[Q,this.__zoom.invert(Q),W.identifier],q.touch0?!q.touch1&&q.touch0[2]!==Q[2]&&(q.touch1=Q,q.taps=0):(q.touch0=Q,Z=!0,q.taps=1+!!c);c&&(c=clearTimeout(c)),Z&&(q.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Es(this),q.start())}}function R(w,...D){if(this.__zooming){var F=E(this,D).event(w),I=w.changedTouches,q=I.length,Z,te,W,Q;for(xn(w),Z=0;Z<q;++Z)te=I[Z],W=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=W:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=W);if(te=F.that.__zoom,F.touch1){var H=F.touch0[0],ie=F.touch0[1],ue=F.touch1[0],de=F.touch1[1],we=(we=ue[0]-H[0])*we+(we=ue[1]-H[1])*we,fe=(fe=de[0]-ie[0])*fe+(fe=de[1]-ie[1])*fe;te=b(te,Math.sqrt(we/fe)),W=[(H[0]+ue[0])/2,(H[1]+ue[1])/2],Q=[(ie[0]+de[0])/2,(ie[1]+de[1])/2]}else if(F.touch0)W=F.touch0[0],Q=F.touch0[1];else return;F.zoom("touch",t(S(te,W,Q),F.extent,o))}}function M(w,...D){if(this.__zooming){var F=E(this,D).event(w),I=w.changedTouches,q=I.length,Z,te;for(Wi(w),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),Z=0;Z<q;++Z)te=I[Z],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var W=Ft(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(n=typeof w=="function"?w:bs(+w),_):n},_.filter=function(w){return arguments.length?(r=typeof w=="function"?w:bs(!!w),_):r},_.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:bs(!!w),_):s},_.extent=function(w){return arguments.length?(e=typeof w=="function"?w:bs([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):e},_.scaleExtent=function(w){return arguments.length?(i[0]=+w[0],i[1]=+w[1],_):[i[0],i[1]]},_.translateExtent=function(w){return arguments.length?(o[0][0]=+w[0][0],o[1][0]=+w[1][0],o[0][1]=+w[0][1],o[1][1]=+w[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(w){return arguments.length?(t=w,_):t},_.duration=function(w){return arguments.length?(a=+w,_):a},_.interpolate=function(w){return arguments.length?(l=w,_):l},_.on=function(){var w=u.on.apply(u,arguments);return w===u?_:w},_.clickDistance=function(w){return arguments.length?(m=(w=+w)*w,_):Math.sqrt(m)},_.tapDistance=function(w){return arguments.length?(x=+w,_):x},_}function kd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=S2().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const S={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(S),o==null||o(S)});l.current=x;const _=Ft(a.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{l.current&&l.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=y.useCallback((x,_,b,S=!0)=>{if(!a.current||!l.current)return;const C=Ft(a.current),k=ri.translate(x,_).scale(b);C.call(l.current.transform,k)},[]),h=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,_=50)=>{if(!a.current||!l.current||x.length===0)return;const b=a.current,S=b.clientWidth,C=b.clientHeight;let k=1/0,E=1/0,v=-1/0,T=-1/0;for(const q of x){const Z=q.width||200,te=q.height||100;k=Math.min(k,q.x),E=Math.min(E,q.y),v=Math.max(v,q.x+Z),T=Math.max(T,q.y+te)}const B=v-k,j=T-E,N=(S-_*2)/B,R=(C-_*2)/j,M=Math.min(N,R,t),w=(k+v)/2,D=(E+T)/2,F=S/2-w*M,I=C/2-D*M;d(F,I,M,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:h,zoomOut:p,resetZoom:g,fitToContent:m}}function Ed(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),h=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((S,C)=>{const k=g.current;return{x:(S-k.x)/k.k,y:(C-k.y)/k.k}},[]),x=y.useCallback((S,C)=>{if(i)return;C.preventDefault(),C.stopPropagation();const k=C.currentTarget,E=parseFloat(k.dataset.x||"0"),v=parseFloat(k.dataset.y||"0");h.current={x:C.clientX,y:C.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},a(S),u(!0),d({x:0,y:0}),t==null||t(S)},[i,m,t]),_=y.useCallback(S=>{if(!l||!o||!h.current)return;const C=g.current,k=h.current,E=S.clientX-k.x,v=S.clientY-k.y,T=E/C.k,B=v/C.k,j=k.nodeX+T,N=k.nodeY+B;p.current={x:j,y:N},d({x:T,y:B}),n==null||n(o,j,N,T,B)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const S=p.current;s==null||s(o,S.x,S.y),a(null),u(!1),d({x:0,y:0}),h.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const S=k=>{_(k)},C=()=>{b()};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",C)}},[l,_,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:_,endDrag:b}}function Dd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?j=>{const N=typeof j=="function"?j(u):j;i==null||i(Array.from(N))}:a,[d,h]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),_=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{_.current=t},[t]);const b=y.useCallback((j,N)=>{const R=x.current;return{x:(j-R.x)/R.k,y:(N-R.y)/R.k}},[]),S=y.useCallback((j,N)=>{const R=_.current.get(j);if(!R)return!1;const M=R.width||200,w=R.height||100;return R.x<N.x+N.width&&R.x+M>N.x&&R.y<N.y+N.height&&R.y+w>N.y},[]),C=y.useCallback(j=>{if(n||j.target.closest("[data-qmap-node]"))return;j.preventDefault();const R=b(j.clientX,j.clientY);m.current=R,h({x:R.x,y:R.y,width:0,height:0}),g(!0),j.shiftKey||c(new Set)},[n,b]),k=y.useCallback(j=>{if(!p||!m.current)return;const N=m.current,R=b(j.clientX,j.clientY),M={x:Math.min(N.x,R.x),y:Math.min(N.y,R.y),width:Math.abs(R.x-N.x),height:Math.abs(R.y-N.y)};h(M);const w=new Set;for(const[D]of _.current)S(D,M)&&w.add(D);c(w)},[p,b,S]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),h(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const j=R=>{k(R)},N=()=>{E()};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",N)}},[p,k,E]);const v=y.useCallback((j,N=!1)=>{c(R=>{const M=new Set(N?R:[]);return R.has(j)&&N?M.delete(j):M.add(j),i==null||i(Array.from(M)),M})},[i]),T=y.useCallback(()=>{const j=new Set(_.current.keys());c(j),i==null||i(Array.from(j))},[i]),B=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:C,updateSelection:k,endSelection:E,toggleSelect:v,selectAll:T,clearSelection:B}}const Ad=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const h=y.useCallback(_=>{i&&_.button===0&&o(e,_)},[e,i,o]),p=y.useCallback(_=>{s||a==null||a(_)},[s,a]),g=y.useCallback(_=>{_.stopPropagation(),l==null||l(_)},[l]),m=y.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u==null||u(_)},[u]),x=t.rotation||0;return f.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:h,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Td(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return E2(n,s);case"bezier":default:return k2(n,s)}}function k2(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function E2(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function D2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,h;return u<c?(d=s.x+(i>0?a:-a),h=s.y+o*a/Math.abs(i)):(h=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:h}}function A2(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function T2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function N2(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function B2(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,a=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+a)}return{x:e,y:t,width:n-e,height:s-t}}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function M2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Nd=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Td(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),h=y.useCallback(()=>{u(!0)},[]),p=y.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return f.jsxs("g",{children:[f.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:h,onMouseLeave:p}),f.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&f.jsx(R2,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function R2({pathD:r,label:e,color:t}){const n=y.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("path",{id:n,d:r})}),f.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:f.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Bd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return f.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:f.jsx("g",{style:{pointerEvents:"auto"},children:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return f.jsx(Nd,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),jd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return f.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),F2=200,L2=100,P2="bezier",I2="#94a3b8",z2=2,O2=.1,$2=4;function q2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=F2,defaultNodeHeight:i=L2,onNodeMove:o,onNodeDrag:a,onNodeClick:l,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:h,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=O2,maxZoom:_=$2,initialTransform:b,defaultEdgeStyle:S=P2,defaultEdgeColor:C=I2,defaultEdgeWidth:k=z2,draggable:E=!0,selectable:v=!0,zoomable:T=!0,pannable:B=!0,className:j="",style:N,background:R="#f8fafc",showGrid:M=!1,gridSize:w=20}){const D=r.data||{positions:{}},F=D.positions||{},I=y.useMemo(()=>{const X=new Map;for(const K of e){const pe=F[K._id]||{x:0,y:0};X.set(K._id,{x:pe.x,y:pe.y,width:pe.width||s,height:pe.height||i,rotation:pe.rotation||0})}return X},[e,F,s,i]),{transform:q,containerRef:Z,zoomIn:te,zoomOut:W,resetZoom:Q,fitToContent:H}=kd({minZoom:x,maxZoom:_,initialTransform:b||D.transform,zoomable:T,pannable:B,onTransformChange:X=>{m==null||m(X);const K={...D,transform:X};g==null||g(K)}}),[ie,ue]=y.useState(new Map),[de,we]=y.useState(new Map),fe=y.useRef(new Map);y.useEffect(()=>{const X=q.k||1,K=new Map;fe.current.forEach((De,Be)=>{if(De){const Qe=De.getBoundingClientRect();K.set(Be,{width:Math.round(Qe.width/X),height:Math.round(Qe.height/X)})}}),e.some(De=>{const Be=K.get(De._id),Qe=de.get(De._id);return Be?Qe?Be.width!==Qe.width||Be.height!==Qe.height:!0:!1})&&we(K)},[e,de,q.k]);const{draggedNodeId:Ce,startDrag:O}=Ed({transform:q,disabled:!E,onDragStart:X=>{const K=I.get(X);K&&ue(new Map([[X,{x:K.x,y:K.y}]]))},onDragMove:(X,K,pe)=>{ue(new Map([[X,{x:K,y:pe}]])),a==null||a(X,K,pe)},onDragEnd:(X,K,pe)=>{ue(new Map),o==null||o(X,K,pe)}}),{selectedIds:je,selectionBox:re,isSelecting:Le,startSelection:Me,toggleSelect:xe,clearSelection:Se}=Dd({transform:q,nodePositions:I,disabled:!v,controlledSelectedIds:d,onSelectionChange:h}),Re=y.useCallback(X=>{const K=I.get(X)||{x:0,y:0,width:s,height:i},pe=ie.get(X),De=de.get(X),Be=(De==null?void 0:De.width)||K.width||s,Qe=(De==null?void 0:De.height)||K.height||i;return pe?{...K,x:pe.x,y:pe.y,width:Be,height:Qe}:{...K,width:Be,height:Qe}},[I,ie,de,s,i]),se=y.useMemo(()=>{const X=new Map;for(const K of I.keys())X.set(K,Re(K));return X},[I,Re]),ce=y.useCallback((X,K)=>{xe(X._id,K.shiftKey),l==null||l(X,K)},[xe,l]),$=y.useCallback(X=>{X.target.closest("[data-qmap-node]")||Se()},[Se]),Ge=y.useCallback(X=>{X.button===0&&(X.target.closest("[data-qmap-node]")||Me(X))},[Me]),Ke=M?`
|
|
186
186
|
linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
|
|
187
187
|
linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px)
|
|
188
|
-
`:void 0;return f.jsxs("div",{ref:
|
|
188
|
+
`:void 0;return f.jsxs("div",{ref:Z,className:`qmap-container ${j}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:R,backgroundImage:Ke,backgroundSize:M?`${w}px ${w}px`:void 0,cursor:Le?"crosshair":B?"grab":"default",...N},onMouseDown:Ge,onClick:$,children:[f.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${q.x}px, ${q.y}px) scale(${q.k})`,willChange:"transform"},children:[f.jsx(Bd,{edges:t,nodePositions:se,defaultStyle:S,defaultColor:C,defaultWidth:k,onEdgeClick:p}),e.map(X=>{const K=Re(X._id),pe=je.has(X._id),De=Ce===X._id;return f.jsx(Ad,{nodeId:X._id,position:K,isSelected:pe,isDragging:De,draggable:E,onDragStart:O,onClick:Be=>ce(X,Be),onDoubleClick:Be=>u==null?void 0:u(X,Be),onContextMenu:Be=>c==null?void 0:c(X,Be),nodeRef:Be=>{Be?fe.current.set(X._id,Be):fe.current.delete(X._id)},children:n(X,pe,K)},X._id)})]}),re&&f.jsx(jd,{box:re,transform:q}),f.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[f.jsx("button",{onClick:te,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),f.jsx("button",{onClick:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),f.jsx("button",{onClick:Q,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),f.jsx("button",{onClick:()=>H(Array.from(se.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=aa;exports.$isQRCodeNode=kg;exports.AnimatedCardFlip=kf;exports.ApiClient=au;exports.AudioEditor=Zc;exports.AuthFlow=fu;exports.AuthFlowModal=bf;exports.AuthManager=Je;exports.AuthProvider=df;exports.AuthService=Ao;exports.Card=wf;exports.ComboBox=Fg;exports.ComboStack=Pg;exports.DataOperations=vs;exports.Detail=Cf;exports.ForgotPasswordForm=cu;exports.GraphClient=Id;exports.ImageEditor=Qg;exports.KanbanBoard=Ig;exports.LLMClient=sf;exports.LoginForm=No;exports.LoginModal=pf;exports.Mail=Df;exports.MailClient=iu;exports.MailComposer=Mg;exports.MailEditor=Gc;exports.NetflixCard=Qc;exports.NetflixDetail=Xc;exports.NetflixLane=Jc;exports.NetflixStack=Ug;exports.QMap=q2;exports.QMapEdgeComponent=Nd;exports.QMapEdgeLayer=Bd;exports.QMapNode=Ad;exports.QMapSelectionBox=jd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Af;exports.Stack=_f;exports.TTS_VOICES=ou;exports.Timeline=Kg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Yg;exports.calculateBoundingBox=B2;exports.calculateEdgePath=Td;exports.distance=j2;exports.distanceSquared=M2;exports.getApiClient=To;exports.getAuthService=af;exports.getConnectionPoint=D2;exports.getNodeCenter=ga;exports.getNodeSidePoint=A2;exports.initializeApiClient=lf;exports.initializeAuthService=of;exports.pointInRect=T2;exports.rectsIntersect=N2;exports.useAuth=ff;exports.useMutation=vf;exports.useNodeDrag=Ed;exports.useQuery=hu;exports.useSelection=Dd;exports.useZoomPan=kd;
|