Files
soul-yongping/soul-admin/dist/assets/index-DALKpE2i.js
卡若 22bb29f433 feat: 内容管理深度优化 (03-07~03-09)
- 排名算法权重可配置,排行榜显示点击量/付款数/热度
- 富文本编辑器升级(TipTap),支持@提及/#链接标签/图片/表格
- 「主人公」Tab → 「链接AI」Tab,AI列表+链接标签管理
- 链接标签新增存客宝(ckb)类型,存客宝绑定配置面板
- 人物ID改为可选,名称必填
- 排行榜操作改为「编辑文章」,付款记录移入编辑弹窗
- 章节ID修改支持(originalId/newId机制)
- 付款记录用户ID/订单ID可点击跳转
- 项目推进表补充14-15节(03-07~09改动记录+存客宝技术方案)

Made-with: Cursor
2026-03-09 05:49:03 +08:00

775 lines
1.1 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function n3(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function xN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var im={exports:{}},Gl={},am={exports:{}},lt={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ob;function r3(){if(ob)return lt;ob=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function g(L){return L===null||typeof L!="object"?null:(L=m&&L[m]||L["@@iterator"],typeof L=="function"?L:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,j={};function w(L,H,ue){this.props=L,this.context=H,this.refs=j,this.updater=ue||y}w.prototype.isReactComponent={},w.prototype.setState=function(L,H){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,H,"setState")},w.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function k(){}k.prototype=w.prototype;function E(L,H,ue){this.props=L,this.context=H,this.refs=j,this.updater=ue||y}var C=E.prototype=new k;C.constructor=E,v(C,w.prototype),C.isPureReactComponent=!0;var M=Array.isArray,D=Object.prototype.hasOwnProperty,F={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function I(L,H,ue){var U,he={},Q=null,ee=null;if(H!=null)for(U in H.ref!==void 0&&(ee=H.ref),H.key!==void 0&&(Q=""+H.key),H)D.call(H,U)&&!R.hasOwnProperty(U)&&(he[U]=H[U]);var de=arguments.length-2;if(de===1)he.children=ue;else if(1<de){for(var Ce=Array(de),B=0;B<de;B++)Ce[B]=arguments[B+2];he.children=Ce}if(L&&L.defaultProps)for(U in de=L.defaultProps,de)he[U]===void 0&&(he[U]=de[U]);return{$$typeof:t,type:L,key:Q,ref:ee,props:he,_owner:F.current}}function A(L,H){return{$$typeof:t,type:L.type,key:H,ref:L.ref,props:L.props,_owner:L._owner}}function O(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function W(L){var H={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(ue){return H[ue]})}var X=/\/+/g;function q(L,H){return typeof L=="object"&&L!==null&&L.key!=null?W(""+L.key):H.toString(36)}function Z(L,H,ue,U,he){var Q=typeof L;(Q==="undefined"||Q==="boolean")&&(L=null);var ee=!1;if(L===null)ee=!0;else switch(Q){case"string":case"number":ee=!0;break;case"object":switch(L.$$typeof){case t:case e:ee=!0}}if(ee)return ee=L,he=he(ee),L=U===""?"."+q(ee,0):U,M(he)?(ue="",L!=null&&(ue=L.replace(X,"$&/")+"/"),Z(he,H,ue,"",function(B){return B})):he!=null&&(O(he)&&(he=A(he,ue+(!he.key||ee&&ee.key===he.key?"":(""+he.key).replace(X,"$&/")+"/")+L)),H.push(he)),1;if(ee=0,U=U===""?".":U+":",M(L))for(var de=0;de<L.length;de++){Q=L[de];var Ce=U+q(Q,de);ee+=Z(Q,H,ue,Ce,he)}else if(Ce=g(L),typeof Ce=="function")for(L=Ce.call(L),de=0;!(Q=L.next()).done;)Q=Q.value,Ce=U+q(Q,de++),ee+=Z(Q,H,ue,Ce,he);else if(Q==="object")throw H=String(L),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return ee}function _(L,H,ue){if(L==null)return L;var U=[],he=0;return Z(L,U,"","",function(Q){return H.call(ue,Q,he++)}),U}function $(L){if(L._status===-1){var H=L._result;H=H(),H.then(function(ue){(L._status===0||L._status===-1)&&(L._status=1,L._result=ue)},function(ue){(L._status===0||L._status===-1)&&(L._status=2,L._result=ue)}),L._status===-1&&(L._status=0,L._result=H)}if(L._status===1)return L._result.default;throw L._result}var oe={current:null},V={transition:null},ae={ReactCurrentDispatcher:oe,ReactCurrentBatchConfig:V,ReactCurrentOwner:F};function Y(){throw Error("act(...) is not supported in production builds of React.")}return lt.Children={map:_,forEach:function(L,H,ue){_(L,function(){H.apply(this,arguments)},ue)},count:function(L){var H=0;return _(L,function(){H++}),H},toArray:function(L){return _(L,function(H){return H})||[]},only:function(L){if(!O(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},lt.Component=w,lt.Fragment=n,lt.Profiler=s,lt.PureComponent=E,lt.StrictMode=r,lt.Suspense=u,lt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ae,lt.act=Y,lt.cloneElement=function(L,H,ue){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var U=v({},L.props),he=L.key,Q=L.ref,ee=L._owner;if(H!=null){if(H.ref!==void 0&&(Q=H.ref,ee=F.current),H.key!==void 0&&(he=""+H.key),L.type&&L.type.defaultProps)var de=L.type.defaultProps;for(Ce in H)D.call(H,Ce)&&!R.hasOwnProperty(Ce)&&(U[Ce]=H[Ce]===void 0&&de!==void 0?de[Ce]:H[Ce])}var Ce=arguments.length-2;if(Ce===1)U.children=ue;else if(1<Ce){de=Array(Ce);for(var B=0;B<Ce;B++)de[B]=arguments[B+2];U.children=de}return{$$typeof:t,type:L.type,key:he,ref:Q,props:U,_owner:ee}},lt.createContext=function(L){return L={$$typeof:o,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:a,_context:L},L.Consumer=L},lt.createElement=I,lt.createFactory=function(L){var H=I.bind(null,L);return H.type=L,H},lt.createRef=function(){return{current:null}},lt.forwardRef=function(L){return{$$typeof:c,render:L}},lt.isValidElement=O,lt.lazy=function(L){return{$$typeof:f,_payload:{_status:-1,_result:L},_init:$}},lt.memo=function(L,H){return{$$typeof:h,type:L,compare:H===void 0?null:H}},lt.startTransition=function(L){var H=V.transition;V.transition={};try{L()}finally{V.transition=H}},lt.unstable_act=Y,lt.useCallback=function(L,H){return oe.current.useCallback(L,H)},lt.useContext=function(L){return oe.current.useContext(L)},lt.useDebugValue=function(){},lt.useDeferredValue=function(L){return oe.current.useDeferredValue(L)},lt.useEffect=function(L,H){return oe.current.useEffect(L,H)},lt.useId=function(){return oe.current.useId()},lt.useImperativeHandle=function(L,H,ue){return oe.current.useImperativeHandle(L,H,ue)},lt.useInsertionEffect=function(L,H){return oe.current.useInsertionEffect(L,H)},lt.useLayoutEffect=function(L,H){return oe.current.useLayoutEffect(L,H)},lt.useMemo=function(L,H){return oe.current.useMemo(L,H)},lt.useReducer=function(L,H,ue){return oe.current.useReducer(L,H,ue)},lt.useRef=function(L){return oe.current.useRef(L)},lt.useState=function(L){return oe.current.useState(L)},lt.useSyncExternalStore=function(L,H,ue){return oe.current.useSyncExternalStore(L,H,ue)},lt.useTransition=function(){return oe.current.useTransition()},lt.version="18.3.1",lt}var lb;function $c(){return lb||(lb=1,am.exports=r3()),am.exports}/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var cb;function s3(){if(cb)return Gl;cb=1;var t=$c(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(c,u,h){var f,m={},g=null,y=null;h!==void 0&&(g=""+h),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(f in u)r.call(u,f)&&!a.hasOwnProperty(f)&&(m[f]=u[f]);if(c&&c.defaultProps)for(f in u=c.defaultProps,u)m[f]===void 0&&(m[f]=u[f]);return{$$typeof:e,type:c,key:g,ref:y,props:m,_owner:s.current}}return Gl.Fragment=n,Gl.jsx=o,Gl.jsxs=o,Gl}var db;function i3(){return db||(db=1,im.exports=s3()),im.exports}var i=i3(),b=$c();const Zn=xN(b),Vh=n3({__proto__:null,default:Zn},[b]);var ru={},om={exports:{}},cr={},lm={exports:{}},cm={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ub;function a3(){return ub||(ub=1,(function(t){function e(V,ae){var Y=V.length;V.push(ae);e:for(;0<Y;){var L=Y-1>>>1,H=V[L];if(0<s(H,ae))V[L]=ae,V[Y]=H,Y=L;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ae=V[0],Y=V.pop();if(Y!==ae){V[0]=Y;e:for(var L=0,H=V.length,ue=H>>>1;L<ue;){var U=2*(L+1)-1,he=V[U],Q=U+1,ee=V[Q];if(0>s(he,Y))Q<H&&0>s(ee,he)?(V[L]=ee,V[Q]=Y,L=Q):(V[L]=he,V[U]=Y,L=U);else if(Q<H&&0>s(ee,Y))V[L]=ee,V[Q]=Y,L=Q;else break e}}return ae}function s(V,ae){var Y=V.sortIndex-ae.sortIndex;return Y!==0?Y:V.id-ae.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var u=[],h=[],f=1,m=null,g=3,y=!1,v=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(V){for(var ae=n(h);ae!==null;){if(ae.callback===null)r(h);else if(ae.startTime<=V)r(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=n(h)}}function M(V){if(j=!1,C(V),!v)if(n(u)!==null)v=!0,$(D);else{var ae=n(h);ae!==null&&oe(M,ae.startTime-V)}}function D(V,ae){v=!1,j&&(j=!1,k(I),I=-1),y=!0;var Y=g;try{for(C(ae),m=n(u);m!==null&&(!(m.expirationTime>ae)||V&&!W());){var L=m.callback;if(typeof L=="function"){m.callback=null,g=m.priorityLevel;var H=L(m.expirationTime<=ae);ae=t.unstable_now(),typeof H=="function"?m.callback=H:m===n(u)&&r(u),C(ae)}else r(u);m=n(u)}if(m!==null)var ue=!0;else{var U=n(h);U!==null&&oe(M,U.startTime-ae),ue=!1}return ue}finally{m=null,g=Y,y=!1}}var F=!1,R=null,I=-1,A=5,O=-1;function W(){return!(t.unstable_now()-O<A)}function X(){if(R!==null){var V=t.unstable_now();O=V;var ae=!0;try{ae=R(!0,V)}finally{ae?q():(F=!1,R=null)}}else F=!1}var q;if(typeof E=="function")q=function(){E(X)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,_=Z.port2;Z.port1.onmessage=X,q=function(){_.postMessage(null)}}else q=function(){w(X,0)};function $(V){R=V,F||(F=!0,q())}function oe(V,ae){I=w(function(){V(t.unstable_now())},ae)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_continueExecution=function(){v||y||(v=!0,$(D))},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(V){switch(g){case 1:case 2:case 3:var ae=3;break;default:ae=g}var Y=g;g=ae;try{return V()}finally{g=Y}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,ae){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var Y=g;g=V;try{return ae()}finally{g=Y}},t.unstable_scheduleCallback=function(V,ae,Y){var L=t.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?L+Y:L):Y=L,V){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=Y+H,V={id:f++,callback:ae,priorityLevel:V,startTime:Y,expirationTime:H,sortIndex:-1},Y>L?(V.sortIndex=Y,e(h,V),n(u)===null&&V===n(h)&&(j?(k(I),I=-1):j=!0,oe(M,Y-L))):(V.sortIndex=H,e(u,V),v||y||(v=!0,$(D))),V},t.unstable_shouldYield=W,t.unstable_wrapCallback=function(V){var ae=g;return function(){var Y=g;g=ae;try{return V.apply(this,arguments)}finally{g=Y}}}})(cm)),cm}var hb;function o3(){return hb||(hb=1,lm.exports=a3()),lm.exports}/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var fb;function l3(){if(fb)return cr;fb=1;var t=$c(),e=o3();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p<arguments.length;p++)d+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+l+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(l,d){o(l,d),o(l+"Capture",d)}function o(l,d){for(s[l]=d,l=0;l<d.length;l++)r.add(d[l])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},m={};function g(l){return u.call(m,l)?!0:u.call(f,l)?!1:h.test(l)?m[l]=!0:(f[l]=!0,!1)}function y(l,d,p,x){if(p!==null&&p.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function v(l,d,p,x){if(d===null||typeof d>"u"||y(l,d,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function j(l,d,p,x,N,S,T){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=N,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=T}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){w[l]=new j(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];w[d]=new j(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){w[l]=new j(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){w[l]=new j(l,2,!1,l,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(l){w[l]=new j(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){w[l]=new j(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){w[l]=new j(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){w[l]=new j(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){w[l]=new j(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(l){return l[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(l){var d=l.replace(k,E);w[d]=new j(d,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var d=l.replace(k,E);w[d]=new j(d,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var d=l.replace(k,E);w[d]=new j(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){w[l]=new j(l,1,!1,l.toLowerCase(),null,!1,!1)}),w.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){w[l]=new j(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,d,p,x){var N=w.hasOwnProperty(d)?w[d]:null;(N!==null?N.type!==0:x||!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(v(d,p,N,x)&&(p=null),x||N===null?g(d)&&(p===null?l.removeAttribute(d):l.setAttribute(d,""+p)):N.mustUseProperty?l[N.propertyName]=p===null?N.type===3?!1:"":p:(d=N.attributeName,x=N.attributeNamespace,p===null?l.removeAttribute(d):(N=N.type,p=N===3||N===4&&p===!0?"":""+p,x?l.setAttributeNS(x,d,p):l.setAttribute(d,p))))}var M=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),F=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),W=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),oe=Symbol.for("react.offscreen"),V=Symbol.iterator;function ae(l){return l===null||typeof l!="object"?null:(l=V&&l[V]||l["@@iterator"],typeof l=="function"?l:null)}var Y=Object.assign,L;function H(l){if(L===void 0)try{throw Error()}catch(p){var d=p.stack.trim().match(/\n( *(at )?)/);L=d&&d[1]||""}return`
`+L+l}var ue=!1;function U(l,d){if(!l||ue)return"";ue=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(d)if(d=function(){throw Error()},Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(le){var x=le}Reflect.construct(l,[],d)}else{try{d.call()}catch(le){x=le}l.call(d.prototype)}else{try{throw Error()}catch(le){x=le}l()}}catch(le){if(le&&x&&typeof le.stack=="string"){for(var N=le.stack.split(`
`),S=x.stack.split(`
`),T=N.length-1,z=S.length-1;1<=T&&0<=z&&N[T]!==S[z];)z--;for(;1<=T&&0<=z;T--,z--)if(N[T]!==S[z]){if(T!==1||z!==1)do if(T--,z--,0>z||N[T]!==S[z]){var K=`
`+N[T].replace(" at new "," at ");return l.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",l.displayName)),K}while(1<=T&&0<=z);break}}}finally{ue=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?H(l):""}function he(l){switch(l.tag){case 5:return H(l.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return l=U(l.type,!1),l;case 11:return l=U(l.type.render,!1),l;case 1:return l=U(l.type,!0),l;default:return""}}function Q(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case R:return"Fragment";case F:return"Portal";case A:return"Profiler";case I:return"StrictMode";case q:return"Suspense";case Z:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case W:return(l.displayName||"Context")+".Consumer";case O:return(l._context.displayName||"Context")+".Provider";case X:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case _:return d=l.displayName||null,d!==null?d:Q(l.type)||"Memo";case $:d=l._payload,l=l._init;try{return Q(l(d))}catch{}}return null}function ee(l){var d=l.type;switch(l.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=d.render,l=l.displayName||l.name||"",d.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Q(d);case 8:return d===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function de(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Ce(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function B(l){var d=Ce(l)?"checked":"value",p=Object.getOwnPropertyDescriptor(l.constructor.prototype,d),x=""+l[d];if(!l.hasOwnProperty(d)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var N=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return N.call(this)},set:function(T){x=""+T,S.call(this,T)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(T){x=""+T},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function me(l){l._valueTracker||(l._valueTracker=B(l))}function Se(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=Ce(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function rt(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function Ye(l,d){var p=d.checked;return Y({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function st(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=de(d.value!=null?d.value:p),l._wrapperState={initialChecked:x,initialValue:p,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function Qe(l,d){d=d.checked,d!=null&&C(l,"checked",d,!1)}function Xe(l,d){Qe(l,d);var p=de(d.value),x=d.type;if(p!=null)x==="number"?(p===0&&l.value===""||l.value!=p)&&(l.value=""+p):l.value!==""+p&&(l.value=""+p);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}d.hasOwnProperty("value")?Pt(l,d.type,p):d.hasOwnProperty("defaultValue")&&Pt(l,d.type,de(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function ft(l,d,p){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var x=d.type;if(!(x!=="submit"&&x!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+l._wrapperState.initialValue,p||d===l.value||(l.value=d),l.defaultValue=d}p=l.name,p!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,p!==""&&(l.name=p)}function Pt(l,d,p){(d!=="number"||rt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Jt=Array.isArray;function Kn(l,d,p,x){if(l=l.options,d){d={};for(var N=0;N<p.length;N++)d["$"+p[N]]=!0;for(p=0;p<l.length;p++)N=d.hasOwnProperty("$"+l[p].value),l[p].selected!==N&&(l[p].selected=N),N&&x&&(l[p].defaultSelected=!0)}else{for(p=""+de(p),d=null,N=0;N<l.length;N++){if(l[N].value===p){l[N].selected=!0,x&&(l[N].defaultSelected=!0);return}d!==null||l[N].disabled||(d=l[N])}d!==null&&(d.selected=!0)}}function qn(l,d){if(d.dangerouslySetInnerHTML!=null)throw Error(n(91));return Y({},d,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function ss(l,d){var p=d.value;if(p==null){if(p=d.children,d=d.defaultValue,p!=null){if(d!=null)throw Error(n(92));if(Jt(p)){if(1<p.length)throw Error(n(93));p=p[0]}d=p}d==null&&(d=""),p=d}l._wrapperState={initialValue:de(p)}}function zt(l,d){var p=de(d.value),x=de(d.defaultValue);p!=null&&(p=""+p,p!==l.value&&(l.value=p),d.defaultValue==null&&l.defaultValue!==p&&(l.defaultValue=p)),x!=null&&(l.defaultValue=""+x)}function Cr(l){var d=l.textContent;d===l._wrapperState.initialValue&&d!==""&&d!==null&&(l.value=d)}function is(l){switch(l){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function On(l,d){return l==null||l==="http://www.w3.org/1999/xhtml"?is(d):l==="http://www.w3.org/2000/svg"&&d==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var pn,mr=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(d,p,x,N){MSApp.execUnsafeLocalFunction(function(){return l(d,p,x,N)})}:l})(function(l,d){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=d;else{for(pn=pn||document.createElement("div"),pn.innerHTML="<svg>"+d.valueOf().toString()+"</svg>",d=pn.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function Br(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var Gn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fe=["Webkit","ms","Moz","O"];Object.keys(Gn).forEach(function(l){fe.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),Gn[d]=Gn[l]})});function ge(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||Gn.hasOwnProperty(l)&&Gn[l]?(""+d).trim():d+"px"}function Sn(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,N=ge(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,N):l[p]=N}}var ri=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Es(l,d){if(d){if(ri[l]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function ua(l,d){if(l.indexOf("-")===-1)return typeof d.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jn=null;function as(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var jt=null,Cn=null,Yn=null;function Dn(l){if(l=Pl(l)){if(typeof jt!="function")throw Error(n(280));var d=l.stateNode;d&&(d=yd(d),jt(l.stateNode,l.type,d))}}function ha(l){Cn?Yn?Yn.push(l):Yn=[l]:Cn=l}function si(){if(Cn){var l=Cn,d=Yn;if(Yn=Cn=null,Dn(l),d)for(l=0;l<d.length;l++)Dn(d[l])}}function Er(l,d){return l(d)}function ii(){}var ai=!1;function mn(l,d,p){if(ai)return l(d,p);ai=!0;try{return Er(l,d,p)}finally{ai=!1,(Cn!==null||Yn!==null)&&(ii(),si())}}function ls(l,d){var p=l.stateNode;if(p===null)return null;var x=yd(p);if(x===null)return null;p=x[d];e:switch(d){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(l=l.type,x=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!x;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(n(231,d,typeof p));return p}var oi=!1;if(c)try{var cs={};Object.defineProperty(cs,"passive",{get:function(){oi=!0}}),window.addEventListener("test",cs,cs),window.removeEventListener("test",cs,cs)}catch{oi=!1}function fa(l,d,p,x,N,S,T,z,K){var le=Array.prototype.slice.call(arguments,3);try{d.apply(p,le)}catch(ye){this.onError(ye)}}var ds=!1,G=null,Ke=!1,Ze=null,En={onError:function(l){ds=!0,G=l}};function Vr(l,d,p,x,N,S,T,z,K){ds=!1,G=null,fa.apply(En,arguments)}function Nf(l,d,p,x,N,S,T,z,K){if(Vr.apply(this,arguments),ds){if(ds){var le=G;ds=!1,G=null}else throw Error(n(198));Ke||(Ke=!0,Ze=le)}}function us(l){var d=l,p=l;if(l.alternate)for(;d.return;)d=d.return;else{l=d;do d=l,(d.flags&4098)!==0&&(p=d.return),l=d.return;while(l)}return d.tag===3?p:null}function no(l){if(l.tag===13){var d=l.memoizedState;if(d===null&&(l=l.alternate,l!==null&&(d=l.memoizedState)),d!==null)return d.dehydrated}return null}function Jc(l){if(us(l)!==l)throw Error(n(188))}function jf(l){var d=l.alternate;if(!d){if(d=us(l),d===null)throw Error(n(188));return d!==l?null:l}for(var p=l,x=d;;){var N=p.return;if(N===null)break;var S=N.alternate;if(S===null){if(x=N.return,x!==null){p=x;continue}break}if(N.child===S.child){for(S=N.child;S;){if(S===p)return Jc(N),l;if(S===x)return Jc(N),d;S=S.sibling}throw Error(n(188))}if(p.return!==x.return)p=N,x=S;else{for(var T=!1,z=N.child;z;){if(z===p){T=!0,p=N,x=S;break}if(z===x){T=!0,x=N,p=S;break}z=z.sibling}if(!T){for(z=S.child;z;){if(z===p){T=!0,p=S,x=N;break}if(z===x){T=!0,x=S,p=N;break}z=z.sibling}if(!T)throw Error(n(189))}}if(p.alternate!==x)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?l:d}function Yc(l){return l=jf(l),l!==null?Qc(l):null}function Qc(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var d=Qc(l);if(d!==null)return d;l=l.sibling}return null}var Xc=e.unstable_scheduleCallback,Zc=e.unstable_cancelCallback,kf=e.unstable_shouldYield,Sf=e.unstable_requestPaint,$t=e.unstable_now,Cf=e.unstable_getCurrentPriorityLevel,gl=e.unstable_ImmediatePriority,ed=e.unstable_UserBlockingPriority,ro=e.unstable_NormalPriority,td=e.unstable_LowPriority,so=e.unstable_IdlePriority,pa=null,gr=null;function nd(l){if(gr&&typeof gr.onCommitFiberRoot=="function")try{gr.onCommitFiberRoot(pa,l,void 0,(l.current.flags&128)===128)}catch{}}var rr=Math.clz32?Math.clz32:Ae,P=Math.log,ie=Math.LN2;function Ae(l){return l>>>=0,l===0?32:31-(P(l)/ie|0)|0}var Re=64,Ot=4194304;function Vt(l){switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Ln(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,N=l.suspendedLanes,S=l.pingedLanes,T=p&268435455;if(T!==0){var z=T&~N;z!==0?x=Vt(z):(S&=T,S!==0&&(x=Vt(S)))}else T=p&~N,T!==0?x=Vt(T):S!==0&&(x=Vt(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&N)===0&&(N=x&-x,S=d&-d,N>=S||N===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0<d;)p=31-rr(d),N=1<<p,x|=l[p],d&=~N;return x}function hs(l,d){switch(l){case 1:case 2:case 4:return d+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return d+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ef(l,d){for(var p=l.suspendedLanes,x=l.pingedLanes,N=l.expirationTimes,S=l.pendingLanes;0<S;){var T=31-rr(S),z=1<<T,K=N[T];K===-1?((z&p)===0||(z&x)!==0)&&(N[T]=hs(z,d)):K<=d&&(l.expiredLanes|=z),S&=~z}}function Ts(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function io(){var l=Re;return Re<<=1,(Re&4194240)===0&&(Re=64),l}function sn(l){for(var d=[],p=0;31>p;p++)d.push(l);return d}function li(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-rr(d),l[d]=p}function jE(l,d){var p=l.pendingLanes&~d;l.pendingLanes=d,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=d,l.mutableReadLanes&=d,l.entangledLanes&=d,d=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0<p;){var N=31-rr(p),S=1<<N;d[N]=0,x[N]=-1,l[N]=-1,p&=~S}}function Tf(l,d){var p=l.entangledLanes|=d;for(l=l.entanglements;p;){var x=31-rr(p),N=1<<x;N&d|l[x]&d&&(l[x]|=d),p&=~N}}var xt=0;function $0(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var F0,Mf,B0,V0,H0,Af=!1,rd=[],ci=null,di=null,ui=null,xl=new Map,yl=new Map,hi=[],kE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function W0(l,d){switch(l){case"focusin":case"focusout":ci=null;break;case"dragenter":case"dragleave":di=null;break;case"mouseover":case"mouseout":ui=null;break;case"pointerover":case"pointerout":xl.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":yl.delete(d.pointerId)}}function vl(l,d,p,x,N,S){return l===null||l.nativeEvent!==S?(l={blockedOn:d,domEventName:p,eventSystemFlags:x,nativeEvent:S,targetContainers:[N]},d!==null&&(d=Pl(d),d!==null&&Mf(d)),l):(l.eventSystemFlags|=x,d=l.targetContainers,N!==null&&d.indexOf(N)===-1&&d.push(N),l)}function SE(l,d,p,x,N){switch(d){case"focusin":return ci=vl(ci,l,d,p,x,N),!0;case"dragenter":return di=vl(di,l,d,p,x,N),!0;case"mouseover":return ui=vl(ui,l,d,p,x,N),!0;case"pointerover":var S=N.pointerId;return xl.set(S,vl(xl.get(S)||null,l,d,p,x,N)),!0;case"gotpointercapture":return S=N.pointerId,yl.set(S,vl(yl.get(S)||null,l,d,p,x,N)),!0}return!1}function U0(l){var d=ma(l.target);if(d!==null){var p=us(d);if(p!==null){if(d=p.tag,d===13){if(d=no(p),d!==null){l.blockedOn=d,H0(l.priority,function(){B0(p)});return}}else if(d===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function sd(l){if(l.blockedOn!==null)return!1;for(var d=l.targetContainers;0<d.length;){var p=If(l.domEventName,l.eventSystemFlags,d[0],l.nativeEvent);if(p===null){p=l.nativeEvent;var x=new p.constructor(p.type,p);Jn=x,p.target.dispatchEvent(x),Jn=null}else return d=Pl(p),d!==null&&Mf(d),l.blockedOn=p,!1;d.shift()}return!0}function K0(l,d,p){sd(l)&&p.delete(d)}function CE(){Af=!1,ci!==null&&sd(ci)&&(ci=null),di!==null&&sd(di)&&(di=null),ui!==null&&sd(ui)&&(ui=null),xl.forEach(K0),yl.forEach(K0)}function bl(l,d){l.blockedOn===d&&(l.blockedOn=null,Af||(Af=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,CE)))}function wl(l){function d(N){return bl(N,l)}if(0<rd.length){bl(rd[0],l);for(var p=1;p<rd.length;p++){var x=rd[p];x.blockedOn===l&&(x.blockedOn=null)}}for(ci!==null&&bl(ci,l),di!==null&&bl(di,l),ui!==null&&bl(ui,l),xl.forEach(d),yl.forEach(d),p=0;p<hi.length;p++)x=hi[p],x.blockedOn===l&&(x.blockedOn=null);for(;0<hi.length&&(p=hi[0],p.blockedOn===null);)U0(p),p.blockedOn===null&&hi.shift()}var ao=M.ReactCurrentBatchConfig,id=!0;function EE(l,d,p,x){var N=xt,S=ao.transition;ao.transition=null;try{xt=1,Rf(l,d,p,x)}finally{xt=N,ao.transition=S}}function TE(l,d,p,x){var N=xt,S=ao.transition;ao.transition=null;try{xt=4,Rf(l,d,p,x)}finally{xt=N,ao.transition=S}}function Rf(l,d,p,x){if(id){var N=If(l,d,p,x);if(N===null)Jf(l,d,x,ad,p),W0(l,x);else if(SE(N,l,d,p,x))x.stopPropagation();else if(W0(l,x),d&4&&-1<kE.indexOf(l)){for(;N!==null;){var S=Pl(N);if(S!==null&&F0(S),S=If(l,d,p,x),S===null&&Jf(l,d,x,ad,p),S===N)break;N=S}N!==null&&x.stopPropagation()}else Jf(l,d,x,null,p)}}var ad=null;function If(l,d,p,x){if(ad=null,l=as(x),l=ma(l),l!==null)if(d=us(l),d===null)l=null;else if(p=d.tag,p===13){if(l=no(d),l!==null)return l;l=null}else if(p===3){if(d.stateNode.current.memoizedState.isDehydrated)return d.tag===3?d.stateNode.containerInfo:null;l=null}else d!==l&&(l=null);return ad=l,null}function q0(l){switch(l){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Cf()){case gl:return 1;case ed:return 4;case ro:case td:return 16;case so:return 536870912;default:return 16}default:return 16}}var fi=null,Pf=null,od=null;function G0(){if(od)return od;var l,d=Pf,p=d.length,x,N="value"in fi?fi.value:fi.textContent,S=N.length;for(l=0;l<p&&d[l]===N[l];l++);var T=p-l;for(x=1;x<=T&&d[p-x]===N[S-x];x++);return od=N.slice(l,1<x?1-x:void 0)}function ld(l){var d=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&d===13&&(l=13)):l=d,l===10&&(l=13),32<=l||l===13?l:0}function cd(){return!0}function J0(){return!1}function xr(l){function d(p,x,N,S,T){this._reactName=p,this._targetInst=N,this.type=x,this.nativeEvent=S,this.target=T,this.currentTarget=null;for(var z in l)l.hasOwnProperty(z)&&(p=l[z],this[z]=p?p(S):S[z]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?cd:J0,this.isPropagationStopped=J0,this}return Y(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=cd)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=cd)},persist:function(){},isPersistent:cd}),d}var oo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Of=xr(oo),Nl=Y({},oo,{view:0,detail:0}),ME=xr(Nl),Df,Lf,jl,dd=Y({},Nl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zf,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==jl&&(jl&&l.type==="mousemove"?(Df=l.screenX-jl.screenX,Lf=l.screenY-jl.screenY):Lf=Df=0,jl=l),Df)},movementY:function(l){return"movementY"in l?l.movementY:Lf}}),Y0=xr(dd),AE=Y({},dd,{dataTransfer:0}),RE=xr(AE),IE=Y({},Nl,{relatedTarget:0}),_f=xr(IE),PE=Y({},oo,{animationName:0,elapsedTime:0,pseudoElement:0}),OE=xr(PE),DE=Y({},oo,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),LE=xr(DE),_E=Y({},oo,{data:0}),Q0=xr(_E),zE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$E={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},FE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function BE(l){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(l):(l=FE[l])?!!d[l]:!1}function zf(){return BE}var VE=Y({},Nl,{key:function(l){if(l.key){var d=zE[l.key]||l.key;if(d!=="Unidentified")return d}return l.type==="keypress"?(l=ld(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?$E[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zf,charCode:function(l){return l.type==="keypress"?ld(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?ld(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),HE=xr(VE),WE=Y({},dd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),X0=xr(WE),UE=Y({},Nl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zf}),KE=xr(UE),qE=Y({},oo,{propertyName:0,elapsedTime:0,pseudoElement:0}),GE=xr(qE),JE=Y({},dd,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),YE=xr(JE),QE=[9,13,27,32],$f=c&&"CompositionEvent"in window,kl=null;c&&"documentMode"in document&&(kl=document.documentMode);var XE=c&&"TextEvent"in window&&!kl,Z0=c&&(!$f||kl&&8<kl&&11>=kl),ey=" ",ty=!1;function ny(l,d){switch(l){case"keyup":return QE.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ry(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var lo=!1;function ZE(l,d){switch(l){case"compositionend":return ry(d);case"keypress":return d.which!==32?null:(ty=!0,ey);case"textInput":return l=d.data,l===ey&&ty?null:l;default:return null}}function e4(l,d){if(lo)return l==="compositionend"||!$f&&ny(l,d)?(l=G0(),od=Pf=fi=null,lo=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1<d.char.length)return d.char;if(d.which)return String.fromCharCode(d.which)}return null;case"compositionend":return Z0&&d.locale!=="ko"?null:d.data;default:return null}}var t4={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function sy(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d==="input"?!!t4[l.type]:d==="textarea"}function iy(l,d,p,x){ha(x),d=md(d,"onChange"),0<d.length&&(p=new Of("onChange","change",null,p,x),l.push({event:p,listeners:d}))}var Sl=null,Cl=null;function n4(l){jy(l,0)}function ud(l){var d=po(l);if(Se(d))return l}function r4(l,d){if(l==="change")return d}var ay=!1;if(c){var Ff;if(c){var Bf="oninput"in document;if(!Bf){var oy=document.createElement("div");oy.setAttribute("oninput","return;"),Bf=typeof oy.oninput=="function"}Ff=Bf}else Ff=!1;ay=Ff&&(!document.documentMode||9<document.documentMode)}function ly(){Sl&&(Sl.detachEvent("onpropertychange",cy),Cl=Sl=null)}function cy(l){if(l.propertyName==="value"&&ud(Cl)){var d=[];iy(d,Cl,l,as(l)),mn(n4,d)}}function s4(l,d,p){l==="focusin"?(ly(),Sl=d,Cl=p,Sl.attachEvent("onpropertychange",cy)):l==="focusout"&&ly()}function i4(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return ud(Cl)}function a4(l,d){if(l==="click")return ud(d)}function o4(l,d){if(l==="input"||l==="change")return ud(d)}function l4(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var Hr=typeof Object.is=="function"?Object.is:l4;function El(l,d){if(Hr(l,d))return!0;if(typeof l!="object"||l===null||typeof d!="object"||d===null)return!1;var p=Object.keys(l),x=Object.keys(d);if(p.length!==x.length)return!1;for(x=0;x<p.length;x++){var N=p[x];if(!u.call(d,N)||!Hr(l[N],d[N]))return!1}return!0}function dy(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function uy(l,d){var p=dy(l);l=0;for(var x;p;){if(p.nodeType===3){if(x=l+p.textContent.length,l<=d&&x>=d)return{node:p,offset:d-l};l=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=dy(p)}}function hy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?hy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function fy(){for(var l=window,d=rt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=rt(l.document)}return d}function Vf(l){var d=l&&l.nodeName&&l.nodeName.toLowerCase();return d&&(d==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||d==="textarea"||l.contentEditable==="true")}function c4(l){var d=fy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&hy(p.ownerDocument.documentElement,p)){if(x!==null&&Vf(p)){if(d=x.start,l=x.end,l===void 0&&(l=d),"selectionStart"in p)p.selectionStart=d,p.selectionEnd=Math.min(l,p.value.length);else if(l=(d=p.ownerDocument||document)&&d.defaultView||window,l.getSelection){l=l.getSelection();var N=p.textContent.length,S=Math.min(x.start,N);x=x.end===void 0?S:Math.min(x.end,N),!l.extend&&S>x&&(N=x,x=S,S=N),N=uy(p,S);var T=uy(p,x);N&&T&&(l.rangeCount!==1||l.anchorNode!==N.node||l.anchorOffset!==N.offset||l.focusNode!==T.node||l.focusOffset!==T.offset)&&(d=d.createRange(),d.setStart(N.node,N.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(T.node,T.offset)):(d.setEnd(T.node,T.offset),l.addRange(d)))}}for(d=[],l=p;l=l.parentNode;)l.nodeType===1&&d.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<d.length;p++)l=d[p],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var d4=c&&"documentMode"in document&&11>=document.documentMode,co=null,Hf=null,Tl=null,Wf=!1;function py(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Wf||co==null||co!==rt(x)||(x=co,"selectionStart"in x&&Vf(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Tl&&El(Tl,x)||(Tl=x,x=md(Hf,"onSelect"),0<x.length&&(d=new Of("onSelect","select",null,d,p),l.push({event:d,listeners:x}),d.target=co)))}function hd(l,d){var p={};return p[l.toLowerCase()]=d.toLowerCase(),p["Webkit"+l]="webkit"+d,p["Moz"+l]="moz"+d,p}var uo={animationend:hd("Animation","AnimationEnd"),animationiteration:hd("Animation","AnimationIteration"),animationstart:hd("Animation","AnimationStart"),transitionend:hd("Transition","TransitionEnd")},Uf={},my={};c&&(my=document.createElement("div").style,"AnimationEvent"in window||(delete uo.animationend.animation,delete uo.animationiteration.animation,delete uo.animationstart.animation),"TransitionEvent"in window||delete uo.transitionend.transition);function fd(l){if(Uf[l])return Uf[l];if(!uo[l])return l;var d=uo[l],p;for(p in d)if(d.hasOwnProperty(p)&&p in my)return Uf[l]=d[p];return l}var gy=fd("animationend"),xy=fd("animationiteration"),yy=fd("animationstart"),vy=fd("transitionend"),by=new Map,wy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function pi(l,d){by.set(l,d),a(d,[l])}for(var Kf=0;Kf<wy.length;Kf++){var qf=wy[Kf],u4=qf.toLowerCase(),h4=qf[0].toUpperCase()+qf.slice(1);pi(u4,"on"+h4)}pi(gy,"onAnimationEnd"),pi(xy,"onAnimationIteration"),pi(yy,"onAnimationStart"),pi("dblclick","onDoubleClick"),pi("focusin","onFocus"),pi("focusout","onBlur"),pi(vy,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ml="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),f4=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ml));function Ny(l,d,p){var x=l.type||"unknown-event";l.currentTarget=p,Nf(x,d,void 0,l),l.currentTarget=null}function jy(l,d){d=(d&4)!==0;for(var p=0;p<l.length;p++){var x=l[p],N=x.event;x=x.listeners;e:{var S=void 0;if(d)for(var T=x.length-1;0<=T;T--){var z=x[T],K=z.instance,le=z.currentTarget;if(z=z.listener,K!==S&&N.isPropagationStopped())break e;Ny(N,z,le),S=K}else for(T=0;T<x.length;T++){if(z=x[T],K=z.instance,le=z.currentTarget,z=z.listener,K!==S&&N.isPropagationStopped())break e;Ny(N,z,le),S=K}}}if(Ke)throw l=Ze,Ke=!1,Ze=null,l}function Et(l,d){var p=d[tp];p===void 0&&(p=d[tp]=new Set);var x=l+"__bubble";p.has(x)||(ky(d,l,2,!1),p.add(x))}function Gf(l,d,p){var x=0;d&&(x|=4),ky(p,l,x,d)}var pd="_reactListening"+Math.random().toString(36).slice(2);function Al(l){if(!l[pd]){l[pd]=!0,r.forEach(function(p){p!=="selectionchange"&&(f4.has(p)||Gf(p,!1,l),Gf(p,!0,l))});var d=l.nodeType===9?l:l.ownerDocument;d===null||d[pd]||(d[pd]=!0,Gf("selectionchange",!1,d))}}function ky(l,d,p,x){switch(q0(d)){case 1:var N=EE;break;case 4:N=TE;break;default:N=Rf}p=N.bind(null,d,p,l),N=void 0,!oi||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(N=!0),x?N!==void 0?l.addEventListener(d,p,{capture:!0,passive:N}):l.addEventListener(d,p,!0):N!==void 0?l.addEventListener(d,p,{passive:N}):l.addEventListener(d,p,!1)}function Jf(l,d,p,x,N){var S=x;if((d&1)===0&&(d&2)===0&&x!==null)e:for(;;){if(x===null)return;var T=x.tag;if(T===3||T===4){var z=x.stateNode.containerInfo;if(z===N||z.nodeType===8&&z.parentNode===N)break;if(T===4)for(T=x.return;T!==null;){var K=T.tag;if((K===3||K===4)&&(K=T.stateNode.containerInfo,K===N||K.nodeType===8&&K.parentNode===N))return;T=T.return}for(;z!==null;){if(T=ma(z),T===null)return;if(K=T.tag,K===5||K===6){x=S=T;continue e}z=z.parentNode}}x=x.return}mn(function(){var le=S,ye=as(p),be=[];e:{var xe=by.get(l);if(xe!==void 0){var Ie=Of,Oe=l;switch(l){case"keypress":if(ld(p)===0)break e;case"keydown":case"keyup":Ie=HE;break;case"focusin":Oe="focus",Ie=_f;break;case"focusout":Oe="blur",Ie=_f;break;case"beforeblur":case"afterblur":Ie=_f;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ie=Y0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ie=RE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ie=KE;break;case gy:case xy:case yy:Ie=OE;break;case vy:Ie=GE;break;case"scroll":Ie=ME;break;case"wheel":Ie=YE;break;case"copy":case"cut":case"paste":Ie=LE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ie=X0}var _e=(d&4)!==0,Yt=!_e&&l==="scroll",ne=_e?xe!==null?xe+"Capture":null:xe;_e=[];for(var J=le,se;J!==null;){se=J;var Ne=se.stateNode;if(se.tag===5&&Ne!==null&&(se=Ne,ne!==null&&(Ne=ls(J,ne),Ne!=null&&_e.push(Rl(J,Ne,se)))),Yt)break;J=J.return}0<_e.length&&(xe=new Ie(xe,Oe,null,p,ye),be.push({event:xe,listeners:_e}))}}if((d&7)===0){e:{if(xe=l==="mouseover"||l==="pointerover",Ie=l==="mouseout"||l==="pointerout",xe&&p!==Jn&&(Oe=p.relatedTarget||p.fromElement)&&(ma(Oe)||Oe[Ms]))break e;if((Ie||xe)&&(xe=ye.window===ye?ye:(xe=ye.ownerDocument)?xe.defaultView||xe.parentWindow:window,Ie?(Oe=p.relatedTarget||p.toElement,Ie=le,Oe=Oe?ma(Oe):null,Oe!==null&&(Yt=us(Oe),Oe!==Yt||Oe.tag!==5&&Oe.tag!==6)&&(Oe=null)):(Ie=null,Oe=le),Ie!==Oe)){if(_e=Y0,Ne="onMouseLeave",ne="onMouseEnter",J="mouse",(l==="pointerout"||l==="pointerover")&&(_e=X0,Ne="onPointerLeave",ne="onPointerEnter",J="pointer"),Yt=Ie==null?xe:po(Ie),se=Oe==null?xe:po(Oe),xe=new _e(Ne,J+"leave",Ie,p,ye),xe.target=Yt,xe.relatedTarget=se,Ne=null,ma(ye)===le&&(_e=new _e(ne,J+"enter",Oe,p,ye),_e.target=se,_e.relatedTarget=Yt,Ne=_e),Yt=Ne,Ie&&Oe)t:{for(_e=Ie,ne=Oe,J=0,se=_e;se;se=ho(se))J++;for(se=0,Ne=ne;Ne;Ne=ho(Ne))se++;for(;0<J-se;)_e=ho(_e),J--;for(;0<se-J;)ne=ho(ne),se--;for(;J--;){if(_e===ne||ne!==null&&_e===ne.alternate)break t;_e=ho(_e),ne=ho(ne)}_e=null}else _e=null;Ie!==null&&Sy(be,xe,Ie,_e,!1),Oe!==null&&Yt!==null&&Sy(be,Yt,Oe,_e,!0)}}e:{if(xe=le?po(le):window,Ie=xe.nodeName&&xe.nodeName.toLowerCase(),Ie==="select"||Ie==="input"&&xe.type==="file")var ze=r4;else if(sy(xe))if(ay)ze=o4;else{ze=i4;var We=s4}else(Ie=xe.nodeName)&&Ie.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(ze=a4);if(ze&&(ze=ze(l,le))){iy(be,ze,p,ye);break e}We&&We(l,xe,le),l==="focusout"&&(We=xe._wrapperState)&&We.controlled&&xe.type==="number"&&Pt(xe,"number",xe.value)}switch(We=le?po(le):window,l){case"focusin":(sy(We)||We.contentEditable==="true")&&(co=We,Hf=le,Tl=null);break;case"focusout":Tl=Hf=co=null;break;case"mousedown":Wf=!0;break;case"contextmenu":case"mouseup":case"dragend":Wf=!1,py(be,p,ye);break;case"selectionchange":if(d4)break;case"keydown":case"keyup":py(be,p,ye)}var Ue;if($f)e:{switch(l){case"compositionstart":var Je="onCompositionStart";break e;case"compositionend":Je="onCompositionEnd";break e;case"compositionupdate":Je="onCompositionUpdate";break e}Je=void 0}else lo?ny(l,p)&&(Je="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(Je="onCompositionStart");Je&&(Z0&&p.locale!=="ko"&&(lo||Je!=="onCompositionStart"?Je==="onCompositionEnd"&&lo&&(Ue=G0()):(fi=ye,Pf="value"in fi?fi.value:fi.textContent,lo=!0)),We=md(le,Je),0<We.length&&(Je=new Q0(Je,l,null,p,ye),be.push({event:Je,listeners:We}),Ue?Je.data=Ue:(Ue=ry(p),Ue!==null&&(Je.data=Ue)))),(Ue=XE?ZE(l,p):e4(l,p))&&(le=md(le,"onBeforeInput"),0<le.length&&(ye=new Q0("onBeforeInput","beforeinput",null,p,ye),be.push({event:ye,listeners:le}),ye.data=Ue))}jy(be,d)})}function Rl(l,d,p){return{instance:l,listener:d,currentTarget:p}}function md(l,d){for(var p=d+"Capture",x=[];l!==null;){var N=l,S=N.stateNode;N.tag===5&&S!==null&&(N=S,S=ls(l,p),S!=null&&x.unshift(Rl(l,S,N)),S=ls(l,d),S!=null&&x.push(Rl(l,S,N))),l=l.return}return x}function ho(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function Sy(l,d,p,x,N){for(var S=d._reactName,T=[];p!==null&&p!==x;){var z=p,K=z.alternate,le=z.stateNode;if(K!==null&&K===x)break;z.tag===5&&le!==null&&(z=le,N?(K=ls(p,S),K!=null&&T.unshift(Rl(p,K,z))):N||(K=ls(p,S),K!=null&&T.push(Rl(p,K,z)))),p=p.return}T.length!==0&&l.push({event:d,listeners:T})}var p4=/\r\n?/g,m4=/\u0000|\uFFFD/g;function Cy(l){return(typeof l=="string"?l:""+l).replace(p4,`
`).replace(m4,"")}function gd(l,d,p){if(d=Cy(d),Cy(l)!==d&&p)throw Error(n(425))}function xd(){}var Yf=null,Qf=null;function Xf(l,d){return l==="textarea"||l==="noscript"||typeof d.children=="string"||typeof d.children=="number"||typeof d.dangerouslySetInnerHTML=="object"&&d.dangerouslySetInnerHTML!==null&&d.dangerouslySetInnerHTML.__html!=null}var Zf=typeof setTimeout=="function"?setTimeout:void 0,g4=typeof clearTimeout=="function"?clearTimeout:void 0,Ey=typeof Promise=="function"?Promise:void 0,x4=typeof queueMicrotask=="function"?queueMicrotask:typeof Ey<"u"?function(l){return Ey.resolve(null).then(l).catch(y4)}:Zf;function y4(l){setTimeout(function(){throw l})}function ep(l,d){var p=d,x=0;do{var N=p.nextSibling;if(l.removeChild(p),N&&N.nodeType===8)if(p=N.data,p==="/$"){if(x===0){l.removeChild(N),wl(d);return}x--}else p!=="$"&&p!=="$?"&&p!=="$!"||x++;p=N}while(p);wl(d)}function mi(l){for(;l!=null;l=l.nextSibling){var d=l.nodeType;if(d===1||d===3)break;if(d===8){if(d=l.data,d==="$"||d==="$!"||d==="$?")break;if(d==="/$")return null}}return l}function Ty(l){l=l.previousSibling;for(var d=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"){if(d===0)return l;d--}else p==="/$"&&d++}l=l.previousSibling}return null}var fo=Math.random().toString(36).slice(2),fs="__reactFiber$"+fo,Il="__reactProps$"+fo,Ms="__reactContainer$"+fo,tp="__reactEvents$"+fo,v4="__reactListeners$"+fo,b4="__reactHandles$"+fo;function ma(l){var d=l[fs];if(d)return d;for(var p=l.parentNode;p;){if(d=p[Ms]||p[fs]){if(p=d.alternate,d.child!==null||p!==null&&p.child!==null)for(l=Ty(l);l!==null;){if(p=l[fs])return p;l=Ty(l)}return d}l=p,p=l.parentNode}return null}function Pl(l){return l=l[fs]||l[Ms],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function po(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function yd(l){return l[Il]||null}var np=[],mo=-1;function gi(l){return{current:l}}function Tt(l){0>mo||(l.current=np[mo],np[mo]=null,mo--)}function kt(l,d){mo++,np[mo]=l.current,l.current=d}var xi={},_n=gi(xi),sr=gi(!1),ga=xi;function go(l,d){var p=l.type.contextTypes;if(!p)return xi;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var N={},S;for(S in p)N[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=N),N}function ir(l){return l=l.childContextTypes,l!=null}function vd(){Tt(sr),Tt(_n)}function My(l,d,p){if(_n.current!==xi)throw Error(n(168));kt(_n,d),kt(sr,p)}function Ay(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var N in x)if(!(N in d))throw Error(n(108,ee(l)||"Unknown",N));return Y({},p,x)}function bd(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||xi,ga=_n.current,kt(_n,l),kt(sr,sr.current),!0}function Ry(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Ay(l,d,ga),x.__reactInternalMemoizedMergedChildContext=l,Tt(sr),Tt(_n),kt(_n,l)):Tt(sr),kt(sr,p)}var As=null,wd=!1,rp=!1;function Iy(l){As===null?As=[l]:As.push(l)}function w4(l){wd=!0,Iy(l)}function yi(){if(!rp&&As!==null){rp=!0;var l=0,d=xt;try{var p=As;for(xt=1;l<p.length;l++){var x=p[l];do x=x(!0);while(x!==null)}As=null,wd=!1}catch(N){throw As!==null&&(As=As.slice(l+1)),Xc(gl,yi),N}finally{xt=d,rp=!1}}return null}var xo=[],yo=0,Nd=null,jd=0,Tr=[],Mr=0,xa=null,Rs=1,Is="";function ya(l,d){xo[yo++]=jd,xo[yo++]=Nd,Nd=l,jd=d}function Py(l,d,p){Tr[Mr++]=Rs,Tr[Mr++]=Is,Tr[Mr++]=xa,xa=l;var x=Rs;l=Is;var N=32-rr(x)-1;x&=~(1<<N),p+=1;var S=32-rr(d)+N;if(30<S){var T=N-N%5;S=(x&(1<<T)-1).toString(32),x>>=T,N-=T,Rs=1<<32-rr(d)+N|p<<N|x,Is=S+l}else Rs=1<<S|p<<N|x,Is=l}function sp(l){l.return!==null&&(ya(l,1),Py(l,1,0))}function ip(l){for(;l===Nd;)Nd=xo[--yo],xo[yo]=null,jd=xo[--yo],xo[yo]=null;for(;l===xa;)xa=Tr[--Mr],Tr[Mr]=null,Is=Tr[--Mr],Tr[Mr]=null,Rs=Tr[--Mr],Tr[Mr]=null}var yr=null,vr=null,Dt=!1,Wr=null;function Oy(l,d){var p=Pr(5,null,null,0);p.elementType="DELETED",p.stateNode=d,p.return=l,d=l.deletions,d===null?(l.deletions=[p],l.flags|=16):d.push(p)}function Dy(l,d){switch(l.tag){case 5:var p=l.type;return d=d.nodeType!==1||p.toLowerCase()!==d.nodeName.toLowerCase()?null:d,d!==null?(l.stateNode=d,yr=l,vr=mi(d.firstChild),!0):!1;case 6:return d=l.pendingProps===""||d.nodeType!==3?null:d,d!==null?(l.stateNode=d,yr=l,vr=null,!0):!1;case 13:return d=d.nodeType!==8?null:d,d!==null?(p=xa!==null?{id:Rs,overflow:Is}:null,l.memoizedState={dehydrated:d,treeContext:p,retryLane:1073741824},p=Pr(18,null,null,0),p.stateNode=d,p.return=l,l.child=p,yr=l,vr=null,!0):!1;default:return!1}}function ap(l){return(l.mode&1)!==0&&(l.flags&128)===0}function op(l){if(Dt){var d=vr;if(d){var p=d;if(!Dy(l,d)){if(ap(l))throw Error(n(418));d=mi(p.nextSibling);var x=yr;d&&Dy(l,d)?Oy(x,p):(l.flags=l.flags&-4097|2,Dt=!1,yr=l)}}else{if(ap(l))throw Error(n(418));l.flags=l.flags&-4097|2,Dt=!1,yr=l}}}function Ly(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;yr=l}function kd(l){if(l!==yr)return!1;if(!Dt)return Ly(l),Dt=!0,!1;var d;if((d=l.tag!==3)&&!(d=l.tag!==5)&&(d=l.type,d=d!=="head"&&d!=="body"&&!Xf(l.type,l.memoizedProps)),d&&(d=vr)){if(ap(l))throw _y(),Error(n(418));for(;d;)Oy(l,d),d=mi(d.nextSibling)}if(Ly(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,d=0;l;){if(l.nodeType===8){var p=l.data;if(p==="/$"){if(d===0){vr=mi(l.nextSibling);break e}d--}else p!=="$"&&p!=="$!"&&p!=="$?"||d++}l=l.nextSibling}vr=null}}else vr=yr?mi(l.stateNode.nextSibling):null;return!0}function _y(){for(var l=vr;l;)l=mi(l.nextSibling)}function vo(){vr=yr=null,Dt=!1}function lp(l){Wr===null?Wr=[l]:Wr.push(l)}var N4=M.ReactCurrentBatchConfig;function Ol(l,d,p){if(l=p.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var x=p.stateNode}if(!x)throw Error(n(147,l));var N=x,S=""+l;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===S?d.ref:(d=function(T){var z=N.refs;T===null?delete z[S]:z[S]=T},d._stringRef=S,d)}if(typeof l!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,l))}return l}function Sd(l,d){throw l=Object.prototype.toString.call(d),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":l))}function zy(l){var d=l._init;return d(l._payload)}function $y(l){function d(ne,J){if(l){var se=ne.deletions;se===null?(ne.deletions=[J],ne.flags|=16):se.push(J)}}function p(ne,J){if(!l)return null;for(;J!==null;)d(ne,J),J=J.sibling;return null}function x(ne,J){for(ne=new Map;J!==null;)J.key!==null?ne.set(J.key,J):ne.set(J.index,J),J=J.sibling;return ne}function N(ne,J){return ne=Ci(ne,J),ne.index=0,ne.sibling=null,ne}function S(ne,J,se){return ne.index=se,l?(se=ne.alternate,se!==null?(se=se.index,se<J?(ne.flags|=2,J):se):(ne.flags|=2,J)):(ne.flags|=1048576,J)}function T(ne){return l&&ne.alternate===null&&(ne.flags|=2),ne}function z(ne,J,se,Ne){return J===null||J.tag!==6?(J=Zp(se,ne.mode,Ne),J.return=ne,J):(J=N(J,se),J.return=ne,J)}function K(ne,J,se,Ne){var ze=se.type;return ze===R?ye(ne,J,se.props.children,Ne,se.key):J!==null&&(J.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===$&&zy(ze)===J.type)?(Ne=N(J,se.props),Ne.ref=Ol(ne,J,se),Ne.return=ne,Ne):(Ne=Jd(se.type,se.key,se.props,null,ne.mode,Ne),Ne.ref=Ol(ne,J,se),Ne.return=ne,Ne)}function le(ne,J,se,Ne){return J===null||J.tag!==4||J.stateNode.containerInfo!==se.containerInfo||J.stateNode.implementation!==se.implementation?(J=em(se,ne.mode,Ne),J.return=ne,J):(J=N(J,se.children||[]),J.return=ne,J)}function ye(ne,J,se,Ne,ze){return J===null||J.tag!==7?(J=Ca(se,ne.mode,Ne,ze),J.return=ne,J):(J=N(J,se),J.return=ne,J)}function be(ne,J,se){if(typeof J=="string"&&J!==""||typeof J=="number")return J=Zp(""+J,ne.mode,se),J.return=ne,J;if(typeof J=="object"&&J!==null){switch(J.$$typeof){case D:return se=Jd(J.type,J.key,J.props,null,ne.mode,se),se.ref=Ol(ne,null,J),se.return=ne,se;case F:return J=em(J,ne.mode,se),J.return=ne,J;case $:var Ne=J._init;return be(ne,Ne(J._payload),se)}if(Jt(J)||ae(J))return J=Ca(J,ne.mode,se,null),J.return=ne,J;Sd(ne,J)}return null}function xe(ne,J,se,Ne){var ze=J!==null?J.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return ze!==null?null:z(ne,J,""+se,Ne);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case D:return se.key===ze?K(ne,J,se,Ne):null;case F:return se.key===ze?le(ne,J,se,Ne):null;case $:return ze=se._init,xe(ne,J,ze(se._payload),Ne)}if(Jt(se)||ae(se))return ze!==null?null:ye(ne,J,se,Ne,null);Sd(ne,se)}return null}function Ie(ne,J,se,Ne,ze){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number")return ne=ne.get(se)||null,z(J,ne,""+Ne,ze);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case D:return ne=ne.get(Ne.key===null?se:Ne.key)||null,K(J,ne,Ne,ze);case F:return ne=ne.get(Ne.key===null?se:Ne.key)||null,le(J,ne,Ne,ze);case $:var We=Ne._init;return Ie(ne,J,se,We(Ne._payload),ze)}if(Jt(Ne)||ae(Ne))return ne=ne.get(se)||null,ye(J,ne,Ne,ze,null);Sd(J,Ne)}return null}function Oe(ne,J,se,Ne){for(var ze=null,We=null,Ue=J,Je=J=0,yn=null;Ue!==null&&Je<se.length;Je++){Ue.index>Je?(yn=Ue,Ue=null):yn=Ue.sibling;var ut=xe(ne,Ue,se[Je],Ne);if(ut===null){Ue===null&&(Ue=yn);break}l&&Ue&&ut.alternate===null&&d(ne,Ue),J=S(ut,J,Je),We===null?ze=ut:We.sibling=ut,We=ut,Ue=yn}if(Je===se.length)return p(ne,Ue),Dt&&ya(ne,Je),ze;if(Ue===null){for(;Je<se.length;Je++)Ue=be(ne,se[Je],Ne),Ue!==null&&(J=S(Ue,J,Je),We===null?ze=Ue:We.sibling=Ue,We=Ue);return Dt&&ya(ne,Je),ze}for(Ue=x(ne,Ue);Je<se.length;Je++)yn=Ie(Ue,ne,Je,se[Je],Ne),yn!==null&&(l&&yn.alternate!==null&&Ue.delete(yn.key===null?Je:yn.key),J=S(yn,J,Je),We===null?ze=yn:We.sibling=yn,We=yn);return l&&Ue.forEach(function(Ei){return d(ne,Ei)}),Dt&&ya(ne,Je),ze}function _e(ne,J,se,Ne){var ze=ae(se);if(typeof ze!="function")throw Error(n(150));if(se=ze.call(se),se==null)throw Error(n(151));for(var We=ze=null,Ue=J,Je=J=0,yn=null,ut=se.next();Ue!==null&&!ut.done;Je++,ut=se.next()){Ue.index>Je?(yn=Ue,Ue=null):yn=Ue.sibling;var Ei=xe(ne,Ue,ut.value,Ne);if(Ei===null){Ue===null&&(Ue=yn);break}l&&Ue&&Ei.alternate===null&&d(ne,Ue),J=S(Ei,J,Je),We===null?ze=Ei:We.sibling=Ei,We=Ei,Ue=yn}if(ut.done)return p(ne,Ue),Dt&&ya(ne,Je),ze;if(Ue===null){for(;!ut.done;Je++,ut=se.next())ut=be(ne,ut.value,Ne),ut!==null&&(J=S(ut,J,Je),We===null?ze=ut:We.sibling=ut,We=ut);return Dt&&ya(ne,Je),ze}for(Ue=x(ne,Ue);!ut.done;Je++,ut=se.next())ut=Ie(Ue,ne,Je,ut.value,Ne),ut!==null&&(l&&ut.alternate!==null&&Ue.delete(ut.key===null?Je:ut.key),J=S(ut,J,Je),We===null?ze=ut:We.sibling=ut,We=ut);return l&&Ue.forEach(function(t3){return d(ne,t3)}),Dt&&ya(ne,Je),ze}function Yt(ne,J,se,Ne){if(typeof se=="object"&&se!==null&&se.type===R&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case D:e:{for(var ze=se.key,We=J;We!==null;){if(We.key===ze){if(ze=se.type,ze===R){if(We.tag===7){p(ne,We.sibling),J=N(We,se.props.children),J.return=ne,ne=J;break e}}else if(We.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===$&&zy(ze)===We.type){p(ne,We.sibling),J=N(We,se.props),J.ref=Ol(ne,We,se),J.return=ne,ne=J;break e}p(ne,We);break}else d(ne,We);We=We.sibling}se.type===R?(J=Ca(se.props.children,ne.mode,Ne,se.key),J.return=ne,ne=J):(Ne=Jd(se.type,se.key,se.props,null,ne.mode,Ne),Ne.ref=Ol(ne,J,se),Ne.return=ne,ne=Ne)}return T(ne);case F:e:{for(We=se.key;J!==null;){if(J.key===We)if(J.tag===4&&J.stateNode.containerInfo===se.containerInfo&&J.stateNode.implementation===se.implementation){p(ne,J.sibling),J=N(J,se.children||[]),J.return=ne,ne=J;break e}else{p(ne,J);break}else d(ne,J);J=J.sibling}J=em(se,ne.mode,Ne),J.return=ne,ne=J}return T(ne);case $:return We=se._init,Yt(ne,J,We(se._payload),Ne)}if(Jt(se))return Oe(ne,J,se,Ne);if(ae(se))return _e(ne,J,se,Ne);Sd(ne,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,J!==null&&J.tag===6?(p(ne,J.sibling),J=N(J,se),J.return=ne,ne=J):(p(ne,J),J=Zp(se,ne.mode,Ne),J.return=ne,ne=J),T(ne)):p(ne,J)}return Yt}var bo=$y(!0),Fy=$y(!1),Cd=gi(null),Ed=null,wo=null,cp=null;function dp(){cp=wo=Ed=null}function up(l){var d=Cd.current;Tt(Cd),l._currentValue=d}function hp(l,d,p){for(;l!==null;){var x=l.alternate;if((l.childLanes&d)!==d?(l.childLanes|=d,x!==null&&(x.childLanes|=d)):x!==null&&(x.childLanes&d)!==d&&(x.childLanes|=d),l===p)break;l=l.return}}function No(l,d){Ed=l,cp=wo=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(ar=!0),l.firstContext=null)}function Ar(l){var d=l._currentValue;if(cp!==l)if(l={context:l,memoizedValue:d,next:null},wo===null){if(Ed===null)throw Error(n(308));wo=l,Ed.dependencies={lanes:0,firstContext:l}}else wo=wo.next=l;return d}var va=null;function fp(l){va===null?va=[l]:va.push(l)}function By(l,d,p,x){var N=d.interleaved;return N===null?(p.next=p,fp(d)):(p.next=N.next,N.next=p),d.interleaved=p,Ps(l,x)}function Ps(l,d){l.lanes|=d;var p=l.alternate;for(p!==null&&(p.lanes|=d),p=l,l=l.return;l!==null;)l.childLanes|=d,p=l.alternate,p!==null&&(p.childLanes|=d),p=l,l=l.return;return p.tag===3?p.stateNode:null}var vi=!1;function pp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Vy(l,d){l=l.updateQueue,d.updateQueue===l&&(d.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function Os(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function bi(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(dt&2)!==0){var N=x.pending;return N===null?d.next=d:(d.next=N.next,N.next=d),x.pending=d,Ps(l,p)}return N=x.interleaved,N===null?(d.next=d,fp(x)):(d.next=N.next,N.next=d),x.interleaved=d,Ps(l,p)}function Td(l,d,p){if(d=d.updateQueue,d!==null&&(d=d.shared,(p&4194240)!==0)){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Tf(l,p)}}function Hy(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var N=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var T={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?N=S=T:S=S.next=T,p=p.next}while(p!==null);S===null?N=S=d:S=S.next=d}else N=S=d;p={baseState:x.baseState,firstBaseUpdate:N,lastBaseUpdate:S,shared:x.shared,effects:x.effects},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=d:l.next=d,p.lastBaseUpdate=d}function Md(l,d,p,x){var N=l.updateQueue;vi=!1;var S=N.firstBaseUpdate,T=N.lastBaseUpdate,z=N.shared.pending;if(z!==null){N.shared.pending=null;var K=z,le=K.next;K.next=null,T===null?S=le:T.next=le,T=K;var ye=l.alternate;ye!==null&&(ye=ye.updateQueue,z=ye.lastBaseUpdate,z!==T&&(z===null?ye.firstBaseUpdate=le:z.next=le,ye.lastBaseUpdate=K))}if(S!==null){var be=N.baseState;T=0,ye=le=K=null,z=S;do{var xe=z.lane,Ie=z.eventTime;if((x&xe)===xe){ye!==null&&(ye=ye.next={eventTime:Ie,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Oe=l,_e=z;switch(xe=d,Ie=p,_e.tag){case 1:if(Oe=_e.payload,typeof Oe=="function"){be=Oe.call(Ie,be,xe);break e}be=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=_e.payload,xe=typeof Oe=="function"?Oe.call(Ie,be,xe):Oe,xe==null)break e;be=Y({},be,xe);break e;case 2:vi=!0}}z.callback!==null&&z.lane!==0&&(l.flags|=64,xe=N.effects,xe===null?N.effects=[z]:xe.push(z))}else Ie={eventTime:Ie,lane:xe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},ye===null?(le=ye=Ie,K=be):ye=ye.next=Ie,T|=xe;if(z=z.next,z===null){if(z=N.shared.pending,z===null)break;xe=z,z=xe.next,xe.next=null,N.lastBaseUpdate=xe,N.shared.pending=null}}while(!0);if(ye===null&&(K=be),N.baseState=K,N.firstBaseUpdate=le,N.lastBaseUpdate=ye,d=N.shared.interleaved,d!==null){N=d;do T|=N.lane,N=N.next;while(N!==d)}else S===null&&(N.shared.lanes=0);Na|=T,l.lanes=T,l.memoizedState=be}}function Wy(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;d<l.length;d++){var x=l[d],N=x.callback;if(N!==null){if(x.callback=null,x=p,typeof N!="function")throw Error(n(191,N));N.call(x)}}}var Dl={},ps=gi(Dl),Ll=gi(Dl),_l=gi(Dl);function ba(l){if(l===Dl)throw Error(n(174));return l}function mp(l,d){switch(kt(_l,d),kt(Ll,l),kt(ps,Dl),l=d.nodeType,l){case 9:case 11:d=(d=d.documentElement)?d.namespaceURI:On(null,"");break;default:l=l===8?d.parentNode:d,d=l.namespaceURI||null,l=l.tagName,d=On(d,l)}Tt(ps),kt(ps,d)}function jo(){Tt(ps),Tt(Ll),Tt(_l)}function Uy(l){ba(_l.current);var d=ba(ps.current),p=On(d,l.type);d!==p&&(kt(Ll,l),kt(ps,p))}function gp(l){Ll.current===l&&(Tt(ps),Tt(Ll))}var Ft=gi(0);function Ad(l){for(var d=l;d!==null;){if(d.tag===13){var p=d.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===l)break;for(;d.sibling===null;){if(d.return===null||d.return===l)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var xp=[];function yp(){for(var l=0;l<xp.length;l++)xp[l]._workInProgressVersionPrimary=null;xp.length=0}var Rd=M.ReactCurrentDispatcher,vp=M.ReactCurrentBatchConfig,wa=0,Bt=null,cn=null,gn=null,Id=!1,zl=!1,$l=0,j4=0;function zn(){throw Error(n(321))}function bp(l,d){if(d===null)return!1;for(var p=0;p<d.length&&p<l.length;p++)if(!Hr(l[p],d[p]))return!1;return!0}function wp(l,d,p,x,N,S){if(wa=S,Bt=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,Rd.current=l===null||l.memoizedState===null?E4:T4,l=p(x,N),zl){S=0;do{if(zl=!1,$l=0,25<=S)throw Error(n(301));S+=1,gn=cn=null,d.updateQueue=null,Rd.current=M4,l=p(x,N)}while(zl)}if(Rd.current=Dd,d=cn!==null&&cn.next!==null,wa=0,gn=cn=Bt=null,Id=!1,d)throw Error(n(300));return l}function Np(){var l=$l!==0;return $l=0,l}function ms(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gn===null?Bt.memoizedState=gn=l:gn=gn.next=l,gn}function Rr(){if(cn===null){var l=Bt.alternate;l=l!==null?l.memoizedState:null}else l=cn.next;var d=gn===null?Bt.memoizedState:gn.next;if(d!==null)gn=d,cn=l;else{if(l===null)throw Error(n(310));cn=l,l={memoizedState:cn.memoizedState,baseState:cn.baseState,baseQueue:cn.baseQueue,queue:cn.queue,next:null},gn===null?Bt.memoizedState=gn=l:gn=gn.next=l}return gn}function Fl(l,d){return typeof d=="function"?d(l):d}function jp(l){var d=Rr(),p=d.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=l;var x=cn,N=x.baseQueue,S=p.pending;if(S!==null){if(N!==null){var T=N.next;N.next=S.next,S.next=T}x.baseQueue=N=S,p.pending=null}if(N!==null){S=N.next,x=x.baseState;var z=T=null,K=null,le=S;do{var ye=le.lane;if((wa&ye)===ye)K!==null&&(K=K.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),x=le.hasEagerState?le.eagerState:l(x,le.action);else{var be={lane:ye,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};K===null?(z=K=be,T=x):K=K.next=be,Bt.lanes|=ye,Na|=ye}le=le.next}while(le!==null&&le!==S);K===null?T=x:K.next=z,Hr(x,d.memoizedState)||(ar=!0),d.memoizedState=x,d.baseState=T,d.baseQueue=K,p.lastRenderedState=x}if(l=p.interleaved,l!==null){N=l;do S=N.lane,Bt.lanes|=S,Na|=S,N=N.next;while(N!==l)}else N===null&&(p.lanes=0);return[d.memoizedState,p.dispatch]}function kp(l){var d=Rr(),p=d.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=l;var x=p.dispatch,N=p.pending,S=d.memoizedState;if(N!==null){p.pending=null;var T=N=N.next;do S=l(S,T.action),T=T.next;while(T!==N);Hr(S,d.memoizedState)||(ar=!0),d.memoizedState=S,d.baseQueue===null&&(d.baseState=S),p.lastRenderedState=S}return[S,x]}function Ky(){}function qy(l,d){var p=Bt,x=Rr(),N=d(),S=!Hr(x.memoizedState,N);if(S&&(x.memoizedState=N,ar=!0),x=x.queue,Sp(Yy.bind(null,p,x,l),[l]),x.getSnapshot!==d||S||gn!==null&&gn.memoizedState.tag&1){if(p.flags|=2048,Bl(9,Jy.bind(null,p,x,N,d),void 0,null),xn===null)throw Error(n(349));(wa&30)!==0||Gy(p,d,N)}return N}function Gy(l,d,p){l.flags|=16384,l={getSnapshot:d,value:p},d=Bt.updateQueue,d===null?(d={lastEffect:null,stores:null},Bt.updateQueue=d,d.stores=[l]):(p=d.stores,p===null?d.stores=[l]:p.push(l))}function Jy(l,d,p,x){d.value=p,d.getSnapshot=x,Qy(d)&&Xy(l)}function Yy(l,d,p){return p(function(){Qy(d)&&Xy(l)})}function Qy(l){var d=l.getSnapshot;l=l.value;try{var p=d();return!Hr(l,p)}catch{return!0}}function Xy(l){var d=Ps(l,1);d!==null&&Gr(d,l,1,-1)}function Zy(l){var d=ms();return typeof l=="function"&&(l=l()),d.memoizedState=d.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fl,lastRenderedState:l},d.queue=l,l=l.dispatch=C4.bind(null,Bt,l),[d.memoizedState,l]}function Bl(l,d,p,x){return l={tag:l,create:d,destroy:p,deps:x,next:null},d=Bt.updateQueue,d===null?(d={lastEffect:null,stores:null},Bt.updateQueue=d,d.lastEffect=l.next=l):(p=d.lastEffect,p===null?d.lastEffect=l.next=l:(x=p.next,p.next=l,l.next=x,d.lastEffect=l)),l}function ev(){return Rr().memoizedState}function Pd(l,d,p,x){var N=ms();Bt.flags|=l,N.memoizedState=Bl(1|d,p,void 0,x===void 0?null:x)}function Od(l,d,p,x){var N=Rr();x=x===void 0?null:x;var S=void 0;if(cn!==null){var T=cn.memoizedState;if(S=T.destroy,x!==null&&bp(x,T.deps)){N.memoizedState=Bl(d,p,S,x);return}}Bt.flags|=l,N.memoizedState=Bl(1|d,p,S,x)}function tv(l,d){return Pd(8390656,8,l,d)}function Sp(l,d){return Od(2048,8,l,d)}function nv(l,d){return Od(4,2,l,d)}function rv(l,d){return Od(4,4,l,d)}function sv(l,d){if(typeof d=="function")return l=l(),d(l),function(){d(null)};if(d!=null)return l=l(),d.current=l,function(){d.current=null}}function iv(l,d,p){return p=p!=null?p.concat([l]):null,Od(4,4,sv.bind(null,d,l),p)}function Cp(){}function av(l,d){var p=Rr();d=d===void 0?null:d;var x=p.memoizedState;return x!==null&&d!==null&&bp(d,x[1])?x[0]:(p.memoizedState=[l,d],l)}function ov(l,d){var p=Rr();d=d===void 0?null:d;var x=p.memoizedState;return x!==null&&d!==null&&bp(d,x[1])?x[0]:(l=l(),p.memoizedState=[l,d],l)}function lv(l,d,p){return(wa&21)===0?(l.baseState&&(l.baseState=!1,ar=!0),l.memoizedState=p):(Hr(p,d)||(p=io(),Bt.lanes|=p,Na|=p,l.baseState=!0),d)}function k4(l,d){var p=xt;xt=p!==0&&4>p?p:4,l(!0);var x=vp.transition;vp.transition={};try{l(!1),d()}finally{xt=p,vp.transition=x}}function cv(){return Rr().memoizedState}function S4(l,d,p){var x=ki(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},dv(l))uv(d,p);else if(p=By(l,d,p,x),p!==null){var N=Xn();Gr(p,l,x,N),hv(p,d,x)}}function C4(l,d,p){var x=ki(l),N={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(dv(l))uv(d,N);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var T=d.lastRenderedState,z=S(T,p);if(N.hasEagerState=!0,N.eagerState=z,Hr(z,T)){var K=d.interleaved;K===null?(N.next=N,fp(d)):(N.next=K.next,K.next=N),d.interleaved=N;return}}catch{}finally{}p=By(l,d,N,x),p!==null&&(N=Xn(),Gr(p,l,x,N),hv(p,d,x))}}function dv(l){var d=l.alternate;return l===Bt||d!==null&&d===Bt}function uv(l,d){zl=Id=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function hv(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Tf(l,p)}}var Dd={readContext:Ar,useCallback:zn,useContext:zn,useEffect:zn,useImperativeHandle:zn,useInsertionEffect:zn,useLayoutEffect:zn,useMemo:zn,useReducer:zn,useRef:zn,useState:zn,useDebugValue:zn,useDeferredValue:zn,useTransition:zn,useMutableSource:zn,useSyncExternalStore:zn,useId:zn,unstable_isNewReconciler:!1},E4={readContext:Ar,useCallback:function(l,d){return ms().memoizedState=[l,d===void 0?null:d],l},useContext:Ar,useEffect:tv,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Pd(4194308,4,sv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Pd(4194308,4,l,d)},useInsertionEffect:function(l,d){return Pd(4,2,l,d)},useMemo:function(l,d){var p=ms();return d=d===void 0?null:d,l=l(),p.memoizedState=[l,d],l},useReducer:function(l,d,p){var x=ms();return d=p!==void 0?p(d):d,x.memoizedState=x.baseState=d,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:d},x.queue=l,l=l.dispatch=S4.bind(null,Bt,l),[x.memoizedState,l]},useRef:function(l){var d=ms();return l={current:l},d.memoizedState=l},useState:Zy,useDebugValue:Cp,useDeferredValue:function(l){return ms().memoizedState=l},useTransition:function(){var l=Zy(!1),d=l[0];return l=k4.bind(null,l[1]),ms().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=Bt,N=ms();if(Dt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),xn===null)throw Error(n(349));(wa&30)!==0||Gy(x,d,p)}N.memoizedState=p;var S={value:p,getSnapshot:d};return N.queue=S,tv(Yy.bind(null,x,S,l),[l]),x.flags|=2048,Bl(9,Jy.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=ms(),d=xn.identifierPrefix;if(Dt){var p=Is,x=Rs;p=(x&~(1<<32-rr(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=$l++,0<p&&(d+="H"+p.toString(32)),d+=":"}else p=j4++,d=":"+d+"r"+p.toString(32)+":";return l.memoizedState=d},unstable_isNewReconciler:!1},T4={readContext:Ar,useCallback:av,useContext:Ar,useEffect:Sp,useImperativeHandle:iv,useInsertionEffect:nv,useLayoutEffect:rv,useMemo:ov,useReducer:jp,useRef:ev,useState:function(){return jp(Fl)},useDebugValue:Cp,useDeferredValue:function(l){var d=Rr();return lv(d,cn.memoizedState,l)},useTransition:function(){var l=jp(Fl)[0],d=Rr().memoizedState;return[l,d]},useMutableSource:Ky,useSyncExternalStore:qy,useId:cv,unstable_isNewReconciler:!1},M4={readContext:Ar,useCallback:av,useContext:Ar,useEffect:Sp,useImperativeHandle:iv,useInsertionEffect:nv,useLayoutEffect:rv,useMemo:ov,useReducer:kp,useRef:ev,useState:function(){return kp(Fl)},useDebugValue:Cp,useDeferredValue:function(l){var d=Rr();return cn===null?d.memoizedState=l:lv(d,cn.memoizedState,l)},useTransition:function(){var l=kp(Fl)[0],d=Rr().memoizedState;return[l,d]},useMutableSource:Ky,useSyncExternalStore:qy,useId:cv,unstable_isNewReconciler:!1};function Ur(l,d){if(l&&l.defaultProps){d=Y({},d),l=l.defaultProps;for(var p in l)d[p]===void 0&&(d[p]=l[p]);return d}return d}function Ep(l,d,p,x){d=l.memoizedState,p=p(x,d),p=p==null?d:Y({},d,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var Ld={isMounted:function(l){return(l=l._reactInternals)?us(l)===l:!1},enqueueSetState:function(l,d,p){l=l._reactInternals;var x=Xn(),N=ki(l),S=Os(x,N);S.payload=d,p!=null&&(S.callback=p),d=bi(l,S,N),d!==null&&(Gr(d,l,N,x),Td(d,l,N))},enqueueReplaceState:function(l,d,p){l=l._reactInternals;var x=Xn(),N=ki(l),S=Os(x,N);S.tag=1,S.payload=d,p!=null&&(S.callback=p),d=bi(l,S,N),d!==null&&(Gr(d,l,N,x),Td(d,l,N))},enqueueForceUpdate:function(l,d){l=l._reactInternals;var p=Xn(),x=ki(l),N=Os(p,x);N.tag=2,d!=null&&(N.callback=d),d=bi(l,N,x),d!==null&&(Gr(d,l,x,p),Td(d,l,x))}};function fv(l,d,p,x,N,S,T){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,S,T):d.prototype&&d.prototype.isPureReactComponent?!El(p,x)||!El(N,S):!0}function pv(l,d,p){var x=!1,N=xi,S=d.contextType;return typeof S=="object"&&S!==null?S=Ar(S):(N=ir(d)?ga:_n.current,x=d.contextTypes,S=(x=x!=null)?go(l,N):xi),d=new d(p,S),l.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Ld,l.stateNode=d,d._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=N,l.__reactInternalMemoizedMaskedChildContext=S),d}function mv(l,d,p,x){l=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(p,x),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(p,x),d.state!==l&&Ld.enqueueReplaceState(d,d.state,null)}function Tp(l,d,p,x){var N=l.stateNode;N.props=p,N.state=l.memoizedState,N.refs={},pp(l);var S=d.contextType;typeof S=="object"&&S!==null?N.context=Ar(S):(S=ir(d)?ga:_n.current,N.context=go(l,S)),N.state=l.memoizedState,S=d.getDerivedStateFromProps,typeof S=="function"&&(Ep(l,d,S,p),N.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof N.getSnapshotBeforeUpdate=="function"||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(d=N.state,typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount(),d!==N.state&&Ld.enqueueReplaceState(N,N.state,null),Md(l,p,N,x),N.state=l.memoizedState),typeof N.componentDidMount=="function"&&(l.flags|=4194308)}function ko(l,d){try{var p="",x=d;do p+=he(x),x=x.return;while(x);var N=p}catch(S){N=`
Error generating stack: `+S.message+`
`+S.stack}return{value:l,source:d,stack:N,digest:null}}function Mp(l,d,p){return{value:l,source:null,stack:p??null,digest:d??null}}function Ap(l,d){try{console.error(d.value)}catch(p){setTimeout(function(){throw p})}}var A4=typeof WeakMap=="function"?WeakMap:Map;function gv(l,d,p){p=Os(-1,p),p.tag=3,p.payload={element:null};var x=d.value;return p.callback=function(){Hd||(Hd=!0,Up=x),Ap(l,d)},p}function xv(l,d,p){p=Os(-1,p),p.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var N=d.value;p.payload=function(){return x(N)},p.callback=function(){Ap(l,d)}}var S=l.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){Ap(l,d),typeof x!="function"&&(Ni===null?Ni=new Set([this]):Ni.add(this));var T=d.stack;this.componentDidCatch(d.value,{componentStack:T!==null?T:""})}),p}function yv(l,d,p){var x=l.pingCache;if(x===null){x=l.pingCache=new A4;var N=new Set;x.set(d,N)}else N=x.get(d),N===void 0&&(N=new Set,x.set(d,N));N.has(p)||(N.add(p),l=W4.bind(null,l,d,p),d.then(l,l))}function vv(l){do{var d;if((d=l.tag===13)&&(d=l.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return l;l=l.return}while(l!==null);return null}function bv(l,d,p,x,N){return(l.mode&1)===0?(l===d?l.flags|=65536:(l.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(d=Os(-1,1),d.tag=2,bi(p,d,1))),p.lanes|=1),l):(l.flags|=65536,l.lanes=N,l)}var R4=M.ReactCurrentOwner,ar=!1;function Qn(l,d,p,x){d.child=l===null?Fy(d,null,p,x):bo(d,l.child,p,x)}function wv(l,d,p,x,N){p=p.render;var S=d.ref;return No(d,N),x=wp(l,d,p,x,S,N),p=Np(),l!==null&&!ar?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~N,Ds(l,d,N)):(Dt&&p&&sp(d),d.flags|=1,Qn(l,d,x,N),d.child)}function Nv(l,d,p,x,N){if(l===null){var S=p.type;return typeof S=="function"&&!Xp(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(d.tag=15,d.type=S,jv(l,d,S,x,N)):(l=Jd(p.type,null,x,d,d.mode,N),l.ref=d.ref,l.return=d,d.child=l)}if(S=l.child,(l.lanes&N)===0){var T=S.memoizedProps;if(p=p.compare,p=p!==null?p:El,p(T,x)&&l.ref===d.ref)return Ds(l,d,N)}return d.flags|=1,l=Ci(S,x),l.ref=d.ref,l.return=d,d.child=l}function jv(l,d,p,x,N){if(l!==null){var S=l.memoizedProps;if(El(S,x)&&l.ref===d.ref)if(ar=!1,d.pendingProps=x=S,(l.lanes&N)!==0)(l.flags&131072)!==0&&(ar=!0);else return d.lanes=l.lanes,Ds(l,d,N)}return Rp(l,d,p,x,N)}function kv(l,d,p){var x=d.pendingProps,N=x.children,S=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},kt(Co,br),br|=p;else{if((p&1073741824)===0)return l=S!==null?S.baseLanes|p:p,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:l,cachePool:null,transitions:null},d.updateQueue=null,kt(Co,br),br|=l,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=S!==null?S.baseLanes:p,kt(Co,br),br|=x}else S!==null?(x=S.baseLanes|p,d.memoizedState=null):x=p,kt(Co,br),br|=x;return Qn(l,d,N,p),d.child}function Sv(l,d){var p=d.ref;(l===null&&p!==null||l!==null&&l.ref!==p)&&(d.flags|=512,d.flags|=2097152)}function Rp(l,d,p,x,N){var S=ir(p)?ga:_n.current;return S=go(d,S),No(d,N),p=wp(l,d,p,x,S,N),x=Np(),l!==null&&!ar?(d.updateQueue=l.updateQueue,d.flags&=-2053,l.lanes&=~N,Ds(l,d,N)):(Dt&&x&&sp(d),d.flags|=1,Qn(l,d,p,N),d.child)}function Cv(l,d,p,x,N){if(ir(p)){var S=!0;bd(d)}else S=!1;if(No(d,N),d.stateNode===null)zd(l,d),pv(d,p,x),Tp(d,p,x,N),x=!0;else if(l===null){var T=d.stateNode,z=d.memoizedProps;T.props=z;var K=T.context,le=p.contextType;typeof le=="object"&&le!==null?le=Ar(le):(le=ir(p)?ga:_n.current,le=go(d,le));var ye=p.getDerivedStateFromProps,be=typeof ye=="function"||typeof T.getSnapshotBeforeUpdate=="function";be||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(z!==x||K!==le)&&mv(d,T,x,le),vi=!1;var xe=d.memoizedState;T.state=xe,Md(d,x,T,N),K=d.memoizedState,z!==x||xe!==K||sr.current||vi?(typeof ye=="function"&&(Ep(d,p,ye,x),K=d.memoizedState),(z=vi||fv(d,p,z,x,xe,K,le))?(be||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(d.flags|=4194308)):(typeof T.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=x,d.memoizedState=K),T.props=x,T.state=K,T.context=le,x=z):(typeof T.componentDidMount=="function"&&(d.flags|=4194308),x=!1)}else{T=d.stateNode,Vy(l,d),z=d.memoizedProps,le=d.type===d.elementType?z:Ur(d.type,z),T.props=le,be=d.pendingProps,xe=T.context,K=p.contextType,typeof K=="object"&&K!==null?K=Ar(K):(K=ir(p)?ga:_n.current,K=go(d,K));var Ie=p.getDerivedStateFromProps;(ye=typeof Ie=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(z!==be||xe!==K)&&mv(d,T,x,K),vi=!1,xe=d.memoizedState,T.state=xe,Md(d,x,T,N);var Oe=d.memoizedState;z!==be||xe!==Oe||sr.current||vi?(typeof Ie=="function"&&(Ep(d,p,Ie,x),Oe=d.memoizedState),(le=vi||fv(d,p,le,x,xe,Oe,K)||!1)?(ye||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(x,Oe,K),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(x,Oe,K)),typeof T.componentDidUpdate=="function"&&(d.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof T.componentDidUpdate!="function"||z===l.memoizedProps&&xe===l.memoizedState||(d.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||z===l.memoizedProps&&xe===l.memoizedState||(d.flags|=1024),d.memoizedProps=x,d.memoizedState=Oe),T.props=x,T.state=Oe,T.context=K,x=le):(typeof T.componentDidUpdate!="function"||z===l.memoizedProps&&xe===l.memoizedState||(d.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||z===l.memoizedProps&&xe===l.memoizedState||(d.flags|=1024),x=!1)}return Ip(l,d,p,x,S,N)}function Ip(l,d,p,x,N,S){Sv(l,d);var T=(d.flags&128)!==0;if(!x&&!T)return N&&Ry(d,p,!1),Ds(l,d,S);x=d.stateNode,R4.current=d;var z=T&&typeof p.getDerivedStateFromError!="function"?null:x.render();return d.flags|=1,l!==null&&T?(d.child=bo(d,l.child,null,S),d.child=bo(d,null,z,S)):Qn(l,d,z,S),d.memoizedState=x.state,N&&Ry(d,p,!0),d.child}function Ev(l){var d=l.stateNode;d.pendingContext?My(l,d.pendingContext,d.pendingContext!==d.context):d.context&&My(l,d.context,!1),mp(l,d.containerInfo)}function Tv(l,d,p,x,N){return vo(),lp(N),d.flags|=256,Qn(l,d,p,x),d.child}var Pp={dehydrated:null,treeContext:null,retryLane:0};function Op(l){return{baseLanes:l,cachePool:null,transitions:null}}function Mv(l,d,p){var x=d.pendingProps,N=Ft.current,S=!1,T=(d.flags&128)!==0,z;if((z=T)||(z=l!==null&&l.memoizedState===null?!1:(N&2)!==0),z?(S=!0,d.flags&=-129):(l===null||l.memoizedState!==null)&&(N|=1),kt(Ft,N&1),l===null)return op(d),l=d.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((d.mode&1)===0?d.lanes=1:l.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(T=x.children,l=x.fallback,S?(x=d.mode,S=d.child,T={mode:"hidden",children:T},(x&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=T):S=Yd(T,x,0,null),l=Ca(l,x,p,null),S.return=d,l.return=d,S.sibling=l,d.child=S,d.child.memoizedState=Op(p),d.memoizedState=Pp,l):Dp(d,T));if(N=l.memoizedState,N!==null&&(z=N.dehydrated,z!==null))return I4(l,d,T,x,z,N,p);if(S){S=x.fallback,T=d.mode,N=l.child,z=N.sibling;var K={mode:"hidden",children:x.children};return(T&1)===0&&d.child!==N?(x=d.child,x.childLanes=0,x.pendingProps=K,d.deletions=null):(x=Ci(N,K),x.subtreeFlags=N.subtreeFlags&14680064),z!==null?S=Ci(z,S):(S=Ca(S,T,p,null),S.flags|=2),S.return=d,x.return=d,x.sibling=S,d.child=x,x=S,S=d.child,T=l.child.memoizedState,T=T===null?Op(p):{baseLanes:T.baseLanes|p,cachePool:null,transitions:T.transitions},S.memoizedState=T,S.childLanes=l.childLanes&~p,d.memoizedState=Pp,x}return S=l.child,l=S.sibling,x=Ci(S,{mode:"visible",children:x.children}),(d.mode&1)===0&&(x.lanes=p),x.return=d,x.sibling=null,l!==null&&(p=d.deletions,p===null?(d.deletions=[l],d.flags|=16):p.push(l)),d.child=x,d.memoizedState=null,x}function Dp(l,d){return d=Yd({mode:"visible",children:d},l.mode,0,null),d.return=l,l.child=d}function _d(l,d,p,x){return x!==null&&lp(x),bo(d,l.child,null,p),l=Dp(d,d.pendingProps.children),l.flags|=2,d.memoizedState=null,l}function I4(l,d,p,x,N,S,T){if(p)return d.flags&256?(d.flags&=-257,x=Mp(Error(n(422))),_d(l,d,T,x)):d.memoizedState!==null?(d.child=l.child,d.flags|=128,null):(S=x.fallback,N=d.mode,x=Yd({mode:"visible",children:x.children},N,0,null),S=Ca(S,N,T,null),S.flags|=2,x.return=d,S.return=d,x.sibling=S,d.child=x,(d.mode&1)!==0&&bo(d,l.child,null,T),d.child.memoizedState=Op(T),d.memoizedState=Pp,S);if((d.mode&1)===0)return _d(l,d,T,null);if(N.data==="$!"){if(x=N.nextSibling&&N.nextSibling.dataset,x)var z=x.dgst;return x=z,S=Error(n(419)),x=Mp(S,x,void 0),_d(l,d,T,x)}if(z=(T&l.childLanes)!==0,ar||z){if(x=xn,x!==null){switch(T&-T){case 4:N=2;break;case 16:N=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:N=32;break;case 536870912:N=268435456;break;default:N=0}N=(N&(x.suspendedLanes|T))!==0?0:N,N!==0&&N!==S.retryLane&&(S.retryLane=N,Ps(l,N),Gr(x,l,N,-1))}return Qp(),x=Mp(Error(n(421))),_d(l,d,T,x)}return N.data==="$?"?(d.flags|=128,d.child=l.child,d=U4.bind(null,l),N._reactRetry=d,null):(l=S.treeContext,vr=mi(N.nextSibling),yr=d,Dt=!0,Wr=null,l!==null&&(Tr[Mr++]=Rs,Tr[Mr++]=Is,Tr[Mr++]=xa,Rs=l.id,Is=l.overflow,xa=d),d=Dp(d,x.children),d.flags|=4096,d)}function Av(l,d,p){l.lanes|=d;var x=l.alternate;x!==null&&(x.lanes|=d),hp(l.return,d,p)}function Lp(l,d,p,x,N){var S=l.memoizedState;S===null?l.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:N}:(S.isBackwards=d,S.rendering=null,S.renderingStartTime=0,S.last=x,S.tail=p,S.tailMode=N)}function Rv(l,d,p){var x=d.pendingProps,N=x.revealOrder,S=x.tail;if(Qn(l,d,x.children,p),x=Ft.current,(x&2)!==0)x=x&1|2,d.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=d.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&Av(l,p,d);else if(l.tag===19)Av(l,p,d);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===d)break e;for(;l.sibling===null;){if(l.return===null||l.return===d)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(kt(Ft,x),(d.mode&1)===0)d.memoizedState=null;else switch(N){case"forwards":for(p=d.child,N=null;p!==null;)l=p.alternate,l!==null&&Ad(l)===null&&(N=p),p=p.sibling;p=N,p===null?(N=d.child,d.child=null):(N=p.sibling,p.sibling=null),Lp(d,!1,N,p,S);break;case"backwards":for(p=null,N=d.child,d.child=null;N!==null;){if(l=N.alternate,l!==null&&Ad(l)===null){d.child=N;break}l=N.sibling,N.sibling=p,p=N,N=l}Lp(d,!0,p,null,S);break;case"together":Lp(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function zd(l,d){(d.mode&1)===0&&l!==null&&(l.alternate=null,d.alternate=null,d.flags|=2)}function Ds(l,d,p){if(l!==null&&(d.dependencies=l.dependencies),Na|=d.lanes,(p&d.childLanes)===0)return null;if(l!==null&&d.child!==l.child)throw Error(n(153));if(d.child!==null){for(l=d.child,p=Ci(l,l.pendingProps),d.child=p,p.return=d;l.sibling!==null;)l=l.sibling,p=p.sibling=Ci(l,l.pendingProps),p.return=d;p.sibling=null}return d.child}function P4(l,d,p){switch(d.tag){case 3:Ev(d),vo();break;case 5:Uy(d);break;case 1:ir(d.type)&&bd(d);break;case 4:mp(d,d.stateNode.containerInfo);break;case 10:var x=d.type._context,N=d.memoizedProps.value;kt(Cd,x._currentValue),x._currentValue=N;break;case 13:if(x=d.memoizedState,x!==null)return x.dehydrated!==null?(kt(Ft,Ft.current&1),d.flags|=128,null):(p&d.child.childLanes)!==0?Mv(l,d,p):(kt(Ft,Ft.current&1),l=Ds(l,d,p),l!==null?l.sibling:null);kt(Ft,Ft.current&1);break;case 19:if(x=(p&d.childLanes)!==0,(l.flags&128)!==0){if(x)return Rv(l,d,p);d.flags|=128}if(N=d.memoizedState,N!==null&&(N.rendering=null,N.tail=null,N.lastEffect=null),kt(Ft,Ft.current),x)break;return null;case 22:case 23:return d.lanes=0,kv(l,d,p)}return Ds(l,d,p)}var Iv,_p,Pv,Ov;Iv=function(l,d){for(var p=d.child;p!==null;){if(p.tag===5||p.tag===6)l.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},_p=function(){},Pv=function(l,d,p,x){var N=l.memoizedProps;if(N!==x){l=d.stateNode,ba(ps.current);var S=null;switch(p){case"input":N=Ye(l,N),x=Ye(l,x),S=[];break;case"select":N=Y({},N,{value:void 0}),x=Y({},x,{value:void 0}),S=[];break;case"textarea":N=qn(l,N),x=qn(l,x),S=[];break;default:typeof N.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=xd)}Es(p,x);var T;p=null;for(le in N)if(!x.hasOwnProperty(le)&&N.hasOwnProperty(le)&&N[le]!=null)if(le==="style"){var z=N[le];for(T in z)z.hasOwnProperty(T)&&(p||(p={}),p[T]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(s.hasOwnProperty(le)?S||(S=[]):(S=S||[]).push(le,null));for(le in x){var K=x[le];if(z=N!=null?N[le]:void 0,x.hasOwnProperty(le)&&K!==z&&(K!=null||z!=null))if(le==="style")if(z){for(T in z)!z.hasOwnProperty(T)||K&&K.hasOwnProperty(T)||(p||(p={}),p[T]="");for(T in K)K.hasOwnProperty(T)&&z[T]!==K[T]&&(p||(p={}),p[T]=K[T])}else p||(S||(S=[]),S.push(le,p)),p=K;else le==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,z=z?z.__html:void 0,K!=null&&z!==K&&(S=S||[]).push(le,K)):le==="children"?typeof K!="string"&&typeof K!="number"||(S=S||[]).push(le,""+K):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(s.hasOwnProperty(le)?(K!=null&&le==="onScroll"&&Et("scroll",l),S||z===K||(S=[])):(S=S||[]).push(le,K))}p&&(S=S||[]).push("style",p);var le=S;(d.updateQueue=le)&&(d.flags|=4)}},Ov=function(l,d,p,x){p!==x&&(d.flags|=4)};function Vl(l,d){if(!Dt)switch(l.tailMode){case"hidden":d=l.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?d||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function $n(l){var d=l.alternate!==null&&l.alternate.child===l.child,p=0,x=0;if(d)for(var N=l.child;N!==null;)p|=N.lanes|N.childLanes,x|=N.subtreeFlags&14680064,x|=N.flags&14680064,N.return=l,N=N.sibling;else for(N=l.child;N!==null;)p|=N.lanes|N.childLanes,x|=N.subtreeFlags,x|=N.flags,N.return=l,N=N.sibling;return l.subtreeFlags|=x,l.childLanes=p,d}function O4(l,d,p){var x=d.pendingProps;switch(ip(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $n(d),null;case 1:return ir(d.type)&&vd(),$n(d),null;case 3:return x=d.stateNode,jo(),Tt(sr),Tt(_n),yp(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(kd(d)?d.flags|=4:l===null||l.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Wr!==null&&(Gp(Wr),Wr=null))),_p(l,d),$n(d),null;case 5:gp(d);var N=ba(_l.current);if(p=d.type,l!==null&&d.stateNode!=null)Pv(l,d,p,x,N),l.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!x){if(d.stateNode===null)throw Error(n(166));return $n(d),null}if(l=ba(ps.current),kd(d)){x=d.stateNode,p=d.type;var S=d.memoizedProps;switch(x[fs]=d,x[Il]=S,l=(d.mode&1)!==0,p){case"dialog":Et("cancel",x),Et("close",x);break;case"iframe":case"object":case"embed":Et("load",x);break;case"video":case"audio":for(N=0;N<Ml.length;N++)Et(Ml[N],x);break;case"source":Et("error",x);break;case"img":case"image":case"link":Et("error",x),Et("load",x);break;case"details":Et("toggle",x);break;case"input":st(x,S),Et("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!S.multiple},Et("invalid",x);break;case"textarea":ss(x,S),Et("invalid",x)}Es(p,S),N=null;for(var T in S)if(S.hasOwnProperty(T)){var z=S[T];T==="children"?typeof z=="string"?x.textContent!==z&&(S.suppressHydrationWarning!==!0&&gd(x.textContent,z,l),N=["children",z]):typeof z=="number"&&x.textContent!==""+z&&(S.suppressHydrationWarning!==!0&&gd(x.textContent,z,l),N=["children",""+z]):s.hasOwnProperty(T)&&z!=null&&T==="onScroll"&&Et("scroll",x)}switch(p){case"input":me(x),ft(x,S,!0);break;case"textarea":me(x),Cr(x);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(x.onclick=xd)}x=N,d.updateQueue=x,x!==null&&(d.flags|=4)}else{T=N.nodeType===9?N:N.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=is(p)),l==="http://www.w3.org/1999/xhtml"?p==="script"?(l=T.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=T.createElement(p,{is:x.is}):(l=T.createElement(p),p==="select"&&(T=l,x.multiple?T.multiple=!0:x.size&&(T.size=x.size))):l=T.createElementNS(l,p),l[fs]=d,l[Il]=x,Iv(l,d,!1,!1),d.stateNode=l;e:{switch(T=ua(p,x),p){case"dialog":Et("cancel",l),Et("close",l),N=x;break;case"iframe":case"object":case"embed":Et("load",l),N=x;break;case"video":case"audio":for(N=0;N<Ml.length;N++)Et(Ml[N],l);N=x;break;case"source":Et("error",l),N=x;break;case"img":case"image":case"link":Et("error",l),Et("load",l),N=x;break;case"details":Et("toggle",l),N=x;break;case"input":st(l,x),N=Ye(l,x),Et("invalid",l);break;case"option":N=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},N=Y({},x,{value:void 0}),Et("invalid",l);break;case"textarea":ss(l,x),N=qn(l,x),Et("invalid",l);break;default:N=x}Es(p,N),z=N;for(S in z)if(z.hasOwnProperty(S)){var K=z[S];S==="style"?Sn(l,K):S==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,K!=null&&mr(l,K)):S==="children"?typeof K=="string"?(p!=="textarea"||K!=="")&&Br(l,K):typeof K=="number"&&Br(l,""+K):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(s.hasOwnProperty(S)?K!=null&&S==="onScroll"&&Et("scroll",l):K!=null&&C(l,S,K,T))}switch(p){case"input":me(l),ft(l,x,!1);break;case"textarea":me(l),Cr(l);break;case"option":x.value!=null&&l.setAttribute("value",""+de(x.value));break;case"select":l.multiple=!!x.multiple,S=x.value,S!=null?Kn(l,!!x.multiple,S,!1):x.defaultValue!=null&&Kn(l,!!x.multiple,x.defaultValue,!0);break;default:typeof N.onClick=="function"&&(l.onclick=xd)}switch(p){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(d.flags|=4)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return $n(d),null;case 6:if(l&&d.stateNode!=null)Ov(l,d,l.memoizedProps,x);else{if(typeof x!="string"&&d.stateNode===null)throw Error(n(166));if(p=ba(_l.current),ba(ps.current),kd(d)){if(x=d.stateNode,p=d.memoizedProps,x[fs]=d,(S=x.nodeValue!==p)&&(l=yr,l!==null))switch(l.tag){case 3:gd(x.nodeValue,p,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&gd(x.nodeValue,p,(l.mode&1)!==0)}S&&(d.flags|=4)}else x=(p.nodeType===9?p:p.ownerDocument).createTextNode(x),x[fs]=d,d.stateNode=x}return $n(d),null;case 13:if(Tt(Ft),x=d.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(Dt&&vr!==null&&(d.mode&1)!==0&&(d.flags&128)===0)_y(),vo(),d.flags|=98560,S=!1;else if(S=kd(d),x!==null&&x.dehydrated!==null){if(l===null){if(!S)throw Error(n(318));if(S=d.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[fs]=d}else vo(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;$n(d),S=!1}else Wr!==null&&(Gp(Wr),Wr=null),S=!0;if(!S)return d.flags&65536?d:null}return(d.flags&128)!==0?(d.lanes=p,d):(x=x!==null,x!==(l!==null&&l.memoizedState!==null)&&x&&(d.child.flags|=8192,(d.mode&1)!==0&&(l===null||(Ft.current&1)!==0?dn===0&&(dn=3):Qp())),d.updateQueue!==null&&(d.flags|=4),$n(d),null);case 4:return jo(),_p(l,d),l===null&&Al(d.stateNode.containerInfo),$n(d),null;case 10:return up(d.type._context),$n(d),null;case 17:return ir(d.type)&&vd(),$n(d),null;case 19:if(Tt(Ft),S=d.memoizedState,S===null)return $n(d),null;if(x=(d.flags&128)!==0,T=S.rendering,T===null)if(x)Vl(S,!1);else{if(dn!==0||l!==null&&(l.flags&128)!==0)for(l=d.child;l!==null;){if(T=Ad(l),T!==null){for(d.flags|=128,Vl(S,!1),x=T.updateQueue,x!==null&&(d.updateQueue=x,d.flags|=4),d.subtreeFlags=0,x=p,p=d.child;p!==null;)S=p,l=x,S.flags&=14680066,T=S.alternate,T===null?(S.childLanes=0,S.lanes=l,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=T.childLanes,S.lanes=T.lanes,S.child=T.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=T.memoizedProps,S.memoizedState=T.memoizedState,S.updateQueue=T.updateQueue,S.type=T.type,l=T.dependencies,S.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),p=p.sibling;return kt(Ft,Ft.current&1|2),d.child}l=l.sibling}S.tail!==null&&$t()>Eo&&(d.flags|=128,x=!0,Vl(S,!1),d.lanes=4194304)}else{if(!x)if(l=Ad(T),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),Vl(S,!0),S.tail===null&&S.tailMode==="hidden"&&!T.alternate&&!Dt)return $n(d),null}else 2*$t()-S.renderingStartTime>Eo&&p!==1073741824&&(d.flags|=128,x=!0,Vl(S,!1),d.lanes=4194304);S.isBackwards?(T.sibling=d.child,d.child=T):(p=S.last,p!==null?p.sibling=T:d.child=T,S.last=T)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=$t(),d.sibling=null,p=Ft.current,kt(Ft,x?p&1|2:p&1),d):($n(d),null);case 22:case 23:return Yp(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(br&1073741824)!==0&&($n(d),d.subtreeFlags&6&&(d.flags|=8192)):$n(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function D4(l,d){switch(ip(d),d.tag){case 1:return ir(d.type)&&vd(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return jo(),Tt(sr),Tt(_n),yp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return gp(d),null;case 13:if(Tt(Ft),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));vo()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Tt(Ft),null;case 4:return jo(),null;case 10:return up(d.type._context),null;case 22:case 23:return Yp(),null;case 24:return null;default:return null}}var $d=!1,Fn=!1,L4=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function So(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){Ht(l,d,x)}else p.current=null}function zp(l,d,p){try{p()}catch(x){Ht(l,d,x)}}var Dv=!1;function _4(l,d){if(Yf=id,l=fy(),Vf(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var N=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var T=0,z=-1,K=-1,le=0,ye=0,be=l,xe=null;t:for(;;){for(var Ie;be!==p||N!==0&&be.nodeType!==3||(z=T+N),be!==S||x!==0&&be.nodeType!==3||(K=T+x),be.nodeType===3&&(T+=be.nodeValue.length),(Ie=be.firstChild)!==null;)xe=be,be=Ie;for(;;){if(be===l)break t;if(xe===p&&++le===N&&(z=T),xe===S&&++ye===x&&(K=T),(Ie=be.nextSibling)!==null)break;be=xe,xe=be.parentNode}be=Ie}p=z===-1||K===-1?null:{start:z,end:K}}else p=null}p=p||{start:0,end:0}}else p=null;for(Qf={focusedElem:l,selectionRange:p},id=!1,Pe=d;Pe!==null;)if(d=Pe,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,Pe=l;else for(;Pe!==null;){d=Pe;try{var Oe=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Oe!==null){var _e=Oe.memoizedProps,Yt=Oe.memoizedState,ne=d.stateNode,J=ne.getSnapshotBeforeUpdate(d.elementType===d.type?_e:Ur(d.type,_e),Yt);ne.__reactInternalSnapshotBeforeUpdate=J}break;case 3:var se=d.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ne){Ht(d,d.return,Ne)}if(l=d.sibling,l!==null){l.return=d.return,Pe=l;break}Pe=d.return}return Oe=Dv,Dv=!1,Oe}function Hl(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var N=x=x.next;do{if((N.tag&l)===l){var S=N.destroy;N.destroy=void 0,S!==void 0&&zp(d,p,S)}N=N.next}while(N!==x)}}function Fd(l,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var p=d=d.next;do{if((p.tag&l)===l){var x=p.create;p.destroy=x()}p=p.next}while(p!==d)}}function $p(l){var d=l.ref;if(d!==null){var p=l.stateNode;switch(l.tag){case 5:l=p;break;default:l=p}typeof d=="function"?d(l):d.current=l}}function Lv(l){var d=l.alternate;d!==null&&(l.alternate=null,Lv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[fs],delete d[Il],delete d[tp],delete d[v4],delete d[b4])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function _v(l){return l.tag===5||l.tag===3||l.tag===4}function zv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||_v(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Fp(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.nodeType===8?p.parentNode.insertBefore(l,d):p.insertBefore(l,d):(p.nodeType===8?(d=p.parentNode,d.insertBefore(l,p)):(d=p,d.appendChild(l)),p=p._reactRootContainer,p!=null||d.onclick!==null||(d.onclick=xd));else if(x!==4&&(l=l.child,l!==null))for(Fp(l,d,p),l=l.sibling;l!==null;)Fp(l,d,p),l=l.sibling}function Bp(l,d,p){var x=l.tag;if(x===5||x===6)l=l.stateNode,d?p.insertBefore(l,d):p.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(Bp(l,d,p),l=l.sibling;l!==null;)Bp(l,d,p),l=l.sibling}var Tn=null,Kr=!1;function wi(l,d,p){for(p=p.child;p!==null;)$v(l,d,p),p=p.sibling}function $v(l,d,p){if(gr&&typeof gr.onCommitFiberUnmount=="function")try{gr.onCommitFiberUnmount(pa,p)}catch{}switch(p.tag){case 5:Fn||So(p,d);case 6:var x=Tn,N=Kr;Tn=null,wi(l,d,p),Tn=x,Kr=N,Tn!==null&&(Kr?(l=Tn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Tn.removeChild(p.stateNode));break;case 18:Tn!==null&&(Kr?(l=Tn,p=p.stateNode,l.nodeType===8?ep(l.parentNode,p):l.nodeType===1&&ep(l,p),wl(l)):ep(Tn,p.stateNode));break;case 4:x=Tn,N=Kr,Tn=p.stateNode.containerInfo,Kr=!0,wi(l,d,p),Tn=x,Kr=N;break;case 0:case 11:case 14:case 15:if(!Fn&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){N=x=x.next;do{var S=N,T=S.destroy;S=S.tag,T!==void 0&&((S&2)!==0||(S&4)!==0)&&zp(p,d,T),N=N.next}while(N!==x)}wi(l,d,p);break;case 1:if(!Fn&&(So(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(z){Ht(p,d,z)}wi(l,d,p);break;case 21:wi(l,d,p);break;case 22:p.mode&1?(Fn=(x=Fn)||p.memoizedState!==null,wi(l,d,p),Fn=x):wi(l,d,p);break;default:wi(l,d,p)}}function Fv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new L4),d.forEach(function(x){var N=K4.bind(null,l,x);p.has(x)||(p.add(x),x.then(N,N))})}}function qr(l,d){var p=d.deletions;if(p!==null)for(var x=0;x<p.length;x++){var N=p[x];try{var S=l,T=d,z=T;e:for(;z!==null;){switch(z.tag){case 5:Tn=z.stateNode,Kr=!1;break e;case 3:Tn=z.stateNode.containerInfo,Kr=!0;break e;case 4:Tn=z.stateNode.containerInfo,Kr=!0;break e}z=z.return}if(Tn===null)throw Error(n(160));$v(S,T,N),Tn=null,Kr=!1;var K=N.alternate;K!==null&&(K.return=null),N.return=null}catch(le){Ht(N,d,le)}}if(d.subtreeFlags&12854)for(d=d.child;d!==null;)Bv(d,l),d=d.sibling}function Bv(l,d){var p=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(qr(d,l),gs(l),x&4){try{Hl(3,l,l.return),Fd(3,l)}catch(_e){Ht(l,l.return,_e)}try{Hl(5,l,l.return)}catch(_e){Ht(l,l.return,_e)}}break;case 1:qr(d,l),gs(l),x&512&&p!==null&&So(p,p.return);break;case 5:if(qr(d,l),gs(l),x&512&&p!==null&&So(p,p.return),l.flags&32){var N=l.stateNode;try{Br(N,"")}catch(_e){Ht(l,l.return,_e)}}if(x&4&&(N=l.stateNode,N!=null)){var S=l.memoizedProps,T=p!==null?p.memoizedProps:S,z=l.type,K=l.updateQueue;if(l.updateQueue=null,K!==null)try{z==="input"&&S.type==="radio"&&S.name!=null&&Qe(N,S),ua(z,T);var le=ua(z,S);for(T=0;T<K.length;T+=2){var ye=K[T],be=K[T+1];ye==="style"?Sn(N,be):ye==="dangerouslySetInnerHTML"?mr(N,be):ye==="children"?Br(N,be):C(N,ye,be,le)}switch(z){case"input":Xe(N,S);break;case"textarea":zt(N,S);break;case"select":var xe=N._wrapperState.wasMultiple;N._wrapperState.wasMultiple=!!S.multiple;var Ie=S.value;Ie!=null?Kn(N,!!S.multiple,Ie,!1):xe!==!!S.multiple&&(S.defaultValue!=null?Kn(N,!!S.multiple,S.defaultValue,!0):Kn(N,!!S.multiple,S.multiple?[]:"",!1))}N[Il]=S}catch(_e){Ht(l,l.return,_e)}}break;case 6:if(qr(d,l),gs(l),x&4){if(l.stateNode===null)throw Error(n(162));N=l.stateNode,S=l.memoizedProps;try{N.nodeValue=S}catch(_e){Ht(l,l.return,_e)}}break;case 3:if(qr(d,l),gs(l),x&4&&p!==null&&p.memoizedState.isDehydrated)try{wl(d.containerInfo)}catch(_e){Ht(l,l.return,_e)}break;case 4:qr(d,l),gs(l);break;case 13:qr(d,l),gs(l),N=l.child,N.flags&8192&&(S=N.memoizedState!==null,N.stateNode.isHidden=S,!S||N.alternate!==null&&N.alternate.memoizedState!==null||(Wp=$t())),x&4&&Fv(l);break;case 22:if(ye=p!==null&&p.memoizedState!==null,l.mode&1?(Fn=(le=Fn)||ye,qr(d,l),Fn=le):qr(d,l),gs(l),x&8192){if(le=l.memoizedState!==null,(l.stateNode.isHidden=le)&&!ye&&(l.mode&1)!==0)for(Pe=l,ye=l.child;ye!==null;){for(be=Pe=ye;Pe!==null;){switch(xe=Pe,Ie=xe.child,xe.tag){case 0:case 11:case 14:case 15:Hl(4,xe,xe.return);break;case 1:So(xe,xe.return);var Oe=xe.stateNode;if(typeof Oe.componentWillUnmount=="function"){x=xe,p=xe.return;try{d=x,Oe.props=d.memoizedProps,Oe.state=d.memoizedState,Oe.componentWillUnmount()}catch(_e){Ht(x,p,_e)}}break;case 5:So(xe,xe.return);break;case 22:if(xe.memoizedState!==null){Wv(be);continue}}Ie!==null?(Ie.return=xe,Pe=Ie):Wv(be)}ye=ye.sibling}e:for(ye=null,be=l;;){if(be.tag===5){if(ye===null){ye=be;try{N=be.stateNode,le?(S=N.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(z=be.stateNode,K=be.memoizedProps.style,T=K!=null&&K.hasOwnProperty("display")?K.display:null,z.style.display=ge("display",T))}catch(_e){Ht(l,l.return,_e)}}}else if(be.tag===6){if(ye===null)try{be.stateNode.nodeValue=le?"":be.memoizedProps}catch(_e){Ht(l,l.return,_e)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===l)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===l)break e;for(;be.sibling===null;){if(be.return===null||be.return===l)break e;ye===be&&(ye=null),be=be.return}ye===be&&(ye=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:qr(d,l),gs(l),x&4&&Fv(l);break;case 21:break;default:qr(d,l),gs(l)}}function gs(l){var d=l.flags;if(d&2){try{e:{for(var p=l.return;p!==null;){if(_v(p)){var x=p;break e}p=p.return}throw Error(n(160))}switch(x.tag){case 5:var N=x.stateNode;x.flags&32&&(Br(N,""),x.flags&=-33);var S=zv(l);Bp(l,S,N);break;case 3:case 4:var T=x.stateNode.containerInfo,z=zv(l);Fp(l,z,T);break;default:throw Error(n(161))}}catch(K){Ht(l,l.return,K)}l.flags&=-3}d&4096&&(l.flags&=-4097)}function z4(l,d,p){Pe=l,Vv(l)}function Vv(l,d,p){for(var x=(l.mode&1)!==0;Pe!==null;){var N=Pe,S=N.child;if(N.tag===22&&x){var T=N.memoizedState!==null||$d;if(!T){var z=N.alternate,K=z!==null&&z.memoizedState!==null||Fn;z=$d;var le=Fn;if($d=T,(Fn=K)&&!le)for(Pe=N;Pe!==null;)T=Pe,K=T.child,T.tag===22&&T.memoizedState!==null?Uv(N):K!==null?(K.return=T,Pe=K):Uv(N);for(;S!==null;)Pe=S,Vv(S),S=S.sibling;Pe=N,$d=z,Fn=le}Hv(l)}else(N.subtreeFlags&8772)!==0&&S!==null?(S.return=N,Pe=S):Hv(l)}}function Hv(l){for(;Pe!==null;){var d=Pe;if((d.flags&8772)!==0){var p=d.alternate;try{if((d.flags&8772)!==0)switch(d.tag){case 0:case 11:case 15:Fn||Fd(5,d);break;case 1:var x=d.stateNode;if(d.flags&4&&!Fn)if(p===null)x.componentDidMount();else{var N=d.elementType===d.type?p.memoizedProps:Ur(d.type,p.memoizedProps);x.componentDidUpdate(N,p.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var S=d.updateQueue;S!==null&&Wy(d,S,x);break;case 3:var T=d.updateQueue;if(T!==null){if(p=null,d.child!==null)switch(d.child.tag){case 5:p=d.child.stateNode;break;case 1:p=d.child.stateNode}Wy(d,T,p)}break;case 5:var z=d.stateNode;if(p===null&&d.flags&4){p=z;var K=d.memoizedProps;switch(d.type){case"button":case"input":case"select":case"textarea":K.autoFocus&&p.focus();break;case"img":K.src&&(p.src=K.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(d.memoizedState===null){var le=d.alternate;if(le!==null){var ye=le.memoizedState;if(ye!==null){var be=ye.dehydrated;be!==null&&wl(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Fn||d.flags&512&&$p(d)}catch(xe){Ht(d,d.return,xe)}}if(d===l){Pe=null;break}if(p=d.sibling,p!==null){p.return=d.return,Pe=p;break}Pe=d.return}}function Wv(l){for(;Pe!==null;){var d=Pe;if(d===l){Pe=null;break}var p=d.sibling;if(p!==null){p.return=d.return,Pe=p;break}Pe=d.return}}function Uv(l){for(;Pe!==null;){var d=Pe;try{switch(d.tag){case 0:case 11:case 15:var p=d.return;try{Fd(4,d)}catch(K){Ht(d,p,K)}break;case 1:var x=d.stateNode;if(typeof x.componentDidMount=="function"){var N=d.return;try{x.componentDidMount()}catch(K){Ht(d,N,K)}}var S=d.return;try{$p(d)}catch(K){Ht(d,S,K)}break;case 5:var T=d.return;try{$p(d)}catch(K){Ht(d,T,K)}}}catch(K){Ht(d,d.return,K)}if(d===l){Pe=null;break}var z=d.sibling;if(z!==null){z.return=d.return,Pe=z;break}Pe=d.return}}var $4=Math.ceil,Bd=M.ReactCurrentDispatcher,Vp=M.ReactCurrentOwner,Ir=M.ReactCurrentBatchConfig,dt=0,xn=null,an=null,Mn=0,br=0,Co=gi(0),dn=0,Wl=null,Na=0,Vd=0,Hp=0,Ul=null,or=null,Wp=0,Eo=1/0,Ls=null,Hd=!1,Up=null,Ni=null,Wd=!1,ji=null,Ud=0,Kl=0,Kp=null,Kd=-1,qd=0;function Xn(){return(dt&6)!==0?$t():Kd!==-1?Kd:Kd=$t()}function ki(l){return(l.mode&1)===0?1:(dt&2)!==0&&Mn!==0?Mn&-Mn:N4.transition!==null?(qd===0&&(qd=io()),qd):(l=xt,l!==0||(l=window.event,l=l===void 0?16:q0(l.type)),l)}function Gr(l,d,p,x){if(50<Kl)throw Kl=0,Kp=null,Error(n(185));li(l,p,x),((dt&2)===0||l!==xn)&&(l===xn&&((dt&2)===0&&(Vd|=p),dn===4&&Si(l,Mn)),lr(l,x),p===1&&dt===0&&(d.mode&1)===0&&(Eo=$t()+500,wd&&yi()))}function lr(l,d){var p=l.callbackNode;Ef(l,d);var x=Ln(l,l===xn?Mn:0);if(x===0)p!==null&&Zc(p),l.callbackNode=null,l.callbackPriority=0;else if(d=x&-x,l.callbackPriority!==d){if(p!=null&&Zc(p),d===1)l.tag===0?w4(qv.bind(null,l)):Iy(qv.bind(null,l)),x4(function(){(dt&6)===0&&yi()}),p=null;else{switch($0(x)){case 1:p=gl;break;case 4:p=ed;break;case 16:p=ro;break;case 536870912:p=so;break;default:p=ro}p=tb(p,Kv.bind(null,l))}l.callbackPriority=d,l.callbackNode=p}}function Kv(l,d){if(Kd=-1,qd=0,(dt&6)!==0)throw Error(n(327));var p=l.callbackNode;if(To()&&l.callbackNode!==p)return null;var x=Ln(l,l===xn?Mn:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||d)d=Gd(l,x);else{d=x;var N=dt;dt|=2;var S=Jv();(xn!==l||Mn!==d)&&(Ls=null,Eo=$t()+500,ka(l,d));do try{V4();break}catch(z){Gv(l,z)}while(!0);dp(),Bd.current=S,dt=N,an!==null?d=0:(xn=null,Mn=0,d=dn)}if(d!==0){if(d===2&&(N=Ts(l),N!==0&&(x=N,d=qp(l,N))),d===1)throw p=Wl,ka(l,0),Si(l,x),lr(l,$t()),p;if(d===6)Si(l,x);else{if(N=l.current.alternate,(x&30)===0&&!F4(N)&&(d=Gd(l,x),d===2&&(S=Ts(l),S!==0&&(x=S,d=qp(l,S))),d===1))throw p=Wl,ka(l,0),Si(l,x),lr(l,$t()),p;switch(l.finishedWork=N,l.finishedLanes=x,d){case 0:case 1:throw Error(n(345));case 2:Sa(l,or,Ls);break;case 3:if(Si(l,x),(x&130023424)===x&&(d=Wp+500-$t(),10<d)){if(Ln(l,0)!==0)break;if(N=l.suspendedLanes,(N&x)!==x){Xn(),l.pingedLanes|=l.suspendedLanes&N;break}l.timeoutHandle=Zf(Sa.bind(null,l,or,Ls),d);break}Sa(l,or,Ls);break;case 4:if(Si(l,x),(x&4194240)===x)break;for(d=l.eventTimes,N=-1;0<x;){var T=31-rr(x);S=1<<T,T=d[T],T>N&&(N=T),x&=~S}if(x=N,x=$t()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*$4(x/1960))-x,10<x){l.timeoutHandle=Zf(Sa.bind(null,l,or,Ls),x);break}Sa(l,or,Ls);break;case 5:Sa(l,or,Ls);break;default:throw Error(n(329))}}}return lr(l,$t()),l.callbackNode===p?Kv.bind(null,l):null}function qp(l,d){var p=Ul;return l.current.memoizedState.isDehydrated&&(ka(l,d).flags|=256),l=Gd(l,d),l!==2&&(d=or,or=p,d!==null&&Gp(d)),l}function Gp(l){or===null?or=l:or.push.apply(or,l)}function F4(l){for(var d=l;;){if(d.flags&16384){var p=d.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var x=0;x<p.length;x++){var N=p[x],S=N.getSnapshot;N=N.value;try{if(!Hr(S(),N))return!1}catch{return!1}}}if(p=d.child,d.subtreeFlags&16384&&p!==null)p.return=d,d=p;else{if(d===l)break;for(;d.sibling===null;){if(d.return===null||d.return===l)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function Si(l,d){for(d&=~Hp,d&=~Vd,l.suspendedLanes|=d,l.pingedLanes&=~d,l=l.expirationTimes;0<d;){var p=31-rr(d),x=1<<p;l[p]=-1,d&=~x}}function qv(l){if((dt&6)!==0)throw Error(n(327));To();var d=Ln(l,0);if((d&1)===0)return lr(l,$t()),null;var p=Gd(l,d);if(l.tag!==0&&p===2){var x=Ts(l);x!==0&&(d=x,p=qp(l,x))}if(p===1)throw p=Wl,ka(l,0),Si(l,d),lr(l,$t()),p;if(p===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=d,Sa(l,or,Ls),lr(l,$t()),null}function Jp(l,d){var p=dt;dt|=1;try{return l(d)}finally{dt=p,dt===0&&(Eo=$t()+500,wd&&yi())}}function ja(l){ji!==null&&ji.tag===0&&(dt&6)===0&&To();var d=dt;dt|=1;var p=Ir.transition,x=xt;try{if(Ir.transition=null,xt=1,l)return l()}finally{xt=x,Ir.transition=p,dt=d,(dt&6)===0&&yi()}}function Yp(){br=Co.current,Tt(Co)}function ka(l,d){l.finishedWork=null,l.finishedLanes=0;var p=l.timeoutHandle;if(p!==-1&&(l.timeoutHandle=-1,g4(p)),an!==null)for(p=an.return;p!==null;){var x=p;switch(ip(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&vd();break;case 3:jo(),Tt(sr),Tt(_n),yp();break;case 5:gp(x);break;case 4:jo();break;case 13:Tt(Ft);break;case 19:Tt(Ft);break;case 10:up(x.type._context);break;case 22:case 23:Yp()}p=p.return}if(xn=l,an=l=Ci(l.current,null),Mn=br=d,dn=0,Wl=null,Hp=Vd=Na=0,or=Ul=null,va!==null){for(d=0;d<va.length;d++)if(p=va[d],x=p.interleaved,x!==null){p.interleaved=null;var N=x.next,S=p.pending;if(S!==null){var T=S.next;S.next=N,x.next=T}p.pending=x}va=null}return l}function Gv(l,d){do{var p=an;try{if(dp(),Rd.current=Dd,Id){for(var x=Bt.memoizedState;x!==null;){var N=x.queue;N!==null&&(N.pending=null),x=x.next}Id=!1}if(wa=0,gn=cn=Bt=null,zl=!1,$l=0,Vp.current=null,p===null||p.return===null){dn=1,Wl=d,an=null;break}e:{var S=l,T=p.return,z=p,K=d;if(d=Mn,z.flags|=32768,K!==null&&typeof K=="object"&&typeof K.then=="function"){var le=K,ye=z,be=ye.tag;if((ye.mode&1)===0&&(be===0||be===11||be===15)){var xe=ye.alternate;xe?(ye.updateQueue=xe.updateQueue,ye.memoizedState=xe.memoizedState,ye.lanes=xe.lanes):(ye.updateQueue=null,ye.memoizedState=null)}var Ie=vv(T);if(Ie!==null){Ie.flags&=-257,bv(Ie,T,z,S,d),Ie.mode&1&&yv(S,le,d),d=Ie,K=le;var Oe=d.updateQueue;if(Oe===null){var _e=new Set;_e.add(K),d.updateQueue=_e}else Oe.add(K);break e}else{if((d&1)===0){yv(S,le,d),Qp();break e}K=Error(n(426))}}else if(Dt&&z.mode&1){var Yt=vv(T);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),bv(Yt,T,z,S,d),lp(ko(K,z));break e}}S=K=ko(K,z),dn!==4&&(dn=2),Ul===null?Ul=[S]:Ul.push(S),S=T;do{switch(S.tag){case 3:S.flags|=65536,d&=-d,S.lanes|=d;var ne=gv(S,K,d);Hy(S,ne);break e;case 1:z=K;var J=S.type,se=S.stateNode;if((S.flags&128)===0&&(typeof J.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(Ni===null||!Ni.has(se)))){S.flags|=65536,d&=-d,S.lanes|=d;var Ne=xv(S,z,d);Hy(S,Ne);break e}}S=S.return}while(S!==null)}Qv(p)}catch(ze){d=ze,an===p&&p!==null&&(an=p=p.return);continue}break}while(!0)}function Jv(){var l=Bd.current;return Bd.current=Dd,l===null?Dd:l}function Qp(){(dn===0||dn===3||dn===2)&&(dn=4),xn===null||(Na&268435455)===0&&(Vd&268435455)===0||Si(xn,Mn)}function Gd(l,d){var p=dt;dt|=2;var x=Jv();(xn!==l||Mn!==d)&&(Ls=null,ka(l,d));do try{B4();break}catch(N){Gv(l,N)}while(!0);if(dp(),dt=p,Bd.current=x,an!==null)throw Error(n(261));return xn=null,Mn=0,dn}function B4(){for(;an!==null;)Yv(an)}function V4(){for(;an!==null&&!kf();)Yv(an)}function Yv(l){var d=eb(l.alternate,l,br);l.memoizedProps=l.pendingProps,d===null?Qv(l):an=d,Vp.current=null}function Qv(l){var d=l;do{var p=d.alternate;if(l=d.return,(d.flags&32768)===0){if(p=O4(p,d,br),p!==null){an=p;return}}else{if(p=D4(p,d),p!==null){p.flags&=32767,an=p;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{dn=6,an=null;return}}if(d=d.sibling,d!==null){an=d;return}an=d=l}while(d!==null);dn===0&&(dn=5)}function Sa(l,d,p){var x=xt,N=Ir.transition;try{Ir.transition=null,xt=1,H4(l,d,p,x)}finally{Ir.transition=N,xt=x}return null}function H4(l,d,p,x){do To();while(ji!==null);if((dt&6)!==0)throw Error(n(327));p=l.finishedWork;var N=l.finishedLanes;if(p===null)return null;if(l.finishedWork=null,l.finishedLanes=0,p===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var S=p.lanes|p.childLanes;if(jE(l,S),l===xn&&(an=xn=null,Mn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Wd||(Wd=!0,tb(ro,function(){return To(),null})),S=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||S){S=Ir.transition,Ir.transition=null;var T=xt;xt=1;var z=dt;dt|=4,Vp.current=null,_4(l,p),Bv(p,l),c4(Qf),id=!!Yf,Qf=Yf=null,l.current=p,z4(p),Sf(),dt=z,xt=T,Ir.transition=S}else l.current=p;if(Wd&&(Wd=!1,ji=l,Ud=N),S=l.pendingLanes,S===0&&(Ni=null),nd(p.stateNode),lr(l,$t()),d!==null)for(x=l.onRecoverableError,p=0;p<d.length;p++)N=d[p],x(N.value,{componentStack:N.stack,digest:N.digest});if(Hd)throw Hd=!1,l=Up,Up=null,l;return(Ud&1)!==0&&l.tag!==0&&To(),S=l.pendingLanes,(S&1)!==0?l===Kp?Kl++:(Kl=0,Kp=l):Kl=0,yi(),null}function To(){if(ji!==null){var l=$0(Ud),d=Ir.transition,p=xt;try{if(Ir.transition=null,xt=16>l?16:l,ji===null)var x=!1;else{if(l=ji,ji=null,Ud=0,(dt&6)!==0)throw Error(n(331));var N=dt;for(dt|=4,Pe=l.current;Pe!==null;){var S=Pe,T=S.child;if((Pe.flags&16)!==0){var z=S.deletions;if(z!==null){for(var K=0;K<z.length;K++){var le=z[K];for(Pe=le;Pe!==null;){var ye=Pe;switch(ye.tag){case 0:case 11:case 15:Hl(8,ye,S)}var be=ye.child;if(be!==null)be.return=ye,Pe=be;else for(;Pe!==null;){ye=Pe;var xe=ye.sibling,Ie=ye.return;if(Lv(ye),ye===le){Pe=null;break}if(xe!==null){xe.return=Ie,Pe=xe;break}Pe=Ie}}}var Oe=S.alternate;if(Oe!==null){var _e=Oe.child;if(_e!==null){Oe.child=null;do{var Yt=_e.sibling;_e.sibling=null,_e=Yt}while(_e!==null)}}Pe=S}}if((S.subtreeFlags&2064)!==0&&T!==null)T.return=S,Pe=T;else e:for(;Pe!==null;){if(S=Pe,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:Hl(9,S,S.return)}var ne=S.sibling;if(ne!==null){ne.return=S.return,Pe=ne;break e}Pe=S.return}}var J=l.current;for(Pe=J;Pe!==null;){T=Pe;var se=T.child;if((T.subtreeFlags&2064)!==0&&se!==null)se.return=T,Pe=se;else e:for(T=J;Pe!==null;){if(z=Pe,(z.flags&2048)!==0)try{switch(z.tag){case 0:case 11:case 15:Fd(9,z)}}catch(ze){Ht(z,z.return,ze)}if(z===T){Pe=null;break e}var Ne=z.sibling;if(Ne!==null){Ne.return=z.return,Pe=Ne;break e}Pe=z.return}}if(dt=N,yi(),gr&&typeof gr.onPostCommitFiberRoot=="function")try{gr.onPostCommitFiberRoot(pa,l)}catch{}x=!0}return x}finally{xt=p,Ir.transition=d}}return!1}function Xv(l,d,p){d=ko(p,d),d=gv(l,d,1),l=bi(l,d,1),d=Xn(),l!==null&&(li(l,1,d),lr(l,d))}function Ht(l,d,p){if(l.tag===3)Xv(l,l,p);else for(;d!==null;){if(d.tag===3){Xv(d,l,p);break}else if(d.tag===1){var x=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Ni===null||!Ni.has(x))){l=ko(p,l),l=xv(d,l,1),d=bi(d,l,1),l=Xn(),d!==null&&(li(d,1,l),lr(d,l));break}}d=d.return}}function W4(l,d,p){var x=l.pingCache;x!==null&&x.delete(d),d=Xn(),l.pingedLanes|=l.suspendedLanes&p,xn===l&&(Mn&p)===p&&(dn===4||dn===3&&(Mn&130023424)===Mn&&500>$t()-Wp?ka(l,0):Hp|=p),lr(l,d)}function Zv(l,d){d===0&&((l.mode&1)===0?d=1:(d=Ot,Ot<<=1,(Ot&130023424)===0&&(Ot=4194304)));var p=Xn();l=Ps(l,d),l!==null&&(li(l,d,p),lr(l,p))}function U4(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),Zv(l,p)}function K4(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,N=l.memoizedState;N!==null&&(p=N.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),Zv(l,p)}var eb;eb=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||sr.current)ar=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return ar=!1,P4(l,d,p);ar=(l.flags&131072)!==0}else ar=!1,Dt&&(d.flags&1048576)!==0&&Py(d,jd,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;zd(l,d),l=d.pendingProps;var N=go(d,_n.current);No(d,p),N=wp(null,d,x,l,N,p);var S=Np();return d.flags|=1,typeof N=="object"&&N!==null&&typeof N.render=="function"&&N.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,ir(x)?(S=!0,bd(d)):S=!1,d.memoizedState=N.state!==null&&N.state!==void 0?N.state:null,pp(d),N.updater=Ld,d.stateNode=N,N._reactInternals=d,Tp(d,x,l,p),d=Ip(null,d,x,!0,S,p)):(d.tag=0,Dt&&S&&sp(d),Qn(null,d,N,p),d=d.child),d;case 16:x=d.elementType;e:{switch(zd(l,d),l=d.pendingProps,N=x._init,x=N(x._payload),d.type=x,N=d.tag=G4(x),l=Ur(x,l),N){case 0:d=Rp(null,d,x,l,p);break e;case 1:d=Cv(null,d,x,l,p);break e;case 11:d=wv(null,d,x,l,p);break e;case 14:d=Nv(null,d,x,Ur(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,N=d.pendingProps,N=d.elementType===x?N:Ur(x,N),Rp(l,d,x,N,p);case 1:return x=d.type,N=d.pendingProps,N=d.elementType===x?N:Ur(x,N),Cv(l,d,x,N,p);case 3:e:{if(Ev(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,N=S.element,Vy(l,d),Md(d,x,null,p);var T=d.memoizedState;if(x=T.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){N=ko(Error(n(423)),d),d=Tv(l,d,x,p,N);break e}else if(x!==N){N=ko(Error(n(424)),d),d=Tv(l,d,x,p,N);break e}else for(vr=mi(d.stateNode.containerInfo.firstChild),yr=d,Dt=!0,Wr=null,p=Fy(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(vo(),x===N){d=Ds(l,d,p);break e}Qn(l,d,x,p)}d=d.child}return d;case 5:return Uy(d),l===null&&op(d),x=d.type,N=d.pendingProps,S=l!==null?l.memoizedProps:null,T=N.children,Xf(x,N)?T=null:S!==null&&Xf(x,S)&&(d.flags|=32),Sv(l,d),Qn(l,d,T,p),d.child;case 6:return l===null&&op(d),null;case 13:return Mv(l,d,p);case 4:return mp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=bo(d,null,x,p):Qn(l,d,x,p),d.child;case 11:return x=d.type,N=d.pendingProps,N=d.elementType===x?N:Ur(x,N),wv(l,d,x,N,p);case 7:return Qn(l,d,d.pendingProps,p),d.child;case 8:return Qn(l,d,d.pendingProps.children,p),d.child;case 12:return Qn(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,N=d.pendingProps,S=d.memoizedProps,T=N.value,kt(Cd,x._currentValue),x._currentValue=T,S!==null)if(Hr(S.value,T)){if(S.children===N.children&&!sr.current){d=Ds(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var z=S.dependencies;if(z!==null){T=S.child;for(var K=z.firstContext;K!==null;){if(K.context===x){if(S.tag===1){K=Os(-1,p&-p),K.tag=2;var le=S.updateQueue;if(le!==null){le=le.shared;var ye=le.pending;ye===null?K.next=K:(K.next=ye.next,ye.next=K),le.pending=K}}S.lanes|=p,K=S.alternate,K!==null&&(K.lanes|=p),hp(S.return,p,d),z.lanes|=p;break}K=K.next}}else if(S.tag===10)T=S.type===d.type?null:S.child;else if(S.tag===18){if(T=S.return,T===null)throw Error(n(341));T.lanes|=p,z=T.alternate,z!==null&&(z.lanes|=p),hp(T,p,d),T=S.sibling}else T=S.child;if(T!==null)T.return=S;else for(T=S;T!==null;){if(T===d){T=null;break}if(S=T.sibling,S!==null){S.return=T.return,T=S;break}T=T.return}S=T}Qn(l,d,N.children,p),d=d.child}return d;case 9:return N=d.type,x=d.pendingProps.children,No(d,p),N=Ar(N),x=x(N),d.flags|=1,Qn(l,d,x,p),d.child;case 14:return x=d.type,N=Ur(x,d.pendingProps),N=Ur(x.type,N),Nv(l,d,x,N,p);case 15:return jv(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,N=d.pendingProps,N=d.elementType===x?N:Ur(x,N),zd(l,d),d.tag=1,ir(x)?(l=!0,bd(d)):l=!1,No(d,p),pv(d,x,N),Tp(d,x,N,p),Ip(null,d,x,!0,l,p);case 19:return Rv(l,d,p);case 22:return kv(l,d,p)}throw Error(n(156,d.tag))};function tb(l,d){return Xc(l,d)}function q4(l,d,p,x){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pr(l,d,p,x){return new q4(l,d,p,x)}function Xp(l){return l=l.prototype,!(!l||!l.isReactComponent)}function G4(l){if(typeof l=="function")return Xp(l)?1:0;if(l!=null){if(l=l.$$typeof,l===X)return 11;if(l===_)return 14}return 2}function Ci(l,d){var p=l.alternate;return p===null?(p=Pr(l.tag,d,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=d,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&14680064,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,d=l.dependencies,p.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p}function Jd(l,d,p,x,N,S){var T=2;if(x=l,typeof l=="function")Xp(l)&&(T=1);else if(typeof l=="string")T=5;else e:switch(l){case R:return Ca(p.children,N,S,d);case I:T=8,N|=8;break;case A:return l=Pr(12,p,d,N|2),l.elementType=A,l.lanes=S,l;case q:return l=Pr(13,p,d,N),l.elementType=q,l.lanes=S,l;case Z:return l=Pr(19,p,d,N),l.elementType=Z,l.lanes=S,l;case oe:return Yd(p,N,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case O:T=10;break e;case W:T=9;break e;case X:T=11;break e;case _:T=14;break e;case $:T=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Pr(T,p,d,N),d.elementType=l,d.type=x,d.lanes=S,d}function Ca(l,d,p,x){return l=Pr(7,l,x,d),l.lanes=p,l}function Yd(l,d,p,x){return l=Pr(22,l,x,d),l.elementType=oe,l.lanes=p,l.stateNode={isHidden:!1},l}function Zp(l,d,p){return l=Pr(6,l,null,d),l.lanes=p,l}function em(l,d,p){return d=Pr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function J4(l,d,p,x,N){this.tag=d,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sn(0),this.expirationTimes=sn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sn(0),this.identifierPrefix=x,this.onRecoverableError=N,this.mutableSourceEagerHydrationData=null}function tm(l,d,p,x,N,S,T,z,K){return l=new J4(l,d,p,z,K),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Pr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},pp(S),l}function Y4(l,d,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:x==null?null:""+x,children:l,containerInfo:d,implementation:p}}function nb(l){if(!l)return xi;l=l._reactInternals;e:{if(us(l)!==l||l.tag!==1)throw Error(n(170));var d=l;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(ir(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(n(171))}if(l.tag===1){var p=l.type;if(ir(p))return Ay(l,p,d)}return d}function rb(l,d,p,x,N,S,T,z,K){return l=tm(p,x,!0,l,N,S,T,z,K),l.context=nb(null),p=l.current,x=Xn(),N=ki(p),S=Os(x,N),S.callback=d??null,bi(p,S,N),l.current.lanes=N,li(l,N,x),lr(l,x),l}function Qd(l,d,p,x){var N=d.current,S=Xn(),T=ki(N);return p=nb(p),d.context===null?d.context=p:d.pendingContext=p,d=Os(S,T),d.payload={element:l},x=x===void 0?null:x,x!==null&&(d.callback=x),l=bi(N,d,T),l!==null&&(Gr(l,N,T,S),Td(l,N,T)),T}function Xd(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function sb(l,d){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<d?p:d}}function nm(l,d){sb(l,d),(l=l.alternate)&&sb(l,d)}function Q4(){return null}var ib=typeof reportError=="function"?reportError:function(l){console.error(l)};function rm(l){this._internalRoot=l}Zd.prototype.render=rm.prototype.render=function(l){var d=this._internalRoot;if(d===null)throw Error(n(409));Qd(l,d,null,null)},Zd.prototype.unmount=rm.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var d=l.containerInfo;ja(function(){Qd(null,l,null,null)}),d[Ms]=null}};function Zd(l){this._internalRoot=l}Zd.prototype.unstable_scheduleHydration=function(l){if(l){var d=V0();l={blockedOn:null,target:l,priority:d};for(var p=0;p<hi.length&&d!==0&&d<hi[p].priority;p++);hi.splice(p,0,l),p===0&&U0(l)}};function sm(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function eu(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function ab(){}function X4(l,d,p,x,N){if(N){if(typeof x=="function"){var S=x;x=function(){var le=Xd(T);S.call(le)}}var T=rb(d,x,l,0,null,!1,!1,"",ab);return l._reactRootContainer=T,l[Ms]=T.current,Al(l.nodeType===8?l.parentNode:l),ja(),T}for(;N=l.lastChild;)l.removeChild(N);if(typeof x=="function"){var z=x;x=function(){var le=Xd(K);z.call(le)}}var K=tm(l,0,!1,null,null,!1,!1,"",ab);return l._reactRootContainer=K,l[Ms]=K.current,Al(l.nodeType===8?l.parentNode:l),ja(function(){Qd(d,K,p,x)}),K}function tu(l,d,p,x,N){var S=p._reactRootContainer;if(S){var T=S;if(typeof N=="function"){var z=N;N=function(){var K=Xd(T);z.call(K)}}Qd(d,T,l,N)}else T=X4(p,d,l,N,x);return Xd(T)}F0=function(l){switch(l.tag){case 3:var d=l.stateNode;if(d.current.memoizedState.isDehydrated){var p=Vt(d.pendingLanes);p!==0&&(Tf(d,p|1),lr(d,$t()),(dt&6)===0&&(Eo=$t()+500,yi()))}break;case 13:ja(function(){var x=Ps(l,1);if(x!==null){var N=Xn();Gr(x,l,1,N)}}),nm(l,1)}},Mf=function(l){if(l.tag===13){var d=Ps(l,134217728);if(d!==null){var p=Xn();Gr(d,l,134217728,p)}nm(l,134217728)}},B0=function(l){if(l.tag===13){var d=ki(l),p=Ps(l,d);if(p!==null){var x=Xn();Gr(p,l,d,x)}nm(l,d)}},V0=function(){return xt},H0=function(l,d){var p=xt;try{return xt=l,d()}finally{xt=p}},jt=function(l,d,p){switch(d){case"input":if(Xe(l,p),d=p.name,p.type==="radio"&&d!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+d)+'][type="radio"]'),d=0;d<p.length;d++){var x=p[d];if(x!==l&&x.form===l.form){var N=yd(x);if(!N)throw Error(n(90));Se(x),Xe(x,N)}}}break;case"textarea":zt(l,p);break;case"select":d=p.value,d!=null&&Kn(l,!!p.multiple,d,!1)}},Er=Jp,ii=ja;var Z4={usingClientEntryPoint:!1,Events:[Pl,po,yd,ha,si,Jp]},ql={findFiberByHostInstance:ma,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},e3={bundleType:ql.bundleType,version:ql.version,rendererPackageName:ql.rendererPackageName,rendererConfig:ql.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Yc(l),l===null?null:l.stateNode},findFiberByHostInstance:ql.findFiberByHostInstance||Q4,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nu.isDisabled&&nu.supportsFiber)try{pa=nu.inject(e3),gr=nu}catch{}}return cr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z4,cr.createPortal=function(l,d){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sm(d))throw Error(n(200));return Y4(l,d,null,p)},cr.createRoot=function(l,d){if(!sm(l))throw Error(n(299));var p=!1,x="",N=ib;return d!=null&&(d.unstable_strictMode===!0&&(p=!0),d.identifierPrefix!==void 0&&(x=d.identifierPrefix),d.onRecoverableError!==void 0&&(N=d.onRecoverableError)),d=tm(l,1,!1,null,null,p,!1,x,N),l[Ms]=d.current,Al(l.nodeType===8?l.parentNode:l),new rm(d)},cr.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var d=l._reactInternals;if(d===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=Yc(d),l=l===null?null:l.stateNode,l},cr.flushSync=function(l){return ja(l)},cr.hydrate=function(l,d,p){if(!eu(d))throw Error(n(200));return tu(null,l,d,!0,p)},cr.hydrateRoot=function(l,d,p){if(!sm(l))throw Error(n(405));var x=p!=null&&p.hydratedSources||null,N=!1,S="",T=ib;if(p!=null&&(p.unstable_strictMode===!0&&(N=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onRecoverableError!==void 0&&(T=p.onRecoverableError)),d=rb(d,null,l,1,p??null,N,!1,S,T),l[Ms]=d.current,Al(l),x)for(l=0;l<x.length;l++)p=x[l],N=p._getVersion,N=N(p._source),d.mutableSourceEagerHydrationData==null?d.mutableSourceEagerHydrationData=[p,N]:d.mutableSourceEagerHydrationData.push(p,N);return new Zd(d)},cr.render=function(l,d,p){if(!eu(d))throw Error(n(200));return tu(null,l,d,!1,p)},cr.unmountComponentAtNode=function(l){if(!eu(l))throw Error(n(40));return l._reactRootContainer?(ja(function(){tu(null,null,l,!1,function(){l._reactRootContainer=null,l[Ms]=null})}),!0):!1},cr.unstable_batchedUpdates=Jp,cr.unstable_renderSubtreeIntoContainer=function(l,d,p,x){if(!eu(p))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return tu(l,d,p,!1,x)},cr.version="18.3.1-next-f1338f8080-20240426",cr}var pb;function yN(){if(pb)return om.exports;pb=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),om.exports=l3(),om.exports}var mb;function c3(){if(mb)return ru;mb=1;var t=yN();return ru.createRoot=t.createRoot,ru.hydrateRoot=t.hydrateRoot,ru}var d3=c3(),Fc=yN();const vN=xN(Fc);/**
* @remix-run/router v1.23.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function wc(){return wc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},wc.apply(this,arguments)}var $i;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})($i||($i={}));const gb="popstate";function u3(t){t===void 0&&(t={});function e(r,s){let{pathname:a,search:o,hash:c}=r.location;return og("",{pathname:a,search:o,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(r,s){return typeof s=="string"?s:Fu(s)}return f3(e,n,null,t)}function nn(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function xx(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function h3(){return Math.random().toString(36).substr(2,8)}function xb(t,e){return{usr:t.state,key:t.key,idx:e}}function og(t,e,n,r){return n===void 0&&(n=null),wc({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?il(e):e,{state:n,key:e&&e.key||r||h3()})}function Fu(t){let{pathname:e="/",search:n="",hash:r=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function il(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substr(r),t=t.substr(0,r)),t&&(e.pathname=t)}return e}function f3(t,e,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,o=s.history,c=$i.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(wc({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=$i.Pop;let w=f(),k=w==null?null:w-h;h=w,u&&u({action:c,location:j.location,delta:k})}function g(w,k){c=$i.Push;let E=og(j.location,w,k);h=f()+1;let C=xb(E,h),M=j.createHref(E);try{o.pushState(C,"",M)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;s.location.assign(M)}a&&u&&u({action:c,location:j.location,delta:1})}function y(w,k){c=$i.Replace;let E=og(j.location,w,k);h=f();let C=xb(E,h),M=j.createHref(E);o.replaceState(C,"",M),a&&u&&u({action:c,location:j.location,delta:0})}function v(w){let k=s.location.origin!=="null"?s.location.origin:s.location.href,E=typeof w=="string"?w:Fu(w);return E=E.replace(/ $/,"%20"),nn(k,"No window.location.(origin|href) available to create URL for href: "+E),new URL(E,k)}let j={get action(){return c},get location(){return t(s,o)},listen(w){if(u)throw new Error("A history only accepts one active listener");return s.addEventListener(gb,m),u=w,()=>{s.removeEventListener(gb,m),u=null}},createHref(w){return e(s,w)},createURL:v,encodeLocation(w){let k=v(w);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(w){return o.go(w)}};return j}var yb;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(yb||(yb={}));function p3(t,e,n){return n===void 0&&(n="/"),m3(t,e,n)}function m3(t,e,n,r){let s=typeof e=="string"?il(e):e,a=yx(s.pathname||"/",n);if(a==null)return null;let o=bN(t);g3(o);let c=null;for(let u=0;c==null&&u<o.length;++u){let h=T3(a);c=S3(o[u],h)}return c}function bN(t,e,n,r){e===void 0&&(e=[]),n===void 0&&(n=[]),r===void 0&&(r="");let s=(a,o,c)=>{let u={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};u.relativePath.startsWith("/")&&(nn(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let h=Wi([r,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(nn(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),bN(a.children,e,f,h)),!(a.path==null&&!a.index)&&e.push({path:h,score:j3(h,a.index),routesMeta:f})};return t.forEach((a,o)=>{var c;if(a.path===""||!((c=a.path)!=null&&c.includes("?")))s(a,o);else for(let u of wN(a.path))s(a,o,u)}),e}function wN(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let o=wN(r.join("/")),c=[];return c.push(...o.map(u=>u===""?a:[a,u].join("/"))),s&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function g3(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:k3(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const x3=/^:[\w-]+$/,y3=3,v3=2,b3=1,w3=10,N3=-2,vb=t=>t==="*";function j3(t,e){let n=t.split("/"),r=n.length;return n.some(vb)&&(r+=N3),e&&(r+=v3),n.filter(s=>!vb(s)).reduce((s,a)=>s+(x3.test(a)?y3:a===""?b3:w3),r)}function k3(t,e){return t.length===e.length&&t.slice(0,-1).every((r,s)=>r===e[s])?t[t.length-1]-e[e.length-1]:0}function S3(t,e,n){let{routesMeta:r}=t,s={},a="/",o=[];for(let c=0;c<r.length;++c){let u=r[c],h=c===r.length-1,f=a==="/"?e:e.slice(a.length)||"/",m=C3({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},f),g=u.route;if(!m)return null;Object.assign(s,m.params),o.push({params:s,pathname:Wi([a,m.pathname]),pathnameBase:P3(Wi([a,m.pathnameBase])),route:g}),m.pathnameBase!=="/"&&(a=Wi([a,m.pathnameBase]))}return o}function C3(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=E3(t.path,t.caseSensitive,t.end),s=e.match(n);if(!s)return null;let a=s[0],o=a.replace(/(.)\/+$/,"$1"),c=s.slice(1);return{params:r.reduce((h,f,m)=>{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=a.slice(0,a.length-j.length).replace(/(.)\/+$/,"$1")}const v=c[m];return y&&!v?h[g]=void 0:h[g]=(v||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:o,pattern:t}}function E3(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),xx(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let r=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(r.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),r]}function T3(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return xx(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function yx(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}const M3=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,A3=t=>M3.test(t);function R3(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:s=""}=typeof t=="string"?il(t):t,a;if(n)if(A3(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),xx(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=bb(n.substring(1),"/"):a=bb(n,e)}else a=e;return{pathname:a,search:O3(r),hash:D3(s)}}function bb(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function dm(t,e,n,r){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function I3(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function vx(t,e){let n=I3(t);return e?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function bx(t,e,n,r){r===void 0&&(r=!1);let s;typeof t=="string"?s=il(t):(s=wc({},t),nn(!s.pathname||!s.pathname.includes("?"),dm("?","pathname","search",s)),nn(!s.pathname||!s.pathname.includes("#"),dm("#","pathname","hash",s)),nn(!s.search||!s.search.includes("#"),dm("#","search","hash",s)));let a=t===""||s.pathname==="",o=a?"/":s.pathname,c;if(o==null)c=n;else{let m=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),m-=1;s.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=R3(s,c),h=o&&o!=="/"&&o.endsWith("/"),f=(a||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const Wi=t=>t.join("/").replace(/\/\/+/g,"/"),P3=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),O3=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,D3=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function L3(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const NN=["post","put","patch","delete"];new Set(NN);const _3=["get",...NN];new Set(_3);/**
* React Router v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function Nc(){return Nc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Nc.apply(this,arguments)}const wx=b.createContext(null),z3=b.createContext(null),na=b.createContext(null),Hh=b.createContext(null),ti=b.createContext({outlet:null,matches:[],isDataRoute:!1}),jN=b.createContext(null);function $3(t,e){let{relative:n}=e===void 0?{}:e;al()||nn(!1);let{basename:r,navigator:s}=b.useContext(na),{hash:a,pathname:o,search:c}=SN(t,{relative:n}),u=o;return r!=="/"&&(u=o==="/"?r:Wi([r,o])),s.createHref({pathname:u,search:c,hash:a})}function al(){return b.useContext(Hh)!=null}function ra(){return al()||nn(!1),b.useContext(Hh).location}function kN(t){b.useContext(na).static||b.useLayoutEffect(t)}function sa(){let{isDataRoute:t}=b.useContext(ti);return t?eT():F3()}function F3(){al()||nn(!1);let t=b.useContext(wx),{basename:e,future:n,navigator:r}=b.useContext(na),{matches:s}=b.useContext(ti),{pathname:a}=ra(),o=JSON.stringify(vx(s,n.v7_relativeSplatPath)),c=b.useRef(!1);return kN(()=>{c.current=!0}),b.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=bx(h,JSON.parse(o),a,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:Wi([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,a,t])}const B3=b.createContext(null);function V3(t){let e=b.useContext(ti).outlet;return e&&b.createElement(B3.Provider,{value:t},e)}function SN(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=b.useContext(na),{matches:s}=b.useContext(ti),{pathname:a}=ra(),o=JSON.stringify(vx(s,r.v7_relativeSplatPath));return b.useMemo(()=>bx(t,JSON.parse(o),a,n==="path"),[t,o,a,n])}function H3(t,e){return W3(t,e)}function W3(t,e,n,r){al()||nn(!1);let{navigator:s}=b.useContext(na),{matches:a}=b.useContext(ti),o=a[a.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=ra(),f;if(e){var m;let w=typeof e=="string"?il(e):e;u==="/"||(m=w.pathname)!=null&&m.startsWith(u)||nn(!1),f=w}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let w=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(w.length).join("/")}let v=p3(t,{pathname:y}),j=J3(v&&v.map(w=>Object.assign({},w,{params:Object.assign({},c,w.params),pathname:Wi([u,s.encodeLocation?s.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?u:Wi([u,s.encodeLocation?s.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),a,n,r);return e&&j?b.createElement(Hh.Provider,{value:{location:Nc({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:$i.Pop}},j):j}function U3(){let t=Z3(),e=L3(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),n?b.createElement("pre",{style:s},n):null,null)}const K3=b.createElement(U3,null);class q3 extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?b.createElement(ti.Provider,{value:this.props.routeContext},b.createElement(jN.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function G3(t){let{routeContext:e,match:n,children:r}=t,s=b.useContext(wx);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(ti.Provider,{value:e},r)}function J3(t,e,n,r){var s;if(e===void 0&&(e=[]),n===void 0&&(n=null),r===void 0&&(r=null),t==null){var a;if(!n)return null;if(n.errors)t=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,c=(s=n)==null?void 0:s.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||nn(!1),o=o.slice(0,Math.min(o.length,f+1))}let u=!1,h=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f<o.length;f++){let m=o[f];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(h=f),m.route.id){let{loaderData:g,errors:y}=n,v=m.route.loader&&g[m.route.id]===void 0&&(!y||y[m.route.id]===void 0);if(m.route.lazy||v){u=!0,h>=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,v=!1,j=null,w=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||K3,u&&(h<0&&g===0?(tT("route-fallback"),v=!0,w=null):h===g&&(v=!0,w=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),E=()=>{let C;return y?C=j:v?C=w:m.route.Component?C=b.createElement(m.route.Component,null):m.route.element?C=m.route.element:C=f,b.createElement(G3,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:C})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(q3,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:E(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):E()},null)}var CN=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(CN||{}),EN=(function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t})(EN||{});function Y3(t){let e=b.useContext(wx);return e||nn(!1),e}function Q3(t){let e=b.useContext(z3);return e||nn(!1),e}function X3(t){let e=b.useContext(ti);return e||nn(!1),e}function TN(t){let e=X3(),n=e.matches[e.matches.length-1];return n.route.id||nn(!1),n.route.id}function Z3(){var t;let e=b.useContext(jN),n=Q3(),r=TN();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function eT(){let{router:t}=Y3(CN.UseNavigateStable),e=TN(EN.UseNavigateStable),n=b.useRef(!1);return kN(()=>{n.current=!0}),b.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,Nc({fromRouteId:e},a)))},[t,e])}const wb={};function tT(t,e,n){wb[t]||(wb[t]=!0)}function nT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function um(t){let{to:e,replace:n,state:r,relative:s}=t;al()||nn(!1);let{future:a,static:o}=b.useContext(na),{matches:c}=b.useContext(ti),{pathname:u}=ra(),h=sa(),f=bx(e,vx(c,a.v7_relativeSplatPath),u,s==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:s}),[h,m,s,n,r]),null}function rT(t){return V3(t.context)}function Mt(t){nn(!1)}function sT(t){let{basename:e="/",children:n=null,location:r,navigationType:s=$i.Pop,navigator:a,static:o=!1,future:c}=t;al()&&nn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:a,static:o,future:Nc({v7_relativeSplatPath:!1},c)}),[u,c,a,o]);typeof r=="string"&&(r=il(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:v="default"}=r,j=b.useMemo(()=>{let w=yx(f,u);return w==null?null:{location:{pathname:w,search:m,hash:g,state:y,key:v},navigationType:s}},[u,f,m,g,y,v,s]);return j==null?null:b.createElement(na.Provider,{value:h},b.createElement(Hh.Provider,{children:n,value:j}))}function iT(t){let{children:e,location:n}=t;return H3(lg(e),n)}new Promise(()=>{});function lg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(r,s)=>{if(!b.isValidElement(r))return;let a=[...e,s];if(r.type===b.Fragment){n.push.apply(n,lg(r.props.children,a));return}r.type!==Mt&&nn(!1),!r.props.index||!r.props.children||nn(!1);let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=lg(r.props.children,a)),n.push(o)}),n}/**
* React Router DOM v6.30.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function cg(){return cg=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},cg.apply(this,arguments)}function aT(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,a;for(a=0;a<r.length;a++)s=r[a],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function oT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function lT(t,e){return t.button===0&&(!e||e==="_self")&&!oT(t)}function dg(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(s=>[n,s]):[[n,r]])},[]))}function cT(t,e){let n=dg(t);return e&&e.forEach((r,s)=>{n.has(s)||e.getAll(s).forEach(a=>{n.append(s,a)})}),n}const dT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],uT="6";try{window.__reactRouterVersion=uT}catch{}const hT="startTransition",Nb=Vh[hT];function fT(t){let{basename:e,children:n,future:r,window:s}=t,a=b.useRef();a.current==null&&(a.current=u3({window:s,v5Compat:!0}));let o=a.current,[c,u]=b.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=b.useCallback(m=>{h&&Nb?Nb(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>nT(r),[r]),b.createElement(sT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const pT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ug=b.forwardRef(function(e,n){let{onClick:r,relative:s,reloadDocument:a,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=aT(e,dT),{basename:y}=b.useContext(na),v,j=!1;if(typeof h=="string"&&mT.test(h)&&(v=h,pT))try{let C=new URL(window.location.href),M=h.startsWith("//")?new URL(C.protocol+h):new URL(h),D=yx(M.pathname,y);M.origin===C.origin&&D!=null?h=D+M.search+M.hash:j=!0}catch{}let w=$3(h,{relative:s}),k=gT(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:s,viewTransition:m});function E(C){r&&r(C),C.defaultPrevented||k(C)}return b.createElement("a",cg({},g,{href:v||w,onClick:j||a?r:E,ref:n,target:u}))});var jb;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(jb||(jb={}));var kb;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(kb||(kb={}));function gT(t,e){let{target:n,replace:r,state:s,preventScrollReset:a,relative:o,viewTransition:c}=e===void 0?{}:e,u=sa(),h=ra(),f=SN(t,{relative:o});return b.useCallback(m=>{if(lT(m,n)){m.preventDefault();let g=r!==void 0?r:Fu(h)===Fu(f);u(t,{replace:g,state:s,preventScrollReset:a,relative:o,viewTransition:c})}},[h,u,f,r,s,n,t,a,o,c])}function MN(t){let e=b.useRef(dg(t)),n=b.useRef(!1),r=ra(),s=b.useMemo(()=>cT(r.search,n.current?null:e.current),[r.search]),a=sa(),o=b.useCallback((c,u)=>{const h=dg(typeof c=="function"?c(s):c);n.current=!0,a("?"+h,u)},[a,s]);return[s,o]}/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yT=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Sb=t=>{const e=yT(t);return e.charAt(0).toUpperCase()+e.slice(1)},AN=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),vT=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var bT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...bT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:AN("lucide",s),...!a&&!vT(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>b.createElement(h,f)),...Array.isArray(a)?a:[a]]));/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const je=(t,e)=>{const n=b.forwardRef(({className:r,...s},a)=>b.createElement(wT,{ref:a,iconNode:e,className:AN(`lucide-${xT(Sb(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Sb(t),n};/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const NT=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],jT=je("arrow-up-down",NT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kT=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Cb=je("bitcoin",kT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ST=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],CT=je("bold",ST);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ET=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],zr=je("book-open",ET);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TT=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Bu=je("calendar",TT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const MT=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],AT=je("chart-column",MT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const RT=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Wh=je("check",RT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const IT=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],jc=je("chevron-down",IT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PT=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],OT=je("chevron-left",PT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const DT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Fo=je("chevron-right",DT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LT=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],RN=je("chevron-up",LT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],zT=je("circle-alert",_T);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $T=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Eb=je("circle-check-big",$T);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const FT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],hg=je("circle-check",FT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const BT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],IN=je("circle-question-mark",BT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const VT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],hm=je("circle-user",VT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HT=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],PN=je("circle-x",HT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const WT=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fg=je("clock",WT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UT=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],KT=je("code",UT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qT=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ON=je("copy",qT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const GT=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Tb=je("credit-card",GT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JT=[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]],Aa=je("crown",JT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YT=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Vu=je("dollar-sign",YT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const QT=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],XT=je("download",QT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZT=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Xs=je("external-link",ZT);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eM=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],pg=je("eye",eM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tM=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],nM=je("file-text",tM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rM=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],DN=je("funnel",rM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sM=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],iM=je("gift",sM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aM=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],oM=je("git-merge",aM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],mg=je("globe",lM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cM=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],dM=je("graduation-cap",cM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uM=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],_s=je("grip-vertical",uM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hM=[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]],fM=je("handshake",hM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const pM=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],mM=je("hash",pM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],xM=je("heading-1",gM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],vM=je("heading-2",yM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bM=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],wM=je("heading-3",bM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const NM=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],jM=je("house",NM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kM=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],LN=je("image",kM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const SM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],su=je("info",SM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const CM=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],EM=je("italic",CM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TM=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],MM=je("key",TM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const AM=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],RM=je("layout-dashboard",AM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const IM=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Gs=je("link-2",IM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PM=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],gg=je("link",PM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OM=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],DM=je("list-ordered",OM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LM=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],_M=je("list",LM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zM=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],$M=je("lock",zM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const FM=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],BM=je("log-out",FM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const VM=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],_N=je("map-pin",VM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const HM=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],WM=je("menu",HM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const UM=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],KM=je("message-circle",UM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qM=[["path",{d:"M5 12h14",key:"1ays0h"}]],GM=je("minus",qM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JM=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],Bo=je("navigation",JM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YM=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],QM=je("palette",YM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XM=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],bt=je("pen-line",XM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZM=[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]],eA=je("percent",ZM);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tA=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],nA=je("phone",tA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rA=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],sA=je("pin",rA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Lt=je("plus",iA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aA=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Mb=je("qr-code",aA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const oA=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],lA=je("quote",oA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cA=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],dA=je("redo",cA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const uA=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],qe=je("refresh-cw",uA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hA=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],rn=je("save",hA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fA=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ui=je("search",fA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const pA=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],mA=je("send",pA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gA=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Da=je("settings",gA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xA=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],fm=je("settings-2",xA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yA=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Nx=je("shield-check",yA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vA=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],xg=je("shopping-bag",vA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bA=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],kc=je("smartphone",bA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wA=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Vo=je("star",wA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const NA=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],jA=je("strikethrough",NA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kA=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],SA=je("table",kA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const CA=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],pm=je("tag",CA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const EA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],vn=je("trash-2",EA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TA=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],cc=je("trending-up",TA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const MA=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],Ab=je("trophy",MA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const AA=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],zN=je("undo-2",AA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const RA=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],IA=je("undo",RA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Hu=je("upload",PA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],yg=je("user-plus",OA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const DA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Wo=je("user",DA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const LA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Nn=je("users",LA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _A=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Jo=je("wallet",_A);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],er=je("x",zA);/**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $A=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Fi=je("zap",$A),jx="admin_token";function kx(){try{return localStorage.getItem(jx)}catch{return null}}function FA(t){try{localStorage.setItem(jx,t)}catch{}}function BA(){try{localStorage.removeItem(jx)}catch{}}const VA="https://soulapi.quwanzhi.com",HA=15e3,WA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):VA};function Yo(t){const e=WA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function Uh(t,e={}){const{data:n,...r}=e,s=Yo(t),a=new Headers(r.headers),o=kx();o&&a.set("Authorization",`Bearer ${o}`),n!=null&&!a.has("Content-Type")&&a.set("Content-Type","application/json");const c=n!=null?JSON.stringify(n):r.body,u=new AbortController,h=setTimeout(()=>u.abort(),HA),f=await fetch(s,{...r,headers:a,body:c,credentials:"include",signal:u.signal}).finally(()=>clearTimeout(h)),g=(f.headers.get("Content-Type")||"").includes("application/json")?await f.json():f;if(!f.ok){const y=new Error((g==null?void 0:g.error)||`HTTP ${f.status}`);throw y.status=f.status,y.data=g,y}return g}function Be(t,e){return Uh(t,{...e,method:"GET"})}function ht(t,e,n){return Uh(t,{...n,method:"POST",data:e})}function Rt(t,e,n){return Uh(t,{...n,method:"PUT",data:e})}function Yr(t,e){return Uh(t,{...e,method:"DELETE"})}const UA=[{icon:RM,label:"数据概览",href:"/dashboard"},{icon:zr,label:"内容管理",href:"/content"},{icon:Nn,label:"用户管理",href:"/users"},{icon:oM,label:"找伙伴",href:"/find-partner"},{icon:Jo,label:"推广中心",href:"/distribution"}];function KA(){const t=ra(),e=sa(),[n,r]=b.useState(!1),[s,a]=b.useState(!1);b.useEffect(()=>{r(!0)},[]),b.useEffect(()=>{if(!n)return;a(!1);let c=!1;return Be("/api/admin").then(u=>{c||(u&&u.success!==!1?a(!0):e("/login",{replace:!0}))}).catch(()=>{c||e("/login",{replace:!0})}),()=>{c=!0}},[n,e]);const o=async()=>{BA();try{await ht("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!s?i.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[i.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):i.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[i.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[i.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[i.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),i.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),i.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[UA.map(c=>{const u=t.pathname===c.href;return i.jsxs(ug,{to:c.href,className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${u?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[i.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),i.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),i.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:i.jsxs(ug,{to:"/settings",className:`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${t.pathname==="/settings"?"bg-[#38bdac]/20 text-[#38bdac] font-medium":"text-gray-400 hover:bg-gray-700/50 hover:text-white"}`,children:[i.jsx(Da,{className:"w-5 h-5 shrink-0"}),i.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),i.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:i.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-700/50 transition-colors",children:[i.jsx(BM,{className:"w-5 h-5"}),i.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),i.jsx("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0",children:i.jsx("div",{className:"w-full min-w-[1024px] min-h-full",children:i.jsx(rT,{})})})]})}function Rb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Sx(...t){return e=>{let n=!1;const r=t.map(s=>{const a=Rb(s,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():Rb(t[s],null)}}}}function mt(...t){return b.useCallback(Sx(...t),t)}var qA=Symbol.for("react.lazy"),Wu=Vh[" use ".trim().toString()];function GA(t){return typeof t=="object"&&t!==null&&"then"in t}function $N(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===qA&&"_payload"in t&&GA(t._payload)}function FN(t){const e=JA(t),n=b.forwardRef((r,s)=>{let{children:a,...o}=r;$N(a)&&typeof Wu=="function"&&(a=Wu(a._payload));const c=b.Children.toArray(a),u=c.find(QA);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return i.jsx(e,{...o,ref:s,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return i.jsx(e,{...o,ref:s,children:a})});return n.displayName=`${t}.Slot`,n}var BN=FN("Slot");function JA(t){const e=b.forwardRef((n,r)=>{let{children:s,...a}=n;if($N(s)&&typeof Wu=="function"&&(s=Wu(s._payload)),b.isValidElement(s)){const o=ZA(s),c=XA(a,s.props);return s.type!==b.Fragment&&(c.ref=r?Sx(r,o):o),b.cloneElement(s,c)}return b.Children.count(s)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var YA=Symbol("radix.slottable");function QA(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===YA}function XA(t,e){const n={...e};for(const r in e){const s=t[r],a=e[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...c)=>{const u=a(...c);return s(...c),u}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...t,...n}}function ZA(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function VN(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=VN(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function HN(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=VN(t))&&(r&&(r+=" "),r+=e);return r}const Ib=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Pb=HN,WN=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Pb(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:a}=e,o=Object.keys(s).map(h=>{const f=n==null?void 0:n[h],m=a==null?void 0:a[h];if(f===null)return null;const g=Ib(f)||Ib(m);return s[h][g]}),c=n&&Object.entries(n).reduce((h,f)=>{let[m,g]=f;return g===void 0||(h[m]=g),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,f)=>{let{class:m,className:g,...y}=f;return Object.entries(y).every(v=>{let[j,w]=v;return Array.isArray(w)?w.includes({...a,...c}[j]):{...a,...c}[j]===w})?[...h,m,g]:h},[]);return Pb(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},eR=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},tR=(t,e)=>({classGroupId:t,validator:e}),UN=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Uu="-",Ob=[],nR="arbitrary..",rR=t=>{const e=iR(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return sR(o);const c=o.split(Uu),u=c[0]===""&&c.length>1?1:0;return KN(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?eR(h,u):u:h||Ob}return n[o]||Ob}}},KN=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const s=t[e],a=n.nextPart.get(s);if(a){const h=KN(t,e+1,a);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Uu):t.slice(e).join(Uu),u=o.length;for(let h=0;h<u;h++){const f=o[h];if(f.validator(c))return f.classGroupId}},sR=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?nR+r:void 0})(),iR=t=>{const{theme:e,classGroups:n}=t;return aR(n,e)},aR=(t,e)=>{const n=UN();for(const r in t){const s=t[r];Cx(s,n,r,e)}return n},Cx=(t,e,n,r)=>{const s=t.length;for(let a=0;a<s;a++){const o=t[a];oR(o,e,n,r)}},oR=(t,e,n,r)=>{if(typeof t=="string"){lR(t,e,n);return}if(typeof t=="function"){cR(t,e,n,r);return}dR(t,e,n,r)},lR=(t,e,n)=>{const r=t===""?e:qN(e,t);r.classGroupId=n},cR=(t,e,n,r)=>{if(uR(t)){Cx(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(tR(n,t))},dR=(t,e,n,r)=>{const s=Object.entries(t),a=s.length;for(let o=0;o<a;o++){const[c,u]=s[o];Cx(u,qN(e,c),n,r)}},qN=(t,e)=>{let n=t;const r=e.split(Uu),s=r.length;for(let a=0;a<s;a++){const o=r[a];let c=n.nextPart.get(o);c||(c=UN(),n.nextPart.set(o,c)),n=c}return n},uR=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,hR=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const s=(a,o)=>{n[a]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return s(a,o),o},set(a,o){a in n?n[a]=o:s(a,o)}}},vg="!",Db=":",fR=[],Lb=(t,e,n,r,s)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),pR=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=s=>{const a=[];let o=0,c=0,u=0,h;const f=s.length;for(let j=0;j<f;j++){const w=s[j];if(o===0&&c===0){if(w===Db){a.push(s.slice(u,j)),u=j+1;continue}if(w==="/"){h=j;continue}}w==="["?o++:w==="]"?o--:w==="("?c++:w===")"&&c--}const m=a.length===0?s:s.slice(u);let g=m,y=!1;m.endsWith(vg)?(g=m.slice(0,-1),y=!0):m.startsWith(vg)&&(g=m.slice(1),y=!0);const v=h&&h>u?h-u:void 0;return Lb(a,y,g,v)};if(e){const s=e+Db,a=r;r=o=>o.startsWith(s)?a(o.slice(s.length)):Lb(fR,!1,o,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},mR=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let s=[];for(let a=0;a<n.length;a++){const o=n[a],c=o[0]==="[",u=e.has(o);c||u?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(o)):s.push(o)}return s.length>0&&(s.sort(),r.push(...s)),r}},gR=t=>({cache:hR(t.cacheSize),parseClassName:pR(t),sortModifiers:mR(t),...rR(t)}),xR=/\s+/,yR=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=e,o=[],c=t.trim().split(xR);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:v,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let w=!!j,k=r(w?v.substring(0,j):v);if(!k){if(!w){u=f+(u.length>0?" "+u:u);continue}if(k=r(v),!k){u=f+(u.length>0?" "+u:u);continue}w=!1}const E=g.length===0?"":g.length===1?g[0]:a(g).join(":"),C=y?E+vg:E,M=C+k;if(o.indexOf(M)>-1)continue;o.push(M);const D=s(k,w);for(let F=0;F<D.length;++F){const R=D[F];o.push(C+R)}u=f+(u.length>0?" "+u:u)}return u},vR=(...t)=>{let e=0,n,r,s="";for(;e<t.length;)(n=t[e++])&&(r=GN(n))&&(s&&(s+=" "),s+=r);return s},GN=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=GN(t[r]))&&(n&&(n+=" "),n+=e);return n},bR=(t,...e)=>{let n,r,s,a;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=gR(h),r=n.cache.get,s=n.cache.set,a=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=yR(u,n);return s(u,f),f};return a=o,(...u)=>a(vR(...u))},wR=[],un=t=>{const e=n=>n[t]||wR;return e.isThemeGetter=!0,e},JN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,YN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,NR=/^\d+\/\d+$/,jR=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,kR=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,SR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,CR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ER=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Mo=t=>NR.test(t),at=t=>!!t&&!Number.isNaN(Number(t)),Ti=t=>!!t&&Number.isInteger(Number(t)),mm=t=>t.endsWith("%")&&at(t.slice(0,-1)),zs=t=>jR.test(t),TR=()=>!0,MR=t=>kR.test(t)&&!SR.test(t),QN=()=>!1,AR=t=>CR.test(t),RR=t=>ER.test(t),IR=t=>!De(t)&&!Le(t),PR=t=>ol(t,ej,QN),De=t=>JN.test(t),Ea=t=>ol(t,tj,MR),gm=t=>ol(t,zR,at),_b=t=>ol(t,XN,QN),OR=t=>ol(t,ZN,RR),iu=t=>ol(t,nj,AR),Le=t=>YN.test(t),Jl=t=>ll(t,tj),DR=t=>ll(t,$R),zb=t=>ll(t,XN),LR=t=>ll(t,ej),_R=t=>ll(t,ZN),au=t=>ll(t,nj,!0),ol=(t,e,n)=>{const r=JN.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},ll=(t,e,n=!1)=>{const r=YN.exec(t);return r?r[1]?e(r[1]):n:!1},XN=t=>t==="position"||t==="percentage",ZN=t=>t==="image"||t==="url",ej=t=>t==="length"||t==="size"||t==="bg-size",tj=t=>t==="length",zR=t=>t==="number",$R=t=>t==="family-name",nj=t=>t==="shadow",FR=()=>{const t=un("color"),e=un("font"),n=un("text"),r=un("font-weight"),s=un("tracking"),a=un("leading"),o=un("breakpoint"),c=un("container"),u=un("spacing"),h=un("radius"),f=un("shadow"),m=un("inset-shadow"),g=un("text-shadow"),y=un("drop-shadow"),v=un("blur"),j=un("perspective"),w=un("aspect"),k=un("ease"),E=un("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...M(),Le,De],F=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],I=()=>[Le,De,u],A=()=>[Mo,"full","auto",...I()],O=()=>[Ti,"none","subgrid",Le,De],W=()=>["auto",{span:["full",Ti,Le,De]},Ti,Le,De],X=()=>[Ti,"auto",Le,De],q=()=>["auto","min","max","fr",Le,De],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...I()],oe=()=>[Mo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],V=()=>[t,Le,De],ae=()=>[...M(),zb,_b,{position:[Le,De]}],Y=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",LR,PR,{size:[Le,De]}],H=()=>[mm,Jl,Ea],ue=()=>["","none","full",h,Le,De],U=()=>["",at,Jl,Ea],he=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[at,mm,zb,_b],de=()=>["","none",v,Le,De],Ce=()=>["none",at,Le,De],B=()=>["none",at,Le,De],me=()=>[at,Le,De],Se=()=>[Mo,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[zs],breakpoint:[zs],color:[TR],container:[zs],"drop-shadow":[zs],ease:["in","out","in-out"],font:[IR],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[zs],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[zs],shadow:[zs],spacing:["px",at],text:[zs],"text-shadow":[zs],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Mo,De,Le,w]}],container:["container"],columns:[{columns:[at,De,Le,c]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Ti,"auto",Le,De]}],basis:[{basis:[Mo,"full","auto",c,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,Mo,"auto","initial","none",De]}],grow:[{grow:["",at,Le,De]}],shrink:[{shrink:["",at,Le,De]}],order:[{order:[Ti,"first","last","none",Le,De]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":q()}],"auto-rows":[{"auto-rows":q()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:oe()}],w:[{w:[c,"screen",...oe()]}],"min-w":[{"min-w":[c,"screen","none",...oe()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,Jl,Ea]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Le,gm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",mm,De]}],"font-family":[{font:[DR,De,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,Le,De]}],"line-clamp":[{"line-clamp":[at,"none",Le,gm]}],leading:[{leading:[a,...I()]}],"list-image":[{"list-image":["none",Le,De]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Le,De]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...he(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Le,Ea]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[at,"auto",Le,De]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Le,De]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Le,De]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ae()}],"bg-repeat":[{bg:Y()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ti,Le,De],radial:["",Le,De],conic:[Ti,Le,De]},_R,OR]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...he(),"hidden","none"]}],"divide-style":[{divide:[...he(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...he(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Le,De]}],"outline-w":[{outline:["",at,Jl,Ea]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",f,au,iu]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",m,au,iu]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[at,Ea]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",g,au,iu]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[at,Le,De]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[Le,De]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":M()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:Y()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Le,De]}],filter:[{filter:["","none",Le,De]}],blur:[{blur:de()}],brightness:[{brightness:[at,Le,De]}],contrast:[{contrast:[at,Le,De]}],"drop-shadow":[{"drop-shadow":["","none",y,au,iu]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",at,Le,De]}],"hue-rotate":[{"hue-rotate":[at,Le,De]}],invert:[{invert:["",at,Le,De]}],saturate:[{saturate:[at,Le,De]}],sepia:[{sepia:["",at,Le,De]}],"backdrop-filter":[{"backdrop-filter":["","none",Le,De]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[at,Le,De]}],"backdrop-contrast":[{"backdrop-contrast":[at,Le,De]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Le,De]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Le,De]}],"backdrop-invert":[{"backdrop-invert":["",at,Le,De]}],"backdrop-opacity":[{"backdrop-opacity":[at,Le,De]}],"backdrop-saturate":[{"backdrop-saturate":[at,Le,De]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Le,De]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Le,De]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Le,De]}],ease:[{ease:["linear","initial",k,Le,De]}],delay:[{delay:[at,Le,De]}],animate:[{animate:["none",E,Le,De]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Le,De]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[Le,De,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Le,De]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Le,De]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[at,Jl,Ea,gm]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},BR=bR(FR);function gt(...t){return BR(HN(t))}const VR=WN("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function re({className:t,variant:e,size:n,asChild:r=!1,...s}){const a=r?BN:"button";return i.jsx(a,{"data-slot":"button",className:gt(VR({variant:e,size:n,className:t})),...s})}function ce({className:t,type:e,...n}){return i.jsx("input",{type:e,"data-slot":"input",className:gt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 md:text-sm focus-visible:ring-2 focus-visible:ring-ring",t),...n})}function HR(){const t=sa(),[e,n]=b.useState(""),[r,s]=b.useState(""),[a,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await ht("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){FA(f.token),t("/dashboard",{replace:!0});return}o(f.error||"用户名或密码错误")}catch(f){const m=f;o(m.status===401?"用户名或密码错误":(m==null?void 0:m.message)||"网络错误,请重试")}finally{u(!1)}};return i.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[i.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[i.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),i.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),i.jsxs("div",{className:"w-full max-w-md relative z-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"w-16 h-16 bg-[#38bdac]/20 rounded-2xl flex items-center justify-center mx-auto mb-4 border border-[#38bdac]/30",children:i.jsx(Nx,{className:"w-8 h-8 text-[#38bdac]"})}),i.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),i.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),i.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[i.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),i.jsxs("div",{className:"relative",children:[i.jsx(Wo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),i.jsx(ce,{type:"text",value:e,onChange:f=>n(f.target.value),placeholder:"请输入用户名",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),i.jsxs("div",{className:"relative",children:[i.jsx($M,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),i.jsx(ce,{type:"password",value:r,onChange:f=>s(f.target.value),placeholder:"请输入密码",className:"pl-10 bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 focus:border-[#38bdac]",onKeyDown:f=>f.key==="Enter"&&h()})]})]}),a&&i.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:a}),i.jsx(re,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),i.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ee=b.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:gt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ee.displayName="Card";const et=b.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:gt("flex flex-col space-y-1.5 p-6",t),...e}));et.displayName="CardHeader";const tt=b.forwardRef(({className:t,...e},n)=>i.jsx("h3",{ref:n,className:gt("font-semibold leading-none tracking-tight",t),...e}));tt.displayName="CardTitle";const It=b.forwardRef(({className:t,...e},n)=>i.jsx("p",{ref:n,className:gt("text-sm text-muted-foreground",t),...e}));It.displayName="CardDescription";const Te=b.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:gt("p-6 pt-0",t),...e}));Te.displayName="CardContent";const WR=b.forwardRef(({className:t,...e},n)=>i.jsx("div",{ref:n,className:gt("flex items-center p-6 pt-0",t),...e}));WR.displayName="CardFooter";function nt(t,e,{checkForDefaultPrevented:n=!0}={}){return function(s){if(t==null||t(s),n===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function UR(t,e){const n=b.createContext(e),r=a=>{const{children:o,...c}=a,u=b.useMemo(()=>c,Object.values(c));return i.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function s(a){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,s]}function ia(t,e=[]){let n=[];function r(a,o){const c=b.createContext(o),u=n.length;n=[...n,o];const h=m=>{var k;const{scope:g,children:y,...v}=m,j=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,w=b.useMemo(()=>v,Object.values(v));return i.jsx(j.Provider,{value:w,children:y})};h.displayName=a+"Provider";function f(m,g){var j;const y=((j=g==null?void 0:g[t])==null?void 0:j[u])||c,v=b.useContext(y);if(v)return v;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[h,f]}const s=()=>{const a=n.map(o=>b.createContext(o));return function(c){const u=(c==null?void 0:c[t])||a;return b.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return s.scopeName=t,[r,KR(s,...e)]}function KR(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(a)[`__scope${h}`];return{...c,...m}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Vn=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},qR=Vh[" useId ".trim().toString()]||(()=>{}),GR=0;function Ki(t){const[e,n]=b.useState(qR());return Vn(()=>{n(r=>r??String(GR++))},[t]),e?`radix-${e}`:""}var JR=Vh[" useInsertionEffect ".trim().toString()]||Vn;function Ba({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[s,a,o]=YR({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:s;{const f=b.useRef(t!==void 0);b.useEffect(()=>{const m=f.current;m!==c&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,r])}const h=b.useCallback(f=>{var m;if(c){const g=QR(f)?f(t):f;g!==t&&((m=o.current)==null||m.call(o,g))}else a(f)},[c,t,a,o]);return[u,h]}function YR({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),s=b.useRef(n),a=b.useRef(e);return JR(()=>{a.current=e},[e]),b.useEffect(()=>{var o;s.current!==n&&((o=a.current)==null||o.call(a,n),s.current=n)},[n,s]),[n,r,a]}function QR(t){return typeof t=="function"}function Sc(t){const e=XR(t),n=b.forwardRef((r,s)=>{const{children:a,...o}=r,c=b.Children.toArray(a),u=c.find(e5);if(u){const h=u.props.children,f=c.map(m=>m===u?b.Children.count(h)>1?b.Children.only(null):b.isValidElement(h)?h.props.children:null:m);return i.jsx(e,{...o,ref:s,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return i.jsx(e,{...o,ref:s,children:a})});return n.displayName=`${t}.Slot`,n}function XR(t){const e=b.forwardRef((n,r)=>{const{children:s,...a}=n;if(b.isValidElement(s)){const o=n5(s),c=t5(a,s.props);return s.type!==b.Fragment&&(c.ref=r?Sx(r,o):o),b.cloneElement(s,c)}return b.Children.count(s)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var ZR=Symbol("radix.slottable");function e5(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ZR}function t5(t,e){const n={...e};for(const r in e){const s=t[r],a=e[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...c)=>{const u=a(...c);return s(...c),u}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...t,...n}}function n5(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var r5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ot=r5.reduce((t,e)=>{const n=Sc(`Primitive.${e}`),r=b.forwardRef((s,a)=>{const{asChild:o,...c}=s,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function s5(t,e){t&&Fc.flushSync(()=>t.dispatchEvent(e))}function Qi(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function i5(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t);b.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var a5="DismissableLayer",bg="dismissableLayer.update",o5="dismissableLayer.pointerDownOutside",l5="dismissableLayer.focusOutside",$b,rj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ex=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(rj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),v=mt(e,R=>m(R)),j=Array.from(h.layers),[w]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=j.indexOf(w),E=f?j.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,M=E>=k,D=u5(R=>{const I=R.target,A=[...h.branches].some(O=>O.contains(I));!M||A||(s==null||s(R),o==null||o(R),R.defaultPrevented||c==null||c())},g),F=h5(R=>{const I=R.target;[...h.branches].some(O=>O.contains(I))||(a==null||a(R),o==null||o(R),R.defaultPrevented||c==null||c())},g);return i5(R=>{E===h.layers.size-1&&(r==null||r(R),!R.defaultPrevented&&c&&(R.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&($b=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),Fb(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=$b)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),Fb())},[f,h]),b.useEffect(()=>{const R=()=>y({});return document.addEventListener(bg,R),()=>document.removeEventListener(bg,R)},[]),i.jsx(ot.div,{...u,ref:v,style:{pointerEvents:C?M?"auto":"none":void 0,...t.style},onFocusCapture:nt(t.onFocusCapture,F.onFocusCapture),onBlurCapture:nt(t.onBlurCapture,F.onBlurCapture),onPointerDownCapture:nt(t.onPointerDownCapture,D.onPointerDownCapture)})});Ex.displayName=a5;var c5="DismissableLayerBranch",d5=b.forwardRef((t,e)=>{const n=b.useContext(rj),r=b.useRef(null),s=mt(e,r);return b.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),i.jsx(ot.div,{...t,ref:s})});d5.displayName=c5;function u5(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t),r=b.useRef(!1),s=b.useRef(()=>{});return b.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let u=function(){sj(o5,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=u,e.addEventListener("click",s.current,{once:!0})):u()}else e.removeEventListener("click",s.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",a),e.removeEventListener("click",s.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function h5(t,e=globalThis==null?void 0:globalThis.document){const n=Qi(t),r=b.useRef(!1);return b.useEffect(()=>{const s=a=>{a.target&&!r.current&&sj(l5,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Fb(){const t=new CustomEvent(bg);document.dispatchEvent(t)}function sj(t,e,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?s5(s,a):s.dispatchEvent(a)}var xm="focusScope.autoFocusOnMount",ym="focusScope.autoFocusOnUnmount",Bb={bubbles:!1,cancelable:!0},f5="FocusScope",Tx=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[c,u]=b.useState(null),h=Qi(s),f=Qi(a),m=b.useRef(null),g=mt(e,j=>u(j)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let j=function(C){if(y.paused||!c)return;const M=C.target;c.contains(M)?m.current=M:Ri(m.current,{select:!0})},w=function(C){if(y.paused||!c)return;const M=C.relatedTarget;M!==null&&(c.contains(M)||Ri(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&Ri(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const E=new MutationObserver(k);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),E.disconnect()}}},[r,c,y.paused]),b.useEffect(()=>{if(c){Hb.add(y);const j=document.activeElement;if(!c.contains(j)){const k=new CustomEvent(xm,Bb);c.addEventListener(xm,h),c.dispatchEvent(k),k.defaultPrevented||(p5(v5(ij(c)),{select:!0}),document.activeElement===j&&Ri(c))}return()=>{c.removeEventListener(xm,h),setTimeout(()=>{const k=new CustomEvent(ym,Bb);c.addEventListener(ym,f),c.dispatchEvent(k),k.defaultPrevented||Ri(j??document.body,{select:!0}),c.removeEventListener(ym,f),Hb.remove(y)},0)}}},[c,h,f,y]);const v=b.useCallback(j=>{if(!n&&!r||y.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,k=document.activeElement;if(w&&k){const E=j.currentTarget,[C,M]=m5(E);C&&M?!j.shiftKey&&k===M?(j.preventDefault(),n&&Ri(C,{select:!0})):j.shiftKey&&k===C&&(j.preventDefault(),n&&Ri(M,{select:!0})):k===E&&j.preventDefault()}},[n,r,y.paused]);return i.jsx(ot.div,{tabIndex:-1,...o,ref:g,onKeyDown:v})});Tx.displayName=f5;function p5(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ri(r,{select:e}),document.activeElement!==n)return}function m5(t){const e=ij(t),n=Vb(e,t),r=Vb(e.reverse(),t);return[n,r]}function ij(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Vb(t,e){for(const n of t)if(!g5(n,{upTo:e}))return n}function g5(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function x5(t){return t instanceof HTMLInputElement&&"select"in t}function Ri(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&x5(t)&&e&&t.select()}}var Hb=y5();function y5(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Wb(t,e),t.unshift(e)},remove(e){var n;t=Wb(t,e),(n=t[0])==null||n.resume()}}}function Wb(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function v5(t){return t.filter(e=>e.tagName!=="A")}var b5="Portal",Mx=b.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[s,a]=b.useState(!1);Vn(()=>a(!0),[]);const o=n||s&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?vN.createPortal(i.jsx(ot.div,{...r,ref:e}),o):null});Mx.displayName=b5;function w5(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var Bc=t=>{const{present:e,children:n}=t,r=N5(e),s=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=mt(r.ref,j5(s));return typeof n=="function"||r.isPresent?b.cloneElement(s,{ref:a}):null};Bc.displayName="Presence";function N5(t){const[e,n]=b.useState(),r=b.useRef(null),s=b.useRef(t),a=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=w5(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=ou(r.current);a.current=c==="mounted"?h:"none"},[c]),Vn(()=>{const h=r.current,f=s.current;if(f!==t){const g=a.current,y=ou(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,u]),Vn(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=ou(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!s.current)){const w=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=w)})}},g=y=>{y.target===e&&(a.current=ou(r.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{f.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:b.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function ou(t){return(t==null?void 0:t.animationName)||"none"}function j5(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var vm=0;function aj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Ub()),document.body.insertAdjacentElement("beforeend",t[1]??Ub()),vm++,()=>{vm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),vm--}},[])}function Ub(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var vs=function(){return vs=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},vs.apply(this,arguments)};function oj(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function k5(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,a;r<s;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))}var Au="right-scroll-bar-position",Ru="width-before-scroll-bar",S5="with-scroll-bars-hidden",C5="--removed-body-scroll-bar-size";function bm(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function E5(t,e){var n=b.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=e,n.facade}var T5=typeof window<"u"?b.useLayoutEffect:b.useEffect,Kb=new WeakMap;function M5(t,e){var n=E5(null,function(r){return t.forEach(function(s){return bm(s,r)})});return T5(function(){var r=Kb.get(n);if(r){var s=new Set(r),a=new Set(t),o=n.current;s.forEach(function(c){a.has(c)||bm(c,null)}),a.forEach(function(c){s.has(c)||bm(c,o)})}Kb.set(n,t)},[t]),n}function A5(t){return t}function R5(t,e){e===void 0&&(e=A5);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(a){var o=e(a,r);return n.push(o),function(){n=n.filter(function(c){return c!==o})}},assignSyncMedium:function(a){for(r=!0;n.length;){var o=n;n=[],o.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var o=[];if(n.length){var c=n;n=[],c.forEach(a),o=n}var u=function(){var f=o;o=[],f.forEach(a)},h=function(){return Promise.resolve().then(u)};h(),n={push:function(f){o.push(f),h()},filter:function(f){return o=o.filter(f),n}}}};return s}function I5(t){t===void 0&&(t={});var e=R5(null);return e.options=vs({async:!0,ssr:!1},t),e}var lj=function(t){var e=t.sideCar,n=oj(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,vs({},n))};lj.isSideCarExport=!0;function P5(t,e){return t.useMedium(e),lj}var cj=I5(),wm=function(){},Kh=b.forwardRef(function(t,e){var n=b.useRef(null),r=b.useState({onScrollCapture:wm,onWheelCapture:wm,onTouchMoveCapture:wm}),s=r[0],a=r[1],o=t.forwardProps,c=t.children,u=t.className,h=t.removeScrollBar,f=t.enabled,m=t.shards,g=t.sideCar,y=t.noRelative,v=t.noIsolation,j=t.inert,w=t.allowPinchZoom,k=t.as,E=k===void 0?"div":k,C=t.gapMode,M=oj(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=g,F=M5([n,e]),R=vs(vs({},M),s);return b.createElement(b.Fragment,null,f&&b.createElement(D,{sideCar:cj,removeScrollBar:h,shards:m,noRelative:y,noIsolation:v,inert:j,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:C}),o?b.cloneElement(b.Children.only(c),vs(vs({},R),{ref:F})):b.createElement(E,vs({},R,{className:u,ref:F}),c))});Kh.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Kh.classNames={fullWidth:Ru,zeroRight:Au};var O5=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function D5(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=O5();return e&&t.setAttribute("nonce",e),t}function L5(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function _5(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var z5=function(){var t=0,e=null;return{add:function(n){t==0&&(e=D5())&&(L5(e,n),_5(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},$5=function(){var t=z5();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},dj=function(){var t=$5(),e=function(n){var r=n.styles,s=n.dynamic;return t(r,s),null};return e},F5={left:0,top:0,right:0,gap:0},Nm=function(t){return parseInt(t||"",10)||0},B5=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[Nm(n),Nm(r),Nm(s)]},V5=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return F5;var e=B5(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},H5=dj(),Uo="data-scroll-locked",W5=function(t,e,n,r){var s=t.left,a=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),`
.`.concat(S5,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(c,"px ").concat(r,`;
}
body[`).concat(Uo,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(s,`px;
padding-top: `).concat(a,`px;
padding-right: `).concat(o,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(c,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(Au,` {
right: `).concat(c,"px ").concat(r,`;
}
.`).concat(Ru,` {
margin-right: `).concat(c,"px ").concat(r,`;
}
.`).concat(Au," .").concat(Au,` {
right: 0 `).concat(r,`;
}
.`).concat(Ru," .").concat(Ru,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(Uo,`] {
`).concat(C5,": ").concat(c,`px;
}
`)},qb=function(){var t=parseInt(document.body.getAttribute(Uo)||"0",10);return isFinite(t)?t:0},U5=function(){b.useEffect(function(){return document.body.setAttribute(Uo,(qb()+1).toString()),function(){var t=qb()-1;t<=0?document.body.removeAttribute(Uo):document.body.setAttribute(Uo,t.toString())}},[])},K5=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,s=r===void 0?"margin":r;U5();var a=b.useMemo(function(){return V5(s)},[s]);return b.createElement(H5,{styles:W5(a,!e,s,n?"":"!important")})},wg=!1;if(typeof window<"u")try{var lu=Object.defineProperty({},"passive",{get:function(){return wg=!0,!0}});window.addEventListener("test",lu,lu),window.removeEventListener("test",lu,lu)}catch{wg=!1}var Ao=wg?{passive:!1}:!1,q5=function(t){return t.tagName==="TEXTAREA"},uj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!q5(t)&&n[e]==="visible")},G5=function(t){return uj(t,"overflowY")},J5=function(t){return uj(t,"overflowX")},Gb=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=hj(t,r);if(s){var a=fj(t,r),o=a[1],c=a[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Y5=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},Q5=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},hj=function(t,e){return t==="v"?G5(e):J5(e)},fj=function(t,e){return t==="v"?Y5(e):Q5(e)},X5=function(t,e){return t==="h"&&e==="rtl"?-1:1},Z5=function(t,e,n,r,s){var a=X5(t,window.getComputedStyle(e).direction),o=a*r,c=n.target,u=e.contains(c),h=!1,f=o>0,m=0,g=0;do{if(!c)break;var y=fj(t,c),v=y[0],j=y[1],w=y[2],k=j-w-a*v;(v||k)&&hj(t,c)&&(m+=k,g+=v);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&c!==document.body||u&&(e.contains(c)||e===c));return(f&&Math.abs(m)<1||!f&&Math.abs(g)<1)&&(h=!0),h},cu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Jb=function(t){return[t.deltaX,t.deltaY]},Yb=function(t){return t&&"current"in t?t.current:t},eI=function(t,e){return t[0]===e[0]&&t[1]===e[1]},tI=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},nI=0,Ro=[];function rI(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),s=b.useState(nI++)[0],a=b.useState(dj)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var j=k5([t.lockRef.current],(t.shards||[]).map(Yb),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var k=cu(j),E=n.current,C="deltaX"in j?j.deltaX:E[0]-k[0],M="deltaY"in j?j.deltaY:E[1]-k[1],D,F=j.target,R=Math.abs(C)>Math.abs(M)?"h":"v";if("touches"in j&&R==="h"&&F.type==="range")return!1;var I=window.getSelection(),A=I&&I.anchorNode,O=A?A===F||A.contains(F):!1;if(O)return!1;var W=Gb(R,F);if(!W)return!0;if(W?D=R:(D=R==="v"?"h":"v",W=Gb(R,F)),!W)return!1;if(!r.current&&"changedTouches"in j&&(C||M)&&(r.current=D),!D)return!0;var X=r.current||D;return Z5(X,w,j,X==="h"?C:M)},[]),u=b.useCallback(function(j){var w=j;if(!(!Ro.length||Ro[Ro.length-1]!==a)){var k="deltaY"in w?Jb(w):cu(w),E=e.current.filter(function(D){return D.name===w.type&&(D.target===w.target||w.target===D.shadowParent)&&eI(D.delta,k)})[0];if(E&&E.should){w.cancelable&&w.preventDefault();return}if(!E){var C=(o.current.shards||[]).map(Yb).filter(Boolean).filter(function(D){return D.contains(w.target)}),M=C.length>0?c(w,C[0]):!o.current.noIsolation;M&&w.cancelable&&w.preventDefault()}}},[]),h=b.useCallback(function(j,w,k,E){var C={name:j,delta:w,target:k,should:E,shadowParent:sI(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(M){return M!==C})},1)},[]),f=b.useCallback(function(j){n.current=cu(j),r.current=void 0},[]),m=b.useCallback(function(j){h(j.type,Jb(j),j.target,c(j,t.lockRef.current))},[]),g=b.useCallback(function(j){h(j.type,cu(j),j.target,c(j,t.lockRef.current))},[]);b.useEffect(function(){return Ro.push(a),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Ao),document.addEventListener("touchmove",u,Ao),document.addEventListener("touchstart",f,Ao),function(){Ro=Ro.filter(function(j){return j!==a}),document.removeEventListener("wheel",u,Ao),document.removeEventListener("touchmove",u,Ao),document.removeEventListener("touchstart",f,Ao)}},[]);var y=t.removeScrollBar,v=t.inert;return b.createElement(b.Fragment,null,v?b.createElement(a,{styles:tI(s)}):null,y?b.createElement(K5,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function sI(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const iI=P5(cj,rI);var Ax=b.forwardRef(function(t,e){return b.createElement(Kh,vs({},t,{ref:e,sideCar:iI}))});Ax.classNames=Kh.classNames;var aI=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Io=new WeakMap,du=new WeakMap,uu={},jm=0,pj=function(t){return t&&(t.host||pj(t.parentNode))},oI=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=pj(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},lI=function(t,e,n,r){var s=oI(e,Array.isArray(t)?t:[t]);uu[n]||(uu[n]=new WeakMap);var a=uu[n],o=[],c=new Set,u=new Set(s),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};s.forEach(h);var f=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(c.has(g))f(g);else try{var y=g.getAttribute(r),v=y!==null&&y!=="false",j=(Io.get(g)||0)+1,w=(a.get(g)||0)+1;Io.set(g,j),a.set(g,w),o.push(g),j===1&&v&&du.set(g,!0),w===1&&g.setAttribute(n,"true"),v||g.setAttribute(r,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return f(e),c.clear(),jm++,function(){o.forEach(function(m){var g=Io.get(m)-1,y=a.get(m)-1;Io.set(m,g),a.set(m,y),g||(du.has(m)||m.removeAttribute(r),du.delete(m)),y||m.removeAttribute(n)}),jm--,jm||(Io=new WeakMap,Io=new WeakMap,du=new WeakMap,uu={})}},mj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),s=aI(t);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),lI(r,s,n,"aria-hidden")):function(){return null}},qh="Dialog",[gj]=ia(qh),[cI,ns]=gj(qh),xj=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=Ba({prop:r,defaultProp:s??!1,onChange:a,caller:qh});return i.jsx(cI,{scope:e,triggerRef:c,contentRef:u,contentId:Ki(),titleId:Ki(),descriptionId:Ki(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};xj.displayName=qh;var yj="DialogTrigger",dI=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=ns(yj,n),a=mt(e,s.triggerRef);return i.jsx(ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Px(s.open),...r,ref:a,onClick:nt(t.onClick,s.onOpenToggle)})});dI.displayName=yj;var Rx="DialogPortal",[uI,vj]=gj(Rx,{forceMount:void 0}),bj=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:s}=t,a=ns(Rx,e);return i.jsx(uI,{scope:e,forceMount:n,children:b.Children.map(r,o=>i.jsx(Bc,{present:n||a.open,children:i.jsx(Mx,{asChild:!0,container:s,children:o})}))})};bj.displayName=Rx;var Ku="DialogOverlay",wj=b.forwardRef((t,e)=>{const n=vj(Ku,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,a=ns(Ku,t.__scopeDialog);return a.modal?i.jsx(Bc,{present:r||a.open,children:i.jsx(fI,{...s,ref:e})}):null});wj.displayName=Ku;var hI=Sc("DialogOverlay.RemoveScroll"),fI=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=ns(Ku,n);return i.jsx(Ax,{as:hI,allowPinchZoom:!0,shards:[s.contentRef],children:i.jsx(ot.div,{"data-state":Px(s.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Va="DialogContent",Nj=b.forwardRef((t,e)=>{const n=vj(Va,t.__scopeDialog),{forceMount:r=n.forceMount,...s}=t,a=ns(Va,t.__scopeDialog);return i.jsx(Bc,{present:r||a.open,children:a.modal?i.jsx(pI,{...s,ref:e}):i.jsx(mI,{...s,ref:e})})});Nj.displayName=Va;var pI=b.forwardRef((t,e)=>{const n=ns(Va,t.__scopeDialog),r=b.useRef(null),s=mt(e,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return mj(a)},[]),i.jsx(jj,{...t,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:nt(t.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:nt(t.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&a.preventDefault()}),onFocusOutside:nt(t.onFocusOutside,a=>a.preventDefault())})}),mI=b.forwardRef((t,e)=>{const n=ns(Va,t.__scopeDialog),r=b.useRef(!1),s=b.useRef(!1);return i.jsx(jj,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=a.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),jj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,c=ns(Va,n),u=b.useRef(null),h=mt(e,u);return aj(),i.jsxs(i.Fragment,{children:[i.jsx(Tx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:i.jsx(Ex,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Px(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(gI,{titleId:c.titleId}),i.jsx(yI,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Ix="DialogTitle",kj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=ns(Ix,n);return i.jsx(ot.h2,{id:s.titleId,...r,ref:e})});kj.displayName=Ix;var Sj="DialogDescription",Cj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=ns(Sj,n);return i.jsx(ot.p,{id:s.descriptionId,...r,ref:e})});Cj.displayName=Sj;var Ej="DialogClose",Tj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,s=ns(Ej,n);return i.jsx(ot.button,{type:"button",...r,ref:e,onClick:nt(t.onClick,()=>s.onOpenChange(!1))})});Tj.displayName=Ej;function Px(t){return t?"open":"closed"}var Mj="DialogTitleWarning",[SV,Aj]=UR(Mj,{contentName:Va,titleName:Ix,docsSlug:"dialog"}),gI=({titleId:t})=>{const e=Aj(Mj),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},xI="DialogDescriptionWarning",yI=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Aj(xI).contentName}}.`;return b.useEffect(()=>{var a;const s=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},vI=xj,bI=bj,wI=wj,NI=Nj,jI=kj,kI=Cj,SI=Tj;function Qt(t){return i.jsx(vI,{"data-slot":"dialog",...t})}function CI(t){return i.jsx(bI,{...t})}const Rj=b.forwardRef(({className:t,...e},n)=>i.jsx(wI,{ref:n,className:gt("fixed inset-0 z-50 bg-black/50",t),...e}));Rj.displayName="DialogOverlay";const Ut=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},s)=>i.jsxs(CI,{children:[i.jsx(Rj,{}),i.jsxs(NI,{ref:s,"aria-describedby":void 0,className:gt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border bg-background p-6 shadow-lg sm:max-w-lg",t),...r,children:[e,n&&i.jsxs(SI,{className:"absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[i.jsx(er,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ut.displayName="DialogContent";function Xt({className:t,...e}){return i.jsx("div",{className:gt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function bn({className:t,...e}){return i.jsx("div",{className:gt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Zt(t){return i.jsx(jI,{className:"text-lg font-semibold leading-none",...t})}function EI(t){return i.jsx(kI,{className:"text-sm text-muted-foreground",...t})}const TI=WN("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Fe({className:t,variant:e,asChild:n=!1,...r}){const s=n?BN:"span";return i.jsx(s,{className:gt(TI({variant:e}),t),...r})}var MI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],AI=MI.reduce((t,e)=>{const n=FN(`Primitive.${e}`),r=b.forwardRef((s,a)=>{const{asChild:o,...c}=s,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),RI="Label",Ij=b.forwardRef((t,e)=>i.jsx(AI.label,{...t,ref:e,onMouseDown:n=>{var s;n.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Ij.displayName=RI;var Pj=Ij;const te=b.forwardRef(({className:t,...e},n)=>i.jsx(Pj,{ref:n,className:gt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));te.displayName=Pj.displayName;function Ox(t){const e=t+"CollectionProvider",[n,r]=ia(e),[s,a]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:w,children:k}=j,E=Zn.useRef(null),C=Zn.useRef(new Map).current;return i.jsx(s,{scope:w,itemMap:C,collectionRef:E,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Sc(c),h=Zn.forwardRef((j,w)=>{const{scope:k,children:E}=j,C=a(c,k),M=mt(w,C.collectionRef);return i.jsx(u,{ref:M,children:E})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Sc(f),y=Zn.forwardRef((j,w)=>{const{scope:k,children:E,...C}=j,M=Zn.useRef(null),D=mt(w,M),F=a(f,k);return Zn.useEffect(()=>(F.itemMap.set(M,{ref:M,...C}),()=>void F.itemMap.delete(M))),i.jsx(g,{[m]:"",ref:D,children:E})});y.displayName=f;function v(j){const w=a(t+"CollectionConsumer",j);return Zn.useCallback(()=>{const E=w.collectionRef.current;if(!E)return[];const C=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(w.itemMap.values()).sort((F,R)=>C.indexOf(F.ref.current)-C.indexOf(R.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},v,r]}var II=b.createContext(void 0);function Gh(t){const e=b.useContext(II);return t||e||"ltr"}var km="rovingFocusGroup.onEntryFocus",PI={bubbles:!1,cancelable:!0},Vc="RovingFocusGroup",[Ng,Oj,OI]=Ox(Vc),[DI,Dj]=ia(Vc,[OI]),[LI,_I]=DI(Vc),Lj=b.forwardRef((t,e)=>i.jsx(Ng.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(Ng.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(zI,{...t,ref:e})})}));Lj.displayName=Vc;var zI=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=mt(e,g),v=Gh(a),[j,w]=Ba({prop:o,defaultProp:c??null,onChange:u,caller:Vc}),[k,E]=b.useState(!1),C=Qi(h),M=Oj(n),D=b.useRef(!1),[F,R]=b.useState(0);return b.useEffect(()=>{const I=g.current;if(I)return I.addEventListener(km,C),()=>I.removeEventListener(km,C)},[C]),i.jsx(LI,{scope:n,orientation:r,dir:v,loop:s,currentTabStopId:j,onItemFocus:b.useCallback(I=>w(I),[w]),onItemShiftTab:b.useCallback(()=>E(!0),[]),onFocusableItemAdd:b.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:b.useCallback(()=>R(I=>I-1),[]),children:i.jsx(ot.div,{tabIndex:k||F===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:nt(t.onMouseDown,()=>{D.current=!0}),onFocus:nt(t.onFocus,I=>{const A=!D.current;if(I.target===I.currentTarget&&A&&!k){const O=new CustomEvent(km,PI);if(I.currentTarget.dispatchEvent(O),!O.defaultPrevented){const W=M().filter($=>$.focusable),X=W.find($=>$.active),q=W.find($=>$.id===j),_=[X,q,...W].filter(Boolean).map($=>$.ref.current);$j(_,f)}}D.current=!1}),onBlur:nt(t.onBlur,()=>E(!1))})})}),_j="RovingFocusGroupItem",zj=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:o,...c}=t,u=Ki(),h=a||u,f=_I(_j,n),m=f.currentTabStopId===h,g=Oj(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:j}=f;return b.useEffect(()=>{if(r)return y(),()=>v()},[r,y,v]),i.jsx(Ng.ItemSlot,{scope:n,id:h,focusable:r,active:s,children:i.jsx(ot.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:nt(t.onMouseDown,w=>{r?f.onItemFocus(h):w.preventDefault()}),onFocus:nt(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:nt(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=BI(w,f.orientation,f.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=g().filter(M=>M.focusable).map(M=>M.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const M=C.indexOf(w.currentTarget);C=f.loop?VI(C,M+1):C.slice(M+1)}setTimeout(()=>$j(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});zj.displayName=_j;var $I={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function FI(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function BI(t,e,n){const r=FI(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return $I[r]}function $j(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function VI(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var HI=Lj,WI=zj,Jh="Tabs",[UI]=ia(Jh,[Dj]),Fj=Dj(),[KI,Dx]=UI(Jh),Bj=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:s,defaultValue:a,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Gh(c),[m,g]=Ba({prop:r,onChange:s,defaultProp:a??"",caller:Jh});return i.jsx(KI,{scope:n,baseId:Ki(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:i.jsx(ot.div,{dir:f,"data-orientation":o,...h,ref:e})})});Bj.displayName=Jh;var Vj="TabsList",Hj=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...s}=t,a=Dx(Vj,n),o=Fj(n);return i.jsx(HI,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:i.jsx(ot.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:e})})});Hj.displayName=Vj;var Wj="TabsTrigger",Uj=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:s=!1,...a}=t,o=Dx(Wj,n),c=Fj(n),u=Gj(o.baseId,r),h=Jj(o.baseId,r),f=r===o.value;return i.jsx(WI,{asChild:!0,...c,focusable:!s,active:f,children:i.jsx(ot.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:u,...a,ref:e,onMouseDown:nt(t.onMouseDown,m=>{!s&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:nt(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:nt(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!s&&m&&o.onValueChange(r)})})})});Uj.displayName=Wj;var Kj="TabsContent",qj=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:s,children:a,...o}=t,c=Dx(Kj,n),u=Gj(c.baseId,r),h=Jj(c.baseId,r),f=r===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),i.jsx(Bc,{present:s||f,children:({present:g})=>i.jsx(ot.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&a})})});qj.displayName=Kj;function Gj(t,e){return`${t}-trigger-${e}`}function Jj(t,e){return`${t}-content-${e}`}var qI=Bj,Yj=Hj,Qj=Uj,Xj=qj;const Hc=qI,cl=b.forwardRef(({className:t,...e},n)=>i.jsx(Yj,{ref:n,className:gt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));cl.displayName=Yj.displayName;const en=b.forwardRef(({className:t,...e},n)=>i.jsx(Qj,{ref:n,className:gt("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",t),...e}));en.displayName=Qj.displayName;const tn=b.forwardRef(({className:t,...e},n)=>i.jsx(Xj,{ref:n,className:gt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));tn.displayName=Xj.displayName;function Lx(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function _x(t){const[e,n]=b.useState(void 0);return Vn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let o,c;if("borderBoxSize"in a){const u=a.borderBoxSize,h=Array.isArray(u)?u[0]:u;o=h.inlineSize,c=h.blockSize}else o=t.offsetWidth,c=t.offsetHeight;n({width:o,height:c})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Yh="Switch",[GI]=ia(Yh),[JI,YI]=GI(Yh),Zj=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:a,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),v=mt(e,C=>y(C)),j=b.useRef(!1),w=g?f||!!g.closest("form"):!0,[k,E]=Ba({prop:s,defaultProp:a??!1,onChange:h,caller:Yh});return i.jsxs(JI,{scope:n,checked:k,disabled:c,children:[i.jsx(ot.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":rk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:v,onClick:nt(t.onClick,C=>{E(M=>!M),w&&(j.current=C.isPropagationStopped(),j.current||C.stopPropagation())})}),w&&i.jsx(nk,{control:g,bubbles:!j.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});Zj.displayName=Yh;var ek="SwitchThumb",tk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,s=YI(ek,n);return i.jsx(ot.span,{"data-state":rk(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:e})});tk.displayName=ek;var QI="SwitchBubbleInput",nk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...s},a)=>{const o=b.useRef(null),c=mt(o,a),u=Lx(n),h=_x(e);return b.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const v=new Event("click",{bubbles:r});y.call(f,n),f.dispatchEvent(v)}},[u,n,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:c,style:{...s.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});nk.displayName=QI;function rk(t){return t?"checked":"unchecked"}var sk=Zj,XI=tk;const yt=b.forwardRef(({className:t,...e},n)=>i.jsx(sk,{className:gt("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0a1628] disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-gray-600 data-[state=checked]:bg-[#38bdac]",t),...e,ref:n,children:i.jsx(XI,{className:gt("pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));yt.displayName=sk.displayName;function zx({open:t,onClose:e,userId:n,onUserUpdated:r}){var Gn;const[s,a]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[v,j]=b.useState(!1),[w,k]=b.useState("info"),[E,C]=b.useState(""),[M,D]=b.useState(""),[F,R]=b.useState([]),[I,A]=b.useState(""),[O,W]=b.useState(""),[X,q]=b.useState(""),[Z,_]=b.useState(!1),[$,oe]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[V,ae]=b.useState([]),[Y,L]=b.useState(!1),[H,ue]=b.useState(!1),[U,he]=b.useState(null),[Q,ee]=b.useState(null),[de,Ce]=b.useState(""),[B,me]=b.useState(""),[Se,rt]=b.useState(""),[Ye,st]=b.useState(!1),[Qe,Xe]=b.useState(null),[ft,Pt]=b.useState("");b.useEffect(()=>{t&&n&&(k("info"),he(null),ee(null),Xe(null),Pt(""),W(""),q(""),Jt(),Be("/api/db/vip-roles").then(fe=>{fe!=null&&fe.success&&fe.data&&ae(fe.data)}).catch(()=>{}))},[t,n]);async function Jt(){if(n){m(!0);try{const fe=await Be(`/api/db/users?id=${encodeURIComponent(n)}`);if(fe!=null&&fe.success&&fe.user){const ge=fe.user;a(ge),C(ge.phone||""),D(ge.nickname||""),Ce(ge.phone||""),me(ge.wechatId||""),rt(ge.openId||"");try{R(typeof ge.tags=="string"?JSON.parse(ge.tags||"[]"):[])}catch{R([])}oe({isVip:!!(ge.isVip??!1),vipExpireDate:ge.vipExpireDate?String(ge.vipExpireDate).slice(0,10):"",vipRole:String(ge.vipRole??""),vipName:String(ge.vipName??""),vipProject:String(ge.vipProject??""),vipContact:String(ge.vipContact??""),vipBio:String(ge.vipBio??"")})}try{const ge=await Be(`/api/user/track?userId=${encodeURIComponent(n)}&limit=50`);ge!=null&&ge.success&&ge.tracks&&c(ge.tracks)}catch{c([])}try{const ge=await Be(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ge!=null&&ge.success&&ge.referrals&&h(ge.referrals)}catch{h([])}}catch(fe){console.error("Load user detail error:",fe)}finally{m(!1)}}}async function Kn(){if(!(s!=null&&s.phone)){alert("用户未绑定手机号,无法同步");return}y(!0);try{const fe=await ht("/api/ckb/sync",{action:"full_sync",phone:s.phone,userId:s.id});fe!=null&&fe.success?(alert("同步成功"),Jt()):alert("同步失败: "+(fe==null?void 0:fe.error))}catch(fe){console.error("Sync CKB error:",fe),alert("同步失败")}finally{y(!1)}}async function qn(){if(s){j(!0);try{const fe={id:s.id,phone:E||void 0,nickname:M||void 0,tags:JSON.stringify(F)},ge=await Rt("/api/db/users",fe);ge!=null&&ge.success?(alert("保存成功"),Jt(),r==null||r()):alert("保存失败: "+(ge==null?void 0:ge.error))}catch(fe){console.error("Save user error:",fe),alert("保存失败")}finally{j(!1)}}}const ss=()=>{I&&!F.includes(I)&&(R([...F,I]),A(""))},zt=fe=>R(F.filter(ge=>ge!==fe));async function Cr(){if(s){if(!O){alert("请输入新密码");return}if(O!==X){alert("两次密码不一致");return}if(O.length<6){alert("密码至少 6 位");return}_(!0);try{const fe=await Rt("/api/db/users",{id:s.id,password:O});fe!=null&&fe.success?(alert("修改成功"),W(""),q("")):alert("修改失败: "+((fe==null?void 0:fe.error)||""))}catch{alert("修改失败")}finally{_(!1)}}}async function is(){if(s){if($.isVip&&!$.vipExpireDate.trim()){alert("开启 VIP 请填写有效到期日");return}L(!0);try{const fe={id:s.id,isVip:$.isVip,vipExpireDate:$.isVip?$.vipExpireDate:void 0,vipRole:$.vipRole||void 0,vipName:$.vipName||void 0,vipProject:$.vipProject||void 0,vipContact:$.vipContact||void 0,vipBio:$.vipBio||void 0},ge=await Rt("/api/db/users",fe);ge!=null&&ge.success?(alert("VIP 设置已保存"),Jt(),r==null||r()):alert("保存失败: "+((ge==null?void 0:ge.error)||""))}catch{alert("保存失败")}finally{L(!1)}}}async function On(){if(!de&&!Se&&!B){ee("请至少输入手机号、微信号或 OpenID 中的一项");return}ue(!0),ee(null),he(null);try{const fe=new URLSearchParams;de&&fe.set("phone",de),Se&&fe.set("openId",Se),B&&fe.set("wechatId",B);const ge=await Be(`/api/admin/shensheshou/query?${fe}`);ge!=null&&ge.success&&ge.data?(he(ge.data),s&&await pn(ge.data)):ee((ge==null?void 0:ge.error)||"未查询到数据,该用户可能未在神射手收录")}catch(fe){console.error("SSS query error:",fe),ee("请求失败,请检查神射手接口配置")}finally{ue(!1)}}async function pn(fe){if(s)try{await ht("/api/admin/shensheshou/enrich",{userId:s.id,phone:de||s.phone||"",openId:Se||s.openId||"",wechatId:B||s.wechatId||""}),Jt()}catch(ge){console.error("SSS enrich error:",ge)}}async function mr(){if(s){st(!0),Xe(null);try{const fe={users:[{phone:s.phone||"",name:s.nickname||"",openId:s.openId||"",tags:F}]},ge=await ht("/api/admin/shensheshou/ingest",fe);ge!=null&&ge.success&&ge.data?Xe(ge.data):Xe({error:(ge==null?void 0:ge.error)||"推送失败"})}catch(fe){console.error("SSS ingest error:",fe),Xe({error:"请求失败"})}finally{st(!1)}}}const Br=fe=>{const Sn={view_chapter:zr,purchase:xg,match:Nn,login:Wo,register:Wo,share:Gs,bind_phone:nA,bind_wechat:KM,fill_profile:pm,visit_page:Bo}[fe]||fg;return i.jsx(Sn,{className:"w-4 h-4"})};return t?i.jsx(Qt,{open:t,onOpenChange:()=>e(),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(Wo,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(s==null?void 0:s.phone)&&i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(s==null?void 0:s.isVip)&&i.jsx(Fe,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),f?i.jsxs("div",{className:"flex items-center justify-center py-20",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s?i.jsxs("div",{className:"flex flex-col h-[75vh]",children:[i.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[i.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:s.avatar?i.jsx("img",{src:s.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Gn=s.nickname)==null?void 0:Gn.charAt(0))||"?"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("h3",{className:"text-lg font-bold text-white",children:s.nickname}),s.isAdmin&&i.jsx(Fe,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),s.hasFullBook&&i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),s.vipRole&&i.jsx(Fe,{className:"bg-amber-500/20 text-amber-400 border-0",children:s.vipRole})]}),i.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[s.phone?`📱 ${s.phone}`:"未绑定手机",s.wechatId&&` · 💬 ${s.wechatId}`,s.mbti&&` · ${s.mbti}`]}),i.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[i.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",s.id.slice(0,16),"…"]}),s.referralCode&&i.jsxs("p",{className:"text-xs",children:[i.jsx("span",{className:"text-gray-500",children:"推广码:"}),i.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:s.referralCode})]})]})]}),i.jsxs("div",{className:"text-right shrink-0",children:[i.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(s.earnings||0).toFixed(2)]}),i.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),i.jsxs(Hc,{value:w,onValueChange:k,className:"flex-1 flex flex-col overflow-hidden",children:[i.jsxs(cl,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[i.jsx(en,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),i.jsx(en,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),i.jsxs(en,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[i.jsx(Bo,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),i.jsx(en,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),i.jsxs(en,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[i.jsx(Fi,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),i.jsxs(tn,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"手机号"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:E,onChange:fe=>C(fe.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"昵称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:M,onChange:fe=>D(fe.target.value)})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.openId&&i.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),i.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:s.openId})]}),s.region&&i.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[i.jsx(_N,{className:"w-4 h-4 text-gray-500"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),i.jsx("p",{className:"text-white",children:s.region})]})]}),s.industry&&i.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),i.jsx("p",{className:"text-white",children:s.industry})]}),s.position&&i.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),i.jsx("p",{className:"text-white",children:s.position})]})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),i.jsx("p",{className:"text-2xl font-bold text-white",children:s.referralCount??0})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),i.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(s.pendingEarnings??0).toFixed(2)]})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),i.jsx("p",{className:"text-sm text-white",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"-"})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(MM,{className:"w-4 h-4 text-yellow-400"}),i.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码至少6位",value:O,onChange:fe=>W(fe.target.value)}),i.jsx(ce,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:X,onChange:fe=>q(fe.target.value)}),i.jsx(re,{size:"sm",onClick:Cr,disabled:Z||!O||!X,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:Z?"保存中...":"确认修改"})]})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Aa,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(te,{className:"text-gray-400 text-sm",children:"VIP 会员"}),i.jsx(yt,{checked:$.isVip,onCheckedChange:fe=>oe(ge=>({...ge,isVip:fe}))})]}),$.isVip&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"到期日"}),i.jsx(ce,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:$.vipExpireDate,onChange:fe=>oe(ge=>({...ge,vipExpireDate:fe.target.value}))})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"角色"}),i.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:$.vipRole,onChange:fe=>oe(ge=>({...ge,vipRole:fe.target.value})),children:[i.jsx("option",{value:"",children:"请选择"}),V.map(fe=>i.jsx("option",{value:fe.name,children:fe.name},fe.id))]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"展示名"}),i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:$.vipName,onChange:fe=>oe(ge=>({...ge,vipName:fe.target.value}))})]}),i.jsx(re,{size:"sm",onClick:is,disabled:Y,className:"bg-amber-500/20 hover:bg-amber-500/30 text-amber-400 border border-amber-500/40",children:Y?"保存中...":"保存 VIP"})]})]})]}),s.isVip&&i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Aa,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),i.jsx(Fe,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:s.vipRole||"VIP"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.vipName&&i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"展示名:"}),i.jsx("span",{className:"text-white",children:s.vipName})]}),s.vipProject&&i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"项目:"}),i.jsx("span",{className:"text-white",children:s.vipProject})]}),s.vipContact&&i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"联系方式:"}),i.jsx("span",{className:"text-white",children:s.vipContact})]}),s.vipExpireDate&&i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"到期时间:"}),i.jsx("span",{className:"text-white",children:new Date(s.vipExpireDate).toLocaleDateString()})]})]}),s.vipBio&&i.jsx("p",{className:"text-gray-400 text-sm mt-2",children:s.vipBio})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(kc,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"text-white font-medium",children:"微信归属"}),i.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx",value:ft,onChange:fe=>Pt(fe.target.value)}),i.jsxs(re,{size:"sm",onClick:async()=>{if(!(!ft||!s))try{await Rt("/api/db/users",{id:s.id,wechatId:ft}),alert("已保存微信归属"),Jt()}catch{alert("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[i.jsx(rn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),s.wechatId&&i.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",i.jsx("span",{className:"text-purple-400",children:s.wechatId})]})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Gs,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),i.jsx(re,{size:"sm",onClick:Kn,disabled:g||!s.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"同步状态:"}),s.ckbSyncedAt?i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):i.jsx(Fe,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"最后同步:"}),i.jsx("span",{className:"text-gray-300 ml-1",children:s.ckbSyncedAt?new Date(s.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),i.jsxs(tn,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(pm,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx("span",{className:"text-white font-medium",children:"用户标签"}),i.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),i.jsxs("div",{className:"mb-3 p-2.5 bg-[#38bdac]/5 border border-[#38bdac]/20 rounded-lg flex items-center gap-2 text-xs text-gray-400",children:[i.jsx(hg,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),i.jsx("div",{className:"mb-4 space-y-3",children:[{category:"身份类型",tags:["创业者","打工人","自由职业","学生","投资人","合伙人"]},{category:"行业背景",tags:["电商","内容","传统行业","科技/AI","金融","教育","餐饮"]},{category:"痛点标签",tags:["找资源","找方向","找合伙人","想赚钱","想学习","找情感出口"]},{category:"付费意愿",tags:["高意向","已付费","观望中","薅羊毛"]},{category:"MBTI",tags:["ENTJ","INTJ","ENFP","INFP","ENTP","INTP","ESTJ","ISFJ"]}].map(fe=>i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:fe.category}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:fe.tags.map(ge=>i.jsxs("button",{type:"button",onClick:()=>{F.includes(ge)?zt(ge):R([...F,ge])},className:`px-2 py-0.5 rounded text-xs border transition-all ${F.includes(ge)?"bg-[#38bdac]/20 border-[#38bdac]/50 text-[#38bdac]":"bg-transparent border-gray-700 text-gray-500 hover:border-gray-500 hover:text-gray-300"}`,children:[F.includes(ge)?"✓ ":"",ge]},ge))})]},fe.category))}),i.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),i.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[F.map((fe,ge)=>i.jsxs(Fe,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[fe,i.jsx("button",{type:"button",onClick:()=>zt(fe),className:"ml-1 hover:text-red-400",children:i.jsx(er,{className:"w-3 h-3"})})]},ge)),F.length===0&&i.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:I,onChange:fe=>A(fe.target.value),onKeyDown:fe=>fe.key==="Enter"&&ss()}),i.jsx(re,{onClick:ss,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),s.ckbTags&&i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(pm,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:(typeof s.ckbTags=="string"?s.ckbTags.split(","):[]).map((fe,ge)=>i.jsx(Fe,{className:"bg-purple-500/20 text-purple-400 border-0",children:fe.trim()},ge))})]})]}),i.jsxs(tn,{value:"journey",className:"flex-1 overflow-auto",children:[i.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[i.jsx(Bo,{className:"w-4 h-4 text-[#38bdac]"}),i.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),i.jsx("div",{className:"space-y-2",children:o.length>0?o.map((fe,ge)=>i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex flex-col items-center",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Br(fe.action)}),ge<o.length-1&&i.jsx("div",{className:"w-0.5 h-4 bg-gray-700/50 mt-1"})]}),i.jsxs("div",{className:"flex-1 pb-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-white font-medium",children:fe.actionLabel}),fe.chapterTitle&&i.jsxs("span",{className:"text-gray-400 text-sm",children:["- ",fe.chapterTitle]})]}),i.jsxs("p",{className:"text-gray-500 text-xs mt-0.5",children:[i.jsx(fg,{className:"w-3 h-3 inline mr-1"}),fe.timeAgo," · ",new Date(fe.createdAt).toLocaleString()]})]})]},fe.id)):i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Bo,{className:"w-10 h-10 text-[#38bdac]/40 mx-auto mb-4"}),i.jsx("p",{className:"text-gray-400",children:"暂无用户旅程记录"}),i.jsx("p",{className:"text-gray-600 text-sm mt-1",children:"当用户浏览章节、购买或完善信息时会自动记录"})]})})]}),i.jsx(tn,{value:"relations",className:"flex-1 overflow-auto space-y-4",children:i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Gs,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx("span",{className:"text-white font-medium",children:"推荐的用户"})]}),i.jsxs(Fe,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:["共 ",u.length," 人"]})]}),i.jsx("div",{className:"space-y-2 max-h-[250px] overflow-y-auto",children:u.length>0?u.map((fe,ge)=>{var ri;const Sn=fe;return i.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((ri=Sn.nickname)==null?void 0:ri.charAt(0))||"?"}),i.jsx("span",{className:"text-white text-sm",children:Sn.nickname})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[Sn.status==="vip"&&i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),i.jsx("span",{className:"text-gray-500 text-xs",children:Sn.createdAt?new Date(Sn.createdAt).toLocaleDateString():""})]})]},Sn.id||ge)}):i.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),i.jsxs(tn,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Fi,{className:"w-5 h-5 text-[#38bdac]"}),i.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),i.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[i.jsxs("div",{children:[i.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:de,onChange:fe=>Ce(fe.target.value)})]}),i.jsxs("div",{children:[i.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:B,onChange:fe=>me(fe.target.value)})]}),i.jsxs("div",{className:"col-span-2",children:[i.jsx(te,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),i.jsx(ce,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx自动填入",value:Se,onChange:fe=>rt(fe.target.value)})]})]}),i.jsx(re,{onClick:On,disabled:H,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:H?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Ui,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),i.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),Q&&i.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:Q}),U&&i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),i.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:U.rfm_score??"-"})]}),i.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),i.jsx("p",{className:"text-2xl font-bold text-white",children:U.user_level??"-"})]})]}),U.tags&&U.tags.length>0&&i.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[i.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:U.tags.map((fe,ge)=>i.jsx(Fe,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:fe},ge))})]}),U.last_active&&i.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",U.last_active]})]})]}),i.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Fi,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),i.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),i.jsx(re,{onClick:mr,disabled:Ye||!s.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:Ye?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):i.jsxs(i.Fragment,{children:[i.jsx(Fi,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!s.phone&&i.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),Qe&&i.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:Qe.error?i.jsx("p",{className:"text-red-400",children:String(Qe.error)}):i.jsxs("div",{className:"space-y-1",children:[i.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[i.jsx(hg,{className:"w-4 h-4"})," 推送成功"]}),Qe.enriched!==void 0&&i.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(Qe.new_tags_added??0)]})]})})]})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[i.jsxs(re,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"关闭"]}),i.jsxs(re,{onClick:qn,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):i.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}):null}function ZI(){const t=sa(),[e,n]=b.useState(!0),[r,s]=b.useState([]),[a,o]=b.useState([]),[c,u]=b.useState(0),[h,f]=b.useState(0),[m,g]=b.useState(0),[y,v]=b.useState(0),[j,w]=b.useState(null),[k,E]=b.useState(null),[C,M]=b.useState(!1);async function D(){var A;n(!0),w(null);try{try{const ae=await Be("/api/admin/dashboard/overview");if(ae!=null&&ae.success){u(ae.totalUsers??0),f(ae.paidOrderCount??0),g(ae.totalRevenue??0),v(ae.conversionRate??0),o(ae.recentOrders??[]),s(ae.newUsers??[]);return}}catch(ae){console.error("数据概览接口失败,尝试降级拉取",ae)}const[O,W]=await Promise.all([Be("/api/db/users?page=1&pageSize=10"),Be("/api/orders?page=1&pageSize=20&status=paid")]),X=typeof(O==null?void 0:O.total)=="number"?O.total:((A=O==null?void 0:O.users)==null?void 0:A.length)??0,q=(W==null?void 0:W.orders)??[],Z=typeof(W==null?void 0:W.total)=="number"?W.total:q.length,_=q.filter(ae=>ae.status==="paid"||ae.status==="completed"||ae.status==="success"),$=_.reduce((ae,Y)=>ae+Number(Y.amount||0),0),oe=new Set(_.map(ae=>ae.userId).filter(Boolean)),V=X>0&&oe.size>0?oe.size/X*100:0;u(X),f(Z),g($),v(V),o(q.slice(0,5)),s((O==null?void 0:O.users)??[])}catch(O){console.error("降级拉取失败",O);const W=O;(W==null?void 0:W.status)===401?w("登录已过期,请重新登录"):(W==null?void 0:W.name)==="AbortError"?w("请求超时,请检查网络后点击重试"):w("加载失败,请检查网络或联系管理员")}finally{n(!1)}}if(b.useEffect(()=>{D();const A=setInterval(D,3e4);return()=>clearInterval(A)},[]),e)return i.jsxs("div",{className:"p-8 w-full",children:[i.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),i.jsxs("div",{className:"flex flex-col items-center justify-center py-24",children:[i.jsx(qe,{className:"w-12 h-12 text-[#38bdac] animate-spin mb-4"}),i.jsx("span",{className:"text-gray-400",children:"加载中..."})]})]});const F=c,R=A=>{const O=A.productType||"",W=A.description||"";if(W){if(O==="section"&&W.includes("章节")){if(W.includes("-")){const X=W.split("-");if(X.length>=3)return{title:`第${X[1]}章 第${X[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:W,subtitle:"章节购买"}}return O==="fullbook"||W.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:O==="match"||W.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:W,subtitle:O==="section"?"单章":O==="fullbook"?"全书":"其他"}}return O==="section"?{title:`章节 ${A.productId||""}`,subtitle:"单章购买"}:O==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:O==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:O||"其他"}},I=[{title:"总用户数",value:F,icon:Nn,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:`¥${(m??0).toFixed(2)}`,icon:cc,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:h,icon:xg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:`${typeof y=="number"?y.toFixed(1):0}%`,icon:zr,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"}];return i.jsxs("div",{className:"p-8 w-full",children:[i.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),j&&i.jsxs("div",{className:"mb-6 px-4 py-3 rounded-lg bg-amber-500/20 border border-amber-500/50 text-amber-200 text-sm flex items-center justify-between",children:[i.jsx("span",{children:j}),i.jsx("button",{type:"button",onClick:()=>D(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:I.map((A,O)=>i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>A.link&&t(A.link),children:[i.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[i.jsx(tt,{className:"text-sm font-medium text-gray-400",children:A.title}),i.jsx("div",{className:`p-2 rounded-lg ${A.bg}`,children:i.jsx(A.icon,{className:`w-4 h-4 ${A.color}`})})]}),i.jsx(Te,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"text-2xl font-bold text-white",children:A.value}),i.jsx(Fo,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},O))}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between",children:[i.jsx(tt,{className:"text-white",children:"最近订单"}),i.jsxs("button",{type:"button",onClick:()=>D(),className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1",title:"刷新",children:[i.jsx(qe,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),i.jsx(Te,{children:i.jsxs("div",{className:"space-y-3",children:[a.slice(0,5).map(A=>{var Z;const O=A.referrerId?r.find(_=>_.id===A.referrerId):void 0,W=A.referralCode||(O==null?void 0:O.referralCode)||(O==null?void 0:O.nickname)||(A.referrerId?String(A.referrerId).slice(0,8):""),X=R(A),q=A.userNickname||((Z=r.find(_=>_.id===A.userId))==null?void 0:Z.nickname)||"匿名用户";return i.jsxs("div",{className:"flex items-start justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30 hover:border-[#38bdac]/30 transition-colors",children:[i.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[A.userAvatar?i.jsx("img",{src:A.userAvatar,alt:q,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:_=>{_.currentTarget.style.display="none";const $=_.currentTarget.nextElementSibling;$&&$.classList.remove("hidden")}}):null,i.jsx("div",{className:`w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 mt-0.5 ${A.userAvatar?"hidden":""}`,children:q.charAt(0)}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("button",{type:"button",onClick:()=>{A.userId&&(E(A.userId),M(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:q}),i.jsx("span",{className:"text-gray-600",children:"·"}),i.jsx("span",{className:"text-sm font-medium text-white truncate",children:X.title})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[X.subtitle&&X.subtitle!=="章节购买"&&i.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:X.subtitle}),i.jsx("span",{children:new Date(A.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),W&&i.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",W]})]})]}),i.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[i.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(A.amount).toFixed(2)]}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:A.paymentMethod||"微信"})]})]},A.id)}),a.length===0&&i.jsxs("div",{className:"text-center py-12",children:[i.jsx(xg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),i.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"新注册用户"})}),i.jsx(Te,{children:i.jsxs("div",{className:"space-y-3",children:[r.slice(0,5).map(A=>{var O;return i.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((O=A.nickname)==null?void 0:O.charAt(0))||"?"}),i.jsxs("div",{children:[i.jsx("button",{type:"button",onClick:()=>{E(A.id),M(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:A.nickname||"匿名用户"}),i.jsx("p",{className:"text-xs text-gray-500",children:A.phone||"-"})]})]}),i.jsx("p",{className:"text-xs text-gray-400",children:A.createdAt?new Date(A.createdAt).toLocaleDateString():"-"})]},A.id)}),r.length===0&&i.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})]})]}),i.jsx(zx,{open:C,onClose:()=>{M(!1),E(null)},userId:k,onUserUpdated:D})]})}const hr=b.forwardRef(({className:t,...e},n)=>i.jsx("div",{className:"relative w-full overflow-auto",children:i.jsx("table",{ref:n,className:gt("w-full caption-bottom text-sm",t),...e})}));hr.displayName="Table";const fr=b.forwardRef(({className:t,...e},n)=>i.jsx("thead",{ref:n,className:gt("[&_tr]:border-b",t),...e}));fr.displayName="TableHeader";const pr=b.forwardRef(({className:t,...e},n)=>i.jsx("tbody",{ref:n,className:gt("[&_tr:last-child]:border-0",t),...e}));pr.displayName="TableBody";const ct=b.forwardRef(({className:t,...e},n)=>i.jsx("tr",{ref:n,className:gt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));ct.displayName="TableRow";const ke=b.forwardRef(({className:t,...e},n)=>i.jsx("th",{ref:n,className:gt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));ke.displayName="TableHead";const ve=b.forwardRef(({className:t,...e},n)=>i.jsx("td",{ref:n,className:gt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));ve.displayName="TableCell";function $x(t,e){const[n,r]=b.useState(t);return b.useEffect(()=>{const s=setTimeout(()=>r(t),e);return()=>clearTimeout(s)},[t,e]),n}function Zr({page:t,totalPages:e,total:n,pageSize:r,onPageChange:s,onPageSizeChange:a,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!a?null:i.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[i.jsxs("span",{children:["共 ",n," 条"]}),a&&i.jsx("select",{value:r,onChange:c=>a(Number(c.target.value)),className:"bg-[#0f2137] border border-gray-600 rounded px-2 py-1 text-gray-300 text-sm",children:o.map(c=>i.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>s(1),disabled:t<=1,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"首页"}),i.jsx("button",{type:"button",onClick:()=>s(t-1),disabled:t<=1,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"上一页"}),i.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),i.jsx("button",{type:"button",onClick:()=>s(t+1),disabled:t>=e,className:"px-3 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"下一页"}),i.jsx("button",{type:"button",onClick:()=>s(e),disabled:t>=e,className:"px-2 py-1 rounded border border-gray-600 text-gray-400 hover:bg-gray-700/50 disabled:opacity-40 text-sm",children:"末页"})]})]})}function eP(){const[t,e]=b.useState([]),[n,r]=b.useState([]),[s,a]=b.useState(0),[o,c]=b.useState(0),[u,h]=b.useState(0),[f,m]=b.useState(1),[g,y]=b.useState(10),[v,j]=b.useState(""),w=$x(v,300),[k,E]=b.useState("all"),[C,M]=b.useState(!0),[D,F]=b.useState(null),[R,I]=b.useState(null),[A,O]=b.useState(""),[W,X]=b.useState(!1);async function q(){M(!0),F(null);try{const Y=k==="all"?"":k==="completed"?"completed":k,L=new URLSearchParams({page:String(f),pageSize:String(g),...Y&&{status:Y},...w&&{search:w}}),[H,ue]=await Promise.all([Be(`/api/orders?${L}`),Be("/api/db/users?page=1&pageSize=500")]);H!=null&&H.success&&(e(H.orders||[]),a(H.total??0),c(H.totalRevenue??0),h(H.todayRevenue??0)),ue!=null&&ue.success&&ue.users&&r(ue.users)}catch(Y){console.error("加载订单失败",Y),F("加载订单失败,请检查网络后重试")}finally{M(!1)}}b.useEffect(()=>{m(1)},[w,k]),b.useEffect(()=>{q()},[f,g,w,k]);const Z=Y=>{var L;return Y.userNickname||((L=n.find(H=>H.id===Y.userId))==null?void 0:L.nickname)||"匿名用户"},_=Y=>{var L;return((L=n.find(H=>H.id===Y))==null?void 0:L.phone)||"-"},$=Y=>{const L=Y.productType||Y.type||"",H=Y.description||"";if(H){if(L==="section"&&H.includes("章节")){if(H.includes("-")){const ue=H.split("-");if(ue.length>=3)return{name:`第${ue[1]}章 第${ue[2]}节`,type:"《一场Soul的创业实验》"}}return{name:H,type:"章节购买"}}return L==="fullbook"||H.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:L==="vip"||H.includes("VIP")?{name:"VIP年度会员",type:"VIP"}:L==="match"||H.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:H,type:"其他"}}return L==="section"?{name:`章节 ${Y.productId||Y.sectionId||""}`,type:"单章"}:L==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:L==="vip"?{name:"VIP年度会员",type:"VIP"}:L==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:L||"其他"}},oe=Math.ceil(s/g)||1;async function V(){var Y;if(!(!(R!=null&&R.orderSn)&&!(R!=null&&R.id))){X(!0),F(null);try{const L=await Rt("/api/admin/orders/refund",{orderSn:R.orderSn||R.id,reason:A||void 0});L!=null&&L.success?(I(null),O(""),q()):F((L==null?void 0:L.error)||"退款失败")}catch(L){const H=L;F(((Y=H==null?void 0:H.data)==null?void 0:Y.error)||"退款失败,请检查网络后重试")}finally{X(!1)}}}function ae(){if(t.length===0){alert("暂无数据可导出");return}const Y=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],L=t.map(Q=>{const ee=$(Q);return[Q.orderSn||Q.id||"",Z(Q),_(Q.userId),ee.name,Number(Q.amount||0).toFixed(2),Q.paymentMethod==="wechat"?"微信支付":Q.paymentMethod==="alipay"?"支付宝":Q.paymentMethod||"微信支付",Q.status==="refunded"?"已退款":Q.status==="paid"||Q.status==="completed"?"已完成":Q.status==="pending"||Q.status==="created"?"待支付":"已失败",Q.status==="refunded"&&Q.refundReason?Q.refundReason:"-",Q.referrerEarnings?Number(Q.referrerEarnings).toFixed(2):"-",Q.createdAt?new Date(Q.createdAt).toLocaleString("zh-CN"):""].join(",")}),H="\uFEFF"+[Y.join(","),...L].join(`
`),ue=new Blob([H],{type:"text/csv;charset=utf-8"}),U=URL.createObjectURL(ue),he=document.createElement("a");he.href=U,he.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,he.click(),URL.revokeObjectURL(U)}return i.jsxs("div",{className:"p-8 w-full",children:[D&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:D}),i.jsx("button",{type:"button",onClick:()=>F(null),className:"hover:text-red-300",children:"×"})]}),i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),i.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs(re,{variant:"outline",onClick:q,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"text-gray-400",children:"总收入:"}),i.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),i.jsx("span",{className:"text-gray-600",children:"|"}),i.jsx("span",{className:"text-gray-400",children:"今日:"}),i.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsxs("div",{className:"relative flex-1 max-w-md",children:[i.jsx(Ui,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),i.jsx(ce,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:v,onChange:Y=>j(Y.target.value)})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(DN,{className:"w-4 h-4 text-gray-400"}),i.jsxs("select",{value:k,onChange:Y=>E(Y.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"pending",children:"待支付"}),i.jsx("option",{value:"created",children:"已创建"}),i.jsx("option",{value:"failed",children:"已失败"}),i.jsx("option",{value:"refunded",children:"已退款"})]})]}),i.jsxs(re,{variant:"outline",onClick:ae,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(XT,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:C?i.jsxs("div",{className:"flex items-center justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs("div",{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"订单号"}),i.jsx(ke,{className:"text-gray-400",children:"用户"}),i.jsx(ke,{className:"text-gray-400",children:"商品"}),i.jsx(ke,{className:"text-gray-400",children:"金额"}),i.jsx(ke,{className:"text-gray-400",children:"支付方式"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-gray-400",children:"退款原因"}),i.jsx(ke,{className:"text-gray-400",children:"分销佣金"}),i.jsx(ke,{className:"text-gray-400",children:"下单时间"}),i.jsx(ke,{className:"text-gray-400",children:"操作"})]})}),i.jsxs(pr,{children:[t.map(Y=>{const L=$(Y);return i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsxs(ve,{className:"font-mono text-xs text-gray-400",children:[(Y.orderSn||Y.id||"").slice(0,12),"..."]}),i.jsx(ve,{children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm",children:Z(Y)}),i.jsx("p",{className:"text-gray-500 text-xs",children:_(Y.userId)})]})}),i.jsx(ve,{children:i.jsxs("div",{children:[i.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[L.name,(Y.productType||Y.type)==="vip"&&i.jsx(Fe,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"VIP"})]}),i.jsx("p",{className:"text-gray-500 text-xs",children:L.type})]})}),i.jsxs(ve,{className:"text-[#38bdac] font-bold",children:["¥",Number(Y.amount||0).toFixed(2)]}),i.jsx(ve,{className:"text-gray-300",children:Y.paymentMethod==="wechat"?"微信支付":Y.paymentMethod==="alipay"?"支付宝":Y.paymentMethod||"微信支付"}),i.jsx(ve,{children:Y.status==="refunded"?i.jsx(Fe,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):Y.status==="paid"||Y.status==="completed"?i.jsx(Fe,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):Y.status==="pending"||Y.status==="created"?i.jsx(Fe,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):i.jsx(Fe,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),i.jsx(ve,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:Y.refundReason,children:Y.status==="refunded"&&Y.refundReason?Y.refundReason:"-"}),i.jsx(ve,{className:"text-[#FFD700]",children:Y.referrerEarnings?`¥${Number(Y.referrerEarnings).toFixed(2)}`:"-"}),i.jsx(ve,{className:"text-gray-400 text-sm",children:new Date(Y.createdAt).toLocaleString("zh-CN")}),i.jsx(ve,{children:(Y.status==="paid"||Y.status==="completed")&&i.jsxs(re,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{I(Y),O("")},children:[i.jsx(zN,{className:"w-3 h-3 mr-1"}),"退款"]})})]},Y.id)}),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),i.jsx(Zr,{page:f,totalPages:oe,total:s,pageSize:g,onPageChange:m,onPageSizeChange:Y=>{y(Y),m(1)}})]})})}),i.jsx(Qt,{open:!!R,onOpenChange:Y=>!Y&&I(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:"订单退款"})}),R&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",R.orderSn||R.id]}),i.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(R.amount||0).toFixed(2)]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),i.jsx("div",{className:"form-input",children:i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:A,onChange:Y=>O(Y.target.value)})})]}),i.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>I(null),disabled:W,children:"取消"}),i.jsx(re,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:V,disabled:W,children:W?"退款中...":"确认退款"})]})]})})]})}const dl=b.forwardRef(({className:t,...e},n)=>i.jsx("textarea",{className:gt("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:n,...e}));dl.displayName="Textarea";const hu=[{id:"register",label:"注册/登录",icon:"👤",color:"bg-blue-500/20 border-blue-500/40 text-blue-400",desc:"微信授权登录或手机号注册"},{id:"browse",label:"浏览章节",icon:"📖",color:"bg-purple-500/20 border-purple-500/40 text-purple-400",desc:"点击免费/付费章节预览"},{id:"bind_phone",label:"绑定手机",icon:"📱",color:"bg-cyan-500/20 border-cyan-500/40 text-cyan-400",desc:"触发付费章节后绑定手机"},{id:"first_pay",label:"首次付款",icon:"💳",color:"bg-green-500/20 border-green-500/40 text-green-400",desc:"购买单章或全书"},{id:"fill_profile",label:"完善资料",icon:"✍️",color:"bg-yellow-500/20 border-yellow-500/40 text-yellow-400",desc:"填写头像、MBTI、行业等"},{id:"match",label:"派对房匹配",icon:"🤝",color:"bg-orange-500/20 border-orange-500/40 text-orange-400",desc:"参与 Soul 派对房"},{id:"vip",label:"升级 VIP",icon:"👑",color:"bg-amber-500/20 border-amber-500/40 text-amber-400",desc:"付款 ¥1980 购买全书"},{id:"distribution",label:"开启分销",icon:"🔗",color:"bg-[#38bdac]/20 border-[#38bdac]/40 text-[#38bdac]",desc:"生成推广码并推荐好友"}];function tP(){var ls,oi,cs,fa,ds;const[t,e]=MN(),n=t.get("pool"),[r,s]=b.useState([]),[a,o]=b.useState(0),[c,u]=b.useState(1),[h,f]=b.useState(10),[m,g]=b.useState(""),y=$x(m,300),v=n==="vip"?"vip":n==="complete"?"complete":"all",[j,w]=b.useState(v),[k,E]=b.useState(!0),[C,M]=b.useState(null),[D,F]=b.useState(!1),[R,I]=b.useState("desc");b.useEffect(()=>{n==="vip"?w("vip"):n==="complete"?w("complete"):n==="all"&&w("all")},[n]);const[A,O]=b.useState(!1),[W,X]=b.useState(null),[q,Z]=b.useState(!1),[_,$]=b.useState(!1),[oe,V]=b.useState({referrals:[],stats:{}}),[ae,Y]=b.useState(!1),[L,H]=b.useState(null),[ue,U]=b.useState(!1),[he,Q]=b.useState(null),[ee,de]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Ce,B]=b.useState([]),[me,Se]=b.useState(!1),[rt,Ye]=b.useState(!1),[st,Qe]=b.useState(null),[Xe,ft]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[Pt,Jt]=b.useState([]),[Kn,qn]=b.useState(!1),[ss,zt]=b.useState(!1),[Cr,is]=b.useState(null),[On,pn]=b.useState({name:"",sort:0}),[mr,Br]=b.useState({}),[Gn,fe]=b.useState(!1);async function ge(){var G;E(!0),M(null);try{if(D){const Ke=new URLSearchParams({search:y,limit:String(h*5)}),Ze=await Be(`/api/db/users/rfm?${Ke}`);if(Ze!=null&&Ze.success){let En=Ze.users||[];R==="asc"&&(En=[...En].reverse());const Vr=(c-1)*h;s(En.slice(Vr,Vr+h)),o(((G=Ze.users)==null?void 0:G.length)??0),En.length===0&&(F(!1),M("暂无订单数据RFM 排序需要用户有购买记录后才能生效"))}else F(!1),M((Ze==null?void 0:Ze.error)||"RFM 加载失败,已切回普通模式")}else{const Ke=new URLSearchParams({page:String(c),pageSize:String(h),search:y,...j==="vip"&&{vip:"true"},...j==="complete"&&{pool:"complete"}}),Ze=await Be(`/api/db/users?${Ke}`);Ze!=null&&Ze.success?(s(Ze.users||[]),o(Ze.total??0)):M((Ze==null?void 0:Ze.error)||"加载失败")}}catch(Ke){console.error("Load users error:",Ke),M("网络错误")}finally{E(!1)}}b.useEffect(()=>{u(1)},[y,j,D]),b.useEffect(()=>{ge()},[c,h,y,j,D,R]);const Sn=Math.ceil(a/h)||1,ri=()=>{D?R==="desc"?I("asc"):(F(!1),I("desc")):(F(!0),I("desc"))},Es=G=>({S:"bg-amber-500/20 text-amber-400",A:"bg-green-500/20 text-green-400",B:"bg-blue-500/20 text-blue-400",C:"bg-gray-500/20 text-gray-400",D:"bg-red-500/20 text-red-400"})[G||""]||"bg-gray-500/20 text-gray-400";async function ua(G){if(confirm("确定要删除这个用户吗?"))try{const Ke=await Yr(`/api/db/users?id=${encodeURIComponent(G)}`);Ke!=null&&Ke.success?ge():alert("删除失败: "+((Ke==null?void 0:Ke.error)||""))}catch{alert("删除失败")}}const Jn=G=>{X(G),de({phone:G.phone||"",nickname:G.nickname||"",password:"",isAdmin:!!(G.isAdmin??!1),hasFullBook:!!(G.hasFullBook??!1)}),O(!0)},as=()=>{X(null),de({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),O(!0)};async function jt(){if(!ee.phone||!ee.nickname){alert("请填写手机号和昵称");return}Z(!0);try{if(W){const G=await Rt("/api/db/users",{id:W.id,nickname:ee.nickname,isAdmin:ee.isAdmin,hasFullBook:ee.hasFullBook,...ee.password&&{password:ee.password}});if(!(G!=null&&G.success)){alert("更新失败: "+((G==null?void 0:G.error)||""));return}}else{const G=await ht("/api/db/users",{phone:ee.phone,nickname:ee.nickname,password:ee.password,isAdmin:ee.isAdmin});if(!(G!=null&&G.success)){alert("创建失败: "+((G==null?void 0:G.error)||""));return}}O(!1),ge()}catch{alert("保存失败")}finally{Z(!1)}}async function Cn(G){H(G),$(!0),Y(!0);try{const Ke=await Be(`/api/db/users/referrals?userId=${encodeURIComponent(G.id)}`);Ke!=null&&Ke.success?V({referrals:Ke.referrals||[],stats:Ke.stats||{}}):V({referrals:[],stats:{}})}catch{V({referrals:[],stats:{}})}finally{Y(!1)}}const Yn=b.useCallback(async()=>{Se(!0);try{const G=await Be("/api/db/user-rules");G!=null&&G.success&&B(G.rules||[])}catch{}finally{Se(!1)}},[]);async function Dn(){if(!Xe.title){alert("请填写规则标题");return}Z(!0);try{if(st){const G=await Rt("/api/db/user-rules",{id:st.id,...Xe});if(!(G!=null&&G.success)){alert("更新失败: "+((G==null?void 0:G.error)||""));return}}else{const G=await ht("/api/db/user-rules",Xe);if(!(G!=null&&G.success)){alert("创建失败: "+((G==null?void 0:G.error)||""));return}}Ye(!1),Yn()}catch{alert("保存失败")}finally{Z(!1)}}async function ha(G){if(confirm("确定删除?"))try{const Ke=await Yr(`/api/db/user-rules?id=${G}`);Ke!=null&&Ke.success&&Yn()}catch{}}async function si(G){try{await Rt("/api/db/user-rules",{id:G.id,enabled:!G.enabled}),Yn()}catch{}}const Er=b.useCallback(async()=>{qn(!0);try{const G=await Be("/api/db/vip-roles");G!=null&&G.success&&Jt(G.roles||[])}catch{}finally{qn(!1)}},[]);async function ii(){if(!On.name){alert("请填写角色名称");return}Z(!0);try{if(Cr){const G=await Rt("/api/db/vip-roles",{id:Cr.id,...On});if(!(G!=null&&G.success)){alert("更新失败");return}}else{const G=await ht("/api/db/vip-roles",On);if(!(G!=null&&G.success)){alert("创建失败");return}}zt(!1),Er()}catch{alert("保存失败")}finally{Z(!1)}}async function ai(G){if(confirm("确定删除?"))try{const Ke=await Yr(`/api/db/vip-roles?id=${G}`);Ke!=null&&Ke.success&&Er()}catch{}}const mn=b.useCallback(async()=>{fe(!0);try{const G=await Be("/api/db/users/journey-stats");G!=null&&G.success&&G.stats&&Br(G.stats)}catch{}finally{fe(!1)}},[]);return i.jsxs("div",{className:"p-8 w-full",children:[C&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:C}),i.jsx("button",{type:"button",onClick:()=>M(null),children:"×"})]}),i.jsx("div",{className:"flex justify-between items-center mb-6",children:i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),i.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",a," 位注册用户",D&&" · RFM 排序中"]})]})}),i.jsxs(Hc,{defaultValue:"users",className:"w-full",children:[i.jsxs(cl,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[i.jsxs(en,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[i.jsx(Nn,{className:"w-4 h-4"})," 用户列表"]}),i.jsxs(en,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:mn,children:[i.jsx(Bo,{className:"w-4 h-4"})," 用户旅程总览"]}),i.jsxs(en,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Yn,children:[i.jsx(Da,{className:"w-4 h-4"})," 规则配置"]}),i.jsxs(en,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Er,children:[i.jsx(Aa,{className:"w-4 h-4"})," VIP 角色"]})]}),i.jsxs(tn,{value:"users",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[i.jsxs(re,{variant:"outline",onClick:ge,disabled:k,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${k?"animate-spin":""}`})," 刷新"]}),i.jsxs("select",{value:j,onChange:G=>{const Ke=G.target.value;w(Ke),u(1),n&&(t.delete("pool"),e(t))},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",disabled:D,children:[i.jsx("option",{value:"all",children:"全部用户"}),i.jsx("option",{value:"vip",children:"VIP会员超级个体"}),i.jsx("option",{value:"complete",children:"完善资料用户"})]}),i.jsxs("div",{className:"relative",children:[i.jsx(Ui,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),i.jsx(ce,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:m,onChange:G=>g(G.target.value)})]}),i.jsxs(re,{onClick:as,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(yg,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:k?i.jsxs("div",{className:"flex items-center justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs("div",{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"用户信息"}),i.jsx(ke,{className:"text-gray-400",children:"绑定信息"}),i.jsx(ke,{className:"text-gray-400",children:"购买状态"}),i.jsx(ke,{className:"text-gray-400",children:"分销收益"}),i.jsxs(ke,{className:"text-gray-400 cursor-pointer select-none",onClick:ri,children:[i.jsxs("div",{className:"flex items-center gap-1 group",children:[i.jsx(cc,{className:"w-3.5 h-3.5"}),i.jsx("span",{children:"RFM分值"}),D?R==="desc"?i.jsx(jc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):i.jsx(RN,{className:"w-3.5 h-3.5 text-[#38bdac]"}):i.jsx(jT,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),D&&i.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),i.jsx(ke,{className:"text-gray-400",children:"注册时间"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsxs(pr,{children:[r.map(G=>{var Ke,Ze,En;return i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:G.avatar?i.jsx("img",{src:G.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Ke=G.nickname)==null?void 0:Ke.charAt(0))||"?"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>{Q(G.id),U(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:G.nickname}),G.isAdmin&&i.jsx(Fe,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),G.openId&&!((Ze=G.id)!=null&&Ze.startsWith("user_"))&&i.jsx(Fe,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),i.jsx("p",{className:"text-xs text-gray-500 font-mono",children:G.openId?G.openId.slice(0,12)+"...":(En=G.id)==null?void 0:En.slice(0,12)})]})]})}),i.jsx(ve,{children:i.jsxs("div",{className:"space-y-1",children:[G.phone&&i.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[i.jsx("span",{className:"text-gray-500",children:"📱"}),i.jsx("span",{className:"text-gray-300",children:G.phone})]}),G.wechatId&&i.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[i.jsx("span",{className:"text-gray-500",children:"💬"}),i.jsx("span",{className:"text-gray-300",children:G.wechatId})]}),G.openId&&i.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[i.jsx("span",{className:"text-gray-500",children:"🔗"}),i.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:G.openId,children:[G.openId.slice(0,12),"..."]})]}),!G.phone&&!G.wechatId&&!G.openId&&i.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),i.jsx(ve,{children:G.hasFullBook?i.jsx(Fe,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):i.jsx(Fe,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),i.jsx(ve,{children:i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(G.earnings||0)).toFixed(2)]}),parseFloat(String(G.pendingEarnings||0))>0&&i.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(G.pendingEarnings||0)).toFixed(2)]}),i.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Cn(G),role:"button",tabIndex:0,onKeyDown:Vr=>Vr.key==="Enter"&&Cn(G),children:[i.jsx(Nn,{className:"w-3 h-3"})," 绑定",G.referralCount||0,"人"]})]})}),i.jsx(ve,{children:G.rfmScore!==void 0?i.jsx("div",{className:"flex flex-col gap-1",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-white font-bold text-base",children:G.rfmScore}),i.jsx(Fe,{className:`border-0 text-xs ${Es(G.rfmLevel)}`,children:G.rfmLevel})]})}):i.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",i.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),i.jsx(ve,{className:"text-gray-400",children:G.createdAt?new Date(G.createdAt).toLocaleDateString():"-"}),i.jsx(ve,{className:"text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>{Q(G.id),U(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:i.jsx(pg,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Jn(G),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>ua(G.id),title:"删除",children:i.jsx(vn,{className:"w-4 h-4"})})]})})]},G.id)}),r.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),i.jsx(Zr,{page:c,totalPages:Sn,total:a,pageSize:h,onPageChange:u,onPageSizeChange:G=>{f(G),u(1)}})]})})})]}),i.jsxs(tn,{value:"journey",children:[i.jsxs("div",{className:"flex items-center justify-between mb-5",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),i.jsxs(re,{variant:"outline",onClick:mn,disabled:Gn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${Gn?"animate-spin":""}`})," 刷新数据"]})]}),i.jsxs("div",{className:"relative mb-8",children:[i.jsx("div",{className:"absolute top-16 left-0 right-0 h-0.5 bg-gradient-to-r from-blue-500/20 via-[#38bdac]/30 to-amber-500/20 mx-20"}),i.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:hu.map((G,Ke)=>i.jsxs("div",{className:"relative flex flex-col items-center",children:[i.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${G.color} text-center cursor-default`,children:[i.jsx("div",{className:"text-2xl mb-1",children:G.icon}),i.jsx("div",{className:`text-xs font-medium ${G.color.split(" ").find(Ze=>Ze.startsWith("text-"))}`,children:G.label}),mr[G.id]!==void 0&&i.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[i.jsx("span",{className:"font-bold text-white",children:mr[G.id]})," 人"]}),i.jsx("div",{className:"absolute -top-2.5 -left-2.5 w-5 h-5 rounded-full bg-[#0a1628] border border-gray-700 flex items-center justify-center text-[10px] text-gray-500",children:Ke+1})]}),Ke<hu.length-1&&i.jsx("div",{className:"hidden lg:block absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-10",children:i.jsx("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",children:i.jsx("path",{d:"M0 6H16M16 6L11 1M16 6L11 11",stroke:"#374151",strokeWidth:"1.5",strokeLinecap:"round"})})}),i.jsx("p",{className:"text-[10px] text-gray-600 text-center mt-2 leading-tight",children:G.desc})]},G.id))})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Bo,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx("span",{className:"text-white font-medium",children:"旅程关键节点"})]}),i.jsx("div",{className:"space-y-2 text-sm",children:[{step:"① 注册",action:"微信 OAuth 或手机号注册",next:"引导填写头像"},{step:"② 浏览",action:"点击章节/阅读免费内容",next:"触发绑定手机"},{step:"③ 首付",action:"购买单章或全书",next:"推送分销功能"},{step:"④ VIP",action:"¥1980 购买全书",next:"进入 VIP 私域群"},{step:"⑤ 分销",action:"推广好友购买",next:"提现分销收益"}].map(G=>i.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[i.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:G.step}),i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-300",children:G.action}),i.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",G.next]})]})]},G.step))})]}),i.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(zr,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),i.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),Gn?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(qe,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(mr).length>0?i.jsx("div",{className:"space-y-2",children:hu.map(G=>{const Ke=mr[G.id]||0,Ze=Math.max(...hu.map(Vr=>mr[Vr.id]||0),1),En=Math.round(Ke/Ze*100);return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[G.icon," ",G.label]}),i.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${En}%`}})}),i.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Ke})]},G.id)})}):i.jsx("div",{className:"text-center py-8",children:i.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),i.jsxs(tn,{value:"rules",children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(re,{variant:"outline",onClick:Yn,disabled:me,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${me?"animate-spin":""}`})," 刷新"]}),i.jsxs(re,{onClick:()=>{Qe(null),ft({title:"",description:"",trigger:"",sort:0,enabled:!0}),Ye(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),me?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ce.length===0?i.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[i.jsx(zr,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),i.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则重启服务将自动写入10条默认规则"}),i.jsxs(re,{onClick:Yn,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(qe,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):i.jsx("div",{className:"space-y-2",children:Ce.map(G=>i.jsx("div",{className:`p-4 rounded-lg border transition-all ${G.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[i.jsx(bt,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),i.jsx("span",{className:"text-white font-medium",children:G.title}),G.trigger&&i.jsxs(Fe,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",G.trigger]}),i.jsx(Fe,{className:`text-xs border-0 ${G.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:G.enabled?"启用":"禁用"})]}),G.description&&i.jsx("p",{className:"text-gray-400 text-sm ml-6",children:G.description})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[i.jsx(yt,{checked:G.enabled,onCheckedChange:()=>si(G)}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>{Qe(G),ft({title:G.title,description:G.description,trigger:G.trigger,sort:G.sort,enabled:G.enabled}),Ye(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>ha(G.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:i.jsx(vn,{className:"w-4 h-4"})})]})]})},G.id))})]}),i.jsxs(tn,{value:"vip-roles",children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"管理用户 VIP 角色分类,这些角色将在用户详情和会员展示中使用"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(re,{variant:"outline",onClick:Er,disabled:Kn,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${Kn?"animate-spin":""}`})," 刷新"]}),i.jsxs(re,{onClick:()=>{is(null),pn({name:"",sort:0}),zt(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"})," 添加角色"]})]})]}),Kn?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Pt.length===0?i.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[i.jsx(Aa,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),i.jsx("p",{className:"text-gray-400 mb-4",children:"暂无 VIP 角色"}),i.jsxs(re,{onClick:()=>{is(null),pn({name:"",sort:0}),zt(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"})," 添加第一个角色"]})]}):i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3",children:Pt.map(G=>i.jsxs("div",{className:"p-4 bg-[#0f2137] border border-amber-500/20 rounded-xl hover:border-amber-500/40 transition-all group",children:[i.jsxs("div",{className:"flex items-start justify-between mb-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Aa,{className:"w-4 h-4 text-amber-400"}),i.jsx("span",{className:"text-white font-medium",children:G.name})]}),i.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[i.jsx("button",{type:"button",onClick:()=>{is(G),pn({name:G.name,sort:G.sort}),zt(!0)},className:"text-gray-500 hover:text-[#38bdac]",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx("button",{type:"button",onClick:()=>ai(G.id),className:"text-gray-500 hover:text-red-400",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]}),i.jsxs("p",{className:"text-gray-600 text-xs",children:["排序: ",G.sort]})]},G.id))})]})]}),i.jsx(Qt,{open:A,onOpenChange:O,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[W?i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}):i.jsx(yg,{className:"w-5 h-5 text-[#38bdac]"}),W?"编辑用户":"添加用户"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"手机号"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:ee.phone,onChange:G=>de({...ee,phone:G.target.value}),disabled:!!W})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"昵称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:ee.nickname,onChange:G=>de({...ee,nickname:G.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:W?"新密码 (留空则不修改)":"密码"}),i.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:W?"留空则不修改":"请输入密码",value:ee.password,onChange:G=>de({...ee,password:G.target.value})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(te,{className:"text-gray-300",children:"管理员权限"}),i.jsx(yt,{checked:ee.isAdmin,onCheckedChange:G=>de({...ee,isAdmin:G})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(te,{className:"text-gray-300",children:"已购全书"}),i.jsx(yt,{checked:ee.hasFullBook,onCheckedChange:G=>de({...ee,hasFullBook:G})})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>O(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:jt,disabled:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),q?"保存中...":"保存"]})]})]})}),i.jsx(Qt,{open:rt,onOpenChange:Ye,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}),st?"编辑规则":"添加规则"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"规则标题 *"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例匹配后填写头像、付款1980需填写信息",value:Xe.title,onChange:G=>ft({...Xe,title:G.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"规则描述"}),i.jsx(dl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Xe.description,onChange:G=>ft({...Xe,description:G.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"触发条件"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Xe.trigger,onChange:G=>ft({...Xe,trigger:G.target.value})})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:i.jsx(te,{className:"text-gray-300",children:"启用状态"})}),i.jsx(yt,{checked:Xe.enabled,onCheckedChange:G=>ft({...Xe,enabled:G})})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>Ye(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:Dn,disabled:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),q?"保存中...":"保存"]})]})]})}),i.jsx(Qt,{open:ss,onOpenChange:zt,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(Aa,{className:"w-5 h-5 text-amber-400"}),Cr?"编辑 VIP 角色":"添加 VIP 角色"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"角色名称 *"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:创业者、资源整合者、技术咖",value:On.name,onChange:G=>pn({...On,name:G.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"排序(越小越前)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:On.sort,onChange:G=>pn({...On,sort:parseInt(G.target.value)||0})})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>zt(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:ii,disabled:q,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),q?"保存中...":"保存"]})]})]})}),i.jsx(Qt,{open:_,onOpenChange:$,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",L==null?void 0:L.nickname]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[i.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((ls=oe.stats)==null?void 0:ls.total)||0}),i.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),i.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[i.jsx("div",{className:"text-2xl font-bold text-green-400",children:((oi=oe.stats)==null?void 0:oi.purchased)||0}),i.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),i.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[i.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((cs=oe.stats)==null?void 0:cs.earnings)||0).toFixed(2)]}),i.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),i.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[i.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((fa=oe.stats)==null?void 0:fa.pendingEarnings)||0).toFixed(2)]}),i.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),ae?i.jsxs("div",{className:"flex items-center justify-center py-8",children:[i.jsx(qe,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((ds=oe.referrals)==null?void 0:ds.length)??0)>0?i.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(oe.referrals??[]).map((G,Ke)=>{var En;const Ze=G;return i.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((En=Ze.nickname)==null?void 0:En.charAt(0))||"?"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-white text-sm",children:Ze.nickname}),i.jsx("div",{className:"text-xs text-gray-500",children:Ze.phone||(Ze.hasOpenId?"微信用户":"未绑定")})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[Ze.status==="vip"&&i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Ze.status==="paid"&&i.jsxs(Fe,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Ze.purchasedSections,"章"]}),Ze.status==="free"&&i.jsx(Fe,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),i.jsx("span",{className:"text-xs text-gray-500",children:Ze.createdAt?new Date(Ze.createdAt).toLocaleDateString():""})]})]},Ze.id||Ke)})}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),i.jsx(bn,{children:i.jsx(re,{variant:"outline",onClick:()=>$(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),i.jsx(zx,{open:ue,onClose:()=>U(!1),userId:he,onUserUpdated:ge})]})}function qu(t,[e,n]){return Math.min(n,Math.max(e,t))}var ik=["PageUp","PageDown"],ak=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ok={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ul="Slider",[jg,nP,rP]=Ox(ul),[lk]=ia(ul,[rP]),[sP,Qh]=lk(ul),ck=b.forwardRef((t,e)=>{const{name:n,min:r=0,max:s=100,step:a=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:u=0,defaultValue:h=[r],value:f,onValueChange:m=()=>{},onValueCommit:g=()=>{},inverted:y=!1,form:v,...j}=t,w=b.useRef(new Set),k=b.useRef(0),C=o==="horizontal"?iP:aP,[M=[],D]=Ba({prop:f,defaultProp:h,onChange:W=>{var q;(q=[...w.current][k.current])==null||q.focus(),m(W)}}),F=b.useRef(M);function R(W){const X=uP(M,W);O(W,X)}function I(W){O(W,k.current)}function A(){const W=F.current[k.current];M[k.current]!==W&&g(M)}function O(W,X,{commit:q}={commit:!1}){const Z=mP(a),_=gP(Math.round((W-r)/a)*a+r,Z),$=qu(_,[r,s]);D((oe=[])=>{const V=cP(oe,$,X);if(pP(V,u*a)){k.current=V.indexOf($);const ae=String(V)!==String(oe);return ae&&q&&g(V),ae?V:oe}else return oe})}return i.jsx(sP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:s,valueIndexToChangeRef:k,thumbs:w.current,values:M,orientation:o,form:v,children:i.jsx(jg.Provider,{scope:t.__scopeSlider,children:i.jsx(jg.Slot,{scope:t.__scopeSlider,children:i.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:nt(j.onPointerDown,()=>{c||(F.current=M)}),min:r,max:s,inverted:y,onSlideStart:c?void 0:R,onSlideMove:c?void 0:I,onSlideEnd:c?void 0:A,onHomeKeyDown:()=>!c&&O(r,0,{commit:!0}),onEndKeyDown:()=>!c&&O(s,M.length-1,{commit:!0}),onStepKeyDown:({event:W,direction:X})=>{if(!c){const _=ik.includes(W.key)||W.shiftKey&&ak.includes(W.key)?10:1,$=k.current,oe=M[$],V=a*_*X;O(oe+V,$,{commit:!0})}}})})})})});ck.displayName=ul;var[dk,uk]=lk(ul,{startEdge:"left",endEdge:"right",size:"width",direction:1}),iP=b.forwardRef((t,e)=>{const{min:n,max:r,dir:s,inverted:a,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=mt(e,C=>g(C)),v=b.useRef(void 0),j=Gh(s),w=j==="ltr",k=w&&!a||!w&&a;function E(C){const M=v.current||m.getBoundingClientRect(),D=[0,M.width],R=Fx(D,k?[n,r]:[r,n]);return v.current=M,R(C-M.left)}return i.jsx(dk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:i.jsx(hk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const M=E(C.clientX);o==null||o(M)},onSlideMove:C=>{const M=E(C.clientX);c==null||c(M)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:C=>{const D=ok[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:D?-1:1})}})})}),aP=b.forwardRef((t,e)=>{const{min:n,max:r,inverted:s,onSlideStart:a,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=mt(e,f),g=b.useRef(void 0),y=!s;function v(j){const w=g.current||f.current.getBoundingClientRect(),k=[0,w.height],C=Fx(k,y?[r,n]:[n,r]);return g.current=w,C(j-w.top)}return i.jsx(dk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:i.jsx(hk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=v(j.clientY);a==null||a(w)},onSlideMove:j=>{const w=v(j.clientY);o==null||o(w)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const k=ok[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:k?-1:1})}})})}),hk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=Qh(ul,n);return i.jsx(ot.span,{...h,ref:e,onKeyDown:nt(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):ik.concat(ak).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:nt(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:nt(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&s(m)}),onPointerUp:nt(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),a(m))})})}),fk="SliderTrack",pk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,s=Qh(fk,n);return i.jsx(ot.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:e})});pk.displayName=fk;var kg="SliderRange",mk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,s=Qh(kg,n),a=uk(kg,n),o=b.useRef(null),c=mt(e,o),u=s.values.length,h=s.values.map(g=>yk(g,s.min,s.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return i.jsx(ot.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:c,style:{...t.style,[a.startEdge]:f+"%",[a.endEdge]:m+"%"}})});mk.displayName=kg;var Sg="SliderThumb",gk=b.forwardRef((t,e)=>{const n=nP(t.__scopeSlider),[r,s]=b.useState(null),a=mt(e,c=>s(c)),o=b.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return i.jsx(oP,{...t,ref:a,index:o})}),oP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:s,...a}=t,o=Qh(Sg,n),c=uk(Sg,n),[u,h]=b.useState(null),f=mt(e,E=>h(E)),m=u?o.form||!!u.closest("form"):!0,g=_x(u),y=o.values[r],v=y===void 0?0:yk(y,o.min,o.max),j=dP(r,o.values.length),w=g==null?void 0:g[c.size],k=w?hP(w,v,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),i.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${v}% + ${k}px)`},children:[i.jsx(jg.ItemSlot,{scope:t.__scopeSlider,children:i.jsx(ot.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":o.min,"aria-valuenow":y,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...a,ref:f,style:y===void 0?{display:"none"}:t.style,onFocus:nt(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&i.jsx(xk,{name:s??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});gk.displayName=Sg;var lP="RadioBubbleInput",xk=b.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const s=b.useRef(null),a=mt(s,r),o=Lx(e);return b.useEffect(()=>{const c=s.current;if(!c)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("input",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),i.jsx(ot.input,{style:{display:"none"},...n,ref:a,defaultValue:e})});xk.displayName=lP;function cP(t=[],e,n){const r=[...t];return r[n]=e,r.sort((s,a)=>s-a)}function yk(t,e,n){const a=100/(n-e)*(t-e);return qu(a,[0,100])}function dP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function uP(t,e){if(t.length===1)return 0;const n=t.map(s=>Math.abs(s-e)),r=Math.min(...n);return n.indexOf(r)}function hP(t,e,n){const r=t/2,a=Fx([0,50],[0,r]);return(r-a(e)*n)*n}function fP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function pP(t,e){if(e>0){const n=fP(t);return Math.min(...n)>=e}return!0}function Fx(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function mP(t){return(String(t).split(".")[1]||"").length}function gP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var xP=ck,yP=pk,vP=mk,bP=gk;function wP({className:t,defaultValue:e,value:n,min:r=0,max:s=100,...a}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,s],[n,e,r,s]);return i.jsxs(xP,{defaultValue:e,value:n,min:r,max:s,className:gt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...a,children:[i.jsx(yP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:i.jsx(vP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>i.jsx(bP,{className:"block size-4 shrink-0 rounded-full border-2 border-[#38bdac] bg-white shadow-sm focus-visible:ring-2 focus-visible:ring-[#38bdac] focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"},u))]})}const NP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function vk({embedded:t=!1}){const[e,n]=b.useState(NP),[r,s]=b.useState(!0),[a,o]=b.useState(!1);b.useEffect(()=>{Be("/api/admin/referral-settings").then(h=>{const f=h==null?void 0:h.data;f&&typeof f=="object"&&n({distributorShare:f.distributorShare??90,minWithdrawAmount:f.minWithdrawAmount??10,bindingDays:f.bindingDays??30,userDiscount:f.userDiscount??5,enableAutoWithdraw:f.enableAutoWithdraw??!1,vipOrderShareVip:f.vipOrderShareVip??20,vipOrderShareNonVip:f.vipOrderShareNonVip??10})}).catch(console.error).finally(()=>s(!1))},[]);const c=async()=>{o(!0);try{const h={distributorShare:Number(e.distributorShare)||0,minWithdrawAmount:Number(e.minWithdrawAmount)||0,bindingDays:Number(e.bindingDays)||0,userDiscount:Number(e.userDiscount)||0,enableAutoWithdraw:!!e.enableAutoWithdraw,vipOrderShareVip:Number(e.vipOrderShareVip)||20,vipOrderShareNonVip:Number(e.vipOrderShareNonVip)||10},f=await ht("/api/admin/referral-settings",h);if(!f||f.success===!1){alert("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}alert(`✅ 分销配置已保存成功!
• 小程序与网站的推广规则会一起生效
• 绑定关系会使用新的天数配置
• 佣金比例会立即应用到新订单
如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),alert("保存失败: "+(h instanceof Error?h.message:String(h)))}finally{o(!1)}},u=h=>f=>{const m=parseFloat(f.target.value||"0");n(g=>({...g,[h]:isNaN(m)?0:m}))};return r?i.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Jo,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),i.jsxs(re,{onClick:c,disabled:a||r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[i.jsx(eA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),i.jsx(It,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),i.jsx(Te,{className:"space-y-6",children:i.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(su,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%"]}),i.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),i.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(Nn,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%"]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(wP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),i.jsx(ce,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),i.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",i.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(su,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %"]}),i.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),i.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(su,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %"]}),i.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),i.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(Nn,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),i.jsx(ce,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),i.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[i.jsx(Jo,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),i.jsx(It,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),i.jsx(Te,{className:"space-y-6",children:i.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"最低提现金额(元)"}),i.jsx(ce,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),i.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",i.jsx(Fe,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsx(yt,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),i.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsx(et,{children:i.jsxs(tt,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[i.jsx(su,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),i.jsxs(Te,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[i.jsxs("p",{children:["1. 以上配置会写入"," ",i.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),"小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),i.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),i.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function jP(){var Ce;const[t,e]=b.useState("overview"),[n,r]=b.useState([]),[s,a]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[v,j]=b.useState(null),[w,k]=b.useState(""),[E,C]=b.useState("all"),[M,D]=b.useState(1),[F,R]=b.useState(10),[I,A]=b.useState(0),[O,W]=b.useState(new Set),[X,q]=b.useState(null),[Z,_]=b.useState(""),[$,oe]=b.useState(!1);b.useEffect(()=>{V()},[]),b.useEffect(()=>{D(1)},[t,E]),b.useEffect(()=>{ae(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&ae(t,!0)},[M,F,E,w]);async function V(){j(null);try{const B=await Be("/api/admin/distribution/overview");B!=null&&B.success&&B.overview&&a(B.overview)}catch(B){console.error("[Admin] 概览接口异常:",B),j("加载概览失败")}try{const B=await Be("/api/db/users");m((B==null?void 0:B.users)||[])}catch(B){console.error("[Admin] 用户数据加载失败:",B)}}async function ae(B,me=!1){var Se;if(!(!me&&O.has(B))){y(!0);try{const rt=f;switch(B){case"overview":break;case"orders":{try{const Ye=new URLSearchParams({page:String(M),pageSize:String(F),...E!=="all"&&{status:E},...w&&{search:w}}),st=await Be(`/api/orders?${Ye}`);if(st!=null&&st.success&&st.orders){const Qe=st.orders.map(Xe=>{const ft=rt.find(Jt=>Jt.id===Xe.userId),Pt=Xe.referrerId?rt.find(Jt=>Jt.id===Xe.referrerId):null;return{...Xe,amount:parseFloat(String(Xe.amount))||0,userNickname:(ft==null?void 0:ft.nickname)||Xe.userNickname||"未知用户",userPhone:(ft==null?void 0:ft.phone)||Xe.userPhone||"-",referrerNickname:(Pt==null?void 0:Pt.nickname)||null,referrerCode:(Pt==null?void 0:Pt.referralCode)??null,type:Xe.productType||Xe.type}});r(Qe),A(st.total??Qe.length)}else r([]),A(0)}catch(Ye){console.error(Ye),j("加载订单失败"),r([])}break}case"bindings":{try{const Ye=new URLSearchParams({page:String(M),pageSize:String(F),...E!=="all"&&{status:E}}),st=await Be(`/api/db/distribution?${Ye}`);c((st==null?void 0:st.bindings)||[]),A((st==null?void 0:st.total)??((Se=st==null?void 0:st.bindings)==null?void 0:Se.length)??0)}catch(Ye){console.error(Ye),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const Ye=E==="completed"?"success":E==="rejected"?"failed":E,st=new URLSearchParams({...Ye&&Ye!=="all"&&{status:Ye},page:String(M),pageSize:String(F)}),Qe=await Be(`/api/admin/withdrawals?${st}`);if(Qe!=null&&Qe.success&&Qe.withdrawals){const Xe=Qe.withdrawals.map(ft=>({...ft,account:ft.account??"未绑定微信号",status:ft.status==="success"?"completed":ft.status==="failed"?"rejected":ft.status}));h(Xe),A((Qe==null?void 0:Qe.total)??Xe.length)}else Qe!=null&&Qe.success||j(`获取提现记录失败: ${(Qe==null?void 0:Qe.error)||"未知错误"}`),h([])}catch(Ye){console.error(Ye),j("加载提现数据失败"),h([])}break}}W(Ye=>new Set(Ye).add(B))}catch(rt){console.error(rt)}finally{y(!1)}}}async function Y(){j(null),W(B=>{const me=new Set(B);return me.delete(t),me}),t==="overview"&&V(),await ae(t,!0)}async function L(B){if(confirm("确认审核通过并打款?"))try{const me=await Rt("/api/admin/withdrawals",{id:B,action:"approve"});if(!(me!=null&&me.success)){const Se=(me==null?void 0:me.message)||(me==null?void 0:me.error)||"操作失败";alert(Se);return}await Y()}catch(me){console.error(me),alert("操作失败")}}async function H(B){const me=prompt("请输入拒绝原因:");if(me)try{const Se=await Rt("/api/admin/withdrawals",{id:B,action:"reject",errorMessage:me});if(!(Se!=null&&Se.success)){alert((Se==null?void 0:Se.error)||"操作失败");return}await Y()}catch(Se){console.error(Se),alert("操作失败")}}async function ue(){var B;if(!(!(X!=null&&X.orderSn)&&!(X!=null&&X.id))){oe(!0),j(null);try{const me=await Rt("/api/admin/orders/refund",{orderSn:X.orderSn||X.id,reason:Z||void 0});me!=null&&me.success?(q(null),_(""),await ae("orders",!0)):j((me==null?void 0:me.error)||"退款失败")}catch(me){const Se=me;j(((B=Se==null?void 0:Se.data)==null?void 0:B.error)||"退款失败,请检查网络后重试")}finally{oe(!1)}}}function U(B){const me={active:"bg-green-500/20 text-green-400",converted:"bg-blue-500/20 text-blue-400",expired:"bg-gray-500/20 text-gray-400",cancelled:"bg-red-500/20 text-red-400",pending:"bg-orange-500/20 text-orange-400",pending_confirm:"bg-orange-500/20 text-orange-400",processing:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",rejected:"bg-red-500/20 text-red-400"},Se={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return i.jsx(Fe,{className:`${me[B]||"bg-gray-500/20 text-gray-400"} border-0`,children:Se[B]||B})}const he=Math.ceil(I/F)||1,Q=n,ee=o.filter(B=>{var Se,rt,Ye,st;if(!w)return!0;const me=w.toLowerCase();return((Se=B.refereeNickname)==null?void 0:Se.toLowerCase().includes(me))||((rt=B.refereePhone)==null?void 0:rt.includes(me))||((Ye=B.referrerName)==null?void 0:Ye.toLowerCase().includes(me))||((st=B.referrerCode)==null?void 0:st.toLowerCase().includes(me))}),de=u.filter(B=>{var Se;if(!w)return!0;const me=w.toLowerCase();return((Se=B.userName)==null?void 0:Se.toLowerCase().includes(me))||B.account&&B.account.toLowerCase().includes(me)});return i.jsxs("div",{className:"p-8 w-full",children:[v&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:v}),i.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),i.jsxs("div",{className:"flex items-center justify-between mb-8",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),i.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),i.jsxs(re,{onClick:Y,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),i.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:cc},{key:"orders",label:"订单管理",icon:Vu},{key:"bindings",label:"绑定管理",icon:Gs},{key:"withdrawals",label:"提现审核",icon:Jo},{key:"settings",label:"推广设置",icon:Da}].map(B=>i.jsxs("button",{type:"button",onClick:()=>{e(B.key),C("all"),k("")},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===B.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[i.jsx(B.icon,{className:"w-4 h-4"}),B.label]},B.key))}),g?i.jsxs("div",{className:"flex items-center justify-center py-20",children:[i.jsx(qe,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs(i.Fragment,{children:[t==="overview"&&s&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),i.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:s.todayClicks}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:i.jsx(pg,{className:"w-6 h-6 text-blue-400"})})]})})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),i.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:s.todayUniqueVisitors??0}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:i.jsx(Nn,{className:"w-6 h-6 text-cyan-400"})})]})})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),i.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(s.todayClickRate??0).toFixed(2)}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:i.jsx(cc,{className:"w-6 h-6 text-amber-400"})})]})})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),i.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:s.todayBindings})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:i.jsx(Gs,{className:"w-6 h-6 text-green-400"})})]})})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),i.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:s.todayConversions})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:i.jsx(Eb,{className:"w-6 h-6 text-purple-400"})})]})})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),i.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",s.todayEarnings.toFixed(2)]})]}),i.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:i.jsx(Vu,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((Ce=s.todayClicksByPage)==null?void 0:Ce.length)??0)>0&&i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(pg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),i.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),i.jsx(Te,{children:i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[i.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),i.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),i.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),i.jsx("tbody",{children:[...s.todayClicksByPage??[]].sort((B,me)=>me.clicks-B.clicks).map((B,me)=>i.jsxs("tr",{className:"border-b border-gray-700/50",children:[i.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:B.page||"(未区分)"}),i.jsx("td",{className:"py-2 pr-4 text-right text-white",children:B.clicks}),i.jsxs("td",{className:"py-2 text-right text-gray-400",children:[s.todayClicks>0?(B.clicks/s.todayClicks*100).toFixed(1):0,"%"]})]},me))})]})})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Ee,{className:"bg-orange-500/10 border-orange-500/30",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:i.jsx(fg,{className:"w-6 h-6 text-orange-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),i.jsxs("p",{className:"text-2xl font-bold text-white",children:[s.expiringBindings," 个"]}),i.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期需关注转化"})]})]})})}),i.jsx(Ee,{className:"bg-blue-500/10 border-blue-500/30",children:i.jsx(Te,{className:"p-6",children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:i.jsx(Jo,{className:"w-6 h-6 text-blue-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),i.jsxs("p",{className:"text-2xl font-bold text-white",children:[s.pendingWithdrawals," 笔"]}),i.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",s.pendingWithdrawAmount.toFixed(2)]})]}),i.jsx(re,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsx(et,{children:i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Bu,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),i.jsx(Te,{children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.monthClicks})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.monthBindings})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.monthConversions})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),i.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",s.monthEarnings.toFixed(2)]})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsx(et,{children:i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(cc,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),i.jsxs(Te,{children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.totalClicks.toLocaleString()})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.totalBindings.toLocaleString()})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),i.jsx("p",{className:"text-xl font-bold text-white",children:s.totalConversions})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[i.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),i.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",s.totalEarnings.toFixed(2)]})]})]}),i.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[i.jsx("span",{className:"text-gray-300",children:"点击转化率"}),i.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[s.conversionRate,"%"]})]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsx(et,{children:i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),i.jsx(Te,{children:i.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[i.jsx("p",{className:"text-3xl font-bold text-white",children:s.totalDistributors}),i.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[i.jsx("p",{className:"text-3xl font-bold text-green-400",children:s.activeDistributors}),i.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[i.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),i.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),i.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[i.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),i.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Ui,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),i.jsx(ce,{value:w,onChange:B=>k(B.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),i.jsxs("select",{value:E,onChange:B=>C(B.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"pending",children:"待支付"}),i.jsx("option",{value:"failed",children:"已失败"}),i.jsx("option",{value:"refunded",children:"已退款"})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-0",children:[n.length===0?i.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[i.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Q.map(B=>{var me,Se;return i.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[i.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(me=B.id)==null?void 0:me.slice(0,12),"..."]}),i.jsx("td",{className:"p-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm",children:B.userNickname}),i.jsx("p",{className:"text-gray-500 text-xs",children:B.userPhone})]})}),i.jsx("td",{className:"p-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white text-sm",children:(()=>{const rt=B.productType||B.type;return rt==="fullbook"?`${B.bookName||"《底层逻辑》"} - 全本`:rt==="match"?"匹配次数购买":`${B.bookName||"《底层逻辑》"} - ${B.sectionTitle||B.chapterTitle||`章节${B.productId||B.sectionId||""}`}`})()}),i.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const rt=B.productType||B.type;return rt==="fullbook"?"全书解锁":rt==="match"?"功能权益":B.chapterTitle||"单章购买"})()})]})}),i.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof B.amount=="number"?B.amount.toFixed(2):parseFloat(String(B.amount||"0")).toFixed(2)]}),i.jsx("td",{className:"p-4 text-gray-300",children:B.paymentMethod==="wechat"?"微信支付":B.paymentMethod==="alipay"?"支付宝":B.paymentMethod||"微信支付"}),i.jsx("td",{className:"p-4",children:B.status==="refunded"?i.jsx(Fe,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):B.status==="completed"||B.status==="paid"?i.jsx(Fe,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):B.status==="pending"||B.status==="created"?i.jsx(Fe,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):i.jsx(Fe,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),i.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:B.refundReason,children:B.status==="refunded"&&B.refundReason?B.refundReason:"-"}),i.jsx("td",{className:"p-4 text-gray-300 text-sm",children:B.referrerId||B.referralCode?i.jsxs("span",{title:B.referralCode||B.referrerCode||B.referrerId||"",children:[B.referrerNickname||B.referralCode||B.referrerCode||((Se=B.referrerId)==null?void 0:Se.slice(0,8)),(B.referralCode||B.referrerCode)&&` (${B.referralCode||B.referrerCode})`]}):"-"}),i.jsx("td",{className:"p-4 text-[#FFD700]",children:B.referrerEarnings?`¥${(typeof B.referrerEarnings=="number"?B.referrerEarnings:parseFloat(String(B.referrerEarnings))).toFixed(2)}`:"-"}),i.jsx("td",{className:"p-4 text-gray-400 text-sm",children:B.createdAt?new Date(B.createdAt).toLocaleString("zh-CN"):"-"}),i.jsx("td",{className:"p-4",children:(B.status==="paid"||B.status==="completed")&&i.jsxs(re,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{q(B),_("")},children:[i.jsx(zN,{className:"w-3 h-3 mr-1"}),"退款"]})})]},B.id)})})]})}),t==="orders"&&i.jsx(Zr,{page:M,totalPages:he,total:I,pageSize:F,onPageChange:D,onPageSizeChange:B=>{R(B),D(1)}})]})})]}),t==="bindings"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Ui,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),i.jsx(ce,{value:w,onChange:B=>k(B.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),i.jsxs("select",{value:E,onChange:B=>C(B.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"active",children:"有效"}),i.jsx("option",{value:"converted",children:"已转化"}),i.jsx("option",{value:"expired",children:"已过期"})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-0",children:[ee.length===0?i.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[i.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ee.map(B=>i.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[i.jsx("td",{className:"p-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:B.refereeNickname||"匿名用户"}),i.jsx("p",{className:"text-gray-500 text-xs",children:B.refereePhone})]})}),i.jsx("td",{className:"p-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white",children:B.referrerName||"-"}),i.jsx("p",{className:"text-gray-500 text-xs font-mono",children:B.referrerCode})]})}),i.jsx("td",{className:"p-4 text-gray-400",children:B.boundAt?new Date(B.boundAt).toLocaleDateString("zh-CN"):"-"}),i.jsx("td",{className:"p-4 text-gray-400",children:B.expiresAt?new Date(B.expiresAt).toLocaleDateString("zh-CN"):"-"}),i.jsx("td",{className:"p-4",children:U(B.status)}),i.jsx("td",{className:"p-4",children:B.commission?i.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",B.commission.toFixed(2)]}):i.jsx("span",{className:"text-gray-500",children:"-"})})]},B.id))})]})}),t==="bindings"&&i.jsx(Zr,{page:M,totalPages:he,total:I,pageSize:F,onPageChange:D,onPageSizeChange:B=>{R(B),D(1)}})]})})]}),t==="withdrawals"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Ui,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),i.jsx(ce,{value:w,onChange:B=>k(B.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),i.jsxs("select",{value:E,onChange:B=>C(B.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"pending",children:"待审核"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"rejected",children:"已拒绝"})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-0",children:[de.length===0?i.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[i.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),i.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-700/50",children:de.map(B=>i.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[i.jsx("td",{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-2",children:[B.userAvatar?i.jsx("img",{src:B.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):i.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(B.userName||B.name||"?").slice(0,1)}),i.jsx("p",{className:"text-white font-medium",children:B.userName||B.name})]})}),i.jsx("td",{className:"p-4",children:i.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",B.amount.toFixed(2)]})}),i.jsx("td",{className:"p-4",children:i.jsx(Fe,{className:B.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:B.method==="wechat"?"微信":"支付宝"})}),i.jsx("td",{className:"p-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-mono text-xs",children:B.account}),i.jsx("p",{className:"text-gray-500 text-xs",children:B.name})]})}),i.jsx("td",{className:"p-4 text-gray-400",children:B.createdAt?new Date(B.createdAt).toLocaleString("zh-CN"):"-"}),i.jsx("td",{className:"p-4",children:U(B.status)}),i.jsx("td",{className:"p-4 text-right",children:B.status==="pending"&&i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsxs(re,{size:"sm",onClick:()=>L(B.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Eb,{className:"w-4 h-4 mr-1"}),"通过"]}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>H(B.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[i.jsx(PN,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},B.id))})]})}),t==="withdrawals"&&i.jsx(Zr,{page:M,totalPages:he,total:I,pageSize:F,onPageChange:D,onPageSizeChange:B=>{R(B),D(1)}})]})})]})]}),i.jsx(Qt,{open:!!X,onOpenChange:B=>!B&&q(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:"订单退款"})}),X&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",X.orderSn||X.id]}),i.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof X.amount=="number"?X.amount.toFixed(2):parseFloat(String(X.amount||"0")).toFixed(2)]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),i.jsx("div",{className:"form-input",children:i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:Z,onChange:B=>_(B.target.value)})})]}),i.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>q(null),disabled:$,children:"取消"}),i.jsx(re,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:ue,disabled:$,children:$?"退款中...":"确认退款"})]})]})}),t==="settings"&&i.jsx("div",{className:"-mx-8 -mt-6",children:i.jsx(vk,{embedded:!0})})]})}function kP(){const[t,e]=b.useState([]),[n,r]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[s,a]=b.useState(!0),[o,c]=b.useState(null),[u,h]=b.useState("all"),[f,m]=b.useState(1),[g,y]=b.useState(10),[v,j]=b.useState(0),[w,k]=b.useState(null);async function E(){var R,I,A,O,W,X,q;a(!0),c(null);try{const Z=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),_=await Be(`/api/admin/withdrawals?${Z}`);if(_!=null&&_.success){const $=_.withdrawals||[];e($),j(_.total??((R=_.stats)==null?void 0:R.total)??$.length),r({total:((I=_.stats)==null?void 0:I.total)??_.total??$.length,pendingCount:((A=_.stats)==null?void 0:A.pendingCount)??0,pendingAmount:((O=_.stats)==null?void 0:O.pendingAmount)??0,successCount:((W=_.stats)==null?void 0:W.successCount)??0,successAmount:((X=_.stats)==null?void 0:X.successAmount)??0,failedCount:((q=_.stats)==null?void 0:q.failedCount)??0})}else c("加载提现记录失败")}catch(Z){console.error("Load withdrawals error:",Z),c("加载失败,请检查网络后重试")}finally{a(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{E()},[u,f,g]);const C=Math.ceil(v/g)||1;async function M(R){const I=t.find(A=>A.id===R);if(I!=null&&I.userCommissionInfo&&I.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${I.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。
确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(R);try{const A=await Rt("/api/admin/withdrawals",{id:R,action:"approve"});A!=null&&A.success?E():alert("操作失败: "+((A==null?void 0:A.error)??""))}catch{alert("操作失败")}finally{k(null)}}async function D(R){const I=prompt("请输入拒绝原因(将返还用户余额):");if(I){k(R);try{const A=await Rt("/api/admin/withdrawals",{id:R,action:"reject",errorMessage:I});A!=null&&A.success?E():alert("操作失败: "+((A==null?void 0:A.error)??""))}catch{alert("操作失败")}finally{k(null)}}}function F(R){switch(R){case"pending":return i.jsx(Fe,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return i.jsx(Fe,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return i.jsx(Fe,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return i.jsx(Fe,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return i.jsx(Fe,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return i.jsx(Fe,{className:"bg-gray-500/20 text-gray-400 border-0",children:R})}}return i.jsxs("div",{className:"p-8 w-full",children:[o&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:o}),i.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),i.jsxs("div",{className:"flex justify-between items-start mb-8",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),i.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),i.jsxs(re,{variant:"outline",onClick:E,disabled:s,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${s?"animate-spin":""}`}),"刷新"]})]}),i.jsx(Ee,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:i.jsx(Te,{className:"p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Vu,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),i.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[i.jsxs("p",{children:["• ",i.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",i.jsx("span",{className:"text-white font-medium",children:"90%"})]}),i.jsxs("p",{children:["• ",i.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),i.jsxs("p",{children:["• ",i.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),i.jsxs("p",{children:["• ",i.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),i.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),i.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),i.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),i.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),i.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsxs(Te,{className:"p-4 text-center",children:[i.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),i.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),i.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(R=>i.jsx(re,{variant:u===R?"default":"outline",size:"sm",onClick:()=>h(R),className:u===R?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:R==="all"?"全部":R==="pending"?"待处理":R==="success"?"已完成":"已拒绝"},R))}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:s?i.jsxs("div",{className:"flex items-center justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Jo,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),i.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[i.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),i.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),i.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(R=>i.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[i.jsx("td",{className:"p-4 text-gray-400",children:new Date(R.createdAt??"").toLocaleString()}),i.jsx("td",{className:"p-4",children:i.jsxs("div",{className:"flex items-center gap-2",children:[R.userAvatar?i.jsx("img",{src:R.userAvatar,alt:R.userName??"",className:"w-8 h-8 rounded-full object-cover"}):i.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(R.userName??"?").charAt(0)}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-white",children:R.userName??"未知"}),i.jsx("p",{className:"text-xs text-gray-500",children:R.userPhone??R.referralCode??(R.userId??"").slice(0,10)})]})]})}),i.jsx("td",{className:"p-4",children:i.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(R.amount).toFixed(2)]})}),i.jsx("td",{className:"p-4",children:R.userCommissionInfo?i.jsxs("div",{className:"text-xs space-y-1",children:[i.jsxs("div",{className:"flex justify-between gap-4",children:[i.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),i.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",R.userCommissionInfo.totalCommission.toFixed(2)]})]}),i.jsxs("div",{className:"flex justify-between gap-4",children:[i.jsx("span",{className:"text-gray-500",children:"已提现:"}),i.jsxs("span",{className:"text-gray-400",children:["¥",R.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),i.jsxs("div",{className:"flex justify-between gap-4",children:[i.jsx("span",{className:"text-gray-500",children:"待审核:"}),i.jsxs("span",{className:"text-orange-400",children:["¥",R.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),i.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[i.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),i.jsxs("span",{className:R.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",R.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):i.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),i.jsxs("td",{className:"p-4",children:[F(R.status),R.errorMessage&&i.jsx("p",{className:"text-xs text-red-400 mt-1",children:R.errorMessage})]}),i.jsx("td",{className:"p-4 text-gray-400",children:R.processedAt?new Date(R.processedAt).toLocaleString():"-"}),i.jsx("td",{className:"p-4 text-gray-400",children:R.userConfirmedAt?i.jsxs("span",{className:"text-green-400",title:R.userConfirmedAt,children:["已确认 ",new Date(R.userConfirmedAt).toLocaleString()]}):"-"}),i.jsxs("td",{className:"p-4 text-right",children:[(R.status==="pending"||R.status==="pending_confirm")&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsxs(re,{size:"sm",onClick:()=>M(R.id),disabled:w===R.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[i.jsx(Wh,{className:"w-4 h-4 mr-1"}),"批准"]}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>D(R.id),disabled:w===R.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(R.status==="success"||R.status==="completed")&&R.transactionId&&i.jsx("span",{className:"text-xs text-gray-500 font-mono",children:R.transactionId})]})]},R.id))})]})}),i.jsx(Zr,{page:f,totalPages:C,total:v,pageSize:g,onPageChange:m,onPageSizeChange:R=>{y(R),m(1)}})]})})})]})}var Sm={exports:{}},Cm={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Qb;function SP(){if(Qb)return Cm;Qb=1;var t=$c();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),v=r({inst:{value:y,getSnapshot:g}}),j=v[0].inst,w=v[1];return a(function(){j.value=y,j.getSnapshot=g,u(j)&&w({inst:j})},[m,y,g]),s(function(){return u(j)&&w({inst:j}),m(function(){u(j)&&w({inst:j})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Cm.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Cm}var Xb;function bk(){return Xb||(Xb=1,Sm.exports=SP()),Sm.exports}var wk=bk();function An(t){this.content=t}An.prototype={constructor:An,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),a=r.content.slice();return s==-1?a.push(n||t,e):(a[s+1]=e,n&&(a[s]=n)),new An(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new An(n)},addToStart:function(t,e){return new An([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new An(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),a=r.find(t);return s.splice(a==-1?s.length:a,0,e,n),new An(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=An.from(t),t.size?new An(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=An.from(t),t.size?new An(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=An.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};An.from=function(t){if(t instanceof An)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new An(e)};function Nk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),a=e.child(r);if(s==a){n+=s.nodeSize;continue}if(!s.sameMarkup(a))return n;if(s.isText&&s.text!=a.text){for(let o=0;s.text[o]==a.text[o];o++)n++;return n}if(s.content.size||a.content.size){let o=Nk(s.content,a.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function jk(t,e,n,r){for(let s=t.childCount,a=e.childCount;;){if(s==0||a==0)return s==a?null:{a:n,b:r};let o=t.child(--s),c=e.child(--a),u=o.nodeSize;if(o==c){n-=u,r-=u;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let h=0,f=Math.min(o.text.length,c.text.length);for(;h<f&&o.text[o.text.length-h-1]==c.text[c.text.length-h-1];)h++,n--,r--;return{a:n,b:r}}if(o.content.size||c.content.size){let h=jk(o.content,c.content,n-1,r-1);if(h)return h}n-=u,r-=u}}class pe{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,a){for(let o=0,c=0;c<n;o++){let u=this.content[o],h=c+u.nodeSize;if(h>e&&r(u,s+c,a||null,o)!==!1&&u.content.size){let f=c+1;u.nodesBetween(Math.max(0,e-f),Math.min(u.content.size,n-f),r,s+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let a="",o=!0;return this.nodesBetween(e,n,(c,u)=>{let h=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?s?typeof s=="function"?s(c):s:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&h||c.isTextblock)&&r&&(o?o=!1:a+=r),a+=h},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)s.push(e.content[a]);return new pe(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let a=0,o=0;o<n;a++){let c=this.content[a],u=o+c.nodeSize;u>e&&((o<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),r.push(c),s+=c.nodeSize),o=u}return new pe(r,s)}cutByIndex(e,n){return e==n?pe.empty:e==0&&n==this.content.length?this:new pe(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new pe(s,a)}addToStart(e){return new pe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new pe(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Nk(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jk(this,e,n,r)}findIndex(e){if(e==0)return fu(0,e);if(e==this.size)return fu(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),a=r+s.nodeSize;if(a>=e)return a==e?fu(n+1,a):fu(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return pe.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new pe(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return pe.empty;let n,r=0;for(let s=0;s<e.length;s++){let a=e[s];r+=a.nodeSize,s&&a.isText&&e[s-1].sameMarkup(a)?(n||(n=e.slice(0,s)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new pe(n||e,r)}static from(e){if(!e)return pe.empty;if(e instanceof pe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new pe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}pe.empty=new pe([],0);const Em={index:0,offset:0};function fu(t,e){return Em.index=t,Em.offset=e,Em}function Gu(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Gu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Gu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Nt=class Cg{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let a=e[s];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,s));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Gu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Cg.none;if(e instanceof Cg)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Nt.none=[];class Ju extends Error{}class Me{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Sk(this.content,e+this.openStart,n);return r&&new Me(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Me(kk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Me.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Me(pe.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)s++;return new Me(e,r,s)}}Me.empty=new Me(pe.empty,0,0);function kk(t,e,n){let{index:r,offset:s}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(s==e||a.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(kk(a.content,e-s-1,n-s-1)))}function Sk(t,e,n,r){let{index:s,offset:a}=t.findIndex(e),o=t.maybeChild(s);if(a==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Sk(o.content,e-a-1,n,o);return c&&t.replaceChild(s,o.copy(c))}function CP(t,e,n){if(n.openStart>t.depth)throw new Ju("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ju("Inconsistent open depths");return Ck(t,e,n,0)}function Ck(t,e,n,r){let s=t.index(r),a=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=Ck(t,e,n,r+1);return a.copy(a.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,c=o.content;return _a(o,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:o,end:c}=EP(n,t);return _a(a,Tk(t,o,c,e,r))}else return _a(a,Yu(t,e,r))}function Ek(t,e){if(!e.type.compatibleContent(t.type))throw new Ju("Cannot join "+e.type.name+" onto "+t.type.name)}function Eg(t,e,n){let r=t.node(n);return Ek(r,e.node(n)),r}function La(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function dc(t,e,n,r){let s=(e||t).node(n),a=0,o=e?e.index(n):s.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(La(t.nodeAfter,r),a++));for(let c=a;c<o;c++)La(s.child(c),r);e&&e.depth==n&&e.textOffset&&La(e.nodeBefore,r)}function _a(t,e){return t.type.checkContent(e),t.copy(e)}function Tk(t,e,n,r,s){let a=t.depth>s&&Eg(t,e,s+1),o=r.depth>s&&Eg(n,r,s+1),c=[];return dc(null,t,s,c),a&&o&&e.index(s)==n.index(s)?(Ek(a,o),La(_a(a,Tk(t,e,n,r,s+1)),c)):(a&&La(_a(a,Yu(t,e,s+1)),c),dc(e,n,s,c),o&&La(_a(o,Yu(n,r,s+1)),c)),dc(r,null,s,c),new pe(c)}function Yu(t,e,n){let r=[];if(dc(null,t,n,r),t.depth>n){let s=Eg(t,e,n+1);La(_a(s,Yu(t,e,n+1)),r)}return dc(e,null,n,r),new pe(r)}function EP(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)s=e.node(a).copy(pe.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Cc{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)s+=r.child(a).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Nt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let c=r;r=s,s=c}let a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!s||!a[o].isInSet(s.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!s||!r[a].isInSet(s.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Qu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,a=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(a),h=a-u;if(r.push(o,c,s+u),!h||(o=o.child(c),o.isText))break;a=h-1,s+=u+1}return new Cc(n,r,a)}static resolveCached(e,n){let r=Zb.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else Zb.set(e,r=new TP);let s=r.elts[r.i]=Cc.resolve(e,n);return r.i=(r.i+1)%MP,s}}class TP{constructor(){this.elts=[],this.i=0}}const MP=12,Zb=new WeakMap;class Qu{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const AP=Object.create(null);let Js=class Tg{constructor(e,n,r,s=Nt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||pe.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Gu(this.attrs,n||e.defaultAttrs||AP)&&Nt.sameSet(this.marks,r||Nt.none)}copy(e=null){return e==this.content?this:new Tg(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Tg(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Me.empty;let s=this.resolve(e),a=this.resolve(n),o=r?0:s.sharedDepth(n),c=s.start(o),h=s.node(o).content.cut(s.pos-c,a.pos-c);return new Me(h,s.depth-o,a.depth-o)}replace(e,n,r){return CP(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Cc.resolveCached(this,e)}resolveNoCache(e){return Cc.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Mk(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=pe.empty,s=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,a),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=s;u<a;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Nt.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Nt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=pe.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,s,r);return a.type.checkAttrs(a.attrs),a}};Js.prototype.text=void 0;class Xu extends Js{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mk(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Xu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Xu(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Mk(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ha{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new RP(e,n);if(r.next==null)return Ha.empty;let s=Ak(r);r.next&&r.err("Unexpected trailing text");let a=zP(_P(s));return $P(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let a=n;s&&a<r;a++)s=s.matchType(e.child(a).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function a(o,c){let u=o.matchFragment(e,r);if(u&&(!n||u.validEnd))return pe.from(c.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:f,next:m}=o.next[h];if(!(f.isText||f.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let g=a(m,c.concat(f));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),a=s.match;if(a.matchType(e)){let o=[];for(let c=s;c.type;c=c.via)o.push(c.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:c,next:u}=a.next[o];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!s.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:s}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let a=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
`)}}Ha.empty=new Ha(!0);class RP{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ak(t){let e=[];do e.push(IP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function IP(t){let e=[];do e.push(PP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function PP(t){let e=LP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=OP(t,e);else break;return e}function e1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function OP(t,e){let n=e1(t),r=n;return t.eat(",")&&(t.next!="}"?r=e1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function DP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let a in n){let o=n[a];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function LP(t){if(t.eat("(")){let e=Ak(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=DP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function _P(t){let e=[[]];return s(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,c,u){let h={term:u,to:c};return e[o].push(h),h}function s(o,c){o.forEach(u=>u.to=c)}function a(o,c){if(o.type=="choice")return o.exprs.reduce((u,h)=>u.concat(a(h,c)),[]);if(o.type=="seq")for(let u=0;;u++){let h=a(o.exprs[u],c);if(u==o.exprs.length-1)return h;s(h,c=n())}else if(o.type=="star"){let u=n();return r(c,u),s(a(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return s(a(o.expr,c),u),s(a(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(c)].concat(a(o.expr,c));if(o.type=="range"){let u=c;for(let h=0;h<o.min;h++){let f=n();s(a(o.expr,u),f),u=f}if(o.max==-1)s(a(o.expr,u),u);else for(let h=o.min;h<o.max;h++){let f=n();r(u,f),s(a(o.expr,u),f),u=f}return[r(u)]}else{if(o.type=="name")return[r(c,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Rk(t,e){return e-t}function t1(t,e){let n=[];return r(e),n.sort(Rk);function r(s){let a=t[s];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(s);for(let o=0;o<a.length;o++){let{term:c,to:u}=a[o];!c&&n.indexOf(u)==-1&&r(u)}}}function zP(t){let e=Object.create(null);return n(t1(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f<s.length;f++)s[f][0]==c&&(h=s[f][1]);t1(t,u).forEach(f=>{h||s.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let a=e[r.join(",")]=new Ha(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let c=s[o][1].sort(Rk);a.next.push({type:s[o][0],next:e[c.join(",")]||n(c)})}return a}}function $P(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],a=!s.validEnd,o=[];for(let c=0;c<s.next.length;c++){let{type:u,next:h}=s.next[c];o.push(u.name),a&&!(u.isText||u.hasRequiredAttrs())&&(a=!1),r.indexOf(h)==-1&&r.push(h)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ik(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Pk(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let a=t[r];if(a.hasDefault)s=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function Ok(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let a=t[s];a.validate&&a.validate(e[s])}}function Dk(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new BP(t,r,e[r]);return n}let n1=class Lk{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Dk(e,r.attrs),this.defaultAttrs=Ik(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ha.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Pk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Js(this,this.computeAttrs(e),pe.from(n),Nt.setFrom(r))}createChecked(e=null,n,r){return n=pe.from(n),this.checkContent(n),new Js(this,this.computeAttrs(e),n,Nt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=pe.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),a=s&&s.fillBefore(pe.empty,!0);return a?new Js(this,e,n.append(a),Nt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ok(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Nt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Lk(a,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function FP(t,e,n){let r=n.split("|");return s=>{let a=s===null?"null":typeof s;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class BP{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?FP(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Xh{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=Dk(e,s.attrs),this.excluded=null;let a=Ik(this.attrs);this.instance=a?new Nt(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Nt(this,Pk(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((a,o)=>r[a]=new Xh(a,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Ok(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _k{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=An.from(e.nodes),n.marks=An.from(e.marks||{}),this.nodes=n1.compile(this.spec.nodes,this),this.marks=Xh.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let a=this.nodes[s],o=a.spec.content||"",c=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=Ha.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=c=="_"?null:c?r1(this,c.split(" ")):c==""||!a.inlineContent?[]:null}for(let s in this.marks){let a=this.marks[s],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:r1(this,o.split(" "))}this.nodeFromJSON=s=>Js.fromJSON(this,s),this.markFromJSON=s=>Nt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof n1){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Xu(r,r.defaultAttrs,e,Nt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function r1(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],a=t.marks[s],o=a;if(a)n.push(a);else for(let c in t.marks){let u=t.marks[c];(s=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function VP(t){return t.tag!=null}function HP(t){return t.style!=null}class qi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(VP(s))this.tags.push(s);else if(HP(s)){let a=/[^=]*/.exec(s.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let a=e.nodes[s.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new i1(this,n,!1);return r.addAll(e,Nt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new i1(this,n,!0);return r.addAll(e,Nt.none,n.from,n.to),Me.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let a=this.tags[s];if(KP(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,s){for(let a=s?this.styles.indexOf(s)+1:0;a<this.styles.length;a++){let o=this.styles[a],c=o.style;if(!(c.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let a=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let c=n[o];if((c.priority==null?50:c.priority)<a)break}n.splice(o,0,s)}for(let s in e.marks){let a=e.marks[s].spec.parseDOM;a&&a.forEach(o=>{r(o=a1(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let a=e.nodes[s].spec.parseDOM;a&&a.forEach(o=>{r(o=a1(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new qi(e,qi.schemaRules(e)))}}const zk={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},WP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$k={ol:!0,ul:!0},Ec=1,Mg=2,uc=4;function s1(t,e,n){return e!=null?(e?Ec:0)|(e==="full"?Mg:0):t&&t.whitespace=="pre"?Ec|Mg:n&~uc}class pu{constructor(e,n,r,s,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Nt.none,this.match=a||(o&uc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(pe.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ec)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-s[0].length))}}let n=pe.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(pe.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!zk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class i1{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,a,o=s1(null,n.preserveWhitespace,0)|(r?uc:0);s?a=new pu(s.type,s.attrs,Nt.none,!0,n.topMatch||s.type.contentMatch,o):r?a=new pu(null,null,Nt.none,!0,null,o):a=new pu(e.schema.topNodeType,null,Nt.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,a=s.options&Mg?"full":this.localPreserveWS||(s.options&Ec)>0,{schema:o}=this.parser;if(a==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let u=0;u<c.length;u++)u&&this.insertNode(o.linebreakReplacement.create(),n,!0),c[u]&&this.insertNode(o.text(c[u]),n,!/\S/.test(c[u]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let c=s.content[s.content.length-1],u=e.previousSibling;(!c||u&&u.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),c;$k.hasOwnProperty(o)&&this.parser.normalizeLists&&UP(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:WP.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let h,f=this.needsBlock;if(zk.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),h=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=u&&u.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),h&&this.sync(a),this.needsBlock=f}else{let h=this.readStyles(e,n);h&&this.addElementByRule(e,u,h,u.consuming===!1?c:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let a=this.parser.matchedStyles[s],o=r.getPropertyValue(a);if(o)for(let c=void 0;;){let u=this.parser.matchStyle(a,o,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(h=>!u.clearMark(h)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,r,s){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(a=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}a&&this.sync(c)&&this.open--}addAll(e,n,r,s){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=s==null?null:e.childNodes[s];o!=c;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let s,a;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!s||s.length>h.length+c)&&(s=h,a=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!s)return null;this.sync(a);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=Nt.none;for(let c of s.concat(e.marks))(a.type?a.type.allowsMarkType(c.type):o1(c.type,e.type))&&(o=c.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,s)),a}enterInner(e,n,r,s=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let c=s1(e,a,o.options);o.options&uc&&o.content.length==0&&(c|=uc);let u=Nt.none;return r=r.filter(h=>(o.type?o.type.allowsMarkType(h.type):o1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new pu(e,n,u,s,null,c)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ec)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(s?0:1),o=(c,u)=>{for(;c>=0;c--){let h=n[c];if(h==""){if(c==n.length-1||c==0)continue;for(;u>=a;u--)if(o(c-1,u))return!0;return!1}else{let f=u>0||u==0&&s?this.nodes[u].type:r&&u>=a?r.node(u-a).type:null;if(!f||f.name!=h&&!f.isInGroup(h))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function UP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&$k.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function KP(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function a1(t){let e={};for(let n in t)e[n]=t[n];return e}function o1(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let a=[],o=c=>{a.push(c);for(let u=0;u<c.edgeCount;u++){let{type:h,next:f}=c.edge(u);if(h==e||a.indexOf(f)<0&&o(f))return!0}};if(o(s.contentMatch))return!0}}class Za{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Tm(n).createDocumentFragment());let s=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let c=0,u=0;for(;c<a.length&&u<o.marks.length;){let h=o.marks[u];if(!this.marks[h.type.name]){u++;continue}if(!h.eq(a[c][0])||h.type.spec.spanning===!1)break;c++,u++}for(;c<a.length;)s=a.pop()[1];for(;u<o.marks.length;){let h=o.marks[u++],f=this.serializeMark(h,o.isInline,n);f&&(a.push([h,s]),s.appendChild(f.dom),s=f.contentDOM||f.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Iu(Tm(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let a=this.serializeMark(e.marks[s],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Iu(Tm(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Iu(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Za(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=l1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return l1(e.marks)}}function l1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Tm(t){return t.document||window.document}const c1=new WeakMap;function qP(t){let e=c1.get(t);return e===void 0&&c1.set(t,e=GP(t)),e}function GP(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Iu(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],a;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=qP(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let c,u=n?t.createElementNS(n,s):t.createElement(s),h=e[1],f=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){f=2;for(let m in h)if(h[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),h[m]):m=="style"&&u.style?u.style.cssText=h[m]:u.setAttribute(m,h[m])}}for(let m=f;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:v}=Iu(t,g,n,r);if(u.appendChild(y),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const Fk=65535,Bk=Math.pow(2,16);function JP(t,e){return t+e*Bk}function d1(t){return t&Fk}function YP(t){return(t-(t&Fk))/Bk}const Vk=1,Hk=2,Pu=4,Wk=8;class Ag{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Wk)>0}get deletedBefore(){return(this.delInfo&(Vk|Pu))>0}get deletedAfter(){return(this.delInfo&(Hk|Pu))>0}get deletedAcross(){return(this.delInfo&Pu)>0}}class Nr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Nr.empty)return Nr.empty}recover(e){let n=0,r=d1(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+YP(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,a=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>e)break;let h=this.ranges[c+a],f=this.ranges[c+o],m=u+h;if(e<=m){let g=h?e==u?-1:e==m?1:n:n,y=u+s+(g<0?0:f);if(r)return y;let v=e==(n<0?u:m)?null:JP(c/3,e-u),j=e==u?Hk:e==m?Vk:Pu;return(n<0?e!=u:e!=m)&&(j|=Wk),new Ag(y,j,v)}s+=f-h}return r?e+s:new Ag(e+s,0,null)}touches(e,n){let r=0,s=d1(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let h=this.ranges[c+a],f=u+h;if(e<=f&&c==s*3)return!0;r+=this.ranges[c+o]-h}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,a=0;s<this.ranges.length;s+=3){let o=this.ranges[s],c=o-(this.inverted?a:0),u=o+(this.inverted?0:a),h=this.ranges[s+n],f=this.ranges[s+r];e(c,c+h,u,u+f),a+=f-h}}invert(){return new Nr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Nr.empty:new Nr(e<0?[0,-e,0]:[0,0,e])}}Nr.empty=new Nr([]);class Tc{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Tc(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Tc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let a=this.from;a<this.to;a++){let o=this._maps[a],c=o.mapResult(e,n);if(c.recover!=null){let u=this.getMirror(a);if(u!=null&&u>a&&u<this.to){a=u,e=this._maps[u].recover(c.recover);continue}}s|=c.delInfo,e=c.pos}return r?e:new Ag(e,s,null)}}const Mm=Object.create(null);class Un{getMap(){return Nr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Mm[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Mm)throw new RangeError("Duplicate use of step JSON ID "+e);return Mm[e]=n,n.prototype.jsonID=e,n}}class on{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new on(e,null)}static fail(e){return new on(null,e)}static fromReplace(e,n,r,s){try{return on.ok(e.replace(n,r,s))}catch(a){if(a instanceof Ju)return on.fail(a.message);throw a}}}function Bx(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let a=t.child(s);a.content.size&&(a=a.copy(Bx(a.content,e,a))),a.isInline&&(a=e(a,n,s)),r.push(a)}return pe.fromArray(r)}class Bi extends Un{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),a=new Me(Bx(n.content,(o,c)=>!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,a)}invert(){return new Xr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Bi(n.pos,r.pos,this.mark)}merge(e){return e instanceof Bi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Bi(n.from,n.to,e.markFromJSON(n.mark))}}Un.jsonID("addMark",Bi);class Xr extends Un{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Me(Bx(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,r)}invert(){return new Bi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xr(n.from,n.to,e.markFromJSON(n.mark))}}Un.jsonID("removeMark",Xr);class Vi extends Un{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Me(pe.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Vi(this.pos,n.marks[s]);return new Vi(this.pos,this.mark)}}return new Wa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Vi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Vi(n.pos,e.markFromJSON(n.mark))}}Un.jsonID("addNodeMark",Vi);class Wa extends Un{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Me(pe.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Vi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Wa(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Wa(n.pos,e.markFromJSON(n.mark))}}Un.jsonID("removeNodeMark",Wa);class wn extends Un{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Rg(e,this.from,this.to)?on.fail("Structure replace would overwrite content"):on.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Nr([this.from,this.to-this.from,this.slice.size])}invert(e){return new wn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new wn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof wn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Me.empty:new Me(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new wn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Me.empty:new Me(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new wn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new wn(n.from,n.to,Me.fromJSON(e,n.slice),!!n.structure)}}Un.jsonID("replace",wn);class jn extends Un{constructor(e,n,r,s,a,o,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=a,this.insert=o,this.structure=c}apply(e){if(this.structure&&(Rg(e,this.from,this.gapFrom)||Rg(e,this.gapTo,this.to)))return on.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return on.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?on.fromReplace(e,this.from,this.to,r):on.fail("Content does not fit in gap")}getMap(){return new Nr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new jn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||a>r.pos?null:new jn(n.pos,r.pos,s,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new jn(n.from,n.to,n.gapFrom,n.gapTo,Me.fromJSON(e,n.slice),n.insert,!!n.structure)}}Un.jsonID("replaceAround",jn);function Rg(t,e,n){let r=t.resolve(e),s=n-e,a=r.depth;for(;s>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,s--;if(s>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function QP(t,e,n,r){let s=[],a=[],o,c;t.doc.nodesBetween(e,n,(u,h,f)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&f.type.allowsMarkType(r.type)){let g=Math.max(h,e),y=Math.min(h+u.nodeSize,n),v=r.addToSet(m);for(let j=0;j<m.length;j++)m[j].isInSet(v)||(o&&o.to==g&&o.mark.eq(m[j])?o.to=y:s.push(o=new Xr(g,y,m[j])));c&&c.to==g?c.to=y:a.push(c=new Bi(g,y,r))}}),s.forEach(u=>t.step(u)),a.forEach(u=>t.step(u))}function XP(t,e,n,r){let s=[],a=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;a++;let u=null;if(r instanceof Xh){let h=o.marks,f;for(;f=r.isInSet(h);)(u||(u=[])).push(f),h=f.removeFromSet(h)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let h=Math.min(c+o.nodeSize,n);for(let f=0;f<u.length;f++){let m=u[f],g;for(let y=0;y<s.length;y++){let v=s[y];v.step==a-1&&m.eq(s[y].style)&&(g=v)}g?(g.to=h,g.step=a):s.push({style:m,from:Math.max(c,e),to:h,step:a})}}}),s.forEach(o=>t.step(new Xr(o.from,o.to,o.style)))}function Vx(t,e,n,r=n.contentMatch,s=!0){let a=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u<a.childCount;u++){let h=a.child(u),f=c+h.nodeSize,m=r.matchType(h.type);if(!m)o.push(new wn(c,f,Me.empty));else{r=m;for(let g=0;g<h.marks.length;g++)n.allowsMarkType(h.marks[g].type)||t.step(new Xr(c,f,h.marks[g]));if(s&&h.isText&&n.whitespace!="pre"){let g,y=/\r?\n|\r/g,v;for(;g=y.exec(h.text);)v||(v=new Me(pe.from(n.schema.text(" ",n.allowedMarks(h.marks))),0,0)),o.push(new wn(c+g.index,c+g.index+g[0].length,v))}}c=f}if(!r.validEnd){let u=r.fillBefore(pe.empty,!0);t.replace(c,c,new Me(u,0,0))}for(let u=o.length-1;u>=0;u--)t.step(o[u])}function ZP(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hl(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,a=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+s,u=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(c,u,n))return r;if(r==0||o.type.spec.isolating||!ZP(o,c,u))break;c&&(s=1),u<o.childCount&&(a=1)}return null}function eO(t,e,n){let{$from:r,$to:s,depth:a}=e,o=r.before(a+1),c=s.after(a+1),u=o,h=c,f=pe.empty,m=0;for(let v=a,j=!1;v>n;v--)j||r.index(v)>0?(j=!0,f=pe.from(r.node(v).copy(f)),m++):u--;let g=pe.empty,y=0;for(let v=a,j=!1;v>n;v--)j||s.after(v+1)<s.end(v)?(j=!0,g=pe.from(s.node(v).copy(g)),y++):h++;t.step(new jn(u,h,o,c,new Me(f.append(g),m,y),f.size-m,!0))}function Hx(t,e,n=null,r=t){let s=tO(t,e),a=s&&nO(r,e);return a?s.map(u1).concat({type:e,attrs:n}).concat(a.map(u1)):null}function u1(t){return{type:t,attrs:null}}function tO(t,e){let{parent:n,startIndex:r,endIndex:s}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,s,o)?a:null}function nO(t,e){let{parent:n,startIndex:r,endIndex:s}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.type);if(!o)return null;let u=(o.length?o[o.length-1]:e).contentMatch;for(let h=r;u&&h<s;h++)u=u.matchType(n.child(h).type);return!u||!u.validEnd?null:o}function rO(t,e,n){let r=pe.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pe.from(n[o].type.create(n[o].attrs,r))}let s=e.start,a=e.end;t.step(new jn(s,a,s,a,new Me(r,0,0),n.length,!0))}function sO(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let u=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,u)&&iO(t.doc,t.mapping.slice(a).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!v?h=!1:!y&&v&&(h=!0)}h===!1&&Kk(t,o,c,a),Vx(t,t.mapping.slice(a).map(c,1),r,void 0,h===null);let f=t.mapping.slice(a),m=f.map(c,1),g=f.map(c+o.nodeSize,1);return t.step(new jn(m,g,m+1,g-1,new Me(pe.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&Uk(t,o,c,a),!1}})}function Uk(t,e,n,r){e.forEach((s,a)=>{if(s.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(s.text);){let u=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function Kk(t,e,n,r){e.forEach((s,a)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
`))}})}function iO(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function aO(t,e,n,r,s){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,s||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new jn(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Me(pe.from(o),0,0),1,!0))}function Ys(t,e,n=1,r){let s=t.resolve(e),a=s.depth-n,o=r&&r[r.length-1]||s.parent;if(a<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let h=s.depth-1,f=n-2;h>a;h--,f--){let m=s.node(h),g=s.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),v=r&&r[f+1];v&&(y=y.replaceChild(0,v.type.create(v.attrs)));let j=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=s.indexAfter(a),u=r&&r[0];return s.node(a).canReplaceWith(c,c,u?u.type:s.node(a+1).type)}function oO(t,e,n=1,r){let s=t.doc.resolve(e),a=pe.empty,o=pe.empty;for(let c=s.depth,u=s.depth-n,h=n-1;c>u;c--,h--){a=pe.from(s.node(c).copy(a));let f=r&&r[h];o=pe.from(f?f.type.create(f.attrs,o):s.node(c).copy(o))}t.step(new wn(e,e,new Me(a.append(o),n,n),!0))}function aa(t,e){let n=t.resolve(e),r=n.index();return qk(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function lO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let a=e.child(s),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function qk(t,e){return!!(t&&e&&!t.isLeaf&&lO(t,e))}function Zh(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let a,o,c=r.index(s);if(s==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(s+1),c++,o=r.node(s).maybeChild(c)):(a=r.node(s).maybeChild(c-1),o=r.node(s+1)),a&&!a.isTextblock&&qk(a,o)&&r.node(s).canReplace(c,c+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function cO(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(s&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(s);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);Kk(t,f.node(),f.before(),c)}o.inlineContent&&Vx(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let u=t.mapping.slice(c),h=u.map(e-n);if(t.step(new wn(h,u.map(e+n,-1),Me.empty,!0)),r===!0){let f=t.doc.resolve(h);Uk(t,f.node(),f.before(),t.steps.length)}return t}function dO(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let a=r.index(s);if(r.node(s).canReplaceWith(a,a,n))return r.before(s+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}return null}function Gk(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let a=0;a<n.openStart;a++)s=s.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let o=r.depth;o>=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(c>0?1:0),h=r.node(o),f=!1;if(a==1)f=h.canReplace(u,u,s);else{let m=h.contentMatchAt(u).findWrapping(s.firstChild.type);f=m&&h.canReplaceWith(u,u,m[0])}if(f)return c==0?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function ef(t,e,n=e,r=Me.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),a=t.resolve(n);return Jk(s,a,r)?new wn(e,n,r):new uO(s,a,r).fit()}function Jk(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class uO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=pe.empty;for(let s=0;s<=e.depth;s++){let a=e.node(s);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=pe.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let a=this.placed,o=r.depth,c=s.depth;for(;o&&c&&a.childCount==1;)a=a.firstChild.content,o--,c--;let u=new Me(a,o,c);return e>-1?new jn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new wn(r.pos,s.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(s=0),a.type.spec.isolating&&s<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,a=null;r?(a=Am(this.unplaced.content,r-1).firstChild,s=a.content):s=this.unplaced.content;let o=s.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:h}=this.frontier[c],f,m=null;if(n==1&&(o?h.matchType(o.type)||(m=h.fillBefore(pe.from(o),!1)):a&&u.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:c,parent:a,inject:m};if(n==2&&o&&(f=h.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:a,wrap:f};if(a&&h.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Am(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Me(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Am(e,n);if(s.childCount<=1&&n>0){let a=e.size-n<=n+s.size;this.unplaced=new Me(nc(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Me(nc(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let j=0;j<a.length;j++)this.openFrontierNode(a[j]);let o=this.unplaced,c=r?r.content:o.content,u=o.openStart-e,h=0,f=[],{match:m,type:g}=this.frontier[n];if(s){for(let j=0;j<s.childCount;j++)f.push(s.child(j));m=m.matchFragment(s)}let y=c.size+e-(o.content.size-o.openEnd);for(;h<c.childCount;){let j=c.child(h),w=m.matchType(j.type);if(!w)break;h++,(h>1||u==0||j.content.size)&&(m=w,f.push(Yk(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let v=h==c.childCount;v||(y=-1),this.placed=rc(this.placed,n,pe.from(f)),this.frontier[n].match=m,v&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=c;j<y;j++){let k=w.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),w=k.content}this.unplaced=v?e==0?Me.empty:new Me(nc(o.content,e-1,1),e-1,y<0?o.openEnd:e-1):new Me(nc(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Rm(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Rm(e,n,s,r,a);if(o){for(let c=n-1;c>=0;c--){let{match:u,type:h}=this.frontier[c],f=Rm(e,c,h,u,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=rc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),a=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,a)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=rc(this.placed,this.depth,pe.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(pe.empty,!0);n.childCount&&(this.placed=rc(this.placed,this.frontier.length,n))}}function nc(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(nc(t.firstChild.content,e-1,n)))}function rc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(rc(t.lastChild.content,e-1,n)))}function Am(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Yk(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Yk(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(pe.empty,!0)))),t.copy(r)}function Rm(t,e,n,r,s){let a=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let c=r.fillBefore(a.content,!0,o);return c&&!hO(n,a.content,o)?c:null}function hO(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function fO(t){return t.spec.defining||t.spec.definingForContent}function pO(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),a=t.doc.resolve(n);if(Jk(s,a,r))return t.step(new wn(e,n,r));let o=Xk(s,a);o[o.length-1]==0&&o.pop();let c=-(s.depth+1);o.unshift(c);for(let g=s.depth,y=s.pos-1;g>0;g--,y--){let v=s.node(g).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(g)>-1?c=g:s.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(c),h=[],f=r.openStart;for(let g=r.content,y=0;;y++){let v=g.firstChild;if(h.push(v),y==r.openStart)break;g=v.content}for(let g=f-1;g>=0;g--){let y=h[g],v=fO(y.type);if(v&&!y.sameMarkup(s.node(Math.abs(c)-1)))f=g;else if(v||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+f+1)%(r.openStart+1),v=h[y];if(v)for(let j=0;j<o.length;j++){let w=o[(j+u)%o.length],k=!0;w<0&&(k=!1,w=-w);let E=s.node(w-1),C=s.index(w-1);if(E.canReplaceWith(C,C,v.type,v.marks))return t.replace(s.before(w),k?a.after(w):n,new Me(Qk(r.content,0,r.openStart,y),y,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=s.before(y),n=a.after(y))}}function Qk(t,e,n,r,s){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(Qk(a.content,e+1,n,r,a)))}if(e>r){let a=s.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(pe.empty,!0))}return t}function mO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=dO(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Me(pe.from(r),0,0))}function gO(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),a=Xk(r,s);for(let o=0;o<a.length;o++){let c=a[o],u=o==a.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),s.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),s.indexAfter(c-1))))return t.delete(r.before(c),s.after(c))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Xk(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let a=t.start(s);if(a<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(a==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==a-1)&&n.push(s)}return n}class Ko extends Un{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return on.fromReplace(e,this.pos,this.pos+1,new Me(pe.from(s),0,n.isLeaf?0:1))}getMap(){return Nr.empty}invert(e){return new Ko(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ko(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ko(n.pos,n.attr,n.value)}}Un.jsonID("attr",Ko);class Mc extends Un{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return on.ok(r)}getMap(){return Nr.empty}invert(e){return new Mc(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Mc(n.attr,n.value)}}Un.jsonID("docAttr",Mc);let Qo=class extends Error{};Qo=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Qo.prototype=Object.create(Error.prototype);Qo.prototype.constructor=Qo;Qo.prototype.name="TransformError";class Wx{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Tc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Qo(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((a,o,c,u)=>{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Me.empty){let s=ef(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Me(pe.from(r),0,0))}delete(e,n){return this.replace(e,n,Me.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return pO(this,e,n,r),this}replaceRangeWith(e,n,r){return mO(this,e,n,r),this}deleteRange(e,n){return gO(this,e,n),this}lift(e,n){return eO(this,e,n),this}join(e,n=1){return cO(this,e,n),this}wrap(e,n){return rO(this,e,n),this}setBlockType(e,n=e,r,s=null){return sO(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return aO(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Ko(e,n,r)),this}setDocAttribute(e,n){return this.step(new Mc(e,n)),this}addNodeMark(e,n){return this.step(new Vi(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Nt)n.isInSet(r.marks)&&this.step(new Wa(e,n));else{let s=r.marks,a,o=[];for(;a=n.isInSet(s);)o.push(new Wa(e,a)),s=a.removeFromSet(s);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return oO(this,e,n,r),this}addMark(e,n,r){return QP(this,e,n,r),this}removeMark(e,n,r){return XP(this,e,n,r),this}clearIncompatible(e,n,r){return Vx(this,e,n,r),this}}const Im=Object.create(null);class Ge{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Zk(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Me.empty){let r=n.content.lastChild,s=null;for(let c=0;c<n.openEnd;c++)s=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let c=0;c<o.length;c++){let{$from:u,$to:h}=o[c],f=e.mapping.slice(a);e.replaceRange(f.map(u.pos),f.map(h.pos),c?Me.empty:n),c==0&&p1(e,a,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:o,$to:c}=s[a],u=e.mapping.slice(r),h=u.map(o.pos),f=u.map(c.pos);a?e.deleteRange(h,f):(e.replaceRangeWith(h,f,n),p1(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new He(e):Do(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let a=e.depth-1;a>=0;a--){let o=n<0?Do(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Do(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new kr(e.node(0))}static atStart(e){return Do(e,e,0,0,1)||new kr(e)}static atEnd(e){return Do(e,e,e.content.size,e.childCount,-1)||new kr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Im[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Im)throw new RangeError("Duplicate use of selection JSON ID "+e);return Im[e]=n,n.prototype.jsonID=e,n}getBookmark(){return He.between(this.$anchor,this.$head).getBookmark()}}Ge.prototype.visible=!0;class Zk{constructor(e,n){this.$from=e,this.$to=n}}let h1=!1;function f1(t){!h1&&!t.parent.inlineContent&&(h1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class He extends Ge{constructor(e,n=e){f1(e),f1(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ge.near(r);let s=e.resolve(n.map(this.anchor));return new He(s.parent.inlineContent?s:r,r)}replace(e,n=Me.empty){if(super.replace(e,n),n==Me.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof He&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new tf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new He(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let a=Ge.findFrom(n,r,!0)||Ge.findFrom(n,-r,!0);if(a)n=a.$head;else return Ge.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ge.findFrom(e,-r,!0)||Ge.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new He(e,n)}}Ge.jsonID("text",He);class tf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new tf(e.map(this.anchor),e.map(this.head))}resolve(e){return He.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ve extends Ge{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),a=e.resolve(s);return r?Ge.near(a):new Ve(a)}content(){return new Me(pe.from(this.node),0,0)}eq(e){return e instanceof Ve&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ux(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ve(e.resolve(n.anchor))}static create(e,n){return new Ve(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ve.prototype.visible=!1;Ge.jsonID("node",Ve);class Ux{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new tf(r,r):new Ux(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ve.isSelectable(r)?new Ve(n):Ge.near(n)}}class kr extends Ge{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Me.empty){if(n==Me.empty){e.delete(0,e.doc.content.size);let r=Ge.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new kr(e)}map(e){return new kr(e)}eq(e){return e instanceof kr}getBookmark(){return xO}}Ge.jsonID("all",kr);const xO={map(){return this},resolve(t){return new kr(t)}};function Do(t,e,n,r,s,a=!1){if(e.inlineContent)return He.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let c=e.child(o);if(c.isAtom){if(!a&&Ve.isSelectable(c))return Ve.create(t,n-(s<0?c.nodeSize:0))}else{let u=Do(t,c,n+s,s<0?c.childCount:0,s,a);if(u)return u}n+=c.nodeSize*s}return null}function p1(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof wn||s instanceof jn))return;let a=t.mapping.maps[r],o;a.forEach((c,u,h,f)=>{o==null&&(o=f)}),t.setSelection(Ge.near(t.doc.resolve(o),n))}const m1=1,mu=2,g1=4;class yO extends Wx{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|m1)&~mu,this.storedMarks=null,this}get selectionSet(){return(this.updated&m1)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=mu,this}ensureMarks(e){return Nt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&mu)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~mu,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Nt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ge.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=g1,this}get scrolledIntoView(){return(this.updated&g1)>0}}function x1(t,e){return!e||!t?t:t.bind(e)}class sc{constructor(e,n,r){this.name=e,this.init=x1(n.init,r),this.apply=x1(n.apply,r)}}const vO=[new sc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new sc("selection",{init(t,e){return t.selection||Ge.atStart(e.doc)},apply(t){return t.selection}}),new sc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new sc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Pm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vO.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new sc(r.key,r.spec.state,r))})}}class Ho{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let a=!1;for(let o=0;o<this.config.plugins.length;o++){let c=this.config.plugins[o];if(c.spec.appendTransaction){let u=s?s[o].n:0,h=s?s[o].state:this,f=u<n.length&&c.spec.appendTransaction.call(c,u?n.slice(u):n,h,r);if(f&&r.filterTransaction(f,o)){if(f.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<o?{state:r,n:n.length}:{state:this,n:0})}n.push(f),r=r.applyInner(f),a=!0}s&&(s[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ho(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let a=r[s];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new yO(this)}static create(e){let n=new Pm(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ho(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Pm(this.schema,e.plugins),r=n.fields,s=new Ho(n);for(let a=0;a<r.length;a++){let o=r[a].name;s[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],a=s.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Pm(e.schema,e.plugins),a=new Ho(s);return s.fields.forEach(o=>{if(o.name=="doc")a.doc=Js.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Ge.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],h=u.spec.state;if(u.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){a[o.name]=h.fromJSON.call(u,e,n[c],a);return}}a[o.name]=o.init(e,a)}}),a}}function eS(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=eS(s,e,{})),n[r]=s}return n}class Ct{constructor(e){this.spec=e,this.props={},e.props&&eS(e.props,this,this.props),this.key=e.key?e.key.key:tS("plugin")}getState(e){return e[this.key]}}const Om=Object.create(null);function tS(t){return t in Om?t+"$"+ ++Om[t]:(Om[t]=0,t+"$")}class _t{constructor(e="key"){this.key=tS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Kx=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function nS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const rS=(t,e,n)=>{let r=nS(t,n);if(!r)return!1;let s=qx(r);if(!s){let o=r.blockRange(),c=o&&hl(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let a=s.nodeBefore;if(hS(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Xo(a,"end")||Ve.isSelectable(a)))for(let o=r.depth;;o--){let c=ef(t.doc,r.before(o),r.after(o),Me.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=t.tr.step(c);u.setSelection(Xo(a,"end")?Ge.findFrom(u.doc.resolve(u.mapping.map(s.pos,-1)),-1):Ve.create(u.doc,s.pos-a.nodeSize)),e(u.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-a.nodeSize,s.pos).scrollIntoView()),!0):!1},bO=(t,e,n)=>{let r=nS(t,n);if(!r)return!1;let s=qx(r);return s?sS(t,s,e):!1},wO=(t,e,n)=>{let r=aS(t,n);if(!r)return!1;let s=Gx(r);return s?sS(t,s,e):!1};function sS(t,e,n){let r=e.nodeBefore,s=r,a=e.pos-1;for(;!s.isTextblock;a--){if(s.type.spec.isolating)return!1;let f=s.lastChild;if(!f)return!1;s=f}let o=e.nodeAfter,c=o,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let f=c.firstChild;if(!f)return!1;c=f}let h=ef(t.doc,a,u,Me.empty);if(!h||h.from!=a||h instanceof wn&&h.slice.size>=u-a)return!1;if(n){let f=t.tr.step(h);f.setSelection(He.create(f.doc,a)),n(f.scrollIntoView())}return!0}function Xo(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const iS=(t,e,n)=>{let{$head:r,empty:s}=t.selection,a=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=qx(r)}let o=a&&a.nodeBefore;return!o||!Ve.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ve.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function qx(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function aS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const oS=(t,e,n)=>{let r=aS(t,n);if(!r)return!1;let s=Gx(r);if(!s)return!1;let a=s.nodeAfter;if(hS(t,s,e,1))return!0;if(r.parent.content.size==0&&(Xo(a,"start")||Ve.isSelectable(a))){let o=ef(t.doc,r.before(),r.after(),Me.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Xo(a,"start")?Ge.findFrom(c.doc.resolve(c.mapping.map(s.pos)),1):Ve.create(c.doc,c.mapping.map(s.pos))),e(c.scrollIntoView())}return!0}}return a.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+a.nodeSize).scrollIntoView()),!0):!1},lS=(t,e,n)=>{let{$head:r,empty:s}=t.selection,a=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=Gx(r)}let o=a&&a.nodeAfter;return!o||!Ve.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ve.create(t.doc,a.pos)).scrollIntoView()),!0)};function Gx(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const NO=(t,e)=>{let n=t.selection,r=n instanceof Ve,s;if(r){if(n.node.isTextblock||!aa(t.doc,n.from))return!1;s=n.from}else if(s=Zh(t.doc,n.from,-1),s==null)return!1;if(e){let a=t.tr.join(s);r&&a.setSelection(Ve.create(a.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},jO=(t,e)=>{let n=t.selection,r;if(n instanceof Ve){if(n.node.isTextblock||!aa(t.doc,n.to))return!1;r=n.to}else if(r=Zh(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},kO=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),a=s&&hl(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)},cS=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function Jx(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const SO=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),a=n.indexAfter(-1),o=Jx(s.contentMatchAt(a));if(!o||!s.canReplaceWith(a,a,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(Ge.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},dS=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof kr||r.parent.inlineContent||s.parent.inlineContent)return!1;let a=Jx(s.parent.contentMatchAt(s.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,c=t.tr.insert(o,a.createAndFill());c.setSelection(He.create(c.doc,o+1)),e(c.scrollIntoView())}return!0},uS=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Ys(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),s=r&&hl(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function CO(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof Ve&&e.selection.node.isBlock)return!r.parentOffset||!Ys(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,c,u=!1,h=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),h=r.start(y)==r.pos-(r.depth-y),c=Jx(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),a.unshift(u&&c?{type:c}:null),o=y;break}else{if(y==1)return!1;a.unshift(null)}let f=e.tr;(e.selection instanceof He||e.selection instanceof kr)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=Ys(f.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=Ys(f.doc,m,a.length,a)),!g)return!1;if(f.split(m,a.length,a),!u&&h&&r.node(o).type!=c){let y=f.mapping.map(r.before(o)),v=f.doc.resolve(y);c&&r.node(o-1).canReplaceWith(v.index(),v.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const EO=CO(),TO=(t,e)=>{let{$from:n,to:r}=t.selection,s,a=n.sharedDepth(r);return a==0?!1:(s=n.before(a),e&&e(t.tr.setSelection(Ve.create(t.doc,s))),!0)};function MO(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,a=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(s.isTextblock||aa(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function hS(t,e,n,r){let s=e.nodeBefore,a=e.nodeAfter,o,c,u=s.type.spec.isolating||a.type.spec.isolating;if(!u&&MO(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let y=e.pos+a.nodeSize,v=pe.empty;for(let k=o.length-1;k>=0;k--)v=pe.from(o[k].create(null,v));v=pe.from(s.copy(v));let j=t.tr.step(new jn(e.pos-1,y,e.pos,y,new Me(v,1,0),o.length,!0)),w=j.doc.resolve(y+2*o.length);w.nodeAfter&&w.nodeAfter.type==s.type&&aa(j.doc,w.pos)&&j.join(w.pos),n(j.scrollIntoView())}return!0}let f=a.type.spec.isolating||r>0&&u?null:Ge.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&hl(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Xo(a,"start",!0)&&Xo(s,"end")){let y=s,v=[];for(;v.push(y),!y.isTextblock;)y=y.lastChild;let j=a,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(y.canReplace(y.childCount,y.childCount,j.content)){if(n){let k=pe.empty;for(let C=v.length-1;C>=0;C--)k=pe.from(v[C].copy(k));let E=t.tr.step(new jn(e.pos-v.length,e.pos+a.nodeSize,e.pos+w,e.pos+a.nodeSize-w,new Me(k,v.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function fS(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,a=s.depth;for(;s.node(a).isInline;){if(!a)return!1;a--}return s.node(a).isTextblock?(n&&n(e.tr.setSelection(He.create(e.doc,t<0?s.start(a):s.end(a)))),!0):!1}}const AO=fS(-1),RO=fS(1);function IO(t,e=null){return function(n,r){let{$from:s,$to:a}=n.selection,o=s.blockRange(a),c=o&&Hx(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function y1(t,e=null){return function(n,r){let s=!1;for(let a=0;a<n.selection.ranges.length&&!s;a++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[a];n.doc.nodesBetween(o,c,(u,h)=>{if(s)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)s=!0;else{let f=n.doc.resolve(h),m=f.index();s=f.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:c},$to:{pos:u}}=n.selection.ranges[o];a.setBlockType(c,u,t,e)}r(a.scrollIntoView())}return!0}}function Yx(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Yx(Kx,rS,iS);Yx(Kx,oS,lS);Yx(cS,dS,uS,EO);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function PO(t,e=null){return function(n,r){let{$from:s,$to:a}=n.selection,o=s.blockRange(a);if(!o)return!1;let c=r?n.tr:null;return OO(c,o,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function OO(t,e,n,r=null){let s=!1,a=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);a=new Qu(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Qu(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let c=Hx(a,n,r,e);return c?(t&&DO(t,e,c,s,n),!0):!1}function DO(t,e,n,r,s){let a=pe.empty;for(let f=n.length-1;f>=0;f--)a=pe.from(n[f].type.create(n[f].attrs,a));t.step(new jn(e.start-(r?2:0),e.end,e.start,e.end,new Me(a,0,0),n.length,!0));let o=0;for(let f=0;f<n.length;f++)n[f].type==s&&(o=f+1);let c=n.length-o,u=e.start+n.length-(r?2:0),h=e.parent;for(let f=e.startIndex,m=e.endIndex,g=!0;f<m;f++,g=!1)!g&&Ys(t.doc,u,c)&&(t.split(u,c),u+=2*c),u+=h.child(f).nodeSize;return t}function LO(t){return function(e,n){let{$from:r,$to:s}=e.selection,a=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?_O(e,n,t,a):zO(e,n,a):!0:!1}}function _O(t,e,n,r){let s=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(s.step(new jn(a-1,o,a,o,new Me(pe.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Qu(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const c=hl(r);if(c==null)return!1;s.lift(r,c);let u=s.doc.resolve(s.mapping.map(a,-1)-1);return aa(s.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&s.join(u.pos),e(s.scrollIntoView()),!0}function zO(t,e,n){let r=t.tr,s=n.parent;for(let y=n.end,v=n.endIndex-1,j=n.startIndex;v>j;v--)y-=s.child(v).nodeSize,r.delete(y-1,y+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==s.childCount,h=a.node(-1),f=a.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?pe.empty:pe.from(s))))return!1;let m=a.pos,g=m+o.nodeSize;return r.step(new jn(m-(c?1:0),g+(u?1:0),m+1,g-1,new Me((c?pe.empty:pe.from(s.copy(pe.empty))).append(u?pe.empty:pe.from(s.copy(pe.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function $O(t){return function(e,n){let{$from:r,$to:s}=e.selection,a=r.blockRange(s,h=>h.childCount>0&&h.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let c=a.parent,u=c.child(o-1);if(u.type!=t)return!1;if(n){let h=u.lastChild&&u.lastChild.type==c.type,f=pe.from(h?t.create():null),m=new Me(pe.from(t.create(null,pe.from(c.type.create(null,f)))),h?3:1,0),g=a.start,y=a.end;n(e.tr.step(new jn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Rn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Zo=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ig=null;const Us=function(t,e,n){let r=Ig||(Ig=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},FO=function(){Ig=null},Ua=function(t,e,n,r){return n&&(v1(t,e,n,r,-1)||v1(t,e,n,r,1))},BO=/^(img|br|input|textarea|hr)$/i;function v1(t,e,n,r,s){for(var a;;){if(t==n&&e==r)return!0;if(e==(s<0?0:_r(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Wc(t)||BO.test(t.nodeName)||t.contentEditable=="false")return!1;e=Rn(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?_r(t):0}else return!1}}function _r(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function VO(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=_r(t)}else if(t.parentNode&&!Wc(t))e=Rn(t),t=t.parentNode;else return null}}function HO(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Wc(t))e=Rn(t)+1,t=t.parentNode;else return null}}function WO(t,e,n){for(let r=e==0,s=e==_r(t);r||s;){if(t==n)return!0;let a=Rn(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,s=s&&a==_r(t)}}function Wc(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const nf=function(t){return t.focusNode&&Ua(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ma(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function UO(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function KO(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(_r(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(_r(r.startContainer),r.startOffset)}}}const Ns=typeof navigator<"u"?navigator:null,b1=typeof document<"u"?document:null,oa=Ns&&Ns.userAgent||"",Pg=/Edge\/(\d+)/.exec(oa),pS=/MSIE \d/.exec(oa),Og=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oa),ur=!!(pS||Og||Pg),Gi=pS?document.documentMode:Og?+Og[1]:Pg?+Pg[1]:0,$r=!ur&&/gecko\/(\d+)/i.test(oa);$r&&+(/Firefox\/(\d+)/.exec(oa)||[0,0])[1];const Dg=!ur&&/Chrome\/(\d+)/.exec(oa),Pn=!!Dg,mS=Dg?+Dg[1]:0,Hn=!ur&&!!Ns&&/Apple Computer/.test(Ns.vendor),el=Hn&&(/Mobile\/\w+/.test(oa)||!!Ns&&Ns.maxTouchPoints>2),Lr=el||(Ns?/Mac/.test(Ns.platform):!1),gS=Ns?/Win/.test(Ns.platform):!1,qs=/Android \d/.test(oa),Uc=!!b1&&"webkitFontSmoothing"in b1.documentElement.style,qO=Uc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function GO(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function $s(t,e){return typeof t=="number"?t:t[e]}function JO(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function w1(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Zo(o);continue}let c=o,u=c==a.body,h=u?GO(a):JO(c),f=0,m=0;if(e.top<h.top+$s(r,"top")?m=-(h.top-e.top+$s(s,"top")):e.bottom>h.bottom-$s(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+$s(s,"top")-h.top:e.bottom-h.bottom+$s(s,"bottom")),e.left<h.left+$s(r,"left")?f=-(h.left-e.left+$s(s,"left")):e.right>h.right-$s(r,"right")&&(f=e.right-h.right+$s(s,"right")),f||m)if(u)a.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,w=c.scrollTop-v;e={left:e.left-j,top:e.top-w,right:e.right-j,bottom:e.bottom-w}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Zo(o)}}function YO(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let c=t.root.elementFromPoint(a,o);if(!c||c==t.dom||!t.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=n-20){r=c,s=u.top;break}}return{refDOM:r,refTop:s,stack:xS(t.dom)}}function xS(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Zo(r));return e}function QO({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;yS(n,r==0?0:r-e)}function yS(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:a}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let Po=null;function XO(t){if(t.setActive)return t.setActive();if(Po)return t.focus(Po);let e=xS(t);t.focus(Po==null?{get preventScroll(){return Po={preventScroll:!0},!0}}:void 0),Po||(Po=!1,yS(e,0))}function vS(t,e){let n,r=2e8,s,a=0,o=e.top,c=e.top,u,h;for(let f=t.firstChild,m=0;f;f=f.nextSibling,m++){let g;if(f.nodeType==1)g=f.getClientRects();else if(f.nodeType==3)g=Us(f).getClientRects();else continue;for(let y=0;y<g.length;y++){let v=g[y];if(v.top<=o&&v.bottom>=c){o=Math.max(v.bottom,o),c=Math.min(v.top,c);let j=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(j<r){n=f,r=j,s=j&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,f.nodeType==1&&j&&(a=m+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=f,h={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(a=m+1)}}return!n&&u&&(n=u,s=h,r=0),n&&n.nodeType==3?ZO(n,s):!n||r&&n.nodeType==1?{node:t,offset:a}:vS(n,s)}function ZO(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let a=0;a<n;a++){r.setEnd(t,a+1),r.setStart(t,a);let o=Ii(r,1);if(o.top!=o.bottom&&Qx(e,o)){s={node:t,offset:a+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Qx(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function eD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function tD(t,e,n){let{node:r,offset:s}=vS(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,a)}function nD(t,e,n,r){let s=-1;for(let a=e,o=!1;a!=t.dom;){let c=t.docView.nearestDesc(a,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&u.left>r.left||u.top>r.top?s=c.posBefore:(!o&&u.right<r.left||u.bottom<r.top)&&(s=c.posAfter),o=!0),!c.contentDOM&&s<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;a=c.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function bS(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=s;;){let o=t.childNodes[a];if(o.nodeType==1){let c=o.getClientRects();for(let u=0;u<c.length;u++){let h=c[u];if(Qx(e,h))return bS(o,e,h)}}if((a=(a+1)%r)==s)break}return t}function rD(t,e){let n=t.dom.ownerDocument,r,s=0,a=KO(n,e.left,e.top);a&&({node:r,offset:s}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),c;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let h=t.dom.getBoundingClientRect();if(!Qx(e,h)||(o=bS(t.dom,e,h),!o))return null}if(Hn)for(let h=o;r&&h;h=Zo(h))h.draggable&&(r=void 0);if(o=eD(o,e),r){if($r&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let f=r.childNodes[s],m;f.nodeName=="IMG"&&(m=f.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let h;Uc&&s&&r.nodeType==1&&(h=r.childNodes[s-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(c=nD(t,r,s,e))}c==null&&(c=tD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function N1(t){return t.top<t.bottom||t.left<t.right}function Ii(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(N1(r))return r}return Array.prototype.find.call(n,N1)||t.getBoundingClientRect()}const sD=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wS(t,e,n){let{node:r,offset:s,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Uc||$r;if(r.nodeType==3)if(o&&(sD.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let u=Ii(Us(r,s,s),n);if($r&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let h=Ii(Us(r,s-1,s-1),-1);if(h.top==u.top){let f=Ii(Us(r,s,s+1),-1);if(f.top!=u.top)return Yl(f,f.left<h.left)}}return u}else{let u=s,h=s,f=n<0?1:-1;return n<0&&!s?(h++,f=-1):n>=0&&s==r.nodeValue.length?(u--,f=1):n<0?u--:h++,Yl(Ii(Us(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&s&&(n<0||s==_r(r))){let u=r.childNodes[s-1];if(u.nodeType==1)return Dm(u.getBoundingClientRect(),!1)}if(a==null&&s<_r(r)){let u=r.childNodes[s];if(u.nodeType==1)return Dm(u.getBoundingClientRect(),!0)}return Dm(r.getBoundingClientRect(),n>=0)}if(a==null&&s&&(n<0||s==_r(r))){let u=r.childNodes[s-1],h=u.nodeType==3?Us(u,_r(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return Yl(Ii(h,1),!1)}if(a==null&&s<_r(r)){let u=r.childNodes[s];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let h=u?u.nodeType==3?Us(u,0,o?0:1):u.nodeType==1?u:null:null;if(h)return Yl(Ii(h,-1),!0)}return Yl(Ii(r.nodeType==3?Us(r):r,-n),n>=0)}function Yl(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Dm(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function NS(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function iD(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return NS(t,e,()=>{let{node:a}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(a,!0);if(!c)break;if(c.node.isBlock){a=c.contentDOM||c.dom;break}a=c.dom.parentNode}let o=wS(t,s.pos,1);for(let c=a.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=Us(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;h<u.length;h++){let f=u[h];if(f.bottom>f.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}const aD=/[\u0590-\u08ac]/;function oD(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,a=!s,o=s==r.parent.content.size,c=t.domSelection();return c?!aD.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?a:o:NS(t,e,()=>{let{focusNode:u,focusOffset:h,anchorNode:f,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:j}=t.domSelectionRange(),w=v&&!y.contains(v.nodeType==1?v:v.parentNode)||u==v&&h==j;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),w}):r.pos==r.start()||r.pos==r.end()}let j1=null,k1=null,S1=!1;function lD(t,e,n){return j1==e&&k1==n?S1:(j1=e,k1=n,S1=n=="up"||n=="down"?iD(t,e,n):oD(t,e,n))}const Fr=0,C1=1,Ra=2,js=3;class Kc{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Fr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Rn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){s=!1;break}if(a.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){s=!0;break}if(a.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let a=this.getDesc(s),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let a=this.getDesc(s);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],a=r+s.size;if(r==e&&a!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let c=s.children[o];if(c.size){s=c;break}}return s}if(e<a)return s.descAt(e-r-s.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],c=a+o.size;if(c>e||o instanceof kS){s=e-a;break}a=c}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof jS&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Rn(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?Rn(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,a=-1;for(let o=r,c=0;;c++){let u=this.children[c],h=o+u.size;if(s==-1&&e<=h){let f=o+u.border;if(e>=f&&n<=h-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,f);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){s=Rn(g.dom)+1;break}e-=g.size}s==-1&&(s=0)}if(s>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;f<this.children.length;f++){let m=this.children[f];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){a=Rn(m.dom);break}n+=m.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let y=0,v=0;y<this.children.length;y++){let j=this.children[y],w=v+j.size;if(a>v&&o<w)return j.setSelection(e-v-j.border,n-v-j.border,r,s);v=w}let c=this.domFromPos(e,e?-1:1),u=n==e?c:this.domFromPos(n,n?-1:1),h=r.root.getSelection(),f=r.domSelectionRange(),m=!1;if(($r||Hn)&&e==n){let{node:y,offset:v}=c;if(y.nodeType==3){if(m=!!(v&&y.nodeValue[v-1]==`
`),m&&v==y.nodeValue.length)for(let j=y,w;j;j=j.parentNode){if(w=j.nextSibling){w.nodeName=="BR"&&(c=u={node:w.parentNode,offset:Rn(w)+1});break}let k=j.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let j=y.childNodes[v-1];m=j&&(j.nodeName=="BR"||j.contentEditable=="false")}}if($r&&f.focusNode&&f.focusNode!=u.node&&f.focusNode.nodeType==1){let y=f.focusNode.childNodes[f.focusOffset];y&&y.contentEditable=="false"&&(s=!0)}if(!(s||m&&Hn)&&Ua(c.node,c.offset,f.anchorNode,f.anchorOffset)&&Ua(u.node,u.offset,f.focusNode,f.focusOffset))return;let g=!1;if((h.extend||e==n)&&!(m&&$r)){h.collapse(c.node,c.offset);try{e!=n&&h.extend(u.node,u.offset),g=!0}catch{}}if(!g){if(e>n){let v=c;c=u,u=v}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(c.node,c.offset),h.removeAllRanges(),h.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let a=this.children[s],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let c=r+a.border,u=o-a.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?Ra:C1,e==c&&n==u&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=js:a.markDirty(e-c,n-c);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Ra:js}r=o}this.dirty=Ra}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ra:C1;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class jS extends Kc{constructor(e,n,r,s){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Fr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cD extends Kc{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ka extends Kc{constructor(e,n,r,s,a){super(e,[],r,s),this.mark=n,this.spec=a}static create(e,n,r,s){let a=s.nodeViews[n.type.name],o=a&&a(n,s,r);return(!o||!o.dom)&&(o=Za.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ka(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&js||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=js&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Fr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Fr}}slice(e,n,r){let s=Ka.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=_g(a,n,o,r)),e>0&&(a=_g(a,0,e,r));for(let c=0;c<a.length;c++)a[c].parent=s;return s.children=a,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ji extends Kc{constructor(e,n,r,s,a,o,c,u,h){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=c}static create(e,n,r,s,a,o){let c=a.nodeViews[n.type.name],u,h=c&&c(n,a,()=>{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,s),f=h&&h.dom,m=h&&h.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:m}=Za.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let g=f;return f=ES(f,r,n),h?u=new dD(e,n,r,s,f,m||null,g,h,a,o+1):n.isText?new rf(e,n,r,s,f,g,a):new Ji(e,n,r,s,f,m||null,g,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>pe.empty)}return e}matchesNode(e,n,r){return this.dirty==Fr&&e.eq(this.node)&&Zu(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new hD(this,o&&o.node,e);mD(this.node,this.innerDeco,(h,f,m)=>{h.spec.marks?u.syncToMarks(h.spec.marks,r,e,f):h.type.side>=0&&!m&&u.syncToMarks(f==this.node.childCount?Nt.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,s)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>s&&e.state.selection.to<s+h.nodeSize&&(y=u.findIndexWithChild(a.node))>-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,s)||u.addNode(h,f,m,e,s),s+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Ra)&&(o&&this.protectLocalComposition(e,o),SS(this.contentDOM,this.children,e),el&&gD(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof He)||r<n||s>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,c=xD(this.node.content,o,r-n,s-n);return c<0?null:{node:a,pos:c,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new cD(this,a,n,s);e.input.compositionNodes.push(o),this.children=_g(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==js||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Fr}updateOuterDeco(e){if(Zu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=CS(this.dom,this.nodeDOM,Lg(this.outerDeco,this.node,n),Lg(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function E1(t,e,n,r,s){ES(r,e,t);let a=new Ji(void 0,t,e,n,r,r,r,s,0);return a.contentDOM&&a.updateChildren(s,0),a}class rf extends Ji{constructor(e,n,r,s,a,o,c){super(e,n,r,s,a,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==js||this.dirty!=Fr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Fr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Fr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),a=document.createTextNode(s.text);return new rf(this.parent,s,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=js)}get domAtom(){return!1}isText(e){return this.node.text==e}}class kS extends Kc{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class dD extends Ji{constructor(e,n,r,s,a,o,c,u,h,f){super(e,n,r,s,a,o,c,h,f),this.spec=u}update(e,n,r,s){if(this.dirty==js)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,s),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function SS(t,e,n){let r=t.firstChild,s=!1;for(let a=0;a<e.length;a++){let o=e[a],c=o.dom;if(c.parentNode==t){for(;c!=r;)r=T1(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(c,r);if(o instanceof Ka){let u=r?r.previousSibling:t.lastChild;SS(o.contentDOM,o.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=T1(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const hc=function(t){t&&(this.nodeName=t)};hc.prototype=Object.create(null);const Ia=[new hc];function Lg(t,e,n){if(t.length==0)return Ia;let r=n?Ia[0]:new hc,s=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&s.push(r=new hc(o.nodeName));for(let c in o){let u=o[c];u!=null&&(n&&s.length==1&&s.push(r=new hc(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return s}function CS(t,e,n,r){if(n==Ia&&r==Ia)return e;let s=e;for(let a=0;a<r.length;a++){let o=r[a],c=n[a];if(a){let u;c&&c.nodeName==o.nodeName&&s!=t&&(u=s.parentNode)&&u.nodeName.toLowerCase()==o.nodeName||(u=document.createElement(o.nodeName),u.pmIsDeco=!0,u.appendChild(s),c=Ia[0]),s=u}uD(s,c||Ia[0],o)}return s}function uD(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)s.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<s.length;a++)r.indexOf(s[a])==-1&&t.classList.add(s[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function ES(t,e,n){return CS(t,t,Ia,Lg(e,n,t.nodeType!=1))}function Zu(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function T1(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hD{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=fD(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let a=0,o=this.stack.length>>1,c=Math.min(o,e.length);for(;a<c&&(a==o-1?this.top:this.stack[a+1<<1]).matchesMark(e[a])&&e[a].type.spec.spanning!==!1;)a++;for(;a<o;)this.destroyRest(),this.top.dirty=Fr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let u=-1,h=this.top.children.length;s<this.preMatch.index&&(h=Math.min(this.index+3,h));for(let f=this.index;f<h;f++){let m=this.top.children[f];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){u=f;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=Ka.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let a=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let h=this.top.children[c];if(h.matchesNode(e,n,r)&&!this.preMatch.matched.has(h)){a=c;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,s,a){let o=this.top.children[s];return o.dirty==js&&o.dom==o.contentDOM&&(o.dirty=Ra),o.update(e,n,r,a)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,a,o){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Ji){let h=this.preMatch.matched.get(u);if(h!=null&&h!=a)return!1;let f=u.dom,m,g=this.isLocked(f)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=js&&Zu(n,u.outerDeco));if(!g&&u.update(e,n,r,s))return this.destroyBetween(this.index,c),u.dom!=f&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(u,e,n,r,s,o)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=Ra,m.updateChildren(s,o+1),m.dirty=Fr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Zu(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let c=Ji.create(this.top,n,r,s,a,o);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,n,r,s,a){let o=Ji.create(this.top,e,n,r,s,a);o.contentDOM&&o.updateChildren(s,a+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let a=new jS(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ka;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof rf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Hn||Pn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new kS(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function fD(t,e){let n=e,r=n.children.length,s=t.childCount,a=new Map,o=[];e:for(;s>0;){let c;for(;;)if(r){let h=n.children[r-1];if(h instanceof Ka)n=h,r=h.children.length;else{c=h,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(s-1))break;--s,a.set(c,s),o.push(c)}}return{index:s,matched:a,matches:o.reverse()}}function pD(t,e){return t.type.side-e.type.side}function mD(t,e,n,r){let s=e.locals(t),a=0;if(s.length==0){for(let h=0;h<t.childCount;h++){let f=t.child(h);r(f,s,e.forChild(a,f),h),a+=f.nodeSize}return}let o=0,c=[],u=null;for(let h=0;;){let f,m;for(;o<s.length&&s[o].to==a;){let w=s[o++];w.widget&&(f?(m||(m=[f])).push(w):f=w)}if(f)if(m){m.sort(pD);for(let w=0;w<m.length;w++)n(m[w],h,!!u)}else n(f,h,!!u);let g,y;if(u)y=-1,g=u,u=null;else if(h<t.childCount)y=h,g=t.child(h++);else break;for(let w=0;w<c.length;w++)c[w].to<=a&&c.splice(w--,1);for(;o<s.length&&s[o].from<=a&&s[o].to>a;)c.push(s[o++]);let v=a+g.nodeSize;if(g.isText){let w=v;o<s.length&&s[o].from<w&&(w=s[o].from);for(let k=0;k<c.length;k++)c[k].to<w&&(w=c[k].to);w<v&&(u=g.cut(w-a),g=g.cut(0,w-a),v=w,y=-1)}else for(;o<s.length&&s[o].to<v;)o++;let j=g.isInline&&!g.isLeaf?c.filter(w=>!w.inline):c.slice();r(g,j,e.forChild(a,g),y),a=v}}function gD(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function xD(t,e,n,r){for(let s=0,a=0;s<t.childCount&&a<=r;){let o=t.child(s++),c=a;if(a+=o.nodeSize,!o.isText)continue;let u=o.text;for(;s<t.childCount;){let h=t.child(s++);if(a+=h.nodeSize,!h.isText)break;u+=h.text}if(a>=n){if(a>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c<r?u.lastIndexOf(e,r-c-1):-1;if(h>=0&&h+e.length+c>=n)return c+h;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function _g(t,e,n,r,s){let a=[];for(let o=0,c=0;o<t.length;o++){let u=t[o],h=c,f=c+=u.size;h>=n||f<=e?a.push(u):(h<e&&a.push(u.slice(0,e-h,r)),s&&(a.push(s),s=void 0),f>n&&a.push(u.slice(n-h,u.size,r)))}return a}function Xx(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),a=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=r.resolve(o),u,h;if(nf(n)){for(u=o;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&Ve.isSelectable(m)&&s.parent&&!(m.isInline&&WO(n.focusNode,n.focusOffset,s.dom))){let g=s.posBefore;h=new Ve(o==g?c:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y<n.rangeCount;y++){let v=n.getRangeAt(y);m=Math.min(m,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(m<0)return null;[u,o]=g==t.state.selection.anchor?[g,m]:[m,g],c=r.resolve(o)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let f=r.resolve(u);if(!h){let m=e=="pointer"||t.state.selection.head<c.pos&&!a?1:-1;h=Zx(t,f,c,m)}return h}function TS(t){return t.editable?t.hasFocus():AS(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qs(t,e=!1){let n=t.state.selection;if(MS(t,n),!!TS(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Pn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ua(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)vD(t);else{let{anchor:r,head:s}=n,a,o;M1&&!(n instanceof He)&&(n.$from.parent.inlineContent||(a=A1(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=A1(t,n.to))),t.docView.setSelection(r,s,t,e),M1&&(a&&R1(a),o&&R1(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&yD(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const M1=Hn||Pn&&mS<63;function A1(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Hn&&s&&s.contentEditable=="false")return Lm(s);if((!s||s.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(s)return Lm(s);if(a)return Lm(a)}}function Lm(t){return t.contentEditable="true",Hn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function R1(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function yD(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!TS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function vD(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Rn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ur&&Gi<=11&&(n.disabled=!0,n.disabled=!1)}function MS(t,e){if(e instanceof Ve){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(I1(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else I1(t)}function I1(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Zx(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||He.between(e,n,r)}function P1(t){return t.editable&&!t.hasFocus()?!1:AS(t)}function AS(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function bD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ua(e.node,e.offset,n.anchorNode,n.anchorOffset)}function zg(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),a=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return a&&Ge.findFrom(a,e)}function Pi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function O1(t,e,n){let r=t.state.selection;if(r instanceof He)if(n.indexOf("s")>-1){let{$head:s}=r,a=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+a.nodeSize*(e<0?-1:1));return Pi(t,new He(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=zg(t.state,e);return s&&s instanceof Ve?Pi(t,s):!1}else if(!(Lr&&n.indexOf("m")>-1)){let s=r.$head,a=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!a||a.isText)return!1;let c=e<0?s.pos-a.nodeSize:s.pos;return a.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Ve.isSelectable(a)?Pi(t,new Ve(e<0?t.state.doc.resolve(s.pos-a.nodeSize):s)):Uc?Pi(t,new He(t.state.doc.resolve(e<0?c:c+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ve&&r.node.isInline)return Pi(t,new He(e>0?r.$to:r.$from));{let s=zg(t.state,e);return s?Pi(t,s):!1}}}function eh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function fc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Oo(t,e){return e<0?wD(t):ND(t)}function wD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,a,o=!1;for($r&&n.nodeType==1&&r<eh(n)&&fc(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(fc(c,-1))s=n,a=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(RS(n))break;{let c=n.previousSibling;for(;c&&fc(c,-1);)s=n.parentNode,a=Rn(c),c=c.previousSibling;if(c)n=c,r=eh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?$g(t,n,r):s&&$g(t,s,a)}function ND(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=eh(n),a,o;for(;;)if(r<s){if(n.nodeType!=1)break;let c=n.childNodes[r];if(fc(c,1))a=n,o=++r;else break}else{if(RS(n))break;{let c=n.nextSibling;for(;c&&fc(c,1);)a=c.parentNode,o=Rn(c)+1,c=c.nextSibling;if(c)n=c,r=0,s=eh(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}a&&$g(t,a,o)}function RS(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function jD(t,e){for(;t&&e==t.childNodes.length&&!Wc(t);)e=Rn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function kD(t,e){for(;t&&!e&&!Wc(t);)e=Rn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function $g(t,e,n){if(e.nodeType!=3){let a,o;(o=jD(e,n))?(e=o,n=0):(a=kD(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(nf(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Qs(t)},50)}function D1(t,e){let n=t.state.doc.resolve(e);if(!(Pn||gS)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(a.left-s.left)>1)return a.left<s.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(a.left-s.left)>1)return a.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function L1(t,e,n){let r=t.state.selection;if(r instanceof He&&!r.empty||n.indexOf("s")>-1||Lr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:a}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=zg(t.state,e);if(o&&o instanceof Ve)return Pi(t,o)}if(!s.parent.inlineContent){let o=e<0?s:a,c=r instanceof kr?Ge.near(o,e):Ge.findFrom(o,e);return c?Pi(t,c):!1}return!1}function _1(t,e){if(!(t.state.selection instanceof He))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function z1(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function SD(t){if(!Hn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;z1(t,r,"true"),setTimeout(()=>z1(t,r,"false"),20)}return!1}function CD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function ED(t,e){let n=e.keyCode,r=CD(e);if(n==8||Lr&&n==72&&r=="c")return _1(t,-1)||Oo(t,-1);if(n==46&&!e.shiftKey||Lr&&n==68&&r=="c")return _1(t,1)||Oo(t,1);if(n==13||n==27)return!0;if(n==37||Lr&&n==66&&r=="c"){let s=n==37?D1(t,t.state.selection.from)=="ltr"?-1:1:-1;return O1(t,s,r)||Oo(t,s)}else if(n==39||Lr&&n==70&&r=="c"){let s=n==39?D1(t,t.state.selection.from)=="ltr"?1:-1:1;return O1(t,s,r)||Oo(t,s)}else{if(n==38||Lr&&n==80&&r=="c")return L1(t,-1,r)||Oo(t,-1);if(n==40||Lr&&n==78&&r=="c")return SD(t)||L1(t,1,r)||Oo(t,1);if(r==(Lr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function e0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:s,openEnd:a}=e;for(;s>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,a--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||Za.fromSchema(t.state.schema),c=_S(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=LS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let v=c.createElement(f[y]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${s} ${a}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,`
`);return{dom:u,text:g,slice:e}}function IS(t,e,n,r,s){let a=s.parent.type.spec.code,o,c;if(!n&&!e)return null;let u=!!e&&(r||a||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return c=new Me(pe.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,s,r,t));if(m)c=m;else{let g=s.marks(),{schema:y}=t.state,v=Za.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=o.appendChild(document.createElement("p"));j&&w.appendChild(v.serializeNode(y.text(j,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=RD(n),Uc&&ID(o);let h=o&&o.querySelector("[data-pm-slice]"),f=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let m=+f[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||qi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:s,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!TD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=PD($1(c,+f[1],+f[2]),f[4]);else if(c=Me.maxOpen(MD(c.content,s),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m<c.openStart&&!y.type.spec.isolating;m++,y=y.firstChild);for(let y=c.content.lastChild;g<c.openEnd&&!y.type.spec.isolating;g++,y=y.lastChild);c=$1(c,m,g)}return t.someProp("transformPasted",m=>{c=m(c,t,u)}),c}const TD=/^(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)$/i;function MD(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(c=>{if(!o)return;let u=s.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&a.length&&OS(u,a,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=DS(o[o.length-1],a.length));let f=PS(c,u);o.push(f),s=s.matchType(f.type),a=u}}),o)return pe.from(o)}return t}function PS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pe.from(t));return t}function OS(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let a=OS(t,e,n,r.lastChild,s+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(pe.from(PS(n,t,s+1))))}}function DS(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,DS(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pe.empty,!0);return t.copy(n.append(r))}function Fg(t,e,n,r,s,a){let o=e<0?t.firstChild:t.lastChild,c=o.content;return t.childCount>1&&(a=0),s<r-1&&(c=Fg(c,e,n,r,s+1,a)),s>=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,a<=s).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(pe.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function $1(t,e,n){return e<t.openStart&&(t=new Me(Fg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Me(Fg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const LS={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let F1=null;function _S(){return F1||(F1=document.implementation.createHTMLDocument("title"))}let _m=null;function AD(t){let e=window.trustedTypes;return e?(_m||(_m=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),_m.createHTML(t)):t}function RD(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=_S().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&LS[r[1].toLowerCase()])&&(t=s.map(a=>"<"+a+">").join("")+t+s.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=AD(t),s)for(let a=0;a<s.length;a++)n=n.querySelector(s[a])||n;return n}function ID(t){let e=t.querySelectorAll(Pn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function PD(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:a,openEnd:o}=t;for(let c=r.length-2;c>=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;s=pe.from(u.create(r[c+1],s)),a++,o++}return new Me(s,a,o)}const tr={},nr={},OD={touchstart:!0,touchmove:!0};class DD{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function LD(t){for(let e in tr){let n=tr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{zD(t,r)&&!t0(t,r)&&(t.editable||!(r.type in nr))&&n(t,r)},OD[e]?{passive:!0}:void 0)}Hn&&t.dom.addEventListener("input",()=>null),Bg(t)}function Hi(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function _D(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Bg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>t0(t,r))})}function t0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function zD(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function $D(t,e){!t0(t,e)&&tr[e.type]&&(t.editable||!(e.type in nr))&&tr[e.type](t,e)}nr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!$S(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qs&&Pn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),el&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Ma(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||ED(t,n)?n.preventDefault():Hi(t,"key")};nr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};nr.keypress=(t,e)=>{let n=e;if($S(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Lr&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof He)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,a))&&t.dispatch(a()),n.preventDefault()}};function sf(t){return{left:t.clientX,top:t.clientY}}function FD(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function n0(t,e,n,r,s){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,c=>o>a.depth?c(t,n,a.nodeAfter,a.before(o),s,!0):c(t,n,a.node(o),a.before(o),s,!1)))return!0;return!1}function qo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function BD(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ve.isSelectable(r)?(qo(t,new Ve(n)),!0):!1}function VD(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Ve&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let c=o>a.depth?a.nodeAfter:a.node(o);if(Ve.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?s=a.before(n.$from.depth):s=a.before(o);break}}return s!=null?(qo(t,Ve.create(t.state.doc,s)),!0):!1}function HD(t,e,n,r,s){return n0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(s?VD(t,n):BD(t,n))}function WD(t,e,n,r){return n0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function UD(t,e,n,r){return n0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||KD(t,n,r)}function KD(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(qo(t,He.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let a=s.depth+1;a>0;a--){let o=a>s.depth?s.nodeAfter:s.node(a),c=s.before(a);if(o.inlineContent)qo(t,He.create(r,c+1,c+1+o.content.size));else if(Ve.isSelectable(o))qo(t,Ve.create(r,c));else continue;return!0}}function r0(t){return th(t)}const zS=Lr?"metaKey":"ctrlKey";tr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=r0(t),s=Date.now(),a="singleClick";s-t.input.lastClick.time<500&&FD(n,t.input.lastClick)&&!n[zS]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(sf(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new qD(t,o,n,!!r)):(a=="doubleClick"?WD:UD)(t,o.pos,o.inside,n)?n.preventDefault():Hi(t,"pointer"))};class qD{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[zS],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);a=f.parent,o=f.depth?f.before():0}const c=s?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:h}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||h instanceof Ve&&h.from<=o&&h.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$r&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Hi(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Qs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(sf(e))),this.updateAllowDefault(e),this.allowDefault||!n?Hi(this.view,"pointer"):HD(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Hn&&this.mightDrag&&!this.mightDrag.node.isAtom||Pn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(qo(this.view,Ge.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Hi(this.view,"pointer")}move(e){this.updateAllowDefault(e),Hi(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}tr.touchstart=t=>{t.input.lastTouch=Date.now(),r0(t),Hi(t,"pointer")};tr.touchmove=t=>{t.input.lastTouch=Date.now(),Hi(t,"pointer")};tr.contextmenu=t=>r0(t);function $S(t,e){return t.composing?!0:Hn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const GD=qs?5e3:-1;nr.compositionstart=nr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof He&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Pn&&gS&&JD(t)))t.markCursor=t.state.storedMarks||n.marks(),th(t,!0),t.markCursor=null;else if(th(t,!e.selection.empty),$r&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,a=r.focusOffset;s&&s.nodeType==1&&a!=0;){let o=a<0?s.lastChild:s.childNodes[a-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else s=o,a=-1}}t.input.composing=!0}FS(t,GD)};function JD(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}nr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,FS(t,20))};function FS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>th(t),e))}function BS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=QD());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function YD(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=VO(e.focusNode,e.focusOffset),r=HO(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function QD(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function th(t,e=!1){if(!(qs&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),BS(t),e||t.docView&&t.docView.dirty){let n=Xx(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function XD(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ac=ur&&Gi<15||el&&qO<604;tr.copy=nr.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let a=Ac?null:n.clipboardData,o=r.content(),{dom:c,text:u}=e0(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",c.innerHTML),a.setData("text/plain",u)):XD(t,c),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ZD(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eL(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Rc(t,r.value,null,s,e):Rc(t,r.textContent,r.innerHTML,s,e)},50)}function Rc(t,e,n,r,s){let a=IS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,s,a||Me.empty)))return!0;if(!a)return!1;let o=ZD(a),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function VS(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}nr.paste=(t,e)=>{let n=e;if(t.composing&&!qs)return;let r=Ac?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Rc(t,VS(r),r.getData("text/html"),s,n)?n.preventDefault():eL(t,n)};class HS{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const tL=Lr?"altKey":"ctrlKey";function WS(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[tL]}tr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,a=s.empty?null:t.posAtCoords(sf(n)),o;if(!(a&&a.pos>=s.from&&a.pos<=(s instanceof Ve?s.to-1:s.to))){if(r&&r.mightDrag)o=Ve.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=Ve.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=e0(t,c);(!n.dataTransfer.files.length||!Pn||mS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ac?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ac||n.dataTransfer.setData("text/plain",h),t.dragging=new HS(f,WS(t,n),o)};tr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};nr.dragover=nr.dragenter=(t,e)=>e.preventDefault();nr.drop=(t,e)=>{try{nL(t,e,t.dragging)}finally{t.dragging=null}};function nL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(sf(e));if(!r)return;let s=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",y=>{a=y(a,t,!1)}):a=IS(t,VS(e.dataTransfer),Ac?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&WS(t,e));if(t.someProp("handleDrop",y=>y(t,e,a||Me.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let c=a?Gk(t.state.doc,s.pos,a):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let h=u.mapping.map(c),f=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,m=u.doc;if(f?u.replaceRangeWith(h,h,a.content.firstChild):u.replaceRange(h,h,a),u.doc.eq(m))return;let g=u.doc.resolve(h);if(f&&Ve.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new Ve(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,j,w,k)=>y=k),u.setSelection(Zx(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}tr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Qs(t)},20))};tr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};tr.beforeinput=(t,e)=>{if(Pn&&qs&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Ma(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in nr)tr[t]=nr[t];function Ic(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class nh{constructor(e,n){this.toDOM=e,this.spec=n||za,this.side=this.spec.side||0}map(e,n,r,s){let{pos:a,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new hn(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof nh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ic(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Yi{constructor(e,n){this.attrs=e,this.spec=n||za}map(e,n,r,s){let a=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new hn(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Yi&&Ic(this.attrs,e.attrs)&&Ic(this.spec,e.spec)}static is(e){return e.type instanceof Yi}destroy(){}}class s0{constructor(e,n){this.attrs=e,this.spec=n||za}map(e,n,r,s){let a=e.mapResult(n.from+s,1);if(a.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=a.pos?null:new hn(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),a;return s==n.from&&!(a=e.child(r)).isText&&s+a.nodeSize==n.to}eq(e){return this==e||e instanceof s0&&Ic(this.attrs,e.attrs)&&Ic(this.spec,e.spec)}destroy(){}}class hn{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new hn(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new hn(e,e,new nh(n,r))}static inline(e,n,r,s){return new hn(e,n,new Yi(r,s))}static node(e,n,r,s){return new hn(e,n,new s0(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yi}get widget(){return this.type instanceof nh}}const Lo=[],za={};class wt{constructor(e,n){this.local=e.length?e:Lo,this.children=n.length?n:Lo}static create(e,n){return n.length?rh(n,e,0,za):Bn}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,a){for(let o=0;o<this.local.length;o++){let c=this.local[o];c.from<=n&&c.to>=e&&(!a||a(c.spec))&&r.push(c.copy(c.from+s,c.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,s+c,a)}}map(e,n,r){return this==Bn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||za)}mapInner(e,n,r,s,a){let o;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,s);u&&u.type.valid(n,u)?(o||(o=[])).push(u):a.onRemove&&a.onRemove(this.local[c].spec)}return this.children.length?rL(this.children,o||[],e,n,r,s,a):o?new wt(o.sort($a),Lo):Bn}add(e,n){return n.length?this==Bn?wt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,a=0;e.forEach((c,u)=>{let h=u+r,f;if(f=KS(n,c,h)){for(s||(s=this.children.slice());a<s.length&&s[a]<u;)a+=3;s[a]==u?s[a+2]=s[a+2].addInner(c,f,h+1):s.splice(a,0,u,u+c.nodeSize,rh(f,c,h+1,za)),a+=3}});let o=US(a?qS(n):n,-r);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||o.splice(c--,1);return new wt(o.length?this.local.concat(o).sort($a):this.local,s||this.children)}remove(e){return e.length==0||this==Bn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let a=0;a<r.length;a+=3){let o,c=r[a]+n,u=r[a+1]+n;for(let f=0,m;f<e.length;f++)(m=e[f])&&m.from>c&&m.to<u&&(e[f]=null,(o||(o=[])).push(m));if(!o)continue;r==this.children&&(r=this.children.slice());let h=r[a+2].removeInner(o,c+1);h!=Bn?r[a+2]=h:(r.splice(a,3),a-=3)}if(s.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let c=0;c<s.length;c++)s[c].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(c--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new wt(s,r):Bn}forChild(e,n){if(this==Bn)return this;if(n.isLeaf)return wt.empty;let r,s;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let a=e+1,o=a+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<o&&u.to>a&&u.type instanceof Yi){let h=Math.max(a,u.from)-a,f=Math.min(o,u.to)-a;h<f&&(s||(s=[])).push(u.copy(h,f))}}if(s){let c=new wt(s.sort($a),Lo);return r?new Li([c,r]):c}return r||Bn}eq(e){if(this==e)return!0;if(!(e instanceof wt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return i0(this.localsInner(e))}localsInner(e){if(this==Bn)return Lo;if(e.inlineContent||!this.local.some(Yi.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Yi||n.push(this.local[r]);return n}forEachSet(e){e(this)}}wt.empty=new wt([],[]);wt.removeOverlap=i0;const Bn=wt.empty;class Li{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,za));return Li.from(r)}forChild(e,n){if(n.isLeaf)return wt.empty;let r=[];for(let s=0;s<this.members.length;s++){let a=this.members[s].forChild(e,n);a!=Bn&&(a instanceof Li?r=r.concat(a.members):r.push(a))}return Li.from(r)}eq(e){if(!(e instanceof Li)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let a=this.members[s].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?i0(r?n:n.sort($a)):Lo}static from(e){switch(e.length){case 0:return Bn;case 1:return e[0];default:return new Li(e.every(n=>n instanceof wt)?e:e.reduce((n,r)=>n.concat(r instanceof wt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function rL(t,e,n,r,s,a,o){let c=t.slice();for(let h=0,f=a;h<n.maps.length;h++){let m=0;n.maps[h].forEach((g,y,v,j)=>{let w=j-v-(y-g);for(let k=0;k<c.length;k+=3){let E=c[k+1];if(E<0||g>E+f-m)continue;let C=c[k]+f-m;y>=C?c[k+1]=g<=C?-2:-1:g>=f&&w&&(c[k]+=w,c[k+1]+=w)}m+=w}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h<c.length;h+=3)if(c[h+1]<0){if(c[h+1]==-2){u=!0,c[h+1]=-1;continue}let f=n.map(t[h]+a),m=f-s;if(m<0||m>=r.content.size){u=!0;continue}let g=n.map(t[h+1]+a,-1),y=g-s,{index:v,offset:j}=r.content.findIndex(m),w=r.maybeChild(v);if(w&&j==m&&j+w.nodeSize==y){let k=c[h+2].mapInner(n,w,f+1,t[h]+a+1,o);k!=Bn?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=sL(c,t,e,n,s,a,o),f=rh(h,r,0,o);e=f.local;for(let m=0;m<c.length;m+=3)c[m+1]<0&&(c.splice(m,3),m-=3);for(let m=0,g=0;m<f.children.length;m+=3){let y=f.children[m];for(;g<c.length&&c[g]<y;)g+=3;c.splice(g,0,f.children[m],f.children[m+1],f.children[m+2])}}return new wt(e.sort($a),c)}function US(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new hn(s.from+e,s.to+e,s.type))}return n}function sL(t,e,n,r,s,a,o){function c(u,h){for(let f=0;f<u.local.length;f++){let m=u.local[f].map(r,s,h);m?n.push(m):o.onRemove&&o.onRemove(u.local[f].spec)}for(let f=0;f<u.children.length;f+=3)c(u.children[f+2],u.children[f]+h+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&c(t[u+2],e[u]+a+1);return n}function KS(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[a]=null);return s}function qS(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function rh(t,e,n,r){let s=[],a=!1;e.forEach((c,u)=>{let h=KS(t,c,u+n);if(h){a=!0;let f=rh(h,c,n+u+1,r);f!=Bn&&s.push(u,u+c.nodeSize,f)}});let o=US(a?qS(t):t,-n).sort($a);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||(r.onRemove&&r.onRemove(o[c].spec),o.splice(c--,1));return o.length||s.length?new wt(o,s):Bn}function $a(t,e){return t.from-e.from||t.to-e.to}function i0(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let a=e[s];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[s]=a.copy(a.from,r.to),B1(e,s+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),B1(e,s,r.copy(a.from,r.to)));break}}}return e}function B1(t,e,n){for(;e<t.length&&$a(n,t[e])>0;)e++;t.splice(e,0,n)}function zm(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Bn&&e.push(r)}),t.cursorWrapper&&e.push(wt.create(t.state.doc,[t.cursorWrapper.deco])),Li.from(e)}const iL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},aL=ur&&Gi<=11;class oL{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class lL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new oL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);ur&&Gi<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Hn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),aL&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,iL)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(P1(this.view)){if(this.suppressingSelectionUpdates)return Qs(this.view);if(ur&&Gi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ua(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=Zo(a))n.add(a);for(let a=e.anchorNode;a;a=Zo(a))if(n.has(a)){r=a;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&P1(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;f<n.length;f++){let m=this.registerMutation(n[f],u);m&&(a=a<0?m.from:Math.min(m.from,a),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(c=!0))}if(u.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let f of u)if(f.nodeName=="BR"&&f.parentNode){let m=f.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&f.parentNode.removeChild(f)}}else if($r&&u.length){let f=u.filter(m=>m.nodeName=="BR");if(f.length==2){let[m,g]=f;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of f){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||uL(e,m)!=y)&&g.remove()}}}let h=null;a<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&nf(r)&&(h=Xx(e))&&h.eq(Ge.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qs(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||s)&&(a>-1&&(e.docView.markDirty(a,o),cL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,hL(e,u)),this.handleDOMChange(a,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Qs(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;f<e.addedNodes.length;f++){let m=e.addedNodes[f];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,a=e.nextSibling;if(ur&&Gi<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:m,nextSibling:g}=e.addedNodes[f];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let o=s&&s.parentNode==e.target?Rn(s)+1:0,c=r.localPosFromDOM(e.target,o,-1),u=a&&a.parentNode==e.target?Rn(a):e.target.childNodes.length,h=r.localPosFromDOM(e.target,u,1);return{from:c,to:h}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let V1=new WeakMap,H1=!1;function cL(t){if(!V1.has(t)&&(V1.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=$r,H1)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),H1=!0}}function W1(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Ua(o.node,o.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function dL(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return W1(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?W1(t,n):null}function uL(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function hL(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let a of e)if(((n=a.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=a.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let c=o;for(;;){let u=c.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;c=u}c.insertBefore(a,c.firstChild),r==a&&t.domSelection().collapse(a,s)}else a.parentNode.removeChild(a)}}function fL(t,e,n){let{node:r,fromOffset:s,toOffset:a,from:o,to:c}=t.docView.parseRange(e,n),u=t.domSelectionRange(),h,f=u.anchorNode;if(f&&t.dom.contains(f.nodeType==1?f:f.parentNode)&&(h=[{node:f,offset:u.anchorOffset}],nf(u)||h.push({node:u.focusNode,offset:u.focusOffset})),Pn&&t.input.lastKeyCode===8)for(let w=a;w>s;w--){let k=r.childNodes[w-1],E=k.pmViewDesc;if(k.nodeName=="BR"&&!E){a=w;break}if(!E||E.size)break}let m=t.state.doc,g=t.someProp("domParser")||qi.fromSchema(t.state.schema),y=m.resolve(o),v=null,j=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:s,to:a,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:pL,context:y});if(h&&h[0].pos!=null){let w=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=w),v={anchor:w+o,head:k+o}}return{doc:j,sel:v,from:o,to:c}}function pL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Hn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Hn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const mL=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function gL(t,e,n,r,s){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let R=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=Xx(t,R);if(I&&!t.state.selection.eq(I)){if(Pn&&qs&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",O=>O(t,Ma(13,"Enter"))))return;let A=t.state.tr.setSelection(I);R=="pointer"?A.setMeta("pointer",!0):R=="key"&&A.scrollIntoView(),a&&A.setMeta("composition",a),t.dispatch(A)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,h=fL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.input.lastKeyCode=null;let v=vL(m.content,h.doc.content,h.from,g,y);if(v&&t.input.domChangeCount++,(el&&t.input.lastIOSEnter>Date.now()-225||qs)&&s.some(R=>R.nodeType==1&&!mL.test(R.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",R=>R(t,Ma(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof He&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let R=U1(t,t.state.doc,h.sel);if(R&&!R.eq(t.state.selection)){let I=t.state.tr.setSelection(R);a&&I.setMeta("composition",a),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof He&&(v.start>t.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?v.start=t.state.selection.from:v.endA<t.state.selection.to&&v.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),ur&&Gi<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>h.from&&h.doc.textBetween(v.start-h.from-1,v.start-h.from+1)=="  "&&(v.start--,v.endA--,v.endB--);let j=h.doc.resolveNoCache(v.start-h.from),w=h.doc.resolveNoCache(v.endB-h.from),k=f.resolve(v.start),E=j.sameParent(w)&&j.parent.inlineContent&&k.end()>=v.endA;if((el&&t.input.lastIOSEnter>Date.now()-225&&(!E||s.some(R=>R.nodeName=="DIV"||R.nodeName=="P"))||!E&&j.pos<h.doc.content.size&&(!j.sameParent(w)||!j.parent.inlineContent)&&j.pos<w.pos&&!/\S/.test(h.doc.textBetween(j.pos,w.pos,"","")))&&t.someProp("handleKeyDown",R=>R(t,Ma(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&yL(f,v.start,v.endA,j,w)&&t.someProp("handleKeyDown",R=>R(t,Ma(8,"Backspace")))){qs&&Pn&&t.domObserver.suppressSelectionUpdates();return}Pn&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),qs&&!E&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,w=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(R){return R(t,Ma(13,"Enter"))})},20));let C=v.start,M=v.endA,D=R=>{let I=R||t.state.tr.replace(C,M,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let A=U1(t,I.doc,h.sel);A&&!(Pn&&t.composing&&A.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==C||A.head==I.mapping.map(M)-1)||ur&&A.empty&&A.head==C)&&I.setSelection(A)}return a&&I.setMeta("composition",a),I.scrollIntoView()},F;if(E)if(j.pos==w.pos){ur&&Gi<=11&&j.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qs(t),20));let R=D(t.state.tr.delete(C,M)),I=f.resolve(v.start).marksAcross(f.resolve(v.endA));I&&R.ensureMarks(I),t.dispatch(R)}else if(v.endA==v.endB&&(F=xL(j.parent.content.cut(j.parentOffset,w.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start())))){let R=D(t.state.tr);F.type=="add"?R.addMark(C,M,F.mark):R.removeMark(C,M,F.mark),t.dispatch(R)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let R=j.parent.textBetween(j.parentOffset,w.parentOffset),I=()=>D(t.state.tr.insertText(R,C,M));t.someProp("handleTextInput",A=>A(t,C,M,R,I))||t.dispatch(I())}else t.dispatch(D());else t.dispatch(D())}function U1(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Zx(t,e.resolve(n.anchor),e.resolve(n.head))}function xL(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,a=r,o,c,u;for(let f=0;f<r.length;f++)s=r[f].removeFromSet(s);for(let f=0;f<n.length;f++)a=n[f].removeFromSet(a);if(s.length==1&&a.length==0)c=s[0],o="add",u=f=>f.mark(c.addToSet(f.marks));else if(s.length==0&&a.length==1)c=a[0],o="remove",u=f=>f.mark(c.removeFromSet(f.marks));else return null;let h=[];for(let f=0;f<e.childCount;f++)h.push(u(e.child(f)));if(pe.from(h).eq(t))return{mark:c,type:o}}function yL(t,e,n,r,s){if(n-e<=s.pos-r.pos||$m(r,!0,!1)<s.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let c=a.nodeAfter;return c!=null&&n==e+c.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve($m(a,!0,!0));return!o.parent.isTextblock||o.pos>n||$m(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function $m(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,s++}return s}function vL(t,e,n,r,s){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let u=Math.max(0,a-Math.min(o,c));r-=o+u-a}if(o<a&&t.size<e.size){let u=r<=a&&r>=o?a-r:0;a-=u,a&&a<e.size&&K1(e.textBetween(a-1,a+1))&&(a+=u?1:-1),c=a+(c-o),o=a}else if(c<a){let u=r<=a&&r>=c?a-r:0;a-=u,a&&a<t.size&&K1(t.textBetween(a-1,a+1))&&(a+=u?1:-1),o=a+(o-c),c=a}return{start:a,endA:o,endB:c}}function K1(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class GS{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new DD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Q1),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=J1(this),G1(this),this.nodeViews=Y1(this),this.docView=E1(this.state.doc,q1(this),zm(this),this.dom,this),this.domObserver=new lL(this,(r,s,a,o)=>gL(this,r,s,a,o)),this.domObserver.start(),LD(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Bg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Q1),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(BS(this),o=!0),this.state=e;let c=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=Y1(this);wL(y,this.nodeViews)&&(this.nodeViews=y,a=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Bg(this),this.editable=J1(this),G1(this);let u=zm(this),h=q1(this),f=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=a||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(s.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&YO(this);if(o){this.domObserver.stop();let y=m&&(ur||Pn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&bL(s.selection,e.selection);if(m){let v=Pn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=YD(this)),(a||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=E1(e.doc,h,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bD(this))?Qs(this,y):(MS(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&QO(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ve){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&w1(this,n.getBoundingClientRect(),e)}else w1(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(s=a)}this.dragging=new HS(e.slice,e.move,s<0?void 0:Ve.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let c=this.directPlugins[o].props[e];if(c!=null&&(s=n?n(c):c))return s}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let c=a[o].props[e];if(c!=null&&(s=n?n(c):c))return s}}hasFocus(){if(ur){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&XO(this.dom),Qs(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rD(this,e)}coordsAtPos(e,n=1){return wS(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return lD(this,n||this.state,e)}pasteHTML(e,n){return Rc(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Rc(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return e0(this,e)}destroy(){this.docView&&(_D(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],zm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,FO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $D(this,e)}domSelectionRange(){let e=this.domSelection();return e?Hn&&this.root.nodeType===11&&UO(this.dom.ownerDocument)==this.dom&&dL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}GS.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function q1(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[hn.node(0,t.state.doc.content.size,e)]}function G1(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:hn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function J1(t){return!t.someProp("editable",e=>e(t.state)===!1)}function bL(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Y1(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function wL(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Q1(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Xi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},sh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},NL=typeof navigator<"u"&&/Mac/.test(navigator.platform),jL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var In=0;In<10;In++)Xi[48+In]=Xi[96+In]=String(In);for(var In=1;In<=24;In++)Xi[In+111]="F"+In;for(var In=65;In<=90;In++)Xi[In]=String.fromCharCode(In+32),sh[In]=String.fromCharCode(In);for(var Fm in Xi)sh.hasOwnProperty(Fm)||(sh[Fm]=Xi[Fm]);function kL(t){var e=NL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||jL&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?sh:Xi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const SL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),CL=typeof navigator<"u"&&/Win/.test(navigator.platform);function EL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,a,o;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))SL?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function TL(t){let e=Object.create(null);for(let n in t)e[EL(n)]=t[n];return e}function Bm(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function ML(t){return new Ct({props:{handleKeyDown:a0(t)}})}function a0(t){let e=TL(t);return function(n,r){let s=kL(r),a,o=e[Bm(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let c=e[Bm(s,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(CL&&r.ctrlKey&&r.altKey)&&(a=Xi[r.keyCode])&&a!=s){let c=e[Bm(a,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var AL=Object.defineProperty,o0=(t,e)=>{for(var n in e)AL(t,n,{get:e[n],enumerable:!0})};function af(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,a=n.storedMarks,n}}}var of=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,a=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(a);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:a}=r,o=[],c=!!t,u=t||s.tr,h=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(u),o.every(m=>m===!0)),f={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...v)=>{const j=this.buildProps(u,e),w=g(...v)(j);return o.push(w),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,a=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:af({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...h)=>u(...h)(o)]))}};return o}},JS={};o0(JS,{blur:()=>RL,clearContent:()=>IL,clearNodes:()=>PL,command:()=>OL,createParagraphNear:()=>DL,cut:()=>LL,deleteCurrentNode:()=>_L,deleteNode:()=>zL,deleteRange:()=>$L,deleteSelection:()=>FL,enter:()=>BL,exitCode:()=>VL,extendMarkRange:()=>HL,first:()=>WL,focus:()=>KL,forEach:()=>qL,insertContent:()=>GL,insertContentAt:()=>QL,joinBackward:()=>e8,joinDown:()=>ZL,joinForward:()=>t8,joinItemBackward:()=>n8,joinItemForward:()=>r8,joinTextblockBackward:()=>s8,joinTextblockForward:()=>i8,joinUp:()=>XL,keyboardShortcut:()=>o8,lift:()=>l8,liftEmptyBlock:()=>c8,liftListItem:()=>d8,newlineInCode:()=>u8,resetAttributes:()=>h8,scrollIntoView:()=>f8,selectAll:()=>p8,selectNodeBackward:()=>m8,selectNodeForward:()=>g8,selectParentNode:()=>x8,selectTextblockEnd:()=>y8,selectTextblockStart:()=>v8,setContent:()=>b8,setMark:()=>F8,setMeta:()=>B8,setNode:()=>V8,setNodeSelection:()=>H8,setTextDirection:()=>W8,setTextSelection:()=>U8,sinkListItem:()=>K8,splitBlock:()=>q8,splitListItem:()=>G8,toggleList:()=>J8,toggleMark:()=>Y8,toggleNode:()=>Q8,toggleWrap:()=>X8,undoInputRule:()=>Z8,unsetAllMarks:()=>e6,unsetMark:()=>t6,unsetTextDirection:()=>n6,updateAttributes:()=>r6,wrapIn:()=>s6,wrapInList:()=>i6});var RL=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),IL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),PL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(c,u)=>{if(c.type.isText)return;const{doc:h,mapping:f}=e,m=h.resolve(f.map(u)),g=h.resolve(f.map(u+c.nodeSize)),y=m.blockRange(g);if(!y)return;const v=hl(y);if(c.type.isTextblock){const{defaultType:j}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,j)}(v||v===0)&&e.lift(y,v)})}),!0},OL=t=>e=>t(e),DL=()=>({state:t,dispatch:e})=>dS(t,e),LL=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,a=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new He(r.doc.resolve(Math.max(o-1,0)))),!0},_L=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let a=s.depth;a>0;a-=1)if(s.node(a).type===r.type){if(e){const c=s.before(a),u=s.after(a);t.delete(c,u).scrollIntoView()}return!0}return!1};function ln(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var zL=t=>({tr:e,state:n,dispatch:r})=>{const s=ln(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===s){if(r){const u=a.before(o),h=a.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},$L=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},FL=()=>({state:t,dispatch:e})=>Kx(t,e),BL=()=>({commands:t})=>t.keyboardShortcut("Enter"),VL=()=>({state:t,dispatch:e})=>SO(t,e);function l0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ih(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:l0(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function YS(t,e,n={}){return t.find(r=>r.type===e&&ih(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function X1(t,e,n={}){return!!YS(t,e,n)}function c0(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(f=>f.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(f=>f.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!YS([...s.node.marks],e,n)))return;let o=s.index,c=t.start()+s.offset,u=o+1,h=c+s.node.nodeSize;for(;o>0&&X1([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u<t.parent.childCount&&X1([...t.parent.child(u).marks],e,n);)h+=t.parent.child(u).nodeSize,u+=1;return{from:c,to:h}}function ni(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var HL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const a=ni(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(s){const m=c0(u,a,e);if(m&&m.from<=h&&m.to>=f){const g=He.create(o,m.from,m.to);n.setSelection(g)}}return!0},WL=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function QS(t){return t instanceof He}function Pa(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function XS(t,e=null){if(!e)return null;const n=Ge.atStart(t),r=Ge.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,a=r.to;return e==="all"?He.create(t,Pa(0,s,a),Pa(t.content.size,s,a)):He.create(t,Pa(e,s,a),Pa(e,s,a))}function Z1(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ah(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function UL(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var KL=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(ah()||Z1())&&r.dom.focus(),UL()&&!ah()&&!Z1()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(a&&t===null&&!QS(n.state.selection))return o(),!0;const c=XS(s.doc,t)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||s.setSelection(c),u&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},qL=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),GL=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ZS=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&ZS(r)}return t};function gu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ZS(n)}function Pc(t,e,n){if(t instanceof Js||t instanceof pe)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return pe.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Pc("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,c="";const u=new _k({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:h=>(o=!0,c=typeof h=="string"?h:h.outerHTML,null)}]}})});if(n.slice?qi.fromSchema(u).parseSlice(gu(t),n.parseOptions):qi.fromSchema(u).parse(gu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const a=qi.fromSchema(e);return n.slice?a.parseSlice(gu(t),n.parseOptions).content:a.parse(gu(t),n.parseOptions)}return Pc("",e,n)}function JL(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof wn||s instanceof jn))return;const a=t.mapping.maps[r];let o=0;a.forEach((c,u,h,f)=>{o===0&&(o=f)}),t.setSelection(Ge.near(t.doc.resolve(o),n))}var YL=t=>!("type"in t),QL=(t,e,n)=>({tr:r,dispatch:s,editor:a})=>{var o;if(s){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=w=>{a.emit("contentError",{editor:a,error:w,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},h={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Pc(e,a.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(w){u(w)}try{c=Pc(e,a.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(w){return u(w),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((YL(c)?c:[c]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,y=y?w.isBlock:!1}),f===m&&y){const{parent:w}=r.doc.resolve(f);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(f-=1,m+=1)}let j;if(g){if(Array.isArray(e))j=e.map(w=>w.text||"").join("");else if(e instanceof pe){let w="";e.forEach(k=>{k.text&&(w+=k.text)}),j=w}else typeof e=="object"&&e&&e.text?j=e.text:j=e;r.insertText(j,f,m)}else{j=c;const w=r.doc.resolve(f),k=w.node(),E=w.parentOffset===0,C=k.isText||k.isTextblock,M=k.content.size>0;E&&C&&M&&(f=Math.max(0,f-1)),r.replaceWith(f,m,j)}n.updateSelection&&JL(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:f,text:j}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:f,text:j})}return!0},XL=()=>({state:t,dispatch:e})=>NO(t,e),ZL=()=>({state:t,dispatch:e})=>jO(t,e),e8=()=>({state:t,dispatch:e})=>rS(t,e),t8=()=>({state:t,dispatch:e})=>oS(t,e),n8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Zh(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},r8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Zh(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},s8=()=>({state:t,dispatch:e})=>bO(t,e),i8=()=>({state:t,dispatch:e})=>wO(t,e);function eC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function a8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,a,o;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))ah()||eC()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var o8=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const a=a8(t).split(/-(?!$)/),o=a.find(h=>!["Alt","Ctrl","Meta","Shift"].includes(h)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",h=>h(n,c))});return u==null||u.steps.forEach(h=>{const f=h.map(r.mapping);f&&s&&r.maybeStep(f)}),!0};function Zi(t,e,n={}){const{from:r,to:s,empty:a}=t.selection,o=e?ln(e,t.schema):null,c=[];t.doc.nodesBetween(r,s,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),v=Math.min(s,g+m.nodeSize);c.push({node:m,from:y,to:v})});const u=s-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>ih(m.node.attrs,n,{strict:!1}));return a?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var l8=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return Zi(n,s,e)?kO(n,r):!1},c8=()=>({state:t,dispatch:e})=>uS(t,e),d8=t=>({state:e,dispatch:n})=>{const r=ln(t,e.schema);return LO(r)(e,n)},u8=()=>({state:t,dispatch:e})=>cS(t,e);function lf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ew(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var h8=(t,e)=>({tr:n,state:r,dispatch:s})=>{let a=null,o=null;const c=lf(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=ln(t,r.schema)),c==="mark"&&(o=ni(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{r.doc.nodesBetween(h.$from.pos,h.$to.pos,(f,m)=>{a&&a===f.type&&(u=!0,s&&n.setNodeMarkup(m,void 0,ew(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,s&&n.addMark(m,m+f.nodeSize,o.create(ew(g.attrs,e))))})})}),u},f8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),p8=()=>({tr:t,dispatch:e})=>{if(e){const n=new kr(t.doc);t.setSelection(n)}return!0},m8=()=>({state:t,dispatch:e})=>iS(t,e),g8=()=>({state:t,dispatch:e})=>lS(t,e),x8=()=>({state:t,dispatch:e})=>TO(t,e),y8=()=>({state:t,dispatch:e})=>RO(t,e),v8=()=>({state:t,dispatch:e})=>AO(t,e);function Vg(t,e,n={},r={}){return Pc(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var b8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:a,dispatch:o,commands:c})=>{const{doc:u}=a;if(r.preserveWhitespace!=="full"){const h=Vg(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&a.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function tC(t,e){const n=ni(e,t.schema),{from:r,to:s,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function nC(t,e){const n=new Wx(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function w8(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function N8(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,a)=>{n(s)&&r.push({node:s,pos:a})}),r}function rC(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function cf(t){return e=>rC(e.$from,t)}function $e(t,e,n){return t.config[e]===void 0&&t.parent?$e(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?$e(t.parent,e,n):null}):t.config[e]}function d0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=$e(e,"addExtensions",n);return r?[e,...d0(r())]:e}).flat(10)}function u0(t,e){const n=Za.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function sC(t){return typeof t=="function"}function pt(t,e=void 0,...n){return sC(t)?e?t.bind(e)(...n):t(...n):t}function j8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function tl(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function iC(t){const e=[],{nodeExtensions:n,markExtensions:r}=tl(t),s=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(h=>h.name!=="text").map(h=>h.name),c=r.map(h=>h.name),u=[...o,...c];return t.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage,extensions:s},m=$e(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let v;Array.isArray(y.types)?v=y.types:y.types==="*"?v=u:y.types==="nodes"?v=o:y.types==="marks"?v=c:v=[],v.forEach(j=>{Object.entries(y.attributes).forEach(([w,k])=>{e.push({type:j,name:w,attribute:{...a,...k}})})})})}),s.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=$e(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,v])=>{const j={...a,...v};typeof(j==null?void 0:j.default)=="function"&&(j.default=j.default()),j!=null&&j.isRequired&&(j==null?void 0:j.default)===void 0&&delete j.default,e.push({type:h.name,name:y,attribute:j})})}),e}function k8(t){const e=[];let n="",r=!1,s=!1,a=0;const o=t.length;for(let c=0;c<o;c+=1){const u=t[c];if(u==="'"&&!s){r=!r,n+=u;continue}if(u==='"'&&!r){s=!s,n+=u;continue}if(!r&&!s){if(u==="("){a+=1,n+=u;continue}if(u===")"&&a>0){a-=1,n+=u;continue}if(u===";"&&a===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function tw(t){const e=[],n=k8(t||""),r=n.length;for(let s=0;s<r;s+=1){const a=n[s],o=a.indexOf(":");if(o===-1)continue;const c=a.slice(0,o).trim(),u=a.slice(o+1).trim();c&&u&&e.push([c,u])}return e}function vt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,a])=>{if(!r[s]){r[s]=a;return}if(s==="class"){const c=a?String(a).split(" "):[],u=r[s]?r[s].split(" "):[],h=c.filter(f=>!u.includes(f));r[s]=[...u,...h].join(" ")}else if(s==="style"){const c=new Map([...tw(r[s]),...tw(a)]);r[s]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[s]=a}),r},{})}function Oc(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>vt(n,r),{})}function S8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function nw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((a,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):S8(n.getAttribute(o.name));return c==null?a:{...a,[o.name]:c}},{});return{...r,...s}}}}function rw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&j8(n)?!1:n!=null))}function sw(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function C8(t,e){var n;const r=iC(t),{nodeExtensions:s,markExtensions:a}=tl(t),o=(n=s.find(h=>$e(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(s.map(h=>{const f=r.filter(k=>k.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((k,E)=>{const C=$e(E,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),y=rw({...g,content:pt($e(h,"content",m)),marks:pt($e(h,"marks",m)),group:pt($e(h,"group",m)),inline:pt($e(h,"inline",m)),atom:pt($e(h,"atom",m)),selectable:pt($e(h,"selectable",m)),draggable:pt($e(h,"draggable",m)),code:pt($e(h,"code",m)),whitespace:pt($e(h,"whitespace",m)),linebreakReplacement:pt($e(h,"linebreakReplacement",m)),defining:pt($e(h,"defining",m)),isolating:pt($e(h,"isolating",m)),attrs:Object.fromEntries(f.map(sw))}),v=pt($e(h,"parseHTML",m));v&&(y.parseDOM=v.map(k=>nw(k,f)));const j=$e(h,"renderHTML",m);j&&(y.toDOM=k=>j({node:k,HTMLAttributes:Oc(k,f)}));const w=$e(h,"renderText",m);return w&&(y.toText=w),[h.name,y]})),u=Object.fromEntries(a.map(h=>{const f=r.filter(w=>w.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((w,k)=>{const E=$e(k,"extendMarkSchema",m);return{...w,...E?E(h):{}}},{}),y=rw({...g,inclusive:pt($e(h,"inclusive",m)),excludes:pt($e(h,"excludes",m)),group:pt($e(h,"group",m)),spanning:pt($e(h,"spanning",m)),code:pt($e(h,"code",m)),attrs:Object.fromEntries(f.map(sw))}),v=pt($e(h,"parseHTML",m));v&&(y.parseDOM=v.map(w=>nw(w,f)));const j=$e(h,"renderHTML",m);return j&&(y.toDOM=w=>j({mark:w,HTMLAttributes:Oc(w,f)})),[h.name,y]}));return new _k({topNode:o,nodes:c,marks:u})}function E8(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function pc(t){return t.sort((n,r)=>{const s=$e(n,"priority")||100,a=$e(r,"priority")||100;return s>a?-1:s<a?1:0})}function aC(t){const e=pc(d0(t)),n=E8(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function oC(t,e,n){const{from:r,to:s}=e,{blockSeparator:a=`
`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,s,(u,h,f,m)=>{var g;u.isBlock&&h>r&&(c+=a);const y=o==null?void 0:o[u.type.name];if(y)return f&&(c+=y({node:u,pos:h,parent:f,index:m,range:e})),!1;u.isText&&(c+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(r,h)-h,s-h))}),c}function T8(t,e){const n={from:0,to:t.content.size};return oC(t,n,e)}function lC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function M8(t,e){const n=ln(e,t.schema),{from:r,to:s}=t.selection,a=[];t.doc.nodesBetween(r,s,c=>{a.push(c)});const o=a.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function cC(t,e){const n=lf(typeof e=="string"?e:e.name,t.schema);return n==="node"?M8(t,e):n==="mark"?tC(t,e):{}}function A8(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function R8(t){const e=A8(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function dC(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,a)=>{const o=[];if(s.ranges.length)s.forEach((c,u)=>{o.push({from:c,to:u})});else{const{from:c,to:u}=n[a];if(c===void 0||u===void 0)return;o.push({from:c,to:u})}o.forEach(({from:c,to:u})=>{const h=e.slice(a).map(c,-1),f=e.slice(a).map(u),m=e.invert().map(h,-1),g=e.invert().map(f);r.push({oldRange:{from:m,to:g},newRange:{from:h,to:f}})})}),R8(r)}function h0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const a=n.resolve(t),o=c0(a,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,a)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:a,to:a+s.nodeSize,mark:o})))}),r}var I8=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const c=s.node(a);(c==null?void 0:c.type.name)===e?o=c:a-=1}return[o,a]};function Ql(t,e){return e.nodes[t]||e.marks[t]||null}function Ou(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(a=>a.type===e&&a.name===r);return s?s.attribute.keepOnSplit:!1}))}var P8=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,a,o,c)=>{var u,h;const f=((h=(u=s.type.spec).toText)==null?void 0:h.call(u,{node:s,pos:a,parent:o,index:c}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?f:f.slice(0,Math.max(0,r-a))}),n};function Hg(t,e,n={}){const{empty:r,ranges:s}=t.selection,a=e?ni(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>ih(m.attrs,n,{strict:!1}));let o=0;const c=[];if(s.forEach(({$from:m,$to:g})=>{const y=m.pos,v=g.pos;t.doc.nodesBetween(y,v,(j,w)=>{if(a&&j.inlineContent&&!j.type.allowsMarkType(a))return!1;if(!j.isText&&!j.marks.length)return;const k=Math.max(y,w),E=Math.min(v,w+j.nodeSize),C=E-k;o+=C,c.push(...j.marks.map(M=>({mark:M,from:k,to:E})))})}),o===0)return!1;const u=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>ih(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),h=c.filter(m=>a?m.mark.type!==a&&m.mark.type.excludes(a):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+h:u)>=o}function O8(t,e,n={}){if(!e)return Zi(t,null,n)||Hg(t,null,n);const r=lf(e,t.schema);return r==="node"?Zi(t,e,n):r==="mark"?Hg(t,e,n):!1}var D8=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const a=cf(c=>c.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},L8=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function iw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function aw(t,e){const{nodeExtensions:n}=tl(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},a=pt($e(r,"group",s));return typeof a!="string"?!1:a.split(" ").includes("list")}function df(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(a=>{s!==!1&&(df(a,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function uC(t){return t instanceof Ve}var hC=class fC{constructor(e){this.position=e}static fromJSON(e){return new fC(e.position)}toJSON(){return{position:this.position}}};function _8(t,e){const n=e.mapping.mapResult(t.position);return{position:new hC(n.pos),mapResult:n}}function z8(t){return new hC(t)}function $8(t,e,n){var r;const{selection:s}=e;let a=null;if(QS(s)&&(a=s.$cursor),a){const c=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(h=>h.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:c,$to:u})=>{let h=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(f,m,g)=>{if(h)return!1;if(f.isInline){const y=!g||g.type.allowsMarkType(n),v=!!n.isInSet(f.marks)||!f.marks.some(j=>j.type.excludes(n));h=y&&v}return!h}),h})}var F8=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:a}=n,{empty:o,ranges:c}=a,u=ni(t,r.schema);if(s)if(o){const h=tC(r,u);n.addStoredMark(u.create({...h,...e}))}else c.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;r.doc.nodesBetween(f,m,(g,y)=>{const v=Math.max(y,f),j=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(v,j,u.create({...k.attrs,...e}))}):n.addMark(v,j,u.create(e))})});return $8(r,n,u)},B8=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),V8=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const a=ln(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?s().command(({commands:c})=>y1(a,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>y1(a,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},H8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Pa(t,0,r.content.size),a=Ve.create(r,s);e.setSelection(a)}return!0},W8=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:a}=r;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=a.from,c=a.to),s&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},U8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:a}=typeof t=="number"?{from:t,to:t}:t,o=He.atStart(r).from,c=He.atEnd(r).to,u=Pa(s,o,c),h=Pa(a,o,c),f=He.create(r,u,h);e.setSelection(f)}return!0},K8=t=>({state:e,dispatch:n})=>{const r=ln(t,e.schema);return $O(r)(e,n)};function ow(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var q8=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:a,doc:o}=e,{$from:c,$to:u}=a,h=s.extensionManager.attributes,f=Ou(h,c.node().type.name,c.node().attrs);if(a instanceof Ve&&a.node.isBlock)return!c.parentOffset||!Ys(o,c.pos)?!1:(r&&(t&&ow(n,s.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=c.depth===0?void 0:w8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,v=Ys(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!v&&Ys(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(v=!0,y=g?[{type:g,attrs:f}]:void 0),r){if(v&&(a instanceof He&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const j=e.mapping.map(c.before()),w=e.doc.resolve(j);c.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&ow(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return v},G8=(t,e={})=>({tr:n,state:r,dispatch:s,editor:a})=>{var o;const c=ln(t,r.schema),{$from:u,$to:h}=r.selection,f=r.selection.node;if(f&&f.isBlock||u.depth<2||!u.sameParent(h))return!1;const m=u.node(-1);if(m.type!==c)return!1;const g=a.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(s){let k=pe.empty;const E=u.index(-1)?1:u.index(-2)?2:3;for(let I=u.depth-E;I>=u.depth-3;I-=1)k=pe.from(u.node(I).copy(k));const C=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,M={...Ou(g,u.node().type.name,u.node().attrs),...e},D=((o=c.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;k=k.append(pe.from(c.createAndFill(null,D)||void 0));const F=u.before(u.depth-(E-1));n.replace(F,u.after(-C),new Me(k,4-E,0));let R=-1;n.doc.nodesBetween(F,n.doc.content.size,(I,A)=>{if(R>-1)return!1;I.isTextblock&&I.content.size===0&&(R=A+1)}),R>-1&&n.setSelection(He.near(n.doc.resolve(R))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...Ou(g,m.type.name,m.attrs),...e},j={...Ou(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const w=y?[{type:c,attrs:v},{type:y,attrs:j}]:[{type:c,attrs:v}];if(!Ys(n.doc,u.pos,2))return!1;if(s){const{selection:k,storedMarks:E}=r,{splittableMarks:C}=a.extensionManager,M=E||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,w).scrollIntoView(),!M||!s)return!0;const D=M.filter(F=>C.includes(F.type.name));n.ensureMarks(D)}return!0},Vm=(t,e)=>{const n=cf(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&aa(t.doc,n.pos)&&t.join(n.pos),!0},Hm=(t,e)=>{const n=cf(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&aa(t.doc,r)&&t.join(r),!0},J8=(t,e,n,r={})=>({editor:s,tr:a,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=s.extensionManager,y=ln(t,o.schema),v=ln(e,o.schema),{selection:j,storedMarks:w}=o,{$from:k,$to:E}=j,C=k.blockRange(E),M=w||j.$to.parentOffset&&j.$from.marks();if(!C)return!1;const D=cf(F=>aw(F.type.name,m))(j);if(C.depth>=1&&D&&C.depth-D.depth<=1){if(D.node.type===y)return h.liftListItem(v);if(aw(D.node.type.name,m)&&y.validContent(D.node.content)&&c)return u().command(()=>(a.setNodeMarkup(D.pos,y),!0)).command(()=>Vm(a,y)).command(()=>Hm(a,y)).run()}return!n||!M||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Vm(a,y)).command(()=>Hm(a,y)).run():u().command(()=>{const F=f().wrapInList(y,r),R=M.filter(I=>g.includes(I.type.name));return a.ensureMarks(R),F?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Vm(a,y)).command(()=>Hm(a,y)).run()},Y8=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:a=!1}=n,o=ni(t,r.schema);return Hg(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:a}):s.setMark(o,e)},Q8=(t,e,n={})=>({state:r,commands:s})=>{const a=ln(t,r.schema),o=ln(e,r.schema),c=Zi(r,a,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?s.setNode(o,u):s.setNode(a,{...u,...n})},X8=(t,e={})=>({state:n,commands:r})=>{const s=ln(t,n.schema);return Zi(n,s,e)?r.lift(s):r.wrapIn(s,e)},Z8=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let a;if(s.spec.isInputRules&&(a=s.getState(t))){if(e){const o=t.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)o.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,u))}else o.delete(a.from,a.to)}return!0}}return!1},e6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},t6=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=ni(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!s)return!0;if(f&&o){let{from:g,to:y}=c;const v=(a=h.marks().find(w=>w.type===u))==null?void 0:a.attrs,j=c0(h,u,v);j&&(g=j.from,y=j.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},n6=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=s.from,o=s.to),r&&e.doc.nodesBetween(a,o,(c,u)=>{if(c.isText)return;const h={...c.attrs};delete h.dir,e.setNodeMarkup(u,void 0,h)}),!0},r6=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let a=null,o=null;const c=lf(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=ln(t,r.schema)),c==="mark"&&(o=ni(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,v,j;n.selection.empty?r.doc.nodesBetween(f,m,(w,k)=>{a&&a===w.type&&(u=!0,v=Math.max(k,f),j=Math.min(k+w.nodeSize,m),g=k,y=w)}):r.doc.nodesBetween(f,m,(w,k)=>{k<f&&a&&a===w.type&&(u=!0,v=Math.max(k,f),j=Math.min(k+w.nodeSize,m),g=k,y=w),k>=f&&k<=m&&(a&&a===w.type&&(u=!0,s&&n.setNodeMarkup(k,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(E=>{if(o===E.type&&(u=!0,s)){const C=Math.max(k,f),M=Math.min(k+w.nodeSize,m);n.addMark(C,M,o.create({...E.attrs,...e}))}}))}),y&&(g!==void 0&&s&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(w=>{o===w.type&&s&&n.addMark(v,j,o.create({...w.attrs,...e}))}))}),u},s6=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return IO(s,e)(n,r)},i6=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return PO(s,e)(n,r)},a6=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},uf=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},o6=(t,e)=>{if(l0(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function xu(t){var e;const{editor:n,from:r,to:s,text:a,rules:o,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const h=u.state.doc.resolve(r);if(h.parent.type.spec.code||(e=h.nodeBefore||h.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let f=!1;const m=P8(h)+a;return o.forEach(g=>{if(f)return;const y=o6(m,g.find);if(!y)return;const v=u.state.tr,j=af({state:u.state,transaction:v}),w={from:r-(y[0].length-a.length),to:s},{commands:k,chain:E,can:C}=new of({editor:n,state:j});g.handler({state:j,range:w,match:y,commands:k,chain:E,can:C})===null||!v.steps.length||(g.undoable&&v.setMeta(c,{transform:v,from:r,to:s,text:a}),u.dispatch(v),f=!0)}),f}function l6(t){const{editor:e,rules:n}=t,r=new Ct({state:{init(){return null},apply(s,a,o){const c=s.getMeta(r);if(c)return c;const u=s.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=u0(pe.from(f),o.schema);const{from:m}=u,g=m+f.length;xu({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:a}},props:{handleTextInput(s,a,o,c){return xu({editor:e,from:a,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:a}=s.state.selection;a&&xu({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,a){if(a.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?xu({editor:e,from:o.pos,to:o.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function c6(t){return Object.prototype.toString.call(t).slice(8,-1)}function yu(t){return c6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function pC(t,e){const n={...t};return yu(t)&&yu(e)&&Object.keys(e).forEach(r=>{yu(e[r])&&yu(t[r])?n[r]=pC(t[r],e[r]):n[r]=e[r]}),n}var f0=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...pt($e(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...pt($e(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>pC(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},eo=class mC extends f0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new mC(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(h=>(h==null?void 0:h.type.name)===n.name))return!1;const u=o.find(h=>(h==null?void 0:h.type.name)===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function d6(t){return typeof t=="number"}var u6=class{constructor(t){this.find=t.find,this.handler=t.handler}},h6=(t,e,n)=>{if(l0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const a=[s.text];return a.index=s.index,a.input=t,a.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(s.replaceWith)),a}):[]};function f6(t){const{editor:e,state:n,from:r,to:s,rule:a,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new of({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(y,v)=>{var j,w,k,E,C;if((w=(j=y.type)==null?void 0:j.spec)!=null&&w.code||!(y.isText||y.isTextblock||y.isInline))return;const M=(C=(E=(k=y.content)==null?void 0:k.size)!=null?E:y.nodeSize)!=null?C:0,D=Math.max(r,v),F=Math.min(s,v+M);if(D>=F)return;const R=y.isText?y.text||"":y.textBetween(D-v,F-v,void 0,"");h6(R,a.find,o).forEach(A=>{if(A.index===void 0)return;const O=D+A.index+1,W=O+A[0].length,X={from:n.tr.mapping.map(O),to:n.tr.mapping.map(W)},q=a.handler({state:n,range:X,match:A,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(q)})}),m.every(y=>y!==null)}var vu=null,p6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function m6(t){const{editor:e,rules:n}=t;let r=null,s=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:f,from:m,to:g,rule:y,pasteEvt:v})=>{const j=f.tr,w=af({state:f,transaction:j});if(!(!f6({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:v,dropEvent:c})||!j.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return n.map(f=>new Ct({view(m){const g=v=>{var j;r=(j=m.dom.parentElement)!=null&&j.contains(v.target)?m.dom.parentElement:null,r&&(vu=e)},y=()=>{vu&&(vu=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(a=r===m.dom.parentElement,c=g,!a){const y=vu;y!=null&&y.isEditable&&setTimeout(()=>{const v=y.state.selection;v&&y.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,g)=>{var y;const v=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,s=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const v=m[0],j=v.getMeta("uiEvent")==="paste"&&!s,w=v.getMeta("uiEvent")==="drop"&&!a,k=v.getMeta("applyPasteRules"),E=!!k;if(!j&&!w&&!E)return;if(E){let{text:D}=k;typeof D=="string"?D=D:D=u0(pe.from(D),y.schema);const{from:F}=k,R=F+D.length,I=p6(D);return u({rule:f,state:y,from:F,to:{b:R},pasteEvt:I})}const C=g.doc.content.findDiffStart(y.doc.content),M=g.doc.content.findDiffEnd(y.doc.content);if(!(!d6(C)||!M||C===M.b))return u({rule:f,state:y,from:C,to:M,pasteEvt:o})}}))}var hf=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=aC(t),this.schema=C8(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ql(e.name,this.schema)},r=$e(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return pc([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ql(r.name,this.schema)},a=[],o=$e(r,"addKeyboardShortcuts",s);let c={};if(r.type==="mark"&&$e(r,"exitable",s)&&(c.ArrowRight=()=>eo.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,v])=>[y,()=>v({editor:t})]));c={...c,...g}}const u=ML(c);a.push(u);const h=$e(r,"addInputRules",s);if(iw(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=l6({editor:t,rules:g}),v=Array.isArray(y)?y:[y];a.push(...v)}}const f=$e(r,"addPasteRules",s);if(iw(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=m6({editor:t,rules:g});a.push(...y)}}const m=$e(r,"addProseMirrorPlugins",s);if(m){const g=m();a.push(...g)}return a})}get attributes(){return iC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=tl(this.extensions);return Object.fromEntries(e.filter(n=>!!$e(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ln(n.name,this.schema)},a=$e(n,"addNodeView",s);if(!a)return[];const o=a();if(!o)return[];const c=(u,h,f,m,g)=>{const y=Oc(u,r);return o({node:u,view:h,getPos:f,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return pc([...this.extensions].reverse()).reduceRight((r,s)=>{const a={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ql(s.name,this.schema)},o=$e(s,"dispatchTransaction",a);return o?c=>{o.call(a,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return pc([...this.extensions]).reduce((r,s)=>{const a={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ql(s.name,this.schema)},o=$e(s,"transformPastedHTML",a);return o?(c,u)=>{const h=r(c,u);return o.call(a,h)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=tl(this.extensions);return Object.fromEntries(e.filter(n=>!!$e(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ni(n.name,this.schema)},a=$e(n,"addMarkView",s);if(!a)return[];const o=(c,u,h)=>{const f=Oc(c,r);return a()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{A6(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ql(e.name,this.schema)};e.type==="mark"&&((n=pt($e(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=$e(e,"onBeforeCreate",r),a=$e(e,"onCreate",r),o=$e(e,"onUpdate",r),c=$e(e,"onSelectionUpdate",r),u=$e(e,"onTransaction",r),h=$e(e,"onFocus",r),f=$e(e,"onBlur",r),m=$e(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),a&&this.editor.on("create",a),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),h&&this.editor.on("focus",h),f&&this.editor.on("blur",f),m&&this.editor.on("destroy",m)})}};hf.resolve=aC;hf.sort=pc;hf.flatten=d0;var g6={};o0(g6,{ClipboardTextSerializer:()=>xC,Commands:()=>yC,Delete:()=>vC,Drop:()=>bC,Editable:()=>wC,FocusEvents:()=>jC,Keymap:()=>kC,Paste:()=>SC,Tabindex:()=>CC,TextDirection:()=>EC,focusEventsPluginKey:()=>NC});var Gt=class gC extends f0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new gC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},xC=Gt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ct({key:new _t("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:a}=s,o=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=lC(n);return oC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),yC=Gt.create({name:"commands",addCommands(){return{...JS}}}),vC=Gt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const a=()=>{var o,c,u,h;if((h=(u=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?h:t.getMeta("y-sync$"))return;const f=nC(t.before,[t,...e]);dC(f).forEach(y=>{f.mapping.mapResult(y.oldRange.from).deletedAfter&&f.mapping.mapResult(y.oldRange.to).deletedBefore&&f.before.nodesBetween(y.oldRange.from,y.oldRange.to,(v,j)=>{const w=j+v.nodeSize-2,k=y.oldRange.from<=j&&w<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:j,to:w,newFrom:f.mapping.map(j),newTo:f.mapping.map(w),deletedRange:y.oldRange,newRange:y.newRange,partial:!k,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,v)=>{var j,w;if(y instanceof Xr){const k=g.slice(v).map(y.from,-1),E=g.slice(v).map(y.to),C=g.invert().map(k,-1),M=g.invert().map(E),D=(j=f.doc.nodeAt(k-1))==null?void 0:j.marks.some(R=>R.eq(y.mark)),F=(w=f.doc.nodeAt(E))==null?void 0:w.marks.some(R=>R.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:C,to:M},newRange:{from:k,to:E},partial:!!(F||D),editor:this.editor,transaction:t,combinedTransform:f})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(a,0):a()}}),bC=Gt.create({name:"drop",addProseMirrorPlugins(){return[new Ct({key:new _t("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),wC=Gt.create({name:"editable",addProseMirrorPlugins(){return[new Ct({key:new _t("editable"),props:{editable:()=>this.editor.options.editable}})]}}),NC=new _t("focusEvents"),jC=Gt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ct({key:NC,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),kC=Gt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:u,doc:h}=c,{empty:f,$anchor:m}=u,{pos:g,parent:y}=m,v=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,j=v.parent.type.spec.isolating,w=m.pos-m.parentOffset,k=j&&v.parent.childCount===1?w===m.pos:Ge.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!k||k&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ah()||eC()?a:s},addProseMirrorPlugins(){return[new Ct({key:new _t("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(j=>j.getMeta("composition")))return;const r=t.some(j=>j.docChanged)&&!e.doc.eq(n.doc),s=t.some(j=>j.getMeta("preventClearDocument"));if(!r||s)return;const{empty:a,from:o,to:c}=e.selection,u=Ge.atStart(e.doc).from,h=Ge.atEnd(e.doc).to;if(a||!(o===u&&c===h)||!df(n.doc))return;const g=n.tr,y=af({state:n,transaction:g}),{commands:v}=new of({editor:this.editor,state:y});if(v.clearNodes(),!!g.steps.length)return g}})]}}),SC=Gt.create({name:"paste",addProseMirrorPlugins(){return[new Ct({key:new _t("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),CC=Gt.create({name:"tabindex",addProseMirrorPlugins(){return[new Ct({key:new _t("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),EC=Gt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=tl(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ct({key:new _t("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),x6=class ic{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You cant set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ic(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ic(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ic(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+r+(a?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!s&&!o&&u.depth<=this.depth)return;const h=new ic(u,this.editor,s,s||o?n:null);s&&(h.actualDepth=this.depth+1),e.push(h)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const a=s.node.attrs,o=Object.keys(n);for(let c=0;c<o.length;c+=1){const u=o[c];if(a[u]!==n[u])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const a=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&a.every(u=>n[u]===o.node.attrs[u])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},y6=`.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror [contenteditable="false"] {
white-space: normal;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 0 !important;
height: 0 !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`;function v6(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var b6=class extends a6{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:_8,createMappablePosition:z8},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:a})=>this.options.onDrop(r,s,a)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=XS(e,this.options.autofocus);this.editorState=Ho.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=v6(y6,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=sC(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const a=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[wC,xC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),yC,jC,kC,CC,bC,SC,vC,EC.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new hf(r,this)}createCommandManager(){this.commandManager=new of({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Vg(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Vg(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,a=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new GS(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const c=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(c),this.prependClass(),this.injectCSS();const u=this.view.dom;u.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(h=>{var f;return(f=this.capturedTransaction)==null?void 0:f.step(h)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(h=>h.getMeta("focus")||h.getMeta("blur")),c=o==null?void 0:o.getMeta("focus"),u=o==null?void 0:o.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(h=>h.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return cC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return O8(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return u0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
`,textSerializers:n={}}=t||{};return T8(this.state.doc,{blockSeparator:e,textSerializers:{...lC(this.schema),...n}})}get isEmpty(){return df(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new x6(e,this)}get $doc(){return this.$pos(0)}};function nl(t){return new uf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=pt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],c=r[0];if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),f=h+o.length;if(h0(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(j=>j===t.type&&j!==y.mark.type)).filter(y=>y.to>h).length)return null;f<n.to&&a.delete(f,n.to),h>n.from&&a.delete(n.from+u,h);const g=n.from+u+o.length;a.addMark(n.from+u,g,t.type.create(s||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function TC(t){return new uf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=pt(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let c=n.to;const u=t.type.create(s);if(r[1]){const h=r[0].lastIndexOf(r[1]);let f=o+h;f>c?f=c:c=f+r[1].length;const m=r[0][r[0].length-1];a.insertText(m,o+r[0].length-1),a.replaceWith(f,c,u)}else if(r[0]){const h=t.type.isInline?o:o-1;a.insert(h,t.type.create(s)).delete(a.mapping.map(o),a.mapping.map(c))}a.scrollIntoView()},undoable:t.undoable})}function Wg(t){return new uf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),a=pt(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function rl(t){return new uf({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const a=pt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&Hx(u,t.type,a);if(!h)return null;if(o.wrap(u,h),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,v=g||m.$to.parentOffset&&m.$from.marks();if(v){const j=v.filter(w=>y.includes(w.type.name));o.ensureMarks(j)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,a).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&aa(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var w6=t=>"touches"in t,N6=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,h=c.clientY-this.startY;this.handleResize(u,h)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const h=u.clientX-this.startX,f=u.clientY-this.startY;this.handleResize(h,f)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,a,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,w6(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,s,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const a=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),c?s=this.startHeight+n:u&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,a,o;if(!n){let h=Math.max(this.minSize.width,t),f=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(h=Math.min(this.maxSize.width,h)),(s=this.maxSize)!=null&&s.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return c<this.minSize.width&&(c=this.minSize.width,u=c/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,c=u*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&c>this.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function j6(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ve){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let s=r.depth;for(;s>=0;){const a=r.index(s);if(r.node(s).contentMatchAt(a).matchType(e))return!0;s-=1}return!1}function k6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var S6={};o0(S6,{createAtomBlockMarkdownSpec:()=>C6,createBlockMarkdownSpec:()=>E6,createInlineMarkdownSpec:()=>MC,parseAttributes:()=>p0,parseIndentedBlocks:()=>Ug,renderNestedMarkdownContent:()=>g0,serializeAttributes:()=>m0});function p0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const h=s.map(f=>f.trim().slice(1));e.class=h.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,h,f])=>{var m;const g=parseInt(((m=f.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[h]=y.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function m0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function C6(t){const{nodeName:e,name:n,parseAttributes:r=p0,serializeAttributes:s=m0,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:c}=t,u=n||e,h=f=>{if(!c)return f;const m={};return c.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{const g={...a,...f.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=f.match(y);if(!v)return;const j=v[1]||"",w=r(j);if(!o.find(E=>!(E in w)))return{type:e,raw:v[0],attributes:w}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=s(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function E6(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=p0,serializeAttributes:a=m0,defaultAttributes:o={},content:c="block",allowedAttributes:u}=t,h=n||e,f=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const j=r(m);y=typeof j=="string"?[{type:"text",text:j}]:j}else c==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const v={...o,...m.attributes};return g.createNode(e,v,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),v=(g=m.match(y))==null?void 0:g.index;return v!==void 0?v:-1},tokenize(m,g,y){var v;const j=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(j);if(!w)return;const[k,E=""]=w,C=s(E);let M=1;const D=k.length;let F="";const R=/^:::([\w-]*)(\s.*)?/gm,I=m.slice(D);for(R.lastIndex=0;;){const A=R.exec(I);if(A===null)break;const O=A.index,W=A[1];if(!((v=A[2])!=null&&v.endsWith(":::"))){if(W)M+=1;else if(M-=1,M===0){const X=I.slice(0,O);F=X.trim();const q=m.slice(0,D+O+A[0].length);let Z=[];if(F)if(c==="block")for(Z=y.blockTokens(X),Z.forEach(_=>{_.text&&(!_.tokens||_.tokens.length===0)&&(_.tokens=y.inlineTokens(_.text))});Z.length>0;){const _=Z[Z.length-1];if(_.type==="paragraph"&&(!_.text||_.text.trim()===""))Z.pop();else break}else Z=y.inlineTokens(F);return{type:e,raw:q,attributes:C,content:F,tokens:Z}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),v=a(y),j=v?` {${v}}`:"",w=g.renderChildren(m.content||[],`
`);return`:::${h}${j}
${w}
:::`}}}function T6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,a,o]=r;e[s]=a||o,r=n.exec(t)}return e}function M6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function MC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=T6,serializeAttributes:a=M6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(v=>{const j=typeof v=="string"?v:v.name,w=typeof v=="string"?void 0:v.skipIfDefault;if(j in g){const k=g[j];if(w!==void 0&&k===w)return;y[j]=k}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const v={...o,...g.attributes};if(c)return y.createNode(e,v);const j=r?r(g):g.content||"";return j?y.createNode(e,v,[y.createTextNode(j)]):y.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=g.match(y),j=v==null?void 0:v.index;return j!==void 0?j:-1},tokenize(g,y,v){const j=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(j);if(!w)return;let k="",E="";if(c){const[,M]=w;E=M}else{const[,M,D]=w;E=M,k=D||""}const C=s(E.trim());return{type:e,raw:w[0],content:k.trim(),attributes:C}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(k=>k.type==="text").map(k=>k.text).join(""));const v=f(g.attrs||{}),j=a(v),w=j?` ${j}`:"";return c?`[${h}${w}]`:`[${h}${w}]${y}[/${h}]`}}}function Ug(t,e,n){var r,s,a,o;const c=t.split(`
`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f<c.length;){const g=c[f],y=g.match(e.itemPattern);if(!y){if(u.length>0)break;if(g.trim()===""){f+=1,h=`${h}${g}
`;continue}else return}const v=e.extractItemData(y),{indentLevel:j,mainContent:w}=v;h=`${h}${g}
`;const k=[w];for(f+=1;f<c.length;){const D=c[f];if(D.trim()===""){const R=c.slice(f+1).findIndex(O=>O.trim()!=="");if(R===-1)break;if((((s=(r=c[f+1+R].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>j){k.push(D),h=`${h}${D}
`,f+=1;continue}else break}if((((o=(a=D.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>j)k.push(D),h=`${h}${D}
`,f+=1;else break}let E;const C=k.slice(1);if(C.length>0){const D=C.map(F=>F.slice(j+m)).join(`
`);D.trim()&&(e.customNestedParser?E=e.customNestedParser(D):E=n.blockTokens(D))}const M=e.createToken(v,E);u.push(M)}if(u.length!==0)return{items:u,raw:h}}function g0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[a,...o]=t.content,c=e.renderChildren([a]),u=[`${s}${c}`];return o&&o.length>0&&o.forEach(h=>{const f=e.renderChildren([h]);if(f){const m=f.split(`
`).map(g=>g?e.indent(g):"").join(`
`);u.push(m)}}),u.join(`
`)}function A6(t,e,n={}){const{state:r}=e,{doc:s,tr:a}=r,o=t;s.descendants((c,u)=>{const h=a.mapping.map(u),f=a.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});a.removeMark(h,f,t.type),a.addMark(h,f,y)}}),a.docChanged&&e.view.dispatch(a)}var fn=class AC extends f0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new AC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function qa(t){return new u6({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const a=pt(t.getAttributes,void 0,r,s);if(a===!1||a===null)return null;const{tr:o}=e,c=r[r.length-1],u=r[0];let h=n.to;if(c){const f=u.search(/\S/),m=n.from+u.indexOf(c),g=m+c.length;if(h0(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(w=>w===t.type&&w!==v.mark.type)).filter(v=>v.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+f,m),h=n.from+f+c.length,o.addMark(n.from+f,h,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:R6,getOwnPropertySymbols:I6}=Object,{hasOwnProperty:P6}=Object.prototype;function Wm(t,e){return function(r,s,a){return t(r,s,a)&&e(r,s,a)}}function bu(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:a}=s,o=a.get(n),c=a.get(r);if(o&&c)return o===r&&c===n;a.set(n,r),a.set(r,n);const u=t(n,r,s);return a.delete(n),a.delete(r),u}}function O6(t){return t!=null?t[Symbol.toStringTag]:void 0}function lw(t){return R6(t).concat(I6(t))}const D6=Object.hasOwn||((t,e)=>P6.call(t,e));function to(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const L6="__v",_6="__o",z6="_owner",{getOwnPropertyDescriptor:cw,keys:dw}=Object;function $6(t,e){return t.byteLength===e.byteLength&&oh(new Uint8Array(t),new Uint8Array(e))}function F6(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function B6(t,e){return t.byteLength===e.byteLength&&oh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function V6(t,e){return to(t.getTime(),e.getTime())}function H6(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function W6(t,e){return t===e}function uw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),a=t.entries();let o,c,u=0;for(;(o=a.next())&&!o.done;){const h=e.entries();let f=!1,m=0;for(;(c=h.next())&&!c.done;){if(s[m]){m++;continue}const g=o.value,y=c.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){f=s[m]=!0;break}m++}if(!f)return!1;u++}return!0}const U6=to;function K6(t,e,n){const r=dw(t);let s=r.length;if(dw(e).length!==s)return!1;for(;s-- >0;)if(!RC(t,e,n,r[s]))return!1;return!0}function Xl(t,e,n){const r=lw(t);let s=r.length;if(lw(e).length!==s)return!1;let a,o,c;for(;s-- >0;)if(a=r[s],!RC(t,e,n,a)||(o=cw(t,a),c=cw(e,a),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function q6(t,e){return to(t.valueOf(),e.valueOf())}function G6(t,e){return t.source===e.source&&t.flags===e.flags}function hw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),a=t.values();let o,c;for(;(o=a.next())&&!o.done;){const u=e.values();let h=!1,f=0;for(;(c=u.next())&&!c.done;){if(!s[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=s[f]=!0;break}f++}if(!h)return!1}return!0}function oh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function J6(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function RC(t,e,n,r){return(r===z6||r===_6||r===L6)&&(t.$$typeof||e.$$typeof)?!0:D6(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Y6="[object ArrayBuffer]",Q6="[object Arguments]",X6="[object Boolean]",Z6="[object DataView]",e_="[object Date]",t_="[object Error]",n_="[object Map]",r_="[object Number]",s_="[object Object]",i_="[object RegExp]",a_="[object Set]",o_="[object String]",l_={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},c_="[object URL]",d_=Object.prototype.toString;function u_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:v}){return function(w,k,E){if(w===k)return!0;if(w==null||k==null)return!1;const C=typeof w;if(C!==typeof k)return!1;if(C!=="object")return C==="number"?c(w,k,E):C==="function"?a(w,k,E):!1;const M=w.constructor;if(M!==k.constructor)return!1;if(M===Object)return u(w,k,E);if(Array.isArray(w))return e(w,k,E);if(M===Date)return r(w,k,E);if(M===RegExp)return f(w,k,E);if(M===Map)return o(w,k,E);if(M===Set)return m(w,k,E);const D=d_.call(w);if(D===e_)return r(w,k,E);if(D===i_)return f(w,k,E);if(D===n_)return o(w,k,E);if(D===a_)return m(w,k,E);if(D===s_)return typeof w.then!="function"&&typeof k.then!="function"&&u(w,k,E);if(D===c_)return y(w,k,E);if(D===t_)return s(w,k,E);if(D===Q6)return u(w,k,E);if(l_[D])return g(w,k,E);if(D===Y6)return t(w,k,E);if(D===Z6)return n(w,k,E);if(D===X6||D===r_||D===o_)return h(w,k,E);if(v){let F=v[D];if(!F){const R=O6(w);R&&(F=v[R])}if(F)return F(w,k,E)}return!1}}function h_({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:$6,areArraysEqual:n?Xl:F6,areDataViewsEqual:B6,areDatesEqual:V6,areErrorsEqual:H6,areFunctionsEqual:W6,areMapsEqual:n?Wm(uw,Xl):uw,areNumbersEqual:U6,areObjectsEqual:n?Xl:K6,arePrimitiveWrappersEqual:q6,areRegExpsEqual:G6,areSetsEqual:n?Wm(hw,Xl):hw,areTypedArraysEqual:n?Wm(oh,Xl):oh,areUrlsEqual:J6,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=bu(r.areArraysEqual),a=bu(r.areMapsEqual),o=bu(r.areObjectsEqual),c=bu(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:c})}return r}function f_(t){return function(e,n,r,s,a,o,c){return t(e,n,c)}}function p_({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(c,u){const{cache:h=t?new WeakMap:void 0,meta:f}=n();return e(c,u,{cache:h,equals:r,meta:f,strict:s})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const a={cache:void 0,equals:r,meta:void 0,strict:s};return function(c,u){return e(c,u,a)}}const m_=la();la({strict:!0});la({circular:!0});la({circular:!0,strict:!0});la({createInternalComparator:()=>to});la({strict:!0,createInternalComparator:()=>to});la({circular:!0,createInternalComparator:()=>to});la({circular:!0,createInternalComparator:()=>to,strict:!0});function la(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,a=h_(t),o=u_(a),c=n?n(o):f_(o);return p_({circular:e,comparator:o,createState:r,equals:c,strict:s})}var Um={exports:{}},Km={};/**
* @license React
* use-sync-external-store-shim/with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var fw;function g_(){if(fw)return Km;fw=1;var t=$c(),e=bk();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return Km.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var v=a(null);if(v.current===null){var j={hasValue:!1,value:null};v.current=j}else j=v.current;v=c(function(){function k(F){if(!E){if(E=!0,C=F,F=g(F),y!==void 0&&j.hasValue){var R=j.value;if(y(R,F))return M=R}return M=F}if(R=M,r(C,F))return R;var I=g(F);return y!==void 0&&y(R,I)?(C=F,R):(C=F,M=I)}var E=!1,C,M,D=m===void 0?null:m;return[function(){return k(f())},D===null?void 0:function(){return k(D())}]},[f,m,g,y]);var w=s(h,v[0],v[1]);return o(function(){j.hasValue=!0,j.value=w},[w]),u(w),w},Km}var pw;function x_(){return pw||(pw=1,Um.exports=g_()),Um.exports}var y_=x_(),v_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},b_=({contentComponent:t})=>{const e=wk.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return i.jsx(i.Fragment,{children:Object.values(e)})};function w_(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:vN.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var N_=class extends Zn.Component{constructor(t){var e;super(t),this.editorContentRef=Zn.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=w_(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:v_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&i.jsx(b_,{contentComponent:t.contentComponent})]})}},j_=b.forwardRef((t,e)=>{const n=Zn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Zn.createElement(N_,{key:n,innerRef:e,...t})}),IC=Zn.memo(j_),k_=typeof window<"u"?b.useLayoutEffect:b.useEffect,S_=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function C_(t){var e;const[n]=b.useState(()=>new S_(t.editor)),r=y_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:m_);return k_(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var E_=!1,Kg=typeof window>"u",T_=Kg||!!(typeof window<"u"&&window.next),M_=class PC{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Kg||T_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,a;return(a=(s=this.options.current).onBeforeCreate)==null?void 0:a.call(s,...r)},onBlur:(...r)=>{var s,a;return(a=(s=this.options.current).onBlur)==null?void 0:a.call(s,...r)},onCreate:(...r)=>{var s,a;return(a=(s=this.options.current).onCreate)==null?void 0:a.call(s,...r)},onDestroy:(...r)=>{var s,a;return(a=(s=this.options.current).onDestroy)==null?void 0:a.call(s,...r)},onFocus:(...r)=>{var s,a;return(a=(s=this.options.current).onFocus)==null?void 0:a.call(s,...r)},onSelectionUpdate:(...r)=>{var s,a;return(a=(s=this.options.current).onSelectionUpdate)==null?void 0:a.call(s,...r)},onTransaction:(...r)=>{var s,a;return(a=(s=this.options.current).onTransaction)==null?void 0:a.call(s,...r)},onUpdate:(...r)=>{var s,a;return(a=(s=this.options.current).onUpdate)==null?void 0:a.call(s,...r)},onContentError:(...r)=>{var s,a;return(a=(s=this.options.current).onContentError)==null?void 0:a.call(s,...r)},onDrop:(...r)=>{var s,a;return(a=(s=this.options.current).onDrop)==null?void 0:a.call(s,...r)},onPaste:(...r)=>{var s,a;return(a=(s=this.options.current).onPaste)==null?void 0:a.call(s,...r)},onDelete:(...r)=>{var s,a;return(a=(s=this.options.current).onDelete)==null?void 0:a.call(s,...r)}};return new b6(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,a)=>{var o;return s===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?PC.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function A_(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new M_(n)),s=wk.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(s),b.useEffect(r.onRender(e)),C_({editor:s,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),s}var OC=b.createContext({editor:null});OC.Consumer;var R_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),I_=()=>b.useContext(R_);Zn.forwardRef((t,e)=>{const{onDragStart:n}=I_(),r=t.as||"div";return i.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Zn.createContext({markViewContentRef:()=>{}});var x0=b.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});x0.displayName="TiptapContext";var P_=()=>b.useContext(x0);function DC({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=b.useMemo(()=>({editor:r}),[r]),a=b.useMemo(()=>({editor:r}),[r]);return i.jsx(OC.Provider,{value:a,children:i.jsx(x0.Provider,{value:s,children:n})})}DC.displayName="Tiptap";function LC({...t}){const{editor:e}=P_();return i.jsx(IC,{editor:e,...t})}LC.displayName="Tiptap.Content";Object.assign(DC,{Content:LC});var lh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},O_=/^\s*>\s$/,D_=fn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return lh("blockquote",{...vt(this.options.HTMLAttributes,t),children:lh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const c=e.renderChildren([s]).split(`
`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(`
`))}),r.join(`
${n}
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[rl({find:O_,type:this.type})]}}),L_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,__=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,z_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,F_=eo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return lh("strong",{...vt(this.options.HTMLAttributes,t),children:lh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[nl({find:L_,type:this.type}),nl({find:z_,type:this.type})]},addPasteRules(){return[qa({find:__,type:this.type}),qa({find:$_,type:this.type})]}}),B_=/(^|[^`])`([^`]+)`(?!`)$/,V_=/(^|[^`])`([^`]+)`(?!`)/g,H_=eo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[nl({find:B_,type:this.type})]},addPasteRules(){return[qa({find:V_,type:this.type})]}}),qm=4,W_=/^```([a-z]+)?[\s\n]$/,U_=/^~~~([a-z]+)?[\s\n]$/,K_=fn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:qm,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",vt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
`):r=`\`\`\`${s}
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qm,{state:r}=t,{selection:s}=r,{$from:a,empty:o}=s;if(a.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:h,to:f}=s,y=r.doc.textBetween(h,f,`
`,`
`).split(`
`).map(v=>c+v).join(`
`);return u.replaceWith(h,f,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qm,{state:r}=t,{selection:s}=r,{$from:a,empty:o}=s;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var u;const{pos:h}=a,f=a.start(),m=a.end(),y=r.doc.textBetween(f,m,`
`,`
`).split(`
`);let v=0,j=0;const w=h-f;for(let F=0;F<y.length;F+=1){if(j+y[F].length>=w){v=F;break}j+=y[F].length+1}const E=((u=y[v].match(/^ */))==null?void 0:u[0])||"",C=Math.min(E.length,n);if(C===0)return!0;let M=f;for(let F=0;F<v;F+=1)M+=y[F].length+1;return c.delete(M,M+C),h-M<=C&&c.setSelection(He.create(c.doc,M)),!0}):t.commands.command(({tr:c})=>{const{from:u,to:h}=s,g=r.doc.textBetween(u,h,`
`,`
`).split(`
`).map(y=>{var v;const j=((v=y.match(/^ */))==null?void 0:v[0])||"",w=Math.min(j.length,n);return y.slice(w)}).join(`
`);return c.replaceWith(u,h,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
`);return!a||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:a}=n;if(!a||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const c=s.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(Ge.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Wg({find:W_,type:this.type,getAttributes:t=>({language:t[1]})}),Wg({find:U_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ct({key:new _t("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,a=s==null?void 0:s.mode;if(!n||!a)return!1;const{tr:o,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,`
`));return o.replaceSelectionWith(this.type.create({language:a},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(He.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),q_=fn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):""}),G_=fn.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",vt(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:a}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,u=a||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:h,dispatch:f})=>{if(f&&u&&o){const m=u.filter(g=>c.includes(g.type.name));h.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),J_=fn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,vt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Wg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Y_=fn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",vt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!j6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return uC(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:a,tr:o,dispatch:c})=>{if(c){const{$to:u}=o.selection,h=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(He.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ve.create(o.doc,u.pos)):o.setSelection(He.create(o.doc,u.pos));else{const f=a.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=f==null?void 0:f.create();m&&(o.insert(h,m),o.setSelection(He.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[TC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Q_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,X_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Z_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ez=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,tz=eo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",vt(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[nl({find:Q_,type:this.type}),nl({find:Z_,type:this.type})]},addPasteRules(){return[qa({find:X_,type:this.type}),qa({find:ez,type:this.type})]}});const nz="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",rz="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3украз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراهاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരത5ලකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",qg="numeric",Gg="ascii",Jg="alpha",mc="asciinumeric",ac="alphanumeric",Yg="domain",_C="emoji",sz="scheme",iz="slashscheme",Gm="whitespace";function az(t,e){return t in e||(e[t]=[]),e[t]}function Oa(t,e,n){e[qg]&&(e[mc]=!0,e[ac]=!0),e[Gg]&&(e[mc]=!0,e[Jg]=!0),e[mc]&&(e[ac]=!0),e[Jg]&&(e[ac]=!0),e[ac]&&(e[Yg]=!0),e[_C]&&(e[Yg]=!0);for(const r in e){const s=az(r,n);s.indexOf(t)<0&&s.push(t)}}function oz(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function dr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}dr.groups={};dr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],a=e.jr[r][1];if(a&&s.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||dr.groups;let s;return e&&e.j?s=e:(s=new dr(e),n&&r&&Oa(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const a=t.length;if(!a)return s;for(let o=0;o<a-1;o++)s=s.tt(t[o]);return s.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||dr.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const a=e;let o,c=s.go(t);if(c?(o=new dr,Object.assign(o.j,c.j),o.jr.push.apply(o.jr,c.jr),o.jd=c.jd,o.t=c.t):o=new dr,a){if(r)if(o.t&&typeof o.t=="string"){const u=Object.assign(oz(o.t,r),n);Oa(a,u,r)}else n&&Oa(a,n,r);o.t=a}return s.j[t]=o,o}};const it=(t,e,n,r,s)=>t.ta(e,n,r,s),Wt=(t,e,n,r,s)=>t.tr(e,n,r,s),mw=(t,e,n,r,s)=>t.ts(e,n,r,s),we=(t,e,n,r,s)=>t.tt(e,n,r,s),Vs="WORD",Qg="UWORD",zC="ASCIINUMERICAL",$C="ALPHANUMERICAL",Dc="LOCALHOST",Xg="TLD",Zg="UTLD",Du="SCHEME",_o="SLASH_SCHEME",y0="NUM",ex="WS",v0="NL",gc="OPENBRACE",xc="CLOSEBRACE",ch="OPENBRACKET",dh="CLOSEBRACKET",uh="OPENPAREN",hh="CLOSEPAREN",fh="OPENANGLEBRACKET",ph="CLOSEANGLEBRACKET",mh="FULLWIDTHLEFTPAREN",gh="FULLWIDTHRIGHTPAREN",xh="LEFTCORNERBRACKET",yh="RIGHTCORNERBRACKET",vh="LEFTWHITECORNERBRACKET",bh="RIGHTWHITECORNERBRACKET",wh="FULLWIDTHLESSTHAN",Nh="FULLWIDTHGREATERTHAN",jh="AMPERSAND",kh="APOSTROPHE",Sh="ASTERISK",Oi="AT",Ch="BACKSLASH",Eh="BACKTICK",Th="CARET",_i="COLON",b0="COMMA",Mh="DOLLAR",xs="DOT",Ah="EQUALS",w0="EXCLAMATION",Dr="HYPHEN",yc="PERCENT",Rh="PIPE",Ih="PLUS",Ph="POUND",vc="QUERY",N0="QUOTE",FC="FULLWIDTHMIDDLEDOT",j0="SEMI",ys="SLASH",bc="TILDE",Oh="UNDERSCORE",BC="EMOJI",Dh="SYM";var VC=Object.freeze({__proto__:null,ALPHANUMERICAL:$C,AMPERSAND:jh,APOSTROPHE:kh,ASCIINUMERICAL:zC,ASTERISK:Sh,AT:Oi,BACKSLASH:Ch,BACKTICK:Eh,CARET:Th,CLOSEANGLEBRACKET:ph,CLOSEBRACE:xc,CLOSEBRACKET:dh,CLOSEPAREN:hh,COLON:_i,COMMA:b0,DOLLAR:Mh,DOT:xs,EMOJI:BC,EQUALS:Ah,EXCLAMATION:w0,FULLWIDTHGREATERTHAN:Nh,FULLWIDTHLEFTPAREN:mh,FULLWIDTHLESSTHAN:wh,FULLWIDTHMIDDLEDOT:FC,FULLWIDTHRIGHTPAREN:gh,HYPHEN:Dr,LEFTCORNERBRACKET:xh,LEFTWHITECORNERBRACKET:vh,LOCALHOST:Dc,NL:v0,NUM:y0,OPENANGLEBRACKET:fh,OPENBRACE:gc,OPENBRACKET:ch,OPENPAREN:uh,PERCENT:yc,PIPE:Rh,PLUS:Ih,POUND:Ph,QUERY:vc,QUOTE:N0,RIGHTCORNERBRACKET:yh,RIGHTWHITECORNERBRACKET:bh,SCHEME:Du,SEMI:j0,SLASH:ys,SLASH_SCHEME:_o,SYM:Dh,TILDE:bc,TLD:Xg,UNDERSCORE:Oh,UTLD:Zg,UWORD:Qg,WORD:Vs,WS:ex});const Fs=/[a-z]/,Zl=new RegExp("\\p{L}","u"),Jm=new RegExp("\\p{Emoji}","u"),Bs=/\d/,Ym=/\s/,gw="\r",Qm=`
`,lz="",cz="",Xm="";let wu=null,Nu=null;function dz(t=[]){const e={};dr.groups=e;const n=new dr;wu==null&&(wu=xw(nz)),Nu==null&&(Nu=xw(rz)),we(n,"'",kh),we(n,"{",gc),we(n,"}",xc),we(n,"[",ch),we(n,"]",dh),we(n,"(",uh),we(n,")",hh),we(n,"<",fh),we(n,">",ph),we(n,"",mh),we(n,"",gh),we(n,"「",xh),we(n,"」",yh),we(n,"『",vh),we(n,"』",bh),we(n,"",wh),we(n,"",Nh),we(n,"&",jh),we(n,"*",Sh),we(n,"@",Oi),we(n,"`",Eh),we(n,"^",Th),we(n,":",_i),we(n,",",b0),we(n,"$",Mh),we(n,".",xs),we(n,"=",Ah),we(n,"!",w0),we(n,"-",Dr),we(n,"%",yc),we(n,"|",Rh),we(n,"+",Ih),we(n,"#",Ph),we(n,"?",vc),we(n,'"',N0),we(n,"/",ys),we(n,";",j0),we(n,"~",bc),we(n,"_",Oh),we(n,"\\",Ch),we(n,"・",FC);const r=Wt(n,Bs,y0,{[qg]:!0});Wt(r,Bs,r);const s=Wt(r,Fs,zC,{[mc]:!0}),a=Wt(r,Zl,$C,{[ac]:!0}),o=Wt(n,Fs,Vs,{[Gg]:!0});Wt(o,Bs,s),Wt(o,Fs,o),Wt(s,Bs,s),Wt(s,Fs,s);const c=Wt(n,Zl,Qg,{[Jg]:!0});Wt(c,Fs),Wt(c,Bs,a),Wt(c,Zl,c),Wt(a,Bs,a),Wt(a,Fs),Wt(a,Zl,a);const u=we(n,Qm,v0,{[Gm]:!0}),h=we(n,gw,ex,{[Gm]:!0}),f=Wt(n,Ym,ex,{[Gm]:!0});we(n,Xm,f),we(h,Qm,u),we(h,Xm,f),Wt(h,Ym,f),we(f,gw),we(f,Qm),Wt(f,Ym,f),we(f,Xm,f);const m=Wt(n,Jm,BC,{[_C]:!0});we(m,"#"),Wt(m,Jm,m),we(m,lz,m);const g=we(m,cz);we(g,"#"),Wt(g,Jm,m);const y=[[Fs,o],[Bs,s]],v=[[Fs,null],[Zl,c],[Bs,a]];for(let j=0;j<wu.length;j++)Mi(n,wu[j],Xg,Vs,y);for(let j=0;j<Nu.length;j++)Mi(n,Nu[j],Zg,Qg,v);Oa(Xg,{tld:!0,ascii:!0},e),Oa(Zg,{utld:!0,alpha:!0},e),Mi(n,"file",Du,Vs,y),Mi(n,"mailto",Du,Vs,y),Mi(n,"http",_o,Vs,y),Mi(n,"https",_o,Vs,y),Mi(n,"ftp",_o,Vs,y),Mi(n,"ftps",_o,Vs,y),Oa(Du,{scheme:!0,ascii:!0},e),Oa(_o,{slashscheme:!0,ascii:!0},e),t=t.sort((j,w)=>j[0]>w[0]?1:-1);for(let j=0;j<t.length;j++){const w=t[j][0],E=t[j][1]?{[sz]:!0}:{[iz]:!0};w.indexOf("-")>=0?E[Yg]=!0:Fs.test(w)?Bs.test(w)?E[mc]=!0:E[Gg]=!0:E[qg]=!0,mw(n,w,w,E)}return mw(n,"localhost",Dc,{ascii:!0}),n.jd=new dr(Dh),{start:n,tokens:Object.assign({groups:e},VC)}}function HC(t,e){const n=uz(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,s=[];let a=0,o=0;for(;o<r;){let c=t,u=null,h=0,f=null,m=-1,g=-1;for(;o<r&&(u=c.go(n[o]));)c=u,c.accepts()?(m=0,g=0,f=c):m>=0&&(m+=n[o].length,g++),h+=n[o].length,a+=n[o].length,o++;a-=m,o-=g,h-=m,s.push({t:f.t,v:e.slice(a-h,a),s:a-h,e:a})}return s}function uz(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),a,o=s<55296||s>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Mi(t,e,n,r,s){let a;const o=e.length;for(let c=0;c<o-1;c++){const u=e[c];t.j[u]?a=t.j[u]:(a=new dr(r),a.jr=s.slice(),t.j[u]=a),t=a}return a=new dr(n),a.jr=s.slice(),t.j[e[o-1]]=a,a}function xw(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let a=0;for(;s.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const Lc={defaultProtocol:"http",events:null,format:yw,formatHref:yw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function k0(t,e=null){let n=Object.assign({},Lc);t&&(n=Object.assign(n,t instanceof k0?t.o:t));const r=n.ignoreTags,s=[];for(let a=0;a<r.length;a++)s.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}k0.prototype={o:Lc,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Lc[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function yw(t){return t}function WC(t,e){this.t="token",this.v=t,this.tk=e}WC.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Lc.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),a=this.toFormattedString(t),o={},c=t.get("className",n,e),u=t.get("target",n,e),h=t.get("rel",n,e),f=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=r,c&&(o.class=c),u&&(o.target=u),h&&(o.rel=h),f&&Object.assign(o,f),{tagName:s,attributes:o,content:a,eventListeners:m}}};function ff(t,e){class n extends WC{constructor(s,a){super(s,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const vw=ff("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),bw=ff("text"),hz=ff("nl"),ju=ff("url",{isLink:!0,toHref(t=Lc.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Dc&&t[1].t===_i}}),Or=t=>new dr(t);function fz({groups:t}){const e=t.domain.concat([jh,Sh,Oi,Ch,Eh,Th,Mh,Ah,Dr,y0,yc,Rh,Ih,Ph,ys,Dh,bc,Oh]),n=[kh,_i,b0,xs,w0,yc,vc,N0,j0,fh,ph,gc,xc,dh,ch,uh,hh,mh,gh,xh,yh,vh,bh,wh,Nh],r=[jh,kh,Sh,Ch,Eh,Th,Mh,Ah,Dr,gc,xc,yc,Rh,Ih,Ph,vc,ys,Dh,bc,Oh],s=Or(),a=we(s,bc);it(a,r,a),it(a,t.domain,a);const o=Or(),c=Or(),u=Or();it(s,t.domain,o),it(s,t.scheme,c),it(s,t.slashscheme,u),it(o,r,a),it(o,t.domain,o);const h=we(o,Oi);we(a,Oi,h),we(c,Oi,h),we(u,Oi,h);const f=we(a,xs);it(f,r,a),it(f,t.domain,a);const m=Or();it(h,t.domain,m),it(m,t.domain,m);const g=we(m,xs);it(g,t.domain,m);const y=Or(vw);it(g,t.tld,y),it(g,t.utld,y),we(h,Dc,y);const v=we(m,Dr);we(v,Dr,v),it(v,t.domain,m),it(y,t.domain,m),we(y,xs,g),we(y,Dr,v);const j=we(y,_i);it(j,t.numeric,vw);const w=we(o,Dr),k=we(o,xs);we(w,Dr,w),it(w,t.domain,o),it(k,r,a),it(k,t.domain,o);const E=Or(ju);it(k,t.tld,E),it(k,t.utld,E),it(E,t.domain,o),it(E,r,a),we(E,xs,k),we(E,Dr,w),we(E,Oi,h);const C=we(E,_i),M=Or(ju);it(C,t.numeric,M);const D=Or(ju),F=Or();it(D,e,D),it(D,n,F),it(F,e,D),it(F,n,F),we(E,ys,D),we(M,ys,D);const R=we(c,_i),I=we(u,_i),A=we(I,ys),O=we(A,ys);it(c,t.domain,o),we(c,xs,k),we(c,Dr,w),it(u,t.domain,o),we(u,xs,k),we(u,Dr,w),it(R,t.domain,D),we(R,ys,D),we(R,vc,D),it(O,t.domain,D),it(O,e,D),we(O,ys,D);const W=[[gc,xc],[ch,dh],[uh,hh],[fh,ph],[mh,gh],[xh,yh],[vh,bh],[wh,Nh]];for(let X=0;X<W.length;X++){const[q,Z]=W[X],_=we(D,q);we(F,q,_),we(_,Z,D);const $=Or(ju);it(_,e,$);const oe=Or();it(_,n),it($,e,$),it($,n,oe),it(oe,e,$),it(oe,n,oe),we($,Z,D),we(oe,Z,D)}return we(s,Dc,E),we(s,v0,hz),{start:s,tokens:VC}}function pz(t,e,n){let r=n.length,s=0,a=[],o=[];for(;s<r;){let c=t,u=null,h=null,f=0,m=null,g=-1;for(;s<r&&!(u=c.go(n[s].t));)o.push(n[s++]);for(;s<r&&(h=u||c.go(n[s].t));)u=null,c=h,c.accepts()?(g=0,m=c):g>=0&&g++,s++,f++;if(g<0)s-=f,s<r&&(o.push(n[s]),s++);else{o.length>0&&(a.push(Zm(bw,e,o)),o=[]),s-=g,f-=g;const y=m.t,v=n.slice(s-f,s);a.push(Zm(y,e,v))}}return o.length>0&&a.push(Zm(bw,e,o)),a}function Zm(t,e,n){const r=n[0].s,s=n[n.length-1].e,a=e.slice(r,s);return new t(a,n)}const mz=typeof console<"u"&&console&&console.warn||(()=>{}),gz="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",At={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function xz(){return dr.groups={},At.scanner=null,At.parser=null,At.tokenQueue=[],At.pluginQueue=[],At.customSchemes=[],At.initialized=!1,At}function ww(t,e=!1){if(At.initialized&&mz(`linkifyjs: already initialized - will not register custom scheme "${t}" ${gz}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);At.customSchemes.push([t,e])}function yz(){At.scanner=dz(At.customSchemes);for(let t=0;t<At.tokenQueue.length;t++)At.tokenQueue[t][1]({scanner:At.scanner});At.parser=fz(At.scanner.tokens);for(let t=0;t<At.pluginQueue.length;t++)At.pluginQueue[t][1]({scanner:At.scanner,parser:At.parser});return At.initialized=!0,At}function S0(t){return At.initialized||yz(),pz(At.parser.start,t,HC(At.scanner.start,t))}S0.scan=HC;function UC(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new k0(n),s=S0(t),a=[];for(let o=0;o<s.length;o++){const c=s[o];c.isLink&&(!e||c.t===e)&&r.check(c)&&a.push(c.toFormattedObject(r))}return a}var C0="[\0-   -\u2029 ]",vz=new RegExp(C0),bz=new RegExp(`${C0}$`),wz=new RegExp(C0,"g");function Nz(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function jz(t){return new Ct({key:new _t("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),a=e.some(h=>h.getMeta("preventAutolink"));if(!s||a)return;const{tr:o}=r,c=nC(n.doc,[...e]);if(dC(c).forEach(({newRange:h})=>{const f=N8(r.doc,h,y=>y.isTextblock);let m,g;if(f.length>1)m=f[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(f.length){const y=r.doc.textBetween(h.from,h.to," "," ");if(!bz.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(vz).filter(Boolean);if(y.length<=0)return!1;const v=y[y.length-1],j=m.pos+g.lastIndexOf(v);if(!v)return!1;const w=S0(v).map(k=>k.toObject(t.defaultProtocol));if(!Nz(w))return!1;w.filter(k=>k.isLink).map(k=>({...k,from:j+k.start+1,to:j+k.end+1})).filter(k=>r.schema.marks.code?!r.doc.rangeHasMark(k.from,k.to,r.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{h0(k.from,k.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!o.steps.length)return o}})}function kz(t){return new Ct({key:new _t("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const u=r.target;if(!u)return!1;const h=t.editor.view.dom;o=u.closest("a"),o&&!h.contains(o)&&(o=null)}if(!o)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=cC(e.state,t.type.name),h=(s=o.href)!=null?s:u.href,f=(a=o.target)!=null?a:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function Sz(t){return new Ct({key:new _t("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:a}=e,{selection:o}=a,{empty:c}=o;if(c)return!1;let u="";r.content.forEach(f=>{u+=f.textContent});const h=UC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||s!==void 0&&!s(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function Ta(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(wz,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var KC=eo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){ww(t);return}ww(t.scheme,t.optionalSlashes)})},onDestroy(){xz()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ta(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ta(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ta(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",vt(this.options.HTMLAttributes,t),0]:["a",vt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,a;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(a=(s=t.attrs)==null?void 0:s.title)!=null?a:"",u=e.renderChildren(t);return c?`[${u}](${o} "${c}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ta(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ta(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[qa({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=UC(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Ta(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(jz({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ta(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(kz({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Sz({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Cz=KC,Ez=Object.defineProperty,Tz=(t,e)=>{for(var n in e)Ez(t,n,{get:e[n],enumerable:!0})},Mz="listItem",Nw="textStyle",jw=/^\s*([-+*])\s$/,qC=fn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Mz,this.editor.getAttributes(Nw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=rl({find:jw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=rl({find:jw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Nw),editor:this.editor})),[t]}}),GC=fn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),c=e.parseChildren(o);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>g0(t,e,r=>{var s,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:a.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Az={};Tz(Az,{findListItemPos:()=>qc,getNextListDepth:()=>E0,handleBackspace:()=>tx,handleDelete:()=>nx,hasListBefore:()=>JC,hasListItemAfter:()=>Rz,hasListItemBefore:()=>YC,listItemHasSubList:()=>QC,nextListIsDeeper:()=>XC,nextListIsHigher:()=>ZC});var qc=(t,e)=>{const{$from:n}=e.selection,r=ln(t,e.schema);let s=null,a=n.depth,o=n.pos,c=null;for(;a>0&&c===null;)s=n.node(a),s.type===r?c=a:(a-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},E0=(t,e)=>{const n=qc(t,e);if(!n)return!1;const[,r]=I8(e,t,n.$pos.pos+4);return r},JC=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),a=t.doc.resolve(s).node();return!(!a||!n.includes(a.type.name))},YC=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},QC=(t,e,n)=>{if(!n)return!1;const r=ln(t,e.schema);let s=!1;return n.descendants(a=>{a.type===r&&(s=!0)}),s},tx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Zi(t.state,e)&&JC(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),h=[];u.node().descendants((g,y)=>{g.type.name===e&&h.push({node:g,pos:y})});const f=h.at(-1);if(!f)return!1;const m=t.state.doc.resolve(u.start()+f.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Zi(t.state,e)||!L8(t.state))return!1;const r=qc(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=QC(e,t.state,a);return YC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},XC=(t,e)=>{const n=E0(t,e),r=qc(t,e);return!r||!n?!1:n>r.depth},ZC=(t,e)=>{const n=E0(t,e),r=qc(t,e);return!r||!n?!1:n<r.depth},nx=(t,e)=>{if(!Zi(t.state,e)||!D8(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:XC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():ZC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Rz=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},e2=Gt.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&nx(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&nx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&tx(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&tx(t,n,r)&&(e=!0)}),e}}}}),kw=/^(\s*)(\d+)\.\s+(.*)$/,Iz=/^\s/;function Pz(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],a=s.match(kw);if(!a)break;const[,o,c,u]=a,h=o.length;let f=u,m=n+1;const g=[s];for(;m<t.length;){const y=t[m];if(y.match(kw))break;if(y.trim()==="")g.push(y),f+=`
`,m+=1;else if(y.match(Iz))g.push(y),f+=`
${y.slice(h+2)}`,m+=1;else break}e.push({indent:h,number:parseInt(c,10),content:f.trim(),raw:g.join(`
`)}),r=m,n=m}return[e,r]}function t2(t,e,n){var r;const s=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const c=o.content.split(`
`),u=((r=c[0])==null?void 0:r.trim())||"",h=[];u&&h.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const f=c.slice(1).join(`
`).trim();if(f){const y=n.blockTokens(f);h.push(...y)}let m=a+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(j=>j.indent)),v=t2(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:v,raw:g.map(j=>j.raw).join(`
`)})}s.push({type:"list_item",raw:o.raw,tokens:h}),a=m}else a+=1}return s}function Oz(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const a=e.parseChildren([s]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([s]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var Dz="listItem",Sw="textStyle",Cw=/^(\d+)\.\s$/,n2=fn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",vt(this.options.HTMLAttributes,n),0]:["ol",vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?Oz(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
`),[a,o]=Pz(s);if(a.length===0)return;const c=t2(a,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:c,raw:s.slice(0,o).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dz,this.editor.getAttributes(Sw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=rl({find:Cw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=rl({find:Cw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Sw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Lz=/^\s*(\[([( |x])?\])\s$/,_z=fn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",vt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return g0(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),h=m=>{var g,y;c.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};h(t),a.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const v=n();if(typeof v!="number")return!1;const j=y.doc.nodeAt(v);return y.setNodeMarkup(v,void 0,{...j==null?void 0:j.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{s.setAttribute(m,g)}),s.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,a.append(c,o),s.append(a,u),Object.entries(e).forEach(([m,g])=>{s.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:s,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;s.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=r.extensionManager.attributes,y=Oc(m,g),v=new Set(Object.keys(y)),j=this.options.HTMLAttributes;return f.forEach(w=>{v.has(w)||(w in j?s.setAttribute(w,j[w]):s.removeAttribute(w))}),Object.entries(y).forEach(([w,k])=>{k==null?w in j?s.setAttribute(w,j[w]):s.removeAttribute(w):s.setAttribute(w,k)}),f=v,!0}}}},addInputRules(){return[rl({find:Lz,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),zz=fn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",vt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=Ug(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},s=Ug(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Gt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(qC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(GC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(e2.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(n2.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(_z.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(zz.configure(this.options.taskList)),t}});var Ew="&nbsp;",$z=" ",Fz=fn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",vt(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===Ew||r[0].text===$z)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?Ew:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Bz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Vz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hz=eo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",vt(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[nl({find:Bz,type:this.type})]},addPasteRules(){return[qa({find:Vz,type:this.type})]}}),Wz=fn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Uz=eo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",vt(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const a=s[2].trim();return{type:"underline",raw:s[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Kz(t={}){return new Ct({view(e){return new qz(e,t)}})}class qz{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let a=o=>{this[s](o)};return e.dom.addEventListener(s,a),{name:s,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,a=s.getBoundingClientRect(),o=a.width/s.offsetWidth,c=a.height/s.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let v=y.getBoundingClientRect(),j=m?v.bottom:v.top;m&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*c;r={left:v.left,right:v.right,top:j-w,bottom:j+w}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let h,f;if(!u||u==document.body&&getComputedStyle(u).position=="static")h=-pageXOffset,f=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;h=m.left-u.scrollLeft*g,f=m.top-u.scrollTop*y}this.element.style.left=(r.left-h)/o+"px",this.element.style.top=(r.top-f)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,a=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=Gk(this.editorView.state.doc,o,this.editorView.dragging.slice);c!=null&&(o=c)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Kt extends Ge{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Kt.valid(r)?new Kt(r):Ge.near(r)}content(){return Me.empty}eq(e){return e instanceof Kt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Kt(e.resolve(n.pos))}getBookmark(){return new T0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Gz(e)||!Jz(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Kt.valid(e))return e;let s=e.pos,a=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)<c.childCount:e.index(o)>0){a=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let u=e.doc.resolve(s);if(Kt.valid(u))return u}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Ve.isSelectable(a)){e=e.doc.resolve(s+a.nodeSize*n),r=!1;continue e}break}a=o,s+=n;let c=e.doc.resolve(s);if(Kt.valid(c))return c}return null}}}Kt.prototype.visible=!1;Kt.findFrom=Kt.findGapCursorFrom;Ge.jsonID("gapcursor",Kt);class T0{constructor(e){this.pos=e}map(e){return new T0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Kt.valid(n)?new Kt(n):Ge.near(n)}}function r2(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Gz(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||r2(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Jz(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||r2(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Yz(){return new Ct({props:{decorations:e7,createSelectionBetween(t,e,n){return e.pos==n.pos&&Kt.valid(n)?new Kt(n):null},handleClick:Xz,handleKeyDown:Qz,handleDOMEvents:{beforeinput:Zz}}})}const Qz=a0({ArrowLeft:ku("horiz",-1),ArrowRight:ku("horiz",1),ArrowUp:ku("vert",-1),ArrowDown:ku("vert",1)});function ku(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,a){let o=r.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof He){if(!a.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=Kt.findGapCursorFrom(c,e,u);return h?(s&&s(r.tr.setSelection(new Kt(h))),!0):!1}}function Xz(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Kt.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Ve.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Kt(r))),!0)}function Zz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Kt))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=pe.empty;for(let o=r.length-1;o>=0;o--)s=pe.from(r[o].createAndFill(null,s));let a=t.state.tr.replace(n.pos,n.pos,new Me(s,0,0));return a.setSelection(He.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function e7(t){if(!(t.selection instanceof Kt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",wt.create(t.doc,[hn.widget(t.selection.head,e,{key:"gapcursor"})])}var Lh=200,kn=function(){};kn.prototype.append=function(e){return e.length?(e=kn.from(e),!this.length&&e||e.length<Lh&&this.leafAppend(e)||this.length<Lh&&e.leafPrepend(this)||this.appendInner(e)):this};kn.prototype.prepend=function(e){return e.length?kn.from(e).append(this):this};kn.prototype.appendInner=function(e){return new t7(this,e)};kn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?kn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};kn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};kn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};kn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(a,o){return s.push(e(a,o))},n,r),s};kn.from=function(e){return e instanceof kn?e:e&&e.length?new s2(e):kn.empty};var s2=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,a){return s==0&&a==this.length?this:new e(this.values.slice(s,a))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,a,o,c){for(var u=a;u<o;u++)if(s(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(s,a,o,c){for(var u=a-1;u>=o;u--)if(s(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Lh)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Lh)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(kn);kn.empty=new s2([]);var t7=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,a,o){var c=this.left.length;if(s<c&&this.left.forEachInner(r,s,Math.min(a,c),o)===!1||a>c&&this.right.forEachInner(r,Math.max(s-c,0),Math.min(this.length,a)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,a,o){var c=this.left.length;if(s>c&&this.right.forEachInvertedInner(r,s-c,Math.max(a,c)-c,o+c)===!1||a<c&&this.left.forEachInvertedInner(r,Math.min(s,c),a,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var a=this.left.length;return s<=a?this.left.slice(r,s):r>=a?this.right.slice(r-a,s-a):this.left.slice(r,a).append(this.right.slice(0,s-a))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(kn);const n7=500;class Qr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,a;n&&(s=this.remapping(r,this.items.length),a=s.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){s||(s=this.remapping(r,g+1),a=s.maps.length),a--,f.push(m);return}if(s){f.push(new Ai(m.map));let y=m.step.map(s.slice(a)),v;y&&o.maybeStep(y).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ai(v,void 0,void 0,h.length+f.length))),a--,v&&s.appendMap(v,a)}else o.maybeStep(m.step);if(m.selection)return c=s?m.selection.map(s.slice(a)):m.selection,u=new Qr(this.items.slice(0,r).append(f.reverse().concat(h)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:c}}addTransform(e,n,r,s){let a=[],o=this.eventCount,c=this.items,u=!s&&c.length?c.get(c.length-1):null;for(let f=0;f<e.steps.length;f++){let m=e.steps[f].invert(e.docs[f]),g=new Ai(e.mapping.maps[f],m,n),y;(y=u&&u.merge(g))&&(g=y,f?a.pop():c=c.slice(0,c.length-1)),a.push(g),n&&(o++,n=void 0),s||(u=g)}let h=o-r.depth;return h>s7&&(c=r7(c,h),o-=h),new Qr(c.append(a),o)}remapping(e,n){let r=new Tc;return this.items.forEach((s,a)=>{let o=s.mirrorOffset!=null&&a-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Qr(this.items.append(e.map(n=>new Ai(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},s);let u=n;this.items.forEach(g=>{let y=a.getMirror(--u);if(y==null)return;o=Math.min(o,y);let v=a.maps[y];if(g.step){let j=e.steps[y].invert(e.docs[y]),w=g.selection&&g.selection.map(a.slice(u+1,y));w&&c++,r.push(new Ai(v,j,w))}else r.push(new Ai(v))},s);let h=[];for(let g=n;g<o;g++)h.push(new Ai(a.maps[g]));let f=this.items.slice(0,s).append(h).append(r),m=new Qr(f,c);return m.emptyItemCount()>n7&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],a=0;return this.items.forEach((o,c)=>{if(c>=e)s.push(o),o.selection&&a++;else if(o.step){let u=o.step.map(n.slice(r)),h=u&&u.getMap();if(r--,h&&n.appendMap(h,r),u){let f=o.selection&&o.selection.map(n.slice(r));f&&a++;let m=new Ai(h.invert(),u,f),g,y=s.length-1;(g=s.length&&s[y].merge(m))?s[y]=g:s.push(m)}}else o.map&&r--},this.items.length,0),new Qr(kn.from(s.reverse()),a)}}Qr.empty=new Qr(kn.empty,0);function r7(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Ai=class i2{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new i2(n.getMap().invert(),n,this.selection)}}};class Di{constructor(e,n,r,s,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=a}}const s7=20;function i7(t,e,n,r){let s=n.getMeta(Fa),a;if(s)return s.historyState;n.getMeta(l7)&&(t=new Di(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Fa))return o.getMeta(Fa).redo?new Di(t.done.addTransform(n,void 0,r,Lu(e)),t.undone,Tw(n.mapping.maps),t.prevTime,t.prevComposition):new Di(t.done,t.undone.addTransform(n,void 0,r,Lu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!a7(n,t.prevRanges)),h=o?eg(t.prevRanges,n.mapping):Tw(n.mapping.maps);return new Di(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Lu(e)),Qr.empty,h,n.time,c??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Di(t.done.rebased(n,a),t.undone.rebased(n,a),eg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Di(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),eg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function a7(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&s>=e[a]&&(n=!0)}),n}function Tw(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,a,o)=>e.push(a,o));return e}function eg(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),a=e.map(t[r+1],-1);s<=a&&n.push(s,a)}return n}function o7(t,e,n){let r=Lu(e),s=Fa.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),c=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),s,r),u=new Di(n?c:a.remaining,n?a.remaining:c,null,0,-1);return a.transform.setSelection(o).setMeta(Fa,{redo:n,historyState:u})}let tg=!1,Mw=null;function Lu(t){let e=t.plugins;if(Mw!=e){tg=!1,Mw=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){tg=!0;break}}return tg}const Fa=new _t("history"),l7=new _t("closeHistory");function c7(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ct({key:Fa,state:{init(){return new Di(Qr.empty,Qr.empty,null,0,-1)},apply(e,n,r){return i7(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?o2:r=="historyRedo"?l2:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function a2(t,e){return(n,r)=>{let s=Fa.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let a=o7(s,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const o2=a2(!1,!0),l2=a2(!0,!0);Gt.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ct({key:new _t("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>s){const o=a-s,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const h=r.tr.deleteRange(c,u);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||s>r&&a>r&&a<=s)return!0;if(s>r&&a>r&&a>s||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=a-r,h=c-u,f=c;return e.deleteRange(h,f),!(this.storage.characters({node:e.doc})>r)}})]}});var d7=Gt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Kz(this.options)]}});Gt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ct({key:new _t("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,a=[];if(!n||!r)return wt.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(s>=h&&s<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(s>=h&&s<=h+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&o-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";a.push(hn.node(h,h+u.nodeSize,{class:this.options.className}))}),wt.create(t,a)}}})]}});var u7=Gt.create({name:"gapCursor",addProseMirrorPlugins(){return[Yz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=pt($e(t,"allowGapCursor",n)))!=null?e:null}}}),Aw="placeholder";function h7(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var f7=Gt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Aw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${h7(this.options.dataAttribute)}`:`data-${Aw}`;return[new Ct({key:new _t("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,a=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=s>=u&&s<=u+c.nodeSize,f=!c.isLeaf&&df(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=hn.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:h}):this.options.placeholder});a.push(g)}return this.options.includeChildren}),wt.create(e,a)}}})]}});Gt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ct({key:new _t("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||uC(n.selection)||t.view.dragging?null:wt.create(n.doc,[hn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Rw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var p7=Gt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new _t(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new Ct({key:e,appendTransaction:(s,a,o)=>{const{doc:c,tr:u,schema:h}=o,f=e.getState(o),m=c.content.size,g=h.nodes[n];if(f)return u.insert(m,g.create())},state:{init:(s,a)=>{const o=a.tr.doc.lastChild;return!Rw({node:o,types:r})},apply:(s,a)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return a;const o=s.doc.lastChild;return!Rw({node:o,types:r})}}})]}}),m7=Gt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>o2(t,e),redo:()=>({state:t,dispatch:e})=>l2(t,e)}},addProseMirrorPlugins(){return[c7(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),g7=Gt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(F_.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(D_.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(qC.configure(this.options.bulletList)),this.options.code!==!1&&s.push(H_.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(K_.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(q_.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(d7.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(u7.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(G_.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(J_.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(m7.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Y_.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(tz.configure(this.options.italic)),this.options.listItem!==!1&&s.push(GC.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(e2.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(KC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(n2.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Fz.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Hz.configure(this.options.strike)),this.options.text!==!1&&s.push(Wz.configure(this.options.text)),this.options.underline!==!1&&s.push(Uz.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(p7.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),x7=g7,y7=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,v7=fn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",vt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,a,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",h=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return h?`![${u}](${c} "${h}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:a,HTMLAttributes:o,editor:c})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const h=new N6({element:u,editor:c,node:s,getPos:a,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=a();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),f=h.dom;return f.style.visibility="hidden",f.style.pointerEvents="none",u.onload=()=>{f.style.visibility="",f.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[TC({find:y7,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),b7=v7;function w7(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:a,startOfLine:o,$position:c}=t,u=r&&!s,h=k6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=s?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),v=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!v)return null;const j=c.pos-v.length,w=Array.from(v.matchAll(y)).pop();if(!w||w.input===void 0||w.index===void 0)return null;const k=w.input.slice(Math.max(0,w.index-1),w.index),E=new RegExp(`^[${a==null?void 0:a.join("")}\0]?$`).test(k);if(a!==null&&!E)return null;const C=j+w.index;let M=C+w[0].length;return u&&f.test(v.slice(M-1,M+1))&&(w[0]+=" ",M+=1),C<c.pos&&M>=c.pos?{range:{from:C,to:M},query:w[0].slice(n.length),text:w[0]}:null}var N7=new _t("suggestion");function j7({pluginKey:t=N7,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:a=[" "],startOfLine:o=!1,decorationTag:c="span",decorationClass:u="suggestion",decorationContent:h="",decorationEmptyClass:f="is-empty",command:m=()=>null,items:g=()=>[],render:y=()=>({}),allow:v=()=>!0,findSuggestionMatch:j=w7,shouldShow:w}){let k;const E=y==null?void 0:y(),C=()=>{const R=e.state.selection.$anchor.pos,I=e.view.coordsAtPos(R),{top:A,right:O,bottom:W,left:X}=I;try{return new DOMRect(X,A,O-X,W-A)}catch{return null}},M=(R,I)=>I?()=>{const A=t.getState(e.state),O=A==null?void 0:A.decorationId,W=R.dom.querySelector(`[data-decoration-id="${O}"]`);return(W==null?void 0:W.getBoundingClientRect())||null}:C;function D(R,I){var A;try{const W=t.getState(R.state),X=W!=null&&W.decorationId?R.dom.querySelector(`[data-decoration-id="${W.decorationId}"]`):null,q={editor:e,range:(W==null?void 0:W.range)||{from:0,to:0},query:(W==null?void 0:W.query)||null,text:(W==null?void 0:W.text)||null,items:[],command:Z=>m({editor:e,range:(W==null?void 0:W.range)||{from:0,to:0},props:Z}),decorationNode:X,clientRect:M(R,X)};(A=E==null?void 0:E.onExit)==null||A.call(E,q)}catch{}const O=R.state.tr.setMeta(I,{exit:!0});R.dispatch(O)}const F=new Ct({key:t,view(){return{update:async(R,I)=>{var A,O,W,X,q,Z,_;const $=(A=this.key)==null?void 0:A.getState(I),oe=(O=this.key)==null?void 0:O.getState(R.state),V=$.active&&oe.active&&$.range.from!==oe.range.from,ae=!$.active&&oe.active,Y=$.active&&!oe.active,L=!ae&&!Y&&$.query!==oe.query,H=ae||V&&L,ue=L||V,U=Y||V&&L;if(!H&&!ue&&!U)return;const he=U&&!H?$:oe,Q=R.dom.querySelector(`[data-decoration-id="${he.decorationId}"]`);k={editor:e,range:he.range,query:he.query,text:he.text,items:[],command:ee=>m({editor:e,range:he.range,props:ee}),decorationNode:Q,clientRect:M(R,Q)},H&&((W=E==null?void 0:E.onBeforeStart)==null||W.call(E,k)),ue&&((X=E==null?void 0:E.onBeforeUpdate)==null||X.call(E,k)),(ue||H)&&(k.items=await g({editor:e,query:he.query})),U&&((q=E==null?void 0:E.onExit)==null||q.call(E,k)),ue&&((Z=E==null?void 0:E.onUpdate)==null||Z.call(E,k)),H&&((_=E==null?void 0:E.onStart)==null||_.call(E,k))},destroy:()=>{var R;k&&((R=E==null?void 0:E.onExit)==null||R.call(E,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(R,I,A,O){const{isEditable:W}=e,{composing:X}=e.view,{selection:q}=R,{empty:Z,from:_}=q,$={...I},oe=R.getMeta(t);if(oe&&oe.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=X,W&&(Z||e.view.composing)){(_<I.range.from||_>I.range.to)&&!X&&!I.composing&&($.active=!1);const V=j({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:a,startOfLine:o,$position:q.$from}),ae=`id_${Math.floor(Math.random()*4294967295)}`;V&&v({editor:e,state:O,range:V.range,isActive:I.active})&&(!w||w({editor:e,range:V.range,query:V.query,text:V.text,transaction:R}))?($.active=!0,$.decorationId=I.decorationId?I.decorationId:ae,$.range=V.range,$.query=V.query,$.text=V.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(R,I){var A,O,W,X;const{active:q,range:Z}=F.getState(R.state);if(!q)return!1;if(I.key==="Escape"||I.key==="Esc"){const $=F.getState(R.state),oe=(A=k==null?void 0:k.decorationNode)!=null?A:null,V=oe??($!=null&&$.decorationId?R.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((O=E==null?void 0:E.onKeyDown)==null?void 0:O.call(E,{view:R,event:I,range:$.range}))||!1)return!0;const Y={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:L=>m({editor:e,range:$.range,props:L}),decorationNode:V,clientRect:V?()=>V.getBoundingClientRect()||null:null};return(W=E==null?void 0:E.onExit)==null||W.call(E,Y),D(R,t),!0}return((X=E==null?void 0:E.onKeyDown)==null?void 0:X.call(E,{view:R,event:I,range:Z}))||!1},decorations(R){const{active:I,range:A,decorationId:O,query:W}=F.getState(R);if(!I)return null;const X=!(W!=null&&W.length),q=[u];return X&&q.push(f),wt.create(R.doc,[hn.inline(A.from,A.to,{nodeName:c,class:q.join(" "),"data-decoration-id":O,"data-decoration-content":h})])}}});return F}function k7({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const s=new _t;return{editor:t,char:r,pluginKey:s,command:({editor:a,range:o,props:c})=>{var u,h,f;const m=a.view.state.selection.$to.nodeAfter;((u=m==null?void 0:m.text)==null?void 0:u.startsWith(" "))&&(o.to+=1),a.chain().focus().insertContentAt(o,[{type:n,attrs:{...c,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(h=a.view.dom.ownerDocument.defaultView)==null?void 0:h.getSelection())==null||f.collapseToEnd()},allow:({state:a,range:o})=>{const c=a.doc.resolve(o.from),u=a.schema.nodes[n];return!!c.parent.type.contentMatch.matchType(u)},...e}}function c2(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>k7({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function Iw(t,e){const n=c2(t),r=n.find(s=>s.char===e);return r||(n.length?n[0]:null)}var S7=fn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!=null?n:"@"}${(r=t.attrs.label)!=null?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,s;return["span",vt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=Iw(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",vt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=vt({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof s=="string"?["span",vt({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...MC({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,a,o]=r,c=a??o;e[s==="char"?"mentionSuggestionChar":s]=c,r=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:Iw(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:s,anchor:a}=r;if(!s)return!1;let o=new Js,c=0;return e.doc.nodesBetween(a-1,a,(u,h)=>{if(u.type.name===this.name)return n=!0,o=u,c=h,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":o.attrs.mentionSuggestionChar,c,c+o.nodeSize),n})}},addProseMirrorPlugins(){return c2(this).map(j7)}}),C7=S7,E7=f7;let rx,sx;if(typeof WeakMap<"u"){let t=new WeakMap;rx=e=>t.get(e),sx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;rx=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},sx=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var qt=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let a=r+1,o=s+1;for(let c=1;a<this.width&&this.map[e+c]==n;c++)a++;for(let c=1;o<this.height&&this.map[e+this.width*c]==n;c++)o++;return{left:r,top:s,right:a,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:a,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[a*this.width+(n<0?r-1:s)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:a}=this.findCell(t),{left:o,right:c,top:u,bottom:h}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,u),right:Math.max(r,c),bottom:Math.max(a,h)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const a=r*this.width+s,o=this.map[a];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[a-1]==o||r==t.top&&r&&this.map[a-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const a=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const c=(t+1)*this.width;for(;o<c&&this.map[o]<s;)o++;return o==c?a-1:this.map[o]}s=a}}static get(t){return rx(t)||sx(t,T7(t))}};function T7(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=M7(t),n=t.childCount,r=[];let s=0,a=null;const o=[];for(let h=0,f=e*n;h<f;h++)r[h]=0;for(let h=0,f=0;h<n;h++){const m=t.child(h);f++;for(let v=0;;v++){for(;s<r.length&&r[s]!=0;)s++;if(v==m.childCount)break;const j=m.child(v),{colspan:w,rowspan:k,colwidth:E}=j.attrs;for(let C=0;C<k;C++){if(C+h>=n){(a||(a=[])).push({type:"overlong_rowspan",pos:f,n:k-C});break}const M=s+C*e;for(let D=0;D<w;D++){r[M+D]==0?r[M+D]=f:(a||(a=[])).push({type:"collision",row:h,pos:f,n:w-D});const F=E&&E[D];if(F){const R=(M+D)%e*2,I=o[R];I==null||I!=F&&o[R+1]==1?(o[R]=F,o[R+1]=1):I==F&&o[R+1]++}}}s+=w,f+=j.nodeSize}const g=(h+1)*e;let y=0;for(;s<g;)r[s++]==0&&y++;y&&(a||(a=[])).push({type:"missing",row:h,n:y}),f++}(e===0||n===0)&&(a||(a=[])).push({type:"zero_sized"});const c=new qt(e,n,r,a);let u=!1;for(let h=0;!u&&h<o.length;h+=2)o[h]!=null&&o[h+1]<n&&(u=!0);return u&&A7(c,o,t),c}function M7(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let a=0;if(n)for(let o=0;o<r;o++){const c=t.child(o);for(let u=0;u<c.childCount;u++){const h=c.child(u);o+h.attrs.rowspan>r&&(a+=h.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const c=s.child(o);a+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=a:e!=a&&(e=Math.max(e,a))}return e}function A7(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const a=t.map[s];if(r[a])continue;r[a]=!0;const o=n.nodeAt(a);if(!o)throw new RangeError(`No cell with offset ${a} found`);let c=null;const u=o.attrs;for(let h=0;h<u.colspan;h++){const f=e[(s+h)%t.width*2];f!=null&&(!u.colwidth||u.colwidth[h]!=f)&&((c||(c=R7(u)))[h]=f)}c&&t.problems.unshift({type:"colwidth mismatch",pos:a,colwidth:c})}}function R7(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Wn(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const zi=new _t("selectingCells");function Ga(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function I7(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function rs(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function pf(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Ga(e.$head)||P7(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function P7(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ix(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function O7(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function M0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function d2(t,e,n){const r=t.node(-1),s=qt.get(r),a=t.start(-1),o=s.nextCell(t.pos-a,e,n);return o==null?null:t.node(0).resolve(a+o)}function Ja(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function u2(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function D7(t,e,n){const r=Wn(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var St=class Hs extends Ge{constructor(e,n=e){const r=e.node(-1),s=qt.get(r),a=e.start(-1),o=s.rectBetween(e.pos-a,n.pos-a),c=e.node(0),u=s.cellsInRect(o).filter(f=>f!=n.pos-a);u.unshift(n.pos-a);const h=u.map(f=>{const m=r.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=a+f+1;return new Zk(c.resolve(g),c.resolve(g+m.content.size))});super(h[0].$from,h[0].$to,h),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(ix(r)&&ix(s)&&M0(r,s)){const a=this.$anchorCell.node(-1)!=r.node(-1);return a&&this.isRowSelection()?Hs.rowSelection(r,s):a&&this.isColSelection()?Hs.colSelection(r,s):new Hs(r,s)}return He.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=qt.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),a={},o=[];for(let u=s.top;u<s.bottom;u++){const h=[];for(let f=u*n.width+s.left,m=s.left;m<s.right;m++,f++){const g=n.map[f];if(a[g])continue;a[g]=!0;const y=n.findCell(g);let v=e.nodeAt(g);if(!v)throw new RangeError(`No cell with offset ${g} found`);const j=s.left-y.left,w=y.right-s.right;if(j>0||w>0){let k=v.attrs;if(j>0&&(k=Ja(k,0,j)),w>0&&(k=Ja(k,k.colspan-w,w)),y.left<s.left){if(v=v.type.createAndFill(k),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else v=v.type.create(k,v.content)}if(y.top<s.top||y.bottom>s.bottom){const k={...v.attrs,rowspan:Math.min(y.bottom,s.bottom)-Math.max(y.top,s.top)};y.top<s.top?v=v.type.createAndFill(k):v=v.type.create(k,v.content)}h.push(v)}o.push(e.child(u).copy(pe.from(h)))}const c=this.isColSelection()&&this.isRowSelection()?e:o;return new Me(pe.from(c),1,1)}replace(e,n=Me.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:c,$to:u}=s[o],h=e.mapping.slice(r);e.replace(h.map(c.pos),h.map(u.pos),o?Me.empty:n)}const a=Ge.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);a&&e.setSelection(a)}replaceWith(e,n){this.replace(e,new Me(pe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=qt.get(n),s=this.$anchorCell.start(-1),a=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<a.length;o++)e(n.nodeAt(a[o]),s+a[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=qt.get(r),a=e.start(-1),o=s.findCell(e.pos-a),c=s.findCell(n.pos-a),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(a+s.map[o.left])),c.bottom<s.height&&(n=u.resolve(a+s.map[s.width*(s.height-1)+c.right-1]))):(c.top>0&&(n=u.resolve(a+s.map[c.left])),o.bottom<s.height&&(e=u.resolve(a+s.map[s.width*(s.height-1)+o.right-1]))),new Hs(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=qt.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),a=n.colCount(this.$headCell.pos-r);if(Math.min(s,a)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,c=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof Hs&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=qt.get(r),a=e.start(-1),o=s.findCell(e.pos-a),c=s.findCell(n.pos-a),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(a+s.map[o.top*s.width])),c.right<s.width&&(n=u.resolve(a+s.map[s.width*(c.top+1)-1]))):(c.left>0&&(n=u.resolve(a+s.map[c.top*s.width])),o.right<s.width&&(e=u.resolve(a+s.map[s.width*(o.top+1)-1]))),new Hs(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Hs(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Hs(e.resolve(n),e.resolve(r))}getBookmark(){return new L7(this.$anchorCell.pos,this.$headCell.pos)}};St.prototype.visible=!1;Ge.jsonID("cell",St);var L7=class h2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new h2(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&M0(n,r)?new St(n,r):Ge.near(r,1)}};function _7(t){if(!(t.selection instanceof St))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(hn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),wt.create(t.doc,e)}function z7({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let a=e.depth;a>=0&&!(e.before(a+1)>e.start(a));a--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function $7({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const a=t.node(s);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){n=a;break}}for(let s=e.depth;s>0;s--){const a=e.node(s);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){r=a;break}}return n!==r&&e.parentOffset===0}function F7(t,e,n){const r=(e||t).selection,s=(e||t).doc;let a,o;if(r instanceof Ve&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")a=St.create(s,r.from);else if(o=="row"){const c=s.resolve(r.from+1);a=St.rowSelection(c,c)}else if(!n){const c=qt.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];a=St.create(s,u+1,h)}}else r instanceof He&&z7(r)?a=He.create(s,r.from):r instanceof He&&$7(r)&&(a=He.create(s,r.$from.start(),r.$from.end()));return a&&(e||(e=t.tr)).setSelection(a),e}const B7=new _t("fix-tables");function f2(t,e,n,r){const s=t.childCount,a=e.childCount;e:for(let o=0,c=0;o<a;o++){const u=e.child(o);for(let h=c,f=Math.min(s,o+3);h<f;h++)if(t.child(h)==u){c=h+1,n+=u.nodeSize;continue e}r(u,n),c<s&&t.child(c).sameMarkup(u)?f2(t.child(c),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function p2(t,e){let n;const r=(s,a)=>{s.type.spec.tableRole=="table"&&(n=V7(t,s,a,n))};return e?e.doc!=t.doc&&f2(e.doc,t.doc,0,r):t.doc.descendants(r),n}function V7(t,e,n,r){const s=qt.get(e);if(!s.problems)return r;r||(r=t.tr);const a=[];for(let u=0;u<s.height;u++)a.push(0);for(let u=0;u<s.problems.length;u++){const h=s.problems[u];if(h.type=="collision"){const f=e.nodeAt(h.pos);if(!f)continue;const m=f.attrs;for(let g=0;g<m.rowspan;g++)a[h.row+g]+=h.n;r.setNodeMarkup(r.mapping.map(n+1+h.pos),null,Ja(m,m.colspan-h.n,h.n))}else if(h.type=="missing")a[h.row]+=h.n;else if(h.type=="overlong_rowspan"){const f=e.nodeAt(h.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+h.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-h.n})}else if(h.type=="colwidth mismatch"){const f=e.nodeAt(h.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+h.pos),null,{...f.attrs,colwidth:h.colwidth})}else if(h.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let o,c;for(let u=0;u<a.length;u++)a[u]&&(o==null&&(o=u),c=u);for(let u=0,h=n+1;u<s.height;u++){const f=e.child(u),m=h+f.nodeSize,g=a[u];if(g>0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const v=[];for(let w=0;w<g;w++){const k=Wn(t.schema)[y].createAndFill();k&&v.push(k)}const j=(u==0||o==u-1)&&c==u?h+1:m-1;r.insert(r.mapping.map(j),v)}h=m}return r.setMeta(B7,{fixTables:!0})}function Ss(t){const e=t.selection,n=pf(t),r=n.node(-1),s=n.start(-1),a=qt.get(r);return{...e instanceof St?a.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):a.findCell(n.pos-s),tableStart:s,map:a,table:r}}function m2(t,{map:e,tableStart:n,table:r},s){let a=s>0?-1:0;D7(e,r,s+a)&&(a=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const c=o*e.width+s;if(s>0&&s<e.width&&e.map[c-1]==e.map[c]){const u=e.map[c],h=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,u2(h.attrs,s-e.colCount(u))),o+=h.attrs.rowspan-1}else{const u=a==null?Wn(r.type.schema).cell:r.nodeAt(e.map[c+a]).type,h=e.positionAt(o,s,r);t.insert(t.mapping.map(n+h),u.createAndFill())}}return t}function H7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t);e(m2(t.tr,n,n.left))}return!0}function W7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t);e(m2(t.tr,n,n.right))}return!0}function U7(t,{map:e,table:n,tableStart:r},s){const a=t.mapping.maps.length;for(let o=0;o<e.height;){const c=o*e.width+s,u=e.map[c],h=n.nodeAt(u),f=h.attrs;if(s>0&&e.map[c-1]==u||s<e.width-1&&e.map[c+1]==u)t.setNodeMarkup(t.mapping.slice(a).map(r+u),null,Ja(f,s-e.colCount(u)));else{const m=t.mapping.slice(a).map(r+u);t.delete(m,m+h.nodeSize)}o+=f.rowspan}}function K7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;U7(r,n,s),s!=n.left;s--){const a=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!a)throw new RangeError("No table found");n.table=a,n.map=qt.get(a)}e(r)}return!0}function q7(t,e,n){var r;const s=Wn(e.type.schema).header_cell;for(let a=0;a<t.width;a++)if(((r=e.nodeAt(t.map[a+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function g2(t,{map:e,tableStart:n,table:r},s){let a=n;for(let h=0;h<s;h++)a+=r.child(h).nodeSize;const o=[];let c=s>0?-1:0;q7(e,r,s+c)&&(c=s==0||s==e.height?null:0);for(let h=0,f=e.width*s;h<e.width;h++,f++)if(s>0&&s<e.height&&e.map[f]==e.map[f-e.width]){const m=e.map[f],g=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),h+=g.colspan-1}else{var u;const m=c==null?Wn(r.type.schema).cell:(u=r.nodeAt(e.map[f+c*e.width]))===null||u===void 0?void 0:u.type,g=m==null?void 0:m.createAndFill();g&&o.push(g)}return t.insert(a,Wn(r.type.schema).row.create(null,o)),t}function G7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t);e(g2(t.tr,n,n.top))}return!0}function J7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t);e(g2(t.tr,n,n.bottom))}return!0}function Y7(t,{map:e,table:n,tableStart:r},s){let a=0;for(let h=0;h<s;h++)a+=n.child(h).nodeSize;const o=a+n.child(s).nodeSize,c=t.mapping.maps.length;t.delete(a+r,o+r);const u=new Set;for(let h=0,f=s*e.width;h<e.width;h++,f++){const m=e.map[f];if(!u.has(m)){if(u.add(m),s>0&&m==e.map[f-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),h+=g.colspan-1}else if(s<e.height&&m==e.map[f+e.width]){const g=n.nodeAt(m),y=g.attrs,v=g.type.create({...y,rowspan:g.attrs.rowspan-1},g.content),j=e.positionAt(s+1,h,n);t.insert(t.mapping.slice(c).map(r+j),v),h+=y.colspan-1}}}}function Q7(t,e){if(!rs(t))return!1;if(e){const n=Ss(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;Y7(r,n,s),s!=n.top;s--){const a=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!a)throw new RangeError("No table found");n.table=a,n.map=qt.get(n.table)}e(r)}return!0}function Pw(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function X7({width:t,height:e,map:n},r){let s=r.top*t+r.left,a=s,o=(r.bottom-1)*t+r.left,c=s+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[a]==n[a-1]||r.right<t&&n[c]==n[c+1])return!0;a+=t,c+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Ow(t,e){const n=t.selection;if(!(n instanceof St)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ss(t),{map:s}=r;if(X7(s,r))return!1;if(e){const a=t.tr,o={};let c=pe.empty,u,h;for(let f=r.top;f<r.bottom;f++)for(let m=r.left;m<r.right;m++){const g=s.map[f*s.width+m],y=r.table.nodeAt(g);if(!(o[g]||!y))if(o[g]=!0,u==null)u=g,h=y;else{Pw(y)||(c=c.append(y.content));const v=a.mapping.map(g+r.tableStart);a.delete(v,v+y.nodeSize)}}if(u==null||h==null)return!0;if(a.setNodeMarkup(u+r.tableStart,null,{...u2(h.attrs,h.attrs.colspan,r.right-r.left-h.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const f=u+1+h.content.size,m=Pw(h)?u+1:f;a.replaceWith(m+r.tableStart,f+r.tableStart,c)}a.setSelection(new St(a.doc.resolve(u+r.tableStart))),e(a)}return!0}function Dw(t,e){const n=Wn(t.schema);return Z7(({node:r})=>n[r.type.spec.tableRole])(t,e)}function Z7(t){return(e,n)=>{const r=e.selection;let s,a;if(r instanceof St){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{var o;if(s=I7(r.$from),!s)return!1;a=(o=Ga(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||a==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let c=s.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=Ss(e),m=e.tr;for(let y=0;y<f.right-f.left;y++)u.push(h?{...c,colwidth:h&&h[y]?[h[y]]:null}:c);let g;for(let y=f.top;y<f.bottom;y++){let v=f.map.positionAt(y,f.left,f.table);y==f.top&&(v+=s.nodeSize);for(let j=f.left,w=0;j<f.right;j++,w++)j==f.left&&y==f.top||m.insert(g=m.mapping.map(v+f.tableStart,1),t({node:s,row:y,col:j}).createAndFill(u[w]))}m.setNodeMarkup(a,t({node:s,row:f.top,col:f.left}),u[0]),r instanceof St&&m.setSelection(new St(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function e$(t,e){return function(n,r){if(!rs(n))return!1;const s=pf(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const a=n.tr;n.selection instanceof St?n.selection.forEachCell((o,c)=>{o.attrs[t]!==e&&a.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):a.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(a)}return!0}}function t$(t){return function(e,n){if(!rs(e))return!1;if(n){const r=Wn(e.schema),s=Ss(e),a=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),c=o.map(u=>s.table.nodeAt(u));for(let u=0;u<o.length;u++)c[u].type==r.header_cell&&a.setNodeMarkup(s.tableStart+o[u],r.cell,c[u].attrs);if(a.steps.length===0)for(let u=0;u<o.length;u++)a.setNodeMarkup(s.tableStart+o[u],r.header_cell,c[u].attrs);n(a)}return!0}}function Lw(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const a=e.table.nodeAt(r[s]);if(a&&a.type!==n.header_cell)return!1}return!0}function _c(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?t$(t):function(n,r){if(!rs(n))return!1;if(r){const s=Wn(n.schema),a=Ss(n),o=n.tr,c=Lw("row",a,s),u=Lw("column",a,s),h=(t==="column"?c:t==="row"&&u)?1:0,f=t=="column"?{left:0,top:h,right:1,bottom:a.map.height}:t=="row"?{left:h,top:0,right:a.map.width,bottom:1}:a,m=t=="column"?u?s.cell:s.header_cell:t=="row"?c?s.cell:s.header_cell:s.cell;a.map.cellsInRect(f).forEach(g=>{const y=g+a.tableStart,v=o.doc.nodeAt(y);v&&o.setNodeMarkup(y,m,v.attrs)}),r(o)}return!0}}_c("row",{useDeprecatedLogic:!0});_c("column",{useDeprecatedLogic:!0});const n$=_c("cell",{useDeprecatedLogic:!0});function r$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const a=t.node(-1).child(r),o=a.lastChild;if(o)return s-1-o.nodeSize;s-=a.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const a=n.child(r);if(a.childCount)return s+1;s+=a.nodeSize}}return null}function _w(t){return function(e,n){if(!rs(e))return!1;const r=r$(pf(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(He.between(s,O7(s))).scrollIntoView())}return!0}}function s$(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Su(t,e){const n=t.selection;if(!(n instanceof St))return!1;if(e){const r=t.tr,s=Wn(t.schema).cell.createAndFill().content;n.forEachCell((a,o)=>{a.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+a.nodeSize-1),new Me(s,0,0))}),r.docChanged&&e(r)}return!0}function i$(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),a=s.type.spec.tableRole,o=s.type.schema,c=[];if(a=="row")for(let u=0;u<e.childCount;u++){let h=e.child(u).content;const f=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,r-1);(f||m)&&(h=ax(Wn(o).row,new Me(h,f,m)).content),c.push(h)}else if(a=="cell"||a=="header_cell")c.push(n||r?ax(Wn(o).row,new Me(e,n,r)).content:e);else return null;return a$(o,c)}function a$(t,e){const n=[];for(let s=0;s<e.length;s++){const a=e[s];for(let o=a.childCount-1;o>=0;o--){const{rowspan:c,colspan:u}=a.child(o).attrs;for(let h=s;h<s+c;h++)n[h]=(n[h]||0)+u}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(pe.empty),n[s]<r){const a=Wn(t).cell.createAndFill(),o=[];for(let c=n[s];c<r;c++)o.push(a);e[s]=e[s].append(pe.from(o))}return{height:e.length,width:r,rows:e}}function ax(t,e){const n=t.createAndFill();return new Wx(n).replace(0,n.content.size,e).doc}function o$({width:t,height:e,rows:n},r,s){if(t!=r){const a=[],o=[];for(let c=0;c<n.length;c++){const u=n[c],h=[];for(let f=a[c]||0,m=0;f<r;m++){let g=u.child(m%u.childCount);f+g.attrs.colspan>r&&(g=g.type.createChecked(Ja(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;y<g.attrs.rowspan;y++)a[c+y]=(a[c+y]||0)+g.attrs.colspan}o.push(pe.from(h))}n=o,t=r}if(e!=s){const a=[];for(let o=0,c=0;o<s;o++,c++){const u=[],h=n[c%e];for(let f=0;f<h.childCount;f++){let m=h.child(f);o+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),u.push(m)}a.push(pe.from(u))}n=a,e=s}return{width:t,height:e,rows:n}}function l$(t,e,n,r,s,a,o){const c=t.doc.type.schema,u=Wn(c);let h,f;if(s>e.width)for(let m=0,g=0;m<e.height;m++){const y=n.child(m);g+=y.nodeSize;const v=[];let j;y.lastChild==null||y.lastChild.type==u.cell?j=h||(h=u.cell.createAndFill()):j=f||(f=u.header_cell.createAndFill());for(let w=e.width;w<s;w++)v.push(j);t.insert(t.mapping.slice(o).map(g-1+r),v)}if(a>e.height){const m=[];for(let v=0,j=(e.height-1)*e.width;v<Math.max(e.width,s);v++){const w=v>=e.width?!1:n.nodeAt(e.map[j+v]).type==u.header_cell;m.push(w?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,pe.from(m)),y=[];for(let v=e.height;v<a;v++)y.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),y)}return!!(h||f)}function zw(t,e,n,r,s,a,o,c){if(o==0||o==e.height)return!1;let u=!1;for(let h=s;h<a;h++){const f=o*e.width+h,m=e.map[f];if(e.map[f-e.width]==m){u=!0;const g=n.nodeAt(m),{top:y,left:v}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g.attrs,rowspan:o-y}),t.insert(t.mapping.slice(c).map(e.positionAt(o,v,n)),g.type.createAndFill({...g.attrs,rowspan:y+g.attrs.rowspan-o})),h+=g.attrs.colspan-1}}return u}function $w(t,e,n,r,s,a,o,c){if(o==0||o==e.width)return!1;let u=!1;for(let h=s;h<a;h++){const f=h*e.width+o,m=e.map[f];if(e.map[f-1]==m){u=!0;const g=n.nodeAt(m),y=e.colCount(m),v=t.mapping.slice(c).map(m+r);t.setNodeMarkup(v,null,Ja(g.attrs,o-y,g.attrs.colspan-(o-y))),t.insert(v+g.nodeSize,g.type.createAndFill(Ja(g.attrs,0,o-y))),h+=g.attrs.rowspan-1}}return u}function Fw(t,e,n,r,s){let a=n?t.doc.nodeAt(n-1):t.doc;if(!a)throw new Error("No table found");let o=qt.get(a);const{top:c,left:u}=r,h=u+s.width,f=c+s.height,m=t.tr;let g=0;function y(){if(a=n?m.doc.nodeAt(n-1):m.doc,!a)throw new Error("No table found");o=qt.get(a),g=m.mapping.maps.length}l$(m,o,a,n,h,f,g)&&y(),zw(m,o,a,n,u,h,c,g)&&y(),zw(m,o,a,n,u,h,f,g)&&y(),$w(m,o,a,n,c,f,u,g)&&y(),$w(m,o,a,n,c,f,h,g)&&y();for(let v=c;v<f;v++){const j=o.positionAt(v,u,a),w=o.positionAt(v,h,a);m.replace(m.mapping.slice(g).map(j+n),m.mapping.slice(g).map(w+n),new Me(s.rows[v-c],0,0))}y(),m.setSelection(new St(m.doc.resolve(n+o.positionAt(c,u,a)),m.doc.resolve(n+o.positionAt(f-1,h-1,a)))),e(m)}const c$=a0({ArrowLeft:Cu("horiz",-1),ArrowRight:Cu("horiz",1),ArrowUp:Cu("vert",-1),ArrowDown:Cu("vert",1),"Shift-ArrowLeft":Eu("horiz",-1),"Shift-ArrowRight":Eu("horiz",1),"Shift-ArrowUp":Eu("vert",-1),"Shift-ArrowDown":Eu("vert",1),Backspace:Su,"Mod-Backspace":Su,Delete:Su,"Mod-Delete":Su});function _u(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Cu(t,e){return(n,r,s)=>{if(!s)return!1;const a=n.selection;if(a instanceof St)return _u(n,r,Ge.near(a.$headCell,e));if(t!="horiz"&&!a.empty)return!1;const o=x2(s,t,e);if(o==null)return!1;if(t=="horiz")return _u(n,r,Ge.near(n.doc.resolve(a.head+e),e));{const c=n.doc.resolve(o),u=d2(c,t,e);let h;return u?h=Ge.near(u,1):e<0?h=Ge.near(n.doc.resolve(c.before(-1)),-1):h=Ge.near(n.doc.resolve(c.after(-1)),1),_u(n,r,h)}}}function Eu(t,e){return(n,r,s)=>{if(!s)return!1;const a=n.selection;let o;if(a instanceof St)o=a;else{const u=x2(s,t,e);if(u==null)return!1;o=new St(n.doc.resolve(u))}const c=d2(o.$headCell,t,e);return c?_u(n,r,new St(o.$anchorCell,c)):!1}}function d$(t,e){const n=t.state.doc,r=Ga(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new St(r))),!0):!1}function u$(t,e,n){if(!rs(t.state))return!1;let r=i$(n);const s=t.state.selection;if(s instanceof St){r||(r={width:1,height:1,rows:[pe.from(ax(Wn(t.state.schema).cell,n))]});const a=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),c=qt.get(a).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=o$(r,c.right-c.left,c.bottom-c.top),Fw(t.state,t.dispatch,o,c,r),!0}else if(r){const a=pf(t.state),o=a.start(-1);return Fw(t.state,t.dispatch,o,qt.get(a.node(-1)).findCell(a.pos-o),r),!0}else return!1}function h$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Bw(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof St)a(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Ga(t.state.selection.$anchor))!=null&&((n=ng(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)a(s,e),e.preventDefault();else if(!r)return;function a(u,h){let f=ng(t,h);const m=zi.getState(t.state)==null;if(!f||!M0(u,f))if(m)f=u;else return;const g=new St(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(zi,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),zi.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(zi,-1))}function c(u){const h=u,f=zi.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(Bw(t,h.target)!=r&&(m=ng(t,e),!m))return o();m&&a(m,h)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function x2(t,e,n){if(!(t.state.selection instanceof He))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const a=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole=="cell"||a.type.spec.tableRole=="header_cell"){const o=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function Bw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ng(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Ga(t.state.doc.resolve(r))||Ga(t.state.doc.resolve(s))}var f$=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ox(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ox(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ox(t,e,n,r,s,a){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;m<h.childCount;m++){const{colspan:y,colwidth:v}=h.child(m).attrs;for(let j=0;j<y;j++,g++){const w=s==g?a:v&&v[j],k=w?w+"px":"";if(o+=w||r,w||(c=!1),u)u.style.width!=k&&(u.style.width=k),u=u.nextSibling;else{const E=document.createElement("col");E.style.width=k,e.appendChild(E)}}}for(;u;){var f;const m=u.nextSibling;(f=u.parentNode)===null||f===void 0||f.removeChild(u),u=m}c?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const jr=new _t("tableColumnResizing");function p$({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=f$,lastColumnResizable:s=!0}={}){const a=new Ct({key:jr,state:{init(o,c){var u;const h=(u=a.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,f=Wn(c.schema).table.name;return r&&h&&(h[f]=(m,g)=>new r(m,n,g)),new m$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=jr.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{g$(o,c,t,s)},mouseleave:o=>{x$(o)},mousedown:(o,c)=>{y$(o,c,e,n)}},decorations:o=>{const c=jr.getState(o);if(c&&c.activeHandle>-1)return j$(o,c.activeHandle)},nodeViews:{}}});return a}var m$=class zu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(jr);if(r&&r.setHandle!=null)return new zu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new zu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return ix(e.doc.resolve(s))||(s=-1),new zu(s,n.dragging)}return n}};function g$(t,e,n,r){if(!t.editable)return;const s=jr.getState(t.state);if(s&&!s.dragging){const a=b$(e.target);let o=-1;if(a){const{left:c,right:u}=a.getBoundingClientRect();e.clientX-c<=n?o=Vw(t,e,"left",n):u-e.clientX<=n&&(o=Vw(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=qt.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}y2(t,o)}}}function x$(t){if(!t.editable)return;const e=jr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&y2(t,-1)}function y$(t,e,n,r){var s;if(!t.editable)return!1;const a=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=jr.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=v$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(jr,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){a.removeEventListener("mouseup",h),a.removeEventListener("mousemove",f);const g=jr.getState(t.state);g!=null&&g.dragging&&(w$(t,g.activeHandle,Hw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(jr,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=jr.getState(t.state);if(g&&g.dragging){const y=Hw(g.dragging,m,n);Ww(t,g.activeHandle,y,r)}}return Ww(t,o.activeHandle,u,r),a.addEventListener("mouseup",h),a.addEventListener("mousemove",f),e.preventDefault(),!0}function v$(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const a=t.domAtPos(e);let o=a.node.childNodes[a.offset].offsetWidth,c=n;if(r)for(let u=0;u<n;u++)r[u]&&(o-=r[u],c--);return o/c}function b$(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Vw(t,e,n,r){const s=n=="right"?-r:r,a=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!a)return-1;const{pos:o}=a,c=Ga(t.state.doc.resolve(o));if(!c)return-1;if(n=="right")return c.pos;const u=qt.get(c.node(-1)),h=c.start(-1),f=u.map.indexOf(c.pos-h);return f%u.width==0?-1:h+u.map[f-1]}function Hw(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function y2(t,e){t.dispatch(t.state.tr.setMeta(jr,{setHandle:e}))}function w$(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),a=qt.get(s),o=r.start(-1),c=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let h=0;h<a.height;h++){const f=h*a.width+c;if(h&&a.map[f]==a.map[f-a.width])continue;const m=a.map[f],g=s.nodeAt(m).attrs,y=g.colspan==1?0:c-a.colCount(m);if(g.colwidth&&g.colwidth[y]==n)continue;const v=g.colwidth?g.colwidth.slice():N$(g.colspan);v[y]=n,u.setNodeMarkup(o+m,null,{...g,colwidth:v})}u.docChanged&&t.dispatch(u)}function Ww(t,e,n,r){const s=t.state.doc.resolve(e),a=s.node(-1),o=s.start(-1),c=qt.get(a).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let u=t.domAtPos(s.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&ox(a,u.firstChild,u,r,c,n)}function N$(t){return Array(t).fill(0)}function j$(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return wt.empty;const a=qt.get(s),o=r.start(-1),c=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let h=0;h<a.height;h++){const f=c+h*a.width;if((c==a.width-1||a.map[f]!=a.map[f+1])&&(h==0||a.map[f]!=a.map[f-a.width])){var u;const m=a.map[f],g=o+m+s.nodeAt(m).nodeSize-1,y=document.createElement("div");y.className="column-resize-handle",!((u=jr.getState(t))===null||u===void 0)&&u.dragging&&n.push(hn.node(o+m,o+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(hn.widget(g,y))}}return wt.create(t.doc,n)}function k$({allowTableNodeSelection:t=!1}={}){return new Ct({key:zi,state:{init(){return null},apply(e,n){const r=e.getMeta(zi);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:a}=e.mapping.mapResult(n);return s?null:a}},props:{decorations:_7,handleDOMEvents:{mousedown:h$},createSelectionBetween(e){return zi.getState(e.state)!=null?e.state.selection:null},handleTripleClick:d$,handleKeyDown:c$,handlePaste:u$},appendTransaction(e,n,r){return F7(r,p2(r,n),t)}})}var v2=fn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(a=>parseInt(a,10)):null;if(!s){const a=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&a&&a[o]){const c=a[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",vt(this.options.HTMLAttributes,t),0]}}),b2=fn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",vt(this.options.HTMLAttributes,t),0]}}),w2=fn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",vt(this.options.HTMLAttributes,t),0]}});function lx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Uw(t,e,n,r,s,a){var o;let c=0,u=!0,h=e.firstChild;const f=t.firstChild;if(f!==null)for(let g=0,y=0;g<f.childCount;g+=1){const{colspan:v,colwidth:j}=f.child(g).attrs;for(let w=0;w<v;w+=1,y+=1){const k=s===y?a:j&&j[w],E=k?`${k}px`:"";if(c+=k||r,k||(u=!1),h){if(h.style.width!==E){const[C,M]=lx(r,k);h.style.setProperty(C,M)}h=h.nextSibling}else{const C=document.createElement("col"),[M,D]=lx(r,k);C.style.setProperty(M,D),e.appendChild(C)}}}for(;h;){const g=h.nextSibling;(o=h.parentNode)==null||o.removeChild(h),h=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var S$=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Uw(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Uw(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function C$(t,e,n,r){let s=0,a=!0;const o=[],c=t.firstChild;if(!c)return{};for(let m=0,g=0;m<c.childCount;m+=1){const{colspan:y,colwidth:v}=c.child(m).attrs;for(let j=0;j<y;j+=1,g+=1){const w=n===g?r:v&&v[j];s+=w||e,w||(a=!1);const[k,E]=lx(e,w);o.push(["col",{style:`${k}: ${E}`}])}}const u=a?`${s}px`:"",h=a?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:u,tableMinWidth:h}}function Kw(t,e){return t.createAndFill()}function E$(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function T$(t,e,n,r,s){const a=E$(t),o=[],c=[];for(let h=0;h<n;h+=1){const f=Kw(a.cell);if(f&&c.push(f),r){const m=Kw(a.header_cell);m&&o.push(m)}}const u=[];for(let h=0;h<e;h+=1)u.push(a.row.createChecked(null,r&&h===0?o:c));return a.table.createChecked(null,u)}function M$(t){return t instanceof St}var Tu=({editor:t})=>{const{selection:e}=t.state;if(!M$(e))return!1;let n=0;const r=rC(e.ranges[0].$from,a=>a.type.name==="table");return r==null||r.node.descendants(a=>{if(a.type.name==="table")return!1;["tableCell","tableHeader"].includes(a.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},A$="";function R$(t){return(t||"").replace(/\s+/g," ").trim()}function I$(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:A$;if(!t||!t.content||t.content.length===0)return"";const a=[];t.content.forEach(v=>{const j=[];v.content&&v.content.forEach(w=>{let k="";w.content&&Array.isArray(w.content)&&w.content.length>1?k=w.content.map(D=>e.renderChildren(D)).join(s):k=w.content?e.renderChildren(w.content):"";const E=R$(k),C=w.type==="tableHeader";j.push({text:E,isHeader:C})}),a.push(j)});const o=a.reduce((v,j)=>Math.max(v,j.length),0);if(o===0)return"";const c=new Array(o).fill(0);a.forEach(v=>{var j;for(let w=0;w<o;w+=1){const E=(((j=v[w])==null?void 0:j.text)||"").length;E>c[w]&&(c[w]=E),c[w]<3&&(c[w]=3)}});const u=(v,j)=>v+" ".repeat(Math.max(0,j-v.length)),h=a[0],f=h.some(v=>v.isHeader);let m=`
`;const g=new Array(o).fill(0).map((v,j)=>f&&h[j]&&h[j].text||"");return m+=`| ${g.map((v,j)=>u(v,c[j])).join(" | ")} |
`,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} |
`,(f?a.slice(1):a).forEach(v=>{m+=`| ${new Array(o).fill(0).map((j,w)=>u(v[w]&&v[w].text||"",c[w])).join(" | ")} |
`}),m}var P$=I$,N2=fn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:S$,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=C$(t,this.options.cellMinWidth),a=e.style;function o(){return a||(r?`width: ${r}`:`min-width: ${s}`)}const c=["table",vt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(a=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>P$(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:a})=>{const o=T$(a.schema,t,e,n);if(s){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(He.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>H7(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>W7(t,e),deleteColumn:()=>({state:t,dispatch:e})=>K7(t,e),addRowBefore:()=>({state:t,dispatch:e})=>G7(t,e),addRowAfter:()=>({state:t,dispatch:e})=>J7(t,e),deleteRow:()=>({state:t,dispatch:e})=>Q7(t,e),deleteTable:()=>({state:t,dispatch:e})=>s$(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ow(t,e),splitCell:()=>({state:t,dispatch:e})=>Dw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>_c("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>_c("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>n$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ow(t,e)?!0:Dw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>e$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>_w(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>_w(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&p2(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=St.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Tu,"Mod-Backspace":Tu,Delete:Tu,"Mod-Delete":Tu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[p$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],k$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:pt($e(t,"tableRole",e))}}});Gt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(N2.configure(this.options.table)),this.options.tableCell!==!1&&t.push(v2.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(b2.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(w2.configure(this.options.tableRow)),t}});function O$(t){if(!t)return"";let e=t;return e=e.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
`),e=e.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
`),e=e.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
`),e=e.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/<s[^>]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/<del[^>]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/<blockquote[^>]*>(.*?)<\/blockquote>/gi,`> $1
`),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/<img[^>]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
`),e=e.replace(/<\/?[uo]l[^>]*>/gi,`
`),e=e.replace(/<br\s*\/?>/gi,`
`),e=e.replace(/<p[^>]*>(.*?)<\/p>/gi,`$1
`),e=e.replace(/<hr\s*\/?>/gi,`---
`),e=e.replace(/<span[^>]*data-type="mention"[^>]*data-id="([^"]*)"[^>]*>@([^<]*)<\/span>/gi,"@$2"),e=e.replace(/<span[^>]*data-type="linkTag"[^>]*data-url="([^"]*)"[^>]*>#([^<]*)<\/span>/gi,"#[$2]($1)"),e=e.replace(/<[^>]+>/g,""),e=e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),e=e.replace(/\n{3,}/g,`
`),e.trim()}function qw(t){if(!t)return"";if(t.startsWith("<")&&t.includes("</"))return t;let e=t;e=e.replace(/^### (.+)$/gm,"<h3>$1</h3>"),e=e.replace(/^## (.+)$/gm,"<h2>$1</h2>"),e=e.replace(/^# (.+)$/gm,"<h1>$1</h1>"),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(.+?)\*/g,"<em>$1</em>"),e=e.replace(/~~(.+?)~~/g,"<s>$1</s>"),e=e.replace(/`([^`]+)`/g,"<code>$1</code>"),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" />'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),e=e.replace(/^> (.+)$/gm,"<blockquote><p>$1</p></blockquote>"),e=e.replace(/^---$/gm,"<hr />"),e=e.replace(/^- (.+)$/gm,"<li>$1</li>");const n=e.split(`
`),r=[];for(const s of n){const a=s.trim();a&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(a)?r.push(a):r.push(`<p>${a}</p>`))}return r.join("")}const D$=t=>({items:({query:e})=>t.filter(n=>n.name.toLowerCase().includes(e.toLowerCase())||n.id.includes(e)).slice(0,8),render:()=>{let e=null,n=0,r=[],s=null;const a=()=>{e&&(e.innerHTML=r.map((o,c)=>`<div class="mention-item ${c===n?"is-selected":""}" data-index="${c}">
<span class="mention-name">@${o.name}</span>
<span class="mention-id">${o.label||o.id}</span>
</div>`).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");s&&r[c]&&s({id:r[c].id,label:r[c].name})})}))};return{onStart:o=>{if(e=document.createElement("div"),e.className="mention-popup",document.body.appendChild(e),r=o.items,s=o.command,n=0,a(),o.clientRect){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onUpdate:o=>{if(r=o.items,s=o.command,n=0,a(),o.clientRect&&e){const c=o.clientRect();c&&(e.style.top=`${c.bottom+4}px`,e.style.left=`${c.left}px`)}},onKeyDown:o=>o.event.key==="ArrowUp"?(n=Math.max(0,n-1),a(),!0):o.event.key==="ArrowDown"?(n=Math.min(r.length-1,n+1),a(),!0):o.event.key==="Enter"?(s&&r[n]&&s({id:r[n].id,label:r[n].name}),!0):o.event.key==="Escape"?(e==null||e.remove(),e=null,!0):!1,onExit:()=>{e==null||e.remove(),e=null}}}}),j2=b.forwardRef(({content:t,onChange:e,onImageUpload:n,persons:r=[],linkTags:s=[],placeholder:a="开始编辑内容...",className:o},c)=>{const u=b.useRef(null),[h,f]=b.useState(""),[m,g]=b.useState(!1),y=b.useRef(qw(t)),v=A_({extensions:[x7,b7.configure({inline:!0,allowBase64:!0}),Cz.configure({openOnClick:!1,HTMLAttributes:{class:"rich-link"}}),C7.configure({HTMLAttributes:{class:"mention-tag"},suggestion:D$(r)}),E7.configure({placeholder:a}),N2.configure({resizable:!0}),w2,v2,b2],content:y.current,onUpdate:({editor:E})=>{e(E.getHTML())},editorProps:{attributes:{class:"rich-editor-content"}}});b.useImperativeHandle(c,()=>({getHTML:()=>(v==null?void 0:v.getHTML())||"",getMarkdown:()=>O$((v==null?void 0:v.getHTML())||"")})),b.useEffect(()=>{if(v&&t!==v.getHTML()){const E=qw(t);E!==v.getHTML()&&v.commands.setContent(E)}},[t]);const j=b.useCallback(async E=>{var M;const C=(M=E.target.files)==null?void 0:M[0];if(!(!C||!v)){if(n){const D=await n(C);D&&v.chain().focus().setImage({src:D}).run()}else{const D=new FileReader;D.onload=()=>{typeof D.result=="string"&&v.chain().focus().setImage({src:D.result}).run()},D.readAsDataURL(C)}E.target.value=""}},[v,n]),w=b.useCallback(E=>{v&&v.chain().focus().insertContent({type:"text",marks:[{type:"link",attrs:{href:E.url,target:"_blank"}}],text:`#${E.label}`}).run()},[v]),k=b.useCallback(()=>{!v||!h||(v.chain().focus().setLink({href:h}).run(),f(""),g(!1))},[v,h]);return v?i.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[i.jsxs("div",{className:"rich-editor-toolbar",children:[i.jsxs("div",{className:"toolbar-group",children:[i.jsx("button",{onClick:()=>v.chain().focus().toggleBold().run(),className:v.isActive("bold")?"is-active":"",type:"button",children:i.jsx(CT,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleItalic().run(),className:v.isActive("italic")?"is-active":"",type:"button",children:i.jsx(EM,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleStrike().run(),className:v.isActive("strike")?"is-active":"",type:"button",children:i.jsx(jA,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleCode().run(),className:v.isActive("code")?"is-active":"",type:"button",children:i.jsx(KT,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"toolbar-divider"}),i.jsxs("div",{className:"toolbar-group",children:[i.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:1}).run(),className:v.isActive("heading",{level:1})?"is-active":"",type:"button",children:i.jsx(xM,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:2}).run(),className:v.isActive("heading",{level:2})?"is-active":"",type:"button",children:i.jsx(vM,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:3}).run(),className:v.isActive("heading",{level:3})?"is-active":"",type:"button",children:i.jsx(wM,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"toolbar-divider"}),i.jsxs("div",{className:"toolbar-group",children:[i.jsx("button",{onClick:()=>v.chain().focus().toggleBulletList().run(),className:v.isActive("bulletList")?"is-active":"",type:"button",children:i.jsx(_M,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleOrderedList().run(),className:v.isActive("orderedList")?"is-active":"",type:"button",children:i.jsx(DM,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().toggleBlockquote().run(),className:v.isActive("blockquote")?"is-active":"",type:"button",children:i.jsx(lA,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().setHorizontalRule().run(),type:"button",children:i.jsx(GM,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"toolbar-divider"}),i.jsxs("div",{className:"toolbar-group",children:[i.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:j,className:"hidden"}),i.jsx("button",{onClick:()=>{var E;return(E=u.current)==null?void 0:E.click()},type:"button",children:i.jsx(LN,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>g(!m),className:v.isActive("link")?"is-active":"",type:"button",children:i.jsx(gg,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:i.jsx(SA,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"toolbar-divider"}),i.jsxs("div",{className:"toolbar-group",children:[i.jsx("button",{onClick:()=>v.chain().focus().undo().run(),disabled:!v.can().undo(),type:"button",children:i.jsx(IA,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>v.chain().focus().redo().run(),disabled:!v.can().redo(),type:"button",children:i.jsx(dA,{className:"w-4 h-4"})})]}),s.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"toolbar-divider"}),i.jsx("div",{className:"toolbar-group",children:i.jsxs("select",{className:"link-tag-select",onChange:E=>{const C=s.find(M=>M.id===E.target.value);C&&w(C),E.target.value=""},defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),s.map(E=>i.jsx("option",{value:E.id,children:E.label},E.id))]})})]})]}),m&&i.jsxs("div",{className:"link-input-bar",children:[i.jsx("input",{type:"url",placeholder:"输入链接地址...",value:h,onChange:E=>f(E.target.value),onKeyDown:E=>E.key==="Enter"&&k(),className:"link-input"}),i.jsx("button",{onClick:k,className:"link-confirm",type:"button",children:"确定"}),i.jsx("button",{onClick:()=>{v.chain().focus().unsetLink().run(),g(!1)},className:"link-remove",type:"button",children:"移除"})]}),i.jsx(IC,{editor:v})]}):null});j2.displayName="RichEditor";const L$=["top","right","bottom","left"],ea=Math.min,wr=Math.max,_h=Math.round,Mu=Math.floor,ws=t=>({x:t,y:t}),_$={left:"right",right:"left",bottom:"top",top:"bottom"},z$={start:"end",end:"start"};function cx(t,e,n){return wr(t,ea(e,n))}function Zs(t,e){return typeof t=="function"?t(e):t}function ei(t){return t.split("-")[0]}function fl(t){return t.split("-")[1]}function A0(t){return t==="x"?"y":"x"}function R0(t){return t==="y"?"height":"width"}const $$=new Set(["top","bottom"]);function bs(t){return $$.has(ei(t))?"y":"x"}function I0(t){return A0(bs(t))}function F$(t,e,n){n===void 0&&(n=!1);const r=fl(t),s=I0(t),a=R0(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=zh(o)),[o,zh(o)]}function B$(t){const e=zh(t);return[dx(t),e,dx(e)]}function dx(t){return t.replace(/start|end/g,e=>z$[e])}const Gw=["left","right"],Jw=["right","left"],V$=["top","bottom"],H$=["bottom","top"];function W$(t,e,n){switch(t){case"top":case"bottom":return n?e?Jw:Gw:e?Gw:Jw;case"left":case"right":return e?V$:H$;default:return[]}}function U$(t,e,n,r){const s=fl(t);let a=W$(ei(t),n==="start",r);return s&&(a=a.map(o=>o+"-"+s),e&&(a=a.concat(a.map(dx)))),a}function zh(t){return t.replace(/left|right|bottom|top/g,e=>_$[e])}function K$(t){return{top:0,right:0,bottom:0,left:0,...t}}function k2(t){return typeof t!="number"?K$(t):{top:t,right:t,bottom:t,left:t}}function $h(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Yw(t,e,n){let{reference:r,floating:s}=t;const a=bs(e),o=I0(e),c=R0(o),u=ei(e),h=a==="y",f=r.x+r.width/2-s.width/2,m=r.y+r.height/2-s.height/2,g=r[c]/2-s[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-s.height};break;case"bottom":y={x:f,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:m};break;case"left":y={x:r.x-s.width,y:m};break;default:y={x:r.x,y:r.y}}switch(fl(e)){case"start":y[o]-=g*(n&&h?-1:1);break;case"end":y[o]+=g*(n&&h?-1:1);break}return y}async function q$(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:a,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=Zs(e,t),v=k2(y),w=c[g?m==="floating"?"reference":"floating":m],k=$h(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),E=m==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),M=await(a.isElement==null?void 0:a.isElement(C))?await(a.getScale==null?void 0:a.getScale(C))||{x:1,y:1}:{x:1,y:1},D=$h(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:C,strategy:u}):E);return{top:(k.top-D.top+v.top)/M.y,bottom:(D.bottom-k.bottom+v.bottom)/M.y,left:(k.left-D.left+v.left)/M.x,right:(D.right-k.right+v.right)/M.x}}const G$=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:o}=n,c=a.filter(Boolean),u=await(o.isRTL==null?void 0:o.isRTL(e));let h=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:f,y:m}=Yw(h,r,u),g=r,y={},v=0;for(let w=0;w<c.length;w++){var j;const{name:k,fn:E}=c[w],{x:C,y:M,data:D,reset:F}=await E({x:f,y:m,initialPlacement:r,placement:g,strategy:s,middlewareData:y,rects:h,platform:{...o,detectOverflow:(j=o.detectOverflow)!=null?j:q$},elements:{reference:t,floating:e}});f=C??f,m=M??m,y={...y,[k]:{...y[k],...D}},F&&v<=50&&(v++,typeof F=="object"&&(F.placement&&(g=F.placement),F.rects&&(h=F.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):F.rects),{x:f,y:m}=Yw(h,g,u)),w=-1)}return{x:f,y:m,placement:g,strategy:s,middlewareData:y}},J$=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:a,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=Zs(t,e)||{};if(h==null)return{};const m=k2(f),g={x:n,y:r},y=I0(s),v=R0(y),j=await o.getDimensions(h),w=y==="y",k=w?"top":"left",E=w?"bottom":"right",C=w?"clientHeight":"clientWidth",M=a.reference[v]+a.reference[y]-g[y]-a.floating[v],D=g[y]-a.reference[y],F=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let R=F?F[C]:0;(!R||!await(o.isElement==null?void 0:o.isElement(F)))&&(R=c.floating[C]||a.floating[v]);const I=M/2-D/2,A=R/2-j[v]/2-1,O=ea(m[k],A),W=ea(m[E],A),X=O,q=R-j[v]-W,Z=R/2-j[v]/2+I,_=cx(X,Z,q),$=!u.arrow&&fl(s)!=null&&Z!==_&&a.reference[v]/2-(Z<X?O:W)-j[v]/2<0,oe=$?Z<X?Z-X:Z-q:0;return{[y]:g[y]+oe,data:{[y]:_,centerOffset:Z-_-oe,...$&&{alignmentOffset:oe}},reset:$}}}),Y$=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:a,rects:o,initialPlacement:c,platform:u,elements:h}=e,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:j=!0,...w}=Zs(t,e);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const k=ei(s),E=bs(c),C=ei(c)===c,M=await(u.isRTL==null?void 0:u.isRTL(h.floating)),D=g||(C||!j?[zh(c)]:B$(c)),F=v!=="none";!g&&F&&D.push(...U$(c,j,v,M));const R=[c,...D],I=await u.detectOverflow(e,w),A=[];let O=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&A.push(I[k]),m){const Z=F$(s,o,M);A.push(I[Z[0]],I[Z[1]])}if(O=[...O,{placement:s,overflows:A}],!A.every(Z=>Z<=0)){var W,X;const Z=(((W=a.flip)==null?void 0:W.index)||0)+1,_=R[Z];if(_&&(!(m==="alignment"?E!==bs(_):!1)||O.every(V=>bs(V.placement)===E?V.overflows[0]>0:!0)))return{data:{index:Z,overflows:O},reset:{placement:_}};let $=(X=O.filter(oe=>oe.overflows[0]<=0).sort((oe,V)=>oe.overflows[1]-V.overflows[1])[0])==null?void 0:X.placement;if(!$)switch(y){case"bestFit":{var q;const oe=(q=O.filter(V=>{if(F){const ae=bs(V.placement);return ae===E||ae==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(ae=>ae>0).reduce((ae,Y)=>ae+Y,0)]).sort((V,ae)=>V[1]-ae[1])[0])==null?void 0:q[0];oe&&($=oe);break}case"initialPlacement":$=c;break}if(s!==$)return{reset:{placement:$}}}return{}}}};function Qw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Xw(t){return L$.some(e=>t[e]>=0)}const Q$=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...a}=Zs(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...a,elementContext:"reference"}),c=Qw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Xw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...a,altBoundary:!0}),c=Qw(o,n.floating);return{data:{escapedOffsets:c,escaped:Xw(c)}}}default:return{}}}}},S2=new Set(["left","top"]);async function X$(t,e){const{placement:n,platform:r,elements:s}=t,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=ei(n),c=fl(n),u=bs(n)==="y",h=S2.has(o)?-1:1,f=a&&u?-1:1,m=Zs(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:v}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof v=="number"&&(y=c==="end"?v*-1:v),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const Z$=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:a,placement:o,middlewareData:c}=e,u=await X$(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:s+u.x,y:a+u.y,data:{...u,placement:o}}}}},eF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:a}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:k=>{let{x:E,y:C}=k;return{x:E,y:C}}},...h}=Zs(t,e),f={x:n,y:r},m=await a.detectOverflow(e,h),g=bs(ei(s)),y=A0(g);let v=f[y],j=f[g];if(o){const k=y==="y"?"top":"left",E=y==="y"?"bottom":"right",C=v+m[k],M=v-m[E];v=cx(C,v,M)}if(c){const k=g==="y"?"top":"left",E=g==="y"?"bottom":"right",C=j+m[k],M=j-m[E];j=cx(C,j,M)}const w=u.fn({...e,[y]:v,[g]:j});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[y]:o,[g]:c}}}}}},tF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:s,rects:a,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=Zs(t,e),f={x:n,y:r},m=bs(s),g=A0(m);let y=f[g],v=f[m];const j=Zs(c,e),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(u){const C=g==="y"?"height":"width",M=a.reference[g]-a.floating[C]+w.mainAxis,D=a.reference[g]+a.reference[C]-w.mainAxis;y<M?y=M:y>D&&(y=D)}if(h){var k,E;const C=g==="y"?"width":"height",M=S2.has(ei(s)),D=a.reference[m]-a.floating[C]+(M&&((k=o.offset)==null?void 0:k[m])||0)+(M?0:w.crossAxis),F=a.reference[m]+a.reference[C]+(M?0:((E=o.offset)==null?void 0:E[m])||0)-(M?w.crossAxis:0);v<D?v=D:v>F&&(v=F)}return{[g]:y,[m]:v}}}},nF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:a,platform:o,elements:c}=e,{apply:u=()=>{},...h}=Zs(t,e),f=await o.detectOverflow(e,h),m=ei(s),g=fl(s),y=bs(s)==="y",{width:v,height:j}=a.floating;let w,k;m==="top"||m==="bottom"?(w=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,w=g==="end"?"top":"bottom");const E=j-f.top-f.bottom,C=v-f.left-f.right,M=ea(j-f[w],E),D=ea(v-f[k],C),F=!e.middlewareData.shift;let R=M,I=D;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(I=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(R=E),F&&!g){const O=wr(f.left,0),W=wr(f.right,0),X=wr(f.top,0),q=wr(f.bottom,0);y?I=v-2*(O!==0||W!==0?O+W:wr(f.left,f.right)):R=j-2*(X!==0||q!==0?X+q:wr(f.top,f.bottom))}await u({...e,availableWidth:I,availableHeight:R});const A=await o.getDimensions(c.floating);return v!==A.width||j!==A.height?{reset:{rects:!0}}:{}}}};function mf(){return typeof window<"u"}function pl(t){return C2(t)?(t.nodeName||"").toLowerCase():"#document"}function Sr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Cs(t){var e;return(e=(C2(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function C2(t){return mf()?t instanceof Node||t instanceof Sr(t).Node:!1}function es(t){return mf()?t instanceof Element||t instanceof Sr(t).Element:!1}function ks(t){return mf()?t instanceof HTMLElement||t instanceof Sr(t).HTMLElement:!1}function Zw(t){return!mf()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Sr(t).ShadowRoot}const rF=new Set(["inline","contents"]);function Gc(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=ts(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!rF.has(s)}const sF=new Set(["table","td","th"]);function iF(t){return sF.has(pl(t))}const aF=[":popover-open",":modal"];function gf(t){return aF.some(e=>{try{return t.matches(e)}catch{return!1}})}const oF=["transform","translate","scale","rotate","perspective"],lF=["transform","translate","scale","rotate","perspective","filter"],cF=["paint","layout","strict","content"];function P0(t){const e=O0(),n=es(t)?ts(t):t;return oF.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||lF.some(r=>(n.willChange||"").includes(r))||cF.some(r=>(n.contain||"").includes(r))}function dF(t){let e=ta(t);for(;ks(e)&&!sl(e);){if(P0(e))return e;if(gf(e))return null;e=ta(e)}return null}function O0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const uF=new Set(["html","body","#document"]);function sl(t){return uF.has(pl(t))}function ts(t){return Sr(t).getComputedStyle(t)}function xf(t){return es(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ta(t){if(pl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Zw(t)&&t.host||Cs(t);return Zw(e)?e.host:e}function E2(t){const e=ta(t);return sl(e)?t.ownerDocument?t.ownerDocument.body:t.body:ks(e)&&Gc(e)?e:E2(e)}function zc(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=E2(t),a=s===((r=t.ownerDocument)==null?void 0:r.body),o=Sr(s);if(a){const c=ux(o);return e.concat(o,o.visualViewport||[],Gc(s)?s:[],c&&n?zc(c):[])}return e.concat(s,zc(s,[],n))}function ux(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function T2(t){const e=ts(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ks(t),a=s?t.offsetWidth:n,o=s?t.offsetHeight:r,c=_h(n)!==a||_h(r)!==o;return c&&(n=a,r=o),{width:n,height:r,$:c}}function D0(t){return es(t)?t:t.contextElement}function Go(t){const e=D0(t);if(!ks(e))return ws(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:a}=T2(e);let o=(a?_h(n.width):n.width)/r,c=(a?_h(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const hF=ws(0);function M2(t){const e=Sr(t);return!O0()||!e.visualViewport?hF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function fF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Sr(t)?!1:e}function Ya(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),a=D0(t);let o=ws(1);e&&(r?es(r)&&(o=Go(r)):o=Go(t));const c=fF(a,n,r)?M2(a):ws(0);let u=(s.left+c.x)/o.x,h=(s.top+c.y)/o.y,f=s.width/o.x,m=s.height/o.y;if(a){const g=Sr(a),y=r&&es(r)?Sr(r):r;let v=g,j=ux(v);for(;j&&r&&y!==v;){const w=Go(j),k=j.getBoundingClientRect(),E=ts(j),C=k.left+(j.clientLeft+parseFloat(E.paddingLeft))*w.x,M=k.top+(j.clientTop+parseFloat(E.paddingTop))*w.y;u*=w.x,h*=w.y,f*=w.x,m*=w.y,u+=C,h+=M,v=Sr(j),j=ux(v)}}return $h({width:f,height:m,x:u,y:h})}function yf(t,e){const n=xf(t).scrollLeft;return e?e.left+n:Ya(Cs(t)).left+n}function A2(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-yf(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function pF(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const a=s==="fixed",o=Cs(r),c=e?gf(e.floating):!1;if(r===o||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=ws(1);const f=ws(0),m=ks(r);if((m||!m&&!a)&&((pl(r)!=="body"||Gc(o))&&(u=xf(r)),ks(r))){const y=Ya(r);h=Go(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!a?A2(o,u):ws(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+f.x+g.x,y:n.y*h.y-u.scrollTop*h.y+f.y+g.y}}function mF(t){return Array.from(t.getClientRects())}function gF(t){const e=Cs(t),n=xf(t),r=t.ownerDocument.body,s=wr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),a=wr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+yf(t);const c=-n.scrollTop;return ts(r).direction==="rtl"&&(o+=wr(e.clientWidth,r.clientWidth)-s),{width:s,height:a,x:o,y:c}}const eN=25;function xF(t,e){const n=Sr(t),r=Cs(t),s=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,c=0,u=0;if(s){a=s.width,o=s.height;const f=O0();(!f||f&&e==="fixed")&&(c=s.offsetLeft,u=s.offsetTop)}const h=yf(r);if(h<=0){const f=r.ownerDocument,m=f.body,g=getComputedStyle(m),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,v=Math.abs(r.clientWidth-m.clientWidth-y);v<=eN&&(a-=v)}else h<=eN&&(a+=h);return{width:a,height:o,x:c,y:u}}const yF=new Set(["absolute","fixed"]);function vF(t,e){const n=Ya(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,a=ks(t)?Go(t):ws(1),o=t.clientWidth*a.x,c=t.clientHeight*a.y,u=s*a.x,h=r*a.y;return{width:o,height:c,x:u,y:h}}function tN(t,e,n){let r;if(e==="viewport")r=xF(t,n);else if(e==="document")r=gF(Cs(t));else if(es(e))r=vF(e,n);else{const s=M2(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return $h(r)}function R2(t,e){const n=ta(t);return n===e||!es(n)||sl(n)?!1:ts(n).position==="fixed"||R2(n,e)}function bF(t,e){const n=e.get(t);if(n)return n;let r=zc(t,[],!1).filter(c=>es(c)&&pl(c)!=="body"),s=null;const a=ts(t).position==="fixed";let o=a?ta(t):t;for(;es(o)&&!sl(o);){const c=ts(o),u=P0(o);!u&&c.position==="fixed"&&(s=null),(a?!u&&!s:!u&&c.position==="static"&&!!s&&yF.has(s.position)||Gc(o)&&!u&&R2(t,o))?r=r.filter(f=>f!==o):s=c,o=ta(o)}return e.set(t,r),r}function wF(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?gf(e)?[]:bF(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=tN(e,f,s);return h.top=wr(m.top,h.top),h.right=ea(m.right,h.right),h.bottom=ea(m.bottom,h.bottom),h.left=wr(m.left,h.left),h},tN(e,c,s));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function NF(t){const{width:e,height:n}=T2(t);return{width:e,height:n}}function jF(t,e,n){const r=ks(e),s=Cs(e),a=n==="fixed",o=Ya(t,!0,a,e);let c={scrollLeft:0,scrollTop:0};const u=ws(0);function h(){u.x=yf(s)}if(r||!r&&!a)if((pl(e)!=="body"||Gc(s))&&(c=xf(e)),r){const y=Ya(e,!0,a,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else s&&h();a&&!r&&s&&h();const f=s&&!r&&!a?A2(s,c):ws(0),m=o.left+c.scrollLeft-u.x-f.x,g=o.top+c.scrollTop-u.y-f.y;return{x:m,y:g,width:o.width,height:o.height}}function rg(t){return ts(t).position==="static"}function nN(t,e){if(!ks(t)||ts(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Cs(t)===n&&(n=n.ownerDocument.body),n}function I2(t,e){const n=Sr(t);if(gf(t))return n;if(!ks(t)){let s=ta(t);for(;s&&!sl(s);){if(es(s)&&!rg(s))return s;s=ta(s)}return n}let r=nN(t,e);for(;r&&iF(r)&&rg(r);)r=nN(r,e);return r&&sl(r)&&rg(r)&&!P0(r)?n:r||dF(t)||n}const kF=async function(t){const e=this.getOffsetParent||I2,n=this.getDimensions,r=await n(t.floating);return{reference:jF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function SF(t){return ts(t).direction==="rtl"}const CF={convertOffsetParentRelativeRectToViewportRelativeRect:pF,getDocumentElement:Cs,getClippingRect:wF,getOffsetParent:I2,getElementRects:kF,getClientRects:mF,getDimensions:NF,getScale:Go,isElement:es,isRTL:SF};function P2(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function EF(t,e){let n=null,r;const s=Cs(t);function a(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function o(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const h=t.getBoundingClientRect(),{left:f,top:m,width:g,height:y}=h;if(c||e(),!g||!y)return;const v=Mu(m),j=Mu(s.clientWidth-(f+g)),w=Mu(s.clientHeight-(m+y)),k=Mu(f),C={rootMargin:-v+"px "+-j+"px "+-w+"px "+-k+"px",threshold:wr(0,ea(1,u))||1};let M=!0;function D(F){const R=F[0].intersectionRatio;if(R!==u){if(!M)return o();R?o(!1,R):r=setTimeout(()=>{o(!1,1e-7)},1e3)}R===1&&!P2(h,t.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(D,{...C,root:s.ownerDocument})}catch{n=new IntersectionObserver(D,C)}n.observe(t)}return o(!0),a}function TF(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=D0(t),f=s||a?[...h?zc(h):[],...zc(e)]:[];f.forEach(k=>{s&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const m=h&&c?EF(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(k=>{let[E]=k;E&&E.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var C;(C=y)==null||C.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let v,j=u?Ya(t):null;u&&w();function w(){const k=Ya(t);j&&!P2(j,k)&&n(),j=k,v=requestAnimationFrame(w)}return n(),()=>{var k;f.forEach(E=>{s&&E.removeEventListener("scroll",n),a&&E.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,u&&cancelAnimationFrame(v)}}const MF=Z$,AF=eF,RF=Y$,IF=nF,PF=Q$,rN=J$,OF=tF,DF=(t,e,n)=>{const r=new Map,s={platform:CF,...n},a={...s.platform,_c:r};return G$(t,e,{...s,platform:a})};var LF=typeof document<"u",_F=function(){},$u=LF?b.useLayoutEffect:_F;function Fh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Fh(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&t.$$typeof)&&!Fh(t[a],e[a]))return!1}return!0}return t!==t&&e!==e}function O2(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function sN(t,e){const n=O2(t);return Math.round(e*n)/n}function sg(t){const e=b.useRef(t);return $u(()=>{e.current=t}),e}function zF(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=b.useState(r);Fh(g,r)||y(r);const[v,j]=b.useState(null),[w,k]=b.useState(null),E=b.useCallback(V=>{V!==F.current&&(F.current=V,j(V))},[]),C=b.useCallback(V=>{V!==R.current&&(R.current=V,k(V))},[]),M=a||v,D=o||w,F=b.useRef(null),R=b.useRef(null),I=b.useRef(f),A=u!=null,O=sg(u),W=sg(s),X=sg(h),q=b.useCallback(()=>{if(!F.current||!R.current)return;const V={placement:e,strategy:n,middleware:g};W.current&&(V.platform=W.current),DF(F.current,R.current,V).then(ae=>{const Y={...ae,isPositioned:X.current!==!1};Z.current&&!Fh(I.current,Y)&&(I.current=Y,Fc.flushSync(()=>{m(Y)}))})},[g,e,n,W,X]);$u(()=>{h===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,m(V=>({...V,isPositioned:!1})))},[h]);const Z=b.useRef(!1);$u(()=>(Z.current=!0,()=>{Z.current=!1}),[]),$u(()=>{if(M&&(F.current=M),D&&(R.current=D),M&&D){if(O.current)return O.current(M,D,q);q()}},[M,D,q,O,A]);const _=b.useMemo(()=>({reference:F,floating:R,setReference:E,setFloating:C}),[E,C]),$=b.useMemo(()=>({reference:M,floating:D}),[M,D]),oe=b.useMemo(()=>{const V={position:n,left:0,top:0};if(!$.floating)return V;const ae=sN($.floating,f.x),Y=sN($.floating,f.y);return c?{...V,transform:"translate("+ae+"px, "+Y+"px)",...O2($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ae,top:Y}},[n,c,$.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:q,refs:_,elements:$,floatingStyles:oe}),[f,q,_,$,oe])}const $F=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?rN({element:r.current,padding:s}).fn(n):{}:r?rN({element:r,padding:s}).fn(n):{}}}},FF=(t,e)=>({...MF(t),options:[t,e]}),BF=(t,e)=>({...AF(t),options:[t,e]}),VF=(t,e)=>({...OF(t),options:[t,e]}),HF=(t,e)=>({...RF(t),options:[t,e]}),WF=(t,e)=>({...IF(t),options:[t,e]}),UF=(t,e)=>({...PF(t),options:[t,e]}),KF=(t,e)=>({...$F(t),options:[t,e]});var qF="Arrow",D2=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:s=5,...a}=t;return i.jsx(ot.svg,{...a,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});D2.displayName=qF;var GF=D2,L0="Popper",[L2,_2]=ia(L0),[JF,z2]=L2(L0),$2=t=>{const{__scopePopper:e,children:n}=t,[r,s]=b.useState(null);return i.jsx(JF,{scope:e,anchor:r,onAnchorChange:s,children:n})};$2.displayName=L0;var F2="PopperAnchor",B2=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...s}=t,a=z2(F2,n),o=b.useRef(null),c=mt(e,o),u=b.useRef(null);return b.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&a.onAnchorChange(u.current)}),r?null:i.jsx(ot.div,{...s,ref:c})});B2.displayName=F2;var _0="PopperContent",[YF,QF]=L2(_0),V2=b.forwardRef((t,e)=>{var ee,de,Ce,B,me,Se;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:v,...j}=t,w=z2(_0,n),[k,E]=b.useState(null),C=mt(e,rt=>E(rt)),[M,D]=b.useState(null),F=_x(M),R=(F==null?void 0:F.width)??0,I=(F==null?void 0:F.height)??0,A=r+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(h)?h:[h],X=W.length>0,q={padding:O,boundary:W.filter(ZF),altBoundary:X},{refs:Z,floatingStyles:_,placement:$,isPositioned:oe,middlewareData:V}=zF({strategy:"fixed",placement:A,whileElementsMounted:(...rt)=>TF(...rt,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[FF({mainAxis:s+I,alignmentAxis:o}),u&&BF({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?VF():void 0,...q}),u&&HF({...q}),WF({...q,apply:({elements:rt,rects:Ye,availableWidth:st,availableHeight:Qe})=>{const{width:Xe,height:ft}=Ye.reference,Pt=rt.floating.style;Pt.setProperty("--radix-popper-available-width",`${st}px`),Pt.setProperty("--radix-popper-available-height",`${Qe}px`),Pt.setProperty("--radix-popper-anchor-width",`${Xe}px`),Pt.setProperty("--radix-popper-anchor-height",`${ft}px`)}}),M&&KF({element:M,padding:c}),eB({arrowWidth:R,arrowHeight:I}),g&&UF({strategy:"referenceHidden",...q})]}),[ae,Y]=U2($),L=Qi(v);Vn(()=>{oe&&(L==null||L())},[oe,L]);const H=(ee=V.arrow)==null?void 0:ee.x,ue=(de=V.arrow)==null?void 0:de.y,U=((Ce=V.arrow)==null?void 0:Ce.centerOffset)!==0,[he,Q]=b.useState();return Vn(()=>{k&&Q(window.getComputedStyle(k).zIndex)},[k]),i.jsx("div",{ref:Z.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:oe?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:he,"--radix-popper-transform-origin":[(B=V.transformOrigin)==null?void 0:B.x,(me=V.transformOrigin)==null?void 0:me.y].join(" "),...((Se=V.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:i.jsx(YF,{scope:n,placedSide:ae,onArrowChange:D,arrowX:H,arrowY:ue,shouldHideArrow:U,children:i.jsx(ot.div,{"data-side":ae,"data-align":Y,...j,ref:C,style:{...j.style,animation:oe?void 0:"none"}})})})});V2.displayName=_0;var H2="PopperArrow",XF={top:"bottom",right:"left",bottom:"top",left:"right"},W2=b.forwardRef(function(e,n){const{__scopePopper:r,...s}=e,a=QF(H2,r),o=XF[a.placedSide];return i.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:i.jsx(GF,{...s,ref:n,style:{...s.style,display:"block"}})})});W2.displayName=H2;function ZF(t){return t!==null}var eB=t=>({name:"transformOrigin",options:t,fn(e){var w,k,E;const{placement:n,rects:r,middlewareData:s}=e,o=((w=s.arrow)==null?void 0:w.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=U2(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((k=s.arrow)==null?void 0:k.x)??0)+c/2,y=(((E=s.arrow)==null?void 0:E.y)??0)+u/2;let v="",j="";return h==="bottom"?(v=o?m:`${g}px`,j=`${-u}px`):h==="top"?(v=o?m:`${g}px`,j=`${r.floating.height+u}px`):h==="right"?(v=`${-u}px`,j=o?m:`${y}px`):h==="left"&&(v=`${r.floating.width+u}px`,j=o?m:`${y}px`),{data:{x:v,y:j}}}});function U2(t){const[e,n="center"]=t.split("-");return[e,n]}var tB=$2,nB=B2,rB=V2,sB=W2,K2=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),iB="VisuallyHidden",aB=b.forwardRef((t,e)=>i.jsx(ot.span,{...t,ref:e,style:{...K2,...t.style}}));aB.displayName=iB;var oB=[" ","Enter","ArrowUp","ArrowDown"],lB=[" ","Enter"],Qa="Select",[vf,bf,cB]=Ox(Qa),[ml]=ia(Qa,[cB,_2]),wf=_2(),[dB,ca]=ml(Qa),[uB,hB]=ml(Qa),q2=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:s,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:v}=t,j=wf(e),[w,k]=b.useState(null),[E,C]=b.useState(null),[M,D]=b.useState(!1),F=Gh(h),[R,I]=Ba({prop:r,defaultProp:s??!1,onChange:a,caller:Qa}),[A,O]=Ba({prop:o,defaultProp:c,onChange:u,caller:Qa}),W=b.useRef(null),X=w?v||!!w.closest("form"):!0,[q,Z]=b.useState(new Set),_=Array.from(q).map($=>$.props.value).join(";");return i.jsx(tB,{...j,children:i.jsxs(dB,{required:y,scope:e,trigger:w,onTriggerChange:k,valueNode:E,onValueNodeChange:C,valueNodeHasChildren:M,onValueNodeHasChildrenChange:D,contentId:Ki(),value:A,onValueChange:O,open:R,onOpenChange:I,dir:F,triggerPointerDownPosRef:W,disabled:g,children:[i.jsx(vf.Provider,{scope:e,children:i.jsx(uB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback($=>{Z(oe=>new Set(oe).add($))},[]),onNativeOptionRemove:b.useCallback($=>{Z(oe=>{const V=new Set(oe);return V.delete($),V})},[]),children:n})}),X?i.jsxs(mE,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:A,onChange:$=>O($.target.value),disabled:g,form:v,children:[A===void 0?i.jsx("option",{value:""}):null,Array.from(q)]},_):null]})})};q2.displayName=Qa;var G2="SelectTrigger",J2=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...s}=t,a=wf(n),o=ca(G2,n),c=o.disabled||r,u=mt(e,o.onTriggerChange),h=bf(n),f=b.useRef("touch"),[m,g,y]=xE(j=>{const w=h().filter(C=>!C.disabled),k=w.find(C=>C.value===o.value),E=yE(w,j,k);E!==void 0&&o.onValueChange(E.value)}),v=j=>{c||(o.onOpenChange(!0),y()),j&&(o.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return i.jsx(nB,{asChild:!0,...a,children:i.jsx(ot.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":gE(o.value)?"":void 0,...s,ref:u,onClick:nt(s.onClick,j=>{j.currentTarget.focus(),f.current!=="mouse"&&v(j)}),onPointerDown:nt(s.onPointerDown,j=>{f.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(v(j),j.preventDefault())}),onKeyDown:nt(s.onKeyDown,j=>{const w=m.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&oB.includes(j.key)&&(v(),j.preventDefault())})})})});J2.displayName=G2;var Y2="SelectValue",Q2=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:o="",...c}=t,u=ca(Y2,n),{onValueNodeHasChildrenChange:h}=u,f=a!==void 0,m=mt(e,u.onValueNodeChange);return Vn(()=>{h(f)},[h,f]),i.jsx(ot.span,{...c,ref:m,style:{pointerEvents:"none"},children:gE(u.value)?i.jsx(i.Fragment,{children:o}):a})});Q2.displayName=Y2;var fB="SelectIcon",X2=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...s}=t;return i.jsx(ot.span,{"aria-hidden":!0,...s,ref:e,children:r||"▼"})});X2.displayName=fB;var pB="SelectPortal",Z2=t=>i.jsx(Mx,{asChild:!0,...t});Z2.displayName=pB;var Xa="SelectContent",eE=b.forwardRef((t,e)=>{const n=ca(Xa,t.__scopeSelect),[r,s]=b.useState();if(Vn(()=>{s(new DocumentFragment)},[]),!n.open){const a=r;return a?Fc.createPortal(i.jsx(tE,{scope:t.__scopeSelect,children:i.jsx(vf.Slot,{scope:t.__scopeSelect,children:i.jsx("div",{children:t.children})})}),a):null}return i.jsx(nE,{...t,ref:e})});eE.displayName=Xa;var Jr=10,[tE,da]=ml(Xa),mB="SelectContentImpl",gB=Sc("SelectContent.RemoveScroll"),nE=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:j,avoidCollisions:w,...k}=t,E=ca(Xa,n),[C,M]=b.useState(null),[D,F]=b.useState(null),R=mt(e,ee=>M(ee)),[I,A]=b.useState(null),[O,W]=b.useState(null),X=bf(n),[q,Z]=b.useState(!1),_=b.useRef(!1);b.useEffect(()=>{if(C)return mj(C)},[C]),aj();const $=b.useCallback(ee=>{const[de,...Ce]=X().map(Se=>Se.ref.current),[B]=Ce.slice(-1),me=document.activeElement;for(const Se of ee)if(Se===me||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===de&&D&&(D.scrollTop=0),Se===B&&D&&(D.scrollTop=D.scrollHeight),Se==null||Se.focus(),document.activeElement!==me))return},[X,D]),oe=b.useCallback(()=>$([I,C]),[$,I,C]);b.useEffect(()=>{q&&oe()},[q,oe]);const{onOpenChange:V,triggerPointerDownPosRef:ae}=E;b.useEffect(()=>{if(C){let ee={x:0,y:0};const de=B=>{var me,Se;ee={x:Math.abs(Math.round(B.pageX)-(((me=ae.current)==null?void 0:me.x)??0)),y:Math.abs(Math.round(B.pageY)-(((Se=ae.current)==null?void 0:Se.y)??0))}},Ce=B=>{ee.x<=10&&ee.y<=10?B.preventDefault():C.contains(B.target)||V(!1),document.removeEventListener("pointermove",de),ae.current=null};return ae.current!==null&&(document.addEventListener("pointermove",de),document.addEventListener("pointerup",Ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",de),document.removeEventListener("pointerup",Ce,{capture:!0})}}},[C,V,ae]),b.useEffect(()=>{const ee=()=>V(!1);return window.addEventListener("blur",ee),window.addEventListener("resize",ee),()=>{window.removeEventListener("blur",ee),window.removeEventListener("resize",ee)}},[V]);const[Y,L]=xE(ee=>{const de=X().filter(me=>!me.disabled),Ce=de.find(me=>me.ref.current===document.activeElement),B=yE(de,ee,Ce);B&&setTimeout(()=>B.ref.current.focus())}),H=b.useCallback((ee,de,Ce)=>{const B=!_.current&&!Ce;(E.value!==void 0&&E.value===de||B)&&(A(ee),B&&(_.current=!0))},[E.value]),ue=b.useCallback(()=>C==null?void 0:C.focus(),[C]),U=b.useCallback((ee,de,Ce)=>{const B=!_.current&&!Ce;(E.value!==void 0&&E.value===de||B)&&W(ee)},[E.value]),he=r==="popper"?hx:rE,Q=he===hx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:j,avoidCollisions:w}:{};return i.jsx(tE,{scope:n,content:C,viewport:D,onViewportChange:F,itemRefCallback:H,selectedItem:I,onItemLeave:ue,itemTextRefCallback:U,focusSelectedItem:oe,selectedItemText:O,position:r,isPositioned:q,searchRef:Y,children:i.jsx(Ax,{as:gB,allowPinchZoom:!0,children:i.jsx(Tx,{asChild:!0,trapped:E.open,onMountAutoFocus:ee=>{ee.preventDefault()},onUnmountAutoFocus:nt(s,ee=>{var de;(de=E.trigger)==null||de.focus({preventScroll:!0}),ee.preventDefault()}),children:i.jsx(Ex,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:ee=>ee.preventDefault(),onDismiss:()=>E.onOpenChange(!1),children:i.jsx(he,{role:"listbox",id:E.contentId,"data-state":E.open?"open":"closed",dir:E.dir,onContextMenu:ee=>ee.preventDefault(),...k,...Q,onPlaced:()=>Z(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:nt(k.onKeyDown,ee=>{const de=ee.ctrlKey||ee.altKey||ee.metaKey;if(ee.key==="Tab"&&ee.preventDefault(),!de&&ee.key.length===1&&L(ee.key),["ArrowUp","ArrowDown","Home","End"].includes(ee.key)){let B=X().filter(me=>!me.disabled).map(me=>me.ref.current);if(["ArrowUp","End"].includes(ee.key)&&(B=B.slice().reverse()),["ArrowUp","ArrowDown"].includes(ee.key)){const me=ee.target,Se=B.indexOf(me);B=B.slice(Se+1)}setTimeout(()=>$(B)),ee.preventDefault()}})})})})})})});nE.displayName=mB;var xB="SelectItemAlignedPosition",rE=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...s}=t,a=ca(Xa,n),o=da(Xa,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=mt(e,R=>f(R)),g=bf(n),y=b.useRef(!1),v=b.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:k,focusSelectedItem:E}=o,C=b.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&j&&w&&k){const R=a.trigger.getBoundingClientRect(),I=h.getBoundingClientRect(),A=a.valueNode.getBoundingClientRect(),O=k.getBoundingClientRect();if(a.dir!=="rtl"){const me=O.left-I.left,Se=A.left-me,rt=R.left-Se,Ye=R.width+rt,st=Math.max(Ye,I.width),Qe=window.innerWidth-Jr,Xe=qu(Se,[Jr,Math.max(Jr,Qe-st)]);c.style.minWidth=Ye+"px",c.style.left=Xe+"px"}else{const me=I.right-O.right,Se=window.innerWidth-A.right-me,rt=window.innerWidth-R.right-Se,Ye=R.width+rt,st=Math.max(Ye,I.width),Qe=window.innerWidth-Jr,Xe=qu(Se,[Jr,Math.max(Jr,Qe-st)]);c.style.minWidth=Ye+"px",c.style.right=Xe+"px"}const W=g(),X=window.innerHeight-Jr*2,q=j.scrollHeight,Z=window.getComputedStyle(h),_=parseInt(Z.borderTopWidth,10),$=parseInt(Z.paddingTop,10),oe=parseInt(Z.borderBottomWidth,10),V=parseInt(Z.paddingBottom,10),ae=_+$+q+V+oe,Y=Math.min(w.offsetHeight*5,ae),L=window.getComputedStyle(j),H=parseInt(L.paddingTop,10),ue=parseInt(L.paddingBottom,10),U=R.top+R.height/2-Jr,he=X-U,Q=w.offsetHeight/2,ee=w.offsetTop+Q,de=_+$+ee,Ce=ae-de;if(de<=U){const me=W.length>0&&w===W[W.length-1].ref.current;c.style.bottom="0px";const Se=h.clientHeight-j.offsetTop-j.offsetHeight,rt=Math.max(he,Q+(me?ue:0)+Se+oe),Ye=de+rt;c.style.height=Ye+"px"}else{const me=W.length>0&&w===W[0].ref.current;c.style.top="0px";const rt=Math.max(U,_+j.offsetTop+(me?H:0)+Q)+Ce;c.style.height=rt+"px",j.scrollTop=de-U+j.offsetTop}c.style.margin=`${Jr}px 0`,c.style.minHeight=Y+"px",c.style.maxHeight=X+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,a.trigger,a.valueNode,c,h,j,w,k,a.dir,r]);Vn(()=>C(),[C]);const[M,D]=b.useState();Vn(()=>{h&&D(window.getComputedStyle(h).zIndex)},[h]);const F=b.useCallback(R=>{R&&v.current===!0&&(C(),E==null||E(),v.current=!1)},[C,E]);return i.jsx(vB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:F,children:i.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:i.jsx(ot.div,{...s,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});rE.displayName=xB;var yB="SelectPopperPosition",hx=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Jr,...a}=t,o=wf(n);return i.jsx(rB,{...o,...a,ref:e,align:r,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});hx.displayName=yB;var[vB,z0]=ml(Xa,{}),fx="SelectViewport",sE=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...s}=t,a=da(fx,n),o=z0(fx,n),c=mt(e,a.onViewportChange),u=b.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),i.jsx(vf.Slot,{scope:n,children:i.jsx(ot.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:nt(s.onScroll,h=>{const f=h.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:g}=o;if(g!=null&&g.current&&m){const y=Math.abs(u.current-f.scrollTop);if(y>0){const v=window.innerHeight-Jr*2,j=parseFloat(m.style.minHeight),w=parseFloat(m.style.height),k=Math.max(j,w);if(k<v){const E=k+y,C=Math.min(v,E),M=E-C;m.style.height=C+"px",m.style.bottom==="0px"&&(f.scrollTop=M>0?M:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});sE.displayName=fx;var iE="SelectGroup",[bB,wB]=ml(iE),NB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=Ki();return i.jsx(bB,{scope:n,id:s,children:i.jsx(ot.div,{role:"group","aria-labelledby":s,...r,ref:e})})});NB.displayName=iE;var aE="SelectLabel",jB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=wB(aE,n);return i.jsx(ot.div,{id:s.id,...r,ref:e})});jB.displayName=aE;var Bh="SelectItem",[kB,oE]=ml(Bh),lE=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:a,...o}=t,c=ca(Bh,n),u=da(Bh,n),h=c.value===r,[f,m]=b.useState(a??""),[g,y]=b.useState(!1),v=mt(e,E=>{var C;return(C=u.itemRefCallback)==null?void 0:C.call(u,E,r,s)}),j=Ki(),w=b.useRef("touch"),k=()=>{s||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(kB,{scope:n,value:r,disabled:s,textId:j,isSelected:h,onItemTextChange:b.useCallback(E=>{m(C=>C||((E==null?void 0:E.textContent)??"").trim())},[]),children:i.jsx(vf.ItemSlot,{scope:n,value:r,disabled:s,textValue:f,children:i.jsx(ot.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...o,ref:v,onFocus:nt(o.onFocus,()=>y(!0)),onBlur:nt(o.onBlur,()=>y(!1)),onClick:nt(o.onClick,()=>{w.current!=="mouse"&&k()}),onPointerUp:nt(o.onPointerUp,()=>{w.current==="mouse"&&k()}),onPointerDown:nt(o.onPointerDown,E=>{w.current=E.pointerType}),onPointerMove:nt(o.onPointerMove,E=>{var C;w.current=E.pointerType,s?(C=u.onItemLeave)==null||C.call(u):w.current==="mouse"&&E.currentTarget.focus({preventScroll:!0})}),onPointerLeave:nt(o.onPointerLeave,E=>{var C;E.currentTarget===document.activeElement&&((C=u.onItemLeave)==null||C.call(u))}),onKeyDown:nt(o.onKeyDown,E=>{var M;((M=u.searchRef)==null?void 0:M.current)!==""&&E.key===" "||(lB.includes(E.key)&&k(),E.key===" "&&E.preventDefault())})})})})});lE.displayName=Bh;var oc="SelectItemText",cE=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:s,...a}=t,o=ca(oc,n),c=da(oc,n),u=oE(oc,n),h=hB(oc,n),[f,m]=b.useState(null),g=mt(e,k=>m(k),u.onItemTextChange,k=>{var E;return(E=c.itemTextRefCallback)==null?void 0:E.call(c,k,u.value,u.disabled)}),y=f==null?void 0:f.textContent,v=b.useMemo(()=>i.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=h;return Vn(()=>(j(v),()=>w(v)),[j,w,v]),i.jsxs(i.Fragment,{children:[i.jsx(ot.span,{id:u.textId,...a,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Fc.createPortal(a.children,o.valueNode):null]})});cE.displayName=oc;var dE="SelectItemIndicator",uE=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return oE(dE,n).isSelected?i.jsx(ot.span,{"aria-hidden":!0,...r,ref:e}):null});uE.displayName=dE;var px="SelectScrollUpButton",hE=b.forwardRef((t,e)=>{const n=da(px,t.__scopeSelect),r=z0(px,t.__scopeSelect),[s,a]=b.useState(!1),o=mt(e,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollTop>0;a(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),s?i.jsx(pE,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});hE.displayName=px;var mx="SelectScrollDownButton",fE=b.forwardRef((t,e)=>{const n=da(mx,t.__scopeSelect),r=z0(mx,t.__scopeSelect),[s,a]=b.useState(!1),o=mt(e,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<h;a(f)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),s?i.jsx(pE,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});fE.displayName=mx;var pE=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=t,a=da("SelectScrollButton",n),o=b.useRef(null),c=bf(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Vn(()=>{var f;const h=c().find(m=>m.ref.current===document.activeElement);(f=h==null?void 0:h.ref.current)==null||f.scrollIntoView({block:"nearest"})},[c]),i.jsx(ot.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:nt(s.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:nt(s.onPointerMove,()=>{var h;(h=a.onItemLeave)==null||h.call(a),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:nt(s.onPointerLeave,()=>{u()})})}),SB="SelectSeparator",CB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return i.jsx(ot.div,{"aria-hidden":!0,...r,ref:e})});CB.displayName=SB;var gx="SelectArrow",EB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,s=wf(n),a=ca(gx,n),o=da(gx,n);return a.open&&o.position==="popper"?i.jsx(sB,{...s,...r,ref:e}):null});EB.displayName=gx;var TB="SelectBubbleInput",mE=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const s=b.useRef(null),a=mt(r,s),o=Lx(e);return b.useEffect(()=>{const c=s.current;if(!c)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==e&&f){const m=new Event("change",{bubbles:!0});f.call(c,e),c.dispatchEvent(m)}},[o,e]),i.jsx(ot.select,{...n,style:{...K2,...n.style},ref:a,defaultValue:e})});mE.displayName=TB;function gE(t){return t===""||t===void 0}function xE(t){const e=Qi(t),n=b.useRef(""),r=b.useRef(0),s=b.useCallback(o=>{const c=n.current+o;e(c),(function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(c)},[e]),a=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,a]}function yE(t,e,n){const s=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,a=n?t.indexOf(n):-1;let o=MB(t,Math.max(a,0));s.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(s.toLowerCase()));return u!==n?u:void 0}function MB(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var AB=q2,vE=J2,RB=Q2,IB=X2,PB=Z2,bE=eE,OB=sE,wE=lE,DB=cE,LB=uE,_B=hE,zB=fE;const ec=AB,tc=RB,zo=b.forwardRef(({className:t,children:e,...n},r)=>i.jsxs(vE,{ref:r,className:gt("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,i.jsx(IB,{asChild:!0,children:i.jsx(jc,{className:"h-4 w-4 opacity-50"})})]}));zo.displayName=vE.displayName;const $o=b.forwardRef(({className:t,children:e,position:n="popper",...r},s)=>i.jsx(PB,{children:i.jsxs(bE,{ref:s,className:gt("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1",t),position:n,...r,children:[i.jsx(_B,{className:"flex cursor-default items-center justify-center py-1",children:i.jsx(RN,{className:"h-4 w-4"})}),i.jsx(OB,{className:"p-1",children:e}),i.jsx(zB,{className:"flex cursor-default items-center justify-center py-1",children:i.jsx(jc,{className:"h-4 w-4"})})]})}));$o.displayName=bE.displayName;const Ws=b.forwardRef(({className:t,children:e,...n},r)=>i.jsxs(wE,{ref:r,className:gt("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(LB,{children:i.jsx(Wh,{className:"h-4 w-4"})})}),i.jsx(DB,{children:e})]}));Ws.displayName=wE.displayName;const $B=["一","二","三","四","五","六","七","八","九","十"];function ig(t){return t.startsWith("part:")?{type:"part",id:t.slice(5)}:t.startsWith("chapter:")?{type:"chapter",id:t.slice(8)}:t.startsWith("section:")?{type:"section",id:t.slice(8)}:null}function FB({parts:t,expandedParts:e,onTogglePart:n,onReorder:r,onReadSection:s,onDeleteSection:a,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:v,pinnedSectionIds:j=[]}){const[w,k]=b.useState(null),[E,C]=b.useState(null),M=(O,W)=>(w==null?void 0:w.type)===O&&(w==null?void 0:w.id)===W,D=(O,W)=>(E==null?void 0:E.type)===O&&(E==null?void 0:E.id)===W,F=b.useCallback(()=>{const O=[];for(const W of t)for(const X of W.chapters)for(const q of X.sections)O.push({id:q.id,partId:W.id,partTitle:W.title,chapterId:X.id,chapterTitle:X.title});return O},[t]),R=b.useCallback(async(O,W,X,q)=>{var V;O.preventDefault(),O.stopPropagation();const Z=O.dataTransfer.getData("text/plain"),_=ig(Z);if(!_||_.type===W&&_.id===X)return;const $=F(),oe=new Map($.map(ae=>[ae.id,ae]));if(_.type==="part"&&W==="part"){const ae=t.map(U=>U.id),Y=ae.indexOf(_.id),L=ae.indexOf(X);if(Y===-1||L===-1)return;const H=[...ae];H.splice(Y,1),H.splice(Y<L?L-1:L,0,_.id);const ue=[];for(const U of H){const he=t.find(Q=>Q.id===U);if(he)for(const Q of he.chapters)for(const ee of Q.sections){const de=oe.get(ee.id);de&&ue.push(de)}}await r(ue);return}if(_.type==="chapter"&&(W==="chapter"||W==="section"||W==="part")){const ae=t.find(de=>de.chapters.some(Ce=>Ce.id===_.id)),Y=ae==null?void 0:ae.chapters.find(de=>de.id===_.id);if(!ae||!Y)return;let L,H,ue=null;if(W==="section"){const de=oe.get(X);if(!de)return;L=de.partId,H=de.partTitle,ue=X}else if(W==="chapter"){const de=t.find(me=>me.chapters.some(Se=>Se.id===X)),Ce=de==null?void 0:de.chapters.find(me=>me.id===X);if(!de||!Ce)return;L=de.id,H=de.title;const B=$.filter(me=>me.chapterId===X).pop();ue=(B==null?void 0:B.id)??null}else{const de=t.find(B=>B.id===X);if(!de||!de.chapters[0])return;L=de.id,H=de.title;const Ce=$.filter(B=>B.partId===de.id&&B.chapterId===de.chapters[0].id);ue=((V=Ce[Ce.length-1])==null?void 0:V.id)??null}const U=Y.sections.map(de=>de.id),he=$.filter(de=>!U.includes(de.id));let Q=he.length;if(ue){const de=he.findIndex(Ce=>Ce.id===ue);de>=0&&(Q=de+1)}const ee=U.map(de=>({...oe.get(de),partId:L,partTitle:H,chapterId:Y.id,chapterTitle:Y.title}));await r([...he.slice(0,Q),...ee,...he.slice(Q)]);return}if(_.type==="section"&&(W==="section"||W==="chapter"||W==="part")){if(!q)return;const{partId:ae,partTitle:Y,chapterId:L,chapterTitle:H}=q;let ue;if(W==="section")ue=$.findIndex(Ce=>Ce.id===X);else if(W==="chapter"){const Ce=$.filter(B=>B.chapterId===X).pop();ue=Ce?$.findIndex(B=>B.id===Ce.id)+1:$.length}else{const Ce=t.find(Se=>Se.id===X);if(!(Ce!=null&&Ce.chapters[0]))return;const B=$.filter(Se=>Se.partId===Ce.id&&Se.chapterId===Ce.chapters[0].id),me=B[B.length-1];ue=me?$.findIndex(Se=>Se.id===me.id)+1:0}const U=$.findIndex(Ce=>Ce.id===_.id);if(U===-1)return;const he=$.filter(Ce=>Ce.id!==_.id),Q=U<ue?ue-1:ue,de={...$[U],partId:ae,partTitle:Y,chapterId:L,chapterTitle:H};he.splice(Q,0,de),await r(he)}},[t,F,r]),I=(O,W,X)=>({onDragEnter:q=>{q.preventDefault(),q.stopPropagation(),q.dataTransfer.dropEffect="move",C({type:O,id:W})},onDragOver:q=>{q.preventDefault(),q.stopPropagation(),q.dataTransfer.dropEffect="move",C({type:O,id:W})},onDragLeave:()=>C(null),onDrop:q=>{C(null);const Z=ig(q.dataTransfer.getData("text/plain"));if(Z&&!(O==="section"&&Z.type==="section"&&Z.id===W))if(O==="part")if(Z.type==="part")R(q,"part",W);else{const _=t.find(oe=>oe.id===W);(_==null?void 0:_.chapters[0])&&X&&R(q,"part",W,X)}else O==="chapter"&&X?(Z.type==="section"||Z.type==="chapter")&&R(q,"chapter",W,X):O==="section"&&X&&R(q,"section",W,X)}}),A=O=>$B[O]??String(O+1);return i.jsx("div",{className:"space-y-3",children:t.map((O,W)=>{var Y,L,H,ue;const X=O.title==="序言"||O.title.includes("序言"),q=O.title==="尾声"||O.title.includes("尾声"),Z=O.title==="附录"||O.title.includes("附录"),_=D("part",O.id),$=e.includes(O.id),oe=O.chapters.length,V=O.chapters.reduce((U,he)=>U+he.sections.length,0);if(X&&O.chapters.length===1&&O.chapters[0].sections.length===1){const U=O.chapters[0].sections[0],he=D("section",U.id),Q={partId:O.id,partTitle:O.title,chapterId:O.chapters[0].id,chapterTitle:O.chapters[0].title};return i.jsxs("div",{draggable:!0,onDragStart:ee=>{ee.stopPropagation(),ee.dataTransfer.setData("text/plain","section:"+U.id),ee.dataTransfer.effectAllowed="move",k({type:"section",id:U.id})},onDragEnd:()=>{k(null),C(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${he?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",U.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...I("section",U.id,Q),children:[i.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[i.jsx(_s,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:ee=>ee.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(U.id),onChange:()=>y(U.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:i.jsx(zr,{className:"w-4 h-4 text-gray-400"})}),i.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[O.chapters[0].title," | ",U.title]}),j.includes(U.id)&&i.jsx("span",{title:"已置顶",children:i.jsx(Vo,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>ee.stopPropagation(),children:[U.price===0||U.isFree?i.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):i.jsxs("span",{className:"text-xs text-gray-500",children:["¥",U.price]}),i.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",U.clickCount??0," · 付款 ",U.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(U.hotScore??0).toFixed(1)," · 第",U.hotRank&&U.hotRank>0?U.hotRank:"-","名"]}),v&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(U),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>s(U),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(U),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]})]},O.id)}if(O.title==="2026每日派对干货"||O.title.includes("2026每日派对干货")){const U=D("part",O.id);return i.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${U?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...I("part",O.id,{partId:O.id,partTitle:O.title,chapterId:((Y=O.chapters[0])==null?void 0:Y.id)??"",chapterTitle:((L=O.chapters[0])==null?void 0:L.title)??""}),children:[i.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","part:"+O.id),he.dataTransfer.effectAllowed="move",k({type:"part",id:O.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",O.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(O.id),children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsx(_s,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),i.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-white text-base",children:O.title}),i.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",V," 节"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:he=>he.stopPropagation(),onClick:he=>he.stopPropagation(),children:[o&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:i.jsx(Lt,{className:"w-3.5 h-3.5"})}),h&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),f&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(O),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:i.jsx(vn,{className:"w-3.5 h-3.5"})}),i.jsxs("span",{className:"text-xs text-gray-500",children:[oe,"章"]}),$?i.jsx(jc,{className:"w-5 h-5 text-gray-500"}):i.jsx(Fo,{className:"w-5 h-5 text-gray-500"})]})]}),$&&O.chapters.length>0&&i.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:O.chapters.map(he=>i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 w-full",children:[i.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:he.title}),i.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>m(O,he),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),c&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>c(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:i.jsx(Lt,{className:"w-3.5 h-3.5"})}),u&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>u(O,he),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx("div",{className:"space-y-1 pl-2",children:he.sections.map(Q=>{const ee=D("section",Q.id);return i.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+Q.id),de.dataTransfer.effectAllowed="move",k({type:"section",id:Q.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${ee?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...I("section",Q.id,{partId:O.id,partTitle:O.title,chapterId:he.id,chapterTitle:he.title}),children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx(_s,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&i.jsx("span",{title:"已置顶",children:i.jsx(Vo,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),v&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>v(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>s(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]},Q.id)})})]},he.id))})]},O.id)}if(Z)return i.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),i.jsx("div",{className:"space-y-3",children:O.chapters.map((U,he)=>U.sections.length>0?U.sections.map(Q=>{const ee=D("section",Q.id);return i.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+Q.id),de.dataTransfer.effectAllowed="move",k({type:"section",id:Q.id})},onDragEnd:()=>{k(null),C(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 group cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${ee?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...I("section",Q.id,{partId:O.id,partTitle:O.title,chapterId:U.id,chapterTitle:U.title}),children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx(_s,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",he+1," | ",U.title," | ",Q.title]}),j.includes(Q.id)&&i.jsx("span",{title:"已置顶",children:i.jsx(Vo,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),v&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>v(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),i.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>s(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx(Fo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},Q.id)}):i.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[i.jsxs("span",{className:"text-sm text-gray-500",children:["附录",he+1," | ",U.title,"(空)"]}),i.jsx(Fo,{className:"w-4 h-4 text-gray-500 shrink-0"})]},U.id))})]},O.id);if(q&&O.chapters.length===1&&O.chapters[0].sections.length===1){const U=O.chapters[0].sections[0],he=D("section",U.id),Q={partId:O.id,partTitle:O.title,chapterId:O.chapters[0].id,chapterTitle:O.chapters[0].title};return i.jsxs("div",{draggable:!0,onDragStart:ee=>{ee.stopPropagation(),ee.dataTransfer.setData("text/plain","section:"+U.id),ee.dataTransfer.effectAllowed="move",k({type:"section",id:U.id})},onDragEnd:()=>{k(null),C(null)},className:`rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between hover:border-[#38bdac]/30 transition-colors cursor-grab active:cursor-grabbing select-none min-h-[40px] ${he?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",U.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...I("section",U.id,Q),children:[i.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[i.jsx(_s,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:ee=>ee.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(U.id),onChange:()=>y(U.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:i.jsx(zr,{className:"w-4 h-4 text-gray-400"})}),i.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[O.chapters[0].title," | ",U.title]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>ee.stopPropagation(),children:[U.price===0||U.isFree?i.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):i.jsxs("span",{className:"text-xs text-gray-500",children:["¥",U.price]}),i.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",U.clickCount??0," · 付款 ",U.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(U.hotScore??0).toFixed(1)," · 第",U.hotRank&&U.hotRank>0?U.hotRank:"-","名"]}),v&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(U),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>s(U),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(U),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]})]},O.id)}return q?i.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),i.jsx("div",{className:"space-y-3",children:O.chapters.map(U=>U.sections.map(he=>{const Q=D("section",he.id);return i.jsxs("div",{draggable:!0,onDragStart:ee=>{ee.stopPropagation(),ee.dataTransfer.setData("text/plain","section:"+he.id),ee.dataTransfer.effectAllowed="move",k({type:"section",id:he.id})},onDragEnd:()=>{k(null),C(null)},className:`flex justify-between items-center py-2 select-none rounded px-2 -mx-2 cursor-grab active:cursor-grabbing min-h-[40px] transition-all duration-200 ${Q?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${M("section",he.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...I("section",he.id,{partId:O.id,partTitle:O.title,chapterId:U.id,chapterTitle:U.title}),children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx(_s,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:ee=>ee.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(he.id),onChange:()=>y(he.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsxs("span",{className:"text-sm text-gray-300",children:[U.title," | ",he.title]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",he.clickCount??0," · 付款 ",he.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(he.hotScore??0).toFixed(1)," · 第",he.hotRank&&he.hotRank>0?he.hotRank:"-","名"]}),v&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(he),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>s(he),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(he),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]})]},he.id)}))})]},O.id):i.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${_?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...I("part",O.id,{partId:O.id,partTitle:O.title,chapterId:((H=O.chapters[0])==null?void 0:H.id)??"",chapterTitle:((ue=O.chapters[0])==null?void 0:ue.title)??""}),children:[i.jsxs("div",{draggable:!0,onDragStart:U=>{U.stopPropagation(),U.dataTransfer.setData("text/plain","part:"+O.id),U.dataTransfer.effectAllowed="move",k({type:"part",id:O.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",O.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,onClick:()=>n(O.id),children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsx(_s,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),i.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac] flex items-center justify-center text-white font-bold shadow-lg shadow-[#38bdac]/30 shrink-0",children:A(W)}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-white text-base",children:O.title}),i.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",V," 节"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:U=>U.stopPropagation(),onClick:U=>U.stopPropagation(),children:[o&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:i.jsx(Lt,{className:"w-3.5 h-3.5"})}),h&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),f&&i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(O),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:i.jsx(vn,{className:"w-3.5 h-3.5"})}),i.jsxs("span",{className:"text-xs text-gray-500",children:[oe,"章"]}),$?i.jsx(jc,{className:"w-5 h-5 text-gray-500"}):i.jsx(Fo,{className:"w-5 h-5 text-gray-500"})]})]}),$&&i.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:O.chapters.map(U=>{const he=D("chapter",U.id);return i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 w-full",children:[i.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","chapter:"+U.id),Q.dataTransfer.effectAllowed="move",k({type:"chapter",id:U.id})},onDragEnd:()=>{k(null),C(null)},onDragEnter:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",C({type:"chapter",id:U.id})},onDragOver:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",C({type:"chapter",id:U.id})},onDragLeave:()=>C(null),onDrop:Q=>{C(null);const ee=ig(Q.dataTransfer.getData("text/plain"));if(!ee)return;const de={partId:O.id,partTitle:O.title,chapterId:U.id,chapterTitle:U.title};(ee.type==="section"||ee.type==="chapter")&&R(Q,"chapter",U.id,de)},className:`flex-1 min-w-0 py-2 px-2 rounded cursor-grab active:cursor-grabbing select-none -mx-2 transition-all duration-200 flex items-center gap-2 ${he?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${M("chapter",U.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[i.jsx(_s,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),i.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:U.title})]}),i.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>m(O,U),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),c&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>c(O),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:i.jsx(Lt,{className:"w-3.5 h-3.5"})}),u&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>u(O,U),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx("div",{className:"space-y-1 pl-2",children:U.sections.map(Q=>{const ee=D("section",Q.id);return i.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+Q.id),de.dataTransfer.effectAllowed="move",k({type:"section",id:Q.id})},onDragEnd:()=>{k(null),C(null)},className:`flex items-center justify-between py-2 px-3 rounded-lg group cursor-grab active:cursor-grabbing select-none min-h-[40px] transition-all duration-200 ${ee?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",Q.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...I("section",Q.id,{partId:O.id,partTitle:O.title,chapterId:U.id,chapterTitle:U.title}),children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&i.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:i.jsx("input",{type:"checkbox",checked:g.includes(Q.id),onChange:()=>y(Q.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),i.jsx(_s,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),i.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${Q.price===0||Q.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),i.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&i.jsx("span",{title:"已置顶",children:i.jsx(Vo,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[Q.isNew&&i.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),Q.price===0||Q.isFree?i.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):i.jsxs("span",{className:"text-xs text-gray-500",children:["¥",Q.price]}),i.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),i.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),v&&i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>v(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),i.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>s(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:i.jsx(bt,{className:"w-3.5 h-3.5"})}),i.jsx(re,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:i.jsx(vn,{className:"w-3.5 h-3.5"})})]})]})]},Q.id)})})]},U.id)})})]},O.id)})})}function BB(t){const e=new Map;for(const c of t){const u=c.partId||"part-1",h=c.partTitle||"未分类",f=c.chapterId||"chapter-1",m=c.chapterTitle||"未分类";e.has(u)||e.set(u,{id:u,title:h,chapters:new Map});const g=e.get(u);g.chapters.has(f)||g.chapters.set(f,{id:f,title:m,sections:[]}),g.chapters.get(f).sections.push({id:c.id,title:c.title,price:c.price??1,filePath:c.filePath,isFree:c.isFree,isNew:c.isNew,clickCount:c.clickCount??0,payCount:c.payCount??0,hotScore:c.hotScore??0,hotRank:c.hotRank??0})}const n="part-2026-daily",r="2026每日派对干货";Array.from(e.values()).some(c=>c.title===r||c.title.includes(r))||e.set(n,{id:n,title:r,chapters:new Map([["chapter-2026-daily",{id:"chapter-2026-daily",title:r,sections:[]}]])});const a=Array.from(e.values()).map(c=>({...c,chapters:Array.from(c.chapters.values())})),o=c=>c.includes("序言")?0:c.includes(r)?1.5:c.includes("附录")?2:c.includes("尾声")?3:1;return a.sort((c,u)=>{const h=o(c.title),f=o(u.title);return h!==f?h-f:0})}function VB(){var gr,nd,rr;const[t,e]=b.useState([]),[n,r]=b.useState(!0),[s,a]=b.useState([]),[o,c]=b.useState(null),[u,h]=b.useState(!1),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[v,j]=b.useState(""),[w,k]=b.useState([]),[E,C]=b.useState(!1),[M,D]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:""}),[F,R]=b.useState(null),[I,A]=b.useState(!1),[O,W]=b.useState(!1),[X,q]=b.useState(null),[Z,_]=b.useState(!1),[$,oe]=b.useState([]),[V,ae]=b.useState(!1),[Y,L]=b.useState(""),[H,ue]=b.useState(""),[U,he]=b.useState(!1),[Q,ee]=b.useState(""),[de,Ce]=b.useState(!1),[B,me]=b.useState(null),[Se,rt]=b.useState(!1),[Ye,st]=b.useState(!1),[Qe,Xe]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[ft,Pt]=b.useState(!1),[Jt,Kn]=b.useState(!1),[qn,ss]=b.useState(1),[zt,Cr]=b.useState([]),[is,On]=b.useState(!1),[pn,mr]=b.useState(20),[Br,Gn]=b.useState(!1),[fe,ge]=b.useState(!1),[Sn,ri]=b.useState([]),[Es,ua]=b.useState([]),[Jn,as]=b.useState({personId:"",name:"",label:""}),[jt,Cn]=b.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),Yn=b.useRef(null),Dn=BB(t),ha=t.length,si=[...t].sort((P,ie)=>(ie.hotScore??0)-(P.hotScore??0)),Er=10,ii=Math.max(1,Math.ceil(si.length/Er)),ai=si.slice((qn-1)*Er,qn*Er),mn=async()=>{r(!0);try{const P=await Be("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(P==null?void 0:P.sections)?P.sections:[])}catch(P){console.error(P),e([])}finally{r(!1)}};b.useEffect(()=>{mn()},[]);const ls=P=>{a(ie=>ie.includes(P)?ie.filter(Ae=>Ae!==P):[...ie,P])},oi=b.useCallback(P=>{const ie=t,Ae=P.flatMap(Re=>{const Ot=ie.find(Vt=>Vt.id===Re.id);return Ot?[{...Ot,partId:Re.partId,partTitle:Re.partTitle,chapterId:Re.chapterId,chapterTitle:Re.chapterTitle}]:[]});return e(Ae),Rt("/api/db/book",{action:"reorder",items:P}).then(Re=>{Re&&Re.success===!1&&(e(ie),alert("排序失败: "+(Re&&typeof Re=="object"&&"error"in Re?Re.error:"未知错误")))}).catch(Re=>{e(ie),console.error("排序失败:",Re),alert("排序失败: "+(Re instanceof Error?Re.message:"网络或服务异常"))}),Promise.resolve()},[t]),cs=async P=>{if(confirm(`确定要删除章节「${P.title}」吗?此操作不可恢复。`))try{const ie=await Yr(`/api/db/book?id=${encodeURIComponent(P.id)}`);ie&&ie.success!==!1?(alert("已删除"),mn()):alert("删除失败: "+(ie&&typeof ie=="object"&&"error"in ie?ie.error:"未知错误"))}catch(ie){console.error(ie),alert("删除失败")}},fa=b.useCallback(async()=>{Pt(!0);try{const P=await Be("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),ie=P&&P.data;ie&&typeof ie.readWeight=="number"&&typeof ie.recencyWeight=="number"&&typeof ie.payWeight=="number"&&Xe({readWeight:Math.max(0,Math.min(1,ie.readWeight)),recencyWeight:Math.max(0,Math.min(1,ie.recencyWeight)),payWeight:Math.max(0,Math.min(1,ie.payWeight))})}catch{}finally{Pt(!1)}},[]);b.useEffect(()=>{Ye&&fa()},[Ye,fa]);const ds=async()=>{const{readWeight:P,recencyWeight:ie,payWeight:Ae}=Qe,Re=P+ie+Ae;if(Math.abs(Re-1)>.001){alert("三个权重之和必须等于 1");return}Kn(!0);try{const Ot=await ht("/api/db/config",{key:"article_ranking_weights",value:{readWeight:P,recencyWeight:ie,payWeight:Ae},description:"文章排名算法权重"});Ot&&Ot.success!==!1?(alert("已保存"),mn()):alert("保存失败: "+(Ot&&typeof Ot=="object"&&"error"in Ot?Ot.error:""))}catch(Ot){console.error(Ot),alert("保存失败")}finally{Kn(!1)}},G=b.useCallback(async()=>{On(!0);try{const P=await Be("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),ie=P&&P.data;Array.isArray(ie)&&Cr(ie)}catch{}finally{On(!1)}},[]),Ke=b.useCallback(async()=>{try{const P=await Be("/api/db/persons");P!=null&&P.success&&P.persons&&ri(P.persons.map(ie=>({id:ie.personId,name:ie.name,label:ie.label})))}catch{}},[]),Ze=b.useCallback(async()=>{try{const P=await Be("/api/db/link-tags");P!=null&&P.success&&P.linkTags&&ua(P.linkTags.map(ie=>({id:ie.tagId,label:ie.label,url:ie.url,type:ie.type,appId:ie.appId,pagePath:ie.pagePath})))}catch{}},[]),En=async P=>{const ie=zt.includes(P)?zt.filter(Ae=>Ae!==P):[...zt,P];Cr(ie);try{await ht("/api/db/config",{key:"pinned_section_ids",value:ie,description:"强制置顶章节ID列表精选推荐/首页最新更新)"})}catch{Cr(zt)}},Vr=b.useCallback(async()=>{Gn(!0);try{const P=await Be("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),ie=P&&P.data;typeof ie=="number"&&ie>0&&ie<=100&&mr(ie)}catch{}finally{Gn(!1)}},[]),Nf=async()=>{if(pn<1||pn>100){alert("预览比例需在 1~100 之间");return}ge(!0);try{const P=await ht("/api/db/config",{key:"unpaid_preview_percent",value:pn,description:"小程序未付费内容默认预览比例(%)"});P&&P.success!==!1?alert("已保存"):alert("保存失败: "+(P.error||""))}catch{alert("保存失败")}finally{ge(!1)}};b.useEffect(()=>{G(),Vr(),Ke(),Ze()},[G,Vr,Ke,Ze]);const us=async P=>{me({section:P,orders:[]}),rt(!0);try{const ie=await Be(`/api/db/book?action=section-orders&id=${encodeURIComponent(P.id)}`),Ae=ie!=null&&ie.success&&Array.isArray(ie.orders)?ie.orders:[];me(Re=>Re?{...Re,orders:Ae}:null)}catch(ie){console.error(ie),me(Ae=>Ae?{...Ae,orders:[]}:null)}finally{rt(!1)}},no=async P=>{m(!0);try{const ie=await Be(`/api/db/book?action=read&id=${encodeURIComponent(P.id)}`);if(ie!=null&&ie.success&&ie.section){const Ae=ie.section;c({id:P.id,originalId:P.id,title:ie.section.title??P.title,price:ie.section.price??P.price,content:ie.section.content??"",filePath:P.filePath,isFree:P.isFree||P.price===0,isNew:Ae.isNew??P.isNew,isPinned:zt.includes(P.id),hotScore:P.hotScore??0})}else c({id:P.id,originalId:P.id,title:P.title,price:P.price,content:"",filePath:P.filePath,isFree:P.isFree,isNew:P.isNew,isPinned:zt.includes(P.id),hotScore:P.hotScore??0}),ie&&!ie.success&&alert("无法读取文件内容: "+(ie.error||"未知错误"))}catch(ie){console.error(ie),c({id:P.id,title:P.title,price:P.price,content:"",filePath:P.filePath,isFree:P.isFree})}finally{m(!1)}},Jc=async()=>{var P;if(o){y(!0);try{let ie=o.content||"";const Ae=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[:].*$`,"gm"),new RegExp(`^#\\s+.*${(P=o.title)==null?void 0:P.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const hs of Ae)ie=ie.replace(hs,"");ie=ie.replace(/^\s*\n+/,"").trim();const Re=o.originalId||o.id,Ot=o.id!==Re,Vt=await Rt("/api/db/book",{id:Re,...Ot?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:ie,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,saveToFile:!0}),Ln=Ot?o.id:Re;o.isPinned!==zt.includes(Ln)&&await En(Ln),Vt&&Vt.success!==!1?(alert(`已保存章节: ${o.title}`),c(null),mn()):alert("保存失败: "+(Vt&&typeof Vt=="object"&&"error"in Vt?Vt.error:"未知错误"))}catch(ie){console.error(ie),alert("保存失败")}finally{y(!1)}}},jf=async()=>{if(!M.id||!M.title){alert("请填写章节ID和标题");return}y(!0);try{const P=await Rt("/api/db/book",{id:M.id,title:M.title,price:M.price,content:M.content,partId:M.partId,chapterId:M.chapterId,saveToFile:!1});P&&P.success!==!1?(alert(`章节创建成功: ${M.title}`),h(!1),D({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:""}),mn()):alert("创建失败: "+(P&&typeof P=="object"&&"error"in P?P.error:"未知错误"))}catch(P){console.error(P),alert("创建失败")}finally{y(!1)}},Yc=P=>{D(ie=>{var Ae;return{...ie,partId:P.id,chapterId:((Ae=P.chapters[0])==null?void 0:Ae.id)??"chapter-1"}}),h(!0)},Qc=P=>{R({id:P.id,title:P.title})},Xc=async()=>{var P;if((P=F==null?void 0:F.title)!=null&&P.trim()){A(!0);try{const ie=t.map(Re=>({id:Re.id,partId:Re.partId||"part-1",partTitle:Re.partId===F.id?F.title.trim():Re.partTitle||"",chapterId:Re.chapterId||"chapter-1",chapterTitle:Re.chapterTitle||""})),Ae=await Rt("/api/db/book",{action:"reorder",items:ie});Ae&&Ae.success!==!1?(R(null),mn()):alert("更新篇名失败: "+(Ae&&typeof Ae=="object"&&"error"in Ae?Ae.error:"未知错误"))}catch(ie){console.error(ie),alert("更新篇名失败")}finally{A(!1)}}},Zc=P=>{const ie=P.chapters.length+1,Ae=`chapter-${P.id}-${ie}-${Date.now()}`;D({id:`${ie}.1`,title:"新章节",price:1,partId:P.id,chapterId:Ae,content:""}),h(!0)},kf=(P,ie)=>{q({part:P,chapter:ie,title:ie.title})},Sf=async()=>{var P;if((P=X==null?void 0:X.title)!=null&&P.trim()){_(!0);try{const ie=t.map(Re=>({id:Re.id,partId:Re.partId||X.part.id,partTitle:Re.partId===X.part.id?X.part.title:Re.partTitle||"",chapterId:Re.chapterId||X.chapter.id,chapterTitle:Re.partId===X.part.id&&Re.chapterId===X.chapter.id?X.title.trim():Re.chapterTitle||""})),Ae=await Rt("/api/db/book",{action:"reorder",items:ie});Ae&&Ae.success!==!1?(q(null),mn()):alert("保存失败: "+(Ae&&typeof Ae=="object"&&"error"in Ae?Ae.error:"未知错误"))}catch(ie){console.error(ie),alert("保存失败")}finally{_(!1)}}},$t=async(P,ie)=>{const Ae=ie.sections.map(Re=>Re.id);if(Ae.length===0){alert("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${P.chapters.indexOf(ie)+1}章 | ${ie.title}」吗?将删除共 ${Ae.length} 节,此操作不可恢复。`))try{for(const Re of Ae)await Yr(`/api/db/book?id=${encodeURIComponent(Re)}`);mn()}catch(Re){console.error(Re),alert("删除失败")}},Cf=async()=>{if(!Q.trim()){alert("请输入篇名");return}Ce(!0);try{const P=`part-new-${Date.now()}`,ie="chapter-1",Ae=`part-placeholder-${Date.now()}`,Re=await Rt("/api/db/book",{id:Ae,title:"占位节(可编辑)",price:0,content:"",partId:P,partTitle:Q.trim(),chapterId:ie,chapterTitle:"第1章 | 待编辑",saveToFile:!1});Re&&Re.success!==!1?(alert(`篇「${Q}」创建成功,请编辑占位节`),W(!1),ee(""),mn()):alert("创建失败: "+(Re&&typeof Re=="object"&&"error"in Re?Re.error:"未知错误"))}catch(P){console.error(P),alert("创建失败")}finally{Ce(!1)}},gl=async()=>{if($.length===0){alert("请先勾选要移动的章节");return}const P=Dn.find(Ae=>Ae.id===Y),ie=P==null?void 0:P.chapters.find(Ae=>Ae.id===H);if(!P||!ie||!Y||!H){alert("请选择目标篇和章");return}he(!0);try{const Ae=()=>{const Ln=new Set($),hs=t.map(sn=>({id:sn.id,partId:sn.partId||"",partTitle:sn.partTitle||"",chapterId:sn.chapterId||"",chapterTitle:sn.chapterTitle||""})),Ef=hs.filter(sn=>Ln.has(sn.id)).map(sn=>({...sn,partId:Y,partTitle:P.title||Y,chapterId:H,chapterTitle:ie.title||H})),Ts=hs.filter(sn=>!Ln.has(sn.id));let io=Ts.length;for(let sn=Ts.length-1;sn>=0;sn-=1){const li=Ts[sn];if(li.partId===Y&&li.chapterId===H){io=sn+1;break}}return[...Ts.slice(0,io),...Ef,...Ts.slice(io)]},Re=async()=>{const Ln=Ae(),hs=await Rt("/api/db/book",{action:"reorder",items:Ln});return hs&&hs.success!==!1?(alert(`已移动 ${$.length} 节到「${P.title}」-「${ie.title}」`),ae(!1),oe([]),await mn(),!0):!1},Ot={action:"move-sections",sectionIds:$,targetPartId:Y,targetChapterId:H,targetPartTitle:P.title||Y,targetChapterTitle:ie.title||H},Vt=await Rt("/api/db/book",Ot);if(Vt&&Vt.success!==!1)alert(`已移动 ${Vt.count??$.length} 节到「${P.title}」-「${ie.title}」`),ae(!1),oe([]),await mn();else{const Ln=Vt&&typeof Vt=="object"&&"error"in Vt?Vt.error||"":"未知错误";if((Ln.includes("缺少 id")||Ln.includes("无效的 action"))&&await Re())return;alert("移动失败: "+Ln)}}catch(Ae){console.error(Ae),alert("移动失败: "+(Ae instanceof Error?Ae.message:"网络或服务异常"))}finally{he(!1)}},ed=P=>{oe(ie=>ie.includes(P)?ie.filter(Ae=>Ae!==P):[...ie,P])},ro=async P=>{const ie=t.filter(Ae=>Ae.partId===P.id).map(Ae=>Ae.id);if(ie.length===0){alert("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${P.title}」整篇吗?将删除共 ${ie.length} 节内容,此操作不可恢复。`))try{for(const Ae of ie)await Yr(`/api/db/book?id=${encodeURIComponent(Ae)}`);mn()}catch(Ae){console.error(Ae),alert("删除失败")}},td=async()=>{var P;if(v.trim()){C(!0);try{const ie=await Be(`/api/search?q=${encodeURIComponent(v)}`);ie!=null&&ie.success&&((P=ie.data)!=null&&P.results)?k(ie.data.results):(k([]),ie&&!ie.success&&alert("搜索失败: "+ie.error))}catch(ie){console.error(ie),k([]),alert("搜索失败")}finally{C(!1)}}},so=Dn.find(P=>P.id===M.partId),pa=(so==null?void 0:so.chapters)??[];return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),i.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",Dn.length," 篇 · ",ha," 节内容"]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs(re,{onClick:()=>st(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[i.jsx(fm,{className:"w-4 h-4 mr-2"}),"排名算法"]}),i.jsxs(re,{onClick:()=>{const P=typeof window<"u"?`${window.location.origin}/api-doc`:"";P&&window.open(P,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(Gs,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),i.jsx(Qt,{open:u,onOpenChange:h,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[90vh] overflow-y-auto",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(Lt,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"章节ID *"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:M.id,onChange:P=>D({...M,id:P.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:M.price,onChange:P=>D({...M,price:Number(P.target.value)})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"章节标题 *"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:M.title,onChange:P=>D({...M,title:P.target.value})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"所属篇"}),i.jsxs(ec,{value:M.partId,onValueChange:P=>D({...M,partId:P,chapterId:"chapter-1"}),children:[i.jsx(zo,{className:"bg-[#0a1628] border-gray-700 text-white",children:i.jsx(tc,{})}),i.jsxs($o,{className:"bg-[#0f2137] border-gray-700",children:[Dn.map(P=>i.jsx(Ws,{value:P.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:P.title},P.id)),Dn.length===0&&i.jsx(Ws,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"所属章"}),i.jsxs(ec,{value:M.chapterId,onValueChange:P=>D({...M,chapterId:P}),children:[i.jsx(zo,{className:"bg-[#0a1628] border-gray-700 text-white",children:i.jsx(tc,{})}),i.jsxs($o,{className:"bg-[#0f2137] border-gray-700",children:[pa.map(P=>i.jsx(Ws,{value:P.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:P.title},P.id)),pa.length===0&&i.jsx(Ws,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"内容 (Markdown格式)"}),i.jsx(dl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[300px] font-mono text-sm placeholder:text-gray-500",placeholder:"输入章节内容...",value:M.content,onChange:P=>D({...M,content:P.target.value})})]})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsx(re,{onClick:jf,disabled:g||!M.id||!M.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),i.jsx(Qt,{open:!!F,onOpenChange:P=>!P&&R(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),F&&i.jsx("div",{className:"space-y-4 py-4",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"篇名"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:F.title,onChange:P=>R({...F,title:P.target.value}),placeholder:"输入篇名"})]})}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>R(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsx(re,{onClick:Xc,disabled:I||!((gr=F==null?void 0:F.title)!=null&&gr.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:I?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),i.jsx(Qt,{open:!!X,onOpenChange:P=>!P&&q(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节名称"]})}),X&&i.jsx("div",{className:"space-y-4 py-4",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"章节名称第8章底层结构"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:X.title,onChange:P=>q({...X,title:P.target.value}),placeholder:"输入章节名称"})]})}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>q(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsx(re,{onClick:Sf,disabled:Z||!((nd=X==null?void 0:X.title)!=null&&nd.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:Z?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),i.jsx(Qt,{open:V,onOpenChange:P=>{var ie;if(ae(P),P&&Dn.length>0){const Ae=Dn[0];L(Ae.id),ue(((ie=Ae.chapters[0])==null?void 0:ie.id)??"")}},children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:"批量移动至指定目录"})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",i.jsx("span",{className:"text-[#38bdac] font-medium",children:$.length})," 节,请选择目标篇与章。"]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"目标篇"}),i.jsxs(ec,{value:Y,onValueChange:P=>{var Ae;L(P);const ie=Dn.find(Re=>Re.id===P);ue(((Ae=ie==null?void 0:ie.chapters[0])==null?void 0:Ae.id)??"")},children:[i.jsx(zo,{className:"bg-[#0a1628] border-gray-700 text-white",children:i.jsx(tc,{placeholder:"选择篇"})}),i.jsx($o,{className:"bg-[#0f2137] border-gray-700",children:Dn.map(P=>i.jsx(Ws,{value:P.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:P.title},P.id))})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"目标章"}),i.jsxs(ec,{value:H,onValueChange:ue,children:[i.jsx(zo,{className:"bg-[#0a1628] border-gray-700 text-white",children:i.jsx(tc,{placeholder:"选择章"})}),i.jsx($o,{className:"bg-[#0f2137] border-gray-700",children:(((rr=Dn.find(P=>P.id===Y))==null?void 0:rr.chapters)??[]).map(P=>i.jsx(Ws,{value:P.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:P.title},P.id))})]})]})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>ae(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsx(re,{onClick:gl,disabled:U||$.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:U?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),i.jsx(Qt,{open:!!B,onOpenChange:P=>!P&&me(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white",children:["付款记录 — ",(B==null?void 0:B.section.title)??""]})}),i.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Se?i.jsxs("div",{className:"flex items-center justify-center py-8",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):B&&B.orders.length===0?i.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):B?i.jsxs("table",{className:"w-full text-sm border-collapse",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[i.jsx("th",{className:"py-2 pr-2",children:"订单号"}),i.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),i.jsx("th",{className:"py-2 pr-2",children:"金额"}),i.jsx("th",{className:"py-2 pr-2",children:"状态"}),i.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),i.jsx("tbody",{children:B.orders.map(P=>i.jsxs("tr",{className:"border-b border-gray-700/50",children:[i.jsx("td",{className:"py-2 pr-2",children:i.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${P.orderSn}`,onClick:()=>window.open(`/orders?search=${P.orderSn??P.id??""}`,"_blank"),children:P.orderSn?P.orderSn.length>16?P.orderSn.slice(0,8)+"..."+P.orderSn.slice(-6):P.orderSn:"-"})}),i.jsx("td",{className:"py-2 pr-2",children:i.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${P.userId??P.openId??""}`,onClick:()=>window.open(`/users?search=${P.userId??P.openId??""}`,"_blank"),children:(()=>{const ie=P.userId??P.openId??"-";return ie.length>12?ie.slice(0,6)+"..."+ie.slice(-4):ie})()})}),i.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",P.amount??0]}),i.jsx("td",{className:"py-2 pr-2 text-gray-300",children:P.status??"-"}),i.jsx("td",{className:"py-2 pr-2 text-gray-500",children:P.payTime??P.createdAt??"-"})]},P.id??P.orderSn??""))})]}):null})]})}),i.jsx(Qt,{open:Ye,onOpenChange:st,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(fm,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),i.jsxs("div",{className:"space-y-4 py-2",children:[i.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1"}),ft?i.jsx("p",{className:"text-gray-500",children:"加载中..."}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"阅读权重"}),i.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Qe.readWeight,onChange:P=>Xe(ie=>({...ie,readWeight:Math.max(0,Math.min(1,parseFloat(P.target.value)||0))}))})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"新度权重"}),i.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Qe.recencyWeight,onChange:P=>Xe(ie=>({...ie,recencyWeight:Math.max(0,Math.min(1,parseFloat(P.target.value)||0))}))})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"付款权重"}),i.jsx(ce,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Qe.payWeight,onChange:P=>Xe(ie=>({...ie,payWeight:Math.max(0,Math.min(1,parseFloat(P.target.value)||0))}))})]})]}),i.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Qe.readWeight+Qe.recencyWeight+Qe.payWeight).toFixed(1)]}),i.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[i.jsx("li",{children:"阅读量前 20 名第1名=20分、第2名=19分...第20名=1分"}),i.jsx("li",{children:"最近更新前 30 篇第1名=30分、第2名=29分...第30名=1分"}),i.jsx("li",{children:"付款数前 20 名第1名=20分、第2名=19分...第20名=1分"}),i.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),i.jsx(re,{onClick:ds,disabled:Jt||Math.abs(Qe.readWeight+Qe.recencyWeight+Qe.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Jt?"保存中...":"保存权重"})]})]})]})}),i.jsx(Qt,{open:O,onOpenChange:W,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(Lt,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),i.jsx("div",{className:"space-y-4 py-4",children:i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:Q,onChange:P=>ee(P.target.value),placeholder:"输入篇名"})]})}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>{W(!1),ee("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsx(re,{onClick:Cf,disabled:de||!Q.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:de?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),i.jsx(Qt,{open:!!o,onOpenChange:()=>c(null),children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[i.jsx(Xt,{className:"shrink-0 px-6 pt-6 pb-2",children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&i.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"章节ID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:P=>c({...o,id:P.target.value}),placeholder:"如: 9.15"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"价格 (元)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:P=>c({...o,price:Number(P.target.value),isFree:Number(P.target.value)===0}),disabled:o.isFree})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"免费"}),i.jsx("div",{className:"flex items-center h-10",children:i.jsxs("label",{className:"flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:P=>c({...o,isFree:P.target.checked,price:P.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),i.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"最新新增"}),i.jsx("div",{className:"flex items-center h-10",children:i.jsxs("label",{className:"flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:P=>c({...o,isNew:P.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),i.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"小程序直推"}),i.jsx("div",{className:"flex items-center h-10",children:i.jsxs("label",{className:"flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:P=>c({...o,isPinned:P.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),i.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"热度分"}),i.jsx(ce,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:P=>c({...o,hotScore:Math.max(0,parseFloat(P.target.value)||0)})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"章节标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:P=>c({...o,title:P.target.value})})]}),o.filePath&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"文件路径"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @提及主人公 和 #链接标签)"}),f?i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsx(j2,{ref:Yn,content:o.content||"",onChange:P=>c({...o,content:P}),onImageUpload:async P=>{var Ot;const ie=new FormData;ie.append("file",P),ie.append("folder","book-images");const Re=await(await fetch(Yo("/api/upload"),{method:"POST",body:ie,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((Ot=Re==null?void 0:Re.data)==null?void 0:Ot.url)||(Re==null?void 0:Re.url)||""},persons:Sn,linkTags:Es,placeholder:"开始编辑内容... 输入 @ 可提及主人公,工具栏可插入 #链接标签"})]})]}),i.jsxs(bn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&i.jsxs(re,{variant:"outline",onClick:()=>us({id:o.id,title:o.title,price:o.price}),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent mr-auto",children:[i.jsx(zr,{className:"w-4 h-4 mr-2"}),"付款记录"]}),i.jsxs(re,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsx(re,{onClick:Jc,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?i.jsxs(i.Fragment,{children:[i.jsx(qe,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):i.jsxs(i.Fragment,{children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),i.jsxs(Hc,{defaultValue:"chapters",className:"space-y-6",children:[i.jsxs(cl,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[i.jsxs(en,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[i.jsx(zr,{className:"w-4 h-4 mr-2"}),"章节管理"]}),i.jsxs(en,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[i.jsx(Ab,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),i.jsxs(en,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[i.jsx(Ui,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),i.jsxs(en,{value:"protagonists",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[i.jsx(Nn,{className:"w-4 h-4 mr-2"}),"主人公"]})]}),i.jsxs(tn,{value:"chapters",className:"space-y-4",children:[i.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac] flex items-center justify-center text-white shadow-lg shadow-[#38bdac]/20 shrink-0",children:i.jsx(zr,{className:"w-6 h-6"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),i.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),i.jsxs("div",{className:"text-center shrink-0",children:[i.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:ha}),i.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(re,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"新建章节"]}),i.jsxs(re,{onClick:()=>W(!0),className:"flex-1 min-w-[120px] bg-amber-500/10 hover:bg-amber-500/20 text-amber-400 border border-amber-500/30",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"新建篇"]}),i.jsxs(re,{variant:"outline",onClick:()=>ae(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",$.length," 节)"]})]}),n?i.jsxs("div",{className:"flex items-center justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsx(FB,{parts:Dn,expandedParts:s,onTogglePart:ls,onReorder:oi,onReadSection:no,onDeleteSection:cs,onAddSectionInPart:Yc,onAddChapterInPart:Zc,onDeleteChapter:$t,onEditPart:Qc,onDeletePart:ro,onEditChapter:kf,selectedSectionIds:$,onToggleSectionSelect:ed,onShowSectionOrders:us,pinnedSectionIds:zt})]}),i.jsx(tn,{value:"search",className:"space-y-4",children:i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"内容搜索"})}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:v,onChange:P=>j(P.target.value),onKeyDown:P=>P.key==="Enter"&&td()}),i.jsx(re,{onClick:td,disabled:E||!v.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:E?i.jsx(qe,{className:"w-4 h-4 animate-spin"}):i.jsx(Ui,{className:"w-4 h-4"})})]}),w.length>0&&i.jsxs("div",{className:"space-y-2 mt-4",children:[i.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",w.length," 个结果"]}),w.map(P=>i.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>no({id:P.id,title:P.title,price:P.price??1,filePath:""}),children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:P.id}),i.jsx("span",{className:"text-white",children:P.title}),zt.includes(P.id)&&i.jsx(Vo,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),i.jsx(Fe,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:P.matchType==="title"?"标题匹配":"内容匹配"})]}),P.snippet&&i.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:P.snippet}),(P.partTitle||P.chapterTitle)&&i.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[P.partTitle," · ",P.chapterTitle]})]},P.id))]})]})]})}),i.jsxs(tn,{value:"ranking",className:"space-y-4",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{className:"pb-3",children:i.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[i.jsx(fm,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),i.jsx(Te,{children:i.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(te,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),i.jsx(ce,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:pn,onChange:P=>mr(Math.max(1,Math.min(100,Number(P.target.value)||20))),disabled:Br}),i.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),i.jsx(re,{size:"sm",onClick:Nf,disabled:fe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:fe?"保存中...":"保存"}),i.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",pn,"% 内容"]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{className:"pb-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[i.jsx(Ab,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",i.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",si.length," 节"]})]}),i.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[i.jsx(re,{variant:"ghost",size:"sm",disabled:qn<=1,onClick:()=>ss(P=>Math.max(1,P-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:i.jsx(OT,{className:"w-4 h-4"})}),i.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[qn," / ",ii]}),i.jsx(re,{variant:"ghost",size:"sm",disabled:qn>=ii,onClick:()=>ss(P=>Math.min(ii,P+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:i.jsx(Fo,{className:"w-4 h-4"})})]})]})}),i.jsx(Te,{children:i.jsxs("div",{className:"space-y-0",children:[i.jsxs("div",{className:"grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2 text-xs text-gray-500 border-b border-gray-700/50",children:[i.jsx("span",{children:"排名"}),i.jsx("span",{children:"置顶"}),i.jsx("span",{children:"标题"}),i.jsx("span",{className:"text-right",children:"点击量"}),i.jsx("span",{className:"text-right",children:"付款数"}),i.jsx("span",{className:"text-right",children:"热度"}),i.jsx("span",{className:"text-right",children:"编辑"})]}),ai.map((P,ie)=>{const Ae=(qn-1)*Er+ie+1,Re=zt.includes(P.id);return i.jsxs("div",{className:`grid grid-cols-[40px_40px_1fr_80px_80px_80px_60px] gap-2 px-3 py-2.5 items-center border-b border-gray-700/30 hover:bg-[#162840] transition-colors ${Re?"bg-amber-500/5":""}`,children:[i.jsx("span",{className:`text-sm font-bold ${Ae<=3?"text-amber-400":"text-gray-500"}`,children:Ae<=3?["🥇","🥈","🥉"][Ae-1]:`#${Ae}`}),i.jsx(re,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${Re?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>En(P.id),disabled:is,title:Re?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:Re?i.jsx(Vo,{className:"w-3.5 h-3.5 fill-current"}):i.jsx(sA,{className:"w-3.5 h-3.5"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{className:"text-white text-sm truncate block",children:P.title}),i.jsxs("span",{className:"text-gray-600 text-xs",children:[P.partTitle," · ",P.chapterTitle]})]}),i.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:P.clickCount??0}),i.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:P.payCount??0}),i.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(P.hotScore??0).toFixed(1)}),i.jsx("div",{className:"text-right",children:i.jsx(re,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>no({id:P.id,title:P.title,price:P.price,filePath:""}),title:"编辑文章",children:i.jsx(bt,{className:"w-3 h-3"})})})]},P.id)}),ai.length===0&&i.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),i.jsxs(tn,{value:"protagonists",className:"space-y-4",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{className:"pb-3",children:i.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[i.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"主人公列表(编辑器内输入 @ 可提及)"]})}),i.jsxs(Te,{className:"space-y-3",children:[i.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"人物ID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 karuo",value:Jn.personId,onChange:P=>as({...Jn,personId:P.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"名称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 卡若",value:Jn.name,onChange:P=>as({...Jn,name:P.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"如 超级个体",value:Jn.label,onChange:P=>as({...Jn,label:P.target.value})})]}),i.jsxs(re,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8",onClick:async()=>{if(!Jn.personId||!Jn.name)return alert("人物ID和名称必填");await ht("/api/db/persons",Jn),as({personId:"",name:"",label:""}),Ke()},children:[i.jsx(Lt,{className:"w-3 h-3 mr-1"}),"添加"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Sn.map(P=>i.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[i.jsxs("span",{className:"text-[#38bdac] font-bold text-base",children:["@",P.name]}),i.jsxs("span",{className:"text-gray-500 text-xs",children:["ID: ",P.id]}),P.label&&i.jsx(Fe,{variant:"secondary",className:"bg-purple-500/20 text-purple-300 border-purple-500/30 text-[10px]",children:P.label})]}),i.jsx(re,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Yr(`/api/db/persons?personId=${P.id}`),Ke()},children:i.jsx(er,{className:"w-3 h-3"})})]},P.id)),Sn.length===0&&i.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无主人公,添加后可在编辑器中 @提及"})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsx(et,{className:"pb-3",children:i.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[i.jsx(mM,{className:"w-4 h-4 text-amber-400"}),"链接标签(编辑器内 #标签 可跳转链接/小程序)"]})}),i.jsxs(Te,{className:"space-y-3",children:[i.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"标签ID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",placeholder:"如 team01",value:jt.tagId,onChange:P=>Cn({...jt,tagId:P.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"显示文字"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 神仙团队",value:jt.label,onChange:P=>Cn({...jt,label:P.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"类型"}),i.jsxs(ec,{value:jt.type,onValueChange:P=>Cn({...jt,type:P}),children:[i.jsx(zo,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",children:i.jsx(tc,{})}),i.jsxs($o,{children:[i.jsx(Ws,{value:"url",children:"网页链接"}),i.jsx(Ws,{value:"miniprogram",children:"小程序"})]})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:jt.type==="url"?"URL地址":"小程序AppID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-40",placeholder:jt.type==="url"?"https://...":"wx...",value:jt.type==="url"?jt.url:jt.appId,onChange:P=>{jt.type==="url"?Cn({...jt,url:P.target.value}):Cn({...jt,appId:P.target.value})}})]}),jt.type==="miniprogram"&&i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-400 text-xs",children:"页面路径"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"pages/index/index",value:jt.pagePath,onChange:P=>Cn({...jt,pagePath:P.target.value})})]}),i.jsxs(re,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:async()=>{if(!jt.tagId||!jt.label)return alert("标签ID和显示文字必填");const P={...jt};P.type==="miniprogram"&&P.appId&&(P.url=`weixin://dl/business/?appid=${P.appId}&path=${P.pagePath}`),await ht("/api/db/link-tags",P),Cn({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),Ze()},children:[i.jsx(Lt,{className:"w-3 h-3 mr-1"}),"添加"]})]}),i.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Es.map(P=>i.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[i.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[i.jsxs("span",{className:"text-amber-400 font-bold text-base",children:["#",P.label]}),i.jsx(Fe,{variant:"secondary",className:"bg-gray-700 text-gray-300 text-[10px]",children:P.type==="url"?"网页":"小程序"}),i.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[250px] hover:underline flex items-center gap-1",children:[P.url," ",i.jsx(Xs,{className:"w-3 h-3 shrink-0"})]})]}),i.jsx(re,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Yr(`/api/db/link-tags?tagId=${P.id}`),Ze()},children:i.jsx(er,{className:"w-3 h-3"})})]},P.id)),Es.length===0&&i.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})]})]})]})]})]})]})}const Ks={name:"卡若",avatar:"K",avatarImg:"",title:"Soul派对房主理人 · 私域运营专家",bio:'每天早上6点到9点在Soul派对房分享真实的创业故事。专注私域运营与项目变现用"云阿米巴"模式帮助创业者构建可持续的商业体系。',stats:[{label:"商业案例",value:"62"},{label:"连续直播",value:"365天"},{label:"派对分享",value:"1000+"}],highlights:["5年私域运营经验","帮助100+品牌从0到1增长","连续创业者,擅长商业模式设计"]};function iN(t){return Array.isArray(t)?t.map(e=>e&&typeof e=="object"&&"label"in e&&"value"in e?{label:String(e.label),value:String(e.value)}:{label:"",value:""}).filter(e=>e.label||e.value):Ks.stats}function aN(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):Ks.highlights}function HB(){const[t,e]=b.useState(Ks),[n,r]=b.useState(!0),[s,a]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{Be("/api/admin/author-settings").then(k=>{const E=k==null?void 0:k.data;E&&typeof E=="object"&&e({name:String(E.name??Ks.name),avatar:String(E.avatar??Ks.avatar),avatarImg:String(E.avatarImg??""),title:String(E.title??Ks.title),bio:String(E.bio??Ks.bio),stats:iN(E.stats).length?iN(E.stats):Ks.stats,highlights:aN(E.highlights).length?aN(E.highlights):Ks.highlights})}).catch(console.error).finally(()=>r(!1))},[]);const h=async()=>{a(!0);try{const k={name:t.name,avatar:t.avatar||"K",avatarImg:t.avatarImg,title:t.title,bio:t.bio,stats:t.stats.filter(M=>M.label||M.value),highlights:t.highlights.filter(Boolean)},E=await ht("/api/admin/author-settings",k);if(!E||E.success===!1){alert("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:""));return}a(!1);const C=document.createElement("div");C.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",C.textContent="作者设置已保存",document.body.appendChild(C),setTimeout(()=>C.remove(),2e3)}catch(k){console.error(k),alert("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{a(!1)}},f=async k=>{var C;const E=(C=k.target.files)==null?void 0:C[0];if(E){c(!0);try{const M=new FormData;M.append("file",E),M.append("folder","avatars");const D=kx(),F={};D&&(F.Authorization=`Bearer ${D}`);const I=await(await fetch(Yo("/api/upload"),{method:"POST",body:M,credentials:"include",headers:F})).json();I!=null&&I.success&&(I!=null&&I.url)?e(A=>({...A,avatarImg:I.url})):alert("上传失败: "+((I==null?void 0:I.error)||"未知错误"))}catch(M){console.error(M),alert("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(k=>({...k,stats:[...k.stats,{label:"",value:""}]})),g=k=>e(E=>({...E,stats:E.stats.filter((C,M)=>M!==k)})),y=(k,E,C)=>e(M=>({...M,stats:M.stats.map((D,F)=>F===k?{...D,[E]:C}:D)})),v=()=>e(k=>({...k,highlights:[...k.highlights,""]})),j=k=>e(E=>({...E,highlights:E.highlights.filter((C,M)=>M!==k)})),w=(k,E)=>e(C=>({...C,highlights:C.highlights.map((M,D)=>D===k?E:M)}));return n?i.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Wo,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),i.jsxs(re,{onClick:h,disabled:s||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),s?"保存中...":"保存"]})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[i.jsx(Wo,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),i.jsx(It,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"姓名"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(E=>({...E,name:k.target.value})),placeholder:"卡若"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:k=>e(E=>({...E,avatar:k.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(LN,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),i.jsxs("div",{className:"flex gap-3 items-center",children:[i.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:k=>e(E=>({...E,avatarImg:k.target.value})),placeholder:"上传或粘贴 URL如 /uploads/avatars/xxx.png"}),i.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),i.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var k;return(k=u.current)==null?void 0:k.click()},children:[i.jsx(Hu,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&i.jsx("div",{className:"mt-2",children:i.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:Yo(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"头衔"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(E=>({...E,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"个人简介"}),i.jsx(dl,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:k=>e(E=>({...E,bio:k.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsx(tt,{className:"text-white",children:"统计数据"}),i.jsx(It,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),i.jsxs(Te,{className:"space-y-3",children:[t.stats.map((k,E)=>i.jsxs("div",{className:"flex gap-3 items-center",children:[i.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:C=>y(E,"label",C.target.value),placeholder:"标签"}),i.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:C=>y(E,"value",C.target.value),placeholder:"数值"}),i.jsx(re,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(E),children:i.jsx(er,{className:"w-4 h-4"})})]},E)),i.jsxs(re,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsx(tt,{className:"text-white",children:"亮点标签"}),i.jsx(It,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),i.jsxs(Te,{className:"space-y-3",children:[t.highlights.map((k,E)=>i.jsxs("div",{className:"flex gap-3 items-center",children:[i.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:C=>w(E,C.target.value),placeholder:"5年私域运营经验"}),i.jsx(re,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>j(E),children:i.jsx(er,{className:"w-4 h-4"})})]},E)),i.jsxs(re,{variant:"outline",size:"sm",onClick:v,className:"border-gray-600 text-gray-400",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function WB(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[s,a]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=$x(h,300),[g,y]=b.useState(!0),[v,j]=b.useState(null),[w,k]=b.useState(!1),[E,C]=b.useState(null),[M,D]=b.useState(""),[F,R]=b.useState(""),[I,A]=b.useState(""),[O,W]=b.useState("admin"),[X,q]=b.useState("active"),[Z,_]=b.useState(!1);async function $(){var H;y(!0),j(null);try{const ue=new URLSearchParams({page:String(s),pageSize:String(o)});m.trim()&&ue.set("search",m.trim());const U=await Be(`/api/admin/users?${ue}`);U!=null&&U.success?(e(U.records||[]),r(U.total??0),u(U.totalPages??0)):j(U.error||"加载失败")}catch(ue){const U=ue;j(U.status===403?"无权限访问":((H=U==null?void 0:U.data)==null?void 0:H.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{$()},[s,o,m]);const oe=()=>{C(null),D(""),R(""),A(""),W("admin"),q("active"),k(!0)},V=H=>{C(H),D(H.username),R(""),A(H.name||""),W(H.role==="super_admin"?"super_admin":"admin"),q(H.status==="disabled"?"disabled":"active"),k(!0)},ae=async()=>{var H;if(!M.trim()){j("用户名不能为空");return}if(!E&&!F){j("新建时密码必填,至少 6 位");return}if(F&&F.length<6){j("密码至少 6 位");return}j(null),_(!0);try{if(E){const ue=await Rt("/api/admin/users",{id:E.id,password:F||void 0,name:I.trim(),role:O,status:X});ue!=null&&ue.success?(k(!1),$()):j((ue==null?void 0:ue.error)||"保存失败")}else{const ue=await ht("/api/admin/users",{username:M.trim(),password:F,name:I.trim(),role:O});ue!=null&&ue.success?(k(!1),$()):j((ue==null?void 0:ue.error)||"保存失败")}}catch(ue){const U=ue;j(((H=U==null?void 0:U.data)==null?void 0:H.error)||"保存失败")}finally{_(!1)}},Y=async H=>{var ue;if(confirm("确定删除该管理员?"))try{const U=await Yr(`/api/admin/users?id=${H}`);U!=null&&U.success?$():j((U==null?void 0:U.error)||"删除失败")}catch(U){const he=U;j(((ue=he==null?void 0:he.data)==null?void 0:ue.error)||"删除失败")}},L=H=>{if(!H)return"-";try{const ue=new Date(H);return isNaN(ue.getTime())?H:ue.toLocaleString("zh-CN")}catch{return H}};return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-6",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Nx,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ce,{placeholder:"搜索用户名/昵称",value:h,onChange:H=>f(H.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),i.jsx(re,{variant:"outline",size:"sm",onClick:$,disabled:g,className:"border-gray-600 text-gray-300",children:i.jsx(qe,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),i.jsxs(re,{onClick:oe,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),v&&i.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm flex justify-between items-center",children:[i.jsx("span",{children:v}),i.jsx("button",{type:"button",onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-0",children:g?i.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):i.jsxs(i.Fragment,{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"ID"}),i.jsx(ke,{className:"text-gray-400",children:"用户名"}),i.jsx(ke,{className:"text-gray-400",children:"昵称"}),i.jsx(ke,{className:"text-gray-400",children:"角色"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-gray-400",children:"创建时间"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsxs(pr,{children:[t.map(H=>i.jsxs(ct,{className:"border-gray-700/50",children:[i.jsx(ve,{className:"text-gray-300",children:H.id}),i.jsx(ve,{className:"text-white font-medium",children:H.username}),i.jsx(ve,{className:"text-gray-400",children:H.name||"-"}),i.jsx(ve,{children:i.jsx(Fe,{variant:"outline",className:H.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:H.role==="super_admin"?"超级管理员":"管理员"})}),i.jsx(ve,{children:i.jsx(Fe,{variant:"outline",className:H.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:H.status==="active"?"正常":"已禁用"})}),i.jsx(ve,{className:"text-gray-500 text-sm",children:L(H.createdAt)}),i.jsxs(ve,{className:"text-right",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>V(H),className:"text-gray-400 hover:text-[#38bdac]",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Y(H.id),className:"text-gray-400 hover:text-red-400",children:i.jsx(vn,{className:"w-4 h-4"})})]})]},H.id)),t.length===0&&!g&&i.jsx(ct,{children:i.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:v==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&i.jsx("div",{className:"p-4 border-t border-gray-700/50",children:i.jsx(Zr,{page:s,pageSize:o,total:n,totalPages:c,onPageChange:a})})]})})}),i.jsx(Qt,{open:w,onOpenChange:k,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:E?"编辑管理员":"新增管理员"})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"用户名"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:M,onChange:H=>D(H.target.value),disabled:!!E}),E&&i.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:E?"新密码(留空不改)":"密码"}),i.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:E?"留空表示不修改":"至少 6 位",value:F,onChange:H=>R(H.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"昵称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:I,onChange:H=>A(H.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"角色"}),i.jsxs("select",{value:O,onChange:H=>W(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[i.jsx("option",{value:"admin",children:"管理员"}),i.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),E&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"状态"}),i.jsxs("select",{value:X,onChange:H=>q(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[i.jsx("option",{value:"active",children:"正常"}),i.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:ae,disabled:Z,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),Z?"保存中...":"保存"]})]})]})})]})}const UB={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},KB={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},qB={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...KB}},GB={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},JB=["system","author","admin"];function YB(){const[t,e]=MN(),n=t.get("tab")??"system",r=JB.includes(n)?n:"system",[s,a]=b.useState(qB),[o,c]=b.useState(GB),[u,h]=b.useState(UB),[f,m]=b.useState(!1),[g,y]=b.useState(!0),[v,j]=b.useState(!1),[w,k]=b.useState(""),[E,C]=b.useState(""),[M,D]=b.useState(!1),[F,R]=b.useState(!1),I=(q,Z,_=!1)=>{k(q),C(Z),D(_),j(!0)};b.useEffect(()=>{(async()=>{try{const Z=await Be("/api/admin/settings");if(!Z||Z.success===!1)return;if(Z.featureConfig&&Object.keys(Z.featureConfig).length&&c(_=>({..._,...Z.featureConfig})),Z.mpConfig&&typeof Z.mpConfig=="object"&&h(_=>({..._,...Z.mpConfig})),Z.siteSettings&&typeof Z.siteSettings=="object"){const _=Z.siteSettings;a($=>({...$,...typeof _.sectionPrice=="number"&&{sectionPrice:_.sectionPrice},...typeof _.baseBookPrice=="number"&&{baseBookPrice:_.baseBookPrice},...typeof _.distributorShare=="number"&&{distributorShare:_.distributorShare},..._.authorInfo&&typeof _.authorInfo=="object"&&{authorInfo:{...$.authorInfo,..._.authorInfo}}}))}}catch(Z){console.error("Load settings error:",Z)}finally{y(!1)}})()},[]);const A=async(q,Z)=>{R(!0);try{const _=await ht("/api/admin/settings",{featureConfig:q});if(!_||_.success===!1){Z(),I("保存失败",(_==null?void 0:_.error)??"未知错误",!0);return}I("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(_){console.error("Save feature config error:",_),Z(),I("保存失败",_ instanceof Error?_.message:String(_),!0)}finally{R(!1)}},O=(q,Z)=>{const _=o,$={..._,[q]:Z};c($),A($,()=>c(_))},W=async()=>{m(!0);try{const q=await ht("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:s.sectionPrice,baseBookPrice:s.baseBookPrice,distributorShare:s.distributorShare,authorInfo:s.authorInfo},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10}});if(!q||q.success===!1){I("保存失败",(q==null?void 0:q.error)??"未知错误",!0);return}I("已保存","设置已保存成功。")}catch(q){console.error("Save settings error:",q),I("保存失败",q instanceof Error?q.message:String(q),!0)}finally{m(!1)}},X=q=>{e(q==="system"?{}:{tab:q})};return g?i.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),i.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),r==="system"&&i.jsxs(re,{onClick:W,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),f?"保存中...":"保存设置"]})]}),i.jsxs(Hc,{value:r,onValueChange:X,className:"w-full",children:[i.jsxs(cl,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[i.jsxs(en,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[i.jsx(Da,{className:"w-4 h-4 mr-2"}),"系统设置"]}),i.jsxs(en,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[i.jsx(hm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),i.jsxs(en,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[i.jsx(Nx,{className:"w-4 h-4 mr-2"}),"管理员"]})]}),i.jsx(tn,{value:"system",className:"mt-0",children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(hm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),i.jsx(It,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[i.jsx(hm,{className:"w-3 h-3"}),"主理人名称"]}),i.jsx(ce,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:s.authorInfo.name??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,name:q.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[i.jsx(Bu,{className:"w-3 h-3"}),"开播日期"]}),i.jsx(ce,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:s.authorInfo.startDate??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,startDate:q.target.value}}))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[i.jsx(Bu,{className:"w-3 h-3"}),"直播时间"]}),i.jsx(ce,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:s.authorInfo.liveTime??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,liveTime:q.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[i.jsx(_N,{className:"w-3 h-3"}),"直播平台"]}),i.jsx(ce,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:s.authorInfo.platform??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,platform:q.target.value}}))})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[i.jsx(zr,{className:"w-3 h-3"}),"简介描述"]}),i.jsx(ce,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:s.authorInfo.description??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,description:q.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),i.jsx(dl,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:s.authorInfo.bio??"",onChange:q=>a(Z=>({...Z,authorInfo:{...Z.authorInfo,bio:q.target.value}}))})]}),i.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[i.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-br from-[#00CED1] to-[#20B2AA] flex items-center justify-center text-xl font-bold text-white",children:(s.authorInfo.name??"K").charAt(0)}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-semibold",children:s.authorInfo.name}),i.jsx("p",{className:"text-gray-400 text-xs",children:s.authorInfo.description}),i.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",s.authorInfo.liveTime," · ",s.authorInfo.platform]})]})]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Vu,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),i.jsx(It,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),i.jsx(Te,{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"单节价格 (元)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:s.sectionPrice,onChange:q=>a(Z=>({...Z,sectionPrice:Number.parseFloat(q.target.value)||1}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"整本价格 (元)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:s.baseBookPrice,onChange:q=>a(Z=>({...Z,baseBookPrice:Number.parseFloat(q.target.value)||9.9}))})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(kc,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),i.jsx(It,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取API 地址由 app.js baseUrl 控制)"})]}),i.jsx(Te,{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"小程序 AppID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:q=>h(Z=>({...Z,appId:q.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"提现订阅模板 ID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:q=>h(Z=>({...Z,withdrawSubscribeTmplId:q.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"微信支付商户号"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:q=>h(Z=>({...Z,mchId:q.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"最低提现金额 (元)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:q=>h(Z=>({...Z,minWithdraw:Number.parseFloat(q.target.value)||10}))})]})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Da,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),i.jsx(It,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Nn,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx(te,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),i.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),i.jsx(yt,{id:"match-enabled",checked:o.matchEnabled,disabled:F,onCheckedChange:q=>O("matchEnabled",q)})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(iM,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx(te,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),i.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),i.jsx(yt,{id:"referral-enabled",checked:o.referralEnabled,disabled:F,onCheckedChange:q=>O("referralEnabled",q)})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(zr,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx(te,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),i.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页搜索栏的显示"})]}),i.jsx(yt,{id:"search-enabled",checked:o.searchEnabled,disabled:F,onCheckedChange:q=>O("searchEnabled",q)})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Da,{className:"w-4 h-4 text-[#38bdac]"}),i.jsx(te,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),i.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),i.jsx(yt,{id:"about-enabled",checked:o.aboutEnabled,disabled:F,onCheckedChange:q=>O("aboutEnabled",q)})]})]}),i.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:i.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),i.jsx(tn,{value:"author",className:"mt-0",children:i.jsx(HB,{})}),i.jsx(tn,{value:"admin",className:"mt-0",children:i.jsx(WB,{})})]}),i.jsx(Qt,{open:v,onOpenChange:j,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[i.jsxs(Xt,{children:[i.jsx(Zt,{className:M?"text-red-400":"text-[#38bdac]",children:w}),i.jsx(EI,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:E})]}),i.jsx(bn,{className:"mt-4",children:i.jsx(re,{onClick:()=>j(!1),className:M?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const oN={wechat:{enabled:!0,qrCode:"/images/wechat-pay.png",account:"卡若",websiteAppId:"",merchantId:"",groupQrCode:"/images/party-group-qr.png"},alipay:{enabled:!0,qrCode:"/images/alipay.png",account:"卡若",partnerId:"",securityKey:""},usdt:{enabled:!1,network:"TRC20",address:"",exchangeRate:7.2},paypal:{enabled:!1,email:"",exchangeRate:7.2}};function QB(){const[t,e]=b.useState(!1),[n,r]=b.useState(oN),[s,a]=b.useState(""),o=async()=>{e(!0);try{const k=await Be("/api/config");k!=null&&k.paymentMethods&&r({...oN,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await ht("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),alert("配置已保存!")}catch(k){console.error("保存失败:",k),alert("保存失败: "+(k instanceof Error?k.message:String(k)))}finally{e(!1)}},u=(k,E)=>{navigator.clipboard.writeText(k),a(E),setTimeout(()=>a(""),2e3)},h=(k,E)=>{r(C=>({...C,wechat:{...C.wechat,[k]:E}}))},f=(k,E)=>{r(C=>({...C,alipay:{...C.alipay,[k]:E}}))},m=(k,E)=>{r(C=>({...C,usdt:{...C.usdt,[k]:E}}))},g=(k,E)=>{r(C=>({...C,paypal:{...C.paypal,[k]:E}}))},y=n.wechat,v=n.alipay,j=n.usdt,w=n.paypal;return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),i.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs(re,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),i.jsxs(re,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),i.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(IN,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),i.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[i.jsx("li",{children:"打开微信,进入目标微信群"}),i.jsx("li",{children:'点击右上角"..." → "群二维码"'}),i.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),i.jsx("li",{children:"在电脑上保存二维码图片上传到图床获取URL"}),i.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),i.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示微信群二维码7天后失效建议使用活码工具"})]})]})}),i.jsxs(Hc,{defaultValue:"wechat",className:"space-y-6",children:[i.jsxs(cl,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[i.jsxs(en,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[i.jsx(kc,{className:"w-4 h-4 mr-2"}),"微信"]}),i.jsxs(en,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[i.jsx(Tb,{className:"w-4 h-4 mr-2"}),"支付宝"]}),i.jsxs(en,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[i.jsx(Cb,{className:"w-4 h-4 mr-2"}),"USDT"]}),i.jsxs(en,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[i.jsx(mg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),i.jsx(tn,{value:"wechat",className:"space-y-4",children:i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs(tt,{className:"text-[#07C160] flex items-center gap-2",children:[i.jsx(kc,{className:"w-5 h-5"}),"微信支付配置"]}),i.jsx(It,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),i.jsx(yt,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"网站AppID"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"商户号"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),i.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[i.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[i.jsx(Xs,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"微信收款码/支付链接"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:k=>h("qrCode",k.target.value)}),i.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),i.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[i.jsx(te,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),i.jsx(ce,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:k=>h("groupQrCode",k.target.value)}),i.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),i.jsx(tn,{value:"alipay",className:"space-y-4",children:i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs(tt,{className:"text-[#1677FF] flex items-center gap-2",children:[i.jsx(Tb,{className:"w-5 h-5"}),"支付宝配置"]}),i.jsx(It,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),i.jsx(yt,{checked:!!v.enabled,onCheckedChange:k=>f("enabled",k)})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"合作者身份 (PID)"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),i.jsx(re,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(v.partnerId??""),"pid"),children:s==="pid"?i.jsx(Wh,{className:"w-4 h-4 text-green-500"}):i.jsx(ON,{className:"w-4 h-4 text-gray-400"})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"安全校验码 (Key)"}),i.jsx(ce,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.securityKey??""),onChange:k=>f("securityKey",k.target.value)})]})]}),i.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[i.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[i.jsx(Xs,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(v.qrCode??""),onChange:k=>f("qrCode",k.target.value)}),i.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),i.jsx(tn,{value:"usdt",className:"space-y-4",children:i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs(tt,{className:"text-[#26A17B] flex items-center gap-2",children:[i.jsx(Cb,{className:"w-5 h-5"}),"USDT配置"]}),i.jsx(It,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),i.jsx(yt,{checked:!!j.enabled,onCheckedChange:k=>m("enabled",k)})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"网络类型"}),i.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(j.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[i.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),i.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),i.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"收款地址"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(j.address??""),onChange:k=>m("address",k.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),i.jsx(tn,{value:"paypal",className:"space-y-4",children:i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsxs(tt,{className:"text-[#169BD7] flex items-center gap-2",children:[i.jsx(mg,{className:"w-5 h-5"}),"PayPal配置"]}),i.jsx(It,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),i.jsx(yt,{checked:!!w.enabled,onCheckedChange:k=>g("enabled",k)})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"PayPal邮箱"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(w.email??""),onChange:k=>g("email",k.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:k=>g("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const XB={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},ZB={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},eV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function tV(){const[t,e]=b.useState({siteConfig:{...XB},menuConfig:{...ZB},pageConfig:{...eV}}),[n,r]=b.useState(!1),[s,a]=b.useState(!1);b.useEffect(()=>{Be("/api/config").then(f=>{f!=null&&f.siteConfig&&e(m=>({...m,siteConfig:{...m.siteConfig,...f.siteConfig}})),f!=null&&f.menuConfig&&e(m=>({...m,menuConfig:{...m.menuConfig,...f.menuConfig}})),f!=null&&f.pageConfig&&e(m=>({...m,pageConfig:{...m.pageConfig,...f.pageConfig}}))}).catch(console.error)},[]);const o=async()=>{a(!0);try{await ht("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await ht("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await ht("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),alert("配置已保存")}catch(f){console.error(f),alert("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{a(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),i.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),i.jsxs(re,{onClick:o,disabled:s,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),s?"保存中...":n?"已保存":"保存设置"]})]}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(mg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),i.jsx(It,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),i.jsx(ce,{id:"site-name",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteName??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteName:f.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),i.jsx(ce,{id:"site-title",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteTitle??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteTitle:f.target.value}}))})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),i.jsx(ce,{id:"site-desc",className:"bg-[#0a1628] border-gray-700 text-white",value:c.siteDescription??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,siteDescription:f.target.value}}))})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),i.jsx(ce,{id:"logo",className:"bg-[#0a1628] border-gray-700 text-white",value:c.logo??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,logo:f.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),i.jsx(ce,{id:"favicon",className:"bg-[#0a1628] border-gray-700 text-white",value:c.favicon??"",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,favicon:f.target.value}}))})]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),i.jsx(It,{className:"text-gray-400",children:"配置网站主题色"})]}),i.jsx(Te,{children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{className:"space-y-2 flex-1",children:[i.jsx(te,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ce,{id:"primary-color",type:"color",className:"w-16 h-10 bg-[#0a1628] border-gray-700 cursor-pointer p-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white flex-1",value:c.primaryColor??"#00CED1",onChange:f=>e(m=>({...m,siteConfig:{...m.siteConfig,primaryColor:f.target.value}}))})]})]}),i.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(WM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),i.jsx(It,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),i.jsx(Te,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>i.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[i.jsx(yt,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),i.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white max-w-[200px]",value:(m==null?void 0:m.label)??"",onChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,label:g.target.value}}}))})]}),i.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(nM,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),i.jsx(It,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"首页标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"首页副标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"目录页标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"匹配页标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"我的页标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"关于作者标题"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function nV(){const[t,e]=b.useState(""),[n,r]=b.useState(""),[s,a]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,v,j,w;try{const k=await Be("/api/config"),E=(v=(y=k==null?void 0:k.liveQRCodes)==null?void 0:y[0])==null?void 0:v.urls;Array.isArray(E)&&e(E.join(`
`));const C=(w=(j=k==null?void 0:k.paymentMethods)==null?void 0:j.wechat)==null?void 0:w.groupQrCode;C&&r(C),c({paymentMethods:k==null?void 0:k.paymentMethods,liveQRCodes:k==null?void 0:k.liveQRCodes})}catch(k){console.error(k)}};b.useEffect(()=>{u()},[]);const h=(y,v)=>{navigator.clipboard.writeText(y),a(v),setTimeout(()=>a(""),2e3)},f=async()=>{try{const y=t.split(`
`).map(j=>j.trim()).filter(Boolean),v=[...o.liveQRCodes||[]];v[0]?v[0].urls=y:v.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await ht("/api/db/config",{key:"live_qr_codes",value:v,description:"群活码配置"}),alert("群活码配置已保存!"),await u()}catch(y){console.error(y),alert("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await ht("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),alert("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(v){console.error(v),alert("保存失败: "+(v instanceof Error?v.message:String(v)))}},g=()=>{n?window.open(n,"_blank"):alert("请先配置微信群链接")};return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"mb-8",children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),i.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),i.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(IN,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm",children:[i.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),i.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[i.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[i.jsx("li",{children:"访问草料二维码创建活码"}),i.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),i.jsx("li",{children:"复制生成的短链接填入下方配置"}),i.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),i.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[i.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),i.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),i.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意微信原生群二维码7天后失效建议使用草料活码"})]})]})]})}),i.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-[#07C160] flex items-center gap-2",children:[i.jsx(Mb,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),i.jsx(It,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(gg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ce,{placeholder:"https://cli.im/xxxxx 或 https://weixin.qq.com/g/...",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",value:n,onChange:y=>r(y.target.value)}),i.jsx(re,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:s==="group"?i.jsx(Wh,{className:"w-4 h-4 text-green-500"}):i.jsx(ON,{className:"w-4 h-4 text-gray-400"})})]}),i.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[i.jsx(Xs,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs(re,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[i.jsx(Hu,{className:"w-4 h-4 mr-2"}),"保存配置"]}),i.jsxs(re,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[i.jsx(Xs,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Mb,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),i.jsx(It,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),i.jsxs(Te,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs(te,{className:"text-gray-300 flex items-center gap-2",children:[i.jsx(gg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),i.jsx(dl,{placeholder:"https://cli.im/group1\\nhttps://cli.im/group2",className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 min-h-[120px] font-mono text-sm",value:t,onChange:y=>e(y.target.value)}),i.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[i.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),i.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(`
`).filter(Boolean).length," 个"]})]}),i.jsxs(re,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Hu,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),i.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[i.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),i.jsxs("div",{className:"space-y-3 text-sm",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),i.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接群满后可直接在后台更换新群码无需修改网站配置。微信原生群码7天失效。"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),i.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const lN={matchTypes:[{id:"partner",label:"创业合伙",matchLabel:"创业伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10}},rV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function sV(){const[t,e]=b.useState(lN),[n,r]=b.useState(!0),[s,a]=b.useState(!1),[o,c]=b.useState(!1),[u,h]=b.useState(null),[f,m]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{r(!0);try{const C=await Be("/api/db/config/full?key=match_config"),M=(C==null?void 0:C.data)??(C==null?void 0:C.config);M&&e({...lN,...M})}catch(C){console.error("加载匹配配置失败:",C)}finally{r(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{a(!0);try{const C=await ht("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});C&&C.success!==!1?alert("配置保存成功!"):alert("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:"未知错误"))}catch(C){console.error("保存配置失败:",C),alert("保存失败")}finally{a(!1)}},v=C=>{h(C),m({id:C.id,label:C.label,matchLabel:C.matchLabel,icon:C.icon,matchFromDB:C.matchFromDB,showJoinAfterMatch:C.showJoinAfterMatch,price:C.price,enabled:C.enabled}),c(!0)},j=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},w=()=>{if(!f.id||!f.label){alert("请填写类型ID和名称");return}const C=[...t.matchTypes];if(u){const M=C.findIndex(D=>D.id===u.id);M!==-1&&(C[M]={...f})}else{if(C.some(M=>M.id===f.id)){alert("类型ID已存在");return}C.push({...f})}e({...t,matchTypes:C}),c(!1)},k=C=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(M=>M.id!==C)})},E=C=>{e({...t,matchTypes:t.matchTypes.map(M=>M.id===C?{...M,enabled:!M.enabled}:M)})};return i.jsxs("div",{className:"p-8 w-full space-y-6",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Da,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs(re,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),i.jsxs(re,{onClick:y,disabled:s,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),s?"保存中...":"保存配置"]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Fi,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),i.jsx(It,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),i.jsxs(Te,{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"每日免费匹配次数"}),i.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:C=>e({...t,freeMatchLimit:parseInt(C.target.value,10)||0})}),i.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),i.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:C=>e({...t,matchPrice:parseFloat(C.target.value)||1})}),i.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),i.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:C=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(C.target.value,10)||10}})}),i.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),i.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:t.settings.enableFreeMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enableFreeMatches:C}})}),i.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:t.settings.enablePaidMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enablePaidMatches:C}})}),i.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),i.jsx(It,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),i.jsxs(re,{onClick:j,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),i.jsx(Te,{children:i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"图标"}),i.jsx(ke,{className:"text-gray-400",children:"类型ID"}),i.jsx(ke,{className:"text-gray-400",children:"显示名称"}),i.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),i.jsx(ke,{className:"text-gray-400",children:"价格"}),i.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsx(pr,{children:t.matchTypes.map(C=>i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{children:i.jsx("span",{className:"text-2xl",children:C.icon})}),i.jsx(ve,{className:"font-mono text-gray-300",children:C.id}),i.jsx(ve,{className:"text-white font-medium",children:C.label}),i.jsx(ve,{className:"text-gray-300",children:C.matchLabel}),i.jsx(ve,{children:i.jsxs(Fe,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",C.price]})}),i.jsx(ve,{children:C.matchFromDB?i.jsx(Fe,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):i.jsx(Fe,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),i.jsx(ve,{children:i.jsx(yt,{checked:C.enabled,onCheckedChange:()=>E(C.id)})}),i.jsx(ve,{className:"text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>v(C),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>k(C.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:i.jsx(vn,{className:"w-4 h-4"})})]})})]},C.id))})]})})]}),i.jsx(Qt,{open:o,onOpenChange:c,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[u?i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}):i.jsx(Lt,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"类型ID英文"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:C=>m({...f,id:C.target.value}),disabled:!!u})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"图标"}),i.jsx("div",{className:"flex gap-1 flex-wrap",children:rV.map(C=>i.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===C?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:C}),children:C},C))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"显示名称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:C=>m({...f,label:C.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"匹配标签"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:C=>m({...f,matchLabel:C.target.value})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),i.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:C=>m({...f,price:parseFloat(C.target.value)||1})})]}),i.jsxs("div",{className:"flex gap-6 pt-2",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:f.matchFromDB,onCheckedChange:C=>m({...f,matchFromDB:C})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:f.showJoinAfterMatch,onCheckedChange:C=>m({...f,showJoinAfterMatch:C})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:f.enabled,onCheckedChange:C=>m({...f,enabled:C})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsxs(re,{onClick:w,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const cN={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function iV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[s,a]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null);async function v(){m(!0),y(null);try{const w=new URLSearchParams({page:String(s),pageSize:String(o)});u&&w.set("matchType",u);const k=await Be(`/api/db/match-records?${w}`);k!=null&&k.success?(e(k.records||[]),r(k.total??0)):y("加载匹配记录失败")}catch(w){console.error("加载匹配记录失败",w),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[s,u]);const j=Math.ceil(n/o)||1;return i.jsxs("div",{className:"p-8 w-full",children:[g&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),i.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("select",{value:u,onChange:w=>{h(w.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[i.jsx("option",{value:"",children:"全部类型"}),Object.entries(cN).map(([w,k])=>i.jsx("option",{value:w,children:k},w))]}),i.jsxs("button",{type:"button",onClick:v,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[i.jsx(qe,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:f?i.jsxs("div",{className:"flex justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs(i.Fragment,{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"发起人"}),i.jsx(ke,{className:"text-gray-400",children:"匹配到"}),i.jsx(ke,{className:"text-gray-400",children:"类型"}),i.jsx(ke,{className:"text-gray-400",children:"联系方式"}),i.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),i.jsxs(pr,{children:[t.map(w=>i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[w.userAvatar?i.jsx("img",{src:w.userAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const E=k.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,i.jsx("span",{className:w.userAvatar?"hidden":"",children:(w.userNickname||w.userId||"?").charAt(0)})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-white",children:w.userNickname||w.userId}),i.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.userId.slice(0,16),"..."]})]})]})}),i.jsx(ve,{children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[w.matchedUserAvatar?i.jsx("img",{src:w.matchedUserAvatar,alt:"",className:"w-full h-full object-cover",onError:k=>{k.currentTarget.style.display="none";const E=k.currentTarget.nextElementSibling;E&&E.classList.remove("hidden")}}):null,i.jsx("span",{className:w.matchedUserAvatar?"hidden":"",children:(w.matchedNickname||w.matchedUserId||"?").charAt(0)})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-white",children:w.matchedNickname||w.matchedUserId}),i.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.matchedUserId.slice(0,16),"..."]})]})]})}),i.jsx(ve,{children:i.jsx(Fe,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:cN[w.matchType]||w.matchType})}),i.jsxs(ve,{className:"text-gray-400 text-sm",children:[w.phone&&i.jsxs("div",{children:["📱 ",w.phone]}),w.wechatId&&i.jsxs("div",{children:["💬 ",w.wechatId]}),!w.phone&&!w.wechatId&&"-"]}),i.jsx(ve,{className:"text-gray-400",children:w.createdAt?new Date(w.createdAt).toLocaleString():"-"})]},w.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),i.jsx(Zr,{page:s,totalPages:j,total:n,pageSize:o,onPageChange:a,onPageSizeChange:w=>{c(w),a(1)}})]})})})]})}function aV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[s,a]=b.useState(!1),[o,c]=b.useState(null),[u,h]=b.useState(""),[f,m]=b.useState(0),[g,y]=b.useState(!1);async function v(){r(!0);try{const C=await Be("/api/db/vip-roles");C!=null&&C.success&&C.data&&e(C.data)}catch(C){console.error("Load roles error:",C)}finally{r(!1)}}b.useEffect(()=>{v()},[]);const j=()=>{c(null),h(""),m(t.length>0?Math.max(...t.map(C=>C.sort))+1:0),a(!0)},w=C=>{c(C),h(C.name),m(C.sort),a(!0)},k=async()=>{if(!u.trim()){alert("角色名称不能为空");return}y(!0);try{if(o){const C=await Rt("/api/db/vip-roles",{id:o.id,name:u.trim(),sort:f});C!=null&&C.success?(a(!1),v()):alert("更新失败: "+(C==null?void 0:C.error))}else{const C=await ht("/api/db/vip-roles",{name:u.trim(),sort:f});C!=null&&C.success?(a(!1),v()):alert("新增失败: "+(C==null?void 0:C.error))}}catch(C){console.error("Save error:",C),alert("保存失败")}finally{y(!1)}},E=async C=>{if(confirm("确定删除该角色?已设置该角色的 VIP 用户将保留角色名称。"))try{const M=await Yr(`/api/db/vip-roles?id=${C}`);M!=null&&M.success?v():alert("删除失败: "+(M==null?void 0:M.error))}catch(M){console.error("Delete error:",M),alert("删除失败")}};return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Aa,{className:"w-5 h-5 text-amber-400"}),"VIP 角色管理"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"超级个体固定角色,在「设置 VIP」时可选择或手动填写"})]}),i.jsxs(re,{onClick:j,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"新增角色"]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-0",children:n?i.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"ID"}),i.jsx(ke,{className:"text-gray-400",children:"角色名称"}),i.jsx(ke,{className:"text-gray-400",children:"排序"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsxs(pr,{children:[t.map(C=>i.jsxs(ct,{className:"border-gray-700/50",children:[i.jsx(ve,{className:"text-gray-300",children:C.id}),i.jsx(ve,{className:"text-white",children:C.name}),i.jsx(ve,{className:"text-gray-400",children:C.sort}),i.jsxs(ve,{className:"text-right",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>w(C),className:"text-gray-400 hover:text-[#38bdac]",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>E(C.id),className:"text-gray-400 hover:text-red-400",children:i.jsx(vn,{className:"w-4 h-4"})})]})]},C.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无角色,点击「新增角色」添加"})})]})]})})}),i.jsx(Qt,{open:s,onOpenChange:a,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:o?"编辑角色":"新增角色"})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"角色名称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创始人、投资人",value:u,onChange:C=>h(C.target.value)})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"排序(下拉展示顺序,越小越前)"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:f,onChange:C=>m(parseInt(C.target.value,10)||0)})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>a(!1),className:"border-gray-600 text-gray-300",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:k,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),g?"保存中...":"保存"]})]})]})})]})}function NE({embedded:t=!1}){const[e,n]=b.useState([]),[r,s]=b.useState(!0),[a,o]=b.useState(!1),[c,u]=b.useState(null),[h,f]=b.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[m,g]=b.useState(!1),[y,v]=b.useState(!1),j=b.useRef(null),w=async I=>{var O;const A=(O=I.target.files)==null?void 0:O[0];if(A){v(!0);try{const W=new FormData;W.append("file",A),W.append("folder","mentors");const X=kx(),q={};X&&(q.Authorization=`Bearer ${X}`);const _=await(await fetch(Yo("/api/upload"),{method:"POST",body:W,credentials:"include",headers:q})).json();_!=null&&_.success&&(_!=null&&_.url)?f($=>({...$,avatar:_.url})):alert("上传失败: "+((_==null?void 0:_.error)||"未知错误"))}catch(W){console.error(W),alert("上传失败")}finally{v(!1),j.current&&(j.current.value="")}}};async function k(){s(!0);try{const I=await Be("/api/db/mentors");I!=null&&I.success&&I.data&&n(I.data)}catch(I){console.error("Load mentors error:",I)}finally{s(!1)}}b.useEffect(()=>{k()},[]);const E=()=>{f({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:e.length>0?Math.max(...e.map(I=>I.sort))+1:0,enabled:!0})},C=()=>{u(null),E(),o(!0)},M=I=>{u(I),f({name:I.name,avatar:I.avatar||"",intro:I.intro||"",tags:I.tags||"",priceSingle:I.priceSingle!=null?String(I.priceSingle):"",priceHalfYear:I.priceHalfYear!=null?String(I.priceHalfYear):"",priceYear:I.priceYear!=null?String(I.priceYear):"",quote:I.quote||"",whyFind:I.whyFind||"",offering:I.offering||"",judgmentStyle:I.judgmentStyle||"",sort:I.sort,enabled:I.enabled??!0}),o(!0)},D=async()=>{if(!h.name.trim()){alert("导师姓名不能为空");return}g(!0);try{const I=O=>O===""?void 0:parseFloat(O),A={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:I(h.priceSingle),priceHalfYear:I(h.priceHalfYear),priceYear:I(h.priceYear),quote:h.quote.trim()||void 0,whyFind:h.whyFind.trim()||void 0,offering:h.offering.trim()||void 0,judgmentStyle:h.judgmentStyle.trim()||void 0,sort:h.sort,enabled:h.enabled};if(c){const O=await Rt("/api/db/mentors",{id:c.id,...A});O!=null&&O.success?(o(!1),k()):alert("更新失败: "+(O==null?void 0:O.error))}else{const O=await ht("/api/db/mentors",A);O!=null&&O.success?(o(!1),k()):alert("新增失败: "+(O==null?void 0:O.error))}}catch(I){console.error("Save error:",I),alert("保存失败")}finally{g(!1)}},F=async I=>{if(confirm("确定删除该导师?"))try{const A=await Yr(`/api/db/mentors?id=${I}`);A!=null&&A.success?k():alert("删除失败: "+(A==null?void 0:A.error))}catch(A){console.error("Delete error:",A),alert("删除失败")}},R=I=>I!=null?`¥${I}`:"-";return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),i.jsxs(re,{onClick:C,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-0",children:r?i.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"ID"}),i.jsx(ke,{className:"text-gray-400",children:"姓名"}),i.jsx(ke,{className:"text-gray-400",children:"简介"}),i.jsx(ke,{className:"text-gray-400",children:"单次"}),i.jsx(ke,{className:"text-gray-400",children:"半年"}),i.jsx(ke,{className:"text-gray-400",children:"年度"}),i.jsx(ke,{className:"text-gray-400",children:"排序"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsxs(pr,{children:[e.map(I=>i.jsxs(ct,{className:"border-gray-700/50",children:[i.jsx(ve,{className:"text-gray-300",children:I.id}),i.jsx(ve,{className:"text-white",children:I.name}),i.jsx(ve,{className:"text-gray-400 max-w-[200px] truncate",children:I.intro||"-"}),i.jsx(ve,{className:"text-gray-400",children:R(I.priceSingle)}),i.jsx(ve,{className:"text-gray-400",children:R(I.priceHalfYear)}),i.jsx(ve,{className:"text-gray-400",children:R(I.priceYear)}),i.jsx(ve,{className:"text-gray-400",children:I.sort}),i.jsxs(ve,{className:"text-right",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>M(I),className:"text-gray-400 hover:text-[#38bdac]",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>F(I.id),className:"text-gray-400 hover:text-red-400",children:i.jsx(vn,{className:"w-4 h-4"})})]})]},I.id)),e.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),i.jsx(Qt,{open:a,onOpenChange:o,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[i.jsx(Xt,{children:i.jsx(Zt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"姓名 *"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:I=>f(A=>({...A,name:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"排序"}),i.jsx(ce,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:I=>f(A=>({...A,sort:parseInt(I.target.value,10)||0}))})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"头像"}),i.jsxs("div",{className:"flex gap-3 items-center",children:[i.jsx(ce,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:I=>f(A=>({...A,avatar:I.target.value})),placeholder:"点击上传或粘贴图片地址"}),i.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:w}),i.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var I;return(I=j.current)==null?void 0:I.click()},children:[i.jsx(Hu,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&i.jsx("div",{className:"mt-2",children:i.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:Yo(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"简介"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:I=>f(A=>({...A,intro:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:I=>f(A=>({...A,tags:I.target.value}))})]}),i.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[i.jsx(te,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),i.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:I=>f(A=>({...A,priceSingle:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),i.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:I=>f(A=>({...A,priceHalfYear:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),i.jsx(ce,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:I=>f(A=>({...A,priceYear:I.target.value}))})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"引言"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:I=>f(A=>({...A,quote:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"为什么找(文本)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:I=>f(A=>({...A,whyFind:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"提供什么(文本)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:I=>f(A=>({...A,offering:I.target.value}))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:I=>f(A=>({...A,judgmentStyle:I.target.value}))})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:I=>f(A=>({...A,enabled:I.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),i.jsx(te,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),i.jsxs(bn,{children:[i.jsxs(re,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),"取消"]}),i.jsxs(re,{onClick:D,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function oV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[s,a]=b.useState("");async function o(){r(!0);try{const h=s?`/api/db/mentor-consultations?status=${s}`:"/api/db/mentor-consultations",f=await Be(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}b.useEffect(()=>{o()},[s]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex justify-between items-center mb-8",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Bu,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{value:s,onChange:h=>a(h.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[i.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>i.jsx("option",{value:h,children:f},h))]}),i.jsxs(re,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-0",children:n?i.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"ID"}),i.jsx(ke,{className:"text-gray-400",children:"用户ID"}),i.jsx(ke,{className:"text-gray-400",children:"导师ID"}),i.jsx(ke,{className:"text-gray-400",children:"类型"}),i.jsx(ke,{className:"text-gray-400",children:"金额"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),i.jsxs(pr,{children:[t.map(h=>i.jsxs(ct,{className:"border-gray-700/50",children:[i.jsx(ve,{className:"text-gray-300",children:h.id}),i.jsx(ve,{className:"text-gray-400",children:h.userId}),i.jsx(ve,{className:"text-gray-400",children:h.mentorId}),i.jsx(ve,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),i.jsxs(ve,{className:"text-white",children:["¥",h.amount]}),i.jsx(ve,{className:"text-gray-400",children:c[h.status]||h.status}),i.jsx(ve,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const lc={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},dN={matchTypes:[{id:"partner",label:"找伙伴",matchLabel:"找伙伴",icon:"⭐",matchFromDB:!0,showJoinAfterMatch:!1,price:1,enabled:!0},{id:"investor",label:"资源对接",matchLabel:"资源对接",icon:"👥",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"mentor",label:"导师顾问",matchLabel:"导师顾问",icon:"❤️",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0},{id:"team",label:"团队招募",matchLabel:"加入项目",icon:"🎮",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}],freeMatchLimit:3,matchPrice:1,settings:{enableFreeMatches:!0,enablePaidMatches:!0,maxMatchesPerDay:10},poolSettings:lc},lV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function cV(){const t=sa(),[e,n]=b.useState(dN),[r,s]=b.useState(!0),[a,o]=b.useState(!1),[c,u]=b.useState(!1),[h,f]=b.useState(null),[m,g]=b.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,v]=b.useState(null),[j,w]=b.useState(!1),k=async()=>{w(!0);try{const A=await Be("/api/db/match-pool-counts");A!=null&&A.success&&A.data&&v(A.data)}catch(A){console.error("加载池子人数失败:",A)}finally{w(!1)}},E=async()=>{s(!0);try{const A=await Be("/api/db/config/full?key=match_config"),O=(A==null?void 0:A.data)??(A==null?void 0:A.config);if(O){let W=O.poolSettings??lc;W.poolSource&&!Array.isArray(W.poolSource)&&(W={...W,poolSource:[W.poolSource]}),n({...dN,...O,poolSettings:W})}}catch(A){console.error("加载匹配配置失败:",A)}finally{s(!1)}};b.useEffect(()=>{E(),k()},[]);const C=async()=>{o(!0);try{const A=await ht("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});alert((A==null?void 0:A.success)!==!1?"配置保存成功!":"保存失败: "+((A==null?void 0:A.error)||"未知错误"))}catch(A){console.error(A),alert("保存失败")}finally{o(!1)}},M=A=>{f(A),g({...A}),u(!0)},D=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},F=()=>{if(!m.id||!m.label){alert("请填写类型ID和名称");return}const A=[...e.matchTypes];if(h){const O=A.findIndex(W=>W.id===h.id);O!==-1&&(A[O]={...m})}else{if(A.some(O=>O.id===m.id)){alert("类型ID已存在");return}A.push({...m})}n({...e,matchTypes:A}),u(!1)},R=A=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(O=>O.id!==A)})},I=A=>{n({...e,matchTypes:e.matchTypes.map(O=>O.id===A?{...O,enabled:!O.enabled}:O)})};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsxs(re,{variant:"outline",onClick:E,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),i.jsxs(re,{onClick:C,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"})," ",a?"保存中...":"保存配置"]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(DN,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),i.jsx(It,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),i.jsxs(Te,{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-3",children:[i.jsx(te,{className:"text-gray-300",children:"匹配来源池"}),i.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{value:"vip",label:"超级个体VIP会员",desc:"付费 ¥1980 的VIP会员",icon:"👑",countKey:"vip"},{value:"complete",label:"完善资料用户",desc:"符合下方完善度要求的用户",icon:"✅",countKey:"complete"},{value:"all",label:"全部用户",desc:"所有已注册用户",icon:"👥",countKey:"all"}].map(A=>{const O=e.poolSettings??lc,X=(Array.isArray(O.poolSource)?O.poolSource:[O.poolSource]).includes(A.value),q=y==null?void 0:y[A.countKey],Z=()=>{const _=Array.isArray(O.poolSource)?[...O.poolSource]:[O.poolSource],$=X?_.filter(oe=>oe!==A.value):[..._,A.value];$.length===0&&$.push(A.value),n({...e,poolSettings:{...O,poolSource:$}})};return i.jsxs("button",{type:"button",onClick:Z,className:`p-4 rounded-lg border text-left transition-all ${X?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${X?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:X&&"✓"}),i.jsx("span",{className:"text-xl",children:A.icon}),i.jsx("span",{className:`text-sm font-medium ${X?"text-[#38bdac]":"text-gray-300"}`,children:A.label})]}),i.jsxs("span",{className:"text-lg font-bold text-white",children:[j?"...":q??"-",i.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),i.jsx("p",{className:"text-gray-500 text-xs mt-2",children:A.desc}),i.jsx("span",{role:"link",tabIndex:0,onClick:_=>{_.stopPropagation(),t(`/users?pool=${A.value}`)},onKeyDown:_=>{_.key==="Enter"&&(_.stopPropagation(),t(`/users?pool=${A.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},A.value)})})]}),i.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[i.jsx(te,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{key:"requirePhone",label:"有手机号",icon:"📱"},{key:"requireNickname",label:"有昵称",icon:"👤"},{key:"requireAvatar",label:"有头像",icon:"🖼️"},{key:"requireBusiness",label:"有业务需求",icon:"💼"}].map(A=>{const W=(e.poolSettings??lc)[A.key];return i.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[i.jsx(yt,{checked:W,onCheckedChange:X=>n({...e,poolSettings:{...e.poolSettings??lc,[A.key]:X}})}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{children:A.icon}),i.jsx(te,{className:"text-gray-300 text-sm",children:A.label})]})]},A.key)})})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Fi,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),i.jsx(It,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),i.jsxs(Te,{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"每日免费匹配次数"}),i.jsx(ce,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:A=>n({...e,freeMatchLimit:parseInt(A.target.value,10)||0})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"付费匹配价格(元)"}),i.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:A=>n({...e,matchPrice:parseFloat(A.target.value)||1})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"每日最大匹配次数"}),i.jsx(ce,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:A=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(A.target.value,10)||10}})})]})]}),i.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:e.settings.enableFreeMatches,onCheckedChange:A=>n({...e,settings:{...e.settings,enableFreeMatches:A}})}),i.jsx(te,{className:"text-gray-300",children:"启用免费匹配"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:e.settings.enablePaidMatches,onCheckedChange:A=>n({...e,settings:{...e.settings,enablePaidMatches:A}})}),i.jsx(te,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:[i.jsxs(et,{className:"flex flex-row items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs(tt,{className:"text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),i.jsx(It,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),i.jsxs(re,{onClick:D,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(Lt,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),i.jsx(Te,{children:i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"图标"}),i.jsx(ke,{className:"text-gray-400",children:"类型ID"}),i.jsx(ke,{className:"text-gray-400",children:"显示名称"}),i.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),i.jsx(ke,{className:"text-gray-400",children:"价格"}),i.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),i.jsx(pr,{children:e.matchTypes.map(A=>i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{children:i.jsx("span",{className:"text-2xl",children:A.icon})}),i.jsx(ve,{className:"font-mono text-gray-300",children:A.id}),i.jsx(ve,{className:"text-white font-medium",children:A.label}),i.jsx(ve,{className:"text-gray-300",children:A.matchLabel}),i.jsx(ve,{children:i.jsxs(Fe,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",A.price]})}),i.jsx(ve,{children:A.matchFromDB?i.jsx(Fe,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):i.jsx(Fe,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),i.jsx(ve,{children:i.jsx(yt,{checked:A.enabled,onCheckedChange:()=>I(A.id)})}),i.jsx(ve,{className:"text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",children:[i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>M(A),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:i.jsx(bt,{className:"w-4 h-4"})}),i.jsx(re,{variant:"ghost",size:"sm",onClick:()=>R(A.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:i.jsx(vn,{className:"w-4 h-4"})})]})})]},A.id))})]})})]}),i.jsx(Qt,{open:c,onOpenChange:u,children:i.jsxs(Ut,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[i.jsx(Xt,{children:i.jsxs(Zt,{className:"text-white flex items-center gap-2",children:[h?i.jsx(bt,{className:"w-5 h-5 text-[#38bdac]"}):i.jsx(Lt,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),i.jsxs("div",{className:"space-y-4 py-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"类型ID英文"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:A=>g({...m,id:A.target.value}),disabled:!!h})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"图标"}),i.jsx("div",{className:"flex gap-1 flex-wrap",children:lV.map(A=>i.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===A?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:A}),children:A},A))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"显示名称"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:A=>g({...m,label:A.target.value})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"匹配标签"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:A=>g({...m,matchLabel:A.target.value})})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(te,{className:"text-gray-300",children:"单次匹配价格(元)"}),i.jsx(ce,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:A=>g({...m,price:parseFloat(A.target.value)||1})})]}),i.jsxs("div",{className:"flex gap-6 pt-2",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:m.matchFromDB,onCheckedChange:A=>g({...m,matchFromDB:A})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:m.showJoinAfterMatch,onCheckedChange:A=>g({...m,showJoinAfterMatch:A})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(yt,{checked:m.enabled,onCheckedChange:A=>g({...m,enabled:A})}),i.jsx(te,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),i.jsxs(bn,{children:[i.jsx(re,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),i.jsxs(re,{onClick:F,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const uN={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function dV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[s,a]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[v,j]=b.useState(null);async function w(){m(!0),y(null);try{const C=new URLSearchParams({page:String(s),pageSize:String(o)});u&&C.set("matchType",u);const M=await Be(`/api/db/match-records?${C}`);M!=null&&M.success?(e(M.records||[]),r(M.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{w()},[s,u]);const k=Math.ceil(n/o)||1,E=({userId:C,nickname:M,avatar:D})=>i.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>j(C),children:[i.jsxs("div",{className:"w-9 h-9 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac] flex-shrink-0 overflow-hidden",children:[D?i.jsx("img",{src:D,alt:"",className:"w-full h-full object-cover",onError:F=>{F.currentTarget.style.display="none"}}):null,i.jsx("span",{className:D?"hidden":"",children:(M||C||"?").charAt(0)})]}),i.jsxs("div",{children:[i.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:M||C}),i.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[C==null?void 0:C.slice(0,16),(C==null?void 0:C.length)>16?"...":""]})]})]});return i.jsxs("div",{children:[g&&i.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-500/20 border border-red-500/50 text-red-400 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),i.jsxs("div",{className:"flex justify-between items-center mb-4",children:[i.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("select",{value:u,onChange:C=>{h(C.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[i.jsx("option",{value:"",children:"全部类型"}),Object.entries(uN).map(([C,M])=>i.jsx("option",{value:C,children:M},C))]}),i.jsxs("button",{type:"button",onClick:w,disabled:f,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[i.jsx(qe,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:f?i.jsxs("div",{className:"flex justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs(i.Fragment,{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"发起人"}),i.jsx(ke,{className:"text-gray-400",children:"匹配到"}),i.jsx(ke,{className:"text-gray-400",children:"类型"}),i.jsx(ke,{className:"text-gray-400",children:"联系方式"}),i.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),i.jsxs(pr,{children:[t.map(C=>i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{children:i.jsx(E,{userId:C.userId,nickname:C.userNickname,avatar:C.userAvatar})}),i.jsx(ve,{children:C.matchedUserId?i.jsx(E,{userId:C.matchedUserId,nickname:C.matchedNickname,avatar:C.matchedUserAvatar}):i.jsx("span",{className:"text-gray-500",children:"—"})}),i.jsx(ve,{children:i.jsx(Fe,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:uN[C.matchType]||C.matchType})}),i.jsxs(ve,{className:"text-sm",children:[C.phone&&i.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&i.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&i.jsx("span",{className:"text-gray-600",children:"-"})]}),i.jsx(ve,{className:"text-gray-400",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"})]},C.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),i.jsx(Zr,{page:s,totalPages:k,total:n,pageSize:o,onPageChange:a,onPageSizeChange:C=>{c(C),a(1)}})]})})}),i.jsx(zx,{open:!!v,onClose:()=>j(null),userId:v,onUserUpdated:w})]})}function uV(){const[t,e]=b.useState("records");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>e("records"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="records"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配记录"}),i.jsx("button",{type:"button",onClick:()=>e("pool"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="pool"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"匹配池设置"})]}),t==="records"&&i.jsx(dV,{}),t==="pool"&&i.jsx(cV,{})]})}const hN={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function hV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[s,a]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0),[f,m]=b.useState("investor"),[g,y]=b.useState(null);async function v(){h(!0);try{const E=new URLSearchParams({page:String(s),pageSize:String(o),matchType:f}),C=await Be(`/api/db/match-records?${E}`);C!=null&&C.success&&(e(C.records||[]),r(C.total??0))}catch(E){console.error(E)}finally{h(!1)}}b.useEffect(()=>{v()},[s,f]);const j=async E=>{if(!E.phone&&!E.wechatId){alert("该记录无联系方式,无法推送到存客宝");return}y(E.id);try{const C=await ht("/api/ckb/join",{type:E.matchType||"investor",phone:E.phone||"",wechat:E.wechatId||"",userId:E.userId,name:E.userNickname||""});alert((C==null?void 0:C.message)||(C!=null&&C.success?"推送成功":"推送失败"))}catch(C){alert("推送失败: "+(C instanceof Error?C.message:"网络错误"))}finally{y(null)}},w=Math.ceil(n/o)||1,k=E=>!!(E.phone||E.wechatId);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between items-center mb-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),i.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("select",{value:f,onChange:E=>{m(E.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(hN).map(([E,C])=>i.jsx("option",{value:E,children:C},E))}),i.jsxs(re,{onClick:v,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:u?i.jsxs("div",{className:"flex justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs(i.Fragment,{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"发起人"}),i.jsx(ke,{className:"text-gray-400",children:"匹配到"}),i.jsx(ke,{className:"text-gray-400",children:"类型"}),i.jsx(ke,{className:"text-gray-400",children:"联系方式"}),i.jsx(ke,{className:"text-gray-400",children:"时间"}),i.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),i.jsxs(pr,{children:[t.map(E=>{var C,M;return i.jsxs(ct,{className:`border-gray-700/50 ${k(E)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[i.jsx(ve,{className:"text-white",children:E.userNickname||((C=E.userId)==null?void 0:C.slice(0,12))}),i.jsx(ve,{className:"text-white",children:E.matchedNickname||((M=E.matchedUserId)==null?void 0:M.slice(0,12))}),i.jsx(ve,{children:i.jsx(Fe,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:hN[E.matchType]||E.matchType})}),i.jsxs(ve,{className:"text-sm",children:[E.phone&&i.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&i.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&i.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),i.jsx(ve,{className:"text-gray-400 text-sm",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"}),i.jsx(ve,{className:"text-right",children:k(E)?i.jsxs(re,{size:"sm",onClick:()=>j(E),disabled:g===E.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[i.jsx(mA,{className:"w-3 h-3 mr-1"}),g===E.id?"推送中...":"推送CKB"]}):i.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},E.id)}),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),i.jsx(Zr,{page:s,totalPages:w,total:n,pageSize:o,onPageChange:a,onPageSizeChange:E=>{c(E),a(1)}})]})})})]})}const fN={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},fV={single:"单次",half_year:"半年",year:"年度"};function pV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[s,a]=b.useState("");async function o(){r(!0);try{const c=s?`/api/db/mentor-consultations?status=${s}`:"/api/db/mentor-consultations",u=await Be(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return b.useEffect(()=>{o()},[s]),i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between items-center mb-4",children:[i.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("select",{value:s,onChange:c=>a(c.target.value),className:"bg-[#0f2137] border border-gray-700 rounded-lg px-3 py-2 text-gray-300 text-sm",children:[i.jsx("option",{value:"",children:"全部状态"}),Object.entries(fN).map(([c,u])=>i.jsx("option",{value:c,children:u},c))]}),i.jsxs(re,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50",children:i.jsx(Te,{className:"p-0",children:n?i.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"ID"}),i.jsx(ke,{className:"text-gray-400",children:"用户ID"}),i.jsx(ke,{className:"text-gray-400",children:"导师ID"}),i.jsx(ke,{className:"text-gray-400",children:"类型"}),i.jsx(ke,{className:"text-gray-400",children:"金额"}),i.jsx(ke,{className:"text-gray-400",children:"状态"}),i.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),i.jsxs(pr,{children:[t.map(c=>i.jsxs(ct,{className:"border-gray-700/50",children:[i.jsx(ve,{className:"text-gray-300",children:c.id}),i.jsx(ve,{className:"text-gray-400",children:c.userId}),i.jsx(ve,{className:"text-gray-400",children:c.mentorId}),i.jsx(ve,{className:"text-gray-400",children:fV[c.consultationType]||c.consultationType}),i.jsxs(ve,{className:"text-white",children:["¥",c.amount]}),i.jsx(ve,{className:"text-gray-400",children:fN[c.status]||c.status}),i.jsx(ve,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function mV(){const[t,e]=b.useState("booking");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>e("booking"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="booking"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"预约记录"}),i.jsx("button",{type:"button",onClick:()=>e("manage"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${t==="manage"?"bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/50":"bg-[#0a1628] text-gray-400 border border-gray-700 hover:text-white"}`,children:"导师管理"})]}),t==="booking"&&i.jsx(pV,{}),t==="manage"&&i.jsx("div",{className:"-mx-8",children:i.jsx(NE,{embedded:!0})})]})}function gV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[s,a]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(s),pageSize:String(o),matchType:"team"}),y=await Be(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),r(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}b.useEffect(()=>{f()},[s]);const m=Math.ceil(n/o)||1;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between items-center mb-4",children:[i.jsxs("div",{children:[i.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),i.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),i.jsxs("button",{type:"button",onClick:f,disabled:u,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700/50 transition-colors disabled:opacity-50",children:[i.jsx(qe,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:i.jsx(Te,{className:"p-0",children:u?i.jsxs("div",{className:"flex justify-center py-12",children:[i.jsx(qe,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),i.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i.jsxs(i.Fragment,{children:[i.jsxs(hr,{children:[i.jsx(fr,{children:i.jsxs(ct,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[i.jsx(ke,{className:"text-gray-400",children:"发起人"}),i.jsx(ke,{className:"text-gray-400",children:"匹配到"}),i.jsx(ke,{className:"text-gray-400",children:"联系方式"}),i.jsx(ke,{className:"text-gray-400",children:"时间"})]})}),i.jsxs(pr,{children:[t.map(g=>i.jsxs(ct,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[i.jsx(ve,{className:"text-white",children:g.userNickname||g.userId}),i.jsx(ve,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),i.jsxs(ve,{className:"text-gray-400 text-sm",children:[g.phone&&i.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&i.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),i.jsx(ve,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&i.jsx(ct,{children:i.jsx(ve,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),i.jsx(Zr,{page:s,totalPages:m,total:n,pageSize:o,onPageChange:a,onPageSizeChange:g=>{c(g),a(1)}})]})})})]})}const pN={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},mN={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function xV({onSwitchTab:t,onOpenCKB:e}={}){const n=sa(),[r,s]=b.useState(null),[a,o]=b.useState(null),[c,u]=b.useState(!0),h=b.useCallback(async()=>{var m,g;u(!0);try{const[y,v]=await Promise.allSettled([Be("/api/db/match-records?stats=true"),Be("/api/db/ckb-plan-stats")]);if(y.status==="fulfilled"&&((m=y.value)!=null&&m.success)&&y.value.data){let j=y.value.data;if(j.totalMatches>0&&(!j.uniqueUsers||j.uniqueUsers===0))try{const w=await Be("/api/db/match-records?page=1&pageSize=200");if(w!=null&&w.success&&w.records){const k=new Set(w.records.map(E=>E.userId).filter(Boolean));j={...j,uniqueUsers:k.size}}}catch{}s(j)}v.status==="fulfilled"&&((g=v.value)!=null&&g.success)&&v.value.data&&o(v.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);b.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return i.jsxs("div",{className:"space-y-8",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[i.jsx(Nn,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[i.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-[#38bdac]/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),i.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.totalMatches)}),i.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[i.jsx(Xs,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),i.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-yellow-500/60 transition-all",onClick:()=>t==null?void 0:t("partner"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),i.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.todayMatches)}),i.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[i.jsx(Fi,{className:"w-3 h-3"})," 今日实时"]})]})}),i.jsx(Ee,{className:"bg-gradient-to-br from-[#0f2137] to-[#162d4a] border-gray-700/40 cursor-pointer hover:border-blue-500/60 transition-all",onClick:()=>n("/users"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),i.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.uniqueUsers)}),i.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[i.jsx(Xs,{className:"w-3 h-3"})," 查看用户管理"]})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0"})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-gray-700/40",children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:f(r==null?void 0:r.paidMatchCount)})]})})]})]}),(r==null?void 0:r.byType)&&r.byType.length>0&&i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),i.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:r.byType.map(m=>{const g=r.totalMatches>0?m.count/r.totalMatches*100:0;return i.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx("span",{className:"text-2xl",children:mN[m.matchType]||"📊"}),i.jsx("span",{className:"text-gray-300 font-medium",children:pN[m.matchType]||m.matchType})]}),i.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),i.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),i.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),i.jsxs("div",{children:[i.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[i.jsx(Gs,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[i.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.ckbTotal)??0}),i.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.withContact)??0}),i.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),i.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:i.jsxs(Te,{className:"p-6",children:[i.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),i.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),i.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(a==null?void 0:a.byType)&&a.byType.length>0&&i.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:a.byType.map(m=>i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsx("span",{className:"text-xl",children:mN[m.matchType]||"📋"}),i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 text-xs",children:pN[m.matchType]||m.matchType}),i.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const yV=["partner","investor","mentor","team"],ag=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],gN=`# 场景获客接口摘要
- 地址POST /v1/api/scenarios
- 必填apiKey、sign、timestamp
- 主标识phone 或 wechatId 至少一项
- 可选name、source、remark、tags、siteTags、portrait
- 签名:排除 sign/apiKey/portrait键名升序拼接值后双重 MD5
- 成功code=200message=新增成功 或 已存在`;function vV({initialTab:t="overview"}){const[e,n]=b.useState(t),[r,s]=b.useState("13800000000"),[a,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(gN),[m,g]=b.useState(!1),[y,v]=b.useState(!1),[j,w]=b.useState([]),[k,E]=b.useState([]),[C,M]=b.useState({}),[D,F]=b.useState([{endpoint:"/api/ckb/join",label:"找伙伴",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"资源对接",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"导师顾问",method:"POST",status:"idle"},{endpoint:"/api/ckb/join",label:"团队招募",method:"POST",status:"idle"},{endpoint:"/api/ckb/match",label:"匹配上报",method:"POST",status:"idle"},{endpoint:"/api/miniprogram/ckb/lead",label:"链接卡若",method:"POST",status:"idle"},{endpoint:"/api/match/config",label:"匹配配置",method:"GET",status:"idle"}]),R=b.useMemo(()=>{const _={};return ag.forEach($=>{_[$.key]=C[$.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),_},[C]),I=_=>{const $=r.trim(),oe=a.trim();return _<=3?{type:yV[_],phone:$||void 0,wechat:oe||void 0,userId:"admin_test",name:"后台测试"}:_===4?{matchType:"partner",phone:$||void 0,wechat:oe||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:_===5?{phone:$||void 0,wechatId:oe||void 0,userId:"admin_test",name:"后台测试"}:{}};async function A(){v(!0);try{const[_,$,oe]=await Promise.all([Be("/api/db/config/full?key=ckb_config"),Be("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Be("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),V=_==null?void 0:_.data;V!=null&&V.routes&&M(V.routes),V!=null&&V.docNotes&&u(V.docNotes),V!=null&&V.docContent&&f(V.docContent),$!=null&&$.success&&w($.records||[]),oe!=null&&oe.success&&E(oe.records||[])}finally{v(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{A()},[]);async function O(){g(!0);try{const _=await ht("/api/db/config",{key:"ckb_config",value:{routes:R,docNotes:c,docContent:h},description:"存客宝接口配置"});alert((_==null?void 0:_.success)!==!1?"存客宝配置已保存":`保存失败: ${(_==null?void 0:_.error)||"未知错误"}`)}catch(_){alert(`保存失败: ${_ instanceof Error?_.message:"网络错误"}`)}finally{g(!1)}}const W=(_,$)=>{M(oe=>({...oe,[_]:{...R[_],...$}}))},X=async _=>{const $=D[_];if($.method==="POST"&&!r.trim()&&!a.trim()){alert("请填写测试手机号");return}const oe=[...D];oe[_]={...$,status:"testing",message:void 0,responseTime:void 0},F(oe);const V=performance.now();try{const ae=$.method==="GET"?await Be($.endpoint):await ht($.endpoint,I(_)),Y=Math.round(performance.now()-V),L=(ae==null?void 0:ae.message)||"",H=(ae==null?void 0:ae.success)===!0||L.includes("已存在")||L.includes("已加入")||L.includes("已提交"),ue=[...D];ue[_]={...$,status:H?"success":"error",message:L||(H?"正常":"异常"),responseTime:Y},F(ue),await A()}catch(ae){const Y=Math.round(performance.now()-V),L=[...D];L[_]={...$,status:"error",message:ae instanceof Error?ae.message:"失败",responseTime:Y},F(L)}},q=async()=>{if(!r.trim()&&!a.trim()){alert("请填写测试手机号");return}for(let _=0;_<D.length;_++)await X(_)},Z=(_,$)=>i.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:i.jsxs("tr",{children:[i.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),i.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),i.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),i.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),i.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),i.jsx("tbody",{children:_.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:$})}):_.map(oe=>i.jsxs("tr",{className:"border-t border-gray-700/30",children:[i.jsx("td",{className:"px-4 py-3 text-white",children:oe.userNickname||oe.userId}),i.jsx("td",{className:"px-4 py-3 text-gray-300",children:oe.matchType}),i.jsx("td",{className:"px-4 py-3 text-green-400",children:oe.phone||"—"}),i.jsx("td",{className:"px-4 py-3 text-blue-400",children:oe.wechatId||"—"}),i.jsx("td",{className:"px-4 py-3 text-gray-400",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"—"})]},oe.id))})]})});return i.jsx(Ee,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:i.jsxs(Te,{className:"p-5",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),i.jsx(Fe,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),i.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[i.jsx(Xs,{className:"w-3 h-3"})," API 文档"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(re,{onClick:()=>A(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[i.jsx(qe,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),i.jsxs(re,{onClick:O,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[i.jsx(rn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),i.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([_,$])=>i.jsx("button",{type:"button",onClick:()=>n(_),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===_?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:$},_))}),e==="overview"&&i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[i.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:j.length})]}),i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[i.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:k.length})]}),i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[i.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),i.jsx("p",{className:"text-3xl font-bold text-white",children:ag.length})]}),i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[i.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),i.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&Z(j,"暂无已提交线索"),e==="contact"&&Z(k,"暂无有联系方式线索"),e==="config"&&i.jsx("div",{className:"space-y-4",children:ag.map(_=>i.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-white font-medium",children:_.label}),i.jsx(Fe,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:_.key})]}),i.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"API 地址"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].apiUrl,onChange:$=>W(_.key,{apiUrl:$.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"API Key"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].apiKey,onChange:$=>W(_.key,{apiKey:$.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"Source"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].source,onChange:$=>W(_.key,{source:$.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"Tags"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].tags,onChange:$=>W(_.key,{tags:$.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"SiteTags"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].siteTags,onChange:$=>W(_.key,{siteTags:$.target.value})})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"说明备注"}),i.jsx(ce,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:R[_.key].notes,onChange:$=>W(_.key,{notes:$.target.value})})]})]})]},_.key))}),e==="test"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[i.jsx(kc,{className:"w-4 h-4 text-gray-500 shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"测试手机号"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:_=>s(_.target.value)})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[i.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),i.jsxs("div",{className:"flex-1",children:[i.jsx(te,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),i.jsx(ce,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:a,onChange:_=>o(_.target.value)})]})]}),i.jsx("div",{className:"flex items-end",children:i.jsxs(re,{onClick:q,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[i.jsx(Fi,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:D.map((_,$)=>i.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[_.status==="idle"&&i.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),_.status==="testing"&&i.jsx(qe,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),_.status==="success"&&i.jsx(hg,{className:"w-3 h-3 text-green-400 shrink-0"}),_.status==="error"&&i.jsx(PN,{className:"w-3 h-3 text-red-400 shrink-0"}),i.jsx("span",{className:"text-white text-xs truncate",children:_.label})]}),i.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[_.responseTime!==void 0&&i.jsxs("span",{className:"text-gray-600 text-[10px]",children:[_.responseTime,"ms"]}),i.jsx("button",{type:"button",onClick:()=>X($),disabled:_.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${_.endpoint}-${$}`))})]}),e==="doc"&&i.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),i.jsxs("a",{href:"https://ckbapi.quwanzhi.com/v1/api/scenarios",target:"_blank",rel:"noreferrer",className:"text-orange-400/70 hover:text-orange-400 text-xs flex items-center gap-1",children:[i.jsx(Xs,{className:"w-3 h-3"})," 打开外链"]})]}),i.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||gN})]}),i.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[i.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),i.jsx("textarea",{className:"w-full min-h-[260px] bg-[#0f2137] border border-gray-700 rounded-md text-sm text-gray-300 p-3 outline-none focus:border-orange-500/50 resize-y",value:c,onChange:_=>u(_.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const bV=[{id:"stats",label:"数据统计",icon:AT},{id:"partner",label:"找伙伴",icon:Nn},{id:"resource",label:"资源对接",icon:fM},{id:"mentor",label:"导师预约",icon:dM},{id:"team",label:"团队招募",icon:yg}];function wV(){const[t,e]=b.useState("stats"),[n,r]=b.useState(!1),[s,a]=b.useState("overview");return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[i.jsx(Nn,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),i.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),i.jsxs(re,{type:"button",variant:"outline",onClick:()=>r(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[i.jsx(Gs,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&i.jsx(vV,{initialTab:s}),i.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:bV.map(o=>{const c=t===o.id;return i.jsxs("button",{type:"button",onClick:()=>e(o.id),className:`flex items-center gap-2 px-5 py-2.5 rounded-md text-sm font-medium transition-all ${c?"bg-[#38bdac] text-white shadow-lg":"text-gray-400 hover:text-white hover:bg-gray-700/50"}`,children:[i.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&i.jsx(xV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{a(o||"overview"),r(!0)}}),t==="partner"&&i.jsx(uV,{}),t==="resource"&&i.jsx(hV,{}),t==="mentor"&&i.jsx(mV,{}),t==="team"&&i.jsx(gV,{})]})}function NV(){return i.jsxs("div",{className:"p-8 w-full",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[i.jsx(Gs,{className:"w-8 h-8 text-[#38bdac]"}),i.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),i.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"1. 接口总览"})}),i.jsxs(Te,{className:"space-y-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),i.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[i.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),i.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),i.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),i.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),i.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),i.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),i.jsx("li",{children:"/api/config — 配置系统"})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),i.jsx("p",{className:"text-gray-300",children:"用户Cookie session_id可选"}),i.jsx("p",{className:"text-gray-300",children:"管理端Authorization: Bearer admin-token-secret"})]})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"2. 书籍内容"})}),i.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[i.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),i.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),i.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"3. 支付"})}),i.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[i.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),i.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),i.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"4. 分销与用户"})}),i.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[i.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),i.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),i.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),i.jsxs(Ee,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[i.jsx(et,{children:i.jsx(tt,{className:"text-white",children:"5. 管理后台"})}),i.jsxs(Te,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[i.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),i.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),i.jsx("p",{children:"GET /api/orders — 订单列表"})]})]}),i.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function jV(){const t=ra();return i.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:i.jsxs("div",{className:"text-center max-w-md",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-red-500/20 text-red-400 mb-6",children:i.jsx(zT,{className:"w-10 h-10"})}),i.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),i.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),i.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),i.jsx(re,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:i.jsxs(ug,{to:"/",children:[i.jsx(jM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function kV(){return i.jsxs(iT,{children:[i.jsx(Mt,{path:"/login",element:i.jsx(HR,{})}),i.jsxs(Mt,{path:"/",element:i.jsx(KA,{}),children:[i.jsx(Mt,{index:!0,element:i.jsx(um,{to:"/dashboard",replace:!0})}),i.jsx(Mt,{path:"dashboard",element:i.jsx(ZI,{})}),i.jsx(Mt,{path:"orders",element:i.jsx(eP,{})}),i.jsx(Mt,{path:"users",element:i.jsx(tP,{})}),i.jsx(Mt,{path:"distribution",element:i.jsx(jP,{})}),i.jsx(Mt,{path:"withdrawals",element:i.jsx(kP,{})}),i.jsx(Mt,{path:"content",element:i.jsx(VB,{})}),i.jsx(Mt,{path:"referral-settings",element:i.jsx(vk,{})}),i.jsx(Mt,{path:"author-settings",element:i.jsx(um,{to:"/settings?tab=author",replace:!0})}),i.jsx(Mt,{path:"admin-users",element:i.jsx(um,{to:"/settings?tab=admin",replace:!0})}),i.jsx(Mt,{path:"vip-roles",element:i.jsx(aV,{})}),i.jsx(Mt,{path:"mentors",element:i.jsx(NE,{})}),i.jsx(Mt,{path:"mentor-consultations",element:i.jsx(oV,{})}),i.jsx(Mt,{path:"settings",element:i.jsx(YB,{})}),i.jsx(Mt,{path:"payment",element:i.jsx(QB,{})}),i.jsx(Mt,{path:"site",element:i.jsx(tV,{})}),i.jsx(Mt,{path:"qrcodes",element:i.jsx(nV,{})}),i.jsx(Mt,{path:"find-partner",element:i.jsx(wV,{})}),i.jsx(Mt,{path:"match",element:i.jsx(sV,{})}),i.jsx(Mt,{path:"match-records",element:i.jsx(iV,{})}),i.jsx(Mt,{path:"api-doc",element:i.jsx(NV,{})})]}),i.jsx(Mt,{path:"*",element:i.jsx(jV,{})})]})}d3.createRoot(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(fT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:i.jsx(kV,{})})}));